473,372 Members | 879 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 software developers and data experts.

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 1763
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.comwrote:
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.programming">

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.comwrote:
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.comwrote:
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.comwrote:
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",&item);
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(sizeof(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",temp->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
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...
1
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...
8
by: sudhirlko2001 | last post by:
How to swap two nodes of doubly Linklist
3
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...
2
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...
3
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...
2
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
by: Aff | last post by:
Dear Brothers, i am facing a problem class compactdisc { char title;/string a; int capacity; public:
4
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
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.