Category "recursion"

Duplicate things a specific number of times in racket

I'm trying to write a program that takes in a phrase and a number (n) and returns a list that contains the phrase repeated n times. What I have so far looks lik

Recursive iteration of a Map Java

I am writing a recursive function whose purpose is to iterate over the pList File. My code is public static void HashMapper(Map lhm1) throws ParseException {

Writing a recursive case

How do I complete this recursive function at output_string += ? Output should be: 5! = 5 * 4 * 3 * 2 * 1 = 120 def print_factorial(fact_counter, fact_value):

Python: Recursive Function. How to return all subsets of targetsum

My code is not showing the shortest subset eg [7] or it is not reading all the subsets, [7], [3,4] to return the shortest subset. Can explain why only 1 set of

recursively split a dataframe with partykit::lmtree as a stump tree

I am trying to recursively split my data using a stump tree based on the lmtree function from the partykitlibrary. The idea is the following: [1] for each varia

How do I recursively use Array.prototype.find() while returning a single object?

The bigger problem I am trying to solve is, given this data: var data = [ { id: 1 }, { id: 2 }, { id: 3 }, { id: 4, children: [ { id: 6

count number of digit using recursive method

Given a non-negative int n, compute recursively (no loops) the count of the occurrences of 8 as a digit, except that an 8 with another 8 immediately to its left

Division using recursion

I am pretty sure that this must be some glaringly stupid mistake by me. But can anyone explain what is wrong in this division code using recursion. I know there

Writing A Recursive Function That Counts Zeros

It is possible to count the number of zeros in an integer through a recursive method that takes a single int parameter and returns the number of zeros the param

New state of the art in unlimited generation of Hamming sequence

(this is exciting!) I know, the subject matter is well known. The state of the art (in Haskell as well as other languages) for efficient generation of unbounded

Building general trees in java (with recursion)

I have been stuck on a problem for quite a few days. My end goal is to perform preorder, inorder, and postorder traversals on a general tree. The problem I am h

Loop through all nested dictionary values?

for k, v in d.iteritems(): if type(v) is dict: for t, c in v.iteritems(): print "{0} : {1}".format(t, c) I'm trying to loop through a

Is it possible to define function that creates an N-dimensional list of lists easily?

I have searched and found these questions: How to create a multi-dimensional list and N dimensional array in python which hint toward what I am looking for, but

Given sorted Array, Returns index i if array A contains an element A[i] such that A[i] = i (recursive and divide and conquer)

So i have homework to make a recursive method that uses a divide and conquer algorithm to search a sorted array and check if A[i] == i (if value matches current

Get full tree of parent/child relationships in mysql of any node in the tree with all parents

Example data: +----+-------+----------+ | org_id | Name | ParentID | +----+-------+----------+ | 1 | Org1 | 2 | | 2 | Org2 | NULL | | 3 | Org3

What is wrong with my Preorder traversal?

I am trying to solve this problem https://oj.leetcode.com/problems/binary-tree-preorder-traversal/ , i.e. preorder traversal with recursive slution. EDIT: The

Map of sets into list of all combinations

I'm stuck with a simple task. What I want to do is to transform Map<K,Set<V>> into the List<Map<K,V>> getting all possible combinations:

If myStr = 'test', why does myStr[4] produce error out of range but myStr[4:] does not?

I'm using recursion to iterate through the values of a string. When I get past the last character, it's allowing me to use that index position as an empty strin

Why is there no tail recursion optimization in Emacs lisp, not but like other scheme?

Emacs lisp is a dialect of LISP and especially Scheme. Most of scheme interpreters do have a optimization of Tail Recursion, but emacs lisp doens't. I searched

Lazy Catalan Numbers in Haskell

How might I go about efficiently generating an infinite list of Catalan numbers? What I have now works reasonably quickly, but it seems to me that there should