(Sclection Sort) There are many, many algorithms for sorting a list of data. In the Selection Sort algorithm, the data is logically (although not usually physically) bro- ken into two disjoint subpicces. Those picces are a sorted subpiece and an unsorted subpiece. Initially, the sorted subpicce is empty and the unsorted subpicce is therefore the entire list. The algorithm then procceds in iterations and, in cach iteration, the minimum clement from the unsorted picce is located and swapped into the position where the unsorted list starts (therecby placing it in the appropriate location). The oscrintion and animation on tho Wikinodia nago for Soloction Sort might bo VERV

Advanced Engineering Mathematics
10th Edition
ISBN:9780470458365
Author:Erwin Kreyszig
Publisher:Erwin Kreyszig
Chapter2: Second-order Linear Odes
Section: Chapter Questions
Problem 1RQ
icon
Related questions
Question

make maqthlab code 

(Selection Sort) There are many, many algorithms for sorting a list of data. In the
Sclection Sort algorithm, the data is logically (although not usually physically) bro-
ken into two disjoint subpicces. Those pieces are a sorted subpicce and an unsorted
subpiece. Initially, the sorted subpicce is empty and the unsorted subpicce is therefore
the entire list. The algorithm then proceeds in iterations and, in cach iteration, the
minimum element from the unsorted piece is located and swapped into the position
where the unsorted list starts (thereby placing it in the appropriate location). The
description and animation on the Wikipedia page for Selection Sort might be VERY
helpful here.
The code for this should consist of an outer loop and an inner loop. Your input will be
an arbitrary-length (row) vector, and you will produce a matrix where the first row is
the initial vector and cach subsequent row is the result of one pass of the outer loop.
See below for sample runs.
select_sort Function:
Input variables:
• a vector of unsorted data
Output variables:
a matrix of the results after cach pass of the outer loop
A possible sample case is:
» data = select_sort([1 2 4 5 3])
data
1
4 5
3
1
4
3
1
2
4
3
4
1
2
4
5
Transcribed Image Text:(Selection Sort) There are many, many algorithms for sorting a list of data. In the Sclection Sort algorithm, the data is logically (although not usually physically) bro- ken into two disjoint subpicces. Those pieces are a sorted subpicce and an unsorted subpiece. Initially, the sorted subpicce is empty and the unsorted subpicce is therefore the entire list. The algorithm then proceeds in iterations and, in cach iteration, the minimum element from the unsorted piece is located and swapped into the position where the unsorted list starts (thereby placing it in the appropriate location). The description and animation on the Wikipedia page for Selection Sort might be VERY helpful here. The code for this should consist of an outer loop and an inner loop. Your input will be an arbitrary-length (row) vector, and you will produce a matrix where the first row is the initial vector and cach subsequent row is the result of one pass of the outer loop. See below for sample runs. select_sort Function: Input variables: • a vector of unsorted data Output variables: a matrix of the results after cach pass of the outer loop A possible sample case is: » data = select_sort([1 2 4 5 3]) data 1 4 5 3 1 4 3 1 2 4 3 4 1 2 4 5
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Similar questions
Recommended textbooks for you
Advanced Engineering Mathematics
Advanced Engineering Mathematics
Advanced Math
ISBN:
9780470458365
Author:
Erwin Kreyszig
Publisher:
Wiley, John & Sons, Incorporated
Numerical Methods for Engineers
Numerical Methods for Engineers
Advanced Math
ISBN:
9780073397924
Author:
Steven C. Chapra Dr., Raymond P. Canale
Publisher:
McGraw-Hill Education
Introductory Mathematics for Engineering Applicat…
Introductory Mathematics for Engineering Applicat…
Advanced Math
ISBN:
9781118141809
Author:
Nathan Klingbeil
Publisher:
WILEY
Mathematics For Machine Technology
Mathematics For Machine Technology
Advanced Math
ISBN:
9781337798310
Author:
Peterson, John.
Publisher:
Cengage Learning,
Basic Technical Mathematics
Basic Technical Mathematics
Advanced Math
ISBN:
9780134437705
Author:
Washington
Publisher:
PEARSON
Topology
Topology
Advanced Math
ISBN:
9780134689517
Author:
Munkres, James R.
Publisher:
Pearson,