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
16
votes
7 answers

Algorithm for sampling without replacement?

I am trying to test the likelihood that a particular clustering of data has occurred by chance. A robust way to do this is Monte Carlo simulation, in which the associations between data and groups are randomly reassigned a large number of times…
Argalatyr
  • 4,639
  • 3
  • 36
  • 62
16
votes
3 answers

How to find open rectangle with specific size efficiently?

Background I have a rectangular area divided up into squares (this is for a game I'm making). I'm representing this in my code as a simple two-dimensional boolean array: ┌──┬──┬──┬──┬──┐ │ │ │ │ │ │ X = X-value, also increasing width …
user837703
16
votes
6 answers

Pseudocode Programming Process vs. Test Driven Development

For those who haven't read Code Complete 2, the Pseudocode Programming Process is basically a way to design a routine by describing it in plain English first, then gradually revise it to more detailed pseudocode, and finally to code. The main…
Charlie
15
votes
1 answer

Looking for Pseudo-code for Fortune's algorithm

I'd really appreciate if someone who ever dealt with Fortune's algorithm for generating Delaunay-triangulations presented me a rather low-level pseudo-code of the algorithm! I read the one on wikipedia but it's a bit confusing and looks high-level,…
Vincent
  • 1,027
  • 1
  • 11
  • 20
14
votes
2 answers

Recursive and Iterative Binary Search: Which one is more efficient and why?

I have written the algorithms for recursive and iterative binary search: Recursive AlgorithmBinSrch(a, i,l,x) // Given an array a[i :l] of elementsin nondecreasing // order,1
Navidk
  • 612
  • 6
  • 14
14
votes
3 answers

Difference among approximatelyEqual and essentiallyEqual in The art of computer programming

I get this code snippet from some where else. According to the webmaster, the code is picked from The art of computer programming by Knuth Since I do not have a copy of that book, may I know what is the difference among the two functions? bool…
Cheok Yan Cheng
  • 47,586
  • 132
  • 466
  • 875
14
votes
4 answers

Object.hashCode() algorithm

I'm looking for the algorithm of Object.hashCode(). This code is native in Object.java. Is this because (a) the code is in assembly-- never was in Java or any other HLL at all or (b) it simply isn't disclosed ? In either case, I am looking to…
Roam
  • 4,831
  • 9
  • 43
  • 72
14
votes
16 answers

Sorting: how to sort an array that contains 3 kind of numbers

For example: int A[] = {3,2,1,2,3,2,1,3,1,2,3}; How to sort this array efficiently? This is for a job interview, I need just a pseudo-code.
thechmodmaster
  • 709
  • 2
  • 7
  • 18
13
votes
3 answers

Algorithm to reach a number in a fixed amount of steps using addition, division and multiplication only

Working on a game at work and at one point in the game the player is tossed into a bonus game. The amount they need to win is predetermined, however we'd like to come up with an algorithm which uses addition, multiplication and division to get to…
WesleyJohnson
  • 1,538
  • 1
  • 16
  • 30
13
votes
4 answers

sorting int array with only 3 elements

I have this array: int [] myarray = {17, 6, 8}; What is the optimal way to sort this array, in pseudocode? Thanks!
clamp
  • 33,000
  • 75
  • 203
  • 299
13
votes
1 answer

Pseudo-code for Network-only-bayes-classifier

I am trying to implement a classification toolkit for univariate network data using igraph and python. However, my question is actually more of an algorithms question in relational classification area instead of programming. I am following…
Sait
  • 19,045
  • 18
  • 72
  • 99
12
votes
7 answers

Can't get insertion sort from introduction to algorithms 3rd ed. right. Where is my thinking mistake?

I am working my way through the book Introduction to Algorithms, 3rd edition. One of the first things explained is the insertion sort. On page 18 there is some pseudo code: A = { 5, 2, 4, 6, 1, 3 }; INSERTION-SORT(A) 1 for j = 2 to A.length 2 key…
Garth Marenghi
  • 1,997
  • 5
  • 20
  • 38
12
votes
3 answers

Pseudocode: How to decode a PNG file from bits and bytes?

I've been trying to figure this out by reverse engineering a .png file I created in GIMP. It's 4x4 pixels. My goal is to decode the raw pixels out of the file with the intent of reversing this to encode. Here is a full hex dump of the file: …
ANoobSwiftly
  • 311
  • 4
  • 13
12
votes
6 answers

How to detect if a repeating pattern exists

My question isn't language specific... I would probably implement this in C# or Python unless there is a specific feature of a language that helps me get what I am looking for. Is there some sort of algorithm that anyone knows of that can help me…
jcaine04
  • 427
  • 1
  • 8
  • 13
12
votes
4 answers

What does ":=" mean in Pseudocode?

Really basic syntax question in pseudocode. What does := mean in Pseudocode?Example a := 1
ElectronAnt
  • 2,115
  • 7
  • 22
  • 39