please help me with question 1 and 2 (a,b,c). Thank you! Exercises 13.1 13.1 som
ID: 3819753 • Letter: P
Question
please help me with question 1 and 2 (a,b,c). Thank you!
Exercises 13.1 13.1 some om Sorting schemes 733 1. For the following array x, show xafter each the first two passes of simple selec- tion sort arrange the elements in ascending order: i 1 2 4 5 6 xli l 30 l 50 70 l 10 40 60 2. a. For the following array x, show x after each of the first two passes bubble sort to arrange the elements in descending order: of 1 2 3 4 5 6 rl] 60 l 50 l 70 10 40 l 20 How many passes will bubble sort make In what situations will bubble sort make the most interchanges? finnad yral in the followingExplanation / Answer
selection sort :-
The algorithm divides the input list into two parts: the sublist of items already sorted, which is built up from left to right at the front (left) of the list, and the sublist of items remaining to be sorted that occupy the rest of the list. Initially, the sorted sublist is empty and the unsorted sublist is the entire input list. The algorithm proceeds by finding the smallest (or largest, depending on sorting order) element in the unsorted sublist, exchanging (swapping) it with the leftmost unsorted element (putting it in sorted order), and moving the sublist boundaries one element to the right.
now your part
x
30 50 70 10 40 60 // this is the initial, starting state of the array
10 50 70 30 40 60 // sorted sublist = {10}
10 30 70 50 40 60 // sorted sublist = {10, 30}
10 30 40 50 70 60 // sorted sublist = {10, 30, 40}
10 30 40 50 70 60 // sorted sublist = {10, 30, 40,50}
10 30 40 50 60 70 // sorted sublist = {10, 30, 40,50,60}
10 30 40 50 60 70 // sorted sublist = {10, 30, 40,50,60,70}
-----------------------------------------------------------------------------------------------------------
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.