What are the Time and Space complexities of this Java method that reverses a singly linked list (of length n)?
I'm more interested in knowing the reasoning behind the space complexity. Let me know if ...

Here are given two functions that calculate the sum of elements in a list. The proof should be done using induction.
The hypothesis is: sum(as) = sum1(as, 0)
def sum( as : List [ Int ] ) : Int = as ...

given a tree i want to calculate max sum of each path from top to bottom. I used DFS for the operation. Here is the function which takes root as input and gives max sum of the path from top to bottom ...

I have an exercise for my algorithms and data structures class, where I basically have to implement a divide and conquer algorithm or function called check_distance to determine whether all numbers in ...

I have an image (an array of 1000 x 1000 pixels) of 1s and 0s. I was asked to do edge detection, so I wrote this program in C to traverse the figure. My idea was to convert every pixel surrounded by ...

I was asked to figure out the time complexity analysis for the following recurrence relation
T(n) = 4*T(n-1) + c.
Basically, I did a replacement.. T(n-1) = 4 * T(n-2) + c and so on..
T(n) = 4^k T(1) ...

Does a compiler look for recurrent expressions to convert it into 'function' to reduce binary size and improve performance?
Of course, the obvious answer might be "some do it, some don't", so I ask ...

I am lost I just can't seem to get my head around backtracking/recursion approaches. I understand how simple recursion problems like factorials work I can even trace those by hand. But when it comes ...

I'm currently using substitution method to solve recurrences. The problem I'm having is dealing with T(n) that have either ceilings or floors. For example in the following example see example here.
...

I am implementing the Douglas, Peucker's Line Simplification algorithm in Python. I started with this implementation. However, it fails to run in Python due to Maximum Recursion Depth being hit. How ...

Is it theoretically possible to transform every kind of general-recursion into tail-recursion? Are they equivalent for example from a lambda-calculus point of view? That's a debate between me and an ...

I am about to make two assumptions. Please correct me if they're wrong:
There isn't a recursive algorithm without an iterative equivalent.
Iteration is always cheaper performance-wise than recursion ...

I'm trying to understand when is preferred to use recursion rather than iteration.
Actually I've encountered recursion only in Javascript but never in Python. I imagine that recursion should be used ...

I have employed a recursive call to a closure in order to mitigate against some race conditions I am getting (That's what I think it is).
I'd like to know if (and why) this is a good solution or a bad ...

I am trying to design an algorithm for optimal sensor placement in a given area.
After doing some research I found the Art Gallery Problem. However, this problem assumes that the guards can see all ...

I understand open recursion as the process of a method on a class calling another method on a class using a keyword such as this, but whereby the method call may actually be bound to a sub class at ...

I am starting to learn Lisp, using the SICP book. The authors mention that a procedure (i.e. function) can be recursive or iterative. Additionally, the process those procedures will generate will also ...

(note I'm putting the question here because it's about the conceptual mechanics of it, rather than a coding problem)
I was working on a small program, that was using a sequence of fibonacci numbers ...

I've done this piece of code for creating bernulli samples, but I think that it is a so heavy algorithm because every time I call this recursive function I create a new vector that is passed to it. Is ...

I have levels of tables (Level1, Level2, Level3, ...) For simplicity, we'll say I have 3 levels.
The rows in the higher level tables are parents of lower level table rows. The relationship does not ...