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
-2
votes
1 answer
How can I compare two nested arrays in PHP?
Recently, I encountered some problem on comparing 2 nested arrays. I have tested to use array_diff_assoc to compare 2 arrays but it return me incorrect. Below are couple scenarios that I am attempt to compare these 2 nested array in php.
$arr1 =…

Miracle Hades
- 146
- 2
- 10
-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) {
…

AnotherEngineer
- 57
- 1
- 6
-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…

user9057272
- 367
- 2
- 5
- 17
-2
votes
1 answer
Coin change recursive algorithm unwinding
I am trying to unwind the recursive function in this algorithm. Coin change problem: Given a target amount n and a list array of distinct coin values, what's the fewest coins needed to make the change amount.
def rec_coin(target,coins):
#…

edmamerto
- 7,605
- 11
- 42
- 66
-2
votes
1 answer
Recursive forecasting in R
setwd("C:/Users/user/Desktop")
library(forecast)
library(vars)
library(tseries)
cay <- read.csv("C:/Users/User/Desktop/cay.csv")
sp500 <- read.csv("C:/Users/User/Desktop/sp500.csv")
cay_indicator <- cay$indicator
cay <- cay$cay
sp500c <-…
-2
votes
1 answer
Recurrence relationship for an array-implementation of a list
I was asked this question recently and got stumped.
Fill in the blanks to write a recurrence relation called RecSearch find a specific value x in a list of size n. You may assume that the list in held in an array called A. Efficiency is not a…

codenovice
- 1
- 2
-2
votes
3 answers
root = NULL not working in my C program
I have created the following function to delete a Node from a tree:
void delNode(int key, Node *root) {
if(root->data != key && root->left != NULL) {
delNode(key,root->left);
}
if(root->data != key && root->right != NULL) {
…

Prajval M
- 2,298
- 11
- 32
-2
votes
1 answer
How do I implement a tree shaker operation?
I need an operation which I call shake_tree. I have implemented it using a recursive algorithm, using only basic ruby-Fortran (referencing the old quote "You can write Fortran code in any language."), but I suspect there is a much more concise and…

Kaelin Colclasure
- 3,925
- 1
- 26
- 36
-3
votes
1 answer
Object Recursion in Java while trying for bi-directional mapping
I have two classes which has bidirectional relationship and having recursive object structure issue due to the way it is being set.
Employer employer = new Employer();
employer.setName("sample1");
Employee empl = new Employee();
List…

RVR
- 97
- 3
- 13
-4
votes
1 answer
Binary Tree basics
I am following a leet code task which is called Binary tilt. The link to the question is here: https://leetcode.com/problems/binary-tree-tilt/description/
I was stuck on the question so had a look at the solution and I was hoping someone could…

abby133342223
- 1
- 2
-4
votes
1 answer
Algorithm Extract Linked Data Patterns
How to implement this algorithm in java?
SPARQL query extracts the patterns
with length one and their frequencies from the linked data:
SELECT DISTINCT ?c1 ?p ?c2 (COUNT(*) as ?count)
WHERE { ?x ?p ?y. ?x rdf:type ?c1. ?y rdf:type ?c2. }
GROUP BY…

Fiers
- 21
- 3
-4
votes
1 answer
C++ What's the standard way to define a recursive constructor?
Sorry, I edited my question now .Pay attention to the bold type words .
I really need a recursive constructor while defining a kdtree class .
But I'm afraid I'm not doing it the right way .
How can I do it more elegantly ?
This is my code using the…

iouvxz
- 89
- 9
- 27
-5
votes
1 answer
How to print cities correctly using recursive?
Hmm.. I've an hard time to do this print recursively.. can someone fix my code?
its very hard to understand how to print all direction of the city where the next city also have an all direction in it.
cityHead will be the center of all city(can be…

Reve
- 3
- 2
-6
votes
2 answers
Haskell Data Types
Which is not value of the Bin data types as defined below?
data Bin = B Bin | C [ Int]
a) C [ ]
b) B ( B C [ 2])
c) B ( C [ 1..5])
d) B (B (B (C[2,3])))

user9158464
- 15
- 3