notes11 - CSE 2320 Notes 11: Rooted Trees (Last updated...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
CSE 2320 Notes 11: Rooted Trees (Last updated 10/30/11 2:56 PM) Sedgewick 5.4-5.7, 12.5-12.9 11.A. T REES Representing Trees (main memory, disk devices in CSE 3330) Binary tree Mandatory Left Right Optional Parent Key Data Subtree Size Key Left Right A B C D Rooted tree with linked siblings D B A C E F G H I D B E F A C G H I Mandatory Optional First Child Last Child Right Sibling Left Sibling Parent Key Data Subtree Size
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 11.B. Binary Tree Traversals (review) 1 st Visit – Preorder 2 nd Visit – Inorder 3 rd Visit – Postorder 1 2 3 D B A C E F G H I recTraversal(Node h) { if (h!=null) { recTraversal(h.l); recTraversal(h.r); } } Preorder D B C E H F A I G Inorder C B H E D A G I F Postorder C H E B G I A F D 11.C. B INARY S EARCH T REES Basic property – Go left for smaller keys. Go right for larger keys. (Use of sentinel) Which traversal lists the keys in ascending order? 120 21 20 11 140 4 10 1 70 9 150 1 40 4 30 1 50 2 60 1 160 2 170 9 key size (N in Sedgewick) 130 1 90 4 100 1 110 2 80 1 190 4 200 1 210 2 180 1
Background image of page 2
3 120 21 20 11 140 4 10 1 70 9 150 1 40 4 30 1 50 2 60 1 160 2 170 9 130 1 90
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 6

notes11 - CSE 2320 Notes 11: Rooted Trees (Last updated...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online