Questions tagged [knuth]

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.

91 questions
1
vote
1 answer

segmentation fault and hang in assembly code

I am re-implementing Knuth's program P from Fascicle 1: generate the first 500 primes. The program generates the first 25 primes without problems. That code is below: $ cat progp.S /* print the first 500 primes */ #define n %bx #define j …
spew
  • 13
  • 3
1
vote
3 answers

Java permutations with least random numbers possible

I want to generate a permutation of an array a and I don't want to use utility functions such as java.util.Collections(). The permutations should be randomized and every permutation should be possible to occur - but there is no need for an equally…
Gnark
  • 4,080
  • 7
  • 33
  • 44
0
votes
1 answer

How to link different but similar structs in a linked circular list?

I'm trying to implement Knuth's Algorithm X but I'm having trouble with generating the linked list. My column headers and data points are different types, but similar in build. type ListObject interface{} type Data struct { L, R, U, D, C…
Erik
  • 11
0
votes
0 answers

Setting up secondary condition for exact cover problem

I understand and have coded the Knuth’s dancing link algorithm for the exact cover problem. What I have a problem with is setting up the options matrix, mainly secondary items. The problem I am trying to solve is the enumeration of 3-configurations…
David
  • 1
0
votes
0 answers

How to get left or right node in tsearch node

I used the example (exactly that example) given here: https://man7.org/linux/man-pages/man3/tsearch.3.html But I could not use LEFT macro or struct node_t struct. I just want to move left or right node by myself because I need to check the tree…
dogus yuksel
  • 111
  • 1
  • 5
0
votes
1 answer

Why does the ADD command in Donald Knuths number one program written on MIX set the overflow to ON?

Here is the program: STZ 1 ENNX 1 STX 1(0:1) SLAX 1 ENNA 1 INCX 1 ENT1 1 SRC 1 ADD 1 DEC1 -1 STZ 1 CMPA 1 MOVE -1,1(1) NUM 1 CHAR 1 HLT 1 What I know so far: STZ 1 sets the next instruction to NOP so the second instruction can be ignored According…
Jonathan Harker
  • 78
  • 1
  • 11
0
votes
1 answer

Knuth GC stack overflow prevention algorithm - how does it work?

I'm reading the Garbage Collection. Algorithmis for Automatic Dynamic Memory Management book, and trying to write a blog post about it. I'm concentrating on mark-sweep chapter, where authors discuss using auxiliary stacks, to avoid mark-sweep to…
0
votes
1 answer

Replace numbers with words? Fisher-Yates randomization

I found very interesting stuff about Fisher-Yates and randomization here: How to randomize (shuffle) a JavaScript array? Content! //function source code from…
0
votes
4 answers

How do you implement Knuth's Toposort in C?

I am trying to implement Knuth's topological sorting algorithm in C. When I search for online resources, all I see are implementations of Kahn's Algorithm and this kind of confuses me. Are they both the same? Or are they different? Here is my…
lambduh
  • 43
  • 11
0
votes
0 answers

What are the applications of Knuth/Fisher-yates algorithm

This algorithm guarantees to rearrange the elements in uniformly random order. What does uniformly random mean ?
0
votes
2 answers

minimal cyclic sub string in a bigger cyclic string

I am trying to find an algorithm that culd return the length of the shortest cyclic sub string in a larger cyclic string. A cyclic string would be defined as a concatenation of tow or more identicle strings, e.g. "abababab", or "aaaa"... Now in a…
Mortalus
  • 10,574
  • 11
  • 67
  • 117
0
votes
0 answers

Can anybody shed light on this System.Random algorithm?

Can anybody shed light on the impact of using a different value here? CLR System.Random (random.cs, 61) appears to cite the algorithm used //This algorithm comes from Numerical Recipes in C (2nd Ed.) and uses this line of code (random.cs, 80) …
Rex Henderson
  • 412
  • 2
  • 7
0
votes
1 answer

"Exact Cover" Wikipedia detailed example, question about the very last step

I'm following the great Wikipedia example of solving a simple "Exact Cover" problem using Knuth's "Dancing Links" DLX algorithm - example is here: https://en.wikipedia.org/wiki/Knuth%27s_Algorithm_X#Example On the VERY LAST STEP they show the…
Mark Bennett
  • 1,446
  • 2
  • 19
  • 37
0
votes
1 answer

Knuth's Optimal Binary Search tree in O(n^2)

I am trying to implement Knuth's optimal binary search tree which can run in O(n^2) time. I have the code which is running in O(n^3). float P[N + 1] = {0, .13, .12, .15, .05, .12, .10, .08, .09, .03, .13}; float sum[N + 1] = {0, .13, .25, .40, .45,…
0
votes
1 answer

How do I change the H sequence in this shell sort?

I'd like to be able to modify this code so that it uses Knuth's H sequence instead of this one. If anyone could help, I'd greatly appreciate it. public class ShellSort { static int iterations = 0; static void insert(double[] a, int h, int r,…