An error in the publishing house

xiaoxiao2021-03-06  41

The implementation of a "fast algorithm" on the "C programming language" book seems to be a fault. I did over the machine last night, the result is wrong. I spent a whole day yesterday to study this "fast algorithm". I checked a lot of books. The "fast algorithm" on this "C programming language" in K & R is a bit blamed. Its efficiency is worse - I am presenting on the paper. However, Yan Weimin's "Data Structure - C Language Description" This book is clearly clear, and several books have been checked, and the spirit of strict books is substantially the same. I did it in Turbo C 2.0 and DEV-C at night, or wrong. I checked the Chinese translation in the Internet this morning, and I downloaded an English version of my book, or the same thing ...

Still trying to think, or I am wrong; if the real author is wrong. I can also change it.

A few days later……

The fast algorithm in the P73 page in the "C programming" (Chinese version) is the wrong mistake, not the fault of the author K & R. Today, I know it in the English original version.

This program is as follows: void Q_SORT (int V [】, int, int right {Int i, last; void swap (int V []), int i, int j);

IF (Left> = Right) / * Do Nothing if Array Contains * / Return; / * Fewer Than Two Elements * / SWAP (V, Left, (Left Right) / 2); / * Move Parts ELEM * / LAST = Left; / * to v [0] * / for (i = left 1; i <= right; i ) / * partition * / if (v [i]

The Chinese version is as follows: Void Q_SORT (int V [】, int LEFT, INT RIGHT {INT I, Last; Void Swap (int V []), INT I, INT J);

IF (Left> = Right) / * Do Nothing if Array Contains * / Return; / * Fewer Than Two Elements * / SWAP (V, Left, (Left Right) / 2); / * Move Parts ELEM * / LAST = Left; / * to v [0] * / for (i = left 1; i <= right; i ) / * partition * / if (v [i]

/ * This Last has been mistaken into Right * / swap (v, limited); / * restore partition elem * / q_sort (v, left, last - 1); Q_SORT (V, Last 1, Right); } Wrong, it can be avoided as much as possible as possible.

转载请注明原文地址:https://www.9cbs.com/read-47525.html

New Post(0)