Logo 
Search:

C++ Programming FAQ

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

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

  Shared By: Vilmos Fischer    Date: Oct 09    Category: C++ Programming    Views: 1050

Answer:

It is a well-known sorting method. It differs from the selection sort in that, instead of finding the smallest record and then performing an interchange, two records are interchanged immediately upon discovering that they are out of order. In this method, after the first pass, the record with the largest key will be in the nth position. On each successive pass, the records with the next largest key will be placed in position n-1, n-2,…respectively.


Pass:

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

9 8 7 6 5 4 3 3 2 1
8 7 6 5 4 3 4 2 1 2
7 6 5 4 3 5 2 1 3 3
6 5 4 3 6 2 1 4 4 4
5 4 3 7 2 1 5 5 5 5
4 3 8 2 1 6 6 6 6 6
3 9 2 1 7 7 7 7 7 7
10 2 1 8 8 8 8 9 8 8
2 1 9 9 9 9 9 8 9 9
1 10 10 10 10 10 10 10 10 10

Share: 
 

Didn't find what you were looking for? Find more on What is Bubble 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: