Logo 
Search:

C++ Programming FAQ

Submit Interview FAQ
Home » Interview FAQ » C++ ProgrammingRSS Feeds

What is Selection Sort in dfs (data file structure)?

  Shared By: Adaliz Fischer    Date: Mar 14    Category: C++ Programming    Views: 1337

Answer:

It is the easiest way to sort a table. The sort is being performed from the first element; a search is performed to locate the element that is smaller than the key element. When this element is found, it is interchanged with the first element in the table. A search for the second smallest key is then carried out. Then it is started from the second element onwards. The element, which has the second smallest key, is interchanged with the element located in second position of table. This process continues till the array is in ascending order.


Pass:

Initially the elements of the array are:
9 8 7 6 5 4 3 2 1

|-- 9 1 1 1 1 1 1 1 1 1 --|
|-- 8 9 2 2 2 2 2 2 2 2 --|
|-- 7 8 9 3 3 3 3 3 3 3 --|
|-- 6 7 8 9 4 4 4 4 4 4 --|
|-- 5 6 7 8 9 5 5 5 5 5 --|
|-- 4 5 6 7 8 9 6 6 6 6 --|
|-- 3 4 5 6 7 8 9 7 7 7 --|
|-- 2 3 4 5 6 7 8 9 8 8 --|
V- 1 2 3 4 5 6 7 8 9 9 -V

Share: 
 

Didn't find what you were looking for? Find more on What is Selection Sort in dfs (data file structure)? Or get search suggestion and latest updates.


Your Comment
  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].


Tagged: