0% found this document useful (0 votes)
7 views

QuickSort and Huffman Coding Algorithm

The document presents an overview of the QuickSort and Huffman Coding algorithms. QuickSort is a divide-and-conquer sorting algorithm with an average time complexity of O(n log n), while Huffman Coding is a lossless compression technique that assigns shorter codes to more frequent characters for efficient data storage and transmission. Both algorithms are widely used in computer science for sorting and file compression applications.

Uploaded by

apollo3122003
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

QuickSort and Huffman Coding Algorithm

The document presents an overview of the QuickSort and Huffman Coding algorithms. QuickSort is a divide-and-conquer sorting algorithm with an average time complexity of O(n log n), while Huffman Coding is a lossless compression technique that assigns shorter codes to more frequent characters for efficient data storage and transmission. Both algorithms are widely used in computer science for sorting and file compression applications.

Uploaded by

apollo3122003
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

QUICK SORT ALGORITHM

&

HUFFMAN CODING ALGORITHM

Presented to Presented by
MD Faizul Abedin Shibli Name: Tanzina Jamal Miazi
Lecturer ID: 232031006
Dept. of Computer Science & 31st(UG)
Engineering
INTRODUCTION TO
QUICKSORT
₪ QuickSort is an efficient divide-and-
conquer sorting algorithm.
₪ It recursively selects a pivot, partitions
the list, and sorts smaller sublists.
₪ It has a time complexity of O(n log n)
in the average case.

6 8 7 1 2 4 1 2 4 6 7 8
QuickSort Steps

❑ Choose a pivot: Select an element from the array (often


the last element).
❑ Partition: Rearrange the array so that all elements smaller
than the pivot are on the left and all the elements larger
than the pivot are on the right
❑ Recursion: Apply the same process recursively to the left
and right subarray

6 8 7 1 2 4

1 2 4 6 8 7

Pivot
QuickSort Pseudocode
QuickSort Example
ID: 232031006

2 3 0 1 6 Pivot

2 3 0 1 6 None

Pivot
Pivot
Recursive
Way up
0 1 2 3 Pivot

0 1 2 3

Sorted Array 0 1 2 3 6
QuickSort Conclusion
❑ QuickSort is fast and efficient for large datasets.
❑ Uses divide-and-conquer to sort efficiently.

Time Complexity:
o Best/Average Case: O(n log n)
o Worst Case: O(n²) (when pivot selection is poor).
INTRODUCTION
TO
HUFFMAN CODING

₪ Huffman Coding is a compression algorithm used


to reduce file size.
₪ It assigns shorter codes to more frequent
characters.
₪ Used in file compression (ZIP, JPEG, MP3).
Huffman Coding Steps

❑ Count Character Frequencies.


❑ Build a Min-Heap of characters sorted by
frequency.
❑ Construct Huffman Tree by merging nodes.
❑ Assign Binary Codes (shorter for more
frequent characters).
Huffman Coding Example
(TANZINAJAMALMIAZI)

Character Frequency
A:5, I:3, M:2, N:2, Z:2, T:1, J:1, L:1
Huffman Tree
17

7 10

I:3 (N,Z):4 A:5 (M,L,T,J):5

N:2 Z:2 M:2 (L,T,J):3

L:1 (T,J):2

T:1 J:1
Assign Huffman Codes
T = 11110
A = 10
N = 010
Z = 011
I = 00
J = 11111
M = 110
L = 1110

(TANZINAJAMALMIAZI) 111101001001100010101111110110101110110001001100
Huffman Coding
Conclusion
❑ Huffman coding is a powerful lossless compression
technique.
❑ It efficiently reduces data size by assigning shorter
codes to frequent characters.
❑ Used in file compression formats like ZIP, JPEG,
and MP3.
❑ Constructs an optimal binary tree for encoding
characters based on frequency.
❑ Helps in efficient data transmission and storage.

You might also like