binary-search-tree Questions

3

Solved

The third paragraph of wikipedia's article on AVL trees says: "Because AVL trees are more rigidly balanced, they are faster than red-black trees for lookup-intensive applications." So, shouldn't T...

1

Solved

I am working on a project that rewards people base on referrals (MLM) I have been able to count the total number of child nodes on both left and right side but now I need to be able to update the ...
Nihility asked 21/9, 2017 at 15:7

2

Solved

What is the time complexity of applying the next() and prev() function on an multiset<int>::iterator type object where the corresponding multiset contains the N elements? I understand that i...
Misvalue asked 8/9, 2017 at 14:56

2

Solved

I have implemented a binary search tree in c++. Instead of using bare pointers to point to a nodes children I used the std::shared_ptr. The nodes of the tree are implemented as follows struct tree...
Scoundrel asked 12/8, 2017 at 14:32

4

Given an array of integers arr = [5, 6, 1]. When we construct a BST with this input in the same order, we will have "5" as root, "6" as the right child and "1" as left child. Now if our input is c...
Apparently asked 9/11, 2009 at 15:7

4

I know this is a common question and I saw a few threads in Stack Overflow but still couldn't get it. Here is an accepted answer from Stack overflow: " Disk seeks are expensive. B-Tree structu...

1

I'm implementing an algorithm to do directory matching. So I'm given a set of valid paths that can include wildcards (denoted by "X"). Then when I pass in an input I need to know if that input matc...

1

I have a homework assignment that reads as follows (don't flame/worry, I am not asking you to do my homework): Write a program that sorts a set of numbers by using the Quick Sort method using a bi...
Izzard asked 21/8, 2013 at 9:31

0

I need to define a binary search tree where each node has access to the parent: enum Tree<'a> { Leaf, Node { left: Box<Tree<'a>>, right: Box<Tree<'a>>, par...
Trillium asked 14/7, 2017 at 17:16

2

Solved

I am very confused by a number of articles at different sites regarding constructing a Binary Search Tree from any one traversal (pre,post or in-order), or a combination of any two of them. For exa...
Ophiolatry asked 14/10, 2012 at 8:59

2

Solved

For each of these operations would a balanced binary search tree complete the task in a faster big oh time than a balanced binary tree? Finding the smallest item in the tree. I think balanced B...
Squamous asked 30/3, 2017 at 4:17

6

Solved

I use the following method to traverse* a binary tree of 300 000 levels: Node* find(int v){ if(value==v) return this; else if(right && value<v) return right->find(v); else if(l...

2

class BinaryNode: def __init__(self, value): self.data = value self.left = None self.right = None def contains(root, value): if root is None: return False if value == root.data: return Tr...
Preoccupied asked 23/3, 2017 at 10:0

2

Solved

I'm learning about B+ trees in a class about databases and I was wondering what concrete advantages B+ trees would give over Binary Search Trees? It seems like they both have O(logN) average comp...
Animator asked 18/3, 2013 at 19:26

5

Solved

I'm prepearing for tech interview, so basically learning algorithms from very beginning :) we are given a BST. I need to find the max length of a desc path in it, which always goes left or right In...
Dulcie asked 18/8, 2013 at 13:45

3

Solved

If each node in a binary search tree stores its weight (number of nodes in its subtree), what would be an efficient method to compute a rank of a given node (its index in the sorted list) as I sear...
Oloughlin asked 28/9, 2014 at 1:58

2

Solved

I have got a question, and it says "calculate the tight time complexity for the process of inserting n numbers into a binary search tree". It does not denote whether this is a balanced tree or not....

3

Solved

Given a binary search tree (BST) of height h, it would take O(k+h) time to apply the BST InOrder Successor algorithm k times in succession, starting in any node, applying each next call on the node...
Bluefarb asked 12/11, 2016 at 9:0

5

I recently finished implementing a Binary search tree for a project I was working on. It went well and I learned a lot. However, now I need to implement a regular Binary Tree... which for some reas...
Kandykane asked 19/5, 2013 at 2:14

4

Consider the deletion procedure on a BST, when the node to delete has two children. Let's say i always replace it with the node holding the minimum key in its right subtree. The question is: is th...
Unbelievable asked 7/6, 2010 at 14:46

1

Solved

I'm currently implementing an algorithm in which I need to know how many numbers, from the ones that have already been read, are smaller than the one that's currently being processed. A way to do ...
Hedger asked 16/8, 2016 at 21:59

4

Solved

I am not good at programmatically implementing a heuristic search algorithm / Dijkstra's algorithm/ A* search algorithm mentioned. However, while solving a problem mentioned in one of my post (Matr...
Cochrane asked 1/8, 2016 at 11:18

10

I would like to calculate the summation of the depths of each node of a Binary Search Tree. The individual depths of the elements are not already stored.
Magnum asked 9/12, 2009 at 19:32

2

Solved

Why is the average case time complexity of tree sort O(n log n)? From Wikipedia: Adding one item to a binary search tree is on average an O(log n) process (in big O notation), so adding n item...

3

Grid Walking (Score 50 points): You are situated in an N dimensional grid at position (x_1,x2,...,x_N). The dimensions of the grid are (D_1,D_2,...D_N). In one step, you can walk one step ahead or ...

© 2022 - 2024 — McMap. All rights reserved.