Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 3 a) What is the Big-O (O(n)) and Big-Omega (O(n)) time complexity for algorithm MyAlgorithm below in terms of n? Show all necessary steps.

image text in transcribed

Question 3 a) What is the Big-O (O(n)) and Big-Omega (O(n)) time complexity for algorithm MyAlgorithm below in terms of n? Show all necessary steps. b) Trace (hand-run) MyAlgorithm for an array A =(4,11,5,3,2). What is the resulting A? c) What does MyAlgorithm do? What can be asserted about its result given any arbitrary array A of n integers? d) Can the runtime of MyAlgorithm be improved easily? how? e) Write the algorithm using actual Java code, insert any additional lines of code for the sole purpose of finding out the number of executions, then run with different initial values of the array including the one given above. Do the results correspond to your above estimate of Big-O? If no, explain clearly the reasons behind this mismatch! Provide the Java code, and the sample outputs as part of your answers. Algorithm MyAlgorithm(A, n) Input: Array of integer containing n elements Output: Possibly modified Array A done true j+0 while j A[i+1] then swap(A[], A[j+11) done:= false j+1+1 end while jun-1 while j 1 do if A[j]<>

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

Databases On The Web Designing And Programming For Network Access

Authors: Patricia Ju

1st Edition

1558515100, 978-1558515109

More Books

Students also viewed these Databases questions