Exam 1 F09 - Key

Exam 1 F09 - Key - CS2050 Exam 1 F09 Instructions: Mark the...

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

View Full Document Right Arrow Icon
CS 2050 Exam 1 F09 Instructions : Mark the single best answer for each of the following questions. Although there are 23 questions, the exam will be scored out of a maximum of 20 points. 1. What is the complexity to read N integers from a file and write half of the integers into a file and the other half of the integers into another file? *(1) O(N) (2) O(N 4/3 ) (3) O(N 1.5 ) (4) O(N 2 ) (5) O(N 2.5 ) 2. An algorithm reads a list of N cities from a file in O(N) time. Then it computes the distances between each pair of cities in O(N 2 ) time. Lastly, it creates a 2D array in which the entry in row i and column j gives the distance between city i and city j. How does the overall running time of the algorithm scale with N? (1) O(N) *(2) O(N 2 ) (3) O(N 3 ) (4) O(N 4 ) (5) O(N 5 ) 3. What is the space complexity of the previous algorithm, i.e., how much memory does it use? (1) O(N) *(2) O(N 2 ) (3) O(N 3 ) (4) O(N 4 ) (5) O(N 5 ) 4. What is the complexity to find the largest key and the smallest key in an array of size N? (1) O(1) (2) O(2) *(3) O(N) (4) O(N 2 ) (5) O(2 N ) 5. What is the complexity to determine if the sum of the first k elements of an array of size N is greater than the sum of last k elements of the array? (1) O(1) *(2) O( k ) (3) O(N) (4) O( k +N) (5) O( k 2 ) 6. Given an NxN 2 dimensional array, what is the complexity to print the elements in the first row? (1) O(1)
Background image of page 1

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

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

This note was uploaded on 11/06/2010 for the course CS 2050 taught by Professor Uhlmann during the Fall '09 term at Missouri (Mizzou).

Page1 / 3

Exam 1 F09 - Key - CS2050 Exam 1 F09 Instructions: Mark the...

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