SlideShare a Scribd company logo
Understanding
Heap creation
Dr. Gopika S
Assistant Professor
Department of Computer Science
Kristu Jayanti College
Heap & Heap Sort – Introduction
• Many sorting methods exists to arrange elements in ascending or
descending order like bubble sort , merge sort, selection sort etc
• A heap sort is a sorting method which uses the concept of heap.
• What is a heap ? A heap is a variant of binary tree
• Types of Heap
 Min heap
Max heap
Understanding Heap sort Ms. Gopika S , Department of Computer Science, Kristu Jayanti College, Bengaluru
Construction of Max Heap
Understanding Heap sort Ms. Gopika S , Department of Computer Science, Kristu Jayanti College, Bengaluru
Example data set = [ 23,34,44,17,21,18,6]
23
34
34
23
Heap property is violated - Not a
heap Now its a heap
Understanding Heap sort Ms. Gopika S , Department of Computer Science, Kristu Jayanti College, Bengaluru
23
34
Example data set = [ 23,34,44,17,21,18,6]
44
44
34 23
Example data set = [ 23,34,44,17,21,18,6]
Understanding Heap sort Ms. Gopika S , Department of Computer Science, Kristu Jayanti College, Bengaluru
44
34 23
17 21 18 6
44 34 23 17 21 18 6
HEAP IS CONSTRUCTED
Array representation of heap
HEAP SORT - STEPS
1. Create the heap using the available elements
2. Remove the root element of the heap and insert it as the last element of
the array
3. Repeat the above steps
Understanding Heap sort Ms. Gopika S , Department of Computer Science, Kristu Jayanti College, Bengaluru
HEAP SORT
Understanding Heap sort Ms. Gopika S , Department of Computer Science, Kristu Jayanti
College, Bengaluru
44
34 23
17 21 18 6
44 34 23 17 21 18 6
HEAP IS CONSTRUCTED
Array representation of heap
HEAP SORT
Understanding Heap sort Ms. Gopika S , Department of Computer Science, Kristu Jayanti College, Bengaluru
6
34 23
17 21 18 44
6 34 23 17 21 18 44
Array representation of heap
HEAP SORT
Understanding Heap sort Ms. Gopika S , Department of Computer Science, Kristu Jayanti College, Bengaluru
6
34 23
17 21 18
34
21 23
17 6 18
Heap Sort ( Continued…)
34 21 23 17 6 18
Understanding Heap sort Ms. Gopika S , Department of Computer Science, Kristu Jayanti College, Bengaluru
Array Representation
18 21 23 17 6 34
34
21 23
17 6 18
Heap sort (Continued…)
Understanding Heap sort Ms. Gopika S , Department of Computer Science, Kristu Jayanti College, Bengaluru
18
21 23
17 6
23
21 18
17 6
NOT A HEAP
NOW, THIS IS A HEAP
Heap Sort ( Continued…)
Continue the steps for heap sort
1. Create the heap using the available elements
2. Remove the root element of the heap and insert it
as the last element of the array
Understanding Heap sort Ms. Gopika S , Department of Computer Science, Kristu Jayanti College, Bengaluru
23
21 18
17 6
23 34 44
Sorted elements in the final array are
Heap Sort ( Continued…)
Understanding Heap sort Ms. Gopika S , Department of Computer Science, Kristu Jayanti College, Bengaluru
6
21 18
17
21
17 18
6
Final Array After sorting
Understanding Heap sort Ms. Gopika S , Department of Computer Science, Kristu Jayanti College, Bengaluru
6 17 18 21 23 34 44
Sorted elements in the final array are

More Related Content

PPT
Heapsort
faribasavari
 
PPT
Heapsort
Gopi Saiteja
 
PPTX
HEAP SORT .pptx
Fazlullah28
 
PPTX
Heap sort
Shayshab Azad
 
PPTX
Heap Sort in Design and Analysis of algorithms
samairaakram
 
PPT
Heap Sort (project).ppt
SudhaPatel11
 
PPT
Heap Sort (project).ppt
HemantSharma134028
 
PPT
Heap Sort (project).ppt
AmitShou
 
Heapsort
faribasavari
 
Heapsort
Gopi Saiteja
 
HEAP SORT .pptx
Fazlullah28
 
Heap sort
Shayshab Azad
 
Heap Sort in Design and Analysis of algorithms
samairaakram
 
Heap Sort (project).ppt
SudhaPatel11
 
Heap Sort (project).ppt
HemantSharma134028
 
Heap Sort (project).ppt
AmitShou
 

Similar to Heap creation from elements - Step by step Approach (20)

PPT
Heap Sort (project).pptccccccccccccccccccccccccccccccccccc
shesnasuneer
 
PPT
Data Structure Heap Sort Algorithom PPT
MdShahabuddin70
 
PPTX
heap Sort Algorithm
Lemia Algmri
 
PPT
Heapsort
Sardar Hussain
 
PDF
HeapSort
Tuqa Rmahi
 
PPT
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Soumen Santra
 
PPT
heap sort in the design anad analysis of algorithms
ssuser7319f8
 
PPTX
Heapsort using Heap
Mohamed Fawzy
 
PPT
Heapsort
imishtiaq
 
PPT
Heap Sort || Heapify Method || Build Max Heap Algorithm
Learning Courses Online
 
PPTX
Data structures and algorithms lab10
Bianca Teşilă
 
PPTX
Heap Sort 1053.pptx
ZainiXh
 
PPTX
Heap_Sort1.pptx
sandeep54552
 
PPTX
Heap sort
Anusha sivakumar
 
PDF
Heap Hand note
Abdur Rouf
 
PPT
Heapsort ppt
Mariam Saeed
 
PPTX
Design and analysis of algorithm
laibaNoor60
 
PPT
3-heapsort gajajag jahajahab jabajanan jabajan
RaviPandey598038
 
PPTX
heapsort
BhuvneshYadav13
 
PPTX
Heap Sort Algorithm
Musaddiq Khan
 
Heap Sort (project).pptccccccccccccccccccccccccccccccccccc
shesnasuneer
 
Data Structure Heap Sort Algorithom PPT
MdShahabuddin70
 
heap Sort Algorithm
Lemia Algmri
 
Heapsort
Sardar Hussain
 
HeapSort
Tuqa Rmahi
 
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Soumen Santra
 
heap sort in the design anad analysis of algorithms
ssuser7319f8
 
Heapsort using Heap
Mohamed Fawzy
 
Heapsort
imishtiaq
 
Heap Sort || Heapify Method || Build Max Heap Algorithm
Learning Courses Online
 
Data structures and algorithms lab10
Bianca Teşilă
 
Heap Sort 1053.pptx
ZainiXh
 
Heap_Sort1.pptx
sandeep54552
 
Heap sort
Anusha sivakumar
 
Heap Hand note
Abdur Rouf
 
Heapsort ppt
Mariam Saeed
 
Design and analysis of algorithm
laibaNoor60
 
3-heapsort gajajag jahajahab jabajanan jabajan
RaviPandey598038
 
heapsort
BhuvneshYadav13
 
Heap Sort Algorithm
Musaddiq Khan
 
Ad

More from GopikaS12 (10)

PPTX
History and Introduction to LINUX .pptx
GopikaS12
 
PPTX
Memory management concepts in operating system
GopikaS12
 
PPTX
Conditional control statements explains the programming constructs
GopikaS12
 
PPTX
Deadlock _Classic problems.pptx
GopikaS12
 
PPTX
Introduction to Tree .pptx
GopikaS12
 
PPTX
C Programming language - introduction
GopikaS12
 
PPTX
C formatted and unformatted input and output constructs
GopikaS12
 
PPTX
Data Structures: Stack Operations
GopikaS12
 
PPT
Net content in computer architecture
GopikaS12
 
PPTX
It unit 1
GopikaS12
 
History and Introduction to LINUX .pptx
GopikaS12
 
Memory management concepts in operating system
GopikaS12
 
Conditional control statements explains the programming constructs
GopikaS12
 
Deadlock _Classic problems.pptx
GopikaS12
 
Introduction to Tree .pptx
GopikaS12
 
C Programming language - introduction
GopikaS12
 
C formatted and unformatted input and output constructs
GopikaS12
 
Data Structures: Stack Operations
GopikaS12
 
Net content in computer architecture
GopikaS12
 
It unit 1
GopikaS12
 
Ad

Recently uploaded (20)

PDF
Zero carbon Building Design Guidelines V4
BassemOsman1
 
PDF
LEAP-1B presedntation xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
hatem173148
 
PPTX
FUNDAMENTALS OF ELECTRIC VEHICLES UNIT-1
MikkiliSuresh
 
PDF
settlement FOR FOUNDATION ENGINEERS.pdf
Endalkazene
 
PPTX
business incubation centre aaaaaaaaaaaaaa
hodeeesite4
 
PDF
Advanced LangChain & RAG: Building a Financial AI Assistant with Real-Time Data
Soufiane Sejjari
 
PDF
Introduction to Ship Engine Room Systems.pdf
Mahmoud Moghtaderi
 
PPTX
MT Chapter 1.pptx- Magnetic particle testing
ABCAnyBodyCanRelax
 
PDF
EVS+PRESENTATIONS EVS+PRESENTATIONS like
saiyedaqib429
 
PPTX
22PCOAM21 Session 2 Understanding Data Source.pptx
Guru Nanak Technical Institutions
 
PDF
Natural_Language_processing_Unit_I_notes.pdf
sanguleumeshit
 
DOCX
SAR - EEEfdfdsdasdsdasdasdasdasdasdasdasda.docx
Kanimozhi676285
 
PPT
Ppt for engineering students application on field effect
lakshmi.ec
 
PPTX
Inventory management chapter in automation and robotics.
atisht0104
 
PPTX
Victory Precisions_Supplier Profile.pptx
victoryprecisions199
 
PDF
flutter Launcher Icons, Splash Screens & Fonts
Ahmed Mohamed
 
PDF
The Effect of Artifact Removal from EEG Signals on the Detection of Epileptic...
Partho Prosad
 
PDF
top-5-use-cases-for-splunk-security-analytics.pdf
yaghutialireza
 
PPTX
Module2 Data Base Design- ER and NF.pptx
gomathisankariv2
 
PDF
20ME702-Mechatronics-UNIT-1,UNIT-2,UNIT-3,UNIT-4,UNIT-5, 2025-2026
Mohanumar S
 
Zero carbon Building Design Guidelines V4
BassemOsman1
 
LEAP-1B presedntation xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
hatem173148
 
FUNDAMENTALS OF ELECTRIC VEHICLES UNIT-1
MikkiliSuresh
 
settlement FOR FOUNDATION ENGINEERS.pdf
Endalkazene
 
business incubation centre aaaaaaaaaaaaaa
hodeeesite4
 
Advanced LangChain & RAG: Building a Financial AI Assistant with Real-Time Data
Soufiane Sejjari
 
Introduction to Ship Engine Room Systems.pdf
Mahmoud Moghtaderi
 
MT Chapter 1.pptx- Magnetic particle testing
ABCAnyBodyCanRelax
 
EVS+PRESENTATIONS EVS+PRESENTATIONS like
saiyedaqib429
 
22PCOAM21 Session 2 Understanding Data Source.pptx
Guru Nanak Technical Institutions
 
Natural_Language_processing_Unit_I_notes.pdf
sanguleumeshit
 
SAR - EEEfdfdsdasdsdasdasdasdasdasdasdasda.docx
Kanimozhi676285
 
Ppt for engineering students application on field effect
lakshmi.ec
 
Inventory management chapter in automation and robotics.
atisht0104
 
Victory Precisions_Supplier Profile.pptx
victoryprecisions199
 
flutter Launcher Icons, Splash Screens & Fonts
Ahmed Mohamed
 
The Effect of Artifact Removal from EEG Signals on the Detection of Epileptic...
Partho Prosad
 
top-5-use-cases-for-splunk-security-analytics.pdf
yaghutialireza
 
Module2 Data Base Design- ER and NF.pptx
gomathisankariv2
 
20ME702-Mechatronics-UNIT-1,UNIT-2,UNIT-3,UNIT-4,UNIT-5, 2025-2026
Mohanumar S
 

Heap creation from elements - Step by step Approach

  • 1. Understanding Heap creation Dr. Gopika S Assistant Professor Department of Computer Science Kristu Jayanti College
  • 2. Heap & Heap Sort – Introduction • Many sorting methods exists to arrange elements in ascending or descending order like bubble sort , merge sort, selection sort etc • A heap sort is a sorting method which uses the concept of heap. • What is a heap ? A heap is a variant of binary tree • Types of Heap  Min heap Max heap Understanding Heap sort Ms. Gopika S , Department of Computer Science, Kristu Jayanti College, Bengaluru
  • 3. Construction of Max Heap Understanding Heap sort Ms. Gopika S , Department of Computer Science, Kristu Jayanti College, Bengaluru Example data set = [ 23,34,44,17,21,18,6] 23 34 34 23 Heap property is violated - Not a heap Now its a heap
  • 4. Understanding Heap sort Ms. Gopika S , Department of Computer Science, Kristu Jayanti College, Bengaluru 23 34 Example data set = [ 23,34,44,17,21,18,6] 44 44 34 23
  • 5. Example data set = [ 23,34,44,17,21,18,6] Understanding Heap sort Ms. Gopika S , Department of Computer Science, Kristu Jayanti College, Bengaluru 44 34 23 17 21 18 6 44 34 23 17 21 18 6 HEAP IS CONSTRUCTED Array representation of heap
  • 6. HEAP SORT - STEPS 1. Create the heap using the available elements 2. Remove the root element of the heap and insert it as the last element of the array 3. Repeat the above steps Understanding Heap sort Ms. Gopika S , Department of Computer Science, Kristu Jayanti College, Bengaluru
  • 7. HEAP SORT Understanding Heap sort Ms. Gopika S , Department of Computer Science, Kristu Jayanti College, Bengaluru 44 34 23 17 21 18 6 44 34 23 17 21 18 6 HEAP IS CONSTRUCTED Array representation of heap
  • 8. HEAP SORT Understanding Heap sort Ms. Gopika S , Department of Computer Science, Kristu Jayanti College, Bengaluru 6 34 23 17 21 18 44 6 34 23 17 21 18 44 Array representation of heap
  • 9. HEAP SORT Understanding Heap sort Ms. Gopika S , Department of Computer Science, Kristu Jayanti College, Bengaluru 6 34 23 17 21 18 34 21 23 17 6 18
  • 10. Heap Sort ( Continued…) 34 21 23 17 6 18 Understanding Heap sort Ms. Gopika S , Department of Computer Science, Kristu Jayanti College, Bengaluru Array Representation 18 21 23 17 6 34 34 21 23 17 6 18
  • 11. Heap sort (Continued…) Understanding Heap sort Ms. Gopika S , Department of Computer Science, Kristu Jayanti College, Bengaluru 18 21 23 17 6 23 21 18 17 6 NOT A HEAP NOW, THIS IS A HEAP
  • 12. Heap Sort ( Continued…) Continue the steps for heap sort 1. Create the heap using the available elements 2. Remove the root element of the heap and insert it as the last element of the array Understanding Heap sort Ms. Gopika S , Department of Computer Science, Kristu Jayanti College, Bengaluru 23 21 18 17 6 23 34 44 Sorted elements in the final array are
  • 13. Heap Sort ( Continued…) Understanding Heap sort Ms. Gopika S , Department of Computer Science, Kristu Jayanti College, Bengaluru 6 21 18 17 21 17 18 6
  • 14. Final Array After sorting Understanding Heap sort Ms. Gopika S , Department of Computer Science, Kristu Jayanti College, Bengaluru 6 17 18 21 23 34 44 Sorted elements in the final array are