Home
51.
Describe the inorder traversal algorithm.
Inorder traversal gets its name from the fact that it visits the root in between visiting the left and right subtrees. The steps are the following:
  1. traverse the left subtree
  2. visit the root
  3. traverse the right subtree
52.
What is the difference between a max-heap and a min-heap?
  1. A max-heap respects the property that if B is a child node of A, then key( A) >= key(B) - the greatest key is always in the root node
  2. A min-heap respects the property that if B is a child node of A, then key( A) <= key(B) - the smallest key is always in the root node
53.
What is a heap?

A heap is a specialized tree-based data structure that satisfies the heap property:
if B is a child node of A, then key(A) >= key(B). This implies that an element with the greatest key is always in the root node.

54.
Describe the breadth-first traversal algorithm.

The breadth-first traversal of a tree visits the nodes in the order of their depth in the tree. Breadth-first traversal first visits all the nodes at depth zero (i.e. the root), then all the nodes at depth one, and so on. At each depth the nodes are visited from left to right.

55.
Describe the postorder traversal algorithm.

Postorder traversal gets its name from the fact that it visits the root last. The steps are the following:

  1. traverse the left subtree
  2. traverse the right subtree
  3. visit the root