Skip to main content
ICT
Lesson AB30 - Binary Search Trees
 
Main Previous Next
Title Page >  
Summary >  
Lesson A1 >  
Lesson A2 >  
Lesson A3 >  
Lesson A4 >  
Lesson A5 >  
Lesson A6 >  
Lesson A7 >  
Lesson A8 >  
Lesson A9 >  
Lesson A10 >  
Lesson A11 >  
Lesson A12 >  
Lesson A13 >  
Lesson A14 >  
Lesson A15 >  
Lesson A16 >  
Lesson A17 >  
Lesson A18 >  
Lesson A19 >  
Lesson A20 >  
Lesson A21 >  
Lesson A22 >  
Lesson AB23 >  
Lesson AB24 >  
Lesson AB25 >  
Lesson AB26 >  
Lesson AB27 >  
Lesson AB28 >  
Lesson AB29 >  
Lesson AB30 >  
Lesson AB31 >  
Lesson AB32 >  
Lesson AB33 >  
Vocabulary >  
 

E. Preorder and Postorder Tree Traversals page 7 of 15

  1. A preorder tree traversal processes each node in a different order.

    • Visit the node
    • Process the left subtree preorder
    • Process the right subtree preorder

    The only difference is that we visit the root first, then go left, then right. The preorder output of the same binary tree will be:

    26 14 9 21 79 53 35 99 87

  2. A postorder tree traversal has this order:

    • Process the left subtree postorder
    • Process the right subtree postorder
    • Visit the node

    The prefix “post” refers to after, hence the location of visiting the node after the recursive calls. The printout of the same tree will be as follows:

    9 21 14 35 53 87 99 79 26

 

 

Main Previous Next
Contact
 © ICT 2006, All Rights Reserved.