binary-search-tree Questions
9
Given a BST, find all sequences of nodes starting from root that will essentially give the same binary search tree.
Given a bst, say
3
/ \
1 5
the answer should be 3,1,5 and 3,5,1.
another e...
Brace asked 19/1, 2014 at 0:29
1
Solved
I'm watching university lectures on algorithms and it seems so many of them rely almost entirely binary search trees of some particular sort for querying/database/search tasks.
I don't understand t...
Goles asked 19/6, 2021 at 1:59
4
Solved
I don't have much experience with recursion, so I'm having a hard time determining exactly how this algorithm works:
public static void inorder(Node<?> n)
{
if (n != null)
{
inorder(n.g...
Credit asked 19/5, 2014 at 18:40
1
Solved
I've found a nice implementation of printing the BST
here from BcK. I wanted to implement it into my code, but I don't really know what parameters' name I should change so it could work in my code....
Rinee asked 14/5, 2021 at 6:57
4
Solved
Imagine I have a big sorted list of integers (>1000 items). I need to be able to do two operations on this list: remove the lower half and fill the list again to its original size by inserting rand...
Rebarbative asked 31/3, 2016 at 10:44
4
Solved
I came across this problem online and I found the following function to check if a BST is valid. However, what I don't fully understand is how max/min change from null to values that you can compar...
Caspian asked 2/12, 2015 at 14:13
3
Solved
How i get the PreOrder,InOrder,PostOrder to work?
Here are my current code and implementation, see InOrder(),PreOrder(),PostOrder(). I have a reference from Geek4Geek (https://www.geeksforgeeks.or...
Slambang asked 20/3, 2021 at 8:35
5
Solved
So I want to find the parent node of a Node in a binary tree.
Suppose that I input 30,15,17,45,69,80,7 in the tree through a text file.
The tree should be
30
15 45
7 17 69
80
And here is m...
Muddler asked 9/6, 2015 at 15:32
11
I went to an interview today where I was asked to serialize a binary tree. I implemented an array-based approach where the children of node i (numbering in level-order traversal) were at the 2*i in...
Experimentalize asked 6/1, 2011 at 3:48
3
Solved
Let's say I have a std::map<int, std::string> myMap containing the data
1. Red
2. Blue
3. Green
5. Fuchsia
6. Mauve
9. Gamboge
10. Vermillion
and also an std::map<int, std::string>::it...
Underscore asked 2/3, 2021 at 23:40
2
Solved
this is a possible way to implement add and delete functions for a BST in Python. It somewhat resembles my ideas of BST in C++. As evident by the code for deleting, I want to delete a node, which I...
Kayleigh asked 21/2, 2021 at 16:34
3
Solved
One of the answers in our powerpoint says it is n/2 leaves, but I am seeing another answer which says (n+1)/2. I was wondering which one is correct if any, and why?
Newfeld asked 8/11, 2014 at 23:50
6
I have made a function for insertion in BST using loops and it is working perfectly fine.
Now, when iam writing to do it using recursion i don't know why it's not working properly, however the logi...
Ioneionesco asked 18/11, 2011 at 14:28
18
Solved
What are the advantages of binary search trees over hash tables?
Hash tables can look up any element in Theta(1) time and it is just as easy to add an element....but I'm not sure of the advantages...
Germicide asked 8/11, 2010 at 22:6
6
Solved
I am trying to implement a remove method for the BST structure that I have been working on. Here is the code with find, insert, and remove methods:
public class BST {
BSTNode root = new BSTNode("...
Hearing asked 9/11, 2013 at 0:6
15
Solved
This is an interview question. Find the second max in BST.
The max element is the rightmost leaf in the BST. The second max is either its parent or its left child. So the solution is to traverse t...
Brutality asked 11/7, 2012 at 4:3
3
Solved
I am currently checking about coding an algorithms. If we have the following case:
Given a sorted (increasing order) array with unique integer elements, wrote an algorithm to create a binary searc...
Presume asked 1/7, 2017 at 11:43
5
Solved
I know there are ways to construct a tree from pre-order traversal (as an array). The more common question is to construct it, given the inorder and pre-order traversals. In this case, although the...
Jamnes asked 31/10, 2012 at 21:15
8
Solved
I am trying to understand BSTs and how to insert elements into it iteratively. My node structure implementation looks like so:
struct Node{
Node *left;
Node *right;
T data; //template class
};...
Edmondo asked 12/11, 2013 at 19:16
11
Solved
How to convert a binary tree to binary search tree in-place, i.e., we cannot use any extra space.
Persnickety asked 5/4, 2010 at 5:46
4
Solved
I learnt implementing inorder traversal of a binary search tree:
def inorder(root): # root has val, left and right fields
if root==None:
return
inorder(root.left)
print(root.val)
inorder(roo...
Hombre asked 2/3, 2018 at 5:52
18
Solved
This is what I've got so far but it is not working:
class Node:
rChild,lChild,data = None,None,None
def __init__(self,key):
self.rChild = None
self.lChild = None
self.data = key
class Tree:...
Anemophilous asked 26/3, 2011 at 18:37
1
Solved
I've heard of a new balanced BST data structure called a zip tree. What is the zip tree? How does it work?
Headphone asked 21/5, 2020 at 21:33
4
Solved
What is the difference between binary search and binary search tree?
Are they the same? Reading the internet it seems the second is only for trees (up to 2 children nodes) and binary search doesn'...
Healion asked 5/2, 2014 at 18:57
1
Solved
I was reading this answer
Efficient (and well explained) implementation of a Quadtree for 2D collision detection
and encountered this paragraph
All right, so actually quadtrees are not my favo...
Quade asked 17/1, 2020 at 22:20
© 2022 - 2024 — McMap. All rights reserved.