Question

2)A heap is a binary tree. What operations does a heap add to the BinaryTree interface?...

2)A heap is a binary tree. What operations does a heap add to the BinaryTree interface?

3) When does a 2-node become a 3-node?

4) Is every tree a graph? Is every graph a tree? Explain

0 0
Add a comment Improve this question Transcribed image text
Answer #1

2. A heap can be called a Binary Tree which satisfies the heap ordering properties.

  • It can be called complete tree because all the levels are filled expect may be the last level and the last level as all the keys left as possible. The actual property of binary heap is stored in the form of array.
  • The Binary Tree can be either Max Heap or Min Heap. In case of Min heap, the key should be minimum among all the keys present in that Binary Tree. And this property should be recursively true for all the nodes present in that Tree.

We can insert new items at the end of the tree. If the new items are greater than its parent, then we need not to do anything. Otherwise, we need to traverse through the parent to fix the violated heap property.

3. In case of a two node tree, it has one data element and it should have two child nodes. But in case of 3 nodes, it should have two data elements and should have three child nodes.

So, when we insert new key at the lowest internal nodes, then it becomes a 2-3 tree. Thus a B-tree of order 3 is termed as a 2-3 tree. Nodes on the outside of that tree should not have any children and one or two data elements.

4. Yes, every tree is a graph but every graph is not a tree.

Let maximum number of edges present in a graph:

E(G) = n(n-1)/2;    where G represents graph

And the max no. of edges in a tree:

E(T) = (n-1);      where T is the tree

By comparing the above equations, we can convey that Every tree is a graph but every graph is not a tree. Moreover, graph can have cycles and loops and can have many paths to the vertices. But in case of tree the vertices should have one path connecting between them.

Add a comment
Know the answer?
Add Answer to:
2)A heap is a binary tree. What operations does a heap add to the BinaryTree interface?...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT