Questions tagged [pseudocode]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
118 views

Parallel Algorithm Pseudocode: Helman-JaJa Listrank

What would Helman-JaJa listrank pseudocode be like? I tried looking around but all I found were "prosecode" descriptions (eg pp. 18-19 here) which I find kinda hard to follow.
jon doyle's user avatar
2 votes
1 answer
69 views

Declaring a JavaScript object in pseudocode

What's the proper way to declare an object in pseudocode. For example: const car = {type:"Fiat", model:"500", color:"white"}; Would ...
waldo 's user avatar
  • 21
27 votes
6 answers
6k views

Is there a "Standard Algorithm" language, as used in academic papers?

In many academic papers algorithms are described. They seem to use similar "syntax". Is there a standard for this language? If I want to describe an algorithm, would I improvise my ...
Makketronix's user avatar
0 votes
0 answers
46 views

As level computer science paper 2 question

Could someone help explain the logic of the ms . The question is The RandomChar() module is to be modified so that alphabetic characters are generated twice as often as numeric characters. Describe ...
Nathania's user avatar
0 votes
3 answers
129 views

How to write recursive function in pseudocode for this number $a_n=n!+2^n$

I need to write recursive function in pseudocode for n-th number term of $a_n=n!+2^n$. Whole code should be contained in one function with $n$ as function argument.
DScounterGO's user avatar
1 vote
1 answer
103 views

How can I convert the pseudo-code that solves maximum subarray problem to Python code?

I'm reading Algorithm Design and Application, by Michael T. Goodrich and Robert Tamassia, and sometimes the pseudo-code in this book doesn't make sense at all. At chapter one they show us 3 solutions ...
André Carvalho's user avatar
0 votes
0 answers
37 views

What does this mean for i from 1 to n in psuedocode?

I am enrolled in the Algorithmic Toolbox course on Coursera, and as apart of the first week that are walking us through how to implement algorithms. But I am having trouble understanding the symbol ...
Jermaine Tucker's user avatar
1 vote
1 answer
92 views

A* pseudocode problem

What is the difference between this two pseudocode and which one should i implement? ...
matthews24's user avatar
1 vote
0 answers
55 views

First piece of code in scientific papers

What is the first/oldest piece of source code shown in an scientific paper or journal? I am looking for source code of assembly or a high level programming language which was real (implemented) and ...
Peter Kofler's user avatar
-1 votes
3 answers
2k views

What is a pseudocode of try-catch?

What is a pseudocode of try-catch? Is it this? **Try** SOMETHING If you succeed Do nothing special Else, if you didn't succeed Do what's described in the **Catch** block Anyway, either if ...
alistro's user avatar
  • 11
0 votes
1 answer
121 views

What would be a pseudocode of try-catch pattern, common in generally all programming languages?

What would be a pseudocode of try-catch pattern, common in generally all programming languages? Perhaps the following? ...
codinglover's user avatar
2 votes
2 answers
201 views

Algorithm that will find the minimum number of steps to get from state $j$ to state $i$

Consider an adjacency matrix $A$ with elements $[A]_{ij}=1$ if one can reach state $i$ from state $j$ in one timestep, and $0$ otherwise. The matrix $[A^k]_{ij}$ represents the number of paths that ...
Slim Shady's user avatar
0 votes
1 answer
117 views

I'm studying a trie tree, where I want to delete a word, Please make me understand the algorithm

...
Adil Nehal's user avatar
0 votes
0 answers
347 views

Minimize the average distance from each cities to the closest hospitals

There are n cities [1, 2, 3, .... n] and k available hospitals. k < n. We need to place hospitals into the cities. How to place these hospitals to minimize the average distance from each cities to ...
noname's user avatar
  • 1
0 votes
2 answers
122 views

Find distinict elements in an array in $O(n)$ time

Given this pseudo-code that finds the number of distinct elements in the given array: ...
Omri Braha's user avatar
2 votes
1 answer
166 views

Sort a $d$-sorted array

An array is $d$-sorted if every key in the array is located at a distance at most $d$ from its location in the sorted array. I need to write an algorithm that get a $d$-sorted array of length $n$ and ...
Omri Braha's user avatar
0 votes
0 answers
715 views

Converting python/numpy code into pseudocode

I've written some code that uses numpy's array broadcasting logic and need to convert it to pseudocode. Basically, $w\in R^{T}$ and $\beta\in R^{T \times M}$. If you have the following code using ...
stevew's user avatar
  • 101
1 vote
1 answer
20 views

Two "bubble" loops in pseudocode; would they return the same thing?

I am trying to create a new form of a bubble loop and want to see if they would return the same truth values during runtime. Could I get a second pair of eyes to confirm if this is the case? Note: ...
Ryan C's user avatar
  • 11
0 votes
1 answer
177 views

Combinations (repetition not allowed & order not important)

How to compute a table of numbers (all possibilities), where repetition is not allowed and order is not important. Example: I have a set of prime numbers. In this example I have four: {3,5,7,11}, but ...
Natural Number Guy's user avatar
2 votes
1 answer
126 views

Transitions between lexicographical orders

I have six characters: (,),[,],{,}. They are stored lexicographically: '(' < ')' < '[' < ']' < '{' < '}'. So I can store all balanced parenthesis sequences of length $n$ ...
Alexander's user avatar
0 votes
2 answers
859 views

Given a sorted array with n integers, how to find the element that has no duplicates?

I am given a sorted array with n integers. All of the elements repeat exactly twice, while there is one element without duplicate. I need to solve it as efficient as it is possible by divide-and-...
Diana 's user avatar
  • 25
1 vote
1 answer
30 views

Notations for dealing with generators in algorithms

This question is about generators, which are functions that return an item from a (usually very large or infinite) set on demand, an example from Python is: ...
DjaouadNM's user avatar
  • 133
1 vote
0 answers
57 views

Merge Sort sentinel: What if your array contains Integer.MAX_VALUE?

I'm just getting my head round Merge Sort, and I was wondering whether the use of the sentinel value was considered good practice in the real world, or mostly an algorithmic conceit? I get that it ...
robhogg's user avatar
  • 11
2 votes
1 answer
106 views

What is the SetHorspool string searching algorithm and how is it implemented?

What is the SetHorspool string searching algorithm with pseudo-code so it can be easily implemented in a language of choice? This has been implemented in 2 libraries I have come across: https://app-...
Suminda Sirinath S. Dharmasena's user avatar
0 votes
0 answers
39 views

data structure Q with priotry queue which allow us to find the median in $O(1)$ and the data structure need to support the following operations

I've got this question from an exercise and i'm not sure if it is possible to do so Think of new data structure Q with priotry queue which allow us to find the median in $O(1)$ and the data structure ...
convxy's user avatar
  • 211
0 votes
2 answers
85 views

Two-Sum - Range Allowance Algorithm Design

🧩 What is the best way to find if there are two individual capacities that sum to a total capacity within a range of plus and minus the total capacity? Optimize for runtime over memory complexity. ...
AdamHurwitz's user avatar
0 votes
2 answers
325 views

Two-Sum - Pre-sort Optimization Algorithm Design

🧩 Is it possible to optimize the runtime of a two-sum solution by receiving a pre-sorted input either in ascending or descending order? 🚀 Original Two-Sum Determine whether there are two items whose ...
AdamHurwitz's user avatar
0 votes
1 answer
532 views

Explanation of pseudocode and time complexity analysis

I am trying to work my way through some computer science training and I am not able to properly understand the following pseudo code: ...
pac234's user avatar
  • 81
0 votes
1 answer
185 views

Find the intersection point between two sorted arrays with unknown lengths in lesser than O(n)

Two sorted arrays of positive integers, X[] and Y[] are given.But, the array sizes are unknown to us. We may assume that accessing any index beyond the last element of the array returns -1. The ...
Swarnabja Bhaumik's user avatar
1 vote
1 answer
2k views

Convention of a += operator in pseudocode

I have to write some algorithm in pseudocode for a paper. For this I have the "$\leftarrow$" to assign a value. $x \leftarrow y^2$ now I want to write a method which adds to the variable. In ...
cagcoach's user avatar
  • 123
2 votes
0 answers
53 views

Minimizing the sum of differences in a pair [duplicate]

You have two arrays, a and b Both contain n elements, all positive and distinct. you have to create a pair, by taking one number from each array, such that the sum of the differences of the pairs ...
Sharhad Bashar's user avatar
0 votes
0 answers
33 views

What is the runtime of this pseudocode?

I need help figuring out the runtime of the following pseudocode. I believe it is O(|E| + |V|), but I'm not totally sure... ...
Jerome Waltz's user avatar
0 votes
1 answer
651 views

pseudocode to split number value to array of numbers

How to write a pseudocode to split a number value to array of numbers? Let's say the number value is 12345. I need to convert it into [1,2,3,4,5].
camille's user avatar
  • 103
-1 votes
3 answers
12k views

Please check my answer to a pseudocode CASE statement question

This is a pseudocode question in my IGCSE CompSci textbook: Use a CASE statement to display the day of the week if the variable ...
user avatar
2 votes
1 answer
755 views

Pseudo code of recursive method of printing all permutations of $n$ given integers

I really don't understand this pseudo code. The function prints all permutations of $n$ given integers, assuming that all numbers are different. Is there a way to explain this code more easily as I ...
NimaJan's user avatar
  • 343
2 votes
0 answers
103 views

Determine the number of self-crossings for an irregular orientation of an n-pointed star, whose vertices lie on the boundary of a circle

I need to create an algorithm that will output the number of self-crossings for an irregular orientation of an n-pointed star, whose vertices lie on the boundary of a circle. The sample input is as ...
flutterbug98's user avatar
0 votes
0 answers
20 views

Run time of pseudo code in big theta notation [duplicate]

I am looking for the run time of the following pseudo code. ...
gamma's user avatar
  • 115
0 votes
0 answers
336 views

Tracing BST Pseudocode for Insertion

I'm having real trouble tracing some pseudocode for insetion into a Binary Search Tree. I need to understand this in order to be able to teach it, but I think there are flaws in the material. For ...
Robin Andrews's user avatar
1 vote
1 answer
299 views

QuickSort of linked lists optimised for duplicates

This is an past year question for a school exam that I do not suggested solutions for. Problem Description Quick Sort is not stable because of need to swap values in array when partition is done. If ...
Prashin Jeevaganth's user avatar
1 vote
1 answer
974 views

dynamic pseudo-code for simplified coin changing algorithm

As a homework exercise our professor presented to us a simplified version of the coin-changing problem in which we do not need to minimize the number of coins used or track the number of possible ...
Trixie the Cat's user avatar
0 votes
1 answer
526 views

What is the fastest algorithm of generating all possible permutations (within a given set of constraints) of a multidimensional array?

There is D-dimensional array A. The number D and the size Sd of every dimension d=1..D is input from keyboard. There is also 1-dimensional array E of size N. It consists of unique integer numbers 0..N-...
layer19's user avatar
  • 11
0 votes
0 answers
3k views

Pseudocode for Userdefined Data Types

In the pseudocode guide for my syllabus, an example of a record data type is given as below: ...
Robin Andrews's user avatar
0 votes
1 answer
138 views

Divide and Conquer Algorithm to calculate $a^n$

I am attempting to create an algorithm which given the value of $a \in \mathbb{R}$ and $b \in \mathbb{N}$, calculate $a^n$. So for example, using the Java language pattern, the algorithm will be ...
Omari Celestine's user avatar
0 votes
1 answer
35 views

For Loop Range with Smaller Number on Right

Simple question from an algorithm noob... If $i=1$ then the inner loop will include what I believe to be an invalid range. Is this acceptable pseudocode? ...
Chrismo16's user avatar
2 votes
1 answer
192 views

Help writing a dynamic programming algorithm in English

It’s Friday night and you have $n$ parties to go to. Party $i$ has a start time $s_i$ end time $t_i$ and a value $v_i \ge 0$. Think of the value as an indicator of how excited you are about that party....
Colin Null's user avatar
0 votes
1 answer
68 views

CLRS pseudocode involving both subscripting and property access of a data structure

In Introduction to Algorithms, the stack data structure's enqueue operation has the following pseudocode ...
Curious's user avatar
  • 273
1 vote
1 answer
822 views

Probability that a random hash from a universal family is injective

This is a homework question, I don't want an actual answer, but rather guidance on how to obtain the correct answer. The question is as follows: In class we saw universal hashing as the solution to ...
Colin Null's user avatar
1 vote
1 answer
200 views

Answering questions about the recurrence of certain aspects of an algorithm

I am thoroughly confused by a problem that was brought up in class: Given the following pseudocode for a function RANDOM which generates a random number based off of recursion: ...
Nat Porter's user avatar
-2 votes
2 answers
2k views

Writing pseudocode to be language independent

There exist 5 rules for any pseudocode , one of these rules is : "Keep statements language independent" I don't understand what is this rule is saying. So can someone explain it and then give an ...
AAA's user avatar
  • 43
14 votes
2 answers
4k views

Will this program terminate for every Integer?

In a Part Test for GATE Preparation there was a question : f(n): if n is even: f(n) = n/2 else f(n) = f(f(n-1)) I answered "It will terminate for all ...
Prakhar Londhe's user avatar