Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ Program ***MUST FOLLOW DIRECTIONS*** Assignment Objectives: To create a C++

ID: 665172 • Letter: C

Question

C++ Program

***MUST FOLLOW DIRECTIONS***

Assignment Objectives: To create a C++ computer program that is a game that bases itself upon binary trees. Your C++ program must satisfy all requirements of the game given below.

Binary Tree Terminal Node Game Requirements

Number of Players: 2

The premise of this game is two people taking turns populating a binary tree with numbers that are within a fixed range of 1-100. As each player inputs the number they wish to add to the tree each turn, the program will populate the binary tree. At the end of the game, the person with the most terminal nodes (the nodes at the bottom of the binary tree with no children) wins!

In order to ensure the tree is perfectly balanced at the end of the game, before the game begins, a pre-determined depth to the tree must be given by a user. So, if you wanted to play a game that used a tree of a node depth of 3 for example, you would tell the program before the game started to play until a node depth of 3had been reached, which would be a total of 22+21+20 = 7 nodes.

Since there will always be an odd amount of nodes in a balanced binary tree, and the players will end up inserting an even amount of numbers, the game will automatically delete the root node (the node at the top and center of your tree) at the end of the game in order to balance the tree.

Because of the players going over the amount of nodes needed for a balanced tree by one node, the game must be allowed to run for (let’s use a node depth of3again as an example) 22+21+20+1 = 8 node insertions.

The same number cannot be entered twice. So if a player attempts to enter a number that has already been entered, they must be prompted to try another number within the 1-100 range.

You must display the numbers that each player has entered to the players at all times. How you precisely decide to display this is up to you.

The point of making this game is to demonstrate how to program a proper binary tree. The tasks of inserting (putting the nodes into the tree one at a time), navigating (navigating the tree once the game is over to flag the terminal nodes for each player), and deleting (deleting the root node and making sure the tree is in order after the deletion) are all demonstrated in the implementation of this game.Please, do not use any binary search tree function libraries for this project & be sure to follow the directions exactly. Example game (above) demonstrates how the program/game should work.

Example Game Below you will find an example of how a game might go. At the start of the game, the program will ask the user to what node depth the game should go to Please enter the node depth you wish the game to go to: 2 In this case, this will be a quick game where the node depth is only 2 The first player is then prompted to insert their first number: Player 1's Numbers: Player 2's Numbers: Player 1, please insert your next number into the tree: 1 1 Player 1 was smart here and entered one of the end numbers in the range to essentially guarantee his/herself a terminal node. Player 1's Numbers: 1 Player 2's Numbers.: Player 2, please insert your next number into the tree: 100 100 Player 2 seems to have followed suite, to ensure to keep the game even

Explanation / Answer

#include #include #include "BTNode.h" #include #include #include using namespace std; BTNode::BTNode(board gameboard, string setplayer) { value = 2; //assume the game is continuing cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote