{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Discrete Mathematics with Graph Theory (3rd Edition) 238

Discrete Mathematics with Graph Theory (3rd Edition) 238 -...

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

View Full Document Right Arrow Icon
236 Solutions to Exercises 19. As mentioned in the text and illustrated in Problem 26, the maximum number of comparisons occurs when just one element remains in one list at the time the other is emptied. Thus an example exists for any s and t. Let /:.;2: bl :::; b2 :::; ... :::; b t be any ordered list of length t. Then choose /:.;1: al :::; a2 :::; ... :::; as with as-l < b t < as. This ensures that as is the only remaining element at the time that /:.;2 is emptied. 20. The most efficient sorting algorithm is 0 (n log n). Thus sorting and then applying a binary search is o ( n log n + log n) = 0 ( n log n). Since n ::::5 n log n, this is less efficient than a linear search. 21. [BB] The answer is min { s, t}. It is impossible to have fewer than this number of comparisons since until min { s, t} of comparisons have been made, elements remain in each list. To see that min { s, t} can be achieved, consider ordered lists aI, a2, ... , as and bl, b2, ... , b t where s < t and as < bl. After s comparisons, the first list is empty.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}