LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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


Reply
  Search this Thread
Old 07-31-2004, 02:04 PM   #1
vijeesh_ep
Member
 
Registered: Jul 2004
Location: India
Distribution: Redhat-8
Posts: 35

Rep: Reputation: 15
Question 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)
 
Old 07-31-2004, 02:12 PM   #2
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
well, i'm going to say that's not possible.

*prepares to possibly eat words*
 
Old 07-31-2004, 02:35 PM   #3
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Quote:
Originally posted by infamous41md
*prepares to possibly eat words*
Rest assured...
 
Old 07-31-2004, 03:05 PM   #4
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 51
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.
 
Old 07-31-2004, 04:13 PM   #5
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
I won't say that's impossible, but IMHO it's a bit like deleting a file by means of editing /dev/hda1.

 
Old 07-31-2004, 04:21 PM   #6
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 51
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.
 
Old 07-31-2004, 05:27 PM   #7
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Quote:
Originally posted by kev82
[....] and would make that clear in an interview.
LOL. Good point!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
perl problem? apache problem? cgi problem? WorldBuilder Linux - Software 1 09-17-2003 07:45 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:18 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration