 |
BOOK Programming Interviews Exposed: Secrets to Landing Your Next Job 2nd Ed ISBN: 978-0-470-12167-2  | This is the forum to discuss the Wrox book Programming Interviews Exposed: Secrets to Landing Your Next Job, 2nd Edition by John Mongan, Noah Suojanen, Eric Giguère; ISBN: 9780470121672 |
|
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK Programming Interviews Exposed: Secrets to Landing Your Next Job 2nd Ed ISBN: 978-0-470-12167-2 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

April 18th, 2011, 04:53 PM
|
|
Registered User
|
|
Join Date: Apr 2011
Posts: 2
Thanks: 1
Thanked 1 Time in 1 Post
|
|
determineTermination bug
I believe the function determineTermination in Chapter 4 to determine if a list is acyclic or cyclic has a bug.
The function starts with:
fast = slow = head;
Then, without modifying fast or slow, checks:
else if ( fast==slow || ...)
return true;
Assuming the head exists and the list has at least two nodes (the first if condition), determineTermination will always return true.
|
|
The Following User Says Thank You to Malina For This Useful Post:
|
|
|

April 19th, 2011, 02:59 AM
|
|
Registered User
|
|
Join Date: Apr 2011
Posts: 1
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Yes. I noticed the same thing.
|
|
The Following User Says Thank You to mlb For This Useful Post:
|
|
|

June 8th, 2011, 04:03 PM
|
|
Registered User
|
|
Join Date: Jun 2011
Posts: 1
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Errata
Yes. Fortunately they have addressed this in the errata: http://www.wiley.com/legacy/compbook...ew/errata.html
|
|
The Following User Says Thank You to User5910 For This Useful Post:
|
|
|

June 11th, 2011, 03:40 PM
|
|
Authorized User
|
|
Join Date: May 2011
Posts: 15
Thanks: 11
Thanked 0 Times in 0 Posts
|
|
Indicated page of Errata is apparently for first edition
As I'm looking at the second edition, not the first edition, I can't be sure, but it appears that the page http://www.wiley.com/legacy/compbook...ew/errata.html is a list of errata for the first edition, not the second. The page numbers don't match the second edition. Sadly, it appears that only one of these four errors was corrected in the second edition. Perhaps the additional author for that edition, Eric Giguère, wasn't aware of this errata page.
Regards,
Wayne
|
|

June 17th, 2013, 02:07 AM
|
|
Registered User
|
|
Join Date: Jun 2013
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
Originally Posted by Malina
I believe the function determineTermination in Chapter 4 to determine if a list is acyclic or cyclic has a bug.
The function starts with:
fast = slow = head;
Then, without modifying fast or slow, checks:
else if ( fast==slow || ...)
return true;
Assuming the head exists and the list has at least two nodes (the first if condition), determineTermination will always return true.
|
Actually, can't the check for fast==slow and fast->next == slow be moved to the end of the loop such that there is no need for additional ugly coding with another variable first ??
|
|

June 17th, 2013, 12:32 PM
|
|
Authorized User
|
|
Join Date: May 2011
Posts: 15
Thanks: 11
Thanked 0 Times in 0 Posts
|
|
In search of elegance
I appreciate your pointing out the inelegance of using an extra variable (in this case, the variable "first"). Fortunately, the newest edition (the third edition, copyright 2013) of this book observes that it is valuable "to start the fast pointer one node ahead of the slow pointer so they're not equal to begin with." (p. 59) Hence, the trouble with the earlier published versions is avoided without resorting to the inelegance of using an extra variable.
Regards,
Wayne
|
|

June 19th, 2013, 11:56 AM
|
|
Registered User
|
|
Join Date: Jun 2013
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
Originally Posted by WayneHeym
I appreciate your pointing out the inelegance of using an extra variable (in this case, the variable "first"). Fortunately, the newest edition (the third edition, copyright 2013) of this book observes that it is valuable "to start the fast pointer one node ahead of the slow pointer so they're not equal to begin with." (p. 59) Hence, the trouble with the earlier published versions is avoided without resorting to the inelegance of using an extra variable.
Regards,
Wayne
|
Thanks Wayne for the positive reply.
|
|
 |