Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assignment: Asymptotic Notations and Correctness of Algorithms [ You may include handwritten submission for the parts of the assignment that are difficult to type, like

Assignment: Asymptotic Notations and Correctness of Algorithms
[You may include handwritten submission for the parts of the assignment that are difficult to type, like equations, rough graphs etc., but make sure it is legible for the graders. Regrade requests due to the illegible parts of the work will not be accepted.]
1. Identify and compare the order of growth: Identify if the following statements are true or false.
Prove your assertion using any of the methods shown in the exploration. Draw a rough graph marking the location of c and n0, if the statement is True. [A generic graph would do for this purpose. You dont have to find the values of c and n0. On the graph you can just write c and n0 without mentioning their values. The idea is that you know how it looks graphically.].
a. n(n+1)/2 in O(n3)
b. n(n+1)/2 in \Theta (n2)
c.10n-6 in \Omega (78n +2020)
d. n! in \Omega (0.00001n)
2. Read and Analyze Pseudocode: Consider the following algorithm (In the algorithm, A[0..n-1] refers to an array of n elements i.e. A[0], A[1]... A[n-1])
Classified(A[0..n-1]):
minval = A[0]
maxval = A[0]
for i =1 to n-1:
if A[i]< minval:
minval = A[i]
if A[i]> maxval
maxval = A[i]
return maxval minval
a. What does this algorithm compute?
b. What is its basic operation (i.e. the line of code or operation that is executed maximum
number of times)?
c. How many times is the basic operation executed?
d. What is the time complexity of this algorithm?
3. Using mathematical induction prove below non-recursive algorithm:
def reverse_array(Arr):
n = len(Arr)
i =(n-1)//2
j = n//2
while(i>=0 and j <=(n-1)):
temp = Arr[i]
Arr[i]= Arr[j]
Arr[j]= temp
i = i-1
j = j+1
a. Write the loop invariant of the reverse_array function.
b. Prove correctness of reverse_array function using induction

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Temporal Databases Research And Practice Lncs 1399

Authors: Opher Etzion ,Sushil Jajodia ,Suryanarayana Sripada

1st Edition

3540645195, 978-3540645191

More Books

Students also viewed these Databases questions