Loading...

Follow Algorithms | Reddit on Feedspot

Continue with Google
Continue with Facebook
or

Valid

I have to explore the permutations of a binary array representing an allocation problem, but the array has length 57, 8 ones and 49 zeros, that means binomal(57,8) =1,6e+9 permutations, and I can't store them all.

I found the [Heap's algorithm](https://en.wikipedia.org/wiki/Heap%27s\_algorithm), but it calculates all the permutations, even the duplicate ones, since the array has only two possible numbers, so I should calculate and explore 57! = 4e+76 permutations...

Anyone have some suggestions?

submitted by /u/MrAnsatz
[visit reddit] [comments]
Read Full Article
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Is it possible to have a O(1) time complexity by creating a stack class which takes in a list and tracks and returns the k largest elements with a get method?

submitted by /u/Bulbasaur2015
[visit reddit] [comments]
Read Full Article
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 
Read Full Article
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Hi everyone! I want to start a project, but I do not have as much experience as I probably do to execute it on my own. I think it’s specific enough that I need to go somewhere like reddit to ask about it, so here I am. If anyone has resources, tips, or even instructions that could point me in the right direction, it would be so much appreciated!

I know this does not make much sense, so after I say this I will give an example: The algorithm I want to create is one that I can run images that I have rated through, and have it be able to predict the ratings of images based on how the previous rated ones looked like. So, for example, I would be able to run 6 different images through the algorithm, and I would be able to tell the algorithm the images rated from 1-6, or most favorite to least favorite, or something. Then, if I were to do this a couple more times, then put in another set, it would be able to predict what the ratings for each image in that set would be based on how previous pictures looked. I know this is a lot, so feel free to ask as many questions as you need if you would like to help... but I would really like to do something like this. Thank you!

submitted by /u/anongraphic
[visit reddit] [comments]
Read Full Article
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

I see alot of ppl cite stack frame usage as main downside to memoized approaches and the "ease" to write bottom up as another advantage, below are some following ways I found to mitigate the former. It seems like instead of storing in memory, there is some kind of outside DB used? Is this true? What is continuation passing? (storing solutions in function params and passing them to next subproblems?)

https://i.redd.it/cqu7p2flkhn21.png

submitted by /u/bitsofshit
[visit reddit] [comments]
Read Full Article
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

The flowchart could be what approach to take -- backtracking, two pointers etc based on the situation.

submitted by /u/Bulbasaur2015
[visit reddit] [comments]
Read Full Article
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Hello,
I've got a following programming challenge:

- Have a 2D grid - a map - with obstacles in it
- You can move only in 4 directions - North, South, East, West (no diagonals)
- Find a shortest path between two points
- Movement directions have priorities. For exmple you like going North first if possible with South on a second place, then East and lastly West
- Final path still have to be the shortest one

I don't have a problem with first three points, that's just implementing Astar or Dijkstra algorithm, but I can not think of a way how to implement such algorithm with the preferred directions, especially with obstacles in the map. I was thinking about saving a list of all shortest paths and then iterating over their moves and giving them a score based on it, but with a bigger maps the memory and computing difficuilty will be too big. I would love some help with that. Thank you.

submitted by /u/Tona_Kriz
[visit reddit] [comments]
Read Full Article
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Hi there,

I'm currently doing my dissertation on using algorithms to try find the best move in scrabble (taking into account things like board positioning as well as word score) and am wondering if anyone knew some good ones to look at. I have looked at minimax/alpha-beta pruning and they seem implementable. I've also looked at genetic and simulated annealing algorithms but cant think of a way to implement them.

Cheers in advance

submitted by /u/oorkyy
[visit reddit] [comments]
Read Full Article
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Please give reasons.

Some questions I word well with detail always get downvoted.

submitted by /u/bitsofshit
[visit reddit] [comments]
Read Full Article

Read for later

Articles marked as Favorite are saved for later viewing.
close
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Separate tags by commas
To access this feature, please upgrade your account.
Start your free month
Free Preview