Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can somebody solve the todo parts of this problem. #include #include VectorADT.h template VectorADT ::VectorADT (){ dataArray= new T*[SIZE]; count=0; } //TODO Copy constructor that

Can somebody solve the todo parts of this problem.

#include #include "VectorADT.h"

template VectorADT::VectorADT (){ dataArray= new T*[SIZE]; count=0; } //TODO Copy constructor that is called when a new vectorADT ic created and equated with the "other" ADT vector object template VectorADT::VectorADT(const VectorADT &other){ //TODO } //destructor template //TODO }

template void VectorADT::resizeADT(){ size_t newSize=2*count; SIZE=SIZE*2; T ** tempADT = new T*[newSize]; for (int i=0;i void VectorADT::push_back(T *v){ //std::cout<toString(); if (count>=SIZE) resizeADT(); dataArray[count]= v; count++; } template T * VectorADT::pop(){ if (!empty()) return dataArray[count-1]; else{ throw new std::string("No such element exception"); exit(-1); } } template T * VectorADT::pop_back() { T * v = new T(); if (!empty()){ v= dataArray[count-1]; count--; return v;} else { throw new std::string("No such element exception"); exit(-1); } } template void VectorADT::printVectorADT(){ for (int i=0;i int VectorADT::size() const { return count;}

template int VectorADT::sortTitle(LessThanEqual less){ //TODO } template int VectorADT::sort(LessThan less){ int steps=0; T * minValue= new T(); int minIndex=0; for (int i=0;i bool VectorADT:: empty(){ return (count<=0); } template T* VectorADT:: get(int i) const{ if (i>=0 && i void VectorADT::set(int i, T * t){ if (i>=0 && i int VectorADT::insert(T * v, int pos){ // USe from Assignment 1 } template int VectorADT::remove(int pos){ //Use from Assignment 1 } template int VectorADT::binarySearchByTitle(int& steps, T * v, int first, int last){ //TODO } template int VectorADT::binarySearchByTitle(int& steps, T * v){ return binarySearchByTitle( steps, v, 0, count-1); }

#include template

//template class VectorADT{

int SIZE = 2;

private: T ** dataArray = nullptr; //dataArray= new T*[SIZE]; int count; public: //default constructor VectorADT(); //copy constructor VectorADT(const VectorADT & other); //destructor ~VectorADT(); // return address of element at index position i T* get(int i) const; // set the element e at position i void set(int i, T *); // print the entire database void printVectorADT(); // print the number of items specified void printVectorADT(int number); // double the size of the database by //creating another database twice the size and copying //the existing database into it. The existing one is then deleted void resizeADT(); // returns true if database is empty, false otherwise bool empty();

//returns the number of items in the database int size() const; // add an item to the end of the database void push_back(T *); // remove and return the last element of the database if there is one T* pop_back(); // "peeks" ie returns a pointer to the last element without removing or deleting it T* pop(); // inserts at the proper position, no sorting necessary // element is inserted at index =pos //if pos is negative or unacceptable number throws exception and exits //returns the number of adjustments done to shift data to right int insert(T * v, int pos);

// deletes the item at index position =pos //if database is empty or pos is negative or an unacceptable number throws exception and exits //returns the number of adjustments done to shift data left int remove(int pos);

void topTen(); // prints top 10 items // kept sorted according to position - use function objects - selection sort

//selection sorts using chart positon int sort(LessThan f); //selection sorts using title int sortTitle(LessThanEqual f); // overloaded binary search that has additional parameters, this is prelude to recursive binary search int binarySearchByTitle(int& steps, T * v, int first, int last); // binary search that calls the overloaded function with first =0 and last = count-1; The data v contains the title being searched int binarySearchByTitle(int& steps, T * v); };

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Mary Z. Last

8th edition

1285427106, 978-1285427102

More Books

Students also viewed these Databases questions

Question

=+How should it be delivered?

Answered: 1 week ago