You are on page 1of 6

School of informatics

Department of Information Systems


Course: Data structure and algorithm
Lab manual on basic sorting algorithm
Target group: - Information Systems 2nd year
students
By: Henok Alamineh
Phone no: +251920701414 // +251923485513
Email:henokalamineh@gmail.com

Wolaita sodo university


Wolaita sodo, Ethiopia
1. Bubble sorting
Bubble sort is a simple sorting algorithm that repeatedly step through the list, compares adjacent
elements and swaps them if they are in the wrong order. The pass through the list is repeated
until the list is sorted.
How it works?
1. Compare the first two elements of the list. If the first element is greater than the second
element, swap them.
2. Move to the second pair of the elements, compare them and swap if necessary.
3. Continue this process for every pair of adjacent elements until the end of the list is
reached.
4. Start again from the beginning of the list until no more swaps are needed, which indicates
that the list is now sorted.
2. Selection Sorting
Selection sort is a simple sorting algorithm that works by selecting the smallest element from the
unsorted part of the list and swapping it with the first element in the unsorted part. This process
is repeated until the entire list is sorted.
Steps on how selection sort work:
1. Find the smallest element in the unsorted part of the list.
2. Swap that element with the first element in the unsorted part.
3. Move the boundary between sorted and unsorted parts of the element to the right.
4. Repeat steps 1-3 until the entire list is sorted.
3. Insertion sorting

You might also like