{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

exercise4 - sorted sequence which contains exactly the...

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

View Full Document Right Arrow Icon
Algorithm and Data Structures Assignment 4 Dr. Andreas N¨uchter Fall 2009 Exercise 4.1 Improve the algorithm insertion sort . Use binary search to identify the position where the element has to be inserted. Show that in this case holds: C max ( N ) = Θ( N log N ) M max ( N ) = Θ( N 2 ) Exercise 4.2 In lecture we have covered the sorting algorithm shell sort (cf. slides 148–151). 1. Execute shell sort using the increments h 3 = 5, h 2 = 2 and h 1 = 1 on the sequence of keys 14 4 5 7 17 3 6 9 Please denote all comparison and movement operations. 2. Show: If h > k then a k -sorted list does not imply that the list is h -sorted. Exercise 4.3 Let A and B be two finite sequences of sorted numbers. 1. Describe an algorithm in pseudocode that merges these two sequences, i.e., that constructs a
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
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: sorted sequence which contains exactly the elements of both input sequences! 2. Calculate the number of comparisons in your algorithm depending on the length of the input sequences! For the following parts assume that the number of elements in the input list of mergesort is a power of two. 3. Estimate the order of the number of comparisons of the mergesort algorithm! 1 4. Discuss the disadvatages of mergesort and describe an algorithm in pseudocode that imple-ments an iterative procedure, i.e., does not need recursion!. Please hand in the solutions on October 1 right before class. Use your own handwriting! Late homework will not be accepted. 2...
View Full Document

{[ snackBarMessage ]}