Need help understanding algorithms

Need help understanding algorithms
0.0 0

#1

does anyone have any good resources on studying algorithmic logic in general? i solved the no repeats challenge now, but only did what the algorithm says to do.I really don’t get how it functions. i don’t like just doing what it says to do and hoping I’m doing it right. it also feels like cheating a little because i didn’t come up with a way on my own.

more details after the blur

I just solved, mostly anyway, “no repeats please” with only the more trivial part of regexing the resulting array.(I just solved the mutations part, and need a break!, it took 4 days just to implement it)

Now, this challenge did more than teach a simple task, it required me to REALLY research the algorithms out there for generating the permutations. here is the algo problem. I used heaps algorithm and got what it was doing, but I DO NOT UNDERSTAND WHY!

its just running 2 counters that are the length of the string, and sometimes switching to 0 and sometimes the actual count.(seemingly for no reason) then once the counts are incremented(or its time to be 0) switch the places of count A and count B.

I do get what its doing, but why 0 if the second counter of the algo is even?
why does it not work with say 1 instead of 0?
why does it not work with switching the first counter?
why does it not work if you don’t do the 0 switch?

i guess i will just need more studying on this topic.

So!, does anyone have any good resources for learning how to follow algorithm logic?


#2

Algorithms is one part of programming. If you are interested in this I’m sure there are books available.
However, as an experienced developer, the bread and butter coding I have done didn’t use complicated algorithms like this.
I’m just saying don’t be discouraged by something you can’t understand.
PS. I found this challenge hard too.


#3

I started reading the book Think Like A Programmer. I’m a newbie and was having a hard time with the algorithms, so like you I felt like I needed another resource to study. So far, I think it is quite a good book.

Good luck!


#4

Look upon a Youtube channel called AlgoRythmics

rreally fun


#5

Introduction to Algorithms by Thomas H. Corman
This one is a reference, but it’s almost 100% theory.

Algorithms by Robert Sedgewick & Kevin Wayne
This one is far more practical, with several examples.

Algorithm for Interviews by Adnan Aziz
As the title says, this one is dedicated to coding interviews.