0% found this document useful (0 votes)
1 views2 pages

Sorting Notes

The document provides detailed notes on various sorting algorithms including Selection Sort, Insertion Sort, Bubble Sort, Quick Sort, Merge Sort, and Radix Sort, along with their definitions and examples. It also covers searching algorithms such as Linear Search and Binary Search, explaining how each method operates. Each algorithm is described with a brief explanation and an illustrative example for clarity.

Uploaded by

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

Sorting Notes

The document provides detailed notes on various sorting algorithms including Selection Sort, Insertion Sort, Bubble Sort, Quick Sort, Merge Sort, and Radix Sort, along with their definitions and examples. It also covers searching algorithms such as Linear Search and Binary Search, explaining how each method operates. Each algorithm is described with a brief explanation and an illustrative example for clarity.

Uploaded by

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

Sorting and Searching – Detailed Notes

Selection Sort
Definition:
Selection Sort is a simple comparison-based sorting technique. It divides the array into two
parts: sorted and unsorted. It repeatedly selects the minimum element from the unsorted
part and moves it to the end of the sorted part.

Example:
Input: [29, 10, 14, 37, 14]
Step 1: [10, 29, 14, 37, 14]
Step 2: [10, 14, 29, 37, 14] ...

Insertion Sort
Definition:
Insertion Sort builds the sorted array one element at a time. It takes an element and inserts
it at the correct position in the already sorted part.

Example:
Input: [5, 2, 4, 6, 1, 3]
Step 1: [2, 5, 4, 6, 1, 3]
Step 2: [2, 4, 5, 6, 1, 3] ...

Bubble Sort
Definition:
Bubble Sort repeatedly steps through the list, compares adjacent elements, and swaps them
if they are in the wrong order. This continues until no swaps are needed.

Example:
Input: [5, 1, 4, 2, 8]
Step 1: [1, 4, 2, 5, 8] ...

Quick Sort
Definition:
Quick Sort is a divide-and-conquer algorithm. It picks a 'pivot' element, partitions the array
around the pivot (elements less than pivot to the left, greater to the right), and then
recursively sorts the partitions.

Example:
Input: [10, 7, 8, 9, 1, 5]
Pivot = 5, Partitions: [1], [5], [10, 7, 8, 9] ...
Merge Sort
Definition:
Merge Sort is a divide-and-conquer sorting algorithm. It divides the array into halves,
recursively sorts them, and merges the sorted halves.

Example:
Input: [38, 27, 43, 3, 9, 82, 10]
Divide: [38, 27, 43] and [3, 9, 82, 10] ...

Radix Sort
Definition:
Radix Sort is a non-comparative sorting algorithm. It sorts the elements based on digits
(from least significant digit to most significant). It is useful for integers and fixed-length
strings.

Example:
Input: [170, 45, 75, 90, 802, 24, 2, 66]
Sort by units → tens → hundreds.

Linear Search
Definition:
Linear Search checks each element one by one from the start to the end until the desired
element is found or the list ends.

Example:
Search 4 in [1, 3, 5, 4, 2]: Found at index 3

Binary Search
Definition:
Binary Search works on a **sorted** array. It repeatedly divides the search interval in half
and compares the middle element with the target.

Example:
Search 6 in [1, 3, 5, 6, 9, 11]: Mid=5, Go left, Mid=6 → Found

You might also like