Tagged Questions

Recursion in computer science is a method of problem solving where the solution to a problem depends on solutions to smaller instances of the same problem.

learn more… | top users | synonyms

3
votes
0answers
37 views

Print all permutations with repetition of characters

Given a string of length n, print all permutation of the given string. Repetition of characters is allowed. Print these permutations in lexicographically sorted order Examples: Input: AB ...
0
votes
0answers
31 views

Count the number of recursion [closed]

I have this algorithm that i made: def printPath(n, m) if n == 0 and m == 0 return puts 'X' end if n > 0 printPath(n-1, m) end if m > 0 printPath(n, m-1) end end ...
1
vote
1answer
45 views

Scala: tail-recursive factorial

Is there anything what could be improved on this code? def factorial(n: Int, offset: Int = 1): Int = { if(n == 0) offset else factorial(n - 1, (offset * n)) } The idea is to have tail-recursive ...
1
vote
1answer
55 views

Eight queens recursion logic error [closed]

I am writing a program to recursively solve the eight queens puzzle, but I am having a hard time wrapping my head around how exactly i am supposed to make my program "backtrack" to solve the problem. ...
5
votes
2answers
168 views

pascal triangle in php (anything wrong with this solution?)

I saw that one of the interview questions could be building a pascal triangle. Is there anything wrong with this particular solution I came up with? function pascal_r($r){ $local = array(); ...
0
votes
1answer
68 views

Codechef: Byte Landian Gold Coin - Java [closed]

This is the link to the question. http://www.codechef.com/problems/COINS Not sure what is wrong with this code. These are the input/output that I get 12 --> 13 13 --> 16 When I submit it to ...
1
vote
2answers
59 views

Confusing program for reversing link List using recursion? [closed]

I was trying to reverse the link list using recursion and somehow I did it? But one think is bothering me how the head in the last line finally points to the element 4 (i.e. the first element after ...
2
votes
0answers
56 views

simple stupid F# async telnet client

Did I write this code to correctly be tail call optimized? Am I forcing computations more than I need with !? Did I generally write this asynchronously correctly to allow sends and receives to occur ...
1
vote
1answer
141 views

shortest path recursive algorithm [closed]

This is the first time I come to this site, even though I tried to post in Stack Overflow but was told that this would be a better place to ask. So I hope this is the right place for my question. ...
2
votes
2answers
88 views

Finding if value exists in any column recursively

Could you please review if I've done this correctly? Our company uses old version of JAXB so it does not allow generics. Other than that, I am using recursive calls because Rows can have subrows and I ...
1
vote
2answers
79 views

Need a method that recursively finds all objects of type System.Web.UI.Pair in an object array

I have an object array that contains various types of objects (primitives, strings, other object arrays) at arbitrary levels of nesting. I need to pull all objects of type System.Web.UI.Pair from ...
0
votes
1answer
102 views

recursion using pipes

So hi, my goal with my code is to have a program similar to pipes in unix like $printenv | sort | less using recursion. I'm pretty new to pipes and file descriptor manipulation so I don't know ...
0
votes
0answers
170 views

Code Improvement on generating Tree Structure

I'm using actionscript/flex 4.5 I have a Class (DEF) with three main properties COD_CLASSE is the ID of the object COD_CLASSE_PADRE is the ID of the parent of the object children is an ...
2
votes
0answers
119 views

Building an ASP.NET Menu Recursively - Needs Refactoring and Readability Improving

The following code builds an ASP.NET menu recursively from data in a database: Imports Microsoft.VisualBasic Public Class MenuBarHelper Public Shared Function GetMainMenu() As Menu Dim ...
2
votes
4answers
215 views

How can I remove unwanted combinations from my algorithm in C#?

I have written an algorithm in C#. It is recursive, but it is not optimal. Maybe you have suggestions for improvement? (I already posted this question on stackoverflow but the question was closed ...

1 2
15 30 50 per page