Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><em>(This was originally a comment)</em></p> <p>You seem to miss what the point of pseudo code is. Pseudo code is neither standardized nor somewhat defined. In general it is just a <em>code-like</em> representation of an algorithm, while maintaining a high level and readability. You can write pseudo code in whatever form you like. Even real Python code could be considered pseudo code. That being said, there are no thing disallowed in pseudo code; you can even write prose to explain something that happens. For example in the inner-most loop, you could just write <em>“swap value1 and value2”</em>.</p> <p>This is approximately how I would transform your Python code into pseudo-code. I tend to leave out all language specific stuff and focus just on the actual algorithmic parts.</p> <pre class="lang-none prettyprint-override"><code>Input: list: Array of input numbers FOR j = 0 to length(list): FOR i = 0 to length(list)-1: if list[i] &gt; list[i+1]: Swap list[i] and list[i+1] OUTPUT ordered list </code></pre> <hr> <blockquote> <p>So is it okay to use lists, tuples, dictionaries in a pseudocode, even if they are not common to all programming languages?</p> </blockquote> <p>Absolutely! In more complex algorithms you will even find things like <em>“Get minimum spanning tree for XY”</em> which would be a whole different problem for which again multiple different solutions exist. Instead of specifying a specific solution you are keeping it open to the actual implementation which algorithm is to be used for that. It usually does not matter for the algorithm you are currently describing. Maybe later when you analyze your algorithm, you might mention things like <em>“There are algorithms known for this who can do this in O(log n)”</em> or something, so you just use that to continue.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload