1
vote
1answer
50 views

Solving the coin change algorithm using 10 coins

I'm solving the coin change problem having target of n and upper bound as n. Also the maximum number of coins is 10. For example. if the target is 11. then the possible outcomes are - ...
2
votes
1answer
29 views

Multiplying a numeric string with the “vedic method”

This is vedic method multiplication. This code takes time on a very long numeric string, and I want to optimize it. I also apply recursion on multIndices (this ...
4
votes
1answer
55 views

Optimization of matrix determinant calculation

I have this algorithm that calculates the matrix determinant using recursive divide-and conquer-approach: ...
3
votes
2answers
58 views

Optimizing a recursion code over lists

I'm writing three functions which iterate over lists, I want do this recursively, but I think this code is not as efficient as it could be. ...
3
votes
3answers
164 views

Finding the closest node

I have a function that I need to optimize: ...
5
votes
1answer
164 views

Kalaha Solver: finding the marbles

As with my other question this is regarding my Kalaha solver. Currently the way I find out the optimal progression of moves is with a command like this: ...
1
vote
3answers
264 views

Lowest common ancestor in recursive tree traversal

LCA = Lowest Common Ancestor The following code finds the lowest common ancestor in tree of nodes, where a node can have two parents, left and right. The tree looks like this: ...
12
votes
3answers
559 views

Improving knapsack branch and bound: how to forward filter?

I've coded branch and bound to solve the knapsack problem, and use a greedy linear relaxation to find an upper bound on a node I'm currently exploring. What I mean by this is that I first sort the ...
3
votes
2answers
121 views

Recursive uniform cost search that needs to be optimized

I have this uniform cost search that I created to solve Project Euler Questions 18 and 67. It takes the numbers in the txt file, places them into a two dimensional list, and then traverses them in a ...
2
votes
1answer
127 views

Finding the longest non-decreasing subsequence in a grid

Over the weekend I was perusing the web, and came across the programming problem, finding the longest non-decreasing subsequence in a grid, and I wanted to tackle it. I'm a web developer by ...
2
votes
2answers
449 views

Merge Sort Implementation

Any reviews/ways to speed up/general improvements for my Merge Sort? Maybe something to simplify it or add more to it? ...
2
votes
3answers
164 views

Is this a correct recursive Scala iterator creation?

I am diving into Scala (using 2.10) headfirst and am trying out a simple task of taking bulk data and then doing something with that stream. The first part is generating that stream. I have seem to be ...
3
votes
0answers
202 views

Implementing recursive filters with Haskell/Repa

I recently learned Haskell, and I am trying to apply it to the code I use in order to get a feeling for the language. I really like the Repa library since I manipulate a lot of multi-dimensional ...
3
votes
1answer
116 views

Recursive Implementation of merge sort

Information about my code: I am following this MIT OCW algorithms course. The first lecture described insertion sort and merge sort. I implemented merge sort in C. The algorithm is structured as a ...
1
vote
1answer
98 views

Given an ASCII string, replace all ASCII chars with their Cyrillic equivalents

The objective of the following PHP function is simple: given an ASCII string, replace all ASCII chars with their Cyrillic equivalents. As can be seen, certain ASCII chars have two possible ...
3
votes
1answer
793 views

Make a recursive method faster

How would you refactor this method to make it more performant? If you have refactored the code you need to prove the performance gain in numbers to get the solution :) ...
2
votes
2answers
107 views

Algorithms for traversing unordered tree

I have been doing some programming 'exercises'. I'm trying to come up with the most efficient algorithm for tree traversal. Consider the following function signature: ...
6
votes
3answers
119 views

Iteration to recursive function

In my first iterative algorithm, I do this ...
7
votes
2answers
288 views

Is this non-recursive mergesort efficient and a good way to simulate the recursive version?

My teacher assigned us to do the recursive version of mergesort, yet I heard that the non-recursive version (bottom up) is a bit tougher, so I decided to this one as well. My main concerns are: ...
5
votes
3answers
1k views

Reversing a string in-place - recursion or iteration?

I am practicing my recursion skills as I think I am really weak in this area. I have written the following Java class whose purpose is to reverse a string but to do it 'in-place' - i.e. no additional ...
1
vote
0answers
357 views

How to optimize this maze solver?

I've written C# code for solving a maze problem. It works, but I want to optimize it so that it could give me all paths. To solve the maze, I walk on the zeros and assumed that the final is reaching ...
4
votes
1answer
114 views

Printing all strings in a Boggle board

I am trying to print all the strings given in a N x N Boggle board. Its basically a N x N scrabble-like board where words can be made from a position - horizontally, vertically and diagonally. Here ...
2
votes
1answer
1k views

Optimize Recursive Function to traverse nested DOM nodes

I wrote a recursive function that traverses nested DOM nodes of the following form: ...
3
votes
0answers
480 views

Recursive JSON walk in Python [closed]

I wrote this JSON walker to help with moving objects around while updating Legacy JSONs to match a new schema. Please let me know how I could further optimize it, or more importantly, make it easier ...
2
votes
2answers
73 views

Optimizing odds calculator

I am trying to setup an odds calculator for a best of 7 series, given independent odds for each event. The following code works, but I would like to add recursion to simplify the end. ...
3
votes
2answers
139 views

Is this recursion a bad idea and does it make for clean code?

This is a program I made to bounce the letter a across the screen. I made a few others, but this one I made with a recursive bounce() method. I know ...
0
votes
2answers
9k views

Create a list of all possible combinations of elements into n-groups from a set of size k

I'm trying to write a Java program that, given a particular number of groups and number of total participants, creates a list of all possible ways to fill that number of groups evenly using all the ...
0
votes
2answers
107 views

Code optimization for euler's problem 28

I have found the solution for euler's problem using recursion.Is it okay or is there any other way to optimize the code? ...
1
vote
1answer
75 views

Improve file-path finding method

I am using a recursive algorithm to find all of the file-paths in a given directory: it returns a dictionary like this: ...
2
votes
1answer
201 views

Iterative Collatz with memoization

I'm trying to write efficient code for calculating the chain-length of each number. For example, ...
2
votes
1answer
938 views

Recursion and iteration how can i optimize this code

I have written some code which will fetch contents from a resource which is actually stored in a tree format. Since it is in a tree format, there will be a parent-child relation and hence recursion. ...