what I am trying to do is store same letter to same node. For example: let say I have person, people is sent to be put into a node. This will create two node. I want to some thing like P: Person People Person and People are same note When I run this on Visual Studio I got C2440 type cast: cannt convert from IntBinaryTree:treeNode to Char; C2264 std:: basic_string.... void IntBinaryTree::insert(TreeNode *&nodePtr, TreeNode *&newNode) { string combineworld; stringstream sk; string newsk; string word = nodePtr->value; char key = word.at(1); sk << key; sk >> newsk; cout << "newsk : …

Member Avatar
Member Avatar
+0 forum 2

Hi,i have a code like this in .h file: #pragma once #include "stdafx.h" #include"iostream" using namespace std; // balance factor enum enum BalanceFactor { LH, RH, EH }; // treenode struct template<class T> struct TreeNode { T info; TreeNode<T>* left; TreeNode<T>* right; BalanceFactor bf; }; template<typename ItemType> class TreeType { private: TreeNode<ItemType>* root; public: TreeType(); void RotateLeft(TreeNode<ItemType> * & tree); void RotateRight(TreeNode<ItemType> * & tree); void InsertItem(ItemType item); void Insert(TreeNode<ItemType>*& tree, ItemType item, bool & taller); void RightBalance(TreeNode<ItemType> *& tree, bool & taller); void LeftBalance(TreeNode<ItemType> *& tree, bool & taller); void Print(TreeNode<ItemType>* tree); void PrintTree(); }; template<class T> TreeType<T>::TreeType() { …

Member Avatar
Member Avatar
+0 forum 3

I wrote a template class named "Tree<T>" in C++ which attributes are : - T data - std::vector<Tree*> sons; I wrote the basic methods consisting of writing and reading in those two attributes. Now, I'm writing methods that return the min and max depth. I have no compilation problems but when I test these methods on an example, I get false values. Here's the code for the minDepth and maxDepth methods (the other methods have names that make clear what they do) : int numberOfLevels() //we assume that this methode will be called on an initialized node { if (nbSons()==0) …

Member Avatar
Member Avatar
+0 forum 1

Hey Guys, I am building app using a huffman tree, and am building this java program to just test a few things and I am having some trouble. I have everything working except that I am having troble decompressing a huffman string back into the original string. I would appreciate any help on this. Please find attached my code so far. As you can see so far, I have most of it down, its just the decompression part that I need trouble with. Essentially, I need to rebuild a huffman tree using the huffman tree string and then use that …

Member Avatar
Member Avatar
+0 forum 1

I'm trying to modify this code: class Tree: def __init__(self, cargo, left=None, right=None): self.cargo = cargo self.left = left self.right = right def __str__(self): return str(self.cargo) def print_tree_inorder(tree): if tree is None: return print_tree_inorder(tree.left) print(tree.cargo, end=" ") print_tree_inorder(tree.right) So that it adds parentheses around every operator and pair of operands. I just don't understand where I have to put the parentheses in this to make it work... Any help would be great please!

Member Avatar
Member Avatar
+0 forum 10

hello i have an attribute in 'users' table called RegNo which refer ro region number ... so i have to select users and display them according to their region number . here is my code <body> <ul id="nav"> <li class="heb"> <a href="parentUrl" >hebron</a> <li class="bet"> <a href="parentUrl" >ramallah</a> <?php include ("config.php"); $query="select * from users"; $returnValue=mysql_query($query,$connect); if (!$returnValue) die ("error"); else { while($row=mysql_fetch_array($returnValue)){ if ($row['RegNo']==100){ echo '<ul class="heb"> <li><a href="childAUrl" >'.$row['username'].'</a></li> </ul> '; } } } ?> </li> </li> </ul> so if the RegNo=100 , username must be displayed under 'hebron' city... how i can solve this problem ?!

Member Avatar
Member Avatar
+0 forum 9

hi all, this is some extra credit from class we sat around cleaning up code today this is what we came up with public boolean equals2(IntTree t2){ return equals2(this.overallRoot, t2.overallRoot); } private Boolean equals2(IntTreeNode r1, IntTreeNode r2){ if(r1 == null || r2 == null){ return r1 == null && r2 == null; } return ((r1.data==r2.data)&& equals2(r1.left, r2.left) && equals(r1.right, r2.right)); } we get five points extra credit if we can shorten any further. So my question iscan someone explain to me the ^ character and is that the right path to shortening this code

Member Avatar
Member Avatar
+0 forum 7

hi , i am searching for a good tree menu design for products categories to use it in my website , i need it to be flexible so i could style it as needed and also simple so i can target it with my own javascript. thanks again.

Member Avatar
Member Avatar
+0 forum 2

Hello. I'm developping a project about the decision tree in Java. My project idea is about animals, but it's gonna be a big database and i don't have too much time to complete. So my question is: Can anyone help me to found a complete database about animals or about anything related to a decision tree project(maybe about fictional character, etc..). (Note: the database should be in sql or oracle). Thanks in advance.

Member Avatar
Member Avatar
+0 forum 1

hey guys, so im creating a page using php html js etc and what i wanna do is have two tables on that page. the first table is populated by data from database(easy) the second table is tricky for me. in the second table i want to be able to add rows but as a tree structure. for example button "add row" adds a new row in the table but at the same time it can be viewed as a tree structure(like it has that small arrow at the side) because i want to add functions like add subject(child) to …

Member Avatar
+0 forum 0

this code was error.please help me fix it include <iostream> include <conio.h> include <algorithm> using namespace std; int a[]={1,5,7,4,9,8}; BST*binary_search_tree; struct BST{ int value; BST* left; BST* right; }; int search_bst(BST* node,int key){ if(node==NULL) return -1; if(key<node->value) return search_bst(node->left,key); if(key>node->value) return search_bst(node->right,key); else return node->value; } void insert_bst(BST* &treeNode,BST* newNode){ if(treeNode==NULL) treeNode=newNode; else if (newNode->value<treeNode->value) insert_bst(treeNode->left,newNode); else insert_bst(treeNode->right,newNode); } void inorder_bst(BST* tree){ if(tree==NULL) return; inorder_bst(tree->left); cout<<tree->value<<" "; inorder_bst(tree->right); } void binary_tree_sort(int a,int length){ BST item; for(int i=0;i<length;i++){ item=new BST(); item->value=a[i]; insert_bst(binary_search_tree,item);} inorder_bst(binary_search_tree); } int main() { binary_tree_sort(a,6); return 0; }

Member Avatar
Member Avatar
+0 forum 5

so i got a class going for making and showing tree elements, i need some help with the following: i need to display the leaves and the height of the tree. here is the code: // ar.cpp #include <iostream> #include <stdlib.h> using namespace std; class nod { public: char inf; int dim; nod *tab[100]; }; nod * crearb(); // Functia pentru crearea arborelui void padinc(nod *); // Functia pentru parcurgerea in adincime void plat(nod *); // Functia pentru parcurgerea in latime class queue{ public: queue(): size(0), end(0) { } void pop(); // functia elimina un element din coada void push(nod …

Member Avatar
Member Avatar
+0 forum 4

Hey! So I am having trouble with this [problem](projecteuler.net/problem=18)! Basically you have to find the path that gives the largest sum down this tree: 75 95 64 17 47 82 18 35 87 10 20 04 82 47 65 19 01 23 75 03 34 88 02 77 73 07 63 67 99 65 04 28 06 16 70 92 41 41 26 56 83 40 80 70 33 41 48 72 33 47 32 37 16 94 29 53 71 44 65 25 43 91 52 97 51 14 70 11 33 28 77 73 17 78 39 68 …

Member Avatar
Member Avatar
+1 forum 2

**hello peeps and geeks, i am missing the MinSpanningTree function here.. any help please? need to fill up the function to get a) Minimum spanning tree cost for the graph b)Spanning tree path for the graph. E.g in matrix or adjancency list. ** #include <iostream> #include <ctime> // For time() #include <cstdlib> // For srand() and rand() #define N 6 #define infinity 9999999 using namespace std; void MinSpanningTree(int AdjMat[N][N]) { cout<<" The minimal Spanning Tree cost is "; cout<<"The minimal Spanning path is "; // A B C D } int main () { int AdjMat[N][N] = { 0, 1, …

Member Avatar
Member Avatar
+0 forum 2

would any one give me idea or code about how to make a binary search tree of apple Ltd products prices. suppose products are: macbook i3, macbook i5, macbook i7, iphone 3g, iphone 3gs, iphone 4, iphone 4s, iphone 5, iphone 5s, iphone 5c, ipand 2, ipad mini.

Member Avatar
+0 forum 0

Hey everyone, I really need help in solving a problem that I have to use recursion for. I have a list of paper objects. Each paper object has its own author(s) objects. Each author object knows which paper(s) objects they belong to. I have to build a scholarly neighborhood for these authors. The user can select an author and specify the "width" of the neighborhood that they wish to view. The width of this neighborhood goes as follows: If they enter "0" the neighborhood will consist of only the author that they selected. If they enter "1" the neighborhood will …

Member Avatar
Member Avatar
+0 forum 4

I have to write the an AVLTree in python, followed all the instructions and I feel I have it just right, only problem is I can't figure out how to display my tree. I have to use the test given below, as well as the 2 methods below in the TreeNode class, which are used to display the AVLTree. I'm not expecting any answers. I looked into my textbook to no avail. Looked online, found nothing to help me in figuring this out. Can anyone give me a nudge in the right direction?? if __name__ == "__main__": bt = AVLTree() …

Member Avatar
+0 forum 0

Hello, I'm trying to write a program that takes an input file name and lists the folders in a heirarchy ex.Folder subfolder etc I have most of my code, but I'm getting 2 errors that are connected and I have no idea how to fix it. Here is my code: import java.util.Scanner; import java.io.File; public class TreeStructure { public static void main(String[] args) { if(0 < args.length) { String folderName = args[0]; File folder = new File(folderName); } Scanner input = new Scanner(System.in); System.out.println("Enter a folder name"); System.out.flush(); String folderName = input.nextLine(); File folder = new File(folderName); treeTraversal(folder, folderName); } …

Member Avatar
Member Avatar
+0 forum 1

[CODE]//To convert postfix expression into an expression tree #include"stdio.h" #include"conio.h" #include"process.h" #include"string.h" #include"stdlib.h" struct node{ char item; struct node *lnode; struct node *rnode; }*stc[30],*temp,*root; typedef struct node *NODEPTR; char expression[50]; char c; int top=0; NODEPTR pop(); void push(NODEPTR); void getinput(); void inorder(NODEPTR p); int main (){ getinput(); int i,j; for(i=0;i<strlen(expression);i++) { printf("\nstrlength=%d--------for i=%d\n",strlen(expression),i); c=expression[i]; switch(c) { case '+': case '-': case '*': case '/': case '^': { temp=(NODEPTR)malloc(sizeof(struct node)); temp->item=c; temp->rnode=pop(); temp->lnode=pop(); push(root); } default : { temp=(NODEPTR)malloc(sizeof(struct node)); temp->item=c; temp->lnode=NULL; temp->rnode=NULL; push(temp); } void free(void *ptr); break; } } root=pop(); inorder(root); getch(); } NODEPTR pop(NODEPTR p) { if(top==0) printf("Underflow …

Member Avatar
Member Avatar
+0 forum 5

Hi all, I want to create all possible combinations of a full binary tree which must have exactly 4 leaf nodes and 3 internal nodes. I want to create it using recursion and tree must be simple binary tree not a binary search tree or BST. Kindly suggest algorithm to achieve this task. Thanks in advance.

Member Avatar
Member Avatar
+0 forum 4

Let's use the basic example.. I have a table for tree representation with just 3 columns: ID, PARENT_ID,NAME. If I delete a record X, how can I delete all recursive records that refer as PARENT_ID of deleted record?

Member Avatar
Member Avatar
+0 forum 1

I have created my binary tree as , It Shows in List Perfectly but i want to show in Genealogy , how can we do this ..I have Pasted My Total Nodes Script Here with HTML & java script for making tables & draw lines btwn nodes . When I Visit This page This msg appears "There has been an error while generating this tree. <br>Please contact the system admin at <?= get_settings('admin_email') ?> to report this problem." **list View it Shown as** Right Sale = 5Nodes Left Sale = 5Nodes **Genealogy View ** total Nodes Right Nodes Left Nodes …

Member Avatar
Member Avatar
+1 forum 1

Im trying to add Total function and isMono functions to this code. Did total already Need help with function ismono which returns whether a tree is mono (all the elements are unique aka no element appears more than one time) or not. Please this is the original program #ifndef T_H #define T_H #include <iostream> #include <iomanip> using namespace std; struct tnode { int info ; int count; tnode * right, *left; }; tnode * insert(int target,tnode * t); tnode * makenode(int x); tnode * tsearch(int x,tnode * t); void inorder(tnode * t); int height(tnode * t); int count(tnode * t) …

Member Avatar
Member Avatar
+0 forum 2

Hi, I need a function that will take a tree as argument and return the number of ints that were typed and a correct call. would it just be preorder? like below. Please. Thanks #include "t.h" void preorder(tnode * t){ if (t == NULL) return; cout << t->info <<endl; preorder(t->left); preorder(t->right); } call would be preorder(t).

Member Avatar
Member Avatar
+0 forum 2

Hello All, So I'm working on hand-coding a forum-like website, just for the experience, and I want to have a similar feature as you'll see above where a thread will have its ancestors linked: "Web Development > JSP > Parent traversal of tree-like Structure" I have several beans for different things, post, thread, category, forum and so on, all have a name property and all (will shortly, still adding) have a parent property. I know I could do this all in Java code inside a tag handler that would just print the whole thing, but I'd rather do it in …

Member Avatar
Member Avatar
+0 forum 2

Hi This code not run : it show this error: incompatible types-found java.lang.String but expected HuffmanCodingAnimation.Node This line of code ` root.left.code = root.code + "0";` Here is the code: import javax.swing.*; import java.awt.*; import java.awt.event.*; import javax.swing.tree.*; /* * This program enables a user to enter text and displays the Huffman coding tree based on the entered text. * * The display shows the weight of the subtree inside a subtree's root circle. The character is displayed at each leaf node. * The encoded bits are displayed for the text in the dialog box. * The decoded text button …

Member Avatar
Member Avatar
+1 forum 3

Hi Everyone, I am trying to get the program below to work correctly. The line below is where I'm having trouble. (line 33 in PrefixCalc.java) calc = new ExpressionTree(new Scanner(console.nextLine())); When I run the program and enter "4 + 8", the scanner only picks up "4". Apparently this program was developed using the Scanner from Java 5. How do I get the entire line into a Scanner object? *** I found this program online at http://penguin.ewu.edu/cscd300/Topic/ExpressionTree/ExpressionTree.pdf. This is not my program. I am just learning from it. *** /** * Prefix calculator: generate the expression tree, then display it * …

Member Avatar
Member Avatar
+0 forum 4

I have to write a program that creates a binary search tree from a file and output it and several other requirements. One requirement that I cannot figure out is how to find the search cost for each node. These are the instructions I was given Calculate the search cost for each node when it is inserted – A binary node element has at least two data fields: Key and SearchCost – For each node, count and store the number of comparisons required when searching for the node (i.e., the number of comparisons = the search cost for the node …

Member Avatar
Member Avatar
+0 forum 1

I am doing huffman coding and I have made the tree. Now I am required to traverse the tree to create bit strings associated with the characters. Then I will put the bit string and char into a map to use with encode/decode. I have been working on this for days and could really use some help. Thanks for any help you can offer! map<char, string> build_encoding_map(freq_info*& huffman_root) { map<char, string> ret; string char_code; char symbol; if (huffman_root->left == NULL && huffman_root->right == NULL) { cout << "Your tree is empty." << endl; } else { while (huffman_root->is_leaf = false) …

Member Avatar
Member Avatar
+0 forum 1

Hi Guys, I am working on a binary search tree and I've been stuck on some code for the last couple of days. There are 2 issues that I can't seem to figure out how to fix. 1) I have a file that has a list of names and ID's and that needs to be inputted into a BST. The odd thing is when the file has an odd number of names, I get an error and when it' even it doesn't give an error. 2) I also need to use depth-first and in-order tree traversal to print to a …

Member Avatar
Member Avatar
+0 forum 1

The End.