What are advantage(s) of a heap for storing a priority queue, compared to an AVL tree?

  • A: faster Big O
  • B: simpler code
  • C: uses less memory
  • D: A and B
  • E: B and C

    Answer: E

    A heap involves relatively simple code, compared to the complex code to handle an AVL tree. The heap also saves memory: whereas the AVL tree has two pointers and a balance code for each node, the heap uses an array and can compute pointers from array indexes; thus it uses no storage for pointers.

    Contents    Page-10    Prev    Next    Page+10    Index