Question

2. Show the steps when sorting (smallest to largest) the following arrays of numbers using selection sort i.e. every time a s
0 0
Add a comment Improve this question Transcribed image text
Answer #1

a.)

1 2 5 8 9 10 4 7
1 2 5 8 9 10 4 7
1 2 4 8 9 10 5 7
1 2 4 5 9 10 8 7
1 2 4 5 7 10 8 9
1 2 4 5 7 8 10 9
1 2 4 5 7 8 9 10
Sorted array:
1 2 4 5 7 8 9 10

b.)

1 7 3 2 5 4 8 12 9
1 2 3 7 5 4 8 12 9
1 2 3 7 5 4 8 12 9
1 2 3 4 5 7 8 12 9
1 2 3 4 5 7 8 12 9
1 2 3 4 5 7 8 12 9
1 2 3 4 5 7 8 12 9
1 2 3 4 5 7 8 9 12
Sorted array:
1 2 3 4 5 7 8 9 12

c.)

1 7 6 5 4 3 2 8
1 2 6 5 4 3 7 8
1 2 3 5 4 6 7 8
1 2 3 4 5 6 7 8
1 2 3 4 5 6 7 8
1 2 3 4 5 6 7 8
1 2 3 4 5 6 7 8
Sorted array:
1 2 3 4 5 6 7 8

d.)

1 3 8 5 9 4 2 6
1 2 8 5 9 4 3 6
1 2 3 5 9 4 8 6
1 2 3 4 9 5 8 6
1 2 3 4 5 9 8 6
1 2 3 4 5 6 8 9
1 2 3 4 5 6 8 9
Sorted array:
1 2 3 4 5 6 8 9

Add a comment
Answer #2
An integer array contains [ 2, 4, 1, 5, 7]. Show the steps of Selection Sort algorithm to sort this array from lowest to highest.
answered by: Moussa Bouceder
Add a comment
Know the answer?
Add Answer to:
2. Show the steps when sorting (smallest to largest) the following arrays of numbers using selection...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Implement and compare sorting algorithms. The task is to sort a list of integers using 5...

    Implement and compare sorting algorithms. The task is to sort a list of integers using 5 sorting algorithms: selection sort insertion sort merge sort heap sort quicksort Your program should include 5 separate sorting methods, though it is fine for them to call some common methods (like "swap") if needed. Each sorting method should also count the number of comparison operations and assignment operations on the array elements during the sorting process. In the main program, two types of array...

  • In C++ language, implement a class that can sort an array of numbers using all three...

    In C++ language, implement a class that can sort an array of numbers using all three algorithms we have seen in this course, but each method updates a “counter” value every time it accesses the array. Have it print this at the end of the sorting process. Store the array values in an “original” array so you don’t have to re-type it for different sorts (since each sort alters the array), and have the sort modify a copy. Note: IF...

  • In C++ language, implement a class that can sort an array of numbers using all three...

    In C++ language, implement a class that can sort an array of numbers using all three algorithms we have seen in this course, but each method updates a “counter” value every time it accesses the array. Have it print this at the end of the sorting process. Store the array values in an “original” array so you don’t have to re-type it for different sorts (since each sort alters the array), and have the sort modify a copy. Note: IF...

  • Using Arrays with Sorting and Searching Algorithms 1) This program has six required outputs and involves...

    Using Arrays with Sorting and Searching Algorithms 1) This program has six required outputs and involves searching and sorting an array of integers. Write a java application that initializes an array with the following numbers, in this order: 23, 17, 5, 90, 12, 44, 38, 84, 77, 3, 66, 55, 1, 19, 37, 88, 8, 97, 25, 50, 75, 61, and 49. Then display the unsorted values. This is required output #1 of 6 for this program. 2) Using a...

  • 1. a. Using C++, represent the following graph using adjacency matrix, and implement depth first searching...

    1. a. Using C++, represent the following graph using adjacency matrix, and implement depth first searching (DFS) by stack (define it with class) to traverse the graph. 6 7 2 4 b. If starting with node 2, when node 7 is printed, what numbers are in the stack (for DFS)? Please draw the stack step by step to show how the numbers are pushed into and popped out of it. 2. a. Given a set of integer numbers as int...

  • I need the report like this (idea) *Sorting Algorithms: A sorting algorithm is an algorithm that...

    I need the report like this (idea) *Sorting Algorithms: A sorting algorithm is an algorithm that puts elements of a list in a certain order. The most-used orders are numerical order and lexicographical order. Efficient sorting is important for optimizing the use of other algorithms (such as search and merge algorithms) which require input data to be in sorted lists; it is also often useful for canonical zing data and for producing human-readable output. More formally, the output must satisfy...

  • Sorting Sort the following array using the quick sort algorithm: (4 Marks) a. 12 26 8...

    Sorting Sort the following array using the quick sort algorithm: (4 Marks) a. 12 26 8 9 7 0 4 Pivot selection is defined to be the first element of each sub-list. Show the array before and after each quicksort round (when the array is partitioned after placing the pivot at its correct position). Also, clearly highlight the pivot in each partition b. Consider an unsorted array of integers of size n. Write a Java program to arrange the array...

  • Sorting Threads Assignment Overview Write a multithreaded sorting program in Java which uses the ...

    Sorting Threads Assignment Overview Write a multithreaded sorting program in Java which uses the merge sort algorithm. The basic steps of merge sort are: 1) divide a collection of items into two lists of equal size, 2) use merge sort to separately sort each of the two lists, and 3) combine the two sorted lists into one sorted list. Of course, if the collection of items is just asingle item then merge sort doesn’t need to perform the three steps,...

  • Write a java program to sort arrays using 3 different methods: Bubble Sort, Selection Sort and...

    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...

  • Sort the list of numbers: 35, 12, 6, 23, 18 using Selection sort. Work through each...

    Sort the list of numbers: 35, 12, 6, 23, 18 using Selection sort. Work through each step of the algorithm. The algorithm for selection sort is as follows: i. Find the smallest item in a list. ii. Swap this value with the value currently at the front of the list. iii. Repeat Steps 1 and 2 with the current size of the list minus one (list size = list size-1)

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT