0% found this document useful (0 votes)
9 views9 pages

Introduction To Sort Algorithms 2

Uploaded by

thetruexy27
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views9 pages

Introduction To Sort Algorithms 2

Uploaded by

thetruexy27
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Introduction to Sort

Algorithms
Sort algorithms are essential tools in Computing, enabling efficient
organization and processing of data. This presentation explores
different types of sort algorithms and their key characteristics.

Group 5
CONTENT
By Akanbi Isreal • Basic classification of
& Dotun Dosumu algorithms
• Types of sort algorithms
• Bubble sort algorithm
• Merge sort algorithm
• Quick sort algorithm
• Insertion sort algorithm
• Importance
• Conclusion
BASIC CLASSIFICATION OF
ALGORITHMS

1. COMPARISON-BASED SORTING ALGORITHMS: 4. SPECIALIZED SORTING ALGORITHMS : they


these algorithms compare elements to include;
determine their order. Examples include
a. External merge sort: used for sorting
bubble sort, selection sort, insertion
large datasets that do not fit in memory
sort, merge sort etc.…
b. Bitonic sort: used for parallel
2. NON-COMPARISON-BASED SORTING
processing and sorting networks
ALGORITHMS : these algorithms do not
(Swapping adjacent materials)
compare elements directly. They are
mostly efficient for specific scenarios. c. Pigeonhole sort: efficient for a small
Examples include counting sort, radix range of integers.
sort and bucket sort.
3. HYBRID SORTING ALGORITHMS : they
combine features of multiple algorithm
for better performance. Examples
include Time sort and intro sort.
Types of Sort Algorithms
1 Bubble Sort 2 Merge Sort
A simple algorithm that repeatedly steps through the list, A recursive algorithm that repeatedly divides the list into
comparing adjacent elements and swapping them if they halves, sorts each half, and then merges the sorted halves
are in the wrong order. back together.

3 Quick Sort 4 Insertion Sort


A divide-and-conquer algorithm that partitions the list A simple algorithm that builds a sorted list one item at a
around a pivot element and recursively sorts the sub-lists. time, inserting each new item into its correct position in the
sorted list.
Bubble Sort Algorithm Imagine you need to sort a list of numbers in smallest to
largest
Original list: (100, 500, 200, 300)
Step 1 1. Compare 100 and 500. No swap needed
Compare adjacent elements and swap them if they are in the wrong order.
2. Compare 500 and 200. Swap: (100, 200, 500, 300)
3. Compare 500 and 300. Swap: (100, 200, 300, 500)
Final sorted list: (100, 200, 300, 500)

Step 2
Repeat step 1 for the entire list, ensuring the largest element is at the end.

Step 3
Repeat steps 1 and 2 for the remaining unsorted elements, excluding the already sorted elements.
Think of it like combining two sorted lists
of names:
-Split the list into two: A-M and N-Z

Merge Sort Algorithm -Divide them again until you have


individual Letters (A), (B)
- Merge them: A, B, C, ..., N, O, P, ..., Z
(smallest to biggest)

Divide
1
Divide the list into halves until each sub-list contains only one element.

Conquer
2 Sort each sub-list by comparing adjacent elements and swapping them if
they are in the wrong order.

Combine
3 Merge the sorted sub-lists back together into a single
sorted list.
Quick Sorting Algorithm:

Quick sort is a highly Quick Sort:


efficient sorting algorithm
that utilizes a divide-and- 1. Pick a "pivot" item from the list.
2. Divide the list into two parts: items
conquer approach. It
smaller than the pivot and items larger.
partitions the input array 3. Repeat steps 1-2 with each part until the
around a pivot element, list is sorted.
recursively sorting the sub- 4. Think of it like organizing a pile of clothes:-
arrays until the entire array Pick a shirt (pivot)- Put smaller shirts on
is sorted. one side, larger on the other- Repeat with
each pile until everything is sorted!
Insertion Sorting Algorithm:

Insertion sort builds a sorted array one element at a time. It iterates through the array,
inserting each element into its correct position in the already sorted subarray.
Insertion sort is efficient for small arrays or nearly sorted arrays. It is also used as a
subroutine in other sorting algorithms, such as Shell sort.

1. Start with the first item. (13245)


2. Create a new sub-array for sorting(
)
3. Insert the next item into its correct
position.(1)
4. Repeat step 3 until the list is
sorted.
Finally: (1,2,3,4,5)
Importance of Sort Algorithms
Data Organization Search Efficiency

Sort algorithms enable efficient organization of data, Sorted data allows for faster search operations, reducing
making it easier to search, access, and process. the time required to find specific information.
Conclusion and Key
Takeaways
Understanding and selecting the appropriate sort algorithm is crucial
for efficient data processing. Consider the data size, complexity, and
desired performance when choosing the right algorithm for your
specific needs.

You might also like