Print linked list backwards
- From: "joshc" <josh.curtz@xxxxxxxxx>
- Date: 9 Dec 2006 14:32:43 -0800
In an interview for an embedded software position recently I was asked
to write code, in C, for printing the contents of a linked list
backwards. After a few minutes I came up with the recursive solution.
Being that recursion is frowned upon in embedded software, the answer
was not what the interviewer expected, but alas it was correct. I asked
some friends how they would have answered and another answer is to
reverse the list and then print the contents as you reverse the list a
second time.
I was searching for any other possible solutions and it seems these 2
are the most common solutions. However, someone mentioned that if there
is a constraint that the list is unmodifiable, there is another
solution but didn't provide that solution. Can anyone provide a
solution besides the 2 I mentioned, especially one that would work
without modifying the list?
Thanks,
Josh
.
- Follow-Ups:
- Re: Print linked list backwards
- From: Richard Harter
- Re: Print linked list backwards
- From: Ben Pfaff
- Re: Print linked list backwards
- From: Sourcerer
- Re: Print linked list backwards
- From: CBFalconer
- Re: Print linked list backwards
- From: Ben Bacarisse
- Re: Print linked list backwards
- Prev by Date: Re: liitle endian
- Next by Date: Re: int a[5] .. difference between a and &a
- Previous by thread: Pointer to extern char?
- Next by thread: Re: Print linked list backwards
- Index(es):
Relevant Pages
|