Question
Solve the problem using C++. Make necessary changes in the following codes to complete the task. Here I am unable to attach the queue class(Header
Solve the problem using C++. Make necessary changes in the following codes to complete the task. Here I am unable to attach the queue class(Header file) code as it is showing too large. Please manage
BinarySearchTree.h
#ifndef BINARYSEARCHTREE_H_INCLUDED #define BINARYSEARCHTREE_H_INCLUDED #include "Queue.h"
enum OrderType {PRE_ORDER, IN_ORDER, POST_ORDER};
template
template
bool IsEmpty(); // d bool IsFull(); // d int LengthIs(); //d
bool InsertItem(ItemType item); // d bool DeleteItem(ItemType item); // d bool RetrieveItem(ItemType& item); //d
void ResetTree(OrderType order); // bool GetNextItem(ItemType& item, OrderType order);
private: TreeNode
BinarySearchTree.tpp
#include "BinarySearchTree.h" #include
using namespace std; template
template
template
template
template
template
template
template
template
template
template
template
template
template
template
template
template
template
template
template
template
Queue.tpp
template
template
Node* newNode = new Node; newNode->info = item; newNode->next = nullptr;
if(IsEmpty()) front = newNode; else rear->next = newNode;
rear = newNode; }
template
//item = front->info;
Node* temp = front; front = front->next;
if(front == nullptr) rear = nullptr;
delete temp;
}
template
return front->info; }
template
/*Node* temp; while (front != nullptr){ temp = front; front = front->next; delete temp; } rear = nullptr;*/
while(!IsEmpty()) DeQueue(); }
template
template
template
main.cpp
#include
int main() {
TreeType
x.InsertItem(10); x.InsertItem(5); x.InsertItem(2); x.InsertItem(7); x.InsertItem(15); x.InsertItem(12); x.InsertItem(20);
x.ResetTree(IN_ORDER);
int out=0; while(x.GetNextItem(out,IN_ORDER)){ cout
cout
/*while(!x.inQue.IsEmpty()){ cout
if(!x.DeleteItem(0)) cout
cout
x.ResetTree(IN_ORDER);
out=0; while(x.GetNextItem(out,IN_ORDER)){ cout
if(x.RetrieveItem(out)){ cout
x.MakeEmpty(); if(x.IsEmpty()){ cout
cout
return 0; }
4. Bonus Task: Remember the implementations of SortedList data structures? So far, we have implemented array based and linked list based SortedList data structure. Your job for this task is to implement a binary search tree based Sorted List data structure. In the driver file: a. Create an integer Sorted List object. b. Insert some items c. Print the list. All of the function prototypes for your SortedList class functions must be the same as they are for the linked list based Sorted List class. Need hints? Check the class recording of the last class. 4. Bonus Task: Remember the implementations of SortedList data structures? So far, we have implemented array based and linked list based SortedList data structure. Your job for this task is to implement a binary search tree based Sorted List data structure. In the driver file: a. Create an integer Sorted List object. b. Insert some items c. Print the list. All of the function prototypes for your SortedList class functions must be the same as they are for the linked list based Sorted List class. Need hints? Check the class recording of the last classStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started