C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 7th, 2013, 04:03 PM
vcj2d vcj2d is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2013
Posts: 2 vcj2d User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 2 m 5 sec
Reputation Power: 0
Exclamation General - PLEASE HELP!!!! Vectors, stack, queue, templates

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:
Code:
// 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:
Code:
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
Code:
// 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!!!

Reply With Quote
  #2  
Old December 7th, 2013, 05:28 PM
vcj2d vcj2d is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2013
Posts: 2 vcj2d User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 2 m 5 sec
Reputation Power: 0
Please! Help!!!

I have been working on this for a while and have figure out parts of this.. but for the most part I am still Totally lost... [QUOTE=vcj2d]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:
Code:
// 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:
Code:
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
Code:
// 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!!!

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > General - PLEASE HELP!!!! Vectors, stack, queue, templates


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap