Questions tagged [binary-tree]
The binary-tree tag has no usage guidance.
42
questions
2
votes
2
answers
660
views
Binary tree deepcopy using the Morris traversal in C
I need to perform a deep copy of a binary tree using the Morris traversal.
I think I managed to do it, that is the code below returns what I expect; however, I am not 100% sure I have covered every ...
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 ...
2
votes
1
answer
81
views
Semi-dynamic range minimum query (RMQ) tree in Java
Introduction
I have this semi-dynamic range minimum query (RMQ) tree in Java. It is called semi-dynamic due to the fact that it cannot be modified after it is constructed. However, the values ...
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 ...
5
votes
2
answers
195
views
Binary tree struct in C
Its been done to death, but the particular prompt (see Assignment 4) guiding me has strict+simple requirements that lead to a nice reduced environment to critique poor form. The project implements a ...
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 ...
0
votes
0
answers
72
views
Is this iterative inorder traversal algorithm well-known?
I was concerned about the approach in Morris traversal algorithm and came up with simpler solution that uses parent pointers in nodes.
The constraints were following:
Time Complexity: O(n)
Space ...
5
votes
1
answer
100
views
leetcode 530. In-order traversal of a binary search tree (C++17)
Given a binary search tree, the problem requires calculating the minimum absolute difference between any two keys in the tree. Given the binary search property, the minimum difference must be between ...
3
votes
3
answers
942
views
A toy implementation of binary tree
I'm playing around with a toy implementation of binary trees in C.
I have a typedef'd struct BTree like so —
...
14
votes
4
answers
4k
views
Max-heap implementation in C
I have tried to implement my Heap in C. The following are the 13 operations defined:
build_maxheap
insert
exctract_max (delete heap max root)
max_delete (delete an element or key)
max_heapify
clear
...
1
vote
1
answer
98
views
'Learning' Animal Guesser Program
I've written a program that uses a binary tree to essentially 'learn' about animals given the name and questions about them. Learn is probably a little strong of a word, all it does is store the ...
1
vote
1
answer
141
views
Binary space partition implemented in Rust which operates on a 2D vector
So I have this binary spaced partition leaf:
...
3
votes
2
answers
297
views
Binary Expression Tree that evaluates Postfix input
My code for a Binary Expression Tree that takes postfix input from the user and recursively builds and evaluates the expression. Proper input can be assumed.
...
2
votes
1
answer
175
views
Lowest Common Ancestor of a Binary Tree in Rust
I am trying to solve the lowest common ancestor problem in Rust. It is guaranteed that the id's of the tree are unique. It is also guaranteed that the two nodes which we are looking for in the tree ...
4
votes
1
answer
3k
views
Create and view a family tree
I have an assignment due Friday to make a family tree. Started to code in January. My reviews from the teacher for this code was that the use of pointers was horrendous and it wasn't OOP enough. This ...