Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me with binary search for this problem in c++ #include #include VectorADT.h template VectorADT ::VectorADT (){ dataArray= new T*[SIZE]; count=0; } //GIVEN Copy

Please help me with binary search for this problem in c++

#include #include "VectorADT.h"

template VectorADT::VectorADT (){ dataArray= new T*[SIZE]; count=0; } //GIVEN 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){ dataArray= new T*[SIZE]; count=0; for (int i=0;i

T * s = new T(); *s=*temp; // created a copy constructor in Song to make this work push_back(s); } }

//destructor template VectorADT::~VectorADT() { for(int i=0; i

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){ int steps=0; T * minValue= new T(); int minIndex=0; for (int i=0;i

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

template int VectorADT::insert(T * v, int pos){ int adjustSteps=0; if (pos <0) { throw new std::string("No such position exception"); exit(-1); } if (pos>=count) {push_back(v);adjustSteps++;} if (pospos;i--){ dataArray[i]=dataArray[i-1]; adjustSteps++; } dataArray[pos]=v; } return adjustSteps; } template int VectorADT::remove(int pos){ int adjustSteps=0; //std::cout<<"Inside Remove"<

template int VectorADT::binarySearchByTitle(int& steps, T * v, int first, int last){ Please help me with this part

//TO DO } //GIVEN template int VectorADT::binarySearchByTitle(int& steps, T * v){ //set steps =0; steps=0; return binarySearchByTitle( steps, v, 0, count-1); }

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

More Books

Students also viewed these Databases questions

Question

Explain the causes of indiscipline.

Answered: 1 week ago