I can not understand Pseudocode

I want to know how I can improve my understanding of algorithms? I mean, if any algorithm is explained, I can understand it. But when I read the pseudocode of the same algorithm, I do not understand. For example, I read about Shell sorting, I also understand the process and operation of this technique, but when I read its pseudo-code, I don’t understand why each specific step is taken? This happens with other algorithms. Is there a problem with my level of intelligence, or is it a common problem? Please, help.

+6
source share
2 answers

I did a lot to study algorithms and data structures myself, and I found that reading pseudo-code is one of the most difficult ways to find out how an algorithm or data structure works. In my experience, the best way to understand the algorithm is to get high-level intuition behind it. What is the key information that drives the algorithm? At a high level, what is he trying to do? Once you know this, it will be much easier for you to understand the algorithm.

As a good example, try finding pseudo-code for Dijkstra's algorithm or mahogany / ebony. Even the best pseudo-code is extremely difficult to understand, because the pseudo-code does not distinguish between the key idea of ​​the algorithm, specific optimizations designed to improve performance, and nut-bolts-pointer-gymnastics. However, if you understand where these algorithms come from - for Dijkstra the idea is to maintain a slowly growing set of points that you know the distance to; for mahogany / ebony, you encode the 2-3-4 tree as a binary tree - then it is much easier to read the pseudo-code, because you know what corresponds to each part of what you read.

So do not despair - reading pseudocode is hard! My recommendation is to find a good explanation explaining what you are reading. If you will have much less time.

Good luck

+4
source

The reason you cannot understand pseudo-code well is that you want to read it as code, when in fact what you have to do is read it in plain text and try to understand it as if you had a conversation with a person.

Imagine you are reading the back of a book. You will read a summary of the book and you will get an idea of ​​its contents, but this will not tell you about the story.

Same thing with pseudo code; this will give you an idea of ​​what the algorithm should do, but it really won’t show you what the source code is.

When I realized this, the pseudocode suddenly became much easier, and it even became easy for me to read code from other languages ​​and understand other languages, which allowed me to write code in my native language using code like Java, which I suck at, and probably will always suck.

+1
source

All Articles