Answered step by step
Verified Expert Solution
Question
1 Approved Answer
c + + please Do a line - by - line BigO analysis of these 3 algorithm sets. It is not necessary to determine the
c please Do a linebyline BigO analysis of these algorithm sets. It is not necessary to determine the purpose of the algorithms or even the names of the algorithms. Based on your BigO analysis of these algorithms, determine which algorithm is most efficient and why. You may determine the algorithms have the same BigO and therefore are equally efficient but the algorithms do vary in efficiency that may not be apparent in a BigO analysis.
If you find a "logic" or "runtime" error in the code, the "error" isn't intentional so assign it an appropriate BigO value for the code in question.
Algorithm Set
void algorithmint a int i
int t s
while s i
t as;
as ai;
ai t;
s;
i;
int algorithmint a int n
int m i;
for m i ; i n; i
if ai am
m i;
return m;
void algorithmint a int n
for int c n; c ; c
int m algorithma c;
if m c
algorithma m;
algorithma c ;
Algorithm Set
void algorithmAint a int l int h
if l h
return;
if al ah
swapal ah;
if h l
int t h l ;
algorithmAa l h t;
algorithmAa l t h;
algorithmAa l h t;
Algorithm Set
const int P pow;
void algorithmXint a int l int r
for int i l ; i r; i
int t ai;
int j i ;
while j l && aj t
aj aj;
j;
aj t;
void algorithmYint a int l int m int r
int l m l l r m;
int leftl rightl;
for int i ; i l; i
lefti al i;
for int i ; i l; i
righti am i;
int i ;
int j ;
int k l;
while i l && j l
if lefti rightj
ak lefti;
i;
else
ak rightj;
j;
k;
while i l
ak lefti;
k;
i;
while j l
ak rightj;
k;
j;
void algorithmZint a int n
for int i ; i n; i P
algorithmXa i mini Pn ;
for int s P; s n; s s
for int l ; l n; l s
int m l s ;
int r minl s n ;
if m r
algorithmYa l m r;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started