Questions tagged [binary-tree]
The binary-tree tag has no summary.
42 questions
2votes
2answers
674views
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 ...
1vote
3answers
142views
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 ...
2votes
1answer
94views
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 ...
2votes
1answer
87views
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 ...
5votes
2answers
222views
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 ...
4votes
2answers
129views
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 ...
5votes
1answer
110views
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 ...
3votes
3answers
959views
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 — ...
14votes
4answers
4kviews
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 ...
2votes
1answer
110views
'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 ...
1vote
1answer
152views
Binary space partition implemented in Rust which operates on a 2D vector
So I have this binary spaced partition leaf: ...
3votes
2answers
309views
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. ...
2votes
1answer
180views
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 ...
4votes
1answer
3kviews
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 ...
3votes
1answer
619views
Huffman coding implementation in java
I wrote a simple huffman coding algorithm for learning and practice. I just used the technique given on the wikipedia page. Could you tell me my missing points and mistakes? Node.java ...