473,769 Members | 1,917 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

deletion in link list

can anyone tell me how to delete a certain node in a doubly circular
link list
Dec 3 '07 #1
9 1786
ratika wrote:
can anyone tell me how to delete a certain node in a doubly circular
link list
Carefully...
Dec 3 '07 #2
On Dec 3, 4:36 pm, ratika <cool_ratikagu. ..@rediff.comwr ote:
can anyone tell me how to delete a certain node in a doubly circular
link list
Let ptr holds the address of the node to be deleted then

(ptr->back)->next = ptr->next;
(ptr->next)->back = ptr->back;
free(ptr);

don't forget to check the boundary conditions
Dec 3 '07 #3
Chris Dollin wrote:

<snip>
[1] Programmers [2] are notable for their literal [3] interpretation
[of
questions.

[2] OK, /some/ programmers [3].

[3] And maybe it's rhetorical, not literal [4].

[4] Or a cover for the control messages to the mind-control satellites
[[4].

[4] There is no footnote 4.
Maybe you should use structured control flow instead of gotos?

Dec 3 '07 #4
santosh wrote:
Chris Dollin wrote:

<snip>
>[1] Programmers [2] are notable for their literal [3] interpretation
[of
questions.

[2] OK, /some/ programmers [3].

[3] And maybe it's rhetorical, not literal [4].

[4] Or a cover for the control messages to the mind-control satellites
[[4].

[4] There is no footnote 4.

Maybe you should use structured control flow instead of gotos?
I do.

--
Chris "they're procedures" Dollin

Hewlett-Packard Limited registered office: Cain Road, Bracknell,
registered no: 690597 England Berks RG12 1HN

Dec 3 '07 #5
ratika wrote:
can anyone tell me how to delete a certain node in a doubly circular
link list
<off-topic reason="better asked in comp.programmin g">

Draw a picture of the list, showing the links as arrows.
Then draw another picture of the list as it would be if the
deleted node were simply not there at all. Study the two
pictures to see which arrows have changed, and then write
code to make those changes in the actual list.

</off-topic>

--
Eric Sosman
es*****@ieee-dot-org.invalid
Dec 3 '07 #6
On Dec 3, 7:36 pm, ratika <cool_ratikagu. ..@rediff.comwr ote:
can anyone tell me how to delete a certain node in a doubly circular
link list
read your book and understand the knowledge points yourself
try it yourself first
remember that practice makes perfect
Dec 3 '07 #7
On Dec 3, 7:21 pm, "Thomas X. Iverson" <thomas.x.iver. ..@gmail.com>
wrote:
On Dec 3, 7:36 pm, ratika <cool_ratikagu. ..@rediff.comwr ote:
can anyone tell me how to delete a certain node in a doubly circular
link list

read your book and understand the knowledge points yourself
try it yourself first
remember that practice makes perfect
i know the concept of the program .i had made the program too . but
the problem is that it is running only two times not more than that
Dec 4 '07 #8
On Dec 3, 4:36 pm, ratika <cool_ratikagu. ..@rediff.comwr ote:
can anyone tell me how to delete a certain node in a doubly circular
link list
//circular doubly link list
#include<stdio. h>
#include<conio. h>
#include<alloc. h>
struct node
{
struct node *pre;
int data;
struct node *next;
};
void addnode(struct node** , int);
void display(struct node*);
void delfirst(struct node*);
void main()
{
int item,ch;
struct node **t;
clrscr();
*t=NULL;
do
{
printf("\nMenu: \n1.add node\n2.display \n3.delete first node\n4.exit
\nenter the choice");
scanf("%d",&ch) ;
switch(ch)
{
case 1:
printf("enter the value to be inserted");
scanf("%d",&ite m);
addnode(t,item) ;
break;
case 2:
display(*t);
break;
case 4:
break;
case 3:
delfirst(*t);
break;
default:
printf("wrong choice try again");
}
}while(ch!=3);
getch();
}
//functions starts
void addnode(struct node **t,int val)
{
struct node *temp,*temp1;
temp=(struct node*)malloc(si zeof(struct node));
temp->pre=NULL;
temp->data=val;
temp->next=NULL;
if(*t==NULL)
{
*t=temp;
temp->pre=*t;
temp->next=*t;
}
else
{
*t=temp1;
while(temp1->next!=*t)
{
temp1=temp1->next;
}
temp1->next->pre=temp;
temp->next=temp1->next;
temp->pre=temp1;
temp1->next=temp;
}
}

void display(struct node *t)
{
struct node *temp;
if(t==NULL)
{
printf("link list empty");
}
else
{
temp=t;
while(temp->next!=NULL)
{
printf("%d",tem p->data);
temp=temp->next;
}
}
}
void delfirst(struct node *st)
{
if(st==NULL)
{
printf("link list empty");
}
else
{
struct node *temp;
temp=st;
temp->pre->next=temp->next;
st=temp->next;
temp->next->pre=temp->pre;
}
}
this is the program made by me please see and tell me the errors
Dec 4 '07 #9
Mark Bluemel wrote:

Oh! and main returns int - I fixed it in my version but forgot to
mention it. (Ideally I should have used "int main(void)")
Dec 4 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1650
by: Christopher Pisz | last post by:
currently my node is like so with everything public: class Quadtree_Node { public: Quadtree_Node(Quadtree_Node * parent, Bounding_Box & bounds); ~Quadtree_Node(); void Subdivide(float smallest_node); const Quadtree_Node *& GetTopLeft(); Bounding_Box m_bounds; // Bounding Coordinates of this node
1
1832
by: Wayne Aprato | last post by:
Is there an effective method of preventing users from accidentally or maliciously deleting the database file/files from a shared network drive? At the moment, I'm using a batch file to copy the data.mdb to another secure location every time a particular user who performs most of the data entry exits the database. Setting the windows permissions for the database folder to "read only" seems to create problems and data entry users obviously...
8
4170
by: sudhirlko2001 | last post by:
How to swap two nodes of doubly Linklist
3
1563
by: Imran Aziz | last post by:
Hello All, I have a delete link on my page, which when clicks calls the URL for deletion, in ASP we use to create a java script confirm box to confirm delete, how can that be done in ASP? Say if I use an ASP link control , or if I use a html anchor link. This is how I am trying to do it <script language="javascript"> function ConfirmDelete(nChannelID)
2
1739
by: Rune Froysa | last post by:
I have one table with columns that are used as foreign-keys from several other tables. Sometimes deletion from this table takes +5 seconds for a single row. Are there any utilities that can be used to figure out why the deletion takes so long? "ANALYZE DELETE FROM foo WHERE bar=gazonk" doesn't really help as it only explains how the where statement is resolved, and not what postgres has to do to preserve database integrity. Regards,
3
1681
by: A_Republican | last post by:
I am interested in writing my own secure file deletion program. I want to be able to read and write to my hard drive directly. My application will seach my hard drive for all locations marked for deletion and then replace it with "x" or something that securely removes previoius data. My question is what objects, API calls, etc, etc do I use to read and write directly to the hard drive? -- Regards, Shaun Goldston
2
4478
by: shahrukh | last post by:
Plz If Anyone Can Tell Me Insertion And Deletion In Linked List And In Array Then Reply Here There Programs. Even Reply Any One Program Either For Linked List And Either For Array.
1
1348
by: Aff | last post by:
Dear Brothers, i am facing a problem class compactdisc { char title;/string a; int capacity; public:
4
4124
by: lokki | last post by:
Hello, can anybody tell me what's wrong with following example code? char *k, *v; k = new char; strcpy(k, "a2"); v = new char;
0
9579
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10205
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10035
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9851
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8863
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7401
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5293
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3556
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2811
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.