Fundamentals of Algorithms (CS502)
Assignment # 01
Spring 2018
Question # 1: 10
Marks
For the following code
segment, provide line-by-line analysis and construct function T(n) that give
the runtime of this code as a function of "n". Also determine the big-O for this code
segment. [Marks: 5+3+2]
Question # 2: 5 Marks
Which of the
following two functions is faster?
a)
f1 = 10n2
b)
f2 = n3
Question # 3: 5 Marks
In
the context of 2D Maxima problem, Brute Force algorithm runs in Θ(n2)
time and Plane-Sweep algorithm runs in Θ(nlog2n) time. For n =
500,000, if Plane-Sweep takes 1 second, how much time (in hours) Brute Force
algorithm will take? Calculate and show all the steps.
Note:
Base of log is 2 (e.g. log210
= 3.321928095)
No comments:
Post a Comment