60 391
Assignments Done
98,1%
Successfully Done
In April 2018

Answer to Question #37680 in C++ for vcj2d

Question #37680
My Lab assignment just corrupted and I hadn't finished debugging my errors. I last worked on it two days ago. I can't remember what I had after a week of debugging and tweaking. my assignment was due last night, but my professor gave me a extension for a few hours (that is almost up and I am nowhere! Its like my brain is fried for finals!) Any and all help .. please! here is the info....

code given:
// Lab10a  Stacks and Queues

#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>

using namespace std;

template <class T>
bool Same(vector <T> tVector);


int main()
{
const int SIZE_INT = 8;
const int SIZE_STRING = 6;


int iTemp1[]= {1,1,2,3,3,2,1,1};
int iTemp2[]= {1,1,2,3,2,3,1,1};


vector <int> iVector1(iTemp1, iTemp1 + SIZE_INT);
vector <int> iVector2(iTemp2, iTemp2+ SIZE_INT);

string sTemp1[]= {"aa", "bb", "cc", "cc", "bb", "aa"};
string sTemp2[]= {"aa", "bb", "cc", "bb", "cc", "aa"};

vector <string> sVector1(sTemp1, sTemp1 + SIZE_STRING);
vector <string> sVector2(sTemp2, sTemp2 + SIZE_STRING);

if (Same(iVector1))
cout << "iVector1 values are in the same order forwards and backwards\n";
else
cout << "iVector1 values are NOT in the same order forwards and backwards\n";

if (Same(iVector2))
cout << "iVector2 values are in the same order forwards and backwards\n";
else
cout << "iVector2 values are NOT in the same order forwards and backwards\n";

if (Same(sVector1))
cout << "sVector1 values are in the same order forwards and backwards\n";
else
cout << "sVector1 values are NOT in the same order forwards and backwards\n";

if (Same(sVector2))
cout << "sVector2 values are in the same order forwards and backwards\n";
else
cout << "sVector2 values are NOT in the same order forwards and backwards\n";

system("pause");
return 0;
}

template <class T>
bool Same(vector <T> tVector)
{

/*Write the code for this function. You must use one STL stack of
type T and one STL queue of type T. You should not have more than 15 lines of
code total.*/

}


and documentation
[quote]Finish the code for Lab10a.cpp . You will write code for the Same function which will return
true if the values of the elements of the vector that is passed to it are the same read both
forwards and backwards. If they are not the same in both directions, it will return false.
Don’t change anything in the main function or add any additional functions to the program.

Output should match iVector1 same order, iVector2 Not same order, sVector1 same, and sVector2 not in same order.



and then the second part:
Trees - Part B (25 points)
Please complete the program below exactly as described. Don’t add anything extra to it
(methods, extra variables, features, etc.) and don’t leave any features described below out.
You are going to write a function that will use recursion to count the number of nodes in a tree. First
use the code on page 1141-1142 to develop the IntBinaryTree class (For the member functions,
you only need the code for the constructor and the insert member function). Your main program will
call a public member function called numNodes. This function will then call a private member
function, countNodes, that will use recursion to count the number of nodes in the entire tree:
int  IntBinaryTree::countNodes(TreeNode *nodePtr) 
{
if (nodePtr == NULL)
//write only one line of code here
else
//write only one line of code here
}

int main()
{
IntBinaryTree tree;

tree.insertNode(14);
tree.insertNode(10);
tree.insertNode(8);
tree.insertNode(6);
tree.insertNode(5);
tree.insertNode(7);
tree.insertNode(9);
tree.insertNode(12);
tree.insertNode(11);
tree.insertNode(13);
tree.insertNode(22);
tree.insertNode(30);
tree.insertNode(32);
tree.insertNode(24);
tree.insertNode(20);
tree.insertNode(17);
tree.insertNode(15);
tree.insertNode(18);
tree.insertNode(21);

cout <<"The number of nodes in the tree is: " << tree.numNodes()<<endl;

return 0;
}


Code from pages 1140-1142:

InBinaryTree.h
// Specification file for the IntBinaryTree class
#ifndef INTBINARYTREE_H
#define INTBINARYTREE_H

class IntBinaryTree
{
private:
struct TreeNode
{
int value; // The value in the node
TreeNode *left; // Pointer to left child node
TreeNode *right; // Pointer to right child node
};

TreeNode *root; // Pointer to the root node

// Private member functions
void insert(TreeNode *&, TreeNode *&);
void destroySubTree(TreeNode *);
void deleteNode(int, TreeNode *&);
void makeDeletion(TreeNode *&);
void displayInOrder(TreeNode *) const;
void displayPreOrder(TreeNode *) const;
void displayPostOrder(TreeNode *) const;

public:
// Constructor
IntBinaryTree()
{ root = NULL; }

// Destructor
~IntBinaryTree()
{ destroySubTree(root); }

// Binary tree operations
void insertNode(int);
bool searchNode(int);
void remove(int);

void displayInOrder() const
{ displayInOrder(root); }

void displayPreOrder() const
{ displayPreOrder(root); }

void displayPostOrder() const
{ displayPostOrder(root); }
};
#endif




Can Anyone help me!!![/quote]
Expert's answer
Dear customer,
Unfortunately, your question requires a lot of work and cannot be done for free.
Please submit it with all requirements as an assignment to our control panel and
we'll assist you.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions