Professional Documents
Culture Documents
Lect 3
Lect 3
Lect 3
Array
Dr.Associate Professor
/Abdualmajed Al-Khulaidi
Array
Matrices: It is a collection of similar items, and
the items can be a numerical or symbolic value,
a mixture thereof, or a group of records.
Array Classifications
one –dimensional array •
matrix •
Sorting
Sorting: It is the arrangement of data in
ascending or descending order depending on a
linear relationship that links the elements of this
data together.
The benefits of the sorting process
-Minimize data traffic and data exchange, as
data exchange takes a great deal of time during
processing.
-Reducing the input and output process.
-Save time while searching for a specific element
of data.
Sorting types
1- Internal sorting methods: They are used when
we can place all the objects that we want to
arrange in the memory. Used with small data.
2-External sort: They are used when we cannot
place the objects that we want to arrange in the
memory. And used with big data.
Selection sort algorithm
1- We are looking for the smallest element in
the matrix .
2- The smallest element is exchanged for the
first element in the matrix. If it is found that the
smallest element in the matrix is in the first
digit, then there is no need to change.
3- Then find the smallest element in the matrix
minus the ordered portion.
Example
30 4 5 90 12 80 3 9
3 | 4 5 90 12 80 30 9
3 4 | 5 90 12 80 30 9
3 4 5 | 90 12 80 30 9
3 4 5 | 9 12 80 30 90
3 4 5 9 | 12 80 30 90
3 4 5 9 12 | 80 30 90
3 4 5 9 12 | 30 80 90
3 4 5 9 12 30 80 90
Quick Sort Algorithm