SlideShare ist ein Scribd-Unternehmen logo
1 von 2
Algorithm for checking whether an array is a min heap.
A binary heap is a heap data structure created using a binary tree. It can be seen as a binary tree
with two additional constraints: A bimaseap data structure created using a binary tanb seen as a
binary tree with two I. Shape property A binary heap is a complete binary tree, that is, all levels
of the tree, except possibly the last one (deepest) are fully filled, and, if the last level of the tree
is not complete, the nodes of that level are filled from left to right. II. Heap property All nodes
are either greater than or equal to or less than or equal to each of their children, according to a
comparison predicate defined for the heap. Heaps with a mathematical "greater than or equal
to" () comparison predicate are called max-heaps those with a mathematical "less than or equal
to" comparison predicate are called min-heaps. Min-heaps are often used to implement priority
queues. The figure below shows a complete binary tree along with its list representation.
Solution
ALGORITHM:
For i = 1, 2, …, [n/2], check whether
H[i] max {H [2i], H [2i+1]}
(Of course, if 2i+1 > n, just H[i] H [2i] needs to be satisfied)
If the inequality does not hold for some i, stop – the array is not a heap. If it holds for every
I = 1, 2, …., [n/2], it is a heap.
PSEUDO CODE:
For i = 1 to length (H) do:
begin
if 2 * i + 1 <= length (H)
IF (H[i] smaller than H[2i] ) OR (H[i] smaller than H[2i+1]):
return false
else if 2 * i <= lenght(H):
if H[i] smaller than H[2i]:
return false
else
break;
end
return true

Weitere ähnliche Inhalte

Mehr von wviola

Alice intends to send a secure message to Bob- (1) What are the threat.docx
Alice intends to send a secure message to Bob- (1) What are the threat.docxAlice intends to send a secure message to Bob- (1) What are the threat.docx
Alice intends to send a secure message to Bob- (1) What are the threat.docxwviola
 
Add a function prototype for the function sumNum- # include using nam.docx
Add a function prototype for the function sumNum- # include  using nam.docxAdd a function prototype for the function sumNum- # include  using nam.docx
Add a function prototype for the function sumNum- # include using nam.docxwviola
 
Add a new check on the emp table to make sure that any new employee in.docx
Add a new check on the emp table to make sure that any new employee in.docxAdd a new check on the emp table to make sure that any new employee in.docx
Add a new check on the emp table to make sure that any new employee in.docxwviola
 
Adding elements to an Array- Given the following simple List class tha.docx
Adding elements to an Array- Given the following simple List class tha.docxAdding elements to an Array- Given the following simple List class tha.docx
Adding elements to an Array- Given the following simple List class tha.docxwviola
 
Ad by DealsFactor - Close Menlo Company Contribution Income.docx
Ad by DealsFactor - Close           Menlo Company Contribution Income.docxAd by DealsFactor - Close           Menlo Company Contribution Income.docx
Ad by DealsFactor - Close Menlo Company Contribution Income.docxwviola
 
Action Center activation Administrative Tools Aero applets Computer Co (2).docx
Action Center activation Administrative Tools Aero applets Computer Co (2).docxAction Center activation Administrative Tools Aero applets Computer Co (2).docx
Action Center activation Administrative Tools Aero applets Computer Co (2).docxwviola
 
Acids Bases Taste Taste pH greater than pH less tharn Acids effect ind.docx
Acids Bases Taste Taste pH greater than pH less tharn Acids effect ind.docxAcids Bases Taste Taste pH greater than pH less tharn Acids effect ind.docx
Acids Bases Taste Taste pH greater than pH less tharn Acids effect ind.docxwviola
 
Action Center activation Administrative Tools Aero applets Computer Co.docx
Action Center activation Administrative Tools Aero applets Computer Co.docxAction Center activation Administrative Tools Aero applets Computer Co.docx
Action Center activation Administrative Tools Aero applets Computer Co.docxwviola
 
Action Center activation Administrative Tools Aero applets Computer Co (1).docx
Action Center activation Administrative Tools Aero applets Computer Co (1).docxAction Center activation Administrative Tools Aero applets Computer Co (1).docx
Action Center activation Administrative Tools Aero applets Computer Co (1).docxwviola
 
Acid lonization Constants (K-) for Some Monoprotic Weak Acids at 25 ec.docx
Acid lonization Constants (K-) for Some Monoprotic Weak Acids at 25 ec.docxAcid lonization Constants (K-) for Some Monoprotic Weak Acids at 25 ec.docx
Acid lonization Constants (K-) for Some Monoprotic Weak Acids at 25 ec.docxwviola
 
AC 556 Accounting for Governmental & Nonprofit Entities Chapter 6Solut.docx
AC 556 Accounting for Governmental & Nonprofit Entities Chapter 6Solut.docxAC 556 Accounting for Governmental & Nonprofit Entities Chapter 6Solut.docx
AC 556 Accounting for Governmental & Nonprofit Entities Chapter 6Solut.docxwviola
 
Accounting Which of the following is true of a corporation- OA- The st.docx
Accounting Which of the following is true of a corporation- OA- The st.docxAccounting Which of the following is true of a corporation- OA- The st.docx
Accounting Which of the following is true of a corporation- OA- The st.docxwviola
 
AC 556 Accounting for Governmental & Nonprofit Entities Chapter 7Solut.docx
AC 556 Accounting for Governmental & Nonprofit Entities Chapter 7Solut.docxAC 556 Accounting for Governmental & Nonprofit Entities Chapter 7Solut.docx
AC 556 Accounting for Governmental & Nonprofit Entities Chapter 7Solut.docxwviola
 
advantages and disadvantages of using centralized network management v.docx
advantages and disadvantages of using centralized network management v.docxadvantages and disadvantages of using centralized network management v.docx
advantages and disadvantages of using centralized network management v.docxwviola
 
Advantages & Disadvantages of Server Applications in 150+ wordsSolutio.docx
Advantages & Disadvantages of Server Applications in 150+ wordsSolutio.docxAdvantages & Disadvantages of Server Applications in 150+ wordsSolutio.docx
Advantages & Disadvantages of Server Applications in 150+ wordsSolutio.docxwviola
 
Does any one have a paper on human resource practices in countries bes.docx
Does any one have a paper on human resource practices in countries bes.docxDoes any one have a paper on human resource practices in countries bes.docx
Does any one have a paper on human resource practices in countries bes.docxwviola
 
Do you think Facebook should operate in China even if it means complyi.docx
Do you think Facebook should operate in China even if it means complyi.docxDo you think Facebook should operate in China even if it means complyi.docx
Do you think Facebook should operate in China even if it means complyi.docxwviola
 
Do you think contingent gains should be disclosed in the financial sta (1).docx
Do you think contingent gains should be disclosed in the financial sta (1).docxDo you think contingent gains should be disclosed in the financial sta (1).docx
Do you think contingent gains should be disclosed in the financial sta (1).docxwviola
 
Do you think contingent gains should be disclosed in the financial sta.docx
Do you think contingent gains should be disclosed in the financial sta.docxDo you think contingent gains should be disclosed in the financial sta.docx
Do you think contingent gains should be disclosed in the financial sta.docxwviola
 
Do you believe the double taxation of earnings which occurs at the cor.docx
Do you believe the double taxation of earnings which occurs at the cor.docxDo you believe the double taxation of earnings which occurs at the cor.docx
Do you believe the double taxation of earnings which occurs at the cor.docxwviola
 

Mehr von wviola (20)

Alice intends to send a secure message to Bob- (1) What are the threat.docx
Alice intends to send a secure message to Bob- (1) What are the threat.docxAlice intends to send a secure message to Bob- (1) What are the threat.docx
Alice intends to send a secure message to Bob- (1) What are the threat.docx
 
Add a function prototype for the function sumNum- # include using nam.docx
Add a function prototype for the function sumNum- # include  using nam.docxAdd a function prototype for the function sumNum- # include  using nam.docx
Add a function prototype for the function sumNum- # include using nam.docx
 
Add a new check on the emp table to make sure that any new employee in.docx
Add a new check on the emp table to make sure that any new employee in.docxAdd a new check on the emp table to make sure that any new employee in.docx
Add a new check on the emp table to make sure that any new employee in.docx
 
Adding elements to an Array- Given the following simple List class tha.docx
Adding elements to an Array- Given the following simple List class tha.docxAdding elements to an Array- Given the following simple List class tha.docx
Adding elements to an Array- Given the following simple List class tha.docx
 
Ad by DealsFactor - Close Menlo Company Contribution Income.docx
Ad by DealsFactor - Close           Menlo Company Contribution Income.docxAd by DealsFactor - Close           Menlo Company Contribution Income.docx
Ad by DealsFactor - Close Menlo Company Contribution Income.docx
 
Action Center activation Administrative Tools Aero applets Computer Co (2).docx
Action Center activation Administrative Tools Aero applets Computer Co (2).docxAction Center activation Administrative Tools Aero applets Computer Co (2).docx
Action Center activation Administrative Tools Aero applets Computer Co (2).docx
 
Acids Bases Taste Taste pH greater than pH less tharn Acids effect ind.docx
Acids Bases Taste Taste pH greater than pH less tharn Acids effect ind.docxAcids Bases Taste Taste pH greater than pH less tharn Acids effect ind.docx
Acids Bases Taste Taste pH greater than pH less tharn Acids effect ind.docx
 
Action Center activation Administrative Tools Aero applets Computer Co.docx
Action Center activation Administrative Tools Aero applets Computer Co.docxAction Center activation Administrative Tools Aero applets Computer Co.docx
Action Center activation Administrative Tools Aero applets Computer Co.docx
 
Action Center activation Administrative Tools Aero applets Computer Co (1).docx
Action Center activation Administrative Tools Aero applets Computer Co (1).docxAction Center activation Administrative Tools Aero applets Computer Co (1).docx
Action Center activation Administrative Tools Aero applets Computer Co (1).docx
 
Acid lonization Constants (K-) for Some Monoprotic Weak Acids at 25 ec.docx
Acid lonization Constants (K-) for Some Monoprotic Weak Acids at 25 ec.docxAcid lonization Constants (K-) for Some Monoprotic Weak Acids at 25 ec.docx
Acid lonization Constants (K-) for Some Monoprotic Weak Acids at 25 ec.docx
 
AC 556 Accounting for Governmental & Nonprofit Entities Chapter 6Solut.docx
AC 556 Accounting for Governmental & Nonprofit Entities Chapter 6Solut.docxAC 556 Accounting for Governmental & Nonprofit Entities Chapter 6Solut.docx
AC 556 Accounting for Governmental & Nonprofit Entities Chapter 6Solut.docx
 
Accounting Which of the following is true of a corporation- OA- The st.docx
Accounting Which of the following is true of a corporation- OA- The st.docxAccounting Which of the following is true of a corporation- OA- The st.docx
Accounting Which of the following is true of a corporation- OA- The st.docx
 
AC 556 Accounting for Governmental & Nonprofit Entities Chapter 7Solut.docx
AC 556 Accounting for Governmental & Nonprofit Entities Chapter 7Solut.docxAC 556 Accounting for Governmental & Nonprofit Entities Chapter 7Solut.docx
AC 556 Accounting for Governmental & Nonprofit Entities Chapter 7Solut.docx
 
advantages and disadvantages of using centralized network management v.docx
advantages and disadvantages of using centralized network management v.docxadvantages and disadvantages of using centralized network management v.docx
advantages and disadvantages of using centralized network management v.docx
 
Advantages & Disadvantages of Server Applications in 150+ wordsSolutio.docx
Advantages & Disadvantages of Server Applications in 150+ wordsSolutio.docxAdvantages & Disadvantages of Server Applications in 150+ wordsSolutio.docx
Advantages & Disadvantages of Server Applications in 150+ wordsSolutio.docx
 
Does any one have a paper on human resource practices in countries bes.docx
Does any one have a paper on human resource practices in countries bes.docxDoes any one have a paper on human resource practices in countries bes.docx
Does any one have a paper on human resource practices in countries bes.docx
 
Do you think Facebook should operate in China even if it means complyi.docx
Do you think Facebook should operate in China even if it means complyi.docxDo you think Facebook should operate in China even if it means complyi.docx
Do you think Facebook should operate in China even if it means complyi.docx
 
Do you think contingent gains should be disclosed in the financial sta (1).docx
Do you think contingent gains should be disclosed in the financial sta (1).docxDo you think contingent gains should be disclosed in the financial sta (1).docx
Do you think contingent gains should be disclosed in the financial sta (1).docx
 
Do you think contingent gains should be disclosed in the financial sta.docx
Do you think contingent gains should be disclosed in the financial sta.docxDo you think contingent gains should be disclosed in the financial sta.docx
Do you think contingent gains should be disclosed in the financial sta.docx
 
Do you believe the double taxation of earnings which occurs at the cor.docx
Do you believe the double taxation of earnings which occurs at the cor.docxDo you believe the double taxation of earnings which occurs at the cor.docx
Do you believe the double taxation of earnings which occurs at the cor.docx
 

Kürzlich hochgeladen

4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...JojoEDelaCruz
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptxmary850239
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptshraddhaparab530
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfErwinPantujan2
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYKayeClaireEstoconing
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfVanessa Camilleri
 

Kürzlich hochgeladen (20)

4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.ppt
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdf
 

Algorithm for checking whether an array is a min heap- A binary heap i.docx

  • 1. Algorithm for checking whether an array is a min heap. A binary heap is a heap data structure created using a binary tree. It can be seen as a binary tree with two additional constraints: A bimaseap data structure created using a binary tanb seen as a binary tree with two I. Shape property A binary heap is a complete binary tree, that is, all levels of the tree, except possibly the last one (deepest) are fully filled, and, if the last level of the tree is not complete, the nodes of that level are filled from left to right. II. Heap property All nodes are either greater than or equal to or less than or equal to each of their children, according to a comparison predicate defined for the heap. Heaps with a mathematical "greater than or equal to" () comparison predicate are called max-heaps those with a mathematical "less than or equal to" comparison predicate are called min-heaps. Min-heaps are often used to implement priority queues. The figure below shows a complete binary tree along with its list representation. Solution ALGORITHM: For i = 1, 2, …, [n/2], check whether H[i] max {H [2i], H [2i+1]} (Of course, if 2i+1 > n, just H[i] H [2i] needs to be satisfied) If the inequality does not hold for some i, stop – the array is not a heap. If it holds for every I = 1, 2, …., [n/2], it is a heap. PSEUDO CODE: For i = 1 to length (H) do: begin if 2 * i + 1 <= length (H) IF (H[i] smaller than H[2i] ) OR (H[i] smaller than H[2i+1]):
  • 2. return false else if 2 * i <= lenght(H): if H[i] smaller than H[2i]: return false else break; end return true