Q1. Write a complete C++ program that implements a heap in an integer array of size 50. Implement the heap class with add and remove member methods and call the add method in the client code to add 15 randomly generated numbers to the heap. Show it works correctly by removing 5 values from it. These would be the 5 largest out of the 15 numbers stored in the heap.
b. Add a method that accepts a number between 0 and 49 and returns two data values. It uses the number as an index into the heap array and reports the data value stored. It also identifies and reports the data value stored at its parent node. Your program should report if any of these indices are empty or out of bounds.
2. Write a complete C++ program to implement a binary tree with a recursive function named search that takes as input the pointer to the root of a binary tree (not a BST!) and a value K, and returns true if value K appears in the tree and false otherwise. You must implement the tree using linked implementation whether structured or object oriented.
WARNING: If you build a BST, you would lose 75% of the points in this question.
- Copy the complete source code here.
- Copy the screenshot of the test run of the code with at least 12 integer values stored in the binary tree and you look for a value that would be found in the tree and another value that would not be found in the tree.
- Add another function for the above tree that counts the number of odd integers stored in all the nodes and returns the sum. Copy the screenshot of the test run of the function with at least 5 odd integers stored in the tree.
implement heap , binary tree other requirement in question
Do you need help with this assignment or any other? We got you! Place your order and leave the rest to our experts.