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
-1
votes
1 answer
Need an explanation to a Recursive reversed singly linked list code in javascript
I've console.log every line, saw many youtube videos about, but can't wrap my head around it.
I need a step by step of what's going on.
To give an example, I understand that return head after the if-statement never gets called, but it should…

learn123456
- 177
- 1
- 2
- 9
-1
votes
1 answer
Recurrence: T(n) = T(n/2) + T(n/4) + T(n/8) + Ω(n) , what is the complexity of T(n)?
how to solve the recurrence equation . T(n) = T(n/2) + T(n/4) + T(n/8) + Ω(n).
I can solve it if instead of Ω(n), we had (n), but now I can't solve it. please help me!

Amirsadra Abdollahi
- 29
- 5
-1
votes
1 answer
How Recursion Works in Trees?
I am traversing a Tree and wanna know how does Recursion works internally in Trees because the code looks easy but when i debug my code i get confused that how is it working as i don't have a clear understanding of Working of Recursion, So can you…

MobixProd
- 11
- 1
-1
votes
4 answers
Data structures get maximum value at each level of N-ary tree
Lets say I have a n-ary tree something like below I need to find maximum value at each level and return like :
[8,7,32] .
8
4 3 7
1 4 3 3 5 6 7 12 32 3 1
My Node will look…

sidkool3k
- 43
- 10
-1
votes
1 answer
Search key in binary tree
the problem that I have is that for certain keys my function works, but for some it doesn't. The function should return a pointer to the node with the key == givenKey or NULL if there is no element in tree with that key. This is the structure and…

Mihalache Rares
- 73
- 5
-1
votes
1 answer
How to improve the efficiency of search operation for BST?
Suppose as a computer programmer, you have been assigned a task to develop a program to store the sorted data in ascending order. Initially, you have used linked list data structure to store the data but search operation was time consuming then you…

Farhan Bashir Seyal
- 11
- 3
-1
votes
1 answer
C++ Binary Search Tree Deletion by unordered variable
I have an ordered binary search tree by name, but im trying to delete all students who have a score less than 50. Im having difficulty because the tree is not ordered by scores, rather its ordered by name, but i need to delete by scores. I cant for…

user421546
- 1
- 2
-1
votes
1 answer
Binary tree : how can i implement LCA with one node?
Im trying to make it right now using recursion but Im having a hard time, I think I have a logical error.
please someone help me T_T
Here is my code so far
import java.util.ArrayList;
public class BTNode{
private BTNode root,…

Amits
- 19
- 7
-1
votes
1 answer
recursive palindrome function
recursive palindrome function
this is me solution of the question
there a mistack in my solution the not palindrome part is not printing
#include
#include
using namespace std;
bool ispalindrome( char string1[],int length);
int…

sh.alzoubi
- 1
- 3
-1
votes
1 answer
Please explain the given binary tree code that is in java
I could not find people to explain me this java code properly so finally I am posting this question.please explain the process how that particular statement is affecting the tree.the problems are stated in the comments.I have problems in the BST…

untilted
- 54
- 7
-1
votes
1 answer
Output of tries traversal seems to be incorrect in c
this is the function witch is used to print all words in the tries .But some time I am getting error .Can't understand where went wrong ???please help me..thanks a lots.
typedef int boolean;
typedef struct test_struct test_struct_t;
struct…

GPrathap
- 7,336
- 7
- 65
- 83
-2
votes
1 answer
How return works in recursion call in python?
I've written a python function to reverse a list, here are the two functions and their respective outputs.
Function 1
a=[1,5]
def rev(k,i):
if i==len(k)-1:
print("in base case {}".format(i))
print(a[i])
print("Return…
-2
votes
1 answer
Data Structure Adding to a Collection Function
The function of adding to a collection has been implemented in the figure. Accordingly, which of the following information is correct?
enter image description here
a) A non-linear data type is organized.
b) The cost of the addition function is…

A. S
- 1
-2
votes
1 answer
Weight distribution in hands so that load between both hands is minimum
Problem is you are given n number of weights, we need to distribute it in both the hands so that weight difference between hand is minimum.
Eg. Weights Given : 5 8 4
Good Distribution -
Right Hand : 5 4
Left Hand : 8
Thanks in advance.

Ayush Rawat
- 65
- 2
- 9
-2
votes
2 answers
Insertion Sort Recursion not picking up last element [5,4,3,2,1,0] After sortin [1,2,3,4,5,0] Where last element not sorted
I have been stuck in the middle of the problem I am writing Recursive insertion sort on my own. The program works well but didn't pick the last element to sort
[5,4,3,2,1,0]. After the execution: [1,2,3,4,5,0]
from array import *
mylist =…

Surjit Singh
- 1
- 2