question archive 1) Review the following algorithms (assume any undeclared variables are declared earlier ) int int count rand ( ) F for (int 0: 1 < N; i+ +) : 0
Subject:Computer SciencePrice:9.82 Bought3
1) Review the following algorithms (assume any undeclared variables are declared earlier ) int int count rand ( ) F for (int 0: 1 < N; i+ +) : 0 .3 rand ( ) ; a < 1.0 int num = rand ( ) ; : <1.5 += rand () if ( num < 0 .5 ) 2 . 0 += rand () count + = 1 ; 1. 5 rand ( ) ; rand ( ) : i ii int count = 0 : int count = 0, for (int i 1 = 0; 1 < N: i+ + int i = N; if (unlucky) if Iunlucky while (i > 0) count = count + : count i / = 2: iii . iv. int count = 0: for line i = 0: i . - 1; it+) for (int i = 0; i < for (int j = 0; j < M-i-1; j+ +1 int num = rand ( ) ; if (atjl > a [j+1]) if[ num < 0 .5 Swap (a [j ], ali + 1]) ; count += 1; 7 int num = count: for (int ] =0: 1 < num: j+ +) count = count + ]: vi. For each of the above answer each of the following a) What is the number of operations of the best , worst and average cases ? b) Describe the best , worst and average case using Big -0 notation. c) Describe each algorithm's s overall performance using the tightest possible class in Big -O notation d) Describe each algorithm's overall performance using the tightest possible class in Big - Q notation. e ) Describe each algorithm's overall performance using Big -@ notation Selecting from one or more of the above which is the best way to succinctly describe the performance of each algorithm using asymptotic notation 2 . Arguably , the most commonly used asymptotic notation used is frequently Big -O. Discuss why this is so commonly the case Is it true that e7 Phalgorithm always takes longer to run than an enlog nalgorithm? Explain your answer. 4. Answer whether the following statements are right or wrong and explain your answers nlog n GOD ORna n D n9 0 10'n 60 8An n log n 609 hank
1.)
2.)
Step-by-step explanation
3.)
b.)
1.) Best case:
2.) worst case:
3.) average case:
c.)
d.)
e.)
f.)