Skip to content

Implementation of several sorting algorithms in Java. The sorting process is displayed via a Swing GUI.

Notifications You must be signed in to change notification settings

KaMuench/sorting-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sorting-java (IntellijIDEA)

This project contains several implementations of sorting algorithms. There is also a GUI to visualize the sorting process.

Implemented Algorithms

Bubblesort O(n^2)

This is probably the simplest sorting algorithm there is. The algorithm starts with the first element in the list and compares it to the second element. If the first one is bigger than the second they switch places. Now the element at the second position is compared with the third one. Same thing here. This process is done for all elements in the list. Then it starts over from the beginning. If all elements are in order the algorithm stops. At the end the elements are ordered from smallest to biggest. The algorithm got its name due to the elements being moved from one site of the list to the other, like bubbles in water ascent to the surface.

Bubblesort

Mergesort O(n*log(n))

This algorithm is a little more complex. It splits the list into two parts. The emerging lists are again split into two halfs. This process is repeated until the sublists can not be split further. For each split the two halfs are sorted. The first elements of both halfs are compared. The bigger element is added to a third list. Now the second element of one half is compared with the remaining first element of the other half. Again the greater element is added to the third list. This is done for all elements in both halfs. The third list is one half of the previous split, if it not contains all elements of the very first list. During the sorting process all the sublists are merged into one big list again, hence the name mergesort.

Mergesort

About

Implementation of several sorting algorithms in Java. The sorting process is displayed via a Swing GUI.

Topics

Resources

Stars

Watchers

Forks

Languages