All Questions
Tagged with binary-tree algorithm
8 questions
2
votes
1
answer
95
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 ...
3
votes
1
answer
628
views
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
...
2
votes
1
answer
183
views
Leetcode 662: maximum width of binary tree in Java
I have the following solution to this problem. The idea is to compute the maximum width of a binary search tree. The width of a BST on a particular depth is defined as the distance from the leftmost ...
2
votes
1
answer
231
views
Sink algorithm in Max Heap Correctness
I am trying to determine the correctness of a helper method within my MaxHeap class.
The goal of this helper method is, given the index of any node in the Max Heap, sink it to the correct level in the ...
2
votes
2
answers
221
views
Lowest Common Ancestor in Binary Tree (Iterative)
In the below code I've implemented a method to find the lowest common ancestor of a binary tree.
This is an iterative approach using this pseudocode.
Please suggest any improvements that can be made.
<...
0
votes
1
answer
429
views
C++ Random Tree Node
I've been trying to kind of teach myself "Modern C++" the last couple of months and I just finished this interview type problem and thought it would be a good one to get some feedback on. I not ...
1
vote
2
answers
286
views
Leetcode: Cousins in Binary Tree
Mu solution to Leetcode problem Cousins in Binary Tree works, but the code feels bulky. Is there a better way to solve this problem, particularly to use less additional variables? I will appreciate ...
3
votes
1
answer
49
views
I need to know that if everything okay in my BTS put and get method
I implement BinaryTree (K extends Comparable, V) concept to binarySearchTree and I have written get and put method. As far as I check, there is no problem in my code. So now I wonder that are there ...