Your task is sorting the given list by dictionary order, sorting operation must be realized using the bubble sort algorithm. Additionally, this list implementation should be written using a two-dimensional char ar- ray. Bubble Sort Algorithm 1 function swap ( a , b) 2 // F i l l own your own ! 3 end function 4 5 function compare ( a , b) 6 // Compare f unc t i on should be implemented 7 // to r e a l i z e the s o r t i n g c r i t e r i a . 8 // For example , e l ement s in a are s t r i n g s and 9 // the y are to be s o r t e d in d i c t i o n a r y order . 10 // strcmp f unc t i on can be used in p l a c e 11 // of compare f unc t i on . 12 end function 13 14 function bubbl e s o r t ( a , n) 15 while n != 0 16 high = 0 17 for i=0 to n=2 incremented by 1 18 i f compare ( a [ i ] , a [ i +1]) > 0 then 19 swap ( a [ i ] , a [ i +1]) 20 high = i+1 21 end i f 22 end for 23 n = high 24 end while 25 end function
Your task is sorting the given list by dictionary order, sorting
operation must be realized using the bubble sort
this list implementation should be written using a two-dimensional char ar-
ray.
Bubble Sort Algorithm
1 function swap ( a , b)
2 // F i l l own your own !
3 end function
4
5 function compare ( a , b)
6 // Compare f unc t i on should be implemented
7 // to r e a l i z e the s o r t i n g c r i t e r i a .
8 // For example , e l ement s in a are s t r i n g s and
9 // the y are to be s o r t e d in d i c t i o n a r y order .
10 // strcmp f unc t i on can be used in p l a c e
11 // of compare f unc t i on .
12 end function
13
14 function bubbl e s o r t ( a , n)
15 while n != 0
16 high = 0
17 for i=0 to n=2 incremented by 1
18 i f compare ( a [ i ] , a [ i +1]) > 0 then
19 swap ( a [ i ] , a [ i +1])
20 high = i+1
21 end i f
22 end for
23 n = high
24 end while
25 end function
1
Step by step
Solved in 2 steps