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: CS20: Midterm #2 May 17, 2004 NAME______________________________ 1. (7 points) Using Big Oh notation, what is the order of the following computation's time requirement? for i = 1 to n { for j = 1 to 5 Answer: O(n) sum = sum + 1 } 2. (8 points) Reduce the following Big Oh values: a) 6n 2 Answer: n 2 b) n 2 Answer: n 2 c) 5n 3 + 100n 2 n  10 Answer: n 3 d) 3n 2 + 2 n Answer: 2 n 3. (18 points) For each of the array sorting algorithms listed below, fill in the blanks for each of the questions. For description, fill in the the letter af that corresponds to the correct definition listed below. a.This is an algorithm that sorts entries into bins based on the digits or letters of the entries. There are multiple passes, starting with the least significant and moving to the most significant digit or character. b. This sort is accomplished by finding the smallest (or largest) element of the list and swapping it with the first (or last) element. Then, ignoring that element, the process is repeated. c. This sort compares the first two elements of the list. If they are out of order, they are swapped. Then taking the second of the two, it is compared with the element following it, and the process is repeated until the largest...
View
Full
Document
This note was uploaded on 04/08/2008 for the course CS 20 taught by Professor Agrawal during the Spring '08 term at UCSB.
 Spring '08
 Agrawal

Click to edit the document details