This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: COP 3530 Midterm, Part 1 (Mar 3, 2008) SOLUTION: . 1. (10 points) Define the term inplace , as it applies to sorting algorithms. Give an example of a sorting method that is not inplace. Solution: An inplace sorting algorithm uses no extra workspace. Mergesort is not inplace. 2. (15 points) Suppose you are searching for an item that appears more than once in the list. Which one will be found by a sequential (linear time) search? Which one will be found by a binary search? Answer as precisely as possible. Solution: Assuming the sequential search goes from i = 0 to n 1, the value with the smallest index will be found. For binary search, there is no guarantee which will be returned. 3. (20 points) Write an algorithm that takes as input an array of n real numbers that is known to be sorted in ascending order, and sorts the array in descending order instead. You may assume that n is even. Use no additional size n workspace. What is the time complexity of your algorithm?...
View
Full
Document
This test prep was uploaded on 04/18/2008 for the course COP 3530 taught by Professor Davis during the Spring '08 term at University of Florida.
 Spring '08
 Davis
 Algorithms, Data Structures, Sort

Click to edit the document details