CPSC 2120 - DAY 6 MAY 18, 2016 ================================================================================ preorder(Node T) { if(T == null) return; T.visit(); preorder(T.lchild); preorder(T.rchild); } main () { preorder(root); } Recursion is good for building prototypes. Used for smaller lines of code, albeit less efficient postorder(Node T) { if(T == null) return; postorder(T.lchild); postorder(T.rchild); T.visit(); } K-ary Trees A tree that has degree k In order on a binary matches postorder on a K-ary tree Know how to convert k-ary to binary tree QUEUES ex. a line at a movie theater Enqueue, Dequeue, Peek, isEmpty Dequeue - take first off and work on it, enqueue - puts it back on the queue Ways of implementing a queue - Using a Vector/Array requires estimate of maximum queue length may grow dynamically empty slots can contain varied data (not necessarily homogeneous)