QuestionQuestion

Description
In this assignment you will be using the standard library's vector class to implement a binary heap of signed integers. Your heap should include the following (minimum) data/functionality:

class heap {
private:
std::vector<int> buffer;
public:
heap();
int size();
void insert(int value);
void remove_max();
int max();
void print();
};
   
You are responsible for testing your heap's functionality, but when I compile against my driver I should be able to say something like:
heap h;

for(int i=0; i<SOME_NUMBER; i++)
    h.insert(rand()%100);

while(h.size() > 0) {
    cout << h.max() << endl;
    h.remove_max();
}

Your program should behave well under similar circumstances.
Bonus:
Turn your class into a templated container. Your templated heap should function well for the C++ primitive types (numeric, char, bool). The templated version of your heap should look something like the following:
template
class heap {
private:
std::vector<T> buffer;
public:
heap();
int size();
void insert(T value);
void remove_max();
T max();
void print();
};

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

#include <cstdlib>
#include <cstddef>
#include "Node.h"
#include "BST.h"
using namespace std;

string filter(string input){
    string result = "";
    int j;
    for (j = 0; j < input.length(); j++) {
       if (isalpha(input[j])) {         
            break;
       }
    }
    if (j == input.length()) {
       return result;
    }
   
    int index1 = 0;
    int index2 = 0;
    for (int i = 0; i < input.length(); i++) {
       if (isalpha(input[i])) {
            index1 = i;
            break;
       }
    }
    for (int i = input.length() - 1; i >= 0; i--) {
       if (isalpha(input[i])) {            
            index2 = i;
            break;
       }
    }...

By purchasing this solution you'll be able to access the following files:
Solution.zip.

$60.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats