Skip to main content
Filter by
Sorted by
Tagged with
Advice
1 vote
9 replies
114 views

I have a binary tree which leafs have a size of 1, and the parent double in size at each level. I project those nodes on a linear axe (memory space). I need to get the equation that gives the adress ...
Simon's user avatar
  • 2,143
1 vote
2 answers
153 views

Let's say our binary tree (bt) looks like this: Node* root = new Node(); root->left = new Node("B"); root->right = new Node(); root->right->right = new Node("A");...
Arun Saini's user avatar
-1 votes
1 answer
112 views

I have a working recursive solution to check if a binary tree is symmetric. The code works correctly for my test cases, but I'm concerned about potential stack overflow with deep trees since Python ...
Jared McCarthy's user avatar
1 vote
1 answer
158 views

I'm trying to solve LeetCode 199. Given the root of a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. I've ...
Benny's user avatar
  • 519
10 votes
3 answers
616 views

This is the code I have written for searching a node in a tree as a part of my assignment: typedef struct NODE { int key; struct NODE *left, *right; } Node; Node *search(Node *head, int key)...
M.B.'s user avatar
  • 279
0 votes
0 answers
44 views

Suppose I have a complete, perfect binary tree stored in an array. If I store node data in breadth-first traversal order (Eytzinger order), then if an internal node's index is i, its left and right ...
Alec Jacobson's user avatar
-1 votes
1 answer
91 views

I'm trying to solve the Binary Tree Longest Consecutive Sequence II problem (Leetcode 549). The goal is to find the length of the longest consecutive path (increasing or decreasing) in a binary tree. ...
fortnight learner's user avatar
2 votes
1 answer
300 views

I understand we can rebuild a binary tree from its inorder AND ( postorder OR preorder ) traversal. I however wonder whether rebuilding it from its postorder AND preorder traversal doable too?
Linda's user avatar
  • 319
-1 votes
1 answer
68 views

I was doing the GeeksforGeeks practice problem Vertical Tree Traversal: Given a root of a Binary Tree, find the vertical traversal of it starting from the leftmost level to the rightmost level. If ...
Sandesh Dubey's user avatar
2 votes
0 answers
68 views

I'm trying to implement a binary tree using an array. It means that the following tree 1 / \ 2 3 / \ / \ 4 5 6 7 would be as the array below: [1, 2, 3, 4, 5, 6, 7] So it means that the ...
Базакин Егор's user avatar
-2 votes
1 answer
60 views

def path_sum(root,temp): print("root is",root) if root == None: return False temp.append(root.val) if root.left == None and root.right == None: ...
data_geek's user avatar
1 vote
0 answers
93 views

I'm working on implementing a Double-Ended Priority Queue (DEAP) data structure in C++. I'm having trouble with establishing the correct implementation of node partnerships between the min and max ...
benhpark's user avatar
6 votes
1 answer
89 views

I am interested in methods for serializing and deserializing a binary tree in breadth-first order. The first part, serialization, is equivalent to performing a levelorder traversal where we preserve ...
Brendan Langfield's user avatar
1 vote
1 answer
85 views

I am trying to visually print out a simple binary tree in Java. Here is the full code: class WordPoint { private final String word; private final float pointValue; public ...
DBar's user avatar
  • 13
-4 votes
2 answers
232 views

I’m trying to implement a level-order traversal of a binary tree in C++ without using recursion. The goal is to traverse the tree level by level, starting from the root, and print the nodes in the ...
Naormeit's user avatar
2 votes
1 answer
219 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
2 votes
2 answers
110 views

I am solving LeetCode problem 1372. Longest ZigZag Path in a Binary Tree: You are given the root of a binary tree. A ZigZag path for a binary tree is defined as follow: Choose any node in the binary ...
JobHunter69's user avatar
  • 2,376
0 votes
1 answer
130 views

I am trying to write a generic free function for a binary tree. typedef struct s_tree { void *content; struct s_tree *left; struct s_tree *right; } t_tree; void ft_treeclear(...
Bastian's user avatar
  • 63
0 votes
1 answer
58 views

Say I have many repetitive entries that are to be merged into a Huffman Coding tree. Simply merging them would cost n*logn but I want it to be faster. Say I have 100000 entries of the same frequency 1,...
Phere Salad's user avatar
1 vote
1 answer
175 views

I am not from a computer science background and have been trying to learn Data Structures using C programming. I have made some binary tree programs and realised that I have used malloc() left and ...
Vinayak Deshmukh's user avatar
-1 votes
1 answer
48 views

I am trying to solve LeetCode problem 872. Leaf Similar Trees: Consider all the leaves of a binary tree, from left to right order, the values of those leaves form a leaf value sequence. For example, ...
ananya-singh-afk's user avatar
0 votes
1 answer
92 views

# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class ...
Shrayus's user avatar
  • 15
1 vote
0 answers
146 views

This is from sicp although a bit different: Exercise 3.18. Write a procedure that examines a list and determines whether it contains a cycle, that is, whether a program that tried to find the end of ...
An5Drama's user avatar
  • 774
0 votes
1 answer
134 views

I am trying to make a tree structure in react. I was trying with @nivo/tree. There's very limited documentation for this library. I couldn't get it to render a custom node. Attaching the code here. ...
Arun K Anil's user avatar
0 votes
1 answer
112 views

I have been attempting to implement a voxel octree for a game, and this issue has completely stumped me. My octree is stored linearly as a hashmap of octree indices and nodes (see "Implicit node ...
alama09x's user avatar
-2 votes
1 answer
89 views

I am learning DSA quite long.. During my learning, I encountered a concept 'Left View Method in Binary Tree'. I am completely scripted my code but there is a error when i tried to give a modified ...
Sagar's user avatar
  • 1
0 votes
1 answer
49 views

I'm studying an algorithm that uses a Huffman tree to find the optimal search cost based on probabilities. Here’s how the algorithm works: Start by checking the most probable element (X1) to see if ...
Mohi Reza's user avatar
8 votes
1 answer
476 views

I've seen contradicting claims about the worst case time complexity for a solution to the GeeksforGeeks challenge Check if Tree is Isomorphic: Given two Binary Trees. Check whether they are ...
Adrian's user avatar
  • 105
0 votes
0 answers
44 views

'This VBA binomial option code contains missing syntax intended to create an N by N matrix of stock prices using inputs for Pricing Binomial Tree Options with discrete dividends saved as a Named Range ...
M Smith's user avatar
3 votes
1 answer
148 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
0 votes
2 answers
87 views

This may be a dumb question so I am sorry, but there is a Leetcode problem where you have to return all of the paths from the root node to leaf nodes in an array of strings connected with "->&...
Mike Carpinello's user avatar
-1 votes
1 answer
35 views

I am working on a university project involving binary trees represented as dictionaries. I've implemented functions to check if these trees are full, complete, and binary, but my binary tree ...
user27367566's user avatar
-1 votes
1 answer
85 views

I have the following code: typedef struct TreeNode { int data; TreeNode *lchild, *rchild; } TreeNode; TreeNode *CreateBTNode(TreeNode *bt) // pre-build { char ch; cin >> ch; ...
Erudito's user avatar
3 votes
1 answer
126 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
1 vote
0 answers
105 views

Why would we ever use a heap over a red-black tree? Take a scenario where we want a min-heap. The time complexities of a mean-heap are as follows. Peek: O(1) average/worst Delete First: O(log(n)) ...
Mike's user avatar
  • 21
0 votes
1 answer
52 views

I was trying to generate the inorder traversal of a binary tree using O(1) space ie I don't wanna use recursion or any other data structures such as queues or vectors to store the node. Edit: This ...
Manas's user avatar
  • 3
0 votes
0 answers
41 views

I want to create a binary tree out of 2d points. What should be the key to be compared for the binary tree?
Newtron Malayalam's user avatar
2 votes
2 answers
118 views

So I'm working on this problem: Given the root of a binary tree, return the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in ...
ABGR's user avatar
  • 5,263
0 votes
1 answer
63 views

When implementing a preorder traversal of a binary tree using a non-recursive approach, I wrote my own stack. An error occurred during runtime. When I try to debug and find the problem, it runs ...
ShiZiMiao's user avatar
0 votes
2 answers
80 views

I'm trying to make a recursive insert method on a binary tree and while the recursive part of the function seems to do the job correctly (I tracked the code step by step with debug option) when time ...
Nico Mcrae's user avatar
-1 votes
1 answer
86 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
0 votes
1 answer
185 views

In case of Binary Trees, It is possible to find the distance between the two nodes without finding the path from the root node or lowest common ancestor. I was wondering if it is possible in the case ...
Jagdeep Kaur's user avatar
2 votes
1 answer
124 views

My professor is currently teaching Binary Trees at college and she gave us a program to create a binary tree in C using Linked Lists. However, there was a debate on whether ampersand (&) has to be ...
SpaciousCoder78's user avatar
0 votes
1 answer
120 views

I'm trying to solve the problem: Binary tree level order traversal problem on LeetCode and I've also tried looking for the answers, but I'm still getting a time limit exceeded (TLE) error. Please help ...
Apoorva Walia's user avatar
0 votes
4 answers
134 views

When building the insertion function in binary tree, I use two if statement to track the node( if the value is smaller than the current node,go left;if bigger,go right) . I know the difference between ...
Yi Zhao's user avatar
  • 21
1 vote
2 answers
189 views

I am looking at LeetCode problem 105. Construct Binary Tree from Preorder and Inorder Traversal: Given two integer arrays preorder and inorder where preorder is the preorder traversal of a binary ...
Yihan Luo's user avatar
0 votes
1 answer
213 views

I understand that the black height of a RB tree increases after insertion when a red-red violation is propagated to the root, which then gets colored to red then recolored to black, and it causes for ...
iSkull's user avatar
  • 5
1 vote
1 answer
89 views

I have some physical model that needs to be represented as an algebraic expressions full binary tree. How can I represent such a tree in a non-ambiguous way? Consider, as an example, the three full ...
Alexandre de Castro Maciel's user avatar
3 votes
1 answer
239 views

I am looking at LeetCode problem 222. Count Complete Tree Nodes: Given the root of a complete binary tree, return the number of the nodes in the tree. According to Wikipedia, every level, except ...
Paras Khosla's user avatar

1
2 3 4 5
137