Hello!
I never came across a binary heap, but I got it on a dz to implement using an array and a linked list on java
There were no problems with the array, as there you can reach each memory area
But with a coherent list, I have no idea how to add an element to the heap?
How to "go through" the list to the very element to which you want to add a new heap element?
Which structure is best suited to the heap:
- Kucha: a pointer to the head of a balanced tree, which is represented by a separate class and has a left son, right son, information that is stored in this root.
- Kucha: information in the root, left son, right son
And another question, how to build a balanced tree? What is the algorithm of its construction, how to check the "balance" through a linear list?
Perhaps, somewhere there is an example where a tree has already been built on Java using a linked list, but I haven’t found anything on this topic. I would be grateful if you point me to the source.
Yes, I understand, I study for a programmer and I have to reproduce it all myself, these are the basics, but for the first time I’ve dealt with it and haven’t seen a balanced heap on the basis of a coherent list, even in theory we weren’t told about it, we just threw dz, Deadline and gave a link to Wikipedia, please treat with understanding.