Questions tagged [pseudocode]

Pseudocode is a compact and informal high-level description of a computer programming algorithm. It represents the code and may look similar to the code or code constructs, but it isn't actual code. It is a representation of the code or code construct. Use this tag for questions which are about pseudocode. Do not use this tag for questions which include pseudocode incidentally.

An easy way of understanding pseudocode is by comparing it to the actual programming language.

For example, you would like to write a code that checks if the student's grade is above the permissible threshold, and if it is then you would like to indicate that the student passed.

This is how it is achieved in Python:

if studentsGrade >= 70:
    print("Student passed")
else
    print("Student failed")

Pseudocode to describe the abovementioned code will be as follows:

if a student's grade is greater than or equal to 70
    Print "Student passed"
else
    Print "Student failed"
1942 questions
11
votes
13 answers

What programming language best bridges the gap between pseudocode and code?

As I write code from now on, I plan to first lay out everything in beautiful, readable pseudocode and then implement the program around that structure. If I rank the languages that I currently know from easiest to most difficult to translate, I'd…
Kai
  • 9,444
  • 6
  • 46
  • 61
11
votes
1 answer

Algorithm for computing partial orderings of dependency graphs

I'm trying to compute a partial "topological sort" of a dependency graph, which is actually a DAG (Directed Acyclic Graph) to be precise; so as to execute tasks without conflicting dependencies in parallel. I came up with this simple algorithm…
d3ddev
  • 131
  • 1
  • 5
11
votes
1 answer

Errata in the original paper on suffix arrays?

I'm looking at the pseudo-code given in figure 3 of the original paper introducing suffix arrays "SUFFIX ARRAYS: A NEW METHOD FOR ON-LINE STRING SEARCHES". I can't figure out the logic for lines 4 and 5 (indexing from 0). The lines reads: else if…
nomad
  • 1,809
  • 2
  • 18
  • 33
11
votes
1 answer

Real LaTeX in iPython notebook

In iPython one can write equations using latex syntax which is interpreted by MathJax. But now I want to do also other fancy latex stuff in iPython like writing pseudocode with some latex packages. Is there a possibility to write something like this…
Tik0
  • 2,499
  • 4
  • 35
  • 50
11
votes
5 answers

Randomly Generate Letters According to their Frequency of Use?

How can I randomly generate letters according to their frequency of use in common speech? Any pseudo-code appreciated, but an implementation in Java would be fantastic. Otherwise just a poke in the right direction would be helpful. Note: I don't…
Tom R
  • 5,991
  • 9
  • 35
  • 41
10
votes
10 answers

How to find the units digit of a certain power in a simplest way

How to find out the units digit of a certain number (e.g. 3 power 2011). What logic should I use to find the answer to this problem?
user915435
  • 109
  • 1
  • 1
  • 3
10
votes
2 answers

Algorithm to solve the points of a evenly-distributed / even-gaps spiral?

First, just to give a visual idea of what I'm after, here's the closest result (yet not exactly what I'm after) image that I've found: Here's the entire site-reference: http://www.mathematische-basteleien.de/spiral.htm BUT, it doesn't exactly solve…
chamberlainpi
  • 4,854
  • 8
  • 32
  • 63
10
votes
2 answers

Feasible implementation of a prime-counting function

What would be a computationally feasible pseudocode of any prime-counting function implementation? I initially attempted coding the Hardy-Wright algorithm, but its factorials began generating miserable overflows, and many others appear bound to…
sevko
  • 1,402
  • 1
  • 18
  • 37
10
votes
5 answers

Binary matrix multiplication bit twiddling hack

Abstract Hi, suppose you have two different independent 64-bit binary matrices A and T (T is another matrix that is stored in transposed form, using the transposed version of matrix allows during multiplication to operate on T's rows rather than…
Lu4
  • 14,873
  • 15
  • 79
  • 132
10
votes
2 answers

Solving an extension of the Shortest Hamiltonian Path

I was thinking about an extension to the Shortest Hamiltonian Path (SHP) problem, and I couldn't find a way of solving it. I know it is NP-complete, but I figured I'd ask here for ideas, since I do not want to simply brute force the problem. The…
Undreren
  • 2,811
  • 1
  • 22
  • 34
10
votes
5 answers

Find maximum value in an array by recursion

// Find a maximum element in the array. findMax(A) findMaxHelper(A, 0, A.length) findMaxHelper(A, left, right) if (left == right - 1) return A[left] else max1 = findMaxHelper(A, left, (right + left) / 2) max2 =…
Justin Bains
  • 109
  • 1
  • 1
  • 8
9
votes
2 answers

Implementing a squarified treemap in javascript

I'm currently trying to implement a treemap algorithm in Javascript. More specifically the algorithm described in Squarified Treemaps. The pseudo code given looks like the following: procedure squarify(list of real children, list of real row, real…
9
votes
3 answers

How to get the cut-set using the Edmonds–Karp algorithm?

I implemented the Edmonds–Karp algorithm using the Pseudocode that I found in the Edmonds–Karp algorithm wiki page: http://en.wikipedia.org/wiki/Edmonds%E2%80%93Karp_algorithm It works great, yet the algorithm output is the max flow value(min cut…
ciochPep
  • 2,472
  • 4
  • 26
  • 30
9
votes
5 answers

Does there exist a Top Down Dynamic Programming solution for Longest Increasing Subsequence?

I want to know how to find the LIS of an array using Top Down Dynamic Programming. Does there exist one such solution? Can you give me the pseudocode for finding the LIS of an array using Top Down Dynamic Programming? I am not able to find one on…
Some Name
  • 307
  • 2
  • 11
9
votes
14 answers

How often do you use pseudocode in the real world?

Back in college, only the use of pseudo code was evangelized more than OOP in my curriculum. Just like commenting (and other preached 'best practices'), I found that in crunch time psuedocode was often neglected. So my question is...who actually…
Kyle Walsh
  • 2,774
  • 4
  • 27
  • 25