Questions tagged [recursive-datastructures]

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.

402 questions
-1
votes
1 answer

Converting iterative code to recursive code

I need some help with that function. I gonna use "val" in other functions but when I try to return the value in a recursive function just return 0. I need to make this loop in a recursive function Sorry for my English. Thanks a lot int val = 0; for…
-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…
-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
  • 9
-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…
-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…
-1
votes
2 answers

Javascript Recursive function to build Tree

Hi I am using JavaScript and jQuery as client side script. I am little bit new to Recursive functions. I have a JSON data as below and I have tried to make a tree structure using below JSON data by writing a recursive function but I am not able to…
prog1011
  • 3,157
  • 3
  • 20
  • 49
-1
votes
1 answer

How to open a file which name is found in another file, recursively

Recursive file openings without destroying the filehandles in perl #!usr/bin/perl $set=1; open (MYFILE, 'file1.txt'); $array[$set]=\*MYFILE; printit ($array[$set]); sub printit { ($array[$set])=shift; …
-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…
-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…
-1
votes
1 answer

Perl nested structure: recursive function

As a follow up to my previous post here! I tested the algorithm with nested hash references: Algorithm: use strict; use warnings; &expand_references2([a,b,{c=>123},d]); sub expand_references2 { my $indenting = -1; my $inner; $inner = sub { …
-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
  • 6
-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
  • 5,786
  • 6
  • 54
  • 75
-2
votes
2 answers

All possible combinations (subsets) in swift

I'm having this issue of trying to trying to recursively print out all subsets of the giving array of String(characters) using swift. The value is ("a1b2"). The output should have 4 subsets. Currently stuck here: func overall(string: String) { …
-2
votes
4 answers

Minimum sum of recursive adding of elements in an array two a time

I have an array of integers. Value of each element represents the time taken to process a file. The processing of files consists of merging two files at a time. What is the algorithm to find the minimum time that can be taken for processing all the…
1 2 3
26
27