SlideShare a Scribd company logo
1 of 20
Presentation
on
Greedy Algorithm (Optimal merge
pattern – Huffman coding)
Md. Monirul Alom - 162422011 (Group Leader)
Md. Moshiur Rahman Khan - 162422507
Md. Jahangir Alam - 162422004
Md. Rokan Uzzaman - 163432024
Md. Sanowar Hossain - 163432021
Md. Raisul Islam Ripon - 163432027
1
Greedy Algorithm
Greedy Algorithm finds the optimal solution from
the set of feasible solutions
2
X → Y
Possible solutions:
S1: Go by feet (walking)
S2: Go by bus
S3: Go by train
S4: Go by flight
….
….
Sn: There may be n solutions
3
X → Y
Possible solutions:
S1: Go by feet (walking)
S2: Go by bus
S3: Go by train
S4: Go by flight
….
….
Sn: There may be n solutions
Feasible solutions:
S3: Go by train
S4: Go by flight
8 hours
4
X → Y
Possible solutions:
S1: Go by feet (walking)
S2: Go by bus
S3: Go by train
S4: Go by flight
….
….
Sn: There may be n solutions
Feasible solutions:
S3: Go by train
S4: Go by flight
Optimal Solution:
S3: Go by train (Costs less)
5
Optimal merge pattern
A B
3 5
8 9
12 11
20 16
C
3
5
8
9
11
12
16
20
m n
4 4
Complexity: ϴ(m+n) = 8
6
List A B C D
Size 6 5 2 3
A
6
B
5
C
2
D
3
11
13
16
Cost = 11+13+16 = 40
7
List A B C D
Size 6 5 2 3
A
6
B
5
C
2
D
3
11 5
16
Cost = 11+5+16 = 32
8
List A B C D
Size 6 5 2 3
A
6
B
5
C
2
D
3
16
10
5
Cost = 5+10+16 = 31
9
List A B C D E
Size 6 5 2 3 7
C
2
D
3
B
5
A
6
E
7
Sorted in ascending order
10
List A B C D E
Size 6 5 2 3 7
C
2
D
3
B
5
A
6
E
7
5
10
23
13
11
List A B C D E
Size 6 5 2 3 7
C
2
D
3
B
5
A
6
Cost
5+10+13+23 = 51
E
7
5
10
23
13
2*3+3*3+5*2+6*2+7*2 = 51
12
Huffman Coding
Message: BCCABBDDAECCBBAEDDCC
Character
A
B
C
D
E
Length: 20
Size: 20*8 = 160 bits
13
Huffman Coding
Message: BCCABBDDAECCBBAEDDCC
Character
Code
A 000
B 001
C 010
D 011
E 100
Length: 20
Size: 20*3 = 60 bits
001010010000………
14
Huffman Coding
Message: BCCABBDDAECCBBAEDDCC
Character
Code
A 000
B 001
C 010
D 011
E 100
40
bits
15
bits
55 bits
Length: 20
Size: 20*3 = 60 bits
001010010000………
Total size = 60 +55
= 115 bits
15
Huffman Coding
Message: BCCABBDDAECCBBAEDDCC
Character
Frequency
A 3
B 5
C 6
D 4
E 2
2 3 4 5 6
E A D B C
Sorted in ascending order according to frequency
16
Huffman Coding
Message: BCCABBDDAECCBBAEDDCC
2 3 4 5 6
E A D B C
5
9
11
20
Character
Frequency
A 3
B 5
C 6
D 4
E 2
17
Huffman Coding
Message: BCCABBDDAECCBBAEDDCC
Character
Frequency
Code
A 3 001 3*3= 9
B 5 10 5*2=10
C 6 11 6*2=12
D 4 01 4*2=8
E 2 000 2*3=6
40
bits
20 12
bits
45 bits
2 3 4 5 6
E A D B C
5
9
11
200
0
0
0
1
11
1
Total = Message + table
= 45 + 52 = 97 bits
18
Decoding
Message: BCCABBDDAECCBBAEDDCC
2 3 4 5 6
E A D B C
5
9
11
200
0
0
0
1
11
1
101111001……..
19
Thank you
20

More Related Content

What's hot

Lecture 17 Iterative Deepening a star algorithm
Lecture 17 Iterative Deepening a star algorithmLecture 17 Iterative Deepening a star algorithm
Lecture 17 Iterative Deepening a star algorithmHema Kashyap
 
simple problem to convert NFA with epsilon to without epsilon
simple problem to convert NFA with epsilon to without epsilonsimple problem to convert NFA with epsilon to without epsilon
simple problem to convert NFA with epsilon to without epsilonkanikkk
 
Control Strategies in AI
Control Strategies in AIControl Strategies in AI
Control Strategies in AIAmey Kerkar
 
SHA 1 Algorithm.ppt
SHA 1 Algorithm.pptSHA 1 Algorithm.ppt
SHA 1 Algorithm.pptRajapriya82
 
Greedy Algorithm
Greedy AlgorithmGreedy Algorithm
Greedy AlgorithmWaqar Akram
 
Artificial Intelligence- TicTacToe game
Artificial Intelligence- TicTacToe gameArtificial Intelligence- TicTacToe game
Artificial Intelligence- TicTacToe gamemanika kumari
 
block ciphers
block ciphersblock ciphers
block ciphersAsad Ali
 
Depth first search [dfs]
Depth first search [dfs]Depth first search [dfs]
Depth first search [dfs]DEEPIKA T
 
Master method
Master method Master method
Master method Rajendran
 
AES by example
AES by exampleAES by example
AES by exampleShiraz316
 
04 brute force
04 brute force04 brute force
04 brute forceHira Gul
 
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting AlgorithmsPranay Neema
 
Transform coding
Transform codingTransform coding
Transform codingNancy K
 

What's hot (20)

Lecture 17 Iterative Deepening a star algorithm
Lecture 17 Iterative Deepening a star algorithmLecture 17 Iterative Deepening a star algorithm
Lecture 17 Iterative Deepening a star algorithm
 
simple problem to convert NFA with epsilon to without epsilon
simple problem to convert NFA with epsilon to without epsilonsimple problem to convert NFA with epsilon to without epsilon
simple problem to convert NFA with epsilon to without epsilon
 
Control Strategies in AI
Control Strategies in AIControl Strategies in AI
Control Strategies in AI
 
SHA 1 Algorithm.ppt
SHA 1 Algorithm.pptSHA 1 Algorithm.ppt
SHA 1 Algorithm.ppt
 
Huffman coding
Huffman coding Huffman coding
Huffman coding
 
Greedy Algorithm
Greedy AlgorithmGreedy Algorithm
Greedy Algorithm
 
Artificial Intelligence- TicTacToe game
Artificial Intelligence- TicTacToe gameArtificial Intelligence- TicTacToe game
Artificial Intelligence- TicTacToe game
 
block ciphers
block ciphersblock ciphers
block ciphers
 
Backtracking
BacktrackingBacktracking
Backtracking
 
Depth first search [dfs]
Depth first search [dfs]Depth first search [dfs]
Depth first search [dfs]
 
Master method
Master method Master method
Master method
 
AES by example
AES by exampleAES by example
AES by example
 
04 brute force
04 brute force04 brute force
04 brute force
 
Randomized algorithms ver 1.0
Randomized algorithms ver 1.0Randomized algorithms ver 1.0
Randomized algorithms ver 1.0
 
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting Algorithms
 
Disjoint sets
Disjoint setsDisjoint sets
Disjoint sets
 
Transform coding
Transform codingTransform coding
Transform coding
 
Divide and Conquer
Divide and ConquerDivide and Conquer
Divide and Conquer
 
Dataflow Analysis
Dataflow AnalysisDataflow Analysis
Dataflow Analysis
 
Hamiltonian path
Hamiltonian pathHamiltonian path
Hamiltonian path
 

Similar to Greedy Algorithm - Huffman coding

MD5 - Hash Functions & RIPEMD160
MD5 - Hash Functions & RIPEMD160MD5 - Hash Functions & RIPEMD160
MD5 - Hash Functions & RIPEMD160chuxuantinh
 
Hash functions MD5 and RIPEMD 160
Hash functions MD5 and RIPEMD 160Hash functions MD5 and RIPEMD 160
Hash functions MD5 and RIPEMD 160chutinhha
 
solution manual Design of Machinery: An Introduction to the Synthesis and Ana...
solution manual Design of Machinery: An Introduction to the Synthesis and Ana...solution manual Design of Machinery: An Introduction to the Synthesis and Ana...
solution manual Design of Machinery: An Introduction to the Synthesis and Ana...MichaelLeigh25
 
Gate ee 2012 with solutions
Gate ee 2012 with solutionsGate ee 2012 with solutions
Gate ee 2012 with solutionskhemraj298
 
Exams in college algebra
Exams in college algebraExams in college algebra
Exams in college algebraRaymond Garcia
 
assembly language programming and organization of IBM PC" by YTHA YU
assembly language programming and organization of IBM PC" by YTHA YUassembly language programming and organization of IBM PC" by YTHA YU
assembly language programming and organization of IBM PC" by YTHA YUEducation
 
Year 10 end of year exam revision 2
Year 10 end of year exam revision 2Year 10 end of year exam revision 2
Year 10 end of year exam revision 2harpermaths
 

Similar to Greedy Algorithm - Huffman coding (13)

Floyd Warshall Algorithm
Floyd Warshall AlgorithmFloyd Warshall Algorithm
Floyd Warshall Algorithm
 
MD5 - Hash Functions & RIPEMD160
MD5 - Hash Functions & RIPEMD160MD5 - Hash Functions & RIPEMD160
MD5 - Hash Functions & RIPEMD160
 
Hash functions MD5 and RIPEMD 160
Hash functions MD5 and RIPEMD 160Hash functions MD5 and RIPEMD 160
Hash functions MD5 and RIPEMD 160
 
solution manual Design of Machinery: An Introduction to the Synthesis and Ana...
solution manual Design of Machinery: An Introduction to the Synthesis and Ana...solution manual Design of Machinery: An Introduction to the Synthesis and Ana...
solution manual Design of Machinery: An Introduction to the Synthesis and Ana...
 
Gate ee 2012 with solutions
Gate ee 2012 with solutionsGate ee 2012 with solutions
Gate ee 2012 with solutions
 
MathsX.pdf
MathsX.pdfMathsX.pdf
MathsX.pdf
 
Đề Thi HK2 Toán 8 - THCS Hùng Vương
Đề Thi HK2 Toán 8 - THCS Hùng VươngĐề Thi HK2 Toán 8 - THCS Hùng Vương
Đề Thi HK2 Toán 8 - THCS Hùng Vương
 
Đề Thi HK2 Toán 8 - THCS Hùng Vương
Đề Thi HK2 Toán 8 - THCS Hùng VươngĐề Thi HK2 Toán 8 - THCS Hùng Vương
Đề Thi HK2 Toán 8 - THCS Hùng Vương
 
Exams in college algebra
Exams in college algebraExams in college algebra
Exams in college algebra
 
assembly language programming and organization of IBM PC" by YTHA YU
assembly language programming and organization of IBM PC" by YTHA YUassembly language programming and organization of IBM PC" by YTHA YU
assembly language programming and organization of IBM PC" by YTHA YU
 
What is a polynomial
What is a polynomialWhat is a polynomial
What is a polynomial
 
Year 10 end of year exam revision 2
Year 10 end of year exam revision 2Year 10 end of year exam revision 2
Year 10 end of year exam revision 2
 
Presentation (7).pptx
Presentation (7).pptxPresentation (7).pptx
Presentation (7).pptx
 

Recently uploaded

College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 

Recently uploaded (20)

DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 

Greedy Algorithm - Huffman coding