linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "mikael-aronsson" <mikael-aronsson@telia.com>
To: Bakki Srinivas <bakki_srinivas@mindtree.com>,
	Justinas <jugu3479@uosis.mif.vu.lt>,
	Jagadeesh Bhaskar P <jbhaskar@hclinsys.com>
Cc: Linux C Programming <linux-c-programming@vger.kernel.org>
Subject: Re: deletion in singly linked list
Date: Tue, 23 Nov 2004 10:13:41 +0100	[thread overview]
Message-ID: <003b01c4d13c$ba026aa0$bf95d1d9@w128mtec> (raw)
In-Reply-To: 5959EA4638D8734599AB75EAAFBB6FEFA471DB@mtv01ex04.mindtree.com

Yeah, that would work if you can move items between the links, just make
sure there are no pointers in other places that rely on the contents of
linked list.

Mikael

----- Original Message ----- 
From: "Bakki Srinivas" <bakki_srinivas@mindtree.com>
To: "mikael-aronsson" <mikael-aronsson@telia.com>; "Justinas"
<jugu3479@uosis.mif.vu.lt>; "Jagadeesh Bhaskar P" <jbhaskar@hclinsys.com>
Cc: "Linux C Programming" <linux-c-programming@vger.kernel.org>
Sent: Tuesday, November 23, 2004 10:00 AM
Subject: RE: deletion in singly linked list


how is this--- 
copy the content of the next item and place it in the current pointed
item,check if the next item pointed by the next item is NULL if it is then
delete the next item else move the pointer till it reaches NULL finally
delete the last one.

Srinivas

-----Original Message-----
From: mikael-aronsson [mailto:mikael-aronsson@telia.com]
Sent: Tuesday, November 23, 2004 2:25 PM
To: Justinas; Jagadeesh Bhaskar P
Cc: Linux C Programming
Subject: Re: deletion in singly linked list


That will break the list, the previous item has to be updated so you will
need to get the first item of the list and walk through the list until you
find the item in front of the one you want to delete and change the "next"
pointer in that item to point to the one in the "next" pointer in the item
you are deleting.

Then you can delete the item you started with.
There is no other way to do it without a double linked list.

Mikael

----- Original Message ----- 
From: "Justinas" <jugu3479@uosis.mif.vu.lt>
To: "Jagadeesh Bhaskar P" <jbhaskar@hclinsys.com>
Cc: "Linux C Programming" <linux-c-programming@vger.kernel.org>
Sent: Tuesday, November 23, 2004 9:42 AM
Subject: Re: deletion in singly linked list


> Hello,
>
> i think You can. For instance n is a pointer to curent node and n->next is
pointer to next node. lets say we like this tmp = n, and n = n->next. After
that free(tmp).
>
> On Tue, 23 Nov 2004 13:54:10 +0530
> Jagadeesh Bhaskar P <jbhaskar@hclinsys.com> wrote:
>
> > I am having the address of a single node of a singly linked list. All I
> > know about that node is that it is not the head of the list. Now say, I
> > want to delete this node. I can infer its next node, but not its
> > predicissor. Is there any way to delete that node, without breaking the
> > whole linked list down!!
> >
> > -- 
> > Jagadeesh Bhaskar P <jbhaskar@hclinsys.com>
> >
> > -
> > To unsubscribe from this list: send the line "unsubscribe
linux-c-programming" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> >
> -
> To unsubscribe from this list: send the line "unsubscribe
linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-
To unsubscribe from this list: send the line "unsubscribe
linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


  reply	other threads:[~2004-11-23  9:13 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-23  9:00 deletion in singly linked list Bakki Srinivas
2004-11-23  9:13 ` mikael-aronsson [this message]
2004-11-23  9:33   ` Jagadeesh Bhaskar P
2004-11-23  9:29 ` Jagadeesh Bhaskar P
2004-11-23  9:59 ` Glynn Clements
  -- strict thread matches above, loose matches on Subject: below --
2004-11-23 10:31 Bakki Srinivas
2004-11-23 10:23 Bakki Srinivas
2004-11-23 10:22 Bakki Srinivas
2004-11-23  9:35 Bakki Srinivas
2004-11-23  9:55 ` Jagadeesh Bhaskar P
2004-11-23  8:24 Jagadeesh Bhaskar P
2004-11-23  8:42 ` Justinas
2004-11-23  8:55   ` mikael-aronsson
2004-11-23  9:09     ` Jagadeesh Bhaskar P
2004-11-23 16:57   ` Justinas
2004-11-23 10:08 ` Glynn Clements
2004-11-24 12:43 ` Alphex Kaanoken
2004-11-25  3:49   ` Jagadeesh Bhaskar P
2004-11-25 10:11     ` Alphex Kaanoken
2004-11-25 10:26       ` Jagadeesh Bhaskar P
2004-11-25 11:09         ` Alphex Kaanoken

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='003b01c4d13c$ba026aa0$bf95d1d9@w128mtec' \
    --to=mikael-aronsson@telia.com \
    --cc=bakki_srinivas@mindtree.com \
    --cc=jbhaskar@hclinsys.com \
    --cc=jugu3479@uosis.mif.vu.lt \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).