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

Info icon This 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) (2) O(N 1/2 ) *(3) O(N) (4) O(N 2 ) (5) O(2 N ) 7. What is the complexity to identify and print the four largest integers in an array of size N?
Image of page 1

Info iconThis 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