Assignment 01
Assignment 01
Instructions
This is an individual assignment. Absolutely NO collaboration is allowed. Any traces of
plagiarism/cheating would result in an “F” grade in this course.
Only handwritten assignments will be accepted.
Late submissions will NOT be accepted, in any case.
Clearly mention your Name, Roll Number and Section on the front page of your assignment.
a) 5n 2 10n (n 2 )
b) 3n 2 2 n n log n (n 2 2 n )
n
c) i ( n )
i 0
2 3
d) n4 107 n2 (n4 )
e) 2n 5 (2n )
2. An algorithm takes 0.7 ms for input size 100. How long will it take for input size 400,
assuming that the exact step count 𝑻(𝒏) of the algorithm is:
a) 𝑇(𝑛) = 𝑛
b) 𝑇(𝑛) = 𝑛 lg 𝑛
c) 𝑇(𝑛) = 𝑛2
d) 𝑇(𝑛) = 𝑛3
e) 𝑇(𝑛) = 2𝑛
Page 1 of 3
4. An algorithm takes 0.6 ms for input size 100. How large a problem can be solved in 1
minute, assuming that the exact step count 𝑻(𝒏) of the algorithm is:
a) 𝑇(𝑛) = 𝑛
b) 𝑇(𝑛) = 𝑛2
c) 𝑇(𝑛) = 𝑛3
d) 𝑇(𝑛) = 2𝑛
e) 𝑇(𝑛) = 5𝑛
Note: In all of the above questions, you must show your complete working to get full credit.
PRACTICE QUESTIONS
Following questions (Question # 5, 6, 7, 8, 9) are for your own practice and you are not
required to submit these. But I will assume in quizzes and exams that you have solved these
questions.
6. Solve the following exercise questions from your textbook (E. Horowitz, S. Sahni, and D.
Mehta, Fundamentals of Data Structures in C++, 2nd Edition, 2007):
Page # Exercise # Remarks
69 1
69-70 3 (a), (b) Also determine the time complexity in Big-Oh notation.
70 4 (d) Also determine the time complexity in Big-Oh notation.
70 5 Also determine the time complexity in Big-Oh notation.
71 7 (a) Also determine the time complexity in Big-Oh notation.
93 2 Write the algorithm in pseudo-code form.
Page 2 of 3
7. Determine the time complexity (in Big-Oh notation) for the following code segments:
int temp = 0, i, j; int temp = 0, i, j;
for (i=0; i<n; i=i+3) { for (i=1; i<n; i=i*2) {
for (j=0; j<n; j=j+2) { for (j=1; j<n; j=j*4) {
temp++; temp++;
} }
} }
8. Suppose that you have a computer that requires 1 minute to solve problem instances of size
n = 1000. Now, suppose you buy a new computer that runs 1000 times faster than the old
one. What instance sizes can be run in 1 minute, assuming that the exact step count T(n) of
your algorithm is:
a) 𝑇(𝑛) = 𝑛
b) 𝑇(𝑛) = 𝑛2
c) 𝑇(𝑛) = 𝑛3
d) 𝑇(𝑛) = 2𝑛
e) 𝑇(𝑛) = 10𝑛
x. 𝑛0.5
GOOD LUCK!
Page 3 of 3