If you have any problem with the answer just let me know in the comments and I’ll try to solve it as soon as possible
Question 3.
A. The time complexity of insertion sort is O(n2). That means that this algorithm takes max time of O(n2) for sorting n elements.
B. Pseudocode for selection sort
Selection sort finds the smallest element and replaces it with first element, then finds the second smallest and replace with second element.
-SELECTION-SORT(A)
for j ← 1 to n-1
smallest ← j
for i ← j + 1 to n
if A[ i ] A[ smallest ]
C. After following above Pseudocode we have
– 9 8 7 4 5 6 ( first we select smallest (4) and replace with first element)
– 4 9 8 7 5 6 ( similarly for second smallest element)
– 4 5 9 8 7 6
– 4 5 6 9 8 7
-4 5 6 7 9 8
– 4 5 6 7 8 9
“Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!”
What Students Are Saying About Us
.......... Customer ID: 12*** | Rating: ⭐⭐⭐⭐⭐"Honestly, I was afraid to send my paper to you, but splendidwritings.com proved they are a trustworthy service. My essay was done in less than a day, and I received a brilliant piece. I didn’t even believe it was my essay at first 🙂 Great job, thank you!"
.......... Customer ID: 14***| Rating: ⭐⭐⭐⭐⭐
"The company has some nice prices and good content. I ordered a term paper here and got a very good one. I'll keep ordering from this website."