This preview shows page 1. Sign up to view the full content.
Unformatted text preview: 7. 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.
- Spring '03