A binary search tree is a data structure which consists of a root node with left and right child nodes. The left node has a smaller value than its root node, while the right node has a larger value than the root node. The children of the root node follow this same pattern. This gives us a tree ...

learn more… | top users | synonyms (2)

0
votes
1answer
24 views

Binary search tree level order with parent node

Hi I am trying to print out level order of a binary search tree in the format (node element, parent node element). I am currently using queues to get the level order but I am having a hard time ...
0
votes
0answers
12 views

Family of AVL-trees in which a single removeItem operation may require Θ(lg(n)) rotations

I've came across this in a lecture note and I was wondering if someone can help me understand what's being asked - Describe a family of AVL-trees in which a single removeItem operation may ...
0
votes
0answers
20 views

BinarySearchTree Boat Charter record keeping

This is for a Homework assignment For this assignment that I have to do, I have to create a recordkeeping log for a cruise liner for a month (represented by the numbers 1-31). There is 1 cruise a day ...
1
vote
2answers
27 views

Find “nth” value in BST (C)

I have no idea how to go about this problem. returns pointer to NAME_VAL pair which is the nth entry in the sorted sequence. if i=1, you return the min entry if i=n, you return the max entry if ...
0
votes
0answers
32 views

Least Common Ancestor of two node using inorder

I have written the code to find the LCA -- int result = 0; private Boolean lca(Node root, int num1, int num2){ if(root==null){ return false; }else{ if(root.data == ...
0
votes
1answer
46 views

Inserting an element in Binary Tree

Tried exploring a lot over the net, but could get any help, Everywhere its like adding a node to the Binary Search tree. Question: Requesting for algorithm and code snippet for adding a node to the ...
1
vote
2answers
38 views

insertion binary search tree in C

I've been stuck on the insertion part of the binary search tree. I get so confused with nested structs. The basic idea of this program is to create a bst that is able to hold names and double values ...
1
vote
1answer
21 views

Making a template for BST class(different types of keys) in C++

I have written an implementation of BST-Tree but the key can be only string type. I would like to use that tree with other types of keys. I know that I would have to define a template, but do not know ...
0
votes
1answer
30 views

Calculating Max Imbalance of Binary Search Tree

I am currently coding a recursive method to return the max imbalance on the whole of a Binary Search Tree. I've very new to recursive programming so it's quite difficult to wrap my head around. The ...
1
vote
1answer
25 views

Dealing with “Keys” in Binary Search Trees

Should I always, use some data as a key value while dealing with the Binary Search trees? I'm asking this becasue I would need key at some point of time if I want to search an element in the tree. Is ...
0
votes
1answer
34 views

Errors with Implementing Breadth First Search (C)

I have been working on a Binary Search Tree and several of its function implementations for a school assignment. I just wrote my Breadth First Search functions and I am getting a segmentation fault in ...
-4
votes
0answers
29 views

Binary Search Tree Sum Function returning memory address

I have a binary search tree written in C. Its an avltree. You run it and start entering integer values. I have created functions within the avltree to find height, element, Min, Max...... When I tried ...
1
vote
1answer
25 views

Infix, prefix or postfix order trough BST to get descending order of printed elements

I know that if we print the BST in the infix order i will get ascending order of elements the tree contains. How to get descending order? Using postfix or prefix?
0
votes
1answer
34 views

Clearing a binary search tree

I came across this method to clear a binary search tree. The code is given in a textbook. Why must a node temp be created and deleted in the end? Why not delete the subroot instead of making it null? ...
0
votes
1answer
39 views

Implementing Delete a Node in Binary Search Tree

Trying to delete a node from BST. After the execution, the node still persists in the tree. How can I implement it properly? public void deleteNode(TreeNode removeNode, TreeNode root) { ...
0
votes
1answer
22 views

Recursive Search in BST [closed]

TreeNode search(int value, TreeNode root) { if(root.data==value) { return root; } else if(root.data < value) { search(value, root.Right); } else if ...
0
votes
1answer
53 views

non recursive destructor binary search tree USING A STACK

I was thinking of making a non recursive destructor using a stack of binary node pointers. Would this code run? binaryNode* parent = root; while (!empty()) { if (parent->left) { ...
0
votes
2answers
43 views

binary search tree of 20 elements

So this code for creating searching and removing nodes to a BST works great but only if it is of size nine how do i make it be of size 20 when i change the SIZE to 20 the programs does not go past ...
0
votes
1answer
37 views

Where to implement a stack class (to be used in a non recursive binary search function)

First of all, this sure is my homework but I will not be asking for code. Inside a BST.h file, I implemented all the private members, functions and public functions. However, I am finding trouble ...
5
votes
1answer
65 views

What's the difference between `ImmutableSortedSet` and fsharp `Set`?

BCL has introduced a group of Immutable Collections I am wondering what's the difference between ImmutableSortedSet and the native FSharp Set? It seems that the performance signatures of both are ...
0
votes
0answers
40 views

Binary Tree Search - delete a node without child

I have a binary tree search, and i try to remove it's biggest number in this tree. But it has crash while I delete a node without child. Totally don't know why. Here is my code.Please help me figure ...
0
votes
0answers
23 views

Seg-Fault at BST remove() Function

Basically the program consists of a BST class that points to the first node of a Binary Tree, and the Nodes are also their own class. The BST calls this member function: void remove(const T& x) ...
2
votes
1answer
33 views

Lisp Program producing contract violation

I wrote a lisp program that takes two parameters, a destination, and a map in the form of a BST. It searchings the BST for the destination number, and prints (found: path) if the destination is found. ...
0
votes
3answers
51 views

Test if two binary search trees has the same set of elements?

I am just starting out with java and recursive methods and i need some help: I need to determine if two Binary Search Trees has exactly the same set of elements, regardless of the structure of the ...
0
votes
2answers
42 views

Not recognizing cout<< in my program?

I'm creating a program with multiple files and it's not recognizing cout<< in my tnode file. Can anyone locate where the problem is? Among other errors, I get this error "cout was not declared ...
2
votes
2answers
82 views

Finding elements in a BST that sum up to a provided value

I'm trying to get an approach to solve the problem Find two elements in balanced BST which sums to a given a value. Constraints Time O(n) and space O(logn). I was wondering whether the following ...
0
votes
3answers
45 views

Turning a Binary Tree to a sorted array

Is there a way to turn a Binary to a sorted array without having to traverse the tree for every array index? Node root; Node runner; int current_smallest; void findsmallest(Node root){ ...
1
vote
1answer
36 views

Searching through BST in Lisp

I'm writing a program that directs a robot down a BST to the goal number. The program has two input parameters, a destination as an integer, and a map that represents all the paths the robot can ...
-2
votes
1answer
57 views

Binary Search Tree - What is the difference between Value and Key?

I'm confused on what the difference is between a Key and a Value in a BinarySearchTree Node is. What is the point of a Key? Can't you base the BST off of a value alone? Here are two code samples that ...
1
vote
1answer
110 views

Python — Morse Code Translation through a binary tree

I'm writing a program that will create a binary tree of the Morse Code alphabet (as well as a period and an apostrophe), and which will then read a line of Morse Code and translate it into English. ...

1 2 3 4 5 24
15 30 50 per page