Skip to main content
Filter by
Sorted by
Tagged with
Advice
1 vote
9 replies
112 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 votes
1 answer
109 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
10 votes
3 answers
614 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
-1 votes
1 answer
86 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
-1 votes
1 answer
66 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
1 answer
54 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
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
-4 votes
2 answers
230 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
2 answers
106 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
56 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 votes
1 answer
41 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
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
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
0 votes
1 answer
48 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
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
0 votes
1 answer
32 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
-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
3 votes
1 answer
119 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
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
2 votes
2 answers
114 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
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
0 votes
1 answer
183 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
0 votes
1 answer
113 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
1 vote
2 answers
187 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
1 vote
1 answer
83 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

1
2 3 4 5
137