0% found this document useful (0 votes)
127 views

Assignment 01

This document contains an assignment on data structures and algorithms. It includes 4 questions to prove time complexities using Big-O notation and determine time complexities of algorithms. It also includes 5 practice questions to solve. Students must show their work to receive full credit and the assignment is due on October 16th.

Uploaded by

Nida Siddiquee
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
127 views

Assignment 01

This document contains an assignment on data structures and algorithms. It includes 4 questions to prove time complexities using Big-O notation and determine time complexities of algorithms. It also includes 5 practice questions to solve. Students must show their work to receive full credit and the assignment is due on October 16th.

Uploaded by

Nida Siddiquee
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Data Structures & Algorithms – Fall 2019

(MSc-CS-F18 Morning & Afternoon)


Assignment # 1
Assigned on: Wednesday, October 09, 2019
Submission Deadline: Wednesday, October 16, 2019 (at the start of lecture)

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.

1. Prove the following inequalities:

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𝑛

3. Determine and prove the Big-Oh for the following expressions:


a) 5𝑛5/2 + 25𝑛2/5
b) 6 lg 𝑛2 + 2𝑛
c) 3𝑛4 + 𝑛4 𝑙𝑔𝑛
d) 𝑛(𝑛 + 10√𝑛)
e) log 4 2𝑛 + log 4 𝑛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.

5. Answer the following short questions:


 An algorithm processes a given input of size 𝒏. If 𝒏 is 4096, the execution time is 512
milliseconds. If 𝒏 is 16384, the execution time is 2048 milliseconds. What is the time
complexity of the algorithm in big-Oh notation?
 An algorithm processes a given input of size 𝒏. If 𝒏 is 4096, the execution time is 512
milliseconds. If 𝒏 is 16384, the execution time is 8192 milliseconds. What is the time
complexity of the algorithm in big-Oh notation?
 An algorithm processes a given input of size 𝒏. If 𝒏 is 4096, the execution time is 512
milliseconds. If 𝒏 is 16384, the execution time is 1024 milliseconds. What is the time
complexity of the algorithm in big-Oh notation?

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++;
} }
} }

int temp = 0, i, j; int temp = 0, i, j;


for (i=0; i<n*n; i=i+2) { for (i=1; i<=n; i++) {
for (j=1; j<n; j=j*3) { for (j=1; j<=n*n; j=j*2) {
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𝑛

9. Reorder the following time complexities from asymptotically smallest to asymptotically


largest:
i. 2𝑛
ii. 𝑛!
iii. 𝑛5
iv. 10,000
v. 𝑛𝑛
vi. 𝑛𝑙𝑔𝑛
vii. 𝑘𝑙𝑔𝑛 (𝑤ℎ𝑒𝑟𝑒 𝑘 𝑖𝑠 𝑎 𝑐𝑜𝑛𝑠𝑡𝑎𝑛𝑡)
viii. 𝑛𝑙𝑔𝑘 (𝑤ℎ𝑒𝑟𝑒 𝑘 𝑖𝑠 𝑎 𝑐𝑜𝑛𝑠𝑡𝑎𝑛𝑡)
ix. 𝑛 + 𝑛 + 𝑛3
2

x. 𝑛0.5

 GOOD LUCK! 

Page 3 of 3

You might also like