+ 24
{About Pseudocode} Why should we write Pseudocode?
If you are unfamiliar with Pseudocode, it is a high-level language that is supposed to mimic how an application or algorithm would be written in an imperative style. The actual syntax does not matter too much; it is used for discussion, or to write ideas down before implementing them in a real language. Look At Comment!
8 odpowiedzi
+ 20
For example, writing an algorithm to find the maximum value in a list of positive numbers may look like this:
int largest = -1
for i in 1 to length of list
if list(i) > largest then largest = list(i)
if (largest == -1) print "No positive numbers found in the list"
else print "Largest number in the list: " + largest
There are no semicolons, and there is no formal syntax; the use of for and if statements rely on the reader having some experience as a programmer.
This example could have been written in a number of different ways, but the most important thing is that everyone who reads it understands the intention.
Pseudocode is used in situations other than interviews. Technical specifications may use it to provide an outline of how an algorithm should work, or sometimes blog posts or technical articles may use Pseudocode to keep any examples language-independent.
+ 17
Design thinking: Just as when you write a paper you need an outline or structure, so when you code you need to take a small amount of time to plan what it is you will do. This plan is pseudocode.
Thank you for this important question Mr. Ram.
Hatsy awesome example:)
+ 17
brilliant shane! thank you Phil and Mustafa excellent, very helpful.
+ 13
If thread is good
apply upvote
apply cookie
If has answer to question
print answer
else
If thread is bad
apply downvote
apply report
rob cookie
else
ignore thread
+ 5
Sometimes you don't express your algorithm with mathematically. Because there may be a complex code or algorithm. Pseudocode simplifies your logical algorithm to your speaking language level.
+ 5
sometimes you want to discuss or brainstorm bits of code or ideas for code, at a whiteboard, flipchart or just a scrap of paper, and it doesn't matter if a computer can interpret or compile it, the only thing that matters is the general logic is right and that the people in the room understand it.
This means you can discuss the logic being used with non-coders, or people who do not know the specific code you are using
+ 4
I often write pseudocode in the ide to plan out my real code. I keep it and turn it into comments so that when I return to the code months later I can remember my thought process.