exam1_solution - COP 3530 Midterm, Part 1 (Mar 3, 2008)...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: COP 3530 Midterm, Part 1 (Mar 3, 2008) SOLUTION: . 1. (10 points) Define the term in-place , as it applies to sorting algorithms. Give an example of a sorting method that is not in-place. Solution: An in-place sorting algorithm uses no extra workspace. Merge-sort is not in-place. 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.

Page1 / 2

exam1_solution - COP 3530 Midterm, Part 1 (Mar 3, 2008)...

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

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