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

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

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
1

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY