Skip to main content
Filter by
Sorted by
Tagged with
0 votes
1 answer
168 views

Table has index on name column: CREATE TABLE firma2.klient ( kood character(12) primary key, nimi character(100), ... ); CREATE INDEX IF NOT EXISTS ...
Andrus's user avatar
  • 28.2k
5 votes
3 answers
225 views

I implemented a recursive solution in Python to check if two binary trees are identical, which traverses nodes recursively and compares values and structure. The time complexity is O(n), space O(h). ...
Jared McCarthy's user avatar
0 votes
0 answers
42 views

I'm doing a programming assignment for my class. One of my programs includes creating a BST with Python within a BST class, and I'm trying to display using preorder() and inorder() functions. My ...
selena's user avatar
  • 1
6 votes
2 answers
257 views

I understand that container::lower_bound harness helpful invariant of the very container hence gives a better performance than std::lower_bound. Taking std::set::lower_bound as an example, during my ...
PkDrew's user avatar
  • 2,301
1 vote
1 answer
111 views

I'm trying to implement an algorithm for insertion into BST (binary search tree) in Rust. I did it recursively, but am having problems implementing the iterative solution. I'm struggling to borrow a ...
Robert Kusznier's user avatar
-1 votes
1 answer
73 views

I am struggling to understand the recursion going on in the insert, _insert_recursive and _inroder_traversal methods. For context, I know recursion and the concept is not strange to me, I struggle to ...
kmmensah's user avatar
0 votes
1 answer
83 views

Hello I basically need to implement a recursive function for insertion of a binary tree. I already implemented the chunk of insertion function (wether it's largest or smaller than root) but there's an ...
Cool Dude's user avatar
3 votes
1 answer
766 views

I'm having trouble implementing a threaded Binary Search Tree in C++. I have a non-threaded tree completely implemented (see below code). What I'm having difficulty with is setting the threads to ...
Boom's user avatar
  • 514
0 votes
0 answers
62 views

Explanation I'm attempting to implement a binary search tree in Rust. The problem is in the insert method, where I have a &mut Box<Node<T>> called node_to_insert_at. To insert the ...
firewuf's user avatar
  • 23
0 votes
2 answers
116 views

I'm having two issues with my code; I'd post them as two separate questions, but I believe one is causing the other. The first involves insertion; from my amateur eyes, the insert code seems to be ...
SuperDoom1 Unrevealed's user avatar
2 votes
2 answers
100 views

I've implemented a red-black tree (which is a kind of self-balancing binary search trees) with duplicated keys allowed. In the Insert method I put nodes with equal keys as right child nodes. As you ...
Maxim's user avatar
  • 2,164
0 votes
0 answers
33 views

I am working on optimizing the Delete-Max operation in an unbalanced Binary Search Tree (BST) where frequent max deletions occur. The current approach follows: Traverse to the rightmost node. Remove ...
Oshani Kaveesha's user avatar
1 vote
1 answer
66 views

I am practicing Maximum difference between node and its ancestor Java problem using my own solution which worked fine for smaller test cases. However, this is giving differnt output than expected for ...
SEJAL PITHADIA's user avatar
2 votes
1 answer
226 views

I'm trying to find a solution for this challenge: Given is n, which is the size of an array filled with ones. There are two types of operations possible on this array: Increase (x, y, m): add m to ...
Donald's user avatar
  • 31
0 votes
1 answer
109 views

I was just starting out with dynamic programming and tried solving factorial problem using the same, i used binary tree for underlying data structure, but when i thought of comparing it with normal ...
Vishwas MIshra's user avatar
1 vote
0 answers
43 views

I build my tree in main with a for loop adding nodes 1-15, removing say 5 or 15 work fine, i think my problem lies in removing the root. It wont follow pre-order when I call it after removing 1, i ...
Declan Mitchell's user avatar
0 votes
0 answers
40 views

Some hidden test cases fail to output correctly. I've tested for all edge cases I can think of; what am I missing? Edge Cases Tested: Nonexistent Key Deletion: Assumes input is valid per the problem ...
Hyungwon Shim's user avatar
0 votes
1 answer
74 views

So for this class here, I have to write out functions, including a recursive find function, an insert function, and a operator[] function, which overall helps insert into a BST #include <compare>...
Cevapi Man69's user avatar
1 vote
0 answers
61 views

I'm making a modified Queue struct template using AVL tree to allow for moving elements forward. If I use normal linked list implementation, moving a given element forward by x positions will cos O(n),...
Marek Pospíšil's user avatar
3 votes
4 answers
297 views

Can a recursion with nested calls in tail position be tail recursion? For example, I have the following function in Racket that is intended to convert a binary tree, defined as a nested struct below, ...
Argyll's user avatar
  • 10.1k
3 votes
1 answer
150 views

I was doing an exercise to convert a sorted array to a binary search tree where every node in the tree has its children whose heights at most differ by 1. One simple solution is to pick out the middle ...
Argyll's user avatar
  • 10.1k
0 votes
1 answer
39 views

I have recently begun studying the structure of the red-black tree and am struggling to determine whether it is balanced. And explain why it is still balanced, or vice versa. ...
RezDom's user avatar
  • 3
2 votes
1 answer
172 views

I'm trying to understand the rules for finding the inorder predecessor of a node in a binary search tree (BST). If a node 𝑥 has a left subtree, the inorder predecessor is the largest value in that ...
Aslam Sha's user avatar
1 vote
1 answer
188 views

In a Binary Search Tree (BST), I am trying to understand the properties of the inorder predecessor, particularly for nodes that have a left subtree. Definition: The inorder predecessor of a node is ...
Aslam Sha's user avatar
-1 votes
1 answer
145 views

I am trying to build a binary tree with a array. I want to take the array, find the root and split right and left side, then perform the same split on each side if needed until two numbers are left ...
Jermain Singleton's user avatar
0 votes
1 answer
56 views

I've been reading up on AA-Trees. One of their invariants is that every non-leaf node has two children. How can that work whenever the total element count happens to not be one less than a power of ...
CTMacUser's user avatar
  • 2,082
0 votes
0 answers
105 views

I don't think this is standard terminology, but we will define a "disjoint segment tree" as a segment tree (a flavor of binary search tree) whose values are pairwise-separated intervals (a,b)...
Brendan Langfield's user avatar
3 votes
1 answer
133 views

It's not quite obvious to me why the algorithm (see below) to delete a node from a binary search tree, that CLRS offers, works correctly (like how do we know that the inorder arrangement of the nodes ...
Vacation Due 20000's user avatar
0 votes
1 answer
100 views

In the original "Balanced Search Trees Made Simple" paper by Arne Andersson, the first paragraph of the second chapter mentions that a single bit could be the flag before introducing the ...
CTMacUser's user avatar
  • 2,082
1 vote
0 answers
59 views

I'm currently working on the odin project on Binary Search Tree. I'm trying to make deleteNode work, and I'm working on removing a node if it is a leaf node. Here's my code: class Node { ...
Andrey's user avatar
  • 13
2 votes
1 answer
115 views

I wanted to get a sanity check here. I believe the algorithm listed on the wikipedia page for the Day–Stout–Warren algorithm for balancing BSTs has a problem. This pseudocode purports to turn a BST ...
Paul C's user avatar
  • 8,439
2 votes
1 answer
114 views

I'm working on formally proving that it's impossible to convert a Min Heap into a BST in O(n) time complexity. My reasoning is that any algorithm attempting this conversion would need to perform ...
Re'em's user avatar
  • 23
-1 votes
1 answer
88 views

In the following insert method for a binary search tree (BST), the left side of the tree is being updated correctly, but there is an issue with inserting values on the right side. Despite using the ...
Ezana's user avatar
  • 11
1 vote
1 answer
86 views

I want an ordered index-able data structure like a python list, which can access, update, insert and delete at arbitrary indices efficiently. I have modified a skip list and an AVL tree to do the ...
Gursimar Miglani's user avatar
0 votes
0 answers
27 views

package main; import java.io.*; import java.util.*; public class IsBSTTree { Set<Integer> set = new HashSet<>(); public static void main(String[] args) throws IOException {...
Yaduska Thambiaiyah's user avatar
1 vote
1 answer
40 views

I am looking at solutions of LeetCode problem 108. Convert Sorted Array to Binary Search Tree: Given an integer array nums where the elements are sorted in ascending order, convert it to a height-...
Daniel Chiu's user avatar
-2 votes
1 answer
123 views

I have implemented a Morris traversal to solve LeetCode problem 98. Validate Binary Search Tree: Given the root of a binary tree, determine if it is a valid binary search tree (BST). My code /** * ...
RISHI MISHRA's user avatar
0 votes
1 answer
115 views

I'm trying to write a Scheme program that performs an in-order traversal of a binary search tree: (define (inorder lst) (cond ((null? lst) '()) ((not (pair? lst)) (list lst)) ...
Dave Filoni's user avatar
1 vote
1 answer
86 views

Binary search trees (BST) are helpful to perform CRUD operations efficiently. Do we need to implement a BST in a programming language when storing data in a database? For example, consider Django + ...
anoop george's user avatar
0 votes
5 answers
182 views

TreeNode* searchBST(TreeNode* root, int val) { if(root==nullptr)return nullptr; if(root->val==val)return root; if(root->val<val)return searchBST(root->right,val); ...
user25359626's user avatar
1 vote
1 answer
123 views

I'm doing some leetcode practice https://leetcode.com/problems/design-hashmap/description/ trying to implement a hashmap in C++ using a binary search tree as the underlying data structure. I'm passing ...
WKGuy's user avatar
  • 129
0 votes
1 answer
59 views

void inorderPredecessor(Node* root, Node* &pre,int key){ if(root == NULL ) return ; if(root -> data == key){ inorderPredecessor(root ->left , pre , key); }else if(root -&...
abhinav550's user avatar
1 vote
1 answer
196 views

I am trying to figure out how to search a BST via a given input. The nodes in the tree have a randomly generated number as the key, and the value of the node is an object with various attributes. ...
rgs's user avatar
  • 21
2 votes
1 answer
87 views

I have two algorithms to build an implicity from an array, one is continuously merging Like so: public Node nlognConvertToTreap(int[] arr){ Node node = Node.EMPTY_NODE; for (int x : arr) node =...
Vihari Vemuri's user avatar
1 vote
0 answers
80 views

input The first line of the input file contains an integer number N -- the number of pairs you should build cartesian tree out of (1 ≤ N ≤ 50 000). The following N lines contain two numbers each -- ...
user25334687's user avatar
0 votes
1 answer
52 views

I'm struggling getting my Delete function to work for my BST class, I mostly understand the idea behind but can't quite get the implementation right. Here in DataStructures.py I have a class for the ...
Nick H's user avatar
  • 1
0 votes
0 answers
52 views

I need to convert binary search tree to max heap in java. As I did like this, public static void inOrderTraversal(Node node, Vector<Node> vec) { if(node == null) { return ; } ...
Sadhna Juhirdeen's user avatar
1 vote
1 answer
73 views

I am new to c, but for a project I am implementing a binary tree. here is my code for the functions: #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct ...
The-coder-E's user avatar
0 votes
0 answers
91 views

I was in the middle of building an AVL Tree until this odd thing happened. When I comment this printf() on line 81, my resulting balance factor shows a random(?) number when its actual BF is 0. But, ...
ruwby's user avatar
  • 29
1 vote
1 answer
306 views

I wrote a solution to the problem linked below but I'm not sure about its time complexity. I was thinking it was quadratic but it passed within 0 ms when I submitted, so it might be linear idk. I ...
renanmatulianes's user avatar

1
2 3 4 5
128