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

Laboratory Exercise 2_ Heap Data Structure Operations

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

Laboratory Exercise 2_ Heap Data Structure Operations

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

Laboratory Exercise 2: Heap Data Structure Operations

Objective: Implement and interact with a Heap Data Structure (either Max-Heap or Min-Heap)
by performing operations such as insertion, deletion, getting the maximum/minimum value, and
removing the maximum/minimum value. The program will ensure that only 10 valid whole
numbers are accepted as input.

Instructions:

1.​ Create a Heap Class:


○​ Implement the heap as an array to store the elements.
○​ Include utility methods to maintain heap properties ​
(e.g., heapify, bubble up, bubble down).
2.​ Implement the Following Functions:
○​ Insert: Add a new value to the heap while maintaining the heap property.
○​ Delete: Remove an element from the heap by index or value (validate the input).
○​ GetMax/GetMin: Return the maximum or minimum value from the heap without
removing it.
○​ RemoveMax/RemoveMin: Remove and return the maximum or minimum value
from the heap while maintaining the heap property.
3.​ Add Input Validation:
○​ Ensure the user can input only whole numbers.
○​ Reject floating-point numbers, characters, and invalid inputs with appropriate
error messages.
○​ Limit the input to 10 numbers for insertion.
4.​ Menu-Driven Program:
○​ Allow users to choose an operation from a menu:
1.​ Insert a value.
2.​ Delete a value.
3.​ GetMax (for max-heap) or GetMin (for min-heap).
4.​ RemoveMax (for max-heap) or RemoveMin (for min-heap).
5.​ Exit.
5.​ Edge Cases to Consider:
○​ Insertion when the heap already contains 10 elements.
○​ Deletion or removal from an empty heap.
○​ Attempting to get maximum/minimum from an empty heap.
○​ Invalid input for numeric values.
Laboratory Exercise 2: Heap Data Structure Operations
6.​ Submission:
○​ Implement the entire program in C++.
○​ Submit the source code as a .cpp file with a file name.
■​ <LA2_LastName1_LastName2_LastName3.cpp>.
○​ Ensure the program compiles and runs correctly before submission.
○​ Group Activity - Max Member Is Three (3)

7.​ Expected Output​


Laboratory Exercise 2: Heap Data Structure Operations
Criteria for Grading:

1.​ Code Quality and Structure (25 points)


○​ Code is logically organized with a clear structure.
○​ Functions are well-defined and appropriately modularized.
○​ Code is adequately commented on, especially for complex or critical
sections.
○​ Variable names and coding styles enhance readability.
2.​ Error Handling and Edge Cases (25 points)
○​ The program effectively handles edge cases (e.g., empty heaps, invalid inputs,
non-existent elements).
○​ Clear and descriptive error messages are displayed for invalid inputs or
operations.
○​ Input validation ensures that only whole numbers are accepted.
3.​ User Interface and Interaction (25 points)
○​ The menu is intuitive, with clear and concise prompts for user input.
○​ The output is well-formatted, and operations are easy to follow.
○​ User feedback is provided after each action (e.g., insertion success, value not
found).
4.​ Implementation and Originality (25 points)
○​ The code is an original creation, demonstrating a solid understanding of BST
concepts.
○​ Online resources may be referenced, but the implementation must reflect
personal effort.
○​ All required BST operations (insertion, searching, deletion, and specified
traversal) are correctly implemented.

Total Points: 100

You might also like