2

Please let me know the Big Oh of the above.

Prasoon Saurav
  • 91,295
  • 49
  • 239
  • 345
user465983
  • 115
  • 5
  • 13
  • Wouldn't the time complexity depend on the type of tree? Could you elaborate on that point? –  Oct 17 '10 at 14:25

1 Answers1

1

Think about how an algorithm executing these traversals would look like - what data structure would you use (stack, queue, something else?) and how many operations would you need to execute for processing each node in the tree? Would you ever have to process a node in the tree twice at all?

BrokenGlass
  • 158,293
  • 28
  • 286
  • 335