Click here to Skip to main content
15,892,927 members
Everything / Trees

Trees

trees

Great Reads

by Dirk Bahle
A list of advanced tips & tricks on Virtualized WPF TreeViews
by Dirk Bahle, Alaa Ben Fatma
Tips & tricks on visting and searching nodes in WPF TreeViews
by Vyacheslav Voronenko
Three approaches to store tree like structures with NoSQL databases in MongoDB
by BrainlessLabs.com
This tip describes a n ary tree structure.

Latest Articles

by IAmJoshChang
How to traverse a postorder binary tree
by Vlad Neculai Vizitiu
Mocking/stubbing lambda expressions to have a bit more control over our unit tests
by Akshay Srinivasan2
This article describes a technique to quickly retrieve and present hierarchical information from a flat relational database table with only one table scan.
by chuck in st paul
This is a utility program for bulk/batch renaming of files that demonstrates using and creating events

All Articles

Sort by Title

Trees 

24 Feb 2018 by Dntdothis
I ran to an issue, I have a task with categories and items, I need to make a menu tree list, it can be N deep, parent can have many children as he wants: Menu tree looks like this: - Category (6) - Category (3) - Item (€0.50) - Category (2) - Item (€1.10) -...
24 Feb 2018 by BillWoodruff
Knowing your tree's item nodes are always leaf nodes of a specific type makes your task a bit simpler. I'm going to post a sketch of a structure that will implement a tree of this type which I know works. I say "sketch" because my goal is to assist you in developing your programming skills ......
27 Apr 2015 by Jörgen Andersson
A high performance extension for creating a DataTable from a Generic collection.
5 Aug 2011 by beratxt
Hi GuysI have a trouble with this website https://ebeyanname.gib.gov.tr/giris.html . After I navigate this link in webBrowser Control , Website is directed to automatically https://ebeyanname.gib.gov.tr/index.html . So , I have trouble to show in webBrowser this link .How can i solve this...
6 Aug 2011 by Richard MacCutchan
The web site is automatically forwarding your browser to the second link; there is nothing you can do about this.
10 Dec 2013 by Petr Ivankov
Multidisciplinary paradigm of software development
11 Aug 2010 by Richard MacCutchan
If you are using MFC (or even pure Win32) then I would suggest using a splitter window with a treeview in one pane and a list view in the other. Alternatively you could show a dialog with a listbox on every tree node selection. Your question is really too general to give a definitive answer in...
22 Dec 2017 by Dirk Bahle
Tips & Tricks on loading and saving WPF Tree View based content.
8 Dec 2017 by Dirk Bahle, Alaa Ben Fatma
Tips & tricks on visting and searching nodes in WPF TreeViews
16 Sep 2017 by Dirk Bahle
A list of advanced tips & tricks on WPF TreeViews
22 Sep 2017 by Dirk Bahle
A list of advanced tips & tricks on Virtualized WPF TreeViews
16 Nov 2015 by girish sp
I have to work with c tree(Conditional Inference Trees) in my Asp.net project,i know c tree is directly not supported, so i am looking for the alternatives which i can start with, i came across r.net i cannot use it as it requires executable to be installed on client side, i went through the...
11 Nov 2015 by Yuriy Magurdumov
Simple generic data structure to maintain hierarchical objects
23 Apr 2011 by algrn912005
Hi,I'm having a little trouble with creating a function to find the average depth of a binary search tree. The definition of average depth of a tree is the sum of the depth of all nodes divided by the total number of nodes. The definition of the depth of a node is the distance from the root of...
23 Apr 2011 by Sergey Alexandrovich Kryukov
The problem is not finding the depth, the problem is to do it just once. Here is the way to do it: do not create a function for finding a depth of the current node. Instead, include the depth of a current node as a parameter of the recursive function.void AccumulateNodeInfo( node *...
24 Apr 2011 by mbue
For every thing i do with trees i use walk functions.Example for a walk function:class INode{public: INode* _child; INode* _next;};class IWalk{public: // IWalk virtual HRESULT Enter(INode* pNode) = 0; virtual HRESULT Leave(INode* pNode) = 0;};void...
2 Dec 2016 by Member 12884199
You have to find average depth at once .I use this formula->AD(n)=ln(n+1)÷ln2This you can find from the formula as we can find maximum no.of nodes by //n=(2^d)-1Where d is depth of the tree.
12 Mar 2019 by Member 10743491
I am trying to perform insertion in one function and then balance the tree if required in another.Here is my code...node* create_bst(node* tree,node* curr){ if (tree==NULL) { return curr; } if(tree!=curr) { if(tree->key>=curr->key) ...
11 Apr 2014 by Steve44
I think the problem is that you are missing the final statement in the balance function: ... return tree;}The statements that assign to tree have no effect that are visible from the caller:(The comments are referring to your example of inserting (2,0,-1) and balance() is...
19 Mar 2018 by jcsanchez1
I am trying to create a b* tree data structure using list. List> List> I am not pretty sure, in the first one I just get 2 levels of the tree, but in the case, the tree will be deeper? I think in the second case fit more with my needs because I can use a list as an...
24 Apr 2021 by Petr Osipov
Hi all, at an interview I was told B-trees are not binary trees as they are intentionally wide structures containing many children elements that are linked to facilitate reversed order traversals is the second part talking about linked...
15 Mar 2013 by johngorman1
I'm starting a new application to search a text file with up to 12000 items for a given term and also allow a depth to be specified.My application requirements are as folllows:A word search tree that allows:1.Parse a text file and build the tree.2. Allow a depth to be specified3....
15 Mar 2013 by Sergey Alexandrovich Kryukov
Thank you for clarification of the question. In this case, you really need to implement one or another kind of a search tree:http://en.wikipedia.org/wiki/Search_tree[^],http://www.drdobbs.com/database/ternary-search-trees/184410528[^].For space efficiency and simplicity, a ternary search...
10 Aug 2023 by pavan idirect
I am trying to come up with a design to efficiently send a tree data structure (each node can have more than 2 branches) to a socket/different process etc. There seems to be a cap on how much data can be sent in one message (1500 Bytes). The tree...
26 Jul 2011 by fgoldenstein
I'm working on a Product BOM (bill of material) and I'm stucked. This is my class diagram: •A Component has ComponentItems. A ComponentItem has a Component and a quantity. Example: Component ABC has 3 Component C1 and 2 Component C2. •A Product has ComponentItems and ProductItems (similar to...
26 Jul 2011 by BobJanova
First question: how complex are your components? Recalculating the price each time may not be a problem, and means that you have no issues with caching and making sure updates work.What you essentially want for rebuilding the prices is a reverse tree: starting from the component that you...
25 Aug 2019 by higii
Trying to learn about Binary Tree while preparing for an exam, and I came across this code. And even tho it looks like it makes sense I simply cannot understand the purpose of this and how it actually works, so can anyone please elaborate? And this is the code : space += 5; ...
25 Aug 2019 by RickZeeland
Here is a tutorial: Binary trees - Learn C - Free Interactive C Tutorial[^] And here is a nice explanation: binary-search-trees-explained-5a2eeb1a9e8b[^]
19 Nov 2011 by T0mii
My program is crashing when i try to delete the largest number, can some one help me please? I really dont know any further i tried my best. Here is the code please some one help:#include #include #include using namespace std; template class...
19 Nov 2011 by T0mii
fixed it, i was over thinking it, cause i just need to delete the largest number in my tree and that wont have a right childe, and then i only have to replace it with the left childe if he got one and delete it, it works perfect, ty everyone who helped me, trough this project.Here is the...
11 Aug 2015 by Christian Specht
Building a pseudo-dynamic tree menu with Jekyll
13 Apr 2016 by Gun Gun Febrianza
i wonder how and what is the best method to create a data tree from particular string with specific pattern into TreeView Control in c#?For example i have input string like this :(program (statements (statement (var_declaration (primitive_type string) (identifier a) = (expression "hi")...
13 Apr 2016 by OriginalGriff
This example uses "(" and ")" - but that's a trivial change: c# - Tree structure as string - how to match nested braces? - Stack Overflow[^]
13 Apr 2016 by BillWoodruff
As Sergey suggested, the "big win" here would be to get whatever is producing your data formatted as string into JSON, or XML format; parsing those formats to a Tree data structure, or creating a populated TreeView Control using those formats, is straightforward.If you are going to try and...
23 Jun 2011 by Mesrop Simonian
Hi everyone,I have a hierarchical tree that can have an unspecified number of branches. You add children to parents then parents to their parents and so on. Everything then gets added onto the main branch. Something like this:MyTree t = new MyTree(); Branch topBranch = new...
22 Jun 2011 by OriginalGriff
It's pretty simple: the runningTotal is passed to the routine by value, not buy reference. So when you make changes to it, they are not reflected back up the tree.For example:void Change (int i) { Console.WriteLine(i); if (i
23 Jun 2011 by TRK3
See my reply in Solution 1 for why root level siblings are not getting traversed.I think a better way to do this, would be to have a member variable called TotalNumberOfChildren.When you create a branch, TotalNumberOfChildren is set to zero.Add a member function:void...
24 Jun 2011 by BobJanova
I think this is easiest in two passes (which has been alluded to in previous answers), a precalculation pass where the totals for each node are recorded (which must traverse the whole tree), and a calculation pass where the branch's value is compared to the parent or root.class Branch {...
8 Jun 2011 by Member 7975239
Hi everyoneFor the check boxes for the in the windows form application, I wonder if there is a 3rd state I could use. For example, if the parent is checked then all of it's childs are checked. if the parent is unchecked then all of it's child are unchecked. But if some of the childs are...
8 Jun 2011 by Dave Kreskowiak
It's not that simple. The standard TreeView control in the ToolBox doesn't support doing this natively, so you have to make your own, or find a third party control that does this for you.There's a couple of CP articles that cover doing something like this here[^] and here[^].
29 Apr 2017 by Member 13161564
I have a Binary Search Tree, some functions in it, not planning to use any other libraries, nor use vectors, I have to use arrays and a tree. This code will mostly work, except for a bug, that for some roots, the functions that add arrays wont work or the printing functions wont work. Basically...
29 Apr 2017 by OriginalGriff
Development is not a case of "write it, compile it, fix compiler errors, compile it, ship it" - just compiling does not mean your code is right! :laugh: Think of the development process as writing an email: compiling successfully means that you wrote the email in the right language - English,...
29 Apr 2017 by Patrice T
Quote: No errors, compiles fine. "Compiles fine" means that your code is correct C++, it does not mean that it does what it should as "no error" would mean. "The cat is flying high in the sky.' is correct English grammar, but it is non sense. Quote: Tried debugging, but I'm a novice and it got...
12 Nov 2011 by Lady Malie
Can anyone please help me understand about random forests?
12 Nov 2011 by Mehdi Gholam
Start here : http://en.wikipedia.org/wiki/Random_forest[^]
13 Nov 2011 by Sergey Alexandrovich Kryukov
Yes, somebody can.(The proof is the post by Mehdi.I answered your question, but it does not look very useful, does it? This is because you ask incorrect question. Take it into account next time. However, for this very question correcting it makes no sense. Use Wikipedia and Google first,...
30 Oct 2013 by Thomas Bovee
I am trying to make a tree structure modeled like this: first-entered string is a “root”, second one is a ‘parent’, and third one is a ‘child’. I don’t want to create a binary search tree, or anything similar. My tree structure would ideally take strings in account and show everything in the...
30 Oct 2013 by Ronnie Peoples
I suggest creating your own class that will represent binary tree, since there are no built-in classes in .NET for tree structure manipulation.You can take a look at these threads to find more...
30 Nov 2011 by Rupanjana
I want to bind data and show data in a horizontal hierarchy order like family tree.Please suggest me the way to achieve this..
1 Dec 2011 by thatraja
Found similar questions with answers, check theseTree View in Asp.net[^](MLM type tree)Creating dynamically Binary Tree to Display Member[^]Draw a Binary Tree using Asp.Net[^]
25 Aug 2015 by XyedBilal
Turn horizontal d3 tree to vertical
21 Jul 2012 by Chris___808
If I use the DC of my CTreeCtrl-derived class to calculate the horizontal extent of a tree item I would like to insert: CDC *pDC = GetDC(); CSize nameSize = pDC->GetTextExtent (*dString);... it seems I cannot depend on this function while appending characters to the...
21 Jul 2012 by Code-o-mat
My guess would be that when you do the GetDC-GetTextExtent thing the DC has a different font selected into it (System font maybe?) than when the tree is drawing the items.When you do the calculation, maybe try querying the tree for its font with GetFont[^] and use it for the calculation.
13 Feb 2015 by Sergey Alexandrovich Kryukov
Please see my comment to the question. In simplest case, if you have some graph (not only a tree) with the nodes of the same type, it can be represented by a single table, a table of nodes. Each record should have one or more attribute used to indicate relation with other node pointing to it by...
19 Apr 2019 by Simon_Whale
I think this would be a good read on how to store AVL trees in SQL Server. Binary Trees in SQL - Simple Talk[^]
19 Apr 2019 by User 9414576
Greetings ,For my application I need to make AVL trees for tags that would be balanced with every query. What would be a good a database to store this form of data. XML is taking way too much time to store and parse?It is a .NET based project and any help would be appreciated.
26 Sep 2012 by rohit ranjan
Hello All , I have Store procedure which create the hierarchy of the user.Next step is that i need to bind result set with tree view control.I am getting difficulty in showing the value.Can any body help me in this.here is sample SPDECLARE @sys_user TABLE (UserId...
2 Apr 2012 by Eugene Sadovoi
Various approaches to implementation of property initialization with DefaultValue attributes
17 Aug 2013 by Brady Bar
/* 12 /\ 9 15 / \ \ 4 11 21The node with data 15 is not being deleted in the above binary serach tree.*/#include#include#includetypedef struct Node { int info;...
17 Aug 2013 by Sergey Alexandrovich Kryukov
Let's do one step at a time. I'll tell you just the problems I can see immediately. Fix them first, and then see if you can solve the problem completely.Both deleteNode and deleteItem have some wrong set of parameters. Your function deleteItem has a redundant parameter item. You don't really...
17 Aug 2013 by OriginalGriff
Look at your code:void deleteNode(node *root,node* parent){ node *temp; if(root->left==NULL)/*Only left child*/ { if(parent->left==root) parent->left=root->right; else parent->right==root->right; free(root); } else...
5 Sep 2021 by Priyanka Somani
I'm trying to understand the low time used in tarjan algorithm using the second example given on GFG Tarjan's Algorithm to find Strongly Connected Components - GeeksforGeeks[^] What I have tried: According to GFG the definition of lowtime is...
13 Mar 2011 by The_Real_Chubaka
Hi,I have tried o look in Google but, it seems like it is going to take me 2 days to find good notes or a good tutorial. I am also looking for easy to follow notes or tutorials on HTML parsersThe tutorials have to be for C++ programmers.Thanks in advance
13 Mar 2011 by Yusuf
You question is some what not complete. For starters you need to explain what you mean by 'HTML Trees'. The fact that you put it in quotes suggest that you meant something, but clearly you know that is not the term. Also, the fact that you are unable to find any good hits with google may be the...
8 Jun 2018 by BerthaDusStuf
I am reading jumping into c++ and in it there is this code that is made to insert into a tree: node* insert (node *p_tree, int key) { // base case--we have reached an empty tree and need to insert our new // node here if ( p_tree == NULL ) { node* p_new_tree = new node; p_new_tree->p_left =...
8 Jun 2018 by Patrice T
Quote: Does this code to insert to a tree not work for empty trees? First: read the code and particularly comments. // base case--we have reached an empty tree and need to insert our new // node here second: there is an easy way to know the answer, make a testing program that call the routine...
20 Jan 2021 by Emre Yaşar
Draw an expression tree for " k p * t / m n r - $ + ." What does ıt mean " $ " symbol . in Data Structure . What I have tried: $ ı dont know that symbol meanıng So ı cant tried anything.
20 Jan 2021 by OriginalGriff
C has no operator "$" - so you will have to go back to your teacher and ask him exactly what it means in this context. SInce expression trees rely on operator precedence you need to know where each operator "fits" in the scheme of things before...
20 Jan 2021 by Patrice T
Quote: What does ıt mean " $ " symbol . Do you really need to know ? The '$' look like an operator in this expression, the only mystery is unary or binary. By the way, I don't know either whet is the '.', since it is not a multiplication. You...
7 Sep 2012 by c0derM
Hi, im trying to draw a family tree. i will try to tell the conceptheres the main data table|ID | Name | ....| Spouse ID| Mother | Father |________________________________________________|p01 | Jhon | ....| p02 | | ...
6 Sep 2012 by fjdiewornncalwe
I actually did this years ago as a project for my father, but I don't have the source anymore. Basically what you have to do is this:The key is to break down the solution into smaller bits that are manageable.1) Decide how to draw a single node on the tree and build that object.2) Decide...
6 Sep 2012 by Andrei Straut
I would recommend you take a different look at how your database is structured. I would recommend you go with Nested Set Model[^] structure. In combination with a PostreSQL DB (which supports recursive queries) it can be a very powerful solution.I've implemented this once (actually it was BS...
31 May 2016 by Hamid Mosalla
Dynamically building JSON tree for use In JavaScript components using C#
25 Jan 2016 by GravityPhazer
This article demonstrates how you can simply enumerate any generic tree depth-first as well as breadth-first using the described construct. Trees can be serialized binary (using the BinaryFormatter), custom binary and as XML.
9 Aug 2013 by Brady Bar
//The following line of code gives above mentioned error//printf("%d",root->left->info);// is there any flaw in the algorithm or coding#include#include#includetypedef struct Node{ int info; struct node* left; struct node*...
9 Aug 2013 by nv3
The problem lies in the definition of your node structure:typedef struct Node{ int info; struct node* left; //
4 Dec 2012 by sadomovalex
Shows how using reverse engineering feature developers may add new conditions into string CAML queries using lambda expressions.
18 Aug 2012 by Dan Randolph
C# interop using platform invoke and C++ vectors to implement fast searching and selection on index keys
9 Nov 2013 by Jakob Lithner
Extension to the TreeView control making it very fast to load items
23 Apr 2011 by aditya kiran maroju
Hi ,Can any one guide me how to create a file Explorer in winformsMy requirement is i want a tree view to display all the directortes in the directories in the system and on clicking the particular folder in the tree view i want to display all the text files with size and date in the...
23 Apr 2011 by Ed Nutting
I would suggest you start by looking at the System.IO namespace with specific reference to the File and Directory classes. The static methods of the Directory class include GetDirectories (which will return top level or all sub directories of a directory you specify) and also GetFiles which will...
14 Nov 2010 by infinateone
A file manager app with Clipboard interaction and drag and drop support.
7 Apr 2010 by ramindya
****THIS IS A ASP.NET Web APPLICATION NOT WINDOWS FORMS*************Problem/ Question: To search a child node anywhere in the treeview. I need to type a Node name in the textbox and search the node name in the Treeview and highlight the node name on finding. I don’t how to do it. I tried for...
21 Apr 2010 by ely_bob
quickest way is a ///Pass into this the base Node.TreeNode recursiveFind(TreeNode Node, obj yourCritera){TreeNode HoldTN = null; foreach(TreeNode tn in Node.Children){ if([YOUR SEARCH CRITERA]){ return tn; } else{ HoldT = recursive(tn);...
21 Apr 2010 by Pranay Rana
Following is code used by me to highlight selected now in tree view #region code done for selecting node by pranay rana string filename = this.Request.FilePath.ToString().Substring(this.Request.FilePath.ToString().LastIndexOf(@"/") + 1); ...
8 Jun 2017 by Member 13248256
Hello all! I am trying to figure out a way to search a BST for its balanced subtree with max height. What I have tried: I have so far been able to find methods to check the height of a tree and to check whether the tree is balanced. I'm having a hard time getting these to work to locate the...
8 Jun 2017 by KarstenK
To get the maximum height you need to store your actual maximum somewhere and compare it with the actual value. And your are missing some edge cases like the last else in MaxBalanced which is missing. You need a fallback in non-balanced trees.
31 Aug 2011 by optimus_prime1
I am trying to write a program that can detect and print two nodes in BST that have been swapped.In a three level tree, I reached near to the solution using this approach.If (!AllSubTreeAreValid()){//Nodes swapped on same side of main root node}else{ int max =...
31 Aug 2011 by dasblinkenlight
Convert the tree to a list using an in-order traversal[^]. The list will be sorted, except for the two swapped elements. The first of them will be followed by a smaller number; the second one will be preceded by a larger number.9 10 16
31 Aug 2011 by mbue
7 Aug 2013 by syed tousif
Can anyone explain the logic for the below code?int FindMax(BinaryTreeNode root){BinaryTreeNode temp;int max = INT_MIN;LLQueue Q = new LLQueue();Q.enQueue(root);while(!Q.isEmpty()){temp = Q.deQueue();//largest of the three valuesif(max
7 Aug 2013 by OriginalGriff
Do you have any idea how much work explaining code line by line is?Every single line needs a paragraph of explanation! For example: int next = r.Next();Create a new variable called "next" which can hold a integer value. From the previously declared Random instance "r", call...
7 Aug 2013 by Zoltán Zörgő
Since recursion is actually calling a function from itself - it is just putting stuff in the stack. And you can model a stack with an array or a dynamic structure. So you can transform any recursion into a non-recursive algorithm, where your code is doing the stack's functionality. Here is a...
23 Sep 2012 by Jörgen Andersson
How to find the Lowest Common Ancestor in a tree.
4 Jan 2011 by AbnormalCreations
I am currently creating a small 2D game engine for my final year project at university, but when ever i think im going in the right direction i get stuck on things like real time rendering in c#, creating and rendering a BSP tree in c# which I have come to find is a difficult task.So i turn my...
4 Jan 2011 by #realJSOP
Part of being a programmer is being able to analyze the problem, and then design and implement the solution. If you ask someone else what *they* would do, then it becomes that person's solution instead of yours. How are going to learn from doing what someone else would do?Lastly, you should...
4 Jan 2011 by Kythen
RE: #3I think the choice of data structure depends on how you intend to use the game engine. If you're thinking of games along the lines of a space shooter like Defender or Asteroids, then you may want to consider a quadtree for hit detection. If it's something with walls or a maze like...
4 Jan 2011 by Espen Harlinn
#3) I think demonstrating that you know how to use the right structures and algorithms for the various tasks your project has to perform will be fairly important. It's often equally important to show that you have thought your way through this, possibly showing more than one approach and...
12 Jul 2010 by HaNnOuU
Hi everybody.I am doing a project with WPF, it's the first time, so i am not an expert in WPF, and i have some problems with treeView.I am trying to create a treeView from an instance of my class menu. A menu is composed by Items and every Item can have a collection of subItems, which can...