152k views
1 vote
I couldn't understand this algorithm. Please help me to do this.​

I couldn't understand this algorithm. Please help me to do this.​-example-1
User Leidolf
by
7.5k points

1 Answer

3 votes

Answer:

This is bubble sort, to alphabetize an array of strings.

Step-by-step explanation:

The algorithm walks through the array, and compares one value to the next. If the 'current' value is larger than the next, it swaps them, and starts all over.

So a value that lexographically is first to be alphabetized, will 'bubble' all the way to the top.

User Hakan Baba
by
7.7k points