Please help me with the Binary Search by Title function 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"< Please help me with this part of the problem, Thanks! template int VectorADT::binarySearchByTitle(int& steps, T * v, int first, int last){
//TO DO } //GIVEN template int VectorADT::binarySearchByTitle(int& steps, T * v){ //set steps =0; steps=0; return binarySearchByTitle( steps, v, 0, count-1); }