
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Assignment; Class: Data Structs & OO Development; Subject: Computer Science; University: Virginia Polytechnic Institute And State University; Term: Unknown 1989;
Typology: Assignments
1 / 1
This page cannot be seen from the preview
Don't miss anything!

CS 2606 Data Structures & OO Devel II Homework 2: Complexity
You will submit your solution to this assignment to the Curator System (as HW2). Your solution must be either a plain text file
(e.g., NotePad) or a MS Word document; submissions in other formats will not be graded.
Except as noted, credit will only be given if you show relevant work.
the body of the following function. (Treat K as a constant. Your answer should be a function of the parameter N.)
int selectKth(int A[], int K, int N) {
int minI, tmp; for (int i = 0; i < K; i++) { minI = i; for (int j = i + 1; j < N; j++) { if ( A[j] < A[minI] ) minI = j; } tmp = A[i]; A[i] = A[minI]; A[minI] = tmp; } return A[k-1]; }
justification is necessary.
a) 2
Hint: the last three take a little analysis.
c)
d)
2
e)
2 2
How long would it take to execute this algorithm on hardware capable of carrying out 2 24 instructions per second if N = 2 32 ? (Give your answer in hours, minutes and seconds, to the nearest second.)