binary-search-tree Questions

8

Solved

I have been asked in an interviews to print the boundary of the Binary Tree. For example. 1 / \ 2 3 / \ / \ 4 5 6 7 / \ \ 8 9 10 Answer will be : 1, 2, 4, 8, 9, 10, 7, 3 I have given the ...

5

I can see how, when looking up a value in a BST we leave half the tree everytime we compare a node with the value we are looking for. However I fail to see why the time complexity is O(log(n)). So...
Embosom asked 20/1, 2013 at 16:52

1

Solved

There is a plenty of solutions how to find closest lower and upper keys in binary tree in imperative languages, but a lack of same questions for doing it in purely functional style like that of Has...
Lancey asked 14/12, 2019 at 15:44

3

Solved

I'm reading Cormen et al., Introduction to Algorithms (3rd ed.) (PDF), section 15.4 on optimal binary search trees, but am having some trouble implementing the pseudocode for the optimal_bst functi...
Skulduggery asked 11/9, 2017 at 17:9

4

Solved

Given an array of integers, is there a way to convert it into Binary Search Tree (unbalanced) quickly? I have tried inserting it one by one for each element, but this means that I have to traverse ...
Horrorstruck asked 23/4, 2016 at 5:16

11

Solved

If the pre-order traversal of a binary search tree is 6, 2, 1, 4, 3, 7, 10, 9, 11, how to get the post-order traversal?
Elisabeth asked 27/12, 2010 at 10:13

2

Suppose we have a binary search tree of depth $n$, where every level is full, we know in advance how big the tree will be, and we will run the find(value) function a lot. The values(integers)...
Scratchy asked 10/6, 2019 at 5:54

2

I am trying to figure out the fastest way to perform search and sort on a pandas dataframe. Below are before and after dataframes of what I am trying to accomplish. Before: flightTo flightFrom to...
Threaten asked 28/5, 2019 at 14:7

2

Solved

I enjoy reading engaging book "Programming in Haskell" (Second Edition) by Graham Hutton. In Chapter "8 Declaring Types and classes", section "8.4 Recursive types", page 97 bottom I find definition...
Corwin asked 30/4, 2019 at 4:26

6

Solved

I'm struggling with the concept of when to use binary search trees and when to use dictionaries. In my application I did a little experiment which used the C5 library TreeDictionary (which I belie...
Maisiemaison asked 28/1, 2010 at 1:46

10

Solved

Given a bst with integer values as keys how do I find the closest node to that key in a bst ? The BST is represented using a object of nodes (Java). Closest will be for eg 4,5,9 and if the key is 6...
Bassarisk asked 2/6, 2011 at 0:50

4

Solved

I'm trying to solve this problem but I'm having some troubles: In a binary search tree (BST): The data value of every node in a node's left subtree is less than the data value of that node....
Rabbi asked 2/12, 2017 at 15:55

3

I'm trying to implement a binary search tree in Rust and I am running into problems with inserting an element. What is an idiomatic way of doing this in Rust? Here is my implementation: use std::...
Abracadabra asked 26/6, 2016 at 21:30

17

Solved

I'm looking for some examples of tree structures that are used in commercial/free software projects, modern or old. I can see examples on wikipedia, but I am looking for more concrete examples and ...
Constringe asked 23/2, 2009 at 13:37

5

Solved

I've bumped into this question at one of Coursera algorithms course and realized that I have no idea how to do that. But still, I have some thoughts about it. The first thing that comes into my min...

4

Solved

When implementing a Hashtable using an array, we inherit the constant time indexing of the array. What are the reasons for implementing a Hashtable with a Binary Search Tree since it offers search ...
Clothespin asked 10/4, 2014 at 18:46

3

Solved

Given a BST tree, we have to break the tree depending on the input(N), into two subtrees, where subtree1 consists of all the nodes, which are less than or equal to N and subtree2 consists of all th...
Myxoma asked 3/5, 2017 at 6:45

2

Solved

Given a set of values, it's possible for there to be many different possible binary search trees that can be formed from those values. For example, for the values 1, 2, and 3, there are five BSTs w...

7

Solved

I am trying to flatten a binary search tree to a singly linked list. Binary search tree: 6 / \ 4 8 / \ \ 1 5 11 / 10 Flattened Singly Linked List: 1 -> 4 -> 5 -> 6 -> 8 -&...
Acedia asked 11/4, 2013 at 2:10

8

Solved

How to delete a node with 2 children nodes in a binary tree? Is there any kind of method to remove it? I googled it. But didn't get clear idea about it. Anybody explain it with diagrammatic repres...
Yesseniayester asked 28/11, 2011 at 7:31

2

Solved

So, I'm trying to implement a Data Structure to handle Dynamic Order Statistic. The Data Structure has following operations: add(x): inserts a new element with value x get(k): returns the k-th sm...
Peipeiffer asked 6/1, 2018 at 16:30

2

Solved

I'm trying to use GNU libavl (http://adtinfo.org/) for one of my academic projects. I need a simple enough tutorial on how to use the BST(Binary search tree) implementation provided by the library....
De asked 3/3, 2014 at 7:21

2

Solved

A heap can be constructed from a list in O(n logn) time, because inserting an element into a heap takes O(logn) time and there are n elements. Similarly, a binary search tree can be constructed fr...
Dave asked 25/12, 2017 at 20:26

6

Solved

Why is std::map implemented as a red-black tree? There are several balanced binary search trees (BSTs) out there. What were design trade-offs in choosing a red-black tree?
Collimator asked 13/3, 2011 at 8:33

4

How to find varchar-word that has the most similar beginning of the specified word in MySQL database? For example: +-------------------+ | word_column | +-------------------+ | StackOferflow | |...
Lorenalorene asked 22/10, 2017 at 9:55

© 2022 - 2024 — McMap. All rights reserved.