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

Dictionary Value lookup performance

I am working on a small project but have run into a performance roadblock. I have a Dictionary() I have a string[]. Lets say my Dictionary has 50,000 entries, and my string[] has 30,000 entries. I want to collect the Keys from my…
Rawle
  • 199
  • 12
0
votes
1 answer

Not sure what this pseudo-code is saying

I saw this pseudo-code on another stackoverflow question found here Split a string to a string of valid words using Dynamic Programming. The problem is a dynamic programming question to see if an input string can be split into words from a…
Anthony J
  • 61
  • 1
  • 1
  • 5
0
votes
2 answers

what does returning -1 mean in a pseudocode

I have the following pseudocode which a sequential search pseudocode and I am trying to understand what return -1 mean. why would we return -1 could someone please explain. A[n] <-- K i <-- 0 while A[i] != K do i = i + 1 if(i
matrixCode
  • 111
  • 1
  • 2
  • 7
0
votes
1 answer

Time-complexity of code containing nested loops

i := n; WHILE i > 1 FOR j := i to n DO X; END FOR j := 3*i to 3*n DO X; END DEC(i); (* i decrement *) END For this pseudocode, I have to calculate a function f: N -> N, depending on n. I'm doing something like…
Arthur
  • 151
  • 10
0
votes
1 answer

Ambiguous pseudocode phrase

I was looking though some pseudocode for some code and I came across the phrase lowest 32 bits of After a very long time of searching through website I came across the answer: What we want to do is AND operation on 64 bit number and 0xffffffff to…
0
votes
1 answer

Pseudocode for progressing a poker game

I'm creating a single function called progress() that is called after a player acts. I think there are only 3 possible ways to end a poker game: Game ends normally, there are 2 or more players until last round ends, do the "showdown" phase, and…
topher
  • 1,357
  • 4
  • 17
  • 36
0
votes
3 answers

For each character in string, read each one from right to left

I have this psuedocode, which converts a binary value to a decimal value: int powTwo = 1; int dec = 0; for each character in the string, starting with the last, if (char == '1') dec += powTwo; powTwo *= 2; How do i write the for each loop…
c0der
  • 73
  • 1
  • 3
  • 11
0
votes
1 answer

How to get a user level from total points and known factor?

I know this is basic calc but I am a bit rusty and I want to be sure I am doing it right. I am implementing a user level system on my site and I need to display each user's level on their profile. They already have some points and from this I want…
Gixty
  • 202
  • 4
  • 13
0
votes
1 answer

How to find array index relative to the position in matrix?

I had a 2D array (matrix) and its array(1D) representation, I want to know what is the relationship between the [x][y] position of an item in matrix with [index] of the corresponding item array representation. Explanation: Lets say I had matrix of…
Dipak
  • 6,532
  • 8
  • 63
  • 87
0
votes
1 answer

Determine Big-O of a function inside while loop

For a loop where the such function aFunction() inside the loop has a big-o of O(nlog(n)), how do you determine the worst case time complexity? i ← 0 while (i < n) aFunction(...) i ← i+1 done
0
votes
2 answers

see if a string is embedded in a larger string

I have data that looks like this using R. > hits Views on a 51-letter DNAString subject subject: TCAGAAACAAAACCCAAAATCAGTAAGGAGGAGAAAGAAACCTAGGGAGAA views: start end width [1] 1 10 10 [TCAGAAACAA] [2] 14 23 10 [CCAAAATCAG] [3] …
masfenix
  • 7,736
  • 11
  • 45
  • 60
0
votes
0 answers

Optimization with Multiple Sets of Constraints

My code is being written in Matlab, but I am hoping to find some ideas for a better algorithm. The gist of the problem is: We have a list of variables (unspecified length) of x = [A B C D E .. N] each variable has a corresponding value (ranging…
0
votes
3 answers

Linked Lists and Sentinal node

So i have been asked in my homework to merge-sort 2 different sorted circular linked lists without useing a sentinal node allso the lists can be empty, my questsion is what is a sentinal node in the first place?
Mike.G
  • 373
  • 2
  • 5
  • 11
0
votes
1 answer

What does "float: function ()" when used a function parameter in pseudocode mean?

I'm working my way through a programming book which uses pseudocode for all of its examples and I came across Float: function() as a function parameter, like so: Float: UseTrapezoidRule(Float: function(), Float: xmin, Float: xmax, Integer:…
Spencer Carnage
  • 2,056
  • 2
  • 28
  • 41
0
votes
2 answers

Calculating time complexity of inner loops

So I am learning how to calculate time complexities of algorithms from Introduction to Algorithms by Cormen. The example given in the book is insertion sort: 1. for i from 2 to length[A] 2. value := A[i] 3. j := i-1 4. while j > 0 and…
An SO User
  • 24,612
  • 35
  • 133
  • 221