{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

MidtermExam2Solution

# MidtermExam2Solution - CS20 Midterm#2 NAME 1(7 points Using...

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

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 a-f 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

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern