2c03-review - 00006

2c03-review - 00006 - 7.[10] procedure PREPOST( a 1 ,a 2...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
3 9 5 3 1 2 4 8 6 7 4.[10] Final solution (without all the steps) 5.[10] a.[4] BFS: 11,12,3,4,5,7,14,15,10,1,2,13,8,9,16 DFS: 11,12,7,8,14,3,15,9,4,10,1,16 b.[5] preorder: 11,12,7,8,14,3,15,9,4,10,1,16,17,2,5,13 postorder: 8,7,12,14,9,15,3,10,16,17,1,2,4,13,5,1 inorder: 8,7,12,14,11,9,15,3,10,4,16,1,17,4,2,13,5 6.[10] a.[5] O(f(n)+g(n))=O(n 3 ), since logn<n for n>1. b.[5] O(f(n)g(n)) = O(n 4 logn), from the result of multiplication.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 7.[10] procedure PREPOST( a 1 ,a 2 ,...,a n ); begin if n=1 then print(a n ) else begin PREPOST(a 2 ,a 3 ,...,a (n+1)/2 ); PREPOST(a (n+3)/2 ,a 2 ,...,a n ); print(a 1 ) end end T(n) = 2 T((n-1)/2)+O(1) = O(n), for both pointer and array implementation. The algorithm does not have to recursive, and can be explain in plan English....
View Full Document

This note was uploaded on 12/10/2009 for the course CAS 2c03 taught by Professor Janicki during the Spring '03 term at McMaster University.

Ask a homework question - tutors are online