The bubble sort algorithm is described in Chapter 5. If we want to sort data stored in a doubly-linked list, then bubble sort is a nice algorithm because we only need to swap adjacent entries in the list. Most other sorting algorithms require direct access to an element in the list given an index.
Create a doubly-linked list of 10 random integers, and write a bubble sort algorithm that sorts the list by swapping the integer values in adjacent nodes.
For example, to swap the nodes with 15 and 25 in the linked list below, we copy the integer values from one node to the other:
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.