A recursive datastructure is a datastructure (e.g. a struct or class) that contains one or several references to instances of the same datastructure as a member.
Questions tagged [recursive-datastructures]
524 questions
0
votes
2 answers
JavaScript: Convert linear JSON array into tree structure with unknown depth
I have a JavaScript array like this:
[{
name:'a'
level:1
},{
name:'b'
level:2
},{
name:'c'
level:3
},{
name:'d'
level:2
},{
name:'e'
level:1
},{
name:'f'
level:2
},{
name:'g'
level:2
},{
…

Raghavendra
- 5,281
- 4
- 36
- 51
0
votes
1 answer
Create parent-child array structure based on value comparison
I'm trying to create an array - in - array structure based on the value of each of the entries and I don't really know how I should approach this.
I hope someone from SO can help me achieve it efficiently.
Things I have tried until now: Setting…

Grozav Alex Ioan
- 1,559
- 3
- 18
- 26
0
votes
2 answers
largest sum of any of the paths till row N-1
There is a N*N integer matrix Arr[N][N]. From the row r and column c, we can go to any of the following three indices:
I. Arr[ r+1 ][ c-1 ] (valid only if c-1>=0)
II. Arr[ r+1 ][ c ]
III. Arr[ r+1 ][ c+1 ]…

User19380
- 63
- 1
- 1
- 5
0
votes
2 answers
Is it possible to extend a class that has an instance of itself as a field such that the subclass has an instance of the subclass instead?
I know that you could break down implementations of LinkedList into two categories. In one, the actuall LinkedList is a reference to the first of some linked Nodes, like this
public class LinkedList1{
class Node{
E data;
…

user3391564
- 576
- 1
- 5
- 16
0
votes
1 answer
inheritance and recursive data structures (trees): identical child class with one method removed behaves differently
I implemented a binary search tree and would like to make a subclass that is self-balancing (AVL). I was getting strange results, and so I decided, to isolate the problem, I made an exact copy of the parent class MyTreeMap, and called it dumbchild…

user3391564
- 576
- 1
- 5
- 16
0
votes
2 answers
Display `pretty output` of directory content from array
I'm using the following code to get an array of directories and their sub-directories where each contain file type extension: png. It works great but I need to be able to output the results of the array in a list style format e.g.
* Test
->…
user275074
0
votes
2 answers
Want to know Time Complexity while using Binary Search logic for Sorted Matrix
I was looking for best optimized way of using Binary Search logic for Sorted Matrix.
Used the logic suggested by "Michal Sznajder" from Stack Over flow. Most efficient way to search a sorted matrix?
But having difficultly in calculation Time…

Sai
- 1,376
- 2
- 15
- 25
0
votes
2 answers
how to convert binary search tree traversal recursion into non-recursive method in java
Forgive me if its asked before but i couldn't find appropriate answer. I have an major issue in converting binary search tree traversal written with recursive method into non recursive method. kindly help me out. Here is a code using recursive…

user3536823
- 3
- 2
0
votes
2 answers
Facing error in LCS function in php
I am coding LCS(longest common subsequence) in php program by using recursive approach. I have the following code:

sana
- 410
- 2
- 6
- 24
0
votes
2 answers
Mutually dependent type declarations and Ada.Containers
In an implementation of "boxed types" (for an interpreter) I originally had vectors in a child package and used System.Access_To_Address_Conversions to convert from System.Address to Vector_Ptr as needed in order to avoid seemingly insurmountable…

Eric '3ToedSloth'
- 332
- 1
- 9
0
votes
2 answers
Root node in Binary search tree is null
I am learning c++ and data structures
I have implemented binary search tress
can any body tell what is the issue in this code
I am getting root pointer as null.
Basically unable to create a tree.
My final goal is to search the key in the tree. i…

ssd
- 1
- 1
- 2
0
votes
2 answers
Recursion through a linked list in Java
I need to code a method that prints the contents of a linked list recursively, however my method isn't working.
public LinkedList reverse() {
LinkedList list = new LinkedList();
list = reverseRecursion(list, 0);
return list;
}
…

user3321373
- 5
- 2
0
votes
2 answers
Recursive collections in Scala such as List
The aim is to use a Scala collection where the size needs not be computed iteratively or recursively.
For instance List proves to be a recursive construction (consider for instance https://stackoverflow.com/a/8197826/3189923), and in order to obtain…

elm
- 20,117
- 14
- 67
- 113
0
votes
1 answer
Creating a KDTree that inserts and visualizes logically
So I was tasked with this homework assignment of constructing a KdTree that has nodes that are type Point2D. First starting on the insert method to make sure nodes were being placed accordingly by x-axis, then constructing the draw() method that…

Trying_to_learn
- 1
- 4
0
votes
2 answers
Not understanding code snippet that reverses linked list using recursion in C
void reverse(LIST **head)
{
if(!*head)
return ;
LIST *first=*head,*rest=(*head)->next;
if(!rest)
return;
reverse(&rest);
first->next->next = first;
first->next= NULL;
*head = rest; …

mahesh cs
- 337
- 1
- 2
- 12