{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

quiz3soln - > True False • Binary search always be...

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

View Full Document Right Arrow Icon
1 Quiz 3 Solution CpE 360 – Computational Algorithms and Data Structures Instructor: Ashish Patel November 21, 2006 (Close notes, close books. Circle on your answers) 1. Represent the following arithmetic expression into Binary tree. ((x + y) * (p - q)/r) - s 2. Represent the following Binary tree using array representation. A B C D E 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 A B C D E s * / + x y - r p q
Background image of page 1

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

View Full Document Right Arrow Icon
2 3. What is the pre-order, post-order and in-order traversal for the binary tree? Pre-order traversal - (PLR): A, B, D, E, G, C, F Post-order traversal - (LRP): D, G, E, B, F, C, A In-order traversal - (LPR): D, B, E, G, A, C, F 4. True of False? (Circle on your Answers) The binary search algorithm eliminates three-quarters of the elements in the array being searched after each comparison.
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ---> True False • Binary search always be faster than linear search, even on a large data set. ---> True False For example, if the item being searched for is the first item in the list, the linear search will find it on its first look, while binary search will take the maximum number of looks, logn . • The best-case time complexity of binary search is in O(1). ---> True False • On average, the linear search algorithm will have to compare the search key with half of the elements in the array. ---> True False • • A complete binary tree has a natural representation in an array. ---> True False • The worst-case time complexity of binary search is in O(log n). ---> True False A B C D F E G...
View Full Document

{[ snackBarMessage ]}

Page1 / 2

quiz3soln - > True False • Binary search always be...

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

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