Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PleasE ANSWER THESE QUESTIONS : Consider the following array: 9 7 , 8 , 7 , 4 5 , 1 3 , 3 2 5

PleasE ANSWER THESE QUESTIONS : Consider the following array: 97,8,7,45,13,325,9,1. Show a trace of execution for selection sort. The trace begins with the provided initial state of the array, followed by the array's state after each swap is made.
Enter each subsequent state as a comma separated list (as shown by the initial state). Do not include any spaces. Appeals based on not following specified format will not be considered.
initial: 97,8,7,45,13,325,9,1
i =0:
1,8,7,45,13,325,9,97
Question 1.1 i =1: ,Q1.2 i =2: ,Q1.3 i =3: , Q1.4 i =4: ,Q1.5 i =5: ,Q1.6 i =6: , Q1.7 i =7: , Consider the following array: 97,8,7,45,13,325,9,1. Show a trace of execution for insertion sort. The trace begins with the provided initial state of the array, followed by the array's state after each pass is made.
Enter each subsequent state as a comma separated list (as shown by the initial state). Do not include any spaces. Appeals based on not following specified format will not be considered.
initial: 97,8,7,45,13,325,9,1
i =1:
8,97,7,45,13,325,9,1
Question
Q2.1 i =2: ,Q2.2 i =3: , Q2.3 i =4: , Q2.4 i =5: , Q2.5 i =6: ,Q2.6
i =7: Give sortInts' Big-Oh order if its input was already sorted, where the expression bounds the number of swaps. Include a short explanation, and be sure that you are giving a relatively tight bound. public static void sortInts (int [] data){
for (int i =1; i < data.length; i++){
int i = i;
while (i >0 && data[i-1]> data[i]){ swap (data[jl, data[j-1])//f (n) counts these
j--; }}} What algorithm runs faster for an array in reverse order: selection sort, or insertion sort? Explain. (Hint: you may need to consider multiple cost metrics.)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions