TreeTraversal2

TreeTraversal2 - preOrder(TreeNode t) cfw_ if(t = null)...

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

View Full Document Right Arrow Icon
preOrder(TreeNode t) { if(t == null) return; print(t.data); preOrder(t.left); preOrder(t.right); } inOrder(TreeNode t) { if(t == null) return; inOrder(t.left); print(t.data); inOrder(t.right); } postOrder(TreeNode t) { if(t == null) return; postOrder(t.left); postOrder(t.right); print(t.data); } 60 20 70 10 40 30 50
Background image of page 1

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

View Full DocumentRight Arrow Icon
preOrder(60) print(60) preOrder(20) print(20) preOrder(10) print(10) preOrder(null) preOrder(null) preOrder(40) print(40) preOrder(30) print(30) preOrder(null) preOrder(null) preOrder(50) print(50) preOrder(null) preOrder(null) preOrder(70) print(70) preOrder(null) preOrder(null)
Background image of page 2
inOrder(60) inOrder(20) inOrder(10) inOrder(null) print(10) inOrder(null) print(20) inOrder(40) inOrder(30) inOrder(null) print(30) inOrder(null) print(40) inOrder(50) inOrder(null) print(50) inOrder(null) print(60) inOrder(70) inOrder(null) print(70) inOrder(null)
Background image of page 3

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

View Full DocumentRight Arrow Icon
postOrder(60) postOrder(20) postOrder(10) postOrder(null) postOrder(null) print(10) postOrder(40) postOrder(30) postOrder(null) postOrder(null) print(30) postOrder(50) postOrder(null) postOrder(null) print(50) print(40) print(20) postOrder(70) postOrder(null) postOrder(null) print(70) print(60)
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 09/21/2009.

Page1 / 21

TreeTraversal2 - preOrder(TreeNode t) cfw_ if(t = null)...

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

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