Using an insertion sort, sort the array 5, 7, 4, 9, 8, 6, 3 into ascending order. After the first swap, what will the array look like?
Answer :
After first Pass: 4 5 7 9 8 6 3
So here it will compare the 2 elements and put it in the ascending order
Note : Please comment below if you have concerns. I am here to help you
If you like my answer please rate and help me it is very Imp for me
Using an insertion sort, sort the array 5, 7, 4, 9, 8, 6, 3 into ascending...
Given the following array: int a[8] = {41, 32, 5, 8, 7, 50, 11, 49}; What does the array look like after the first swap of a Selection Sort in descending order?
[5 marks] Using selection sort algorithm to sort the array int array[7]-5, 6, 2, 7, 9, 4, 3). Assuming we call the following function using statement selection sort (int array, 7); Please fill the table to show the changes of the array int_array after each iteration. The first column is filled. void selection_sort (int list[], int list_size) for (int i = 0; i < list size - 1; 1++) int current min = list[1]; int current_min_index-i for (int j -...
PROBLEM #11 What are the two algorithms used to sort an array? How do they work? -------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------------------------- PROBLEM #12 Given the following array 'jumbled', what will the array be after the first swap of a selection sort algorithm? (Assume the algorithm sorts in ascending order). --------------------------------------------------------------------------------------------------------------- */ int jumbled[] = {12, 5, 3, 1, 9, 100, 45}; /* --------------------------------------------------------------------------------------------------------------- PROBLEM #13 Given the following array 'jumbled2', what will the array be after the third swap of a...
Sort the same array [3, 5, 1, 4, 8, 7,9, 2] in the ascending order by applying the Merge sort algorithm. Write down the intermediate results step by step in a tree structure. (20 points)
Please come up with an array of 9 random integers then sort the array. Show the contents of the array each time a sorting algorithm changes it while sorting the array into ascending order. The 6 sorting algorithm we are using are: 1. Selection Sort 3 points 2. Insertion Sort 3 points 3. Shell Sort 6 points 4. Bubble Sort 3 points 5. Merge Sort 10 points 6. Quick Sort 10 points It is OK to do this assignment on...
DATA STRUCTURE 1) Sort 3, 4, 5, 6,1, 9, 2, 5, 6 using insertion sort.
1. Which of the following algorithms requires the most extra space when implemented? A. Quicksort B. Mergesort C. Radix sort D. All use the same amount of extra space 2. Sort this array into ascending order: 80 90 70 85 60 40 50 95. Assume the pivot is 40. (SHOW WORK) A. (40) and (50 60 70 80 85 90 95) B. () and (80 90 70 85 60 50 95) C. () and (50 60 70 80 85 90...
6. (10 points) Trace insertion sort algorithm as it sorts the following sequence of integer array into an ascending order. 17 3 12
Write a java program to sort arrays using 3 different methods: Bubble Sort, Selection Sort and Insertion Sort. The numbers to be sorted will be obtained using a library function which generates pseudo-random numbers. TO Do 1. Fill an array with 140 real numbers between 0.00 and 945.00. Generate the numbers using the subroutine that generates random numbers. Make a spare copy of the array; you will need it later. 2. Call a subroutine to print the contents of the...
4. Use the Insertion Sort algorithm to sort the following array in nondecreasing order. arr = { 896 745 23 } a. Show the order of the array after every i-loop iteration. (4 points) b. How many comparisons are made for this specific array? (1 point) C. State the best, worst, and average-case performance of Insertion Sort. (1 point)