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
-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
  • 4,841
  • 6
  • 30
  • 46
-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…
-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
  • 1,978
  • 8
  • 26
-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,855
  • 1
  • 22
  • 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
  • 2
  • 13
-4
votes
0 answers

Removal of recursion using Iteration?

How can I remove recursion by using iteration?
-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…
-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
-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
-5
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
  • 609
  • 8
  • 22
-7
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])))
1 2 3
26
27