Write a non-recursive traversal of a Binary Search Tree using constant space and O(n) run time

后端 未结 10 2226
刺人心
刺人心 2020-12-07 11:44

This is not homework, this is an interview question.

The catch here is that the algorithm should be constant space. I\'m pretty clueless on how to d

10条回答
  •  执笔经年
    2020-12-07 11:49

    Accepted answer needs the following change otherwise it will not print the tree where the BST only has one node

    if (current == NULL && root != NULL)
       print(root);
    

提交回复
热议问题