Tagged Questions
2
votes
3answers
148 views
Find all nodes in tree, without a sibling
Find all nodes of trees, without siblings.
This question is attributed to GeeksForGeeks.
I'm looking for code reviews, optimizations and best practices.
...
0
votes
0answers
22 views
Find K distant nodes
Find all nodes, which are at a distance of k from the input node.
Input:
target = pointer to node with data 8.
...
-2
votes
1answer
58 views
Given a BST, transform it into greater sum tree
Given a BST, transform it into greater sum tree where each node contains sum of all nodes greater than that node. Diagram is here.
Looking for code review, optimizations and best practices.
...
6
votes
2answers
81 views
Given a Perfect Binary Tree, reverse the alternate level nodes of the binary tree
Given a Perfect Binary Tree, reverse the alternate level nodes of the binary tree.
Given tree:
...
0
votes
0answers
25 views
Detect if a tree is complete binary tree
Detect if tree is complete binary tree. This question is improvement over previously asked here. Looking for code-review, optimizations and best practices.
Verifying both space and time complexity to ...
4
votes
1answer
60 views
Detect a complete binary tree
Detect if a tree is complete binary tree or not. Looking for code review, optimizations and best practices.
...
4
votes
1answer
64 views
Segment tree implementation
I'm learning segment trees and their implementation. For the purpose, I tried solving the problem on CodeChef.
Full code here
My tree implementation is as follows:
...
7
votes
5answers
514 views
Treap implementation in C
I was needed a SET-like data structure written in pure C for some university class, so I've implemented a simple one - the Treap (or cartesian tree).
Please check if everything is okay (actually, I'm ...
3
votes
0answers
46 views
Morris inorder traversal
Morris Inorder traversal - an algorithm for in-order traversal, of a tree, without recursion of extra memory. Looking for code review, optimizations and best practices.
...
3
votes
2answers
137 views
BinarySearch Tree implementation & traversals
I am practicing various tree algorithms and that require code review for it's efficiency, clarity and also if it can be made better etc.
Is there a better way to call ...
10
votes
1answer
101 views
Binary Tree/ Amorphous Binary Tree Creator
I suppose this is a two-part question. The first part is just a simple implementation of a Binary Tree (BTree), with pre-order, post-order, and in-order searches ...
5
votes
2answers
115 views
Binary tree/knowledge base design
Currently I have a binary tree template setup where my main is using it with strings to make a question/answer game. I'm using a knowledge base that works as an interface to the binary tree that main ...
2
votes
1answer
282 views
Printing the values on each level of a Binary Tree
The below code is for printing level-by-level in a binary tree:
...
3
votes
1answer
125 views
Inorder traversal of a tree without recursion or stack
Please review the code for code cleanup, smart optimizations and best practices. Also verify my complexity: O(n2), where n is the number of nodes
...
5
votes
1answer
72 views
Unbalanced binary search tree
I wrote this unbalanced binary tree and would like to know how to improve the code and performance. If you can point out any situations that are not being handled appropriately, that would be great ...
3
votes
2answers
124 views
Constructing a binary tree in java
I am constructing a binary tree. Let me know if this is a right way to do it. If not please tell me how to?? I could not find a proper link where constructing a general binary tree has been coded. ...
2
votes
2answers
291 views
1
vote
1answer
455 views
Trie - code review request for improvement
Ok, code reviewers, I want you to pick my code apart and give me some feedback on how I could make it better or more simple.
...
-1
votes
1answer
239 views
Join levels of binary tree
Please ignore feedback to include generics and function renaming while giving me feedback. Names of functions have been deliberately kept the way they are for time-being. Also please let me know if ...
1
vote
1answer
3k views
Create a binary tree, code review request
Ok, code reviewers, I want you to pick my code apart and give me some feedback on how I could make it better or more simple. ( Generics would be added a bit later).
...
3
votes
2answers
785 views
Creating a binary search tree
I want you to pick my code apart and give me some feedback on how I could make it better or simpler. Although, agree that generics should be used, instead of integers, let's punt on generics as a ...
1
vote
1answer
125 views
Given preorder array construct a BST
Ok, code reviewers, I want you to pick my code apart and give me some feedback on how I could make it better or more simple. Also its really hard to make this code work if ...
5
votes
1answer
112 views
Duplicate detection and reporting in a BST
For the purpose of this problem, the BST is defined to allow duplicates, and the duplicate values will always follow to the right-side of the parent nodes with the same value. For example, with the ...
1
vote
1answer
305 views
Print all path from root to leaves - code review request
Ok, code reviewers, I want you to pick my code apart and give me some feedback on how I could make it better or more simple.
...
3
votes
1answer
717 views
non-recursive tree traversal, code review request
Ok, code reviewers, I want you to pick my code apart and give me some feedback on how I could make it better or more simple.
...
3
votes
1answer
1k views
Print path (leaf to root) with max sum in a binary tree
I want you to pick my code apart and give me some feedback on how I could make it better or more simple.
...
4
votes
1answer
6k views
Create a tree from a list of nodes with parent pointers only
I want you to pick my code apart and give me some feedback on how I could make it better or more simple.
...
2
votes
1answer
680 views
Finding inorder successor
I want you to pick my code apart and give me some feedback on how I could make it better or more simple. This code finds inorder successor in a binary tree.
...
1
vote
2answers
45 views
Print periphery of a binary tree, critique request
Ok, code reviewers, I want you to pick my code apart and give me some feedback on how I could make it better or more simple. This code will traverse peripheri ( clock and anticlockwise ) in O(n) just ...
5
votes
1answer
1k views
LinkedList and Binary Search Tree in Javascript
I recently decided to make a LinkedList and Binary Search Tree using JavaScript. I wanted to reach out to a wider audience and see how I did, and where could I improve.
Linked List: ...
2
votes
1answer
511 views
Least common ancestor for binary search tree
I want you to pick my code apart and give me some feedback on how I could make it better or more simple. This code finds a common ancestor for binary search tree. This code accounts duplicates as ...
3
votes
2answers
174 views
Least common ancestor in binary tree
This code finds a common ancestor. If one of the input does not exist in the tree then throws an exception. This does not use extra storage. It does not even traverse more than what it should be. It ...
0
votes
2answers
932 views
Preorder traversal using stack
I wrote the code for an iterative pre-order traversal using stack for binary search tree. Below is the code for same. Please help me verify the correctness of the algorithm. Here ...
4
votes
4answers
1k views
Check if a Binary Tree <String> is aBinary Search Tree
I'm understanding the question, but I want to know whether or not my implementation is correct.
The question is:
Write a method that accepts as its argument a BinaryTree object and
returns true ...
9
votes
2answers
885 views
Quadtree design
I have an application which is used for displaying and modifying huge volumes of point cloud data from lidar files (up to few gigabytes each, sometimes loaded in simultaneously). In the app the user ...