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
1 answer
find more than one item in a list using binary search
this is what i have done but this only locates one item in the list i want to print out both indices of item 36
please help this is what i have done so far
if the way i posted this or my question isn't clear i apologize in advance
[code]
def…

user1594831
- 41
- 5
0
votes
1 answer
Algorithms and generalisation of functions
I admit I'm little bit poor in functions in mathematics.
But I'm in real urge to get this riddle out.
how to express x(n)=x(n-1)+x(n-2)+1 where n>1 and x(0)=0 and x(1)=1.
in terms of function y(n)=y(n-1)+n where n>1 and y(0)=0 and y(1)=1.
I found…

cdummy
- 455
- 1
- 4
- 14
0
votes
1 answer
data structure for line segment splitting and merging
I am writing a Qt application to enable generation of signal files using a GUI. The GUI has a canvas that allows a user to draw a new signal. Id like a signal to be defined as a set of contiguous line segments where each segment can be shifted up or…

user1487551
- 391
- 2
- 3
- 8
0
votes
1 answer
Populating a tree recursively with database contents
I am using an ORM that uses POCOs.
Each table (class) contains references to other tables.
public class Table1 {
[AutoIncrement]
public Int32 Id { get; set; }
[Index(Unique = true)]
public string FieldA { get; set; }
}
public Table2…

A T
- 13,008
- 21
- 97
- 158
0
votes
1 answer
How can I iterate over a quadruple linked 2-dimensional grid of data as if it were a 2-dimensional array?
How can I iterate over a quadruple linked 2-dimensional grid of data as if it were a 2-dimensional array?
My grid structure is:
typedef bool tile;
struct BLOCK;
typedef struct BLOCK block;
struct BLOCK {
const block * to_the_left;
const block *…

Molly Stewart-Gallus
- 1,118
- 9
- 25
-1
votes
2 answers
Merge Two Sorted List Leetcode Question 21
So I keep getting a maximum recursion error on line 22, for this test case
list1 is 1,2,4
list2 is 1,3,4
Output is 1,1,2,3,4,4
can someone explain what is causing this infinite loop to occur, python reads from top to bottom and left to right so it…

Shahryar
- 9
- 1
-1
votes
1 answer
Inconsistent output in Recursion?
I was solving a question today on Leetcode named Lexicographically Smallest Equivalent String (link) and I came up with a solution of DFS with some customization to solve the problem and here's is my code.
#!/usr/bin/python3
from collections import…

Kiran Deep
- 83
- 7
-1
votes
2 answers
Segmentation fault is on terminal. Its the code to convert string to binary tree
Node * create(Node * root, int I, int J, string str)
{
if (I == J) { root -> data =str[I]; root -> left=NULL; root -> right=NULL; }
int i = 0, j = 0, k = 0, l = 0;
//// to store the data of root
string val;
for (i = I; i < J;…

Arjun Singh
- 11
- 3
-1
votes
1 answer
target sum for given array
Write a function canSum(targetSum, numbers) that takes in a targetSum and an array of numbers as arguments.
The function should return a boolean indicating whether or not it is possible to generate the targetSum using numbers from the array.
Dynamic…

singam suresh
- 45
- 4
-1
votes
2 answers
Write a block of 3 lines repeatedly with calculated data into a text file using Python
I want to write data with headers into a file. The first three lines are unique, and can be considered as a 'block' which are then repeated with increments in x and y (0.12, 1) respectively. The data in the file should look like:
#X #Y Xmin …

rohan kundu
- 15
- 3
-1
votes
2 answers
How to revert back to original array after updating it in C lang? like using a temp pointer or any other way to revert?
//I want to revert array back to original state after 2nd printf statement OR code any other way such that next code a=++(*p) operates on origianl array not on Update array.
CODE:
#include
#include
int main(){
int…

ayushkadbe
- 91
- 2
- 13
-1
votes
1 answer
For loop is not working inside recursive function
1.I have a use case where i want the parent to be made false if any last child "isSelected" is true. For example the id 4 isSelcted is true so the parents of 4 are 3,2,1 whose key "collapse" should be made false.
2.Example 2: If Id 7 isSelected is…

Srujan R
- 29
- 5
-1
votes
2 answers
Recursion method that finds the sum between two numbers
I want to implement a recursive method that finds the sum of x consecutive integers, starting from a starting number and ending with an end number.
For example, if start = 0 and end = 3, the method returns 6 (0+1+2+3). I tried to come up with the…
user14153071
-1
votes
1 answer
How to print all the ways to cut off a string - combination
input: "abcd"
output: a list of all the ways to cut off the string.
[ ["a", "bcd"],["a", "b", "cd"], ["a", "b", "c", "d"],
["ab", "cd"], ["ab", "c", "d"],
["abc", "d"],
["abcd", ""]
]
I want a recursive solution. Preferably Java but not need…

JustAnotherJavaDeveloper
- 57
- 2
- 4
-1
votes
1 answer
Understanding nested defaultdict and `tree = lambda: defaultdict(tree)` vs `tree = defaultdict(lambda: tree)`
Working form
From another question, I see how to create a defaultdict of defaultdict of defaultdict... as:
Working form
Using it
Output
tree = lambda: defaultdict(tree)x = tree()
x["1"]x["2"]x["1"]["3"]print(json.dumps(x))
{"1": {"2": {}},…

joseville
- 685
- 3
- 16