Skip to main content
The 2025 Developer Survey results are in. Explore insights into technology and tools, careers, community and more. View results.

All Questions

Filter by
Sorted by
Tagged with
10 votes
1 answer
2k views

Find all paths in a graph

My code does a DFS on the given graph and prints all possible paths for a given start and end node. My question is how can this be improved? Can some form of memoization be used here? There are cases ...
python_user's user avatar
4 votes
3 answers
8k views

Knapsack problem - recursive approach with memoization

This post is based on the 0-1 Knapsack problem. I came across this problem in Assignment #4 of Professor Tim Roughgarden's course Greedy Algorithms, Minimum Spanning Trees, and Dynamic Programming on ...
user avatar
3 votes
1 answer
2k views

Determine all ways a string can be split into valid words, given a dictionary of all words

This function word_break(s, dictionary) receives a string s and a set of all valid words ...
nycb's user avatar
  • 31
5 votes
2 answers
368 views

Comparison of Fibonacci (Multinacci) Functions in Python3

After coming up with a formula on this Stack Overflow question, defeating recursion limits and finding a few new ways of calculating these numbers (as per this Stack Overflow question), I decided that ...
mleyfman's user avatar
  • 5,220
6 votes
1 answer
2k views

Iterative Collatz with memoization

I'm trying to write efficient code for calculating the chain-length of each number. For example, ...
xylon97's user avatar
  • 173