Follow

Translate

Friday, March 11, 2016

Example Using the bubble sort algorithm

Using the bubble sort algorithm, Algorithm 4.4, find the number C of comparisons and the number D of interchanges which alphabetize the n = 6 letters in PEOPLE.


The sequence of pairs of letters which are compared in  each of the n - 1 = 5 Passes follow:
a square indicates that the pair of letters is compared and interchanged, and a circle indicates that the pair of letters is compared but not interchanged.


Pass 1.  P E O P L E,   E P O PLE,  E O P P L E
            E O P P L E     E O P L P E   E O P L E P


Pass 2.    E O P L E P,   E O P L E P,    E O P L E P
               E O L P E P,     E O L E P P

Pass 3.   E O L E P P,  E O L E P P,  E L O E P P
             E L E O P P

Pass 4.  E L E O P P,  E L E O P P,  E E L O P P

Pass 5.   E E L O P P,   E E L O P P  
If You want to learn about the technology, computer science & engineering, web programming, freelancing, earning please click here :CSE SOLVE

0 comments:

Post a Comment