Binary Trees and Traversals - Implementations in Python

Download Q&A
Q. What is the main difference between a binary tree and a binary search tree?
  • A. Binary trees can have duplicate values, binary search trees cannot
  • B. Binary search trees are always balanced, binary trees are not
  • C. Binary search trees have a specific ordering property, binary trees do not
  • D. There is no difference
Q. What is the space complexity of a recursive implementation of binary tree traversal?
  • A. O(n)
  • B. O(log n)
  • C. O(1)
  • D. O(n log n)
Q. Which of the following is a valid way to implement a binary tree node in Python?
  • A. class Node: def __init__(self, value): self.value = value
  • B. class Node: def __init__(self, value): self.value = value; self.left = None; self.right = None
  • C. class Node: def __init__(self): self.value = None
  • D. class Node: def __init__(self, value): self.left = None; self.right = None
Q. Which of the following is true about the height of a binary tree?
  • A. Height is the number of nodes in the longest path from root to leaf
  • B. Height is the number of edges in the longest path from root to leaf
  • C. Height is always equal to the number of levels in the tree
  • D. Height can be negative
Q. Which traversal method would you use to get the nodes of a binary tree in pre-order?
  • A. Visit left, visit right, visit node
  • B. Visit node, visit left, visit right
  • C. Visit right, visit left, visit node
  • D. Visit node, visit right, visit left
Showing 1 to 5 of 5 (1 Pages)
Soulshift Feedback ×

On a scale of 0–10, how likely are you to recommend The Soulshift Academy?

Not likely Very likely