



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: Exam; Class: ALGORITHM IMPLEMENTATION; Subject: Computer Science; University: University of Pittsburgh; Term: Spring 2006;
Typology: Exams
1 / 7
This page cannot be seen from the preview
Don't miss anything!




The solutions are in bold.
Input Size Machine Speed Time 100,000 1,000, operations/second 1 Hour 100,000 3,000, operations/second 1/3 hour = 20 minutes 300,000 1,000, operations/second 3 hours 1,000,000 10,000, operations/second 1 Hour b)Assume that we have a program that is known to run in time Theta(n^3 ). Fill in the following table. Input Size Machine Speed Time 100,000 1,000, operations/second 1 Hour 100,000 3,000, operations/second 1/3 hour = 20 minutes 300,000 1,000, operations/second 27 hours (10)1/3^ *** 100,000 ~ 215,**
operations/second 1 Hour c)Explain the standard argument that the asymptotic run time of a program/algorithm becomes more important as machine speeds increase. You can base your answer on the above two tables if you like. If the goal is to run the program on the largest input that can be handled in a fixed amount of time, then programs with higher asymptotic run times gain less from increased processor speed. In the above examples, increasing the machine speed by a factor of 10 allows the linear time algorithm to handle a 10 times larger input, while the Theta(n^3 ) time algorithm can only handle a factor of 2 larger input. 3) Consider the mismatched character heuristic of the Boyer-Moore string matching algorithm. a) (5 points) Show the skip array for the following pattern
must be __, Bit 3 must be …”, or something like that. For 5 points: Bit value 1 0 3 1 6 0 8 1 For 5 extra credit points Bit value 2 0 4 1 5 0 7 1 b) (5 Points) Specify the node where a Search for the bit string 00111000000 terminates. The left/0 child of the root. That is the one with position = 3. c) (10 Points) Show the tree resulting from inserting the bit string 00111000000. A new node is created between the nodes with positions 3 and 6 in the tree. The 1 pointer of the position 3 node is set to this new node. The picture for this part of the tree is shown below.
Here is a C-like solution: Void Permutation(int n, int partial_perm[], int taken[], int depth) if depth == n then for (i=1; i++; i <= n) do print(partial_perm[i]) print(newline) else for (i=1; i++; i <= n) do if not taken[i] then partial_perm[depth +1]=i taken[i]= Permutation(n, partial_perm, taken, depth+1) Taken[i]=