Question: C++ need to make changes to the insertItem to add linear search and deleteItem to do binary search my code for unsorted list: =============================================================== unsortedlist.h

C++
need to make changes to the insertItem to add linear search and deleteItem to do binary search
my code for unsorted list:
===============================================================
unsortedlist.h
#ifndef UNSORTEDLIST_H
#define UNSORTEDLIST_H
#include
#include
using namespace std;
class UnsortedList
{
private:
int *numbers;
int length;
public:
static const int MAX_SIZE = 10;
UnsortedList();
~UnsortedList();
void insertItem(int item);
void deleteItem(int item);
void show();// To see the list
bool isFull();
bool isEmpty();
};
#endif
====================================================================
unsortedlist.cpp
#include
#include "UnsortedList.h"
using namespace std;
UnsortedList::UnsortedList()
{
length = 0;
numbers = new int[MAX_SIZE];
}
UnsortedList::~UnsortedList()
{
delete[] numbers;
}
void UnsortedList::insertItem(int item)
{
if(!isFull())
{
numbers[length] = item;
length++;
}
else
cout
}
void UnsortedList::deleteItem(int item)
{
int i;
if(!isEmpty())
{
for(i=0; i
if(numbers[i] == item)
{
cout
for(int j=i+1; j
numbers[j-1] = numbers[j];
length--;
return;
}
if(i == length)
cout
}
}
void UnsortedList::show()//To view the list
{
cout
for(int i=0; i
cout
cout
}
bool UnsortedList::isEmpty()
{
if(length == 0)
{
cout
return true;
}
return false;
}
bool UnsortedList::isFull()
{
if(length == MAX_SIZE)
return true;
return false;
}
=====================================================
main.cpp
#include
#include"UnsortedList.h"
using namespace std;
void showMenu();
int main()
{
char choice;
showMenu();
cin >> choice;
UnsortedList myList;
while(choice != 'q')
{
if(choice == 'a')
{
int num;
cout
cin >> num;
myList.insertItem(num);
}
else if(choice == 'b')
{
int num;
cout
cin >> num;
myList.deleteItem(num);
}
else if(choice == 'q')
cout
else
cout
cout
myList.show();
showMenu();
cin >> choice;
}
}
//Function to print the menu to the user
void showMenu()
{
cout
}
HW 3b Array-based SortedList Write a program that uses a SortedList class to manage a sorted list of numbers. The list will hold up to 10 integers. The numbers are sorted in ascending order (low to high). When the list is initially created, it will be empty. Numbers can be inserted into the list (as long as the list is not full). Numbers can be deleted from the list (as long as the list is not empty). - -One of the data members of the class is an array that will be used to hold the numbers. Project: HW 3b 3 Files: SortedList.h SortedLIst.cpp main.cpp Note: Comparing the UnsortedList to the SortedList, only the insertItem and deleteltem methods are different. Therefore, copy and paste your code from HW_4a, and make changes to the insertItem and deleteltem methods. Include code to do a linear search for the insertItem method. Include code to do a binary search for the deleteltem method
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
