Please copy and paste this embed script to where you want to embed

COT 5405

Analysis of Algorithms

Spring 2004

On-Campus Exam #1 Name: __________________________________________ UFID: ____________ - ____________ E-mail: _________________________________________

Instructions: 1. Write neatly and legibly 2. While grading, not only your final answer but also your approach to the problem will be evaluated 3. You have to attempt only TWO problems. If you attempt more than two problems, we will grade ANY two problems of OUR choice 4. Each problem carries 10 points 5. Total time for the exam is 50 minutes 6. You are not allowed to use a calculator for this exam I have read carefully, and have understood the above instructions. On my honor, I have neither given nor received unauthorized aid on this examination. Signature: _____________________________________ Date: ____ (MM) / ____ (DD) / ___________ (YYYY)

Analysis of Algorithms Spring 2004

On-Campus Exam #1

Page 1 of 8

Analysis of Algorithms Spring 2004

On-Campus Exam #1

Page 2 of 8

Question 1: Solve the recurrence relation without using Master’s theorem: N N T ( N ) = 2T + 2 2 (log N )

Derive a Theta expression for T(N).

Analysis of Algorithms Spring 2004

On-Campus Exam #1

Page 3 of 8

Analysis of Algorithms Spring 2004

On-Campus Exam #1

Page 4 of 8

Question 2: We have an array of sorted distinct numbers that is infinitely long. The first n numbers are fractions that are greater than 0 but less than 1. All the remaining elements are “1”s, and you are not given the value of n. You need to develop an algorithm to check if a user-given fraction F occurs in that array. Analyze the time complexity of your algorithm as a function of n. (An example for n=8) 1 0

2 3 0.23 0.3

4 0.4

5 0.5

Analysis of Algorithms Spring 2004

6 0.6

7 0.9

8 1

9 1

On-Campus Exam #1

10 1

11 1

12 1

.. 1

.. 1

Page 5 of 8

.. 1

Analysis of Algorithms Spring 2004

On-Campus Exam #1

Page 6 of 8

Question 3: You are the TA for a class with an enrollment of n students. You have their final scores (unsorted), and you must assign them one of the G available grades (A, B, C etc.). The constraints are (assuming n is a multiple of G): Exactly (n/G) students get each grade (for example, if n = 30, and G = {A,B,C}, then exactly 10 students get A, 10 get B, and 10 get C) • A student with lower score doesn’t get a higher grade than a student with a higher score (however, they may get the same grade) Assuming that each student received a different score, derive an efficient algorithm and give its complexity in terms of n and G. Any algorithm that first sorts the scores will receive zero credit. •

Analysis of Algorithms Spring 2004

On-Campus Exam #1

Page 7 of 8

Analysis of Algorithms Spring 2004

On-Campus Exam #1

Page 8 of 8

View more...
Analysis of Algorithms

Spring 2004

On-Campus Exam #1 Name: __________________________________________ UFID: ____________ - ____________ E-mail: _________________________________________

Instructions: 1. Write neatly and legibly 2. While grading, not only your final answer but also your approach to the problem will be evaluated 3. You have to attempt only TWO problems. If you attempt more than two problems, we will grade ANY two problems of OUR choice 4. Each problem carries 10 points 5. Total time for the exam is 50 minutes 6. You are not allowed to use a calculator for this exam I have read carefully, and have understood the above instructions. On my honor, I have neither given nor received unauthorized aid on this examination. Signature: _____________________________________ Date: ____ (MM) / ____ (DD) / ___________ (YYYY)

Analysis of Algorithms Spring 2004

On-Campus Exam #1

Page 1 of 8

Analysis of Algorithms Spring 2004

On-Campus Exam #1

Page 2 of 8

Question 1: Solve the recurrence relation without using Master’s theorem: N N T ( N ) = 2T + 2 2 (log N )

Derive a Theta expression for T(N).

Analysis of Algorithms Spring 2004

On-Campus Exam #1

Page 3 of 8

Analysis of Algorithms Spring 2004

On-Campus Exam #1

Page 4 of 8

Question 2: We have an array of sorted distinct numbers that is infinitely long. The first n numbers are fractions that are greater than 0 but less than 1. All the remaining elements are “1”s, and you are not given the value of n. You need to develop an algorithm to check if a user-given fraction F occurs in that array. Analyze the time complexity of your algorithm as a function of n. (An example for n=8) 1 0

2 3 0.23 0.3

4 0.4

5 0.5

Analysis of Algorithms Spring 2004

6 0.6

7 0.9

8 1

9 1

On-Campus Exam #1

10 1

11 1

12 1

.. 1

.. 1

Page 5 of 8

.. 1

Analysis of Algorithms Spring 2004

On-Campus Exam #1

Page 6 of 8

Question 3: You are the TA for a class with an enrollment of n students. You have their final scores (unsorted), and you must assign them one of the G available grades (A, B, C etc.). The constraints are (assuming n is a multiple of G): Exactly (n/G) students get each grade (for example, if n = 30, and G = {A,B,C}, then exactly 10 students get A, 10 get B, and 10 get C) • A student with lower score doesn’t get a higher grade than a student with a higher score (however, they may get the same grade) Assuming that each student received a different score, derive an efficient algorithm and give its complexity in terms of n and G. Any algorithm that first sorts the scores will receive zero credit. •

Analysis of Algorithms Spring 2004

On-Campus Exam #1

Page 7 of 8

Analysis of Algorithms Spring 2004

On-Campus Exam #1

Page 8 of 8

Thank you for interesting in our services. We are a non-profit group that run this website to share documents. We need your help to maintenance this website.

To keep our site running, we need your help to cover our server cost (about $400/m), a small donation will help us a lot.