A recursive object (e.g. function or data structure) is defined using itself.

learn more… | top users | synonyms

-2
votes
0answers
22 views

How to find the shortest common element between two sets generated by a grammar? [on hold]

Suppose I define two grammars: A = N | L (L A) B = N | L (L (L B)) Where A and B are recursive definitions, so ...
2
votes
1answer
72 views

What does Tarski's Fixed-Point theorem give us that that Y-Combinator does't

I'm taking a graduate course on the theory of functional programming, based on Paul Taylor's "Practical Foundations of Mathematics." I understand the statement of Tarski's theorem about how for any ...
0
votes
0answers
18 views

Printing the words of a trie tree [migrated]

I was trying to print the contents of a trie in C. However I'm not very sucessful. And also let me say right in the beginning that this something we are doing in school right now, and this is one ...
1
vote
2answers
87 views

What are efficient ways to compute the derivatives of iterated functions?

The derivatives of iterated functions at a fixed point $z_0$ are useful in constructing a Taylors series of iterated analytic functions - in other words, the Taylors series of a dynamical system ...
0
votes
2answers
59 views

How many times can you divide a list of n elements in 1/2 [closed]

I am trying to wrap my head around recursion and divide and conquer algorithms. Can someone provide a proof and explanation of how many times a list of n elements can be divided in 1/2 on both sides.. ...
1
vote
0answers
33 views

Barnes-Hut algorithm and recursion limit [closed]

I'm running the Barnes-Hut simulation algorithm for an $n$-body simulation. If while distributing each particles to their corresponding nodes, two particles comes closer to a level smaller than the ...
1
vote
2answers
113 views

The minimization operator is an effective operator

Assume $\{f_i^{(n)}\}_{i=0}^\infty$ is a Gödel enumeration of the $\mu$-recursive functions of $n$ arguments, such that the $S^m_n$ theorem and the universal function theorem hold. Denote the set of ...
3
votes
1answer
31 views

Can indirect recursion also be tail recursive? [closed]

Consider the following function definitions: ...
1
vote
1answer
607 views

CLRS 4.4-3 Height of recursion tree for T(N) = 4T(n/2 +2) + n

I'm having a hard time with the following question: Use a recursion tree to determine a good asymptotic upper bound on the recurrence $T(n) = 4T(n/2 + 2) + n$. Use the substitution method to verify ...
2
votes
2answers
108 views

Solution to recurrence $T(n) = T(n/2) + n^2$

I am getting confused with the solution to this recurrence - $T(n) = T(n/2) + n^2$ Recursion tree - ...
2
votes
1answer
62 views

Would adding recursive named functions to Simply typed lambda calculus make it Turing complete?

Say I have Simply typed lambda calculus, and add an assignment rule: <identifier> : <type> = <abstraction> Where ...
3
votes
1answer
93 views

Viterbi algorithm recursive justification

I have a question regarding recursion in Viterbi algorithm. Define $\pi(k; u; v)$ which is the maximum probability for any sequence of length $k$, ending in the tag bigram $(u; v)$. The base case ...
0
votes
1answer
107 views

single algorithm to work on both directed and undirected graph to detect cycles?

I have been trying to implement an algorithm to detect cycles (probably how many of them) in a directed and undirected graph. That is the code should apply for both ...
2
votes
1answer
144 views

Finding growth of “inter-recursive” functions

consider following code int f(int x) { if(x<1) return 1; else return f(x-1)+g(x); } int g(int x) { if(x<2) return 1; else return f(x-1)+g(x/2); } ...
6
votes
3answers
691 views

Can a tree be traversed without recursion, stack, or queue, and just a handful of pointers?

Half a decade ago I was sitting in a data structures class where the professor offered extra credit if anyone could traverse a tree without using recursion, a stack, queue, etc. (or any other similar ...
3
votes
2answers
167 views

Algorithm to determine if recursion was breadth first or depth first

Given a tree $T$ and a sequence of nodes $S$, with the only constraint on $S$ being that it's done through some type of recursion - that is, a node can only appear in $S$ if all of its ancestors have ...
1
vote
2answers
63 views

Give a recursive function $r$ on $A$ that reverses a string

I really need help with this task here. Im stuck at it and I really would appreciate your help Here is the task: Give a recursive function $r$ on $A$ that reverses a string. For instance, ...
4
votes
1answer
369 views

Recursive equation for complexity: T(n) = log(n) * T(log(n)) + n

For analyzing the running time of an algorithm , I'm stuck with this recursive equation : $$ T(n) = \log(n) \cdot T(\log n) + n $$ Obviously this can't be handled with the use of the Master Theorem, ...
2
votes
3answers
915 views

Printing The Longest Path from Root to Leaf in Binary Tree [duplicate]

I am stumped as to how to print the longest path from the root of a binary tree to a leaf, essentially traversing the height of the tree. I've got the following for finding the height of a binary ...
2
votes
1answer
224 views

Complexity of a recursive bignum multiplication algorithm

We have started learning about analysis of recursive algorithms and I got the gist of it. However there are some questions, like the one I'm going to post, that confuse me a little. The exercise ...
2
votes
1answer
70 views

Tight asymptotic bound for recursive algorithm

I have this algorithm where: $$ T(n) = \begin{cases} 1 & \text{if}\; n \le 1 \\ T(n/2) + 1 & \text{otherwise} \\ \end{cases} $$ So, evaluating for $T(0), T(1), T(2), T(3), \ldots, T(n)$, ...
1
vote
3answers
84 views

Ordering a list of lists subject to constraints

I have encountered a surprisingly challenging problem arranging a matrix-like (List of Lists) of values subject to the following constraints (or deciding it is not possible): A matrix of m randomly ...
1
vote
1answer
279 views

Recursive definition of sum of two numbers in terms of the successor function

This is a question from the book Data structures using C and C++ by Tenenbaum. Not a homework problem but self-study. Recursive definition of a+b, where a and b ...
5
votes
1answer
187 views

Inductive vs. recursive definition

When should I call a definition recursive and when should I call it inductive? I have read Carl Mummert's nice answer on MSE. So if I understand correctly we refer to definitions of objects like ...
0
votes
3answers
874 views

Iterative and/or tail-recursive implementations of merge sort?

I recently learned how to implement merge-sort, using a standard recursive algorithm. Can the algorithm be implemented in a way that allows for a tail-recursive implementation? Can it be implemented ...
2
votes
1answer
175 views

Complexity of recursive solution to coin change

How do you go about analysing coin change recursive solution. i.e, T(N,K) = T(N,K-1) + T(N-1,K) for K denominations that add up to amount N. You can find the ...
2
votes
3answers
227 views

Can we create recursive functions only by using if-else statements?

I have to show whether a program containing only if-else statements but no loops is able to calculate the following type of functions: $f^n(x)$. The function $f$ is applied $n$ times to $x$, so I ...
0
votes
1answer
50 views

Time complexity of mutually recursive functions

Suppose I have two mutually recursive functions like this: ...
1
vote
1answer
119 views

Partial recursive function and Turing machine

The wikipedia article about primitive recursion states that An equivalent definition states that a partial recursive function is one that can be computed by a Turing machine. My question is how ...
0
votes
1answer
223 views

Register Machine code for Fibonacci Numbers

I am not sure whether this is the right place to ask this question. I would like to write a register machine code which when given an input of n in register 1, returns (also in register 1) the nth ...
0
votes
1answer
119 views

Particularly Tricky Recurrence Relation (Master's Theorem)

Master's theorem is shown below, The recursive function to be solved is shown below, I understand that a refers to the number of recursive calls in this ...
10
votes
1answer
494 views

Towers of Hanoi but with arbitrary initial and final configuration

Recently, I came across this problem, a variation of towers of hanoi. Problem statement: Consider the folowing variation of the well know problem Towers of Hanoi: We are given $n$ towers ...
1
vote
1answer
75 views

Resolving this recurrence equation [duplicate]

I have this recurrence equation: $T(n) = T(n/4) + T(3n/4) + \mathcal{O}(n)$ $T(1) = 1$ I know that the result is $\mathcal{O}(n \log n)$ but i don't know how to proceed.
0
votes
1answer
208 views

Proving correctness of the algorithm for convex polygon minimum cost triangulation

I have read many solutions for the minimum cost of triangulation problem and intuitively get the idea , however I am struggling to figure out how to prove it formally. I kind of feel that it has to be ...
1
vote
2answers
95 views

Can a recurrence relation be translated to a composite function of itself?

Perhaps this is a question for stackoverflow because its practical nature, but I am not aware of any general method to relate recurrence relations and recursive functions. Having as an example this ...
0
votes
0answers
24 views

The use of master theorem appriopriately [duplicate]

I have a recurrence relation and trying to use master theorem to solve it. The recurrence relation is: $T(n) = 3T(n/5) + n^{0.5}$ Can I use the master theorem in that relation? If so, can I say that ...
2
votes
2answers
248 views

Need help about solving a recurrence relation

I have a recurrence relation which is like the following: $T(n) = 2T(\frac{n}{2}) + \log_{2}n$ I am using recursion tree method to solve this. And at the end, i came up with the following equation: ...
2
votes
2answers
265 views

Tasks in which recursion is either the fastest or only way to produce a result [duplicate]

I've just finished studying recursion at university. One thing that stood out for me however was that in both the lectures and in the practical we completed, all the tasks we were asked to do could be ...
1
vote
1answer
229 views

Why does backtracking work the way it does?

I just recently started learning in a CS context (as opposed to a programming context) about simple recursive functions, along with the combinatorial applications, and techniques such as Backtracking ...
0
votes
1answer
65 views

A Formula For Generalized Josephus problem

There is a formula in wikipedia for the general case of josepus problem Josephus Problem But there is no reference for it, I don't know where it came from and I need too find out... Maybe Donald ...
2
votes
1answer
102 views

Prove $\varphi(x)$ to be primitive recursive

Let $\varphi(x)=2x$ if $x$ is a perfect square, $\varphi(x) = 2x+1$ otherwise. Show $\varphi$ is primitive recursive. In proving $\varphi$ to be a p.r. function I think it could come in handy the ...
2
votes
1answer
94 views

How to prove “The power set of a countable set must be uncountable”?

I'm not sure if this statement is correct, but my friend said so. The problem arose from this T/F question: Let $F=\{f: f$ be a primitive recursive function from $\mathbb{N}$ to $\mathbb{N}\}$, then ...
3
votes
2answers
520 views

Show $x^y$ is a primitive recursive function

As this thread title gives away I need to prove $x^y$ to be a primitive recursive function. So mathematically speaking, I think the following are the recursion equations, well aware that I am ...
3
votes
1answer
63 views

Clarifications on primitive recursive function definition

I am studying primitive recursive functions and there's something that I don't quite understand: let's take the function that computes $x+y$, then, in order to show that $f(x,y)=x+y$ is primitive ...
0
votes
3answers
145 views

Recursive function calculating number of ways to sum $a + 2 b + 3 c = x$

Using python need to code a recursive function with one input and no global integers that calculates the number of options to get $x$ using $a*1+b*2+c*3$. Say $x=3$, there are four options: $\lbrace ...
2
votes
0answers
263 views

A Recursive Formula For Generalized Josephus problem

The Josephus Problem asks where to start taking out every kth person in the circle consisted of n people, such that you are the last "survivor". The following recursive formula is given: ...
1
vote
1answer
211 views

Recursion problem involving head, tail and xor

Consider a set of functions: head(l) returns first bit from list l, e.g. ...
4
votes
1answer
170 views

What is the TAK function for?

We covered this in class today. I understand the mechanics of it, but aside from being a nice example of recursion does it serve any purpose? Searching the web reveals lots of pages with the ...