Consider the following algorithm where the input A0 n 1 is
Consider the following algorithm where the input A[0, n - 1]) is an array of n integers. a. What does this algorithm do? b. What are the basic operations of this algorithm? c. How many times are the basic operations executed? d. What is the efficiency class of this algorithm? Express your answer with the most appropriate O, Theta or Ohm notation.
Solution
Answer:
a) This algorithm is Bubble sort.
b) Shorting in increasing order , comparison between 2 numbers.
c) The basic operations executed = n(n-1).
d) The effecience of this algorithm is O(n^2).
![Consider the following algorithm where the input A[0, n - 1]) is an array of n integers. a. What does this algorithm do? b. What are the basic operations of th Consider the following algorithm where the input A[0, n - 1]) is an array of n integers. a. What does this algorithm do? b. What are the basic operations of th](/WebImages/34/consider-the-following-algorithm-where-the-input-a0-n-1-is-1099216-1761580396-0.webp)