Skip to main content

Questions tagged [binary-search-tree]

The tag has no usage guidance.

1 vote
3 answers
127 views

Maximum Sum BST in a Binary Tree

I was trying to find the Maximum sum BST of a binary tree on LeetCode. While the Java code I have come up with, mostly seems right and is able to pass 55 out of the given 59 test cases too, the error ...
Siddharth Garg's user avatar
2 votes
1 answer
80 views

Sort array of numbers using tree sort - Leetcode 912

Problem statement: Sort integer array nums in O(N log N) time, without relying on any library sort routine. I am trying to use a tree sort method (using the ...
qxzsilver's user avatar
  • 123
4 votes
2 answers
113 views

Delete a node in binary tree

Problem Statement Given a root node reference of a BST and a key, delete the node with the given key in the BST. Return the root node reference (possibly updated) of the BST. Basically, the deletion ...
iskander's user avatar
  • 121
-2 votes
1 answer
56 views

Market Portfolio Binary Search Tree [closed]

I'm trying to solve the following problem here: First line of input contains the number of days D. The next d lines contains a character c and a number x. If c is B, then buy stock . If c is S, then ...
driver's user avatar
  • 232
1 vote
0 answers
60 views

Binary Search Tree Universe

In the world of Binary Search Tree (BST) enthusiasts, where collecting and trading BSTs is a craze, you have a beloved BST with n nodes. In this scenario: (a) Identifying Swapped Nodes and Common ...
driver's user avatar
  • 232
2 votes
2 answers
125 views

Binary search tree with Iterators

One more BST implementation with iterators added. Did not manage to find another implementation with iterators and it is my first attempt at implementing them so thought to check on your opinion: <...
acd's user avatar
  • 107
6 votes
2 answers
1k views

Avoiding memory leaks and using pointers the right way in my binary search tree implementation - C++

I'm learning C++ and I wanted to test my knowledge by implementing a Binary Search Tree using struct (I know, I’m using C++ I should use classes but I want to keep ...
Neptune Luke's user avatar
7 votes
1 answer
1k views

Pet Shelter in C++

The provided code represents an implementation of a Binary Search Tree (BST) in C++, specifically tailored for a "Pet ...
I_throw_but_dont_catch's user avatar
3 votes
1 answer
40 views

Convert sorted list to BST

I am working on a Daily Coding Challenge to convert a sorted singly-linked list into a binary search tree. We are given the head of the list; the definitions of ...
Arya Singh's user avatar
4 votes
1 answer
157 views

Binary Search Tree implementation in C [1]

I have tried to implement my Binary Search Tree in C. The following are the 18 operations defined: create a bst is_empty insert delete clear find find_min find_max height size depth level order ...
V_head's user avatar
  • 525
4 votes
2 answers
152 views

Max Stack implementation in C++ involving iterators

The tricky thing was keeping copies of list iterators in a tree map and managing both together. I'm not handling invalid input cases (like popping an empty stack) in this code. I am following Google C+...
user267704's user avatar
2 votes
2 answers
1k views

C# Binary Search Tree implementation

I have implemented a Binary Search Tree and would really appreciate it if someone could take time to check it and give me feedback. I try to keep my code clear and simple. Is it readable? Is the API ...
Kirill Dolghi's user avatar
2 votes
0 answers
612 views

C++: STL-like AVL Tree (+ benchmark vs. my red-black tree and std::set)

AVL trees and red-black trees are most famous balanced binary search trees. I've always wondered "Why do all major C++ standard library implementations use red-black trees as their ordered ...
frozenca's user avatar
  • 1,703
1 vote
3 answers
183 views

Binary Search Tree that allows for duplicate elements - C++

I've recently made an attempt at creating a binary search tree class that allows for duplicate elements. I've included as many functions as I can think of so that I can use it later on. I've tested ...
Anthony Seager's user avatar
1 vote
1 answer
356 views

Binary Search Tree implementation in C++ with templates

Im implementing a BST using templates and dynamic memory, here is my attempt: This is the BSTNode.hh ...
Norhther's user avatar
  • 269

15 30 50 per page