Write C code for iterative preorder, inorder and postorder tree traversals

October 28, 2007 · Filed Under Placement Questions, Tree

Here is a complete C program which prints a BST using both recursion and iteration. The best way to understand these algorithms is to get a pen and a paper and trace out the traversals (with the stack or the queue) alongside. Dont even try to memorize these algorithms!
#include
typedef struct node
{
int value;
[…]

Read the rest of this entry »