{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

MidtermExam2Solution

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

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

View Full Document Right Arrow Icon
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
Image of page 1

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

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern