Question: This is the question and answer is below. I want to convert the code from c++ to java. CS 2336 - PROJECT 4 - Redbox

This is the question and answer is below. I want to convert the code from c++ to java.

CS 2336 - PROJECT 4 - Redbox Inventory System

Project Due: 11/21 by 11:59 PM

KEY ITEMS: Key items are marked in red. Failure to include or complete key items will incur additional deductions

as noted beside the item.

Submission:

The file containing main must be named Main.java. (-5 points)

The project files must be in packages that start with RedBox.* (-5 points)

All project deliverables are to be submitted in eLearning

o Zip the contents of the src directory into a single zipped file

o Make sure the zipped file has a .zip extension (not .tar, .rar, .7z, etc.) (-5 points)

o Add your project's presentation link in the comments section in eLearning

Programs must compile and run with Java SE 13.

Each student is responsible for developing unit test cases to ensure the program works as expected.

Type your name and netID in the comments at the top of all files submitted. (-5 points)

Objectives:

Implement a binary search tree class in Java

Utilize a binary search tree

Create a modular code solution with multi-packages

Use the Singleton pattern to create and manage the Scanner object

Use Java Generics to create generic classes and methods

Problem: Redbox needs a program to track inventory and to generate a report for their DVD rental kiosks. Given

a log of transactions including renting and returning DVDs as well as adding and removing DVD titles, the program

will need to process each transaction and create a report after all transactions have been processed. The

generated report will list all DVD titles stored in the kiosk as well as how many of each disc are in the kiosk.

Details:

The inventory will be held in a binary search tree that you will create (-15 points if not)

Use the DVD title to determine node placement in the tree

The binary tree will be seeded with an inventory file

Once seeded, the program will parse a transaction log to update the inventory

There are five possible transactions:

o Add

Add a new title

Create a new node and insert it into the tree

Add copies to an existing title

Find the title in the tree and increase the number of available copies by the

amount listed

o Remove copies of an existing title

Find the title in the tree and reduce the number of available copies by the amount listed

If number available is zero and no copies are rented out, delete the node from the tree

There will not be more copies removed than available.

o Rent a DVD

Reduce available amount of an existing title by one and increase rented amount by one

o Return a DVD

Increase available amount of an existing title by one and reduce rented amount by one

Classes:

Node

o Members

Data field that will hold a Movie object [Title (string - case insensitive), Available (integer),

Rented (integer)]

Left (node pointer)

Right (node pointer)

o Methods

Overloaded constructor

Mutators

Accessors

Binary Search Tree

o Binary Search Tree class must use generics (-5 points if not)

o Members

Root (node pointer)

o Methods

Mutator

Accessor

Insert (recursive) (-5 points if not)

Search (recursive) (-5 points if not)

Delete

Other methods that are necessary to interact with a binary search tree

Remember that methods should be generic to be used on a binary tree regardless

of the problem and data type.

User Interface and Input: There is no user interface for this program. Input will be loaded from two files,

inventory.dat and transaction.log. The inventory.dat is assumed to be error free and it will be

read first by your program and loaded into a binary search tree. Each line (except the last line which may not have

a newline character) in inventory.dat will be formatted as follows (NOTE: represents a variable value):

"",<quantity available>, <quantity rented> //May contain space(s) around commas</p> <p>After processing the inventory file, begin processing transaction.log. Each line of the file should follow one</p> <p>of the following formats (Note: Command is case insensitive):</p> <p> aDd "<title>", <number to add> //Command lines may contain space(s) around commas</p> <p> ReMove "<title>",<number to remove></p> <p> rent "<title>"</p> <p> retUrn "<title>"</p> <p>The transaction file may contain errors due to network disruptions from the main server. For each line in the</p> <p>transaction log, validate that it follows one of the formats listed above. If it is the correct format, process the</p> <p>transaction. If the <number to add>, <number to remove>, or the line format is invalid write the line to an error</p> <p>file (as described below). All numbers are expected to be integers. To be valid, the line must follow the format</p> <p>exactly. Also, do not assume that a title in the transaction log will be in the tree.</p> <p>Output: A file named error.log will be created only if any lines of transaction.log are invalid.</p> <p>Error.log will contain all invalid entries of the transaction file.</p> <p>At the end of the program, create a formatted report file that contains each title, the number of copies available</p> <p>to rent for that title as well as the number of copies that are currently rented. The titles should be listed in</p> <p>alphabetical order (without the double quotes). The report should be arranged in three formatted columns that</p> <p>line up the data nicely:</p> <p> Title</p> <p> Copies available</p> <p> Copies rented</p> <p>Title Available Rented</p> <p>-----------------------------------------------------------</p> <p>Collateral Beauty 2 2</p> <p>Doctor Strange 1 2</p> <p>Hacksaw Ridge 0 1</p> <p>Write the report to a file named redbox_kiosk.txt</p> <p>Program Flow:</p> <p> Program starts in main() method</p> <p> Load inventory.dat</p> <p> Create and populate the Binary Search Tree</p> <p> Load transaction.log</p> <p> Process all transactions</p> <p> Output final inventory to file</p> <p>Unit Testing:</p> <p>A unit test method is required to test each of the commands listed in the write-up above. These methods will be</p> <p>used by the unit testing framework to test the accuracy of your code.</p> <p> AddTitle(...)</p> <p> RemoveTitle(...)</p> <p> RentTitle(...)</p> <p> ReturnTitle(...)</p> <p>Grading:</p> <p> Coding standards, style and comments (20 Points)</p> <p>o Create a multi-package code solution (8 Points)</p> <p>o Use Singleton pattern for scanner instance (2 Points)</p> <p>o Coding standards and comments (10 Points)</p> <p> Unit testing methods x 4, one for each of the methods mentioned above (12 Points)</p> <p> The rest of the grade will be broken down as follows:</p> <p> AddTitle(...) (12 Points)</p> <p> RemoveTitle(...) (12 Points)</p> <p> RentTitle(...) (12 Points)</p> <p> ReturnTitle(...) (12 Points)</p> <p> Generic Binary Search Tree (20 Points)</p> <p>Notes:</p> <p> No startup code solution will be provided. You are expected to start a new solution from scratch and layer</p> <p>your solution in a way similar to project #3.</p> <p> All *.dat files are assumed to be local to the current executable.</p> <p> Your program is expected to have basic file validation.</p> <p> Your program must use a Singleton pattern for Scanner instance. This ensures that only one instance of</p> <p>the Scanner object is created throughout your program.</p> <p> You must implement and utilize a generic binary search tree class. Your class should not inherit any</p> <p>existing Java binary tree class.</p> <p> Deliverables: Up to 10 minutes project video presentation (MS Teams) with a functioning program</p> <p>including Unit Testing methods.</p> <p> </p> <p><strong>Answer:</strong></p> <p><strong>Main.cpp</strong></p> <p>#include "Node.h"</p> <p>#include "BinaryTree.h"</p> <p>#include <iostream></p> <p>#include <fstream></p> <p>#include <sstream></p> <p>#include <string></p> <p> </p> <p>using namespace std;</p> <p> </p> <p>/**</p> <p>*Creates a Binary Tree of type Node with a given input file.</p> <p>*</p> <p>*@param input file from which the binary tree's information will be pulled from</p> <p>*@return Binary Tree of type Node</p> <p>*/</p> <p>BinaryTree<node> createTree(ifstream &input);</p> <p> </p> <p>/**</p> <p>*Reads and processes the transactions onto the Binary Tree with a given input file</p> <p>*</p> <p>*@param input file from which the transactions will be pulled from</p> <p>*@param tree Binary Tree of type Node</p> <p>*/</p> <p>void readTransaction(ifstream &input, BinaryTree<node> tree);</p> <p> </p> <p>/**</p> <p>*Adds copies of movies to the tree.</p> <p>*If the Binary Tree does not have a given movie, add it to the tree.</p> <p>*</p> <p>*@param line the string with info of the transaction</p> <p>*@param tree Binary Tree of type Node</p> <p>*/</p> <p>void add(string line, BinaryTree<node> tree);</p> <p> </p> <p>/**</p> <p>*Removes copies of movies to the tree.</p> <p>*If the movie has no more copies, remove it from the tree.</p> <p>*</p> <p>*@param line the string with info of the transaction</p> <p>*@param tree Binary Tree of type Node</p> <p>*/</p> <p>void remove(string line, BinaryTree<node> tree);</p> <p> </p> <p>/**</p> <p>*Rents movies.</p> <p>*Decrement available copies and increment rented copies by 1.</p> <p>*</p> <p>*@param line the string with info of the transaction</p> <p>*@param tree Binary Tree of type Node</p> <p>*/</p> <p>void rent(string line, BinaryTree<node> tree);</p> <p> </p> <p>/**</p> <p>*Returns movies.</p> <p>*Increment available copies and Decrement rented copies by 1.</p> <p>*</p> <p>*@param line the string with info of the transaction</p> <p>*@param tree Binary Tree of type Node</p> <p>*/</p> <p>void returnMovie(string line, BinaryTree<node> tree);</p> <p> </p> <p>/**</p> <p>*Find a substring from the given string between quotation marks.</p> <p>*</p> <p>*@param line the string with info of the transaction</p> <p>*/</p> <p>string parseTitle(string line);</p> <p> </p> <p>/**</p> <p>*Find the first occurence of a number.</p> <p>*</p> <p>*@param line the string with info of the transaction</p> <p>*/</p> <p>int parseInt(string line);</p> <p> </p> <p>/**</p> <p>*Check if a movie is already in the tree.</p> <p>*</p> <p>*@param line the string with info of the transaction</p> <p>*@param tree Binary Tree of type Node</p> <p>*@return if the movie is in the tree</p> <p>*/</p> <p>bool checkExists(BinaryTree<node> tree, string line);</p> <p> </p> <p>int main()</p> <p>{</p> <p> //create tree</p> <p> ifstream input("inventory.dat");</p> <p> BinaryTree<node> tree = createTree(input);</p> <p> input.close();</p> <p> </p> <p> //process transactions</p> <p> input.open("transaction.log");</p> <p> readTransaction(input, tree);</p> <p> input.close();</p> <p> </p> <p> //print tree in alphabetical order</p> <p> ofstream out("redbox_kiosk.txt");</p> <p> tree.printOrder(tree.getRoot(), out);</p> <p> out.close();</p> <p> return 0;</p> <p>}</p> <p> </p> <p>BinaryTree<node> createTree(ifstream &input)</p> <p>{</p> <p> //creat the tree</p> <p> BinaryTree<node> tree;</p> <p> string line;</p> <p> getline(input, line);</p> <p> </p> <p> //gather info for root node</p> <p> string title = parseTitle(line);</p> <p> int available = parseInt(line.substr(line.rfind('"')));</p> <p> int rented = parseInt(line.substr(line.rfind(',')));</p> <p> </p> <p> //set the root of the tree</p> <p> tree.setRoot(new Node(title, available, rented));</p> <p> </p> <p> while (getline(input, line))</p> <p> {</p> <p> //gather info for node to insert</p> <p> title = parseTitle(line);</p> <p> available = parseInt(line.substr(line.rfind('"')));</p> <p> rented = parseInt(line.substr(line.rfind(',')));</p> <p> </p> <p> //insert node into tree</p> <p> tree.insert(tree.getRoot(), new Node(title, available, rented));</p> <p> }</p> <p> </p> <p> return tree;</p> <p>}</p> <p> </p> <p>void readTransaction(ifstream &input, BinaryTree<node> tree)</p> <p>{</p> <p> string line;</p> <p> ofstream output("error.log");</p> <p> while (getline(input, line))</p> <p> {</p> <p> //check for a proper command</p> <p> //make sure there are only 3 or 1 characters after the last quotation mark</p> <p> string check = line.substr(line.find_last_of('"'));</p> <p> int icheck = (int)check.length();</p> <p> </p> <p> if (line.rfind("add", 0) == 0 && icheck == 3)</p> <p> {</p> <p> string check2 = line.substr(0, line.find_first_of('"'));</p> <p> int icheck2 = (int)check2.length();</p> <p> if (icheck2 == 4) // make sure begginning is "add "</p> <p> {</p> <p> add(line, tree);</p> <p> continue;</p> <p> }</p> <p> }</p> <p> else if (line.rfind("remove", 0) == 0 && icheck == 3)</p> <p> {</p> <p> string check2 = line.substr(0, line.find_first_of('"'));</p> <p> int icheck2 = (int)check2.length();</p> <p> //make sure that the movie is in the tree</p> <p> if (checkExists(tree, line) && icheck2 == 7) //make sure beginning is "remove "</p> <p> {</p> <p> remove(line, tree);</p> <p> continue;</p> <p> }</p> <p> }</p> <p> else if (line.rfind("rent", 0) == 0 && icheck == 1)</p> <p> {</p> <p> string check2 = line.substr(0, line.find_first_of('"'));</p> <p> int icheck2 = (int)check2.length();</p> <p> //make sure that the movie is in the tree</p> <p> if (checkExists(tree, line) && icheck2 == 5) //make sure beginning is "rent "</p> <p> {</p> <p> rent(line, tree);</p> <p> continue;</p> <p> }</p> <p> }</p> <p> else if (line.rfind("return", 0) == 0 && icheck == 1)</p> <p> {</p> <p> string check2 = line.substr(0, line.find_first_of('"'));</p> <p> int icheck2 = (int)check2.length();</p> <p> //make sure that the movie is in the tree</p> <p> if (checkExists(tree, line) && icheck2 == 7) //make sure beginning is "return "</p> <p> {</p> <p> returnMovie(line, tree);</p> <p> continue;</p> <p> }</p> <p> }</p> <p> </p> <p> //output to error log</p> <p> output << line << endl;</p> <p> }</p> <p>}</p> <p> </p> <p> </p> <p>void add(string line, BinaryTree<node> tree)</p> <p>{</p> <p> //gather info for adding a movie</p> <p> string title = parseTitle(line);</p> <p> int add = parseInt(line);</p> <p> </p> <p> //search for the node</p> <p> Node *node = tree.search(tree.getRoot(), new Node(title));</p> <p> </p> <p> //if node does not exist in tree, insert it</p> <p> if (!node)</p> <p> {</p> <p> Node *newNode = new Node(title, add, 0);</p> <p> node = tree.insert(tree.getRoot(), newNode);</p> <p> return;</p> <p> }</p> <p> </p> <p> //increase available copies by add amount</p> <p> node->setAvailable(node->getAvailable() + add);</p> <p>}</p> <p> </p> <p>void remove(string line, BinaryTree<node> tree)</p> <p>{</p> <p> //gather info for movie to remove</p> <p> string title = parseTitle(line);</p> <p> int remove = parseInt(line);</p> <p> </p> <p> //find the node of the movie</p> <p> Node *node = tree.search(tree.getRoot(), new Node(title));</p> <p> </p> <p> //subtract remove amount</p> <p> node->setAvailable(node->getAvailable() - remove);</p> <p> </p> <p> //if number of available movies is less than 0, remove the node</p> <p> if (node->getAvailable() <= 0 && node->getRented() <= 0)</p> <p> {</p> <p> tree.remove(tree.getRoot(), node);</p> <p> }</p> <p>}</p> <p> </p> <p>void rent(string line, BinaryTree<node> tree)</p> <p>{</p> <p> //gather info for movie to rent</p> <p> string title = parseTitle(line);</p> <p> </p> <p> //find the node of the movie</p> <p> Node *node = tree.search(tree.getRoot(), new Node(title));</p> <p> </p> <p> //decrease available amount and increase rented amount by 1</p> <p> node->setRented(node->getRented() + 1);</p> <p> node->setAvailable(node->getAvailable() - 1);</p> <p>}</p> <p> </p> <p>void returnMovie(string line, BinaryTree<node> tree)</p> <p>{</p> <p> //gather info for movie to return</p> <p> string title = parseTitle(line);</p> <p> </p> <p> //find the node of the movie</p> <p> Node *node = tree.search(tree.getRoot(), new Node(title));</p> <p> </p> <p> //increase available amount and decrease rented amount by 1</p> <p> node->setAvailable(node->getAvailable() + 1);</p> <p> node->setRented(node->getRented() - 1);</p> <p>}</p> <p> </p> <p>string parseTitle(string line)</p> <p>{</p> <p> //return string between quotation marks</p> <p> int start = line.find_first_of('"');</p> <p> int end = line.find_last_of('"');</p> <p> return line.substr(start + 1, end - start - 1);</p> <p>}</p> <p> </p> <p>int parseInt(string str)</p> <p>{</p> <p> //finds the first occurence of a number</p> <p> int num;</p> <p> int index = str.find_first_of("0123456789");</p> <p> if (index > 0)</p> <p> {</p> <p> char s = str[index];</p> <p> num = atoi(&s);</p> <p> }</p> <p> return num;</p> <p>}</p> <p> </p> <p>bool checkExists(BinaryTree<node> tree, string line)</p> <p>{</p> <p> //checks to see if a given node exists</p> <p> string title = parseTitle(line);</p> <p> Node *n = tree.search(tree.getRoot(), new Node(title));</p> <p> return n;</p> <p>}</p> <p><strong>Node.cpp</strong></p> <p>#include "Node.h"</p> <p>#include <iomanip></p> <p> </p> <p> </p> <p>Node::Node()</p> <p>{</p> <p>}</p> <p> </p> <p>Node::Node(std::string title)</p> <p>{</p> <p> this->title = title;</p> <p>}</p> <p> </p> <p>Node::Node(std::string title, int available, int rented)</p> <p>{</p> <p> this->title = title;</p> <p> this->available = available;</p> <p> this->rented = rented;</p> <p>}</p> <p> </p> <p>Node::Node(std::string title, int available, int rented, Node *left, Node *right)</p> <p>{</p> <p> </p> <p> this->title = title;</p> <p> this->available = available;</p> <p> this->rented = rented;</p> <p> this->left = left;</p> <p> this->right = right;</p> <p>}</p> <p> </p> <p>void Node::copyNode(Node n)</p> <p>{</p> <p> this->title = n.title;</p> <p> this->available = n.available;</p> <p> this->rented = n.rented;</p> <p>}</p> <p> </p> <p>bool Node::operator==(const Node &right)</p> <p>{</p> <p> return title == right.title;</p> <p>}</p> <p> </p> <p>bool Node::operator>(const Node &right)</p> <p>{</p> <p> return title > right.title;</p> <p>}</p> <p> </p> <p>bool Node::operator<(const Node &right)</p> <p>{</p> <p> return title < right.title;</p> <p>}</p> <p> </p> <p>std::ostream& operator<<(std::ostream &out, const Node &node)</p> <p>{</p> <p> out << std::setw(30) << std::left << node.title;</p> <p> out << std::setw(5) << std::right << node.available << std::setw(5) << node.rented;</p> <p> return out;</p> <p>}</p> <p> </p> <p> </p> <p>Node::~Node()</p> <p>{</p> <p>}</p> <p> </p> <p><strong>BinaryTree.h</strong></p> <p>#ifndef BINARY_TREE_H</p> <p>#define BINARY_TREE_H</p> <p> </p> <p>#include <string></p> <p>#include <iostream></p> <p> </p> <p>template <class t></p> <p>class BinaryTree</p> <p>{</p> <p>private:</p> <p> T *root;</p> <p>public:</p> <p> void setRoot(T *root) { this->root = root; }</p> <p> T *getRoot() { return root; }</p> <p> </p> <p> T *min(T *root);</p> <p> T *insert(T *root, T *node);</p> <p> T *search(T *root, T *node);</p> <p> T *remove(T *root, T *node);</p> <p> void printOrder(T *root, std::ostream &out);</p> <p>};</p> <p> </p> <p>template <class t></p> <p>T* BinaryTree<t>::min(T *root)</p> <p>{</p> <p> T *current = root;</p> <p> </p> <p> //find left most leaf</p> <p> while (current->getLeft())</p> <p> {</p> <p> current = current->getLeft();</p> <p> }</p> <p> </p> <p> return current;</p> <p>}</p> <p> </p> <p>template <class t></p> <p>T* BinaryTree<t>::insert(T *root, T *node)</p> <p>{</p> <p> //base case</p> <p> if (!root)</p> <p> {</p> <p> root = node;</p> <p> }</p> <p> </p> <p> //what we're inserting belongs on the left</p> <p> if (*node < *root)</p> <p> {</p> <p> root->setLeft(insert(root->getLeft(), node));</p> <p> }</p> <p> //what we're inserting belongs on the right</p> <p> else if (*node > *root)</p> <p> {</p> <p> root->setRight(insert(root->getRight(), node));</p> <p> }</p> <p> </p> <p> return root;</p> <p>}</p> <p> </p> <p>template <class t></p> <p>T* BinaryTree<t>::search(T *root, T *node)</p> <p>{</p> <p> //base case</p> <p> if (!root || *root == *node)</p> <p> {</p> <p> return root;</p> <p> }</p> <p> </p> <p> //what we're searching for is on the right</p> <p> if (*root < *node)</p> <p> {</p> <p> return search(root->getRight(), node);</p> <p> }</p> <p> </p> <p> //what we're searching for is on the left</p> <p> return search(root->getLeft(), node);</p> <p>}</p> <p> </p> <p>template <class t></p> <p>T* BinaryTree<t>::remove(T *root, T *node)</p> <p>{</p> <p> //base case</p> <p> if (!root)</p> <p> {</p> <p> return root;</p> <p> }</p> <p> </p> <p> //what we're deleting is on the left</p> <p> if (*node < *root)</p> <p> {</p> <p> root->setLeft(remove(root->getLeft(), node));</p> <p> }</p> <p> //what we're deleting is on the right</p> <p> else if (*node > *root)</p> <p> {</p> <p> root->setRight(remove(root->getRight(), node));</p> <p> }</p> <p> //we've found what we're deleting</p> <p> else</p> <p> {</p> <p> //0 children</p> <p> if (!root->getLeft() && !root->getRight())</p> <p> {</p> <p> delete root;</p> <p> root = nullptr;</p> <p> }</p> <p> //1 child</p> <p> else if (!root->getLeft())</p> <p> {</p> <p> T *temp = root->getRight();</p> <p> </p> <p> root->setTitle(temp->getTitle());</p> <p> root->setAvailable(temp->getAvailable());</p> <p> root->setRented(temp->getRented());</p> <p> root->setLeft(temp->getLeft());</p> <p> root->setRight(temp->getRight());</p> <p> </p> <p> delete temp;</p> <p> </p> <p> return root;</p> <p> }</p> <p> else if (!root->getRight())</p> <p> {</p> <p> T *temp = root->getLeft();</p> <p> </p> <p> root->setTitle(temp->getTitle());</p> <p> root->setAvailable(temp->getAvailable());</p> <p> root->setRented(temp->getRented());</p> <p> root->setLeft(temp->getLeft());</p> <p> root->setRight(temp->getRight());</p> <p> </p> <p> delete temp;</p> <p> </p> <p> return root;</p> <p> }</p> <p> //2 children</p> <p> else</p> <p> {</p> <p> T *temp = min(root->getRight());</p> <p> </p> <p> root->copyNode(*temp);</p> <p> </p> <p> root->setRight(remove(root->getRight(), root));</p> <p> }</p> <p> }</p> <p> </p> <p> return root;</p> <p>}</p> <p> </p> <p>template <class t></p> <p>void BinaryTree<t>::printOrder(T *root, std::ostream &out)</p> <p>{</p> <p> //we've reached the end of a leaf</p> <p> if (!root)</p> <p> {</p> <p> return;</p> <p> }</p> <p> </p> <p> //process left</p> <p> printOrder(root->getLeft(), out);</p> <p> </p> <p> //process node</p> <p> out << *root << std::endl;</p> <p> </p> <p> //process right</p> <p> printOrder(root->getRight(), out);</p> <p>}</p> <p> </p> <p>#endif</p> <p> </p> <p><strong>Node.h</strong></p> <p>#ifndefNODE_H</p> <p>#define NODE_H</p> <p> </p> <p>#include <string></p> <p> </p> <p>class Node</p> <p>{</p> <p>private:</p> <p> std::string title;</p> <p> int available;</p> <p> int rented;</p> <p> Node *left = nullptr;</p> <p> Node *right = nullptr;</p> <p>public:</p> <p> Node();</p> <p> Node(std::string title);</p> <p> Node(std::string title, int available, int rented);</p> <p> Node(std::string title, int available, int rented, Node *left, Node *right);</p> <p> </p> <p> //Accessors</p> <p> std::string getTitle() { return title; }</p> <p> int getAvailable() { return available; }</p> <p> int getRented() { return rented; }</p> <p> Node* getLeft() { return left; }</p> <p> Node* getRight() { return right; }</p> <p> </p> <p> //Mutators</p> <p> void setTitle(std::string title) { this->title = title; }</p> <p> void setAvailable(int available) { this->available = available; }</p> <p> void setRented(int rented) { this->rented = rented; }</p> <p> void setLeft(Node *left) { this->left = left; }</p> <p> void setRight(Node *right) { this->right = right; }</p> <p> </p> <p> void copyNode(Node n);</p> <p> </p> <p> //Operator</p> <p> bool operator==(const Node &right);</p> <p> bool operator>(const Node &right);</p> <p> bool operator<(const Node &right);</p> <p> </p> <p> friend std::ostream& operator<<(std::ostream &out, const Node &node);</p> <p> </p> <p> ~Node();</p> <p>};</p> <p> </p> <p>#endif</p> </p> </div> <div class="question-answer-divider"></div> <section class="answerHolder" itemscope itemtype="http://schema.org/Answer"> <div class="answerHolderHeader"> <h2>Step by Step Solution</h2> <div class="answerReviews"> <div class="starIcon"> </div> </div> </div> <div class="questionProperties"> <p>There are 3 Steps involved in it</p> <div class="cart-flex"> <div class="cart cart1"> 1 Expert Approved Answer </div> </div> </div> <div class="step org_answer"> <span class="view_solution_btn view-solution-btn-cursor"> <strong class="step-heading step-1">Step: 1 <span>Unlock <i class="fa-solid fa-lock"></i></span></strong> </span> <img src="https://www.solutioninn.com/includes/images/document_product_info/blur-text-image.webp" class="blured-ans-image" width="759" height="271" alt="blur-text-image" decoding="async" fetchpriority="high"> <div class="step1Popup"> <span class="heading">Question Has Been Solved by an Expert!</span> <p>Get step-by-step solutions from verified subject matter experts</p> <button class="view_solution_btn step1PopupButton">View Solution</button> </div> </div> <div class="step"> <span class="view_solution_btn view-solution-btn-cursor"> <strong class="accordion step-heading">Step: 2 <span>Unlock <i class="fa-solid fa-lock"></i></span></strong> </span> </div> <div class="step"> <span class="view_solution_btn view-solution-btn-cursor"> <strong class="accordion step-heading">Step: 3 <span>Unlock <i class="fa-solid fa-lock"></i></span></strong> </span> </div> </section> <section class="relatedQuestion"> <h2>Students Have Also Explored These Related Programming Questions!</h2> <div class="relatedQuestionSliderHolder"> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/choose-either-project-1a-project-1b-or-project-1c-note-12322335" > Choose Either Project 1a, Project 1b, or Project 1c Note: Project 1c is not allowed if you did this project for CS 104 Project 1a: Amazon Customer Order History System Congratulations! After a... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/chapter-10-business-process-and-information-systems-development-jeff-we-10678369" > Chapter 10 Business Process and Information Systems Development \"Jeff, we clean the clubhouse restrooms twice a day . . . in the morning before 7 and again just before lunch. We've been doing that... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/let-a-b-be-sets-define-a-the-cartesian-product-667469" > Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/in-a-hopfield-neural-network-configured-as-an-associative-memory-668038" > In a Hopfield neural network configured as an associative memory, with all of its weights trained and fixed, what three possible behaviours may occur over time in configuration space as the net... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/i-know-its-a-bit-harsh-but-see-if-you-4102909" > I know its a bit harsh but see if you can finish it in before tomorrow? thanks QUEENSLAND UNIVERSITY OF TECHNOLOGY QUT Business School School of Accountancy AYN416 Financial Accounting 1 Semester 2... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/the-values-explicitly-used-in-the-initialization-are-used-however-751124" > The values explicitly used in the initialization are used. However, if there is at least one constructor defined in the class other than the no-argument constructor which is absent, Java will treat... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/i-have-an-accounting-assignment-need-to-be-finished-asap-4034440" > I have an accounting assignment need to be finished asap. QUEENSLAND UNIVERSITY OF TECHNOLOGY QUT Business School School of Accountancy AYN416 Financial Accounting 1 Semester 1 2017 Integrated... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/1-for-this-task-imagine-that-you-were-asked-to-17756102" > 1 For this task, imagine that you were asked to present to a class of master's level students who are enrolled in their first quantitative research methods course. Create a PowerPoint presentation... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/i-am-so-lost-with-all-of-this-and-the-4110183" > I am so lost with all of this and the worst part it is due in an hour and a half. I don't know what to do please help. In this course you will have the opportunity to apply the concepts learned to a... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/c-111-project-1a-august-1-2016-stephanie-ram-a-5808489" > C 111 Project 1A August 1, 2016, Stephanie Ram, a sole proprietor, started a new business, Ram Wholesale Company. The company sells refrigerators ierchandise) to various retail stores and uses the... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/the-browser-company-purchases-a-computer-in-december-2011-for" > The Browser Company purchases a computer in December 2011 for $100,000. This is the only depreciable personal property acquired during the year. Browser elects not to claim bonus depreciation and... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/abc-company-has-three-employees-who-were-paid-60000-each-479860" > ABC Company has three employees who were paid $60,000 each during the current year. Assume that ABC pays state unemployment taxes and is entitled to the maximum credit of 5.4% subject to a federal... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/an-indicator-of-market-value-that-compares-the-price-per-27939144" > An indicator of market value that compares the price per share to the value of each share as stated on the company's balance sheet is called the: price - to - book ratio price per ohare earnings per... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/2023-1040-form-1phillip-and-claire-are-married-and-file-10820280" > 2023 1040 form 1.Phillip and Claire are married and file a joint return. Phillip is self-employed as a real estate agent, and Claire is a flight attendant. Phillip and Claire have three dependent... </a> </div> </div> <nav class="navigationButtons"> <a class="previousQuestionButton" href="/study-help/questions/consider-the-following-code-answer-questions-1-to-4-this-17794753">Previous Question</a> <a class="nextQuestionButton" href="/study-help/questions/i-need-a-brief-description-of-the-meaning-of-the-17794755">Next Question</a> </nav> </section> </main> <aside class="expertRight"> <section class="relatedBook" style="margin-bottom:40px; width: 100%;" > <div class="bookHolder" > <div class="relatedBookHeading" > <h2 class="heading">Recommended Textbook</h2> </div> <div class="bookMainInfo" > <div class="bookImage" style="width: 100px !important; min-width: 100px; flex-shrink: 0; margin-right: 20px;"> <a href="/textbooks/app-inventor-1st-edition-9781449397487"> <img src="https://dsd5zvtm8ll6.cloudfront.net/si.question.images/book_images/2022/02/62022964ba0a1_8366202296434d21.jpg" width="100" height="131" alt="App Inventor" loading="lazy" style="width: 100px !important;"> </a> </div> <div class="bookInfo" style="text-align: left;"> <span class="bookTitle" style="text-align: left;"> <a href="/textbooks/app-inventor-1st-edition-9781449397487" style="text-align: left;"> App Inventor </a> </span> <div class="bookMetaInfo" style="text-align: left;"> <p class="bookAuthor" style="text-align: left;"> <b>Authors:</b> <span>David Wolber, Hal Abelson</span> </p> <p class="bookEdition" style="text-align: left;"> 1st Edition </p> <p class="bookEdition" style="text-align: left;"> 1449397484, 9781449397487 </p> </div></div></div> </div> </section> <div class="post-question-section"> <div class="description-question-section"> <span class="post-question-section-title">Ask a Question and Get Instant Help!</span> </div> <div class="text-area-post-question"> <form action="/study-help/post-question?ref=search" method="post" enctype="multipart/form-data"> <textarea rows="4" class="form-control form-posting-margin" name="textarea-question-content" id="textarea-question-content" placeholder="Type Your Question ...."></textarea> <button type="submit" class="btn btn-sm btn-submit-post-question text-center">Get Answer</button> </form> </div> </div> </aside> </div> </div> <div class="promo items-center justify-center hidden"> <div class="app_promo"> <span class="app_promo_dismiss"> <i class="fa-solid fa-x"></i> </span> <div class="app-button"> <div class="image-wrapper"> <img width="30" height="30" src="https://www.solutioninn.com/includes/images/rewamp/common/mobile-app-logo.png" decoding="async" fetchpriority="high" alt="SolutionInn App Logo"> <strong>Study Help</strong> </div> <button class="app_promo_action redirection" data-question-open-url='q_id=17794754&q_type=2'> Open in App </button> </div> </div> </div> </div> </div> <div class="blank-portion"></div> <footer> <div class="container footerHolder"> <div class="footerLinksFlex"> <div class="footerLinksCol col-md-3 col-lg-3 col-sm-6 col-6"> <p>Services</p> <ul> <li><a href="/site-map">Sitemap</a></li> <li><a href="/fun/">Fun</a></li> <li><a href="/study-help/definitions">Definitions</a></li> <li><a href="/tutors/become-a-tutor">Become Tutor</a></li> <li><a href="/books/used-textbooks">Used Textbooks</a></li> <li><a href="/study-help/categories">Study Help Categories</a></li> <li><a href="/study-help/latest-questions">Recent Questions</a></li> <li><a href="/study-help/questions-and-answers">Expert Questions</a></li> <li><a href="/clothing">Campus Wear</a></li> <li><a href="/sell-books">Sell Your Books</a></li> </ul> </div> <div class="footerLinksCol col-md-3 col-lg-3 col-sm-6 col-6"> <p>Company Info</p> <ul> <li><a href="/security">Security</a></li> <li><a href="/copyrights">Copyrights</a></li> <li><a href="/privacy">Privacy Policy</a></li> <li><a href="/conditions">Terms & Conditions</a></li> <li><a href="/solutioninn-fee">SolutionInn Fee</a></li> <li><a href="/scholarships">Scholarship</a></li> <li><a href="/online-quiz">Online Quiz</a></li> <li><a href="/study-feedback">Give Feedback, Get Rewards</a></li> </ul> </div> <div class="footerLinksCol col-md-3 col-lg-3 col-sm-6 col-6"> <p>Get In Touch</p> <ul> <li><a href="/about-us">About Us</a></li> <li><a href="/support">Contact Us</a></li> <li><a href="/career">Career</a></li> <li><a href="/jobs">Jobs</a></li> <li><a href="/support">FAQ</a></li> <li><a href="https://www.studentbeans.com/en-us/us/beansid-connect/hosted/solutioninn" target="_blank" rel="noopener nofollow">Student Discount</a></li> <li><a href="/campus-ambassador-program">Campus Ambassador</a></li> </ul> </div> <div class="footerLinksCol col-md-3 col-lg-3 col-sm-6 col-12"> <p>Secure Payment</p> <div class="footerAppDownloadRow"> <div class="downloadLinkHolder"> <img src="https://dsd5zvtm8ll6.cloudfront.net/includes/images/rewamp/common/footer/secure_payment_method.png" class="img-fluid mb-3" width="243" height="28" alt="payment-verified-icon" loading="lazy"> </div> </div> <p>Download Our App</p> <div class="footerAppDownloadRow"> <div class="downloadLinkHolder mobileAppDownload col-md-6 col-lg-6 col-sm-6 col-6 redirection" data-id="1"> <img style="cursor:pointer;" src="https://dsd5zvtm8ll6.cloudfront.net/includes/images/rewamp/home_page/google-play-svg.svg" alt="SolutionInn - Study Help App for Android" width="116" height="40" class="img-fluid mb-3 " loading="lazy"> </div> <div class="downloadLinkHolder mobileAppDownload col-md-6 col-lg-6 col-sm-6 col-6 redirection" data-id="2"> <img style="cursor:pointer;" src="https://dsd5zvtm8ll6.cloudfront.net/includes/images/rewamp/home_page/apple-store-download-icon.svg" alt="SolutionInn - Study Help App for iOS" width="116" height="40" class="img-fluid mb-3" loading="lazy"> </div> </div> </div> </div> </div> <div class="footer-bottom"> <p>© 2026 SolutionInn. All Rights Reserved</p> </div></footer> <script> window.addEventListener("load",function(){jQuery(document).ready(function(t){ // Clarity tracking (function(c,l,a,r,i,t,y){ c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)}; t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i; y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y); })(window, document, "clarity", "script", "sjv6tuxsok"); // Helper to read a cookie by name function getCookie(name) { return document.cookie .split('; ') .map(v => v.split('=')) .reduce((acc, [k, val]) => (k === name ? decodeURIComponent(val || '') : acc), ''); } // Read cookies var si = getCookie('si_u_id'); var uid = getCookie('u_id'); var zen = getCookie('zenid'); // Send to Clarity if (si) clarity('set', 'si_u_id', si); if (uid) clarity('set', 'u_id', uid); if (zen) clarity('set', 'zenid', zen); clarity('set', 'ip_address', '216.73.216.28'); t.ajax({type:"POST",url:"/",data:{trackUserActivity:!0,reqUri:document.URL,referer:document.referrer},success:function(t){}})})},!1),window.addEventListener("load",function(){jQuery(document).ready(function(t){t.ajax({type:"POST",url:"/",data:{insertCrawler:!0,reqUri:document.URL,parseTime:"0.056",queryTime:"0.01654768548584",queryCount:"30"},success:function(t){}})})},!1),window.addEventListener("load",function(){jQuery(document).ready(function(){function t(t="",n=!1){var i="itms-apps://itunes.apple.com/app/id6462455425",e="openApp://action?"+t;isAndroid()?(setTimeout(function(){return window.location="market://details?id=com.solutioninn.studyhelp",!1},25),window.location=e):isIOS()?(setTimeout(function(){return window.location=i,!1},25),window.location=e):(i="https://apps.apple.com/in/app/id6462455425",n&&(i="https://play.google.com/store/apps/details?id=com.solutioninn.studyhelp"),window.open("about:blank","_blank").location.href=i)}jQuery("#appModal").modal("show"),jQuery(".download-app-btn").click(function(){t(jQuery(this).attr("data-question-open-url"))}),jQuery(".redirection").click(function(){var n=jQuery(this).attr("data-question-open-url"),i=jQuery(this).attr("data-id");void 0!=n?1==i?t(n,!0):t(n,!1):1==i?t("",!0):t("",!1)}),jQuery(".app-notification-close").click(function(){jQuery(".app-notification-section").css("visibility","hidden");var t=new FormData;t.append("hide_notification",!0),jQuery.ajax({type:"POST",url:"/",data:t,cache:!1,contentType:!1,processData:!1,beforeSend:function(){},success:function(t){location.reload()}})})})},!1); </script> </body> </html>