In his classical paper Permutation Generation Methods, Computing Surveys 1977, Robert Sedgewick presents his "Algorithm 1" on page 140 like this:procedure permutations(N); begin ...
I want to turn a variable (let's say with a current value of 20) into a value that is <variable> minutes (in to), so a variable of 20 turns into 1200 (the number of seconds in 20 minutes)How ...
Specifically:Write a function (in python, java or pseudocode) average(nums) that prints the mean of the numbers in list nums, and returns a tuple:The tuple's first element is the index of the ...
The A* search algorithm is usually implemented using an open and a closed list (or other data structures). Recently I read in Wikpedia a pseudocode that makes use only of an open list.Is the closed ...
Here is a problem that was in a past exam for Advanced algorithms in my studies,it's on 5 points over 3 hours so should take approximately 1H but I am struggling to find the solution for the first ...
I wrote the following pice of pseudocode. It is about the classic producer-consumer queue in multithreading, but I am trying to add a graceful shutdown mechanism. I want consumeItem to keep working ...
I came across a practice problem:I already wrote out the pseudocode for this, really easily too, just made the calls to the function as mention in the problem statement. But I was really struggling ...
The input is an N by N matrix of numbers. Each individual row is increasing from left to right. Each individual column is increasing from top to bottom. The example of a matrix is given below with N = ...
Statistics are often calculated with varying amounts of input data. Write a program that takes any number of non-negative integers as input, and outputs the average (using integer division) and max. A ...
I have an input string S and three parameters: a prefix string (denoted by A), a suffix string (denoted by B) and a set N of strings.Given these three parameters, is it possible to generate a single ...
I wanted to get a sanity check here. I believe the algorithm listed on the wikipedia page for the Day–Stout–Warren algorithm for balancing BSTs has a problem.This pseudocode purports to turn a BST ...
I'm a graduate student in biology that encountered a problem that I really struggled solving in my project. I solved it using an iterative approach (will describe more below) but was curious if there ...
Each street in Monopoly is comprised of 2 or 3 different properties.When a user upgrades a street, it will build 1 of 3 buildings on the appropriate property.House - least valuable, will build this ...
How can I calculate the maximum possible sum of vertices in a weighted DAG excluding vertices directly connected by an edge? This is a vertex selection problem where each vertex has a weight.In this ...
GOALThe goal is to use a chained hash table, with a hashing function h that satisfies the Simple Uniform Hashing Assumption, to store some numbers (the same number, if inserted multiple times, is ...