CPE212- Project05 Solved

35.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: zip solution files instantly, after Payment

Securely Powered by: Secure Checkout

Description

5/5 - (3 votes)

 

 

<Project05 Directions for Executing the Sample Solution>

You may run the sample solution by typing the following at a terminal window command prompt

/home/work/cpe212/project05/p05    inputfile  Note:  inputfile is called a Command-Line Argument

inputfile  must be the name of a text file in your current working directory All output is written to the standard output device (monitor). The grade preview script for Project05 is available at

/home/work/cpe212data/project05/preview05.bash

<Project05 Constraints> On Project05, you may only use the following include files:

 

#include <iostream>                                                              #include <new>

#include <iomanip>                                                               #include <cstddef>

#include <fstream>                                                                #include “heap.h”

#include <string>                                                                   

#include <cmath>

You are not allowed to utilize Global Variables!!   è  Recursive Function Calls are permitted!! ç

Failure to follow these directions will result in zero (0) credit on this assignment.

Once you are satisfied with your solution, submit your program files via CANVAS.

NOTE: make sure that you do not change the order in which the information is entered.  An automatic script is used to process all lab submissions, and if the order of the input information is modified, the script will not work properly with your program. <Project05 heap.cpp Description>

Your goal is to EXACTLY match the output of your program to that of the sample solution.

‘c’ è Constructor dynamically allocates a Heap object

‘+’ è Insert the data value that appears after the ‘+’ onto the Heap

‘-‘  è DeleteMax deletes the maximum value from the Heap

‘p’ è Print writes the contents of Heap to stdout 

‘s’ è Size returns the number of elements currently stored in the Heap object

‘e’ è MakeEmpty empties the heap leaving it ready to accept new data

‘m’ è Capacity returns the maximum number of elements currently allocated to the Heap object ‘d’ è Destructor deallocates the Heap object

 

 

<Project05 SmartHeap Class Description>

The SmartHeap class uses a dynamically allocated one dimensional array to store heap values.  When this array is filled to capacity, the next insert causes creation of a new array with twice the capacity.  Values from the smaller array are copied from the small array into the new larger array, and then the smaller array is deallocated to prevent a memory leak.

When deleting the maximum value, the process of expanding the array is reversed.  When the amount of data stored within the smart heap array dwindles to less than half of the current array capacity, you must resize the array without losing any data or creating a memory leak.  When resizing the array, cut the capacity in half.  However, be sure that you do not to shrink the array below the minimum array size of DEFAULTSIZE.

 

The data type of the value stored in each node is determined by the client code main.cpp. è Inline functions are not allowed in this course and will result in no credit (0) ç

[Note: An inline function is a function whose definition appears within the class declaration]

The SmartHeap class contains three private attributes, six private functions, and eight public member functions

è See the file smartheap.h for additional details regarding the function interfaces ç

 

<Project05 Hints>

Sample codes for the array implementation of the Heap container appear in Chapter 9 of the official course textbook,

C++ Plus Data Structures, Sixth edition  by Nell Dale, Chip Weems, and Tim Richards

  • project05-8wlzt8.zip