QuickSort and Huffman Coding Algorithm
QuickSort and 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
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
Character Frequency
A:5, I:3, M:2, N:2, Z:2, T:1, J:1, L:1
Huffman Tree
17
7 10
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.