cpppro

Sorting A Linked List with Bubble Sort

In C Tidbits, Data Structures in C/C++, Pointers & Callbacks on April 11, 2007 at 10:01 pm

The basic idea of this sorting algorithm is to
compare two neighboring objects, and to swap them if
they are in the wrong order.

here is an example, which shows sorted list in several passes..

5   10   20   13   7   17
5   10   13   7    17  20
5   10   7    13   17  20
5   7    10   13   17  20
5   7    10   13   17  20

Here’s a snippet of C code for bubble sort for sorting an array:

Please refer http://www.refcode.net/2013/02/sorting-linked-list-with-bubble-sort.html

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: