What is the space complexity of a breadth-first traversal of a binary tree?

Practice Questions

1 question
Q1
What is the space complexity of a breadth-first traversal of a binary tree?
  1. O(n)
  2. O(log n)
  3. O(1)
  4. O(n log n)

Questions & Step-by-step Solutions

1 item
Q
Q: What is the space complexity of a breadth-first traversal of a binary tree?
Solution: The space complexity of a breadth-first traversal is O(n) because it needs to store all nodes at the current level in the queue.
Steps: 6

Related Questions

Soulshift Feedback ×

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

Not likely Very likely