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 January 20th, 2011, 09:56 PM
Registered User
 
Join Date: Jan 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation List Flattening

Chap.4 Linked list, list flattening problem
p.47 of 2nd ed.

I think the source code only add the child list of 2nd level, not further level,
because it only search the child of the first level nodes, and append the list of them.
I see no recursion or pointer advancing to access child of child.
Would somebody verify this, and explaim me if I am wrong?
Thanks.
 
Old May 26th, 2011, 05:08 PM
Authorized User
 
Join Date: May 2011
Posts: 15
Thanks: 11
Thanked 0 Times in 0 Posts
Lightbulb Re: List Flattening

When a child list is appended to the top level, it is attached to the end of the top level. Hence, as processing continues along the top level, nodes that had been only on the second level are reached on the top level, allowing third-level children (and so on) to be appended to the end of the top level also.

I hope this remark helps.

Regards,

Wayne

p.s. Note that, in the original problem statement, each non-NULL child pointer pointed to a *separate* doubly-liked list. Without this assumption, flattening would do strange things, such as introducing cycles into the list-with-children. That's why my original solution to this problem would have made undoing this operation with an unflattening operation impossible. I carefully reset each child pointer to NULL, making a single top-level list following the original stricture that any non-NULL child pointer (there wouldn't be any anymore) would point to a *separate* doubly-linked list. My flattening operation could be called again on the result of my flattening operation and result in no change. Be aware that after the book's flattening operation is called on a list obeying the original requirements, calling it on the result would violate those original requirements and very likely result in non-termination (or some other bad outcome).





Similar Threads
Thread Thread Starter Forum Replies Last Post
Dim list As New List(Of Testclass) dotnetDeveloper General .NET 1 January 6th, 2009 08:19 PM
Dim list As New List(Of Testclass) dotnetDeveloper Visual Basic 2008 Essentials 0 January 6th, 2009 04:04 PM
multi-column list box values moved to 2nd list box sbmvr Access VBA 1 May 14th, 2007 01:58 PM
fill dropdown list with items when parent list isaac_cm Pro PHP 1 July 10th, 2006 05:41 AM
List tablesname from database & list databasename ittorget MySQL 3 September 10th, 2005 03:06 AM





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