Embercode
✕
Binary TreesQuick quiz

Complete trees in arrays

7 questions. Covers Complete, full and perfect trees in arrays with Python.

Questions 1 to 5 of 7

  1. 1. A complete tree has 12 nodes and is stored in an array of 12 positions. Which index is the first leaf?
  2. 2. What does this print? ``python def height_of_complete(n): return n.bit_length() - 1 print(height_of_complete(64)) ``
  3. 3. A completeness check walks the tree one level at a time. It adds None to the queue for each missing child, so that it can see the gap. Which statement is true in Python?
  4. 4. Which arrays does is_complete_array return True for? ``python def is_complete_array(arr): seen_none = False for item in arr: if item is None: seen_none = True elif seen_none: return False return True ``

    Pick every answer that is true.

  5. 5. Which statements about full, complete and perfect trees are true?

    Pick every answer that is true.

5 question(s) left on this page.