CS1081205a - Computer Science Foundation Exam August 12,...

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

View Full Document Right Arrow Icon
Computer Science Foundation Exam August 12, 2005 Computer Science Section 1A No Calculators! Name: SSN: Score: / 50 In this section of the exam, there are four (4) problems. You must do all of them. The weight of each problem in this section is indicated with the problem. Partial credit cannot be given unless all work is shown and is readable. Be complete, yet concise, and above all be neat . KEY Solutions and Grading Criteria
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 1. [15 points – 5 pts each] Answer each of the following “timing” questions concerning an algorithm of a particular order and a data set of a particular size. Assume that the run time is affected only by the size of the data set and not its composition and that n is an arbitrary integer. Show your work and place your final answer in the box. (a) For an O(n log 2 n) algorithm, one data set with n = 32 takes 16 seconds. How long will the same algorithm take if the size of the data set is increased to n = 256 ? sec 48 . 20 10 2048 T ) 8 ( 256 T 10 T 256 log 256 10 16 ) 5 ( 32 16 32 32 2 2 = = = = = = = = (b) For an O(n 2 ) algorithm, one data set with n = 16 takes 24 seconds. What is the largest size data set that can be executed by this algorithm in 60 seconds? 25 n 640 n 24 60 256 n 60 n 24 16 2 2 2 2 = = × = = (c) Suppose you have two different algorithms that both correctly solve a particular problem. One of the algorithms is O(n!) and the other algorithm is O(n 3 ) . Which of the algorithms takes longer to execute when n = 5 ? 5! = 1 × 2 × 3 × 4 × 5 = 120 5 3 = 5 × 5 × 5 = 125 125 > 120 so the O(n 3 ) algorithm takes longer when n = 5 20.48 sec n = 25 The O(n 3 algorithm takes the longer time.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 09/21/2011.

Page1 / 7

CS1081205a - Computer Science Foundation Exam August 12,...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online