Donald E. Knuth is a computer scientist, best known as the author of the series of books on algorithms The Art of Computer Programming and the creator of the TeX typesetting system.
Questions tagged [knuth]
91 questions
0
votes
1 answer
Testing a counter for an introductory exercise for TAOCP Knuth
The exercise in the first chapter of Vol 1 of The art of computer Programming by Donald Knuth- Has to do with taking the averages of remainder steps using Euclid's gcd algorithm. My code returns the GCD perfectly and has been tested to do so. I…

jack parsons
- 165
- 1
- 13
0
votes
1 answer
Hashing - M should be a power of two
I have heard that m should be a power of two in knuth multiplicative hash. Otherwise, a power of two is always a good choice. Could somebody please tell me in an easy way why this is more efficient?
Kind regards
user6121656
0
votes
1 answer
Mastermind algorithm with long code
I currently implementing knuths mastermind algorithm
But I want to create a mastermind program, where the length of the code goes up to 15. And the amount of different colors is also 15.
So I have a problem with the Seed S, mentioned in the…

ThristBugz
- 1
- 2
0
votes
1 answer
Help fix my KMP search algorithm
Hello I am trying to write a C# version of KMP search from Algorithms in C book.
Having trouble finding the flaw in my algorithm. Would someone help?
static int KMP(string p, string str) {
int m = p.Length;
int n = str.Length;
int i;
…

shaans
- 534
- 2
- 5
0
votes
1 answer
Trying to understand Knuth's algorithm for permutations
I was recently instructed in one of my algorithm classes to use Knuth's algorithm to create permutations stored in a malloc'd array.
Here is the setup:
array is a pointer to a malloced array holding the permutation. It is intially storing n values,…

Tyler Shellberg
- 1,086
- 11
- 28
0
votes
3 answers
Knuth Permutation Algorithm Weird behaviour
I have attached a code which gives weird outputs basing on cout statements. This program essentially computes the Knuth's Permutations.
Input is say: run1
The code runs for first pass fine:
Call trace will be:
r un1
ur n1
nur 1
1nur
n1ur…

RMR
- 13
- 6
0
votes
0 answers
Mastermind Minimax algorithm in Python
I am trying to implement Donald Knuth's algorithm for solving Mastermind, as detailed here: http://en.wikipedia.org/wiki/Mastermind_(board_game)#Five-guess_algorithm
Most of my code is working, but I can't get the Minimax step to work (in the…

dwally89
- 51
- 2
- 7
0
votes
0 answers
How can we obtain the same number by taking Roman Numerals?
On page 2 of The Art of Computer Programming, Volume 1, Fascicle 1, Knuth (2005) writes, "The same number may also be obtained in a simpler way by taking Roman Numerals."
This is part of Knuth's humorous explanation of the identifying number of the…

Shaun Luttin
- 133,272
- 81
- 405
- 467
0
votes
0 answers
Implementing Knuths Mastermind Algorithm Java
I am trying to implement Knuths Mastermind Algorithm in java. The algorithm is explained in this paper, paper. This is how I have implemented it so far but it takes more than the maximum 5 guesses than the algorithm should take.
private static…

Virus7711
- 27
- 1
- 5
0
votes
2 answers
Knuth Shuffle Multiple Arrays in the same way
I am using a knuth shuffle to randomise an array. I would like to be able to add another array and have it randomise in the same way. I had previously thought of separating the array within the string, such as ['A|1|I,B|2|II,C|3|III,D|4|IV'] etc.
On…

redditor
- 4,196
- 1
- 19
- 40
0
votes
1 answer
Evaluating Random Number Generator as per Knuth [2, 41-79]
I have created a random number generator using gettimeofday() function, in C. Now,I need to evaluate this using statistical or empirical methods developed by Knuth. I searched exhaustively for the same, but could not find a workable solution. Or I…

Krishna
- 425
- 3
- 6
- 14
-1
votes
3 answers
Evaluating Knuth's arrow notation in a function
I am having trouble calculating Knuth's arrow notation, which is ↑ and can be found here, within a function. What I've made so far is:
int arrowCount = (int)arrowNum.Value; // Part of
BigInteger a = (int)aNum.Value; // the input I
BigInteger b…

Darkrifts
- 211
- 2
- 11
-2
votes
1 answer
I need to convert list in java into java array with while loop
I get the question about choosing a random word from user input using Knuth's shuffling algorithm, but the problem is I have the constraint of using some specific libraries.
(here is the link for more details - my part is to form the random word…

DTJ
- 5
- 2
-3
votes
2 answers
Java: Random permutation without importing java.util
There are many different instructions to do random permutation on the Internet, but they all use libraries. Is there any way to do random permutation without using any built-in library? I know how to generate random numbers using Math.random(). Does…

studenthahahoho
- 21
- 4
-4
votes
2 answers
Knuth's Art of Programming Third Edition and the Euclidean algorithm example
I just started reading volume 1 of Knuth's art of programming and got to the section on page 4 where he describes the Euclidean algorithm. He states the steps to find the greatest common divisor of two numbers. You can read more about it here…

Lee Dale
- 1,136
- 9
- 20