FAQ Database Discussion Community


Time-complexity of code containing nested loops

algorithm,time-complexity,pseudocode
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...

Python TypeError in string formatting code

python,pseudocode
I have a question where I have to convert from pseudo code into Python and i have an error that goes: Traceback (most recent call last): File "C:/Users/Toshiba/Documents/Stevens stuff/Rings work.py", line 16, in <module> Rings[i] = int(input(("How many teeth are on ring #i ?") % (i + 1))) TypeError: not...

Iterative version of the Bron–Kerbosch algorithm?

algorithm,graph-algorithm,pseudocode
The Bron–Kerbosch algorithm is a method for listing all maximal cliques of a graph. I recently implemented the algorithm successfully just for fun. The downside is that the algorithm is recursive, and thus can only be ran on tiny graphs until the stack overflows. It should be possible to make...

Mathmatical expressions in pseudo code

python,logic,pseudocode,mathematical-expressions
I have pseudo code am trying to implement in python but I cant seem to remember what p ← 0 would mean in logic or calculus. Thanks in advance

Convert random hex values to CJK characters

unicode,pseudocode
I've got a list of random hex values of 3 digits each: List<hex> hexes = "A19", "8EB", "5EF" I'd like to compress them into a list of single characters that can be copied and pasted, then be decompressed later on. For asthetic reasons, it would be nice if they were...

How to represents initialization of empty list in python into pseudocode

python,pseudocode
I want to ask how to represents initialization of empty list into pseudocode, my code is following below: cat1 = [] cat2 = [] cat3 = [] cat4 = [] cat5 = [] cat6 = [] cat7 = [] In here I want to ask how to represent those things...

How to extract derivation rules from a bracketed parse tree?

java,parsing,recursion,nlp,pseudocode
I have a lot of parse trees like this: ( S ( NP-SBJ ( PRP I ) ) ( [email protected] ( VP ( VBP have ) ( NP ( DT a ) ( [email protected] ( NN savings ) ( NN account ) ) ) ) ( . . ) )...

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

java,pseudocode
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 specified...

Pseudo code for integrating GPS and accelerometer data using Kalman filters

navigation,gps,pseudocode,kalman-filter
I have some accelerometer sensors that gather data every second: AC.X AC.Y AC.Z 9234 -0.98 -0.10 0.03 9235 -0.98 -0.10 0.03 9236 -0.98 -0.10 0.03 9237 -0.98 -0.10 0.03 9238 -0.98 -0.10 0.03 9239 -0.98 -0.10 0.03 The GPS data set gets captured in longer intervals: X1 X2 X3 X4...

Euclidean algorithm pseudocode conversion to Swift?

ios,swift,pseudocode
I have been working on a function for reducing fractions in Swift, and came across the Euclidean algorithm for finding the greatest common factor (http://en.wikipedia.org/wiki/Euclidean_algorithm) I converted the pseudo code into swift, but yet I am confused how this is going to give me the greatest common factor if it...

Not sure what this pseudo-code is saying

dynamic,dynamic-programming,pseudocode
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 dictionary. The third line, means to set an...

How does this if statement work? It appears to have no boolean expression

arrays,if-statement,pseudocode
This is a snippet of code. I am unsure how the if statement on the second last line works? It doesn't have a boolean expression like 'if A[n − 1, j] == x' or anything like that. Could someone explain what it actually does to me? Thanks Connected(A[0..n − 1,...

Check for currency sign [closed]

php,pseudocode
I found on the web a lots of complicated functions and options to see if the string starts with X this all where to complicated or to big how Can I do it in the fastest way for this Pseudocode if price != startswith $ or € echo "<td>Free</td>" else...

Merge Sort algorithm isn't merging properly

vba,pseudocode,mergesort
So, I do know what a merge sort is supposed to do, and I can somewhat visualize it now. Recursively splitting until only one element is left in the array, since an array of one element is already sorted, it reduces the amount of work needed for each recursion, and...

How to assign -INFINITY amongst others to multiple variables?

matlab,pseudocode
I have this line of pseudocode that I am trying to translate in Matlab: (maxSum, maxStartIndex, maxEndIndex) := (-INFINITY, 0, 0) I have translated the second and third variables simply assigning a 0: maxStartIndex=0; maxEndIndex=0; How should I translate this line? maxSum= -INFINITY I have not find reference for this....

what does returning -1 mean in a pseudocode

c++,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<n) return i; else return...

How to compute the grand sum of a matrix?

r,pseudocode
I have a matrix of size 4 x 10. I want to compute the sum all possible entries of the sum. In other words, if you have a 2 x 2 matrix 2 3 4 1 then there are 2^2 sums (2 + 3, 2 + 1) and (4 +...

Ambiguous pseudocode phrase

c++,bit-manipulation,pseudocode
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 get lowest...

Angle between two lines beginning at one side of the line

math,geometry,line,pseudocode,angle
I have two lines specified by two points with x and y coordinate each. The first point (where the lines begin) is equal meaning that I have 3 points A, B and C where one line is from A to B and the other one from A to C. I...

Pseudocode for progressing a poker game

algorithm,pseudocode,poker
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 determine winners Game ends abruptly,...

calculating the average length of split vector

r,pseudocode
Consider the following vector (or dataframe or datatable) a = data.frame(x = c(2, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1)) x represents a 'state', either 1 or 2. The vector data represents spatial data and I am looking to get the average length per...

Mandelbrot set defined by a specific function

javascript,canvas,pseudocode,fractals,mandelbrot
I'm experimenting with canvas and I'm trying to modify this piece of code, but unfortunately I don't understand some parts of it. My question is - how to customize the above code to be defined for example by f(z) = c^e(-z) (the formula is taken from a book with fractal...

A game I'm writing for my programming concepts class [closed]

pseudocode
The randomcoord function was given to me in the project. That's why it's not mentioned anywhere else. This is in pseudocode and I just wanted to check if there is anything wrong with it. The program is supposed to be a game with a 10x10 grid where the player starts...

An algorithm that return true if a given string match a given pattern

algorithm,pseudocode
Anyone has an idea of how to implement an algorithm finding if string match a specific pattern?( not contains it!) without the use of regular expression... Rules are,the pattern can hold sign like ? or *: ? = one character or number * = multiple characters or number or non...

Dictionary Value lookup performance

c#,performance,dictionary,lookup,pseudocode
I am working on a small project but have run into a performance roadblock. I have a Dictionary<string, string>() 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 Dictionary where the value.ToCharArray().OrderBy(x => x)...

Dynamic programming: finding largest triangle

algorithm,dynamic-programming,pseudocode
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...