🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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?

  1. A.O(log n)
  2. B.O(n)
  3. C.O(n log n)
  4. 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 →