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

Recursive Algorithm

I'm new to writing algorithms, i am making a program that checks if a string is an ordered shuffle of 2 other strings. (ordered from left to right) for example string 1 = dog string 2 = cat string shuffle = dcoagt here is my algorithm…
user5525032
0
votes
1 answer

Pseudo Code - Position Finder

I am a complete novice to python and am trying to attempt pseudo code, I know pseudo code isnt a language, as shown in other questions but I cannot grasp how to simplify down code to make it work, especially after I spent a lot of time on this…
0
votes
2 answers

Dynamic algorithm to multiply elements in a sequence two at a time and find the total

I am trying to find a dynamic approach to multiply each element in a linear sequence to the following element, and do the same with the pair of elements, etc. and find the sum of all of the products. Note that any two elements cannot be multiplied.…
user3495690
  • 576
  • 3
  • 15
0
votes
0 answers

MergSort Algorithm java

So I am trying to implement a mergsort algorithm using the following pseudo code as a guide: Mergesort(A[0..n – 1]) if n > 1 copy A[0..[n / 2] – 1] to B[0..[n / 2] – 1] copy A[[n / 2]..n – 1] to C[0..[n / 2] – 1] Mergesort(B[0..[n / 2] –…
teo345
  • 11
  • 1
0
votes
1 answer

Recursively compare each item from two lists, return new list with smallest items

Doing this in Scheme/Racket The question is: Take two equal-length lists of numbers, then return a list consisting of the smallest numbers position by position. Ex: listMins( '(1 7 5) '(2 8 3) ) returns (1, 7, 3) since 1<2 and 7<8 and 3<5 I am new…
HC_
  • 1,040
  • 10
  • 23
0
votes
1 answer

XSL - check a mapping using key() against a list of items

what I would like to achieve is a solution where an existing mapping in XSL is used to verify that a number of items are supported. Items to be tested are stored in an attribute (separated by whitespace).
Sebastian
  • 1
  • 1
0
votes
2 answers

Solving maze with "islands"

I have this layout of a maze that I am having trouble thinking of how to implement a solution for: I know there are many resources for maze solving algorithms e.g. http://www.astrolog.org/labyrnth/algrithm.htm but I am not sure which algorithm is…
Bill Bo
  • 3
  • 3
0
votes
1 answer

Splitting linked list into half C programming

I am having some problem when trying to split a linked list into half. Let's say for example my linked list is 2,3,5,6,7. And the first split linked list should contain 2,3,5 and the second one should be 6,7. I have not actually came out with the…
user2531590
0
votes
0 answers

How to cluster addresses into paperboy rounds

Assume i have a list of newspaper subscribers and their geographical location (f.e. postal codes) and the distance between different locations. The goal is cluster subscribers together in 'rounds'. The size/length of a round is constrained by time:…
ErwinM
  • 5,051
  • 2
  • 23
  • 35
0
votes
0 answers

Sales area partitioning between salesreps

I have a list of zip codes from customers that need to be visited by a salesrep within a specific timeframe. I can translate the zipcodes to a matrix of distances between each zipcode if required. Assuming every customer needs to be visited within…
ErwinM
  • 5,051
  • 2
  • 23
  • 35
0
votes
3 answers

Short Circuiting: How would I write if then else with short-circuiting?

Is it possible to write a one-line if then else statement in a language that supports short-circuiting? It doesn't have to be language specific, just pseudocode. In case you didn't know, short-circuiting means that a language will evaluate exp1 ||…
AMACB
  • 1,290
  • 2
  • 18
  • 26
0
votes
0 answers

PN Sequence Generation using matlab

I am trying to generate a pn sequence using five shift registers. The shift register should be composed out of 10 states, giving us a period of 1023 bits. I was trying hard to get it done, but I am completely confused as how to generate 1023 bits…
K. Wag
  • 1
  • 1
0
votes
3 answers

Count amount of times loop runs (Big O)

I'm given a pseodocode statement as such: function testFunc(B) for j=1 to B.length-1 for i=1 to B.length-j if(B[i-1] > B[i] swap B[i-1] and B[i] And I'm told to show that this algorithm runs in Big o O(n^2) time. So I know…
user3739406
  • 254
  • 1
  • 3
  • 16
0
votes
1 answer

Uniform Cost Search algorithm pseudocode/ocaml notation

I am just wondering if anyone can help me understand some of the notation involved in this pseudocode/ocaml notation algorithm for Uniform Cost Search. This is the algorithm we were given: Input: Graph G = (V, E), Start state s, Set of goal states…
toastedDeli
  • 570
  • 5
  • 28
0
votes
0 answers

Input the number of pages and the number of pages in a packet. Cost of packet is 350 and the cost of a loose sheet is 2. Calculate the total costs

Input the number of pages and the number of pages in a packet. The cost of the packet is 350, and the cost of a loose sheet is 2. Calculate the total costs What I did was: Dim NOP, NOPIAP as, V1, V2, total as integer 'NOP is no of pages, NOPIAP is…