Ask Question
4 November, 04:58

After class a student asked why you would ever use a heap instead of a binary search tree. Provide a good explanation for why and when you would.

+1
Answers (1)
  1. 4 November, 06:55
    0
    Heap is useful when you want to find max/min element in the given list

    BinarySearchTree is used if you need sorted elements of the list

    Explanation:

    Heap is Good at finding Min/Max and it's time complexity is (O (1)), while BST is good at all finds (O (logN)). Insert is O (logN) for Heap and BSTstructures ...

    Max Heap ensures that elements on higher levels are greater than elements at lower level

    MinHeap ensures that elements on higher levels are lesser than elements at lower level

    BST gives sorted elements by following order (left, root, right). If we want sorted elements we can go with BST
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “After class a student asked why you would ever use a heap instead of a binary search tree. Provide a good explanation for why and when you ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers