Question: How can I write DvcScheduleSearch.cpp to solve the problem where in college catalogs, sometimes courses are listed that have not been offered in many years,
How can I write DvcScheduleSearch.cpp to solve the problem where in college catalogs, sometimes courses are listed that have not been offered in many years, and departments have no intention of offering them again. It's a disservice to students and to the community to continue to list them. For this and several other reasons the administration wants a program that will output the last semester in which a course was offered, and the first semester a course was offered.. In a loop, prompt the user to enter a course name like COMSC including a subject code like COMSC a dash, and an alphanumeric sequence number. If a user enters uppercase or lowercase X quit the loop and the program be sure to explain this in the prompt. For any other input, look up the course and output the first time and the last time that course was offered, nicely labeled like "COMSC was first offered in Fall and last offered in Fall Or if the course is not found, output something like this: CS could not be found as far back as the year because that's as far back as the database goes. The file is in this format: term section course instructor whenWhere
Spring ADJUS McLeran NOT AVAILABLE
Spring ADJUS Weaver NOT AVAILABLE
I have created a header file that I would like to use, but not sure how to take the next step:
#ifndef BINARYSEARCHTREEH
#define BINARYSEARCHTREEH
#include
#include
template class BinarySearchTree
private:
struct Node
K key;
V value;
Node left;
Node right;
Nodeconst K &key, const V &value
: keykey valuevalue leftnullptr rightnullptr
;
Node rootNode;
int siz;
void Keysconst Node node std::queue &q const
if node nullptr
Keysnodeleft, q;
qpushnodekey;
Keysnoderight, q;
void clearNode node
if node nullptr
clearnodeleft;
clearnoderight;
delete node;
Node copyTreeNode const node
if node nullptr
return nullptr;
Node newNode new Nodenodekey, nodevalue;
newNodeleft copyTreenodeleft;
newNoderight copyTreenoderight;
return newNode;
Node findNodeconst K &key, Node node
while node nullptr && key nodekey
if key nodekey
node &nodeleft;
else
node &noderight;
return node;
public:
BinarySearchTree : rootNodenullptr siz
BinarySearchTreeconst BinarySearchTree &other
: rootNodenullptr siz
rootNode copyTreeotherrootNode;
siz other.siz;
BinarySearchTree &operatorconst BinarySearchTree &other
if this &other
clearrootNode;
rootNode copyTreeotherrootNode;
siz other.siz;
return this;
~BinarySearchTree clearrootNode;
int size const return siz;
V &operatorconst K &key
Node node findNodekey &rootNode;
if node nullptr
node new Node
key, V; Insert with defaultconstructed value if not found
siz;
return nodevalue;
bool containsKeyconst K &key const
Node node rootNode;
while node nullptr && key nodekey
if key nodekey
node nodeleft;
else
node noderight;
return node nullptr;
void deleteKeyconst K &key
Node node findNodekey &rootNode;
if node nullptr
throw std::outofrangeKey not found";
Node oldNode node;
if nodeleft nullptr
node noderight;
else if noderight nullptr
node nodeleft;
else
Node pred &nodeleft;
while predright nullptr
pred &predright;
nodekey predkey;
nodevalue predvalue;
oldNode pred;
pred predleft;
delete oldNode;
siz;
std::queue Keys const
std::queue q;
KeysrootNode q;
return q;
void clear
clearrootNode;
rootNode nullptr;
siz ;
;
#endif BINARYSEARCHTREEH
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
