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
0
votes
1 answer

Potential for Race Conditions in Reader/Writer Pseudocode

I'm analysing the following pseudocode for race conditions (a bit of self practise) and looking at where the possibilities are. The pseudocode describes a vague asynchronous reader/writer. Writer Thread r = 0; w = 1; l = 2; //assign start slot…
davidhood2
  • 1,367
  • 17
  • 47
0
votes
1 answer

Q.allSettled not returning all the results

I'm trying to use Q.allSettled in NodeJS (LoopbackJS) for the following scenario. As an input to my method (REST API) I get an array of objects. Each of these objects internally has 2 objects: ObjA & ObjB. For each item in the array: If ObjA exists…
Vivek Athalye
  • 2,974
  • 2
  • 23
  • 32
0
votes
1 answer

Pseudocode - Search Tree

I need some help with the following problem. There is a Search Tree (Binary Search Tree) and I need to find a particular element, so to search the Search Tree. But this only needs to be displayed in Pseudocode (so the actual search tree isn't…
0
votes
2 answers

Predictive Aiming in Tower Defense

I don't even know if it's mathematically feasible, but let's say I have a tower at (Tx, Ty) shooting at a monster located at (Mx(t),My(t)). The thing is, the path followed by the monster is jagged and swirly, meaning that predictive aiming from a…
0
votes
1 answer

One dimensional array pseudocode?

can array[1:30] be an one dimensional array? Also how do you print two arrays next to each other? (in pseudocode) PRINT array[1:30],arraytwo[1:30] ^is this ok?
user5720691
0
votes
0 answers

Python: NUmber Fail in Graph Attempt 2

So this is attempt 2 to make a quadratic graph, y=x^2+3 I have 19 17 7 etc numbers when I have to have 19,18,17 on the y axis side and my x axis side I have successfully made it go across but I wasn't able to make the lines like y axis. Also my…
SweetTech
  • 17
  • 5
0
votes
0 answers

Matlab pseudocode for data splitting

A pseudocode for the data split implementation: inds= 1...n; // divide randomly to N slots for k=1...N n(k)= round(n/(N-k+1)); // size of this chunk n= n-n(k); // number of samples left to divide later… …
0
votes
1 answer

Binomial coefficient pseudo code

1.I just understood by calculating one binomial coefficient example step by step. but when it comes to pseudo code, I am a little bit confused. especially this part for(j=minimum(i,k); j>=0; j--). and what else I understood is that n is the size of…
jay
  • 55
  • 1
  • 8
0
votes
0 answers

Pseudo code to Python - Count neighbours

I want to print all the neigbours of a 2 dimensional array. For that I found this pseudocode but have problems translating it into python. Can someone explain what does max() and min() are supposed to do? I think it's a range but not sure row_limit…
Juanvulcano
  • 1,354
  • 3
  • 26
  • 44
0
votes
2 answers

Calculate Big O Notation

I currently have the following pseudo code, and I am trying to figure out why the answer to the question is O(n). sum = 0; for (i = 0; i < n; i++) do for (j = n/3;j < 2*n; j+= n/3) do sum++; I thought the answer would be O(n^2) since…
0
votes
3 answers

Finding the Big O of a simple algorithm

I'm given the pseudocode of an algorithm: 1 for i=1 to n //n times 2 j=2^i //n times 3 while j>=2 //2+3+....? times 4 j=j/2 //1+2+....? times Where 'to' means less than or equal…
TTEd
  • 309
  • 1
  • 10
0
votes
2 answers

Gaussian Elimination Algorithm GE(A[0 . . n − 1, 0 . . n])?

GE(A[0..n-1,0..n]) // Input an n × (n + 1) matrix A[0 . . n − 1, 0 . . n] of real numbers for i = 0 to n − 2 for j = i + 1 to n − 1 for k = i to n A[j, k] = A[j, k] − A[i, k] ∗ A[j, i]/A[i, i] How to compute for its running time…
Gelo
  • 43
  • 1
  • 5
0
votes
1 answer

How to count the number of operations including an 'if... else...' statement?

Say I was calculating the running time of the following pseudocode using operation counting: if(a > b) then [1 operation] return a-b [1 operation] else return b-a [1 operation] Would I count the total number of operation including…
KOB
  • 4,084
  • 9
  • 44
  • 88
0
votes
1 answer

Having some difficulty implementing a 'generalized arc consistency' algorithm in Java

Here is the algorithm I am trying to implement in Java... (Didn't fully format correctly, so it may be easier to view it at this link, just scroll up half a page from where it brings you http://artint.info/html/ArtInt_79.html#AC-3-fig ) 1: procedure…
Badger
  • 301
  • 3
  • 15
0
votes
1 answer

Write an algorithm which will evaluate Pn (x) = (N + 1)xn + N x n - 1 + ... + 2x + 1

Write an algorithm which will evaluate: Pn(x) = (N + 1)xn + N x n - 1 + ... + 2x + 1 I am trying to write pseudocode to evaluate the above. I am trying to do using a while loop and without using arrays. So far I have something like this: P:= 0 …
groot
  • 31
  • 1
  • 6