Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
222 views
65 pages
Data Structure Practical - MCA Idol Shree Ram College
Data Structure Practical | MCA Idol Shree Ram College | Mumbai University Mca Idol | Bhandup
Uploaded by
Unknown
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download
Save
Save Data Structure Practical | MCA Idol Shree Ram Coll... For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
222 views
65 pages
Data Structure Practical - MCA Idol Shree Ram College
Data Structure Practical | MCA Idol Shree Ram College | Mumbai University Mca Idol | Bhandup
Uploaded by
Unknown
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Carousel Previous
Carousel Next
Download
Save
Save Data Structure Practical | MCA Idol Shree Ram Coll... For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 65
Search
Fullscreen
DATA STRUCTURES INDEX SR.NO. CONTENT SIGNATURE 1. Write a program create a Stack & add elements into the stack,delete elements from the same stack. 2. Write a program to create a Stack. | 3. Write a program to create a Queue , add elements into the queue & delete elements from the same queue. Prod 4. Write a program to create a Queue. 5. Write a program to to traverse binary tree - in: 1) Inorder form 2)Pre-order form 3 )Postorder form ( 6. Write a program to count the leaf nodes in - binary tree. a, Write a program to create a Single Linked List, Insert & Delete elements from it. 8. Write a program to create a single linked list. 9. Write a program to implement Bubble Sort 10. Write a program to implement Heap Sort 18 Write a program to implement Insertion Sort12. Write a program to sort the given numbers by using Bubble sort technique. 13, Write a program to join circular linked lists. (G : ( pepe 14. Write a program to join single linked lists.“Fracti cat No 31 Croake oe & ddd elemeats fata the steok Delete elements fa the same. lyaxtth oo 2 Create Steck Pre + stack clement Cootiiiassfee 04 stuck Post : Idee ob fade Aiea alfarated ds czas sii Rehun : Potntee Ie hewcl node ar null _pototee 2 No memar 1 Ph (om. ORY mit ef vail hie) _ fy Stackphr <2 oulp else A GWlereke Zetackpn) (Head! gitocatead. /ee geal tatHabfee £ sllacete stuck aexdef) fi) Shockph unt =o_ Sui tock p be inp = =) jv) stutkphe rockmax = stock elem fF ( memorye not avafloble) a) ede fe Cskuelxpbe) epull vw) Alse ( Atte ey eto) — AD ) Rehwo ge ne he A) kad FOR EDUCATIONAL USE,Algacttha 2 Add element [am the tock (push Ly short \f Top = size -| then CTop fs ptr dm potas Lop anest ebook ob stro 1) Dfsabay “steuls OverAlous hp Batt 4) Else Top =Toe +! 4) A(Toe) = n ( Obsiz€) pre damens =) fF xT 4 xfhhen 2 Delete element faoar stele ( Pag ) Shor} = If Top < 0 Men $> Di: 4 cle fi ¥ Tp Baeth 3) Fise Bemovt phe bop mast element. 4) N
Practical no. 1 Hinclude
int stack[50] item; int ch,n=0,top,i; void main() { void createQ); void add(); void deletelast(); void display; do { clrscr(); printf("\n\t Stack Operations \n't"); printf("\n-— printf("\n\n n\n"); 1 Create \n\n 2.Add \n\n 3,Delete\n\n 4.Display\n\n 5.Exit\n\n"); printf("\nEnter Your Choice:"); scanf("%d",&ch); printf("Enter maximum size for stack :"); scanf("%d",&n); case 1: create); getch(); break; case 2: add(); getch(); break; case 3: deletelast(); getch(); break; case 4: display(); getch(); brea case 5: exit(); getch(); break; default: printf("Invalid choice "); break; if(ch==1) t ) switeh(ch) t ) gotch(); } while(ch!=5); } void create() { printf("\n\t Create a Stack :");printf("\n stack is created !"); return; I void add() { _ printf("\n Adding element to stack "); printf(" n\n"); printf{"Enter item to be inserted into stack scanf{"%d",&item); if(top==n) { _printf("Stack ios full cant insert !"); getch(); return; } top; stack{top]=item; printf("\n Item %d has been inserted into stack" item); return; } void deletelast() { _ printf("\nDeleting element from stack :\n"); printf("Stack is empt getch(); retum; —} item=stack[top]; top--; printf("\nltem %d is deleted from stack" item); printf{"\nltems of stack are:\n"); for(i=1;i
#include
#include
struct stack { int data; struct stack *next; hb struct stack *pop(struct stack *top); struct stack *push(struct stack *top); void main() { struct stack *top; int reply,option,data; - lrser(); top=NULL; do { printf{"\nStack Operations: \n"); printf("~ "Ys printf("\n push \n 2.pop \n 3.exit\n\n"); printf("Select Your option:"); scanf("%d",&option); switch(option) { case I:top=push(top); break; case 2:top=pop(top); break; case 3: exit(0); break;} 3 while(1); struct stack *push(struct stack *top) { } struct stack *c; o=(struct stack*)malloc(sizeof{struct stack)); if(e==NULL) { printf("\nInsufficient Memory !"); return(top); J printf("\nEnter data: "); scanf("%d" &e->data); c->next=NULL; printf("\n\tTha Data item %d has been pushed into the stack \n\n",c->data); if(top=NULL) { top=<; else c->next=top; top=c; } return(top); struct stack *pop(struct stack *top) { struct stack *c; if(top-=NULL) x printf("stack is empty"); return(top); 3 printf("\n\t Popped data is: %d\n\n"top->data); top; retun(top);FRacticar No 2 3 | Create a Queue 6 Adel element falo the —__ Pas 3 hi oad ban betel |allevabed 2 fatitathg aaa Rehons heud's oldress FA succersshd ,nul Ph e overtler _ | Steet fk_( memory —averfleble) a) allocate C neroptr) — b)_newpt-> bmat = oulh ©) theo phy nee = null dh) pep > count Zp @) 2ehero newt ) ise @) vehwn ull pofarer. 4) Bef. FOR EDUCATIONAL USEAl 2Eh 2 Addl el fo 4 0. | i stew b 2 SInehralfee FRont = -) , RPAR = -) | Po_varidble 'n\! A Ik (RepR >= size) 7 f> Display "@ueue Oyertlow" | 422 £xfh SS) glse es | or f> REAR = REAR +) _ = 4\ #( REAR) =~ TD Axi 6 2 Delebe clements fro te queue | Ce | S) s terk s = If (RAAR ¢ FRort) i 7 FRps oa oe | ib _Drspl. “@ eo _uncderflan” iy Ax fh Blse ° f> N 2 A ( FRonr) 4) FRboNT £ FRONT 4) ) Bact FOR EDUCATIONAL USEPractical no. 3 #include
#include
#include
int queue[S0},item; int ch,n=0, front,rear,i; void main() { void create(); void add(); void deletelast(); void display(); do { clrser(); printf("\n Queue operations\n"); printf("\n - ln"), printf("\n 1.Create \n\n 2.Add \n\n 3.Deletelast \n\n 4,Display\n\n 5.Exitin"); printf("\n Enter Your Choice:"); seanf{"%d" Sch); if{ch—=1) { printf("\n Enter maximum size of queue you wish to have:"); scanf("%d",&n); } switch(ch) { case L:create();getch();break; case 2:add();getch();break; case 3:deletelast();getch()sbreak; case 4:display();getch();break; case S:exit(0);getch();:break; default: printf("Invalid choice! Try again "); getch();break;} void create() { printf("\n\nCreating a Queue.. printf("\n -\n. front=0,rear—0; printf("\n\nQueue created"); return; } void add() { if(tear>=n) { printf("Queue is full 1"); getch(); return; } else { printf("\nAdding element into a queue"); printf(" "); printf("Enter item to be inserted : "); scanf("%d",&item); reart+; queue[rear]=item; if{(front—=0) front=1; printf(""\n\nltem %d has been inserted into queue’ item); printf("\n Items of queue are:"); for(itront;i<=rear;i++) { printf("\1%d",queuefi)); 3 return; 3 } void deletelast() { printf"\nDeleting element from queue\n"); printf("\n "5printf(""\nQueue is empty !"); getch(); return; } front++; item=queue[front]; printf("\n Item %d has been deleted from queue" tem); printf(""\n Items of queue are:"); for(i=front;i<—tear;i++) { printf("'1%d",queuefi]); } return; } void display() { printf("\n display all elements of Queue\n"); printf("\n Items of queue are:"); for(i=front;i<=rearsi++)_ { printf("\t%d" queuefi]); } return;Gases Queue overat ion: reece eet ep rSccre ees cee ery Eee eee cere ee eee eect cc torts reece eae cies Gicciieies ere Ferd Pacey Eee rra ne Perce Bao eee tone Deleting elenent from queue Diet oe oC eto ec) eteFractal No $4 al - || bbefre a progaam fo Create a Queue + | Algorfrhos 5 _Cresste Queue | Th clgoxftha alle cater _memoxy for queue | heal: The pofater are set ho null < counter Te20- Allacates mememy tora queue head _pacle brom_dynamte _memarp £ 2chuns fh delebress to Hhe certler . | Pret _nabhtag least shee! has been allocated £ fothtalPoed | Kehun: heads adldees fk succersh nutl PP overblow+ » trot a # ¢ memary avaflable) fy allocate (newpte) ih pew ptr > front 2 null i i> newmptr > year = nub/ fo newpb aunt sO vy Rebwn nerrphe eherp rulf BS) flae ly) Ext FOR EDUCATIONAL USE,Practical no. 4 #include
#include
#define max 3 int queue[max},data; int front,rear,reply,option; void main() t elrser(); front=rear=-1; do t Prinf('\nQueue Operations : \nln\tl Insert into Queue \n\n\t2.Delete from Queue \n\n\t3.Exit\n"); printf("\n\n\tEnter Your choice: "); seanf("%d", option); switch(option) case I: printf("\nEnter data to insert:"); scanf("%d", data); reply=insertq(queue,crear,&data); if{teply-=-1) printf("'Queue is full!"); else Printf("Data %d inserted into Queue successfully !\n\n",data); break; case 2: reply=deleteq(queue, &rear,&data); if(teply==-1) printf("Queue is Empty!"); else printf("Data %d is deleted....\n\n" data); break; case 3:exit(0); default: printf("Invalide choice..Try again "); break;while(1); 3 int insertq(int queue{max],int *rear, int *data) { if(*rear—= max-1) retum (-1); else *rear=*rear+1; queue[*rear]=*data; return (1); int deleteq(int queue[{max],int *front, int *rear,int *data) { if(*front—*rear) return (-1); else (Hront) +; *data-queue[*front]; return(1);areaFOR EDUCATIONAL USEPre - Order Trevercot 2 La pre-order priversal, the 22ok pode fs__procersed Part, Pallowed by tes subhee — & then 2fghk Ub bree. o Algoxtthari Prearde Cyol ret 2 node parfoters) Bavese a _hbfamy tree fo nade -lofh ~ _ vi wen. Prt_2 rook fs the €obey node ot o_fte or subbee 2 2 eath ode has beea poatedsod foordee PEC 2ok fs nok null) 2. ix Process Craot) if» preorder (200b = left subb-e) ‘iin Prrarcle ook _pigh+ subbte) —____ » Rehr» FOR EDUCATIONAL USE,AL fi & pasty: i “Prdwers 2 a binary p> fa =a2ighk- euuernce » Pret 200k fs the coop pade cf bee 92 -sclbhre post + each node Aa been praced.ted fa trdee i> fA ( 20or fs not nub) {> Pastordes Croat > lebhsubbie) > eostnrder Anak =~2_2Sghtsih te) __ ea it process (r0ot) 2) Rehon a FOR EDUCATIONAL USE,Practical no. 5 #include
#includesstdlib.h> #include
struct treeree { struct treerec *lchild; struct treerec *rchild; char data; hb struct treerec *item; struct treeree *rdata[50]; void main() { intin; clrser(); printf{""\nEnter no of data-items to be enterd in tree: "); seanf("%d",&n); printf(""\n\nEnter data-items: "); for(i=1;i<-mi++) { rdata{i}=(struct treerec *)malloc(sizeofistruct treerec)); scanf("\r%c", Serdatali]->data); rdatafi]->Ichild=NULL; rdatai]>rehild=NULL; } for(i=1;i<=n;i++) ti rdatafi]->Ichild-rdata[2*i]; rdatafi]->rchild=rdata[2"i+1]; } item=rdatafi; printf("\n\nGiven Data in Tree\n"); ‘atn"); n;i++) printf("%c\t"rdata{i]->data);printf("\n\n"); printf("Inorder tree traversal\n\n"); print{("*#sseesenansenanenaenneig\, inorder(item); print{("\n\nPreorder tree traversal\n\n"); print{("*ereerseenensenaesastseanien: preorder(item); printf("\n\nPostorder tree traversalin\n"); print{("eeeesernernerecteeeeseer ni); postordertitem); getch(); } inorder(cnode) struct treerec *enode; { if{enode!=NULL) { inorder(cnode->Ichild); if{cnode->data!=" ') { printi("%c" enode->data); } inorder(cnode->rehild); } return(1); $ preorder(cnode) struct treerec *cnode; { iffenode!=NULL) { inorder(cnode->Ichild); iffenode->data!="_’) { printf("%c" cnode->data); } preorder(cnode->Iehild); preorder(cnode->rehild);} postorder(cnode) struct treetee *enode; { if{enode!=NULL) { postorder(cnode->lchild); postorder(cnode->rchild); if{cnode->data!~"_") { printf("%c" cnode->data); } } return (1);PRacica, to 36 Wpfle a ot) eh2.0b 20. ; ty__counr leat nade fa _ binary tre Dlgoxct thor’ _getLeakGount Mode} JP node fs HuLl then 2ehun g child nodes are Nur ehun! 3) Blse 2ecurstyels calewabe leat count ot the leat foun) ba tree zlea! touat af lob) subbee + Leak count at right subbee A) Boefk FOR EDUCATIONAL USEPractical no. 6 Hinclude
#include
#include
#include
struct node { int data; struct node*left; struct nade*right; b unsigned int getleafcount(struct node* node) { if{node=NULL) return (getleafcount(node->lef)+ getleafcount(node->right)); 3 struct node*newnode(int data) t struct node*node=(struct node*)malloc(sizeof{(struct node)); node->data=data; node>left-NULL; node->right=NULI return(node); } int mainQ) {__ struct node *root=newnode(1); clrser(); root->left=newnode(2); root->right-newnode(3); 100t->left->left=newnode(4); root->left->right-newnode(5); printf"Leaf count of the tree is %d",getleafcount(root)); getch); return 0;Outpu:TRacncat No 27 | PL => || Algoxtthe, i (Crease Stagly lfaked esr a Ifsk mode £ rehuns fre gdalress tn caller } Ly Start 2> PEC memerp avaflable) Le Allocate ( PNew) | 2. PNeuw 2 heal Nu, | | 4: pNew >» Count =D Fis | pdew > oull 1 2) Rehun _pNer t ) Bach : FOR EDUCATIONAL USEAlgaorxttha : losot a node oe v 1) Steep} > Input aki op _be_fnsezted 3) Creatke a Newttode temp 2) temp 3 DATA =n s) ft ( staat. NuLL) ternp > next = H, 6) Els temp > next = sTART seTeeQr ee hemp go) Exfr FOR EDUCATIONAL USEAl gust l- 4 eg nade 2 PTT = START 2D _STHaT = START 2 NE xp AD Free (ett) 5) bit Delete a pachtabler ode 1 Felack 2 Input nade which wou paot tn olelebe B® PTR = 4) Hhile ¢ —_ fot _cqutcd PTR 2 Date AND PTR 00 J PTT = PTR PTR = PTR Next oie PIT 2nexr = PTR > hext free (PTR) 6) Fl Display \ Bement pot Aruadl T> Pacfr FOR EDUCATIONAL USE.Practical no. 7 #include
#include
#include
struct studinfo { int data; struct studinfo *next; B struct studinfo *start=NULL, *ptr, “disp; void insertnode(); void deletenode(); void display(); void main() { int ch; clrser(); do { printf("\n\n\tMenus\n\t-— -\n"); printf("\t1 Insert node \n\n\t2.Delete node\n\n\t3, Display\n\n\t4.Exit\n\n\t"); printf("Enter Your Choice:"); scanf("%d",&ch); fflush(stdin); switch(ch) { case 1: insertnode(); break; case 2: deletenode(); break; case 3: display(); brea case 4: exit(0); break; default:print{("Invalid choice entered ! Enter again"); break;3 while(1); 3 void insertnode() { struct studinfo *newnode; newnode=(struct studinfo *)malloc(sizeof(struct studinfo)); printf("\Enter data of for the node to be inserted :"); seanf{"%d", &riewnode->data); ptr=start; if(start = NULL) { start=newnode; newnode->next=NULL; ptr=newnode; Printf("wn\tNewnode with data:%d inserted" newnode->data); else ptr->next=newnode; newnode->next=NULL; ptr=newnode; Printf("\n\tNewnode with data:%d inserted" newnode->data); } fflush(stdin); i void deletenode() { struct studinfo *del; iffstart==NULL) { printi("List is empty"); else ptrstart; start=start->next; free(ptr); printf("Deleted");3 void display() { sdlisp=disp->next) { if(pt=NULL) { printf("List is empty"); } else { ptr=ptr->next; printf("\n\tData: %d",disp->data); } }Sac Berar) Ge era Perera eer eee oe Peete CetteFRactcal No ik nies hizfte a _prngraa ho _crecthe Lest togly Ltaked. Algaxtthen § ! S shat bk » PAL New > heacl = null fi ¥ FOR EDUCATIONAL USEstruct node *current; current = head; if(current!= NULL) { > do { printf("%d\t",current->data); current = current->next; 3 while (current!= head); printf("\n"); } else printf("The list is empty\n"); } void destroy(struct node *head) { struct node *current, *tmp; current head->next = NULL;_ while(current != NULL) 1ead->next; { tmp = current->next; free(current); current = tmp; } void main() { struct node *head = NULL; clrser(); head = add(head,1); printlist(head); head = add(head,20); printlist(head); head = add(head,10); printlist(head); head = add(head,5); printlist(head); destroy(head); getch();Output: GXPractar No gusP hh on A - s lots
) ad ft: ae exthaageel Jot) Its fs completely ardesecd. 1) Stavt 2 Currenak =) > Saed < Fal PE Clfst © walked < Lise Lwaliser 1] Ie Sarked = fal. 2. A en -usclkces, worcil kee TD Walker = Jo th a ee End FOR EDUCATIONAL USEPractical no. 9 Hinclude
#include
void main() { int arr[5] = { 25, 17, 31, 13,2) 5 inti, j, temp ; clrser( ) 5 printf ( "Bubble sort.\n" ) ; printf ("\nArray before sorting:\n for (i=0;i<=4;i++) printf ("%d\t", arr[i] ) ; for (i=0;1<=3;it+) { for (j=03j<=3-isjt+) { if ( arr{j] > arr[j + 1) ) { temp = arr{j] ; arr{j] = arr{j +1]; arr{j + 1] = temp ; } } } printf ("\n\nArray after sorting:\n") ; for (i= O31 <=45 i++) printf ( "dit", arrfi] ) ; getch() 5FRacncar. Nu_s lo | eye birtke a pragaam fre Mean sot —__ Algor hh an 3 g pep 'a' § -ca_array of 'o' elements 1> Strack Pe) 2) pinsle (je =n) a) tall InsertHeup (a,j ,alpeig) by j aj a 3) whfle (n> =\) a) ¢ull pelebeHeapt) a by any 2x =n =} A) Rath FOR EDUCATIONAL USE. iPractical no. 10 Hinclude
include
void makeheap (int [], int ); ‘Void heapsort (int [ ], int); void main( ) { } int arr[10] = { 11, 2, 9, 13, 57, 25, 17, 1, 90,3} 5 inti; elrser( ) 5 printf ( "Heap Sort.\n" ) ; makeheap (arr, 10) ; printf ( "\nBefore Sorting:\n" ) ; for (i= 0;1<=9; i++) printf ("%d\e", arr{i] ) ; heapsort ( arr, 10); printf ("\nA ter Sorting:in" ) ; for (i= 0;1<=9 5144) printf ("%d\t", arti] ) ; getch( ); void makeheap ( int x{ }, int n ) { inti, val, s, £3 for (i=1;i
0 && x[f] < val ) { xs] =x{f] s=f; f=(s-1)/2; } x{s] = val ; }inti, s, f, ivalue ; for(i=n-15i>03i-) { ivalue = x{i) ; xfi] = x[0] 5 f=0; if(i=1) s=-l; else s=1; if (i> 2 && x[2]>x[1]) while ( s >= 0 && ivalue
i-1) 3 x{f] = ivalue ;i2_dP fe euth i fx list fs foserted fon sorted If~ 1>_ stort 2) Cumrenk =
#include
void main( ) { int arr{5] = { 25, 17, 31, 13,2}; int i j,k, temp ; elrser() 5 printf ("Insertion sort.\n" ) ; printf ( "\nArray before sorting:\n") ; for (i= 0;1<=4; i++) printf ("%d\t", arr{i) ) ; for (i= 15i<=45it+) { for(j=O3j
arefi] ) { temp = arti] ; arr(j] = arr{i] 5 for (k=i;k>j;k-) arr[k] = arr[k- 1] 5 arr[k + 1] = temp ; } } } printf ("\n\nArray after sorting:\n") ; for (i=0;i<= 45 i++) printf ("%d\t", arr[i] ) ; getch() ;GRUrU ManagFRacticar No 212 ee 6) Ar( feo; Pee 85 ist) 20° = Bs yor) checl a rr fpa > arr tj +11) the ie} bem Sarr tjd, nee eee axa tai] © deme | ey, fotk ( “AT puis for (feo; fecu ; foe) vail order): >) Boefh _ = FOR EDUCATIONAL USEPractical no. 12 #include
Hinelude
void main( ) { inti, j,arr{50},temp; forli=O;i<5;i++) { printf("Enter no. %d: "\i+1); seanf("%d", Sarrfi]); } printf ("\nBubble sort.\n" ) ; printf ( "\n\nArray before sorting:\n\n\t") ; for (i=0;i<=4; i++) printf ("%d\t", arr{i] ) ; for (i=0;1<=3 i++) { for (j=03)<=3-i;j++) { if (arr{j] > arr{j + 1]) { temp = arrfj] 5 arr(j] = arr{j + 1] ; arr[j + 1]=temp ; } 3 } printf ("\n\nArray after sorting:\n\n") ; for (i=0;i<=4; i++) printf ("\%d", arrfi] ); getchQ;TRACICAL No 313 —ll ye a 13. = tak eal ile Blgortthes 2 abe ci , Le. 1) Stout Ia (reste a New Node Temp Temp > Pater = 4) Temp =» Next = strirt > Nex, )_ Stir} > a ——____ aan 6) £xft | Algorftho, To _fasert Doel, start \ Input Node t wPher which you wish ho enter PIR = Stes 3 next AD while (+ aor qual» PTR2 Dak BND PTR2n6. por equal tn stew k neat) PTA = PTR Next = Je Cb eqeretl bb PTR Date) Create a newned. emp Temp = Dake _=N Temp >Next = PTR Heath PTR > Next = Teme Sturt = Temp a) Display “Blemeat not found“ Feet t J FOR EDUCATIONAL USEPractical no. 13 Hinclude
#include
#include
‘define newnode (struct node*) malloc(sizeofistruct node)) struct node { int data; struct node *next; B struct node *start; struct node *create_list(); struct node *merge_list(struct node *f1, struct node *12); void main() t struct node *n1,*n2,*n3; int len,reply; nl =n2=NULL; clrser(); printf("\n\n\titloin 2 circular Lists\n\n"); printf("\nEnter first circular linked-list\n");, nl = create list; printf("\nEnter second circular linked-list\n"); n2 = create list; printf("\n\nin First list is: \"); print_list(n1); printf("\n\n Second list is: \"); print_ist(n2); n3 = merge _list(n1,n2); printf("\n\n\nThe resultant joint list "ys print_list(n3); getch(); } lf main struct node *create_list() {int tdata; f£=NULL; printf("\n Enter data ( use 0 to exit): "); scanf("%d",&tdata);, while( tdata != 0 ) { ¢=newnode; if{ == NULL) { printf{"\n Insuf. mem. "); exit(0); 3 data = tdata; next = NULL; if(-= NULL) feo; else penext = ¢; pac printf(("\n Enter data (use 0 to exit): "); scanf("%d",Setdata); } return(f); print_list( struct node *f) { struct node *t; iftf = NULL) { rintf("List is empty"); return; 3 t=f while (t != NULL) { printf("%4d",t->data); t=t>next; return;struct node *merge_list(struct node *nl, struct node *n2) { int reply; struct node “1,2; if(al == NULL && n2 return(NULL); else if(nl != NULL && n2 == NULL) return(nl)s else NULL && n2 != NULL) return(n2); th=nl; while (1>next != NULL) { tl = tl->next; } tI->next =n2; return(nl);a EEC Eat ed 303_a a a f. ; bye jototoq of Maled LP. | Algustthen 2 1) Shert > Declavt shuchue “nade" wth date members det of syne Fatey tert of hype struct Ood Nedarye len 6) tor Perse Ifabed lest data fa ni; by the stakement 11 = Create lise); 2) Ask use» pp cater second Ifaked Irs data __ Short _sctond Jfaked |fs+ data fan b4 Stakement 2 = (vrate—lfsi() 3) fi G rspCos) y prlor_tist2 by calling prfiarist (ar); 4) Merge hua lRaked tsk £ stre_fo n2_by Wing | imi, Nas jain ltst (Oy4n2)/: ho) PrYor 26 cullen list by ding + peta list las), End mafat) FOR EDUCATIONAL USE.nocle+ Declare 5 faheyer phat 'hodophe! sek f= Null 15) Ask wee fy enter dakn fox |Poked Ifst to. dolder_ta_*telotha! 14) Jihfle (tebe 20) eC = nes noole cChetk pf Cc = = Null) " petarh (Insubbres ") ‘exfE(o): = eet > dota « datn’ ek C > neat = null: 1s) thes PA CF er P else er p >next =C, P= i 16) Aquat arabe 'tdolte! rehuo (Ph) fad functoo $7) Fun chon. ir S cletlare sheuck nade *b; 18) ¢theck %#(f ==Null) then _ pata (“list @s eanphy"), er ts pL I 14) dihfle C+) =Nult) Q2tofl +> data); FOR EDUCATIONAL USEassign t= b> nexek | __zeherr. Lad fincko 20) Fundfen shasch node ¥ jata list truck nocle x01) hack node #n2) | cleslare _foteyer "reply" Jeclape 2 potaher #b1, #7 pochve oes node: Ibi) Chek Pf (nt= Nut 22 2 == null) thea 2chen (oui!) | else | heels (0) != Null ge 2 22 Null) then eh (o)’ else heels Pen! => uy £2 021 =Nutt) thea _2ehea (02); tls er tient _ 4 while Uti > nest Js I ebb) etl 3 nett 2s sek +t\ > next =n _2ehvn (no) 2S) Pett. FOR EDUCATIONAL USE#include
#include
#include
#define newnode (struct node*) malloc(sizeof(struct node)) struct node { int data; struct node *next; ‘ struct node *start; struct node “create list(); struct node *join_list(struct node *f1, struct node *f2); void main() { struct node *f1,"£2,*£3; int len,reply; fl = f2= NULL; clrser(); printf("\nEnter first list\n"); fl = create list(); printf(""\Enter second list\n"); £2 = create list; printf("\n First list is\n"); print_list(fl); printf("\n Second list is\n"); print_list(f2); £3 = join_list(f1,f2); print{("\nThe resultant list is \n"); print_list(f3); zetch(); } struct node *create_list() { struct node *f,*c,*p; int tdata; f=NULL;ee ee a { c= newnode; if(e—= NULL) { printf("\n Insuf. mem. exit(O); } data = tdata; e->next = NULL; if{ f= NULL) prg printf("\n Enter data (use 0 to exit ) : seanf("%d" getdata); } return(f); } print_list( struct node *f) { struct node *t; int ULL) { printf("List is empty"); return; } a f while (t != NULL) { printf("%4d",t->data); next; } return; } struct node *join_list(struct node *f1, struct node *£2) { int reply;a else if( fl != NULL && f2 == NULL) return(f1); else if( f1 = NULL && f2 != NULL) retur(£2); else { =f; while (t1>next != NULL ) { t1=t>next; } tl>next = £2; return(fl); }
You might also like
CS3311 - Data Structures Lab.R2021
PDF
100% (3)
CS3311 - Data Structures Lab.R2021
58 pages
CS3361 Data Structure Lab
PDF
No ratings yet
CS3361 Data Structure Lab
59 pages
ds
PDF
No ratings yet
ds
119 pages
Data Structure
PDF
No ratings yet
Data Structure
89 pages
DS Final Record WORD
PDF
No ratings yet
DS Final Record WORD
87 pages
Data Sturcture and Algorithm Lab Manual
PDF
No ratings yet
Data Sturcture and Algorithm Lab Manual
61 pages
ADS LAB MANUAL(M-TECH)
PDF
No ratings yet
ADS LAB MANUAL(M-TECH)
68 pages
DSA Practicals Nayan
PDF
No ratings yet
DSA Practicals Nayan
70 pages
Assignment Data Structures 6-12
PDF
No ratings yet
Assignment Data Structures 6-12
14 pages
Data Structures record (1)-1
PDF
No ratings yet
Data Structures record (1)-1
67 pages
Chirag Saraswat 289 (DSA Lab)
PDF
No ratings yet
Chirag Saraswat 289 (DSA Lab)
29 pages
ds-fair_final[6]-4
PDF
No ratings yet
ds-fair_final[6]-4
38 pages
DSA List of Experiments
PDF
No ratings yet
DSA List of Experiments
62 pages
Full PRGRM DS
PDF
No ratings yet
Full PRGRM DS
47 pages
cs3311 Data Structures Lab Manual
PDF
No ratings yet
cs3311 Data Structures Lab Manual
100 pages
DS Lab
PDF
No ratings yet
DS Lab
97 pages
DS progam
PDF
No ratings yet
DS progam
60 pages
Data Structure
PDF
No ratings yet
Data Structure
86 pages
cs3311-to print
PDF
No ratings yet
cs3311-to print
59 pages
DS-lab record
PDF
No ratings yet
DS-lab record
69 pages
Avani DS Final
PDF
No ratings yet
Avani DS Final
41 pages
DSLAB 2022 Print
PDF
No ratings yet
DSLAB 2022 Print
59 pages
DAS Lab Programs2024
PDF
No ratings yet
DAS Lab Programs2024
55 pages
DS Lab
PDF
No ratings yet
DS Lab
74 pages
Practical 1 Dsa
PDF
No ratings yet
Practical 1 Dsa
19 pages
Data Structure Unit 2 Important Questions
PDF
No ratings yet
Data Structure Unit 2 Important Questions
48 pages
Ds Lab Manual Part b 2025
PDF
No ratings yet
Ds Lab Manual Part b 2025
15 pages
Dsaa
PDF
No ratings yet
Dsaa
49 pages
Lab DS
PDF
No ratings yet
Lab DS
35 pages
Circularqueue Merged
PDF
No ratings yet
Circularqueue Merged
35 pages
ds_practical_qs
PDF
No ratings yet
ds_practical_qs
23 pages
CS8381 Data Structures Record
PDF
No ratings yet
CS8381 Data Structures Record
107 pages
Vijay Ds Practical New
PDF
No ratings yet
Vijay Ds Practical New
41 pages
Amxn DSA2
PDF
No ratings yet
Amxn DSA2
32 pages
DS LAB Manual
PDF
No ratings yet
DS LAB Manual
78 pages
Program Using Function of Array
PDF
No ratings yet
Program Using Function of Array
60 pages
Dsa Lab Manual
PDF
No ratings yet
Dsa Lab Manual
35 pages
#Include #Include
PDF
No ratings yet
#Include #Include
23 pages
17bec1006 Cse2003 Lab Record
PDF
No ratings yet
17bec1006 Cse2003 Lab Record
70 pages
05 - Aditya - DS Practical File
PDF
No ratings yet
05 - Aditya - DS Practical File
44 pages
CS3311 DS Lab Record
PDF
No ratings yet
CS3311 DS Lab Record
18 pages
22R21A04F7-tejesh-3_week_-ds-1[1]
PDF
No ratings yet
22R21A04F7-tejesh-3_week_-ds-1[1]
9 pages
DSA For B.Tech
PDF
No ratings yet
DSA For B.Tech
22 pages
Practical Fil1 (Ankush Shukla 206320040)
PDF
No ratings yet
Practical Fil1 (Ankush Shukla 206320040)
32 pages
Stack & Queques Program
PDF
No ratings yet
Stack & Queques Program
17 pages
NAME: Nitesh Patel Class: Se Comps B' Roll No: 49 Practical 1 Implementation of Stack Using Array
PDF
No ratings yet
NAME: Nitesh Patel Class: Se Comps B' Roll No: 49 Practical 1 Implementation of Stack Using Array
37 pages
Expt 4 Ds
PDF
No ratings yet
Expt 4 Ds
12 pages
Ds File Extended
PDF
No ratings yet
Ds File Extended
21 pages
20mcal16 DS Lab Manual Isem
PDF
100% (1)
20mcal16 DS Lab Manual Isem
41 pages
DS Lab Record
PDF
No ratings yet
DS Lab Record
47 pages
Practical 8 To 12
PDF
No ratings yet
Practical 8 To 12
16 pages
Data Structure Lab Manual
PDF
No ratings yet
Data Structure Lab Manual
20 pages
Parth DS SEM 3
PDF
No ratings yet
Parth DS SEM 3
25 pages
Programms
PDF
No ratings yet
Programms
8 pages
Data Structure Term - Paper ON
PDF
No ratings yet
Data Structure Term - Paper ON
17 pages
Data Structure Term - Paper ON
PDF
No ratings yet
Data Structure Term - Paper ON
17 pages
Linked Lists
PDF
No ratings yet
Linked Lists
11 pages
Assignment II
PDF
No ratings yet
Assignment II
6 pages
Data Structures C
PDF
No ratings yet
Data Structures C
10 pages
Discrete Mathematics Notes Prof. S.G. Vaidya
PDF
100% (3)
Discrete Mathematics Notes Prof. S.G. Vaidya
200 pages
Class 5 Maths - Data Handling - CBSE Worksheets
PDF
No ratings yet
Class 5 Maths - Data Handling - CBSE Worksheets
9 pages
Human Behaviour in Organisation - ITM University - Semester 2 - MBA
PDF
100% (1)
Human Behaviour in Organisation - ITM University - Semester 2 - MBA
162 pages
Lexmark T652-T654 Service Manual
PDF
100% (2)
Lexmark T652-T654 Service Manual
572 pages
Research Methodology - ITM Unviersity - MBA - Sem 2
PDF
No ratings yet
Research Methodology - ITM Unviersity - MBA - Sem 2
180 pages
Software Testing Viva Questions and Answer Mca Sem5
PDF
100% (5)
Software Testing Viva Questions and Answer Mca Sem5
11 pages
Manual de Usuario Yaris Belta 2007
PDF
No ratings yet
Manual de Usuario Yaris Belta 2007
302 pages
Stair Case MCQ Ans Key
PDF
100% (4)
Stair Case MCQ Ans Key
7 pages
Software Testing Sem 5 Mca Idol Mumbai University - Journal
PDF
No ratings yet
Software Testing Sem 5 Mca Idol Mumbai University - Journal
57 pages
Library Management System With Blackbook Download
PDF
83% (12)
Library Management System With Blackbook Download
91 pages
Idol Question Paper Softwrare Testing Idol 2016 December Mumbai University
PDF
No ratings yet
Idol Question Paper Softwrare Testing Idol 2016 December Mumbai University
1 page
Mirabueno Chapter 5
PDF
No ratings yet
Mirabueno Chapter 5
11 pages
e cataloge
PDF
No ratings yet
e cataloge
41 pages
MicroEconomics - ITM University
PDF
100% (2)
MicroEconomics - ITM University
160 pages
Service and Maintenance Manual: Models 100SX 110SX 110SXJ 120SXJ
PDF
No ratings yet
Service and Maintenance Manual: Models 100SX 110SX 110SXJ 120SXJ
120 pages
BOP STACK All Phases of Drilling A 4CP Well
PDF
No ratings yet
BOP STACK All Phases of Drilling A 4CP Well
6 pages
Introduction To Marketing - Itm University
PDF
No ratings yet
Introduction To Marketing - Itm University
212 pages
Proline-Promass-40E (1)_2
PDF
No ratings yet
Proline-Promass-40E (1)_2
28 pages
DBMS Viva Questions MCA Idol
PDF
100% (10)
DBMS Viva Questions MCA Idol
14 pages
Wireless Technology Viva Questions and Answer Mca Sem5
PDF
100% (5)
Wireless Technology Viva Questions and Answer Mca Sem5
12 pages
Event Code List D6N
PDF
100% (1)
Event Code List D6N
4 pages
Probability & Stats (PNS) - Prof Vaidya - MCA - Sem 2 - Idol - Mumbai University
PDF
100% (3)
Probability & Stats (PNS) - Prof Vaidya - MCA - Sem 2 - Idol - Mumbai University
286 pages
EMR80HLR 220 V 60 HZ 1
PDF
No ratings yet
EMR80HLR 220 V 60 HZ 1
4 pages
Senior Design Final Report Engineering 340: David Dickensheets Knoa Knapper David Qu Matt Scholten
PDF
No ratings yet
Senior Design Final Report Engineering 340: David Dickensheets Knoa Knapper David Qu Matt Scholten
81 pages
Software Testing Lab Final
PDF
100% (1)
Software Testing Lab Final
112 pages
NTPC Cor - 23690 - 1 - 1
PDF
No ratings yet
NTPC Cor - 23690 - 1 - 1
8 pages
What Is Philosophy For by Mary Midgley
PDF
86% (7)
What Is Philosophy For by Mary Midgley
233 pages
Speaker's Purpose and Tone
PDF
No ratings yet
Speaker's Purpose and Tone
1 page
Advanced Web Technology Practical MCA IDol - Journal
PDF
No ratings yet
Advanced Web Technology Practical MCA IDol - Journal
58 pages
Thailand Cosmetics
PDF
No ratings yet
Thailand Cosmetics
24 pages
Awt Journal Final Shree Ram College
PDF
No ratings yet
Awt Journal Final Shree Ram College
52 pages
The Scientific Revolution
PDF
No ratings yet
The Scientific Revolution
16 pages
Bryan Johnson’s Daily Sleep Schedule
PDF
No ratings yet
Bryan Johnson’s Daily Sleep Schedule
5 pages
CLIL - Lesson Plan Equation
PDF
100% (1)
CLIL - Lesson Plan Equation
11 pages
Pauluzzo, R., & Mason, M. C. (2021). A multi-dimensional view of consumer value to explain socially-responsible consumer behavior: a fuzzy-set analysis of Generation Y’s fast-fashion consumers. Journal of Marketing Theory and Practice, 1-22.
PDF
No ratings yet
Pauluzzo, R., & Mason, M. C. (2021). A multi-dimensional view of consumer value to explain socially-responsible consumer behavior: a fuzzy-set analysis of Generation Y’s fast-fashion consumers. Journal of Marketing Theory and Practice, 1-22.
23 pages
C Journal Prints - Shree Ram College Bhandup
PDF
No ratings yet
C Journal Prints - Shree Ram College Bhandup
45 pages
Full MCA SEM 4 Practicals Idol Index Shree Ram College - Mumbai University
PDF
No ratings yet
Full MCA SEM 4 Practicals Idol Index Shree Ram College - Mumbai University
5 pages
DBMS Practicals Sem 3 Mca Idol - Shree Ram College
PDF
100% (3)
DBMS Practicals Sem 3 Mca Idol - Shree Ram College
34 pages
PWM Rectifier
PDF
No ratings yet
PWM Rectifier
8 pages
Web Pracs Mca Sem 1 Idol Mumbai SHree Ram College
PDF
No ratings yet
Web Pracs Mca Sem 1 Idol Mumbai SHree Ram College
23 pages
C++ Practicals Shree Ram College Bhandup
PDF
No ratings yet
C++ Practicals Shree Ram College Bhandup
20 pages
ADT MCA IDOL Practicals Shree Ram College Bhandup - MCA - Idol
PDF
No ratings yet
ADT MCA IDOL Practicals Shree Ram College Bhandup - MCA - Idol
18 pages
Daniel, S., & Bridges, S. K
PDF
No ratings yet
Daniel, S., & Bridges, S. K
8 pages
772 Full
PDF
No ratings yet
772 Full
11 pages
Uml Certificate Idol MCA Shree Ram College
PDF
No ratings yet
Uml Certificate Idol MCA Shree Ram College
2 pages
Security Model (Pearson)
PDF
No ratings yet
Security Model (Pearson)
7 pages
AWT Viva PDF
PDF
No ratings yet
AWT Viva PDF
11 pages
01 - Inlges - Ficha Tecnica Interruptor MasterPact NW - 48112
PDF
No ratings yet
01 - Inlges - Ficha Tecnica Interruptor MasterPact NW - 48112
2 pages
Editing With S - DEVELOP Authorizations
PDF
No ratings yet
Editing With S - DEVELOP Authorizations
8 pages
EXPERIMENT 11: Uni-Junction Transistor (UJT) CHARACTERISTICS
PDF
No ratings yet
EXPERIMENT 11: Uni-Junction Transistor (UJT) CHARACTERISTICS
4 pages
Web Practicals Certificate Shree Ram College
PDF
No ratings yet
Web Practicals Certificate Shree Ram College
3 pages
Beyond Translation Memories: Reinhard Schäler
PDF
No ratings yet
Beyond Translation Memories: Reinhard Schäler
7 pages
Production and Operations Management Essay
PDF
100% (1)
Production and Operations Management Essay
4 pages
Gestalt Approach To Team Building
PDF
71% (7)
Gestalt Approach To Team Building
2 pages