Wrox Programmer Forums
|
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
 
Old April 18th, 2011, 04:53 PM
Registered User
 
Join Date: Apr 2011
Posts: 2
Thanks: 1
Thanked 1 Time in 1 Post
Default 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:
WayneHeym (May 27th, 2011)
 
Old April 19th, 2011, 02:59 AM
mlb mlb is offline
Registered User
 
Join Date: Apr 2011
Posts: 1
Thanks: 0
Thanked 1 Time in 1 Post
Default

Yes. I noticed the same thing.
The Following User Says Thank You to mlb For This Useful Post:
WayneHeym (May 27th, 2011)
 
Old June 8th, 2011, 04:03 PM
Registered User
 
Join Date: Jun 2011
Posts: 1
Thanks: 0
Thanked 1 Time in 1 Post
Default 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:
Malina (June 8th, 2011)
 
Old June 8th, 2011, 04:20 PM
Registered User
 
Join Date: Apr 2011
Posts: 2
Thanks: 1
Thanked 1 Time in 1 Post
Default

Thanks for the link. I had been consulting this page for errata:

http://www.wrox.com/WileyCDA/WroxTit...Cd-ERRATA.html

and hadn't seen this listed there.
 
Old June 11th, 2011, 03:40 PM
Authorized User
 
Join Date: May 2011
Posts: 15
Thanks: 11
Thanked 0 Times in 0 Posts
Default 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
 
Old June 17th, 2013, 02:07 AM
Registered User
 
Join Date: Jun 2013
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Malina View Post
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 ??
 
Old June 17th, 2013, 12:32 PM
Authorized User
 
Join Date: May 2011
Posts: 15
Thanks: 11
Thanked 0 Times in 0 Posts
Default 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
 
Old June 19th, 2013, 11:56 AM
Registered User
 
Join Date: Jun 2013
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by WayneHeym View Post
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.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Bug or no to bug learning C using VS.Net to compil tesh All Other Wrox Books 0 February 14th, 2007 01:06 PM
Span Bug? interrupt HTML Code Clinic 4 June 20th, 2006 09:40 AM
bug in jsp sagar Pro JSP 0 July 5th, 2004 09:16 AM
Bug happens guoqi BOOK: ASP.NET Website Programming Problem-Design-Solution 0 October 13th, 2003 01:35 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.