home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!decwrl!infopiz!lupine!jcb
- Newsgroups: comp.arch
- Subject: Re: Finding which bit set in a bit-string.
- Message-ID: <9208121953.AA05683@verbosa.ncd.com>
- From: jcb (Jim Becker)
- Date: 12 Aug 92 19:53:58 GMT
- Sender: news@NCD.COM
- References: <9208041713.AA16446@verbosa.ncd.com><1992Aug6.153710.8565@crd.ge.com><1992Aug6.175602.19433@bcars64a.bnr.ca>
- Nntp-Posting-Host: verbosa
- Return-Path: <jcb>
- To: postnews
- Lines: 51
-
-
- From: schow@bqneh3.bnr.ca (Stanley T.H. Chow)
-
- In article <1992Aug6.153710.8565@crd.ge.com> davidsen@crd.ge.com (bill davidsen) writes:
- >In article <9208041713.AA16446@verbosa.ncd.com>, jcb (Jim Becker) writes:
- >
- >| next question -- how do you create a bi-directional linked list using
- >| a single 32 bit pointer??? gee, another "trick"!! :)
- >
- > Pretty neat trick if you have an answer. Or is this a trick question
- >where you say "I didn't tell you that the range of the values is
- >constrained?" Please post to comp.compression, too, how you represent
- >any two possible 32 bit values in only 32 bits.
-
- The question is mis-phrased. The problem is really:
-
- How do you bi-directionally traverse a singly linked list without
- needing extra storage.
-
- this is a fuzzy problem definition as well, but i really am not
- interested in getting into semantics arguments. please excuse me for
- not being more verbose in the problem description (very out of
- character for me, i can assure you.. :).)
-
- my idea was to get across the concept of people asking interview
- questions that are "meaningless tricks" rather than those which
- discern problem solving techniques and experience.
-
- There are many capabilities of true double links that are not possible
- with the xor scheme.
-
- Stanley Chow InterNet: schow@BNR.CA
-
- i always use double links, and have never used tricks like this, for
- bi-directional list traversal. however, those who mention you can only
- traverse the list from first<->last don't think of retaining _two_
- pointers into the list. with _two_ pointers you can do the same as
- with _one_ in a "true" bi-directional list, albeit with XOR hacking
- and more pointer management overhead.
-
- like i said, i don't code like this. but it might be useful if you
- have memory restraints and like people to call you "King Hacker" to
- your face.. :)
-
- apologies to those who don't feel this is appropriate use of the
- comp.arch newgroup. so how many mflops come enabled with a base P5
- anyway? :*)
-
- -jim
- --
- -Jim Becker / jcb@ncd.com / Network Computing Devices, Inc. (NCD)
-