Questions tagged [binary-tree]
The binary-tree tag has no summary.
55 questions
1
vote
0
answers
146
views
Ideal Profits in companies in Perfect Binary Search tree
I'm trying to solve the following problems here:
In the X world, companies have a hierarchical structure to form a large binary tree network (can be assumed to be a perfect binary tree). Thus every ...
3
votes
2
answers
1k
views
Is the TreeSet class in java a Red Black Binary Search Tree?
I simply wanted to know if the internal implementation of the TreeSet class in java is Red Black Binary Search Tree. Ideally, I would think that it is a threaded RB-BST, since it supports iteration ...
-2
votes
1
answer
691
views
Optimal Data Structure for Searching though String
I am current developing a karaoke app in JavaFX, I need advise on the most optimal data structure storing a huge list of songs (library). I am inclined to use Binary Search Trees due to its Big O ...
1
vote
1
answer
227
views
Does a Self-Balancing Self-Sorting Binary Search Tree exist?
When we are inserting into a self-balancing tree, can we also assume it is sorting itself using those same operations? Or rather is there a traversal method that gets us the elements as a sorted list?
0
votes
2
answers
4k
views
How to represent a directory structure in a binary tree?
I was just thinking about implementing a binary tree with its root pointing to the parent folder and then the children pointing to subdirs nested within to store a directory structure in a binary tree....
1
vote
3
answers
1k
views
Which data structure is best for an auto complete drop down that learns?
I made an auto complete text box for an application I'm working on. The text box basically has an associated list that it searches each time you enter something in the box.
If you enter something ...
3
votes
2
answers
1k
views
Deleting a node and returning the deleted node's value in a Binary Search Tree?
Hi I have a programming project where I'm basically using a Binary Search Tree to implement a min/max priority queue. I'm having trouble with the popMin/popMax methods. I get how to get the minimum/...
2
votes
2
answers
3k
views
Can Two Binary Search Trees Have the Same Values but Different Structures?
Define a BST as: all left descendants <= n < all right descendants.
Then is it possible to build two binary search trees with different structures but the same exact values? Duplicate values ...
1
vote
1
answer
523
views
reordering sorted array to level-order array without queue
I have very large sorted array, stored on the disk.
I can random access any element.
I want to make it level-ordered in order to speed up binary search there. The idea is borrowed from:
http://...
1
vote
1
answer
91
views
How do you achieve the 'BST Property' in a Template Binary Search Tree?
We recently started learning about binary search trees. We created one of our own using integers as our Key/Data. It's easy to achieve the BST property using an int key, but what happens when we ...
1
vote
1
answer
135
views
Joining binary trees
Suppose we have a set of binary trees with their inorder and preorder traversals given and where no tree is a subtree of another tree in the given set.
Now another binary tree Q is given.
Find ...
0
votes
2
answers
2k
views
Keeping track of the number of nodes in the subtree in black and red trees
I was wondering, if I have a black and red tree and I want to keep track of the number of nodes in the subtree, what is the most effective way to do so?
I mean how do I work with these values while ...
2
votes
1
answer
88
views
Efficiently determining many-to-many subset relation
I'm doing market basket analysis. I have a set of transactions. Every transaction is a set of items that were bought. I then have a set of itemsets (i.e. a set of items) that I want to determine the ...
0
votes
1
answer
1k
views
Merging Two Binary Search Trees
What time in terms of Big O will it take to merge two BST's in One?
Each having no of nodes n and height O(log n) with no common element.
Resultant should be also a BST
0
votes
1
answer
2k
views
How do binary trees use memory to store its data?
So I know that arrays use a block on contiguous memory addresses to store data to memory, and lists make use of static arrays and when data is appended to the list, if there is no room, a new static ...
0
votes
2
answers
2k
views
Efficiently find whether Binary Search Tree is Height Balanced or not?
A binary tree is height balanced if and only if the two subtrees of root are height balanced and the difference between the two subtrees height is at most 1.
I implemented a code in java to find ...
2
votes
1
answer
2k
views
Difference between sibling lists, left-child right-sibling binary tree and doubly-chained tree
The Wikipedia page for suffix trees descibes sibling lists as
Each node has a pointer to its first child, and to the next node in the child list it is a part of.
Wikipedia describes left-child right-...
1
vote
1
answer
2k
views
In which of the following tree traversal all the child nodes are visited first before the parent node [closed]
In an n-ary tree...
Given a reference to some child node
And a reference to a distant parent of the referenced child node
Is there a method that a parent node can use to figure out which of its ...
2
votes
2
answers
363
views
Is there a known standard data structure which is a hash table that resolves collisions using a binary tree?
Is there a known standard data structure which is a hash table that resolves collisions using a binary tree?
If so what is the name of this data structure?
I imagine such a structure would be useful ...
0
votes
3
answers
2k
views
Print bottom view of a binary tree
For a binary tree we define horizontal distance as follows:
Horizontal distance(hd) of root = 0
If you go left then hd = hd(of its parent)-1, and
if you go right then hd = hd(of its ...
22
votes
4
answers
44k
views
Is Pre-Order traversal same as Depth First Search?
It seems to me like pre-order traversal and DFS are same as in both the cases we traverse from root till the left branch and back to root and then to the right branch recursively. Could any please ...
0
votes
1
answer
6k
views
Convert Algebraic Expression directly into Binary Tree Structure (sans prefix / postfix)
I am looking all over internet to find a logic to convert an Algebraic Expression into a Binary Tree.
I could only find ones where you first convert the algebra expression to postfix or prefix and ...
13
votes
3
answers
26k
views
Usefulness of pre and post order traversal of binary trees
This may be very naive, but I was wondering, it the context of binary trees (plain, sorted and balanced), of all the traversal types:
depth-first pre-order
depth-first in-order
depth-first post-order
...
6
votes
1
answer
6k
views
What is the usage of Splay Trees in the real world?
I decided to learn about balanced search trees, so I picked 2-3-4 and splay trees.
What are the examples of splay trees usage in the real world?
In this Cornell: http://www.cs.cornell.edu/courses/...
-1
votes
1
answer
1k
views
How should I setup a UI for editing a binary tree? [closed]
I need to allow the user to create an binary tree. I have a Backbone Model populating properly from the database, the problem I am stuck on is how do I setup the ui elements in a way that is fairly ...