What's New-Given Below
technicalsymposium
technicalsymposium
technicalsymposium

Free E-Mail Alerts

College Lab Codings/Project Codings-Download


DataStructure-Program to maintain a doubly linked list.

#include <stdio.h>
#include <conio.h>
#include <alloc.h>
/* structure representing a node of the doubly linked list */
struct dnode
{
struct dnode *prev ;
int data ;
struct dnode * next ;
} ;
void d_append ( struct dnode **, int ) ;
void d_addatbeg ( struct dnode **, int ) ;
void d_addafter ( struct dnode *, int , int ) ;
void d_display ( struct dnode * ) ;
int d_count ( struct dnode * ) ;
void d_delete ( struct dnode **, int ) ;
void main( )
{
struct dnode *p ;
p = NULL ; /* empty doubly linked list */
d_append ( &p , 11 ) ;
d_append ( &p , 2 ) ;
d_append ( &p , 14 ) ;
d_append ( &p , 17 ) ;
d_append ( &p , 99 ) ;
clrscr( ) ;
d_display ( p ) ;
printf ( "\nNo. of elements in the DLL = %d\n", d_count ( p ) ) ;
d_addatbeg ( &p, 33 ) ;
d_addatbeg ( &p, 55 ) ;
d_display ( p ) ;
printf ( "\nNo. of elements in the DLL = %d\n", d_count ( p ) ) ;
d_addafter ( p, 4, 66 ) ;
d_addafter ( p, 2, 96 ) ;
d_display ( p ) ;
printf ( "\nNo. of elements in the DLL = %d\n", d_count ( p ) ) ;
d_delete ( &p, 55 ) ;
d_delete ( &p, 2 ) ;
d_delete ( &p, 99 ) ;
d_display ( p ) ;
printf ( "\nNo. of elements in the DLL = %d\n", d_count ( p ) ) ;
}
/* adds a new node at the end of the doubly linked list */
void d_append ( struct dnode **s, int num )
{
struct dnode *r, *q = *s ;
/* if the linked list is empty */
if ( *s == NULL )
{
/*create a new node */
*s = malloc ( sizeof ( struct dnode ) ) ;
( *s ) -> prev = NULL ;
( *s ) -> data = num ;
( *s ) -> next = NULL ;
}
else
{
/* traverse the linked list till the last node is reached */
while ( q -> next != NULL )
q = q -> next ;
/* add a new node at the end */
r = malloc ( sizeof ( struct dnode ) ) ;
r -> data = num ;
r -> next = NULL ;
r -> prev = q ;
q -> next = r ;
}
}
/* adds a new node at the begining of the linked list */
void d_addatbeg ( struct dnode **s, int num )
{
struct dnode *q ;
/* create a new node */
q = malloc ( sizeof ( struct dnode ) ) ;
/* assign data and pointer to the new node */
q -> prev = NULL ;
q -> data = num ;
q -> next = *s ;
/* make new node the head node */
( *s ) -> prev = q ;
*s = q ;
}
/* adds a new node after the specified number of nodes */
void d_addafter ( struct dnode *q, int loc, int num )
{
struct dnode *temp ;
int i ;
/* skip to desired portion */
for ( i = 0 ; i < loc ; i++ )
{
q = q -> next ;
/* if end of linked list is encountered */
if ( q == NULL )
{ printf ( "\nThere are less than %d elements", loc );
return ;
}
}
/* insert new node */
q = q -> prev ;
temp = malloc ( sizeof ( struct dnode ) ) ;
temp -> data = num ;
temp -> prev = q ;
temp -> next = q -> next ;
temp -> next -> prev = temp ;
q -> next = temp ;
}
/* displays the contents of the linked list */
void d_display ( struct dnode *q )
{
printf ( "\n" ) ;
/* traverse the entire linked list */
while ( q != NULL )
{
printf ( "%2d\t", q -> data ) ;
q = q -> next ;
}
}
/* counts the number of nodes present in the linked list */
int d_count ( struct dnode * q )
{
int c = 0 ;
/* traverse the entire linked list */
while ( q != NULL )
{
q = q -> next ;
c++ ;
}
return c ;
}
/* deletes the specified node from the doubly linked list */
void d_delete ( struct dnode **s, int num )
{
struct dnode *q = *s ;
/* traverse the entire linked list */
while ( q != NULL )
{
/* if node to be deleted is found */
if ( q -> data == num )
{
/* if node to be deleted is the first node */
if ( q == *s )
{
*s = ( *s ) -> next ;
( *s ) -> prev = NULL ;
}
else
{
/* if node to be deleted is the last node */
if ( q -> next == NULL )
q -> prev -> next = NULL ;
else
/* if node to be deleted is any intermediate node */
{
q -> prev -> next = q -> next ;
q -> next -> prev = q -> prev ;
}
free ( q ) ;
}
return ; /* return back after deletion */
}
q = q -> next ; /* go to next node */
}
printf ( "\n%d not found.", num ) ;
}

CSE/IT/MCA Lab & Technical Programs with Answers-Given Below

Placement Training Program for Engineering Students
(Aptitude Short-Cut Training Program)
Don’t miss this opportunity & 100% Hands on & Practical Sessions Only.

technical symposium

One Day Placement Training program on “Hands on Aptitude short-cut training program & Winning Techniques of Technical/HR Round".
• BE/B.Tech(All Branches)/ME/M.Tech(All Branches)/Passed Out Students
Training Program Will be held in A/C Hall & Reg.Fee includes Course Materials & Lunch,Refreshments.
Participation Certificate Will be Issued to All Participants
Click here to View Complete Details

technical symposium
Freshers Software/Government Jobs Details
job detailsAll Government Jobs Openings
job detailsAll Software Job Openings
job detailsAll Govt/Software Intern Openings
View all Government/Software Jobs Openings job detailsjob detailsjob details



Engineering College/Universities Conference/Symposium Details
job detailsAll Engineering College/Universities Conferences Details
job detailsAll College Symposium Details
job detailsAll College Workshops/Training Program Details
View all Conference & Symposium Details job detailsjob detailsjob details



Engineering Lecture Notes /Study Materials
job detailsCSE/ECE/CIVIL/MECHANICAL Engineering (All Sem Complete Notes)
job detailsMCA/IT/Automobile Engineering (All Sem Complete Notes)
job detailsMBA/Bio-Technology/Bio-Medical Engineering (All Sem Complete Notes)
View all Departments Lecture Notes job detailsjob detailsjob details
Placement Materials with Answers
job detailsTCS/WIPRO/CTS/INFOSYS Placement Papers with Answers
job detailsAll Software Companies Technical Round Materials
job detailsFree Interview & HR Round Materials
View all Placement Materials job detailsjob detailsjob details



Technical Round Programs/Lab Programs & Manuals
job detailsJAVA/C/C++/OS Technical Round Programs with Answer
job detailsC Aptitude Round Programs with Answers
job detailsData Structure Lab & Technical Round Programs with Answers
View all Techical Round & Lab Programs job detailsjob detailsjob details



GATE Original Question Papers Details
job detailsAll Branches of GATE Papers
job detailsGATE All Branches Syllabuses
job detailsGATE Exam Complete Details
View all GATE Exam Question Papers job detailsjob detailsjob details
Anna University & All Universities Original Question papers Details
job detailsAnna University All Branches Question Papers
job detailsAll Universities All Sem Question Papers
job detailsAll University & Anna University Elective Papers Question Papers
View all Universities Question Papers job detailsjob detailsjob details



Govt Exam Original Question Papers Details
job detailsTNPSC/TET Original Question Papers
job detailsUPSC/SSC Original Question Papers
job detailsIES Question Papers
View all Govt Exam Question Papers job detailsjob detailsjob details



Govt Exam/Entrance Exam Syllabuses Details
job detailsEngineering Services Exam Syllabus-All Department
job detailsSTAFF SELECTION COMMISSION (SSC) SYLLABUS
job detailsUGC-NET/SLET Syllabuses
View all Govt Exam/Entrance Exam Syllabuses job detailsjob detailsjob details
Engineering Colleges in Tamil Nadu-Complete Details
job detailsAll Engineering Colleges Complete Details
job detailsDistrict Wise Engineering Colleges Details
job detailsAll Engineering Colleges Address & Seats Details
View all Engineering Colleges Detailsjob detailsjob detailsjob details



Universities in India-Complete Details
job detailsAll Universities in India Complete Details
job detailsAll Universities-State Wise Complete Details
job detailsUniversities Address & Seats Complete Details
View all Universities Detailsjob detailsjob detailsjob details



Paper Presentation Abstracts -Complete Details
job detailsAll Branches of Paper Abstracts
job detailsLatest Paper Abstracts
job detailsFree Download of All Abstracts
View all Paper Abstractsjob detailsjob detailsjob details

Hosting by Yahoo!

About-Us    Contact-Us    Site-map

©copyright 2009 All rights are reserved to technicalsymposium.com