Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
07-31-2004, 02:04 PM
|
#1
|
Member
Registered: Jul 2004
Location: India
Distribution: Redhat-8
Posts: 35
Rep:
|
problem with linklist
hai
suppose i had a linklist.given the address of a particular node.I had to delete the previous node of the given node.It is not a circular or doubly linked list. also I dont have the address of the starting node of the linkedlist.(This was a job interview question)
|
|
|
07-31-2004, 02:12 PM
|
#2
|
Member
Registered: Mar 2003
Posts: 804
Rep:
|
well, i'm going to say that's not possible.
*prepares to possibly eat words*
|
|
|
07-31-2004, 02:35 PM
|
#3
|
Senior Member
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536
Rep: 
|
Quote:
Originally posted by infamous41md
*prepares to possibly eat words*
|
Rest assured...
|
|
|
07-31-2004, 03:05 PM
|
#4
|
Senior Member
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263
Rep:
|
I would say it aint(safely) possible but someone please correct me if im wrong, I hope this aint a stupid question where you do have an address before the node you wanna delete but its not actually the start of the list. I assume that all you have is the address of a node and the struct of the node - which is what you say above.
if i had to do it i would probably just search the heap for the address i'd been given and try and fit a node stuct over it, if it fitted i'd have the address of the previous node and i'd just delete it normally. i could also use LD_PRELOAD to override malloc() and generate a list of all allocations that you search through, there are architecture dependant solutions such as recording all memory writes with a debug interrupt then check the list against the address you were passed to find where it was written(the previous node) but i think thats going over the top.
|
|
|
07-31-2004, 04:13 PM
|
#5
|
Senior Member
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536
Rep: 
|
I won't say that's impossible, but IMHO it's a bit like deleting a file by means of editing /dev/hda1.

|
|
|
07-31-2004, 04:21 PM
|
#6
|
Senior Member
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263
Rep:
|
by Hko
I won't say that's impossible, but IMHO it's a bit like deleting a file by means of editing /dev/hda1.
yeah pretty much, and for anything other than demonstration purposes i would never do it and would make that clear in an interview.
|
|
|
07-31-2004, 05:27 PM
|
#7
|
Senior Member
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536
Rep: 
|
Quote:
Originally posted by kev82
[....] and would make that clear in an interview.
|
LOL. Good point!
|
|
|
All times are GMT -5. The time now is 11:18 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|