Tagged Questions
0
votes
0answers
10 views
Kd Tree Algorithm not working properly [closed]
I am implementing Kd Tree in 3D space where I get a point cloud and I need to store it in a kdTree structure. My problem is that it doesn't work as it should, it add the same numbers as in an infinite ...
11
votes
1answer
336 views
Recursion vs iteration of tree structure
Some recursive code is part of a particularly slow path of a project. Out of curiosity I was playing around with reimplementing the code using stack context iteration instead of recursion. Below are ...
6
votes
1answer
101 views
Functional, but not recursive, tree traversal
To learn tree traversal i implemented os.walk, tail-recursive and stack-based. Unfortunately Python doesn't support tail call optimization. How do i rewrite my ...
2
votes
2answers
107 views
Algorithms for traversing unordered tree
I have been doing some programming 'exercises'. I'm trying to come up with the most efficient algorithm for tree traversal.
Consider the following function signature:
...
1
vote
3answers
265 views
Lowest common ancestor in recursive tree traversal
LCA = Lowest Common Ancestor
The following code finds the lowest common ancestor in tree of nodes, where a node can have two parents, left and right.
The tree looks like this:
...
1
vote
1answer
95 views
Construct a tree given pre and inorder or post and inorder
I want you to pick my code apart and give me some feedback on how I could make it better or simpler. For a full tree (all nodes with 0 or 2 children) it works deterministically:
...
3
votes
2answers
238 views
Binary Tree Operations
I've been programming for about 5 years now, mostly in C++ and Java, while continuing my college education in Computer Science. As an adult student, I'm always looking for opinions and ways to improve ...
4
votes
1answer
1k views
Recursive search to delete n'th child in tree
I have to implement a tree programming here. What I mean by tree programming is I have data stored in tree format. I have a parent object which will have child objects of same type the level of ...