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
6
votes
2 answers

Is there a better way to calculate the frequency of all symbols in a file?

Okay, so, say I have a text file (not necessarily containing every possible symbol) and I'd like to calculate the frequency of each symbol and, after calculating the frequency, I then need to access each symbol and its frequency from most frequent…
rps
  • 1,263
  • 3
  • 13
  • 18
6
votes
8 answers

Detecting if a point is of a line segment

If I have a line, with the points x,y,endx and endy how can I detect if another point is on the line? A simple equation, or example functions in JavaScript or pseudocode will be most helpful. EDIT: This is for a game I'm working on, I'm trying to…
Jef Null
  • 405
  • 2
  • 6
  • 12
6
votes
1 answer

Coalesced Hashing Deletion Algorithm

Can someone show me an example of deletion algorithm for a coalesced chained hash table? My insertion algorithm is like this: Insert (key) int p = hash(key) if d[p] = NIL then d[p] = key next[p] = NIL else while…
Bogdan
  • 662
  • 1
  • 12
  • 23
6
votes
7 answers

Path finding in a Java 2d Game?

Essentially its a pacman clone game I'm working on. I have an Enemy class, and 4 instances of this class created which all represent 4 ghosts of the game. All ghosts start up in random areas of the screen and then they have to work their way towards…
Ali
  • 261,656
  • 265
  • 575
  • 769
6
votes
3 answers

How to make a pipe in c++

I'm looking at the code for a c++ program which pipes the contents of a file to more. I don't quite understand it, so I was wondering if someone could write pseudocode for a c++ program that pipes something to something else? Why is it necessary to…
node ninja
  • 31,796
  • 59
  • 166
  • 254
6
votes
3 answers

Java Simulated Annealing from Pseudocode

I am currently working on a project (TSP) and am attempting to convert some simulated annealing pseudocode into Java. I have been successful in the past at converting pseudocode into Java code, however I am unable to convert this successfully. The…
Mus
  • 7,290
  • 24
  • 86
  • 130
6
votes
1 answer

5 numbers equal 23

How can I check whether 5 given numbers and mathematical operations (+, -, *)could be arranged to get the result of 23? For instance: 1 1 1 1 1 –– Impossible 1 2 3 4 5 –– Possible Specifications: All the operations have the same priority and…
Kamran Poladov
  • 450
  • 3
  • 13
6
votes
3 answers

Hyperbolic tessellation Java library

I was wondering if anyone knows a good library for tessellating a hyperbolic plane with polygons (my main interest lies in {8,3} tessellation). I found some applets here and there but the separation of logic from view is horrendous in all of them.…
Andrey
  • 8,882
  • 10
  • 58
  • 82
6
votes
1 answer

How to fit a bounding ellipse around a set of 2D points

Given a set of 2d points (in Cartesian form), I need to find the minimum-area ellipse such that every point in the set lies either on or inside the ellipse. I have found the solution in the form of pseudo-code on this site, but my attempt to…
Dziugas
  • 1,500
  • 1
  • 12
  • 28
6
votes
5 answers

Common pseudocode questions, puzzles and challenges

I am looking for examples of pseudocode problems that you may have been asked in an interview or been asked to represent as part of your job or education. I'm not looking for examples from any domain in particular, so it can be related to design…
fletcher
  • 13,380
  • 9
  • 52
  • 69
6
votes
3 answers

Dynamic programming: finding largest triangle

I need to find the largest triangle of ones in a matrix of zeros and ones using dynamic programming. So if this is my matrix: 1 0 0 1 1 0 1 1 1 1 0 1 1 1 0 1 1 1 1 1 1 1 0 0 1 Then there are two largest triangles with the right corner at [2,2]…
Chantal
  • 111
  • 2
  • 10
6
votes
3 answers

What does "!" mean in pseudo-code? I know "!" stands for factorial but I can't translate it

What does ! mean in pseudo-code? I know ! stands for factorial but I can't translate it . ex: get operation if (operation!= ’B’ OR operation != ’D’ OR operation!= ’W’) then print "Invalid Operation" What does it mean?
Dina
  • 515
  • 1
  • 5
  • 6
6
votes
5 answers

How to initialise a 2D array in Python?

I've been given the pseudo-code: for i= 1 to 3 for j = 1 to 3 board [i] [j] = 0 next j next i How would I create this in python? (The idea is to create a 3 by 3 array with all of the elements set to 0 using a for…
Oceanescence
  • 1,967
  • 3
  • 18
  • 28
6
votes
2 answers

In a triangulated isometric grid, what triangle is a given point in?

I have a triangulated isometric grid, like this: (source: mathforum.org) In my code, triangles are grouped by columns. As I hover the mouse, I want to calculate what triangle the mouse coordinates are in. Is there a simple algorithm to do that?
Steph Thirion
  • 9,313
  • 9
  • 50
  • 58
6
votes
2 answers

Currency Exchange Altorithm (Android / Java /Pseudocode)

I have a problem finding a good solution to the exchange currency problem. I've spent all the day thinking about this with any elegant and fast solution for all cases. Statement: We have some exchange currency rates like... EUR to USD -> 1.37 USD…
Sotti
  • 14,089
  • 2
  • 50
  • 43