← Binary Trees & BST Quiz: all 8 questions
Binary Trees & BST Quiz · Question 8 of 8
What is the time complexity of visiting every node of a binary tree with n nodes?
What is the time complexity of visiting every node of a binary tree with n nodes?
- A.O(log n)
- B.O(n)
- C.O(n log n)
- D.O(n²)
Answer & explanation
Correct answer: O(n)
Each node is visited once.
Can you get the rest right without peeking?
Take the timed Binary Trees & BST Quiz quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →