SlideShare a Scribd company logo
1 of 6
Download to read offline
^^^
Q2. Discuss about Header Node?
And also write a program for unordered single linked list and linked implementation of
QUEUE?
Solution
Header node:
Sometimes it is desire to keep an extra node at the front of a List. Such a node doesn’t represent
an item in the List and is called a Header Node or a List Header. The Information field of such
Header node might be unused but the Next field maintains the first node address. More often the
information of such a node could be used to keep Global Information about the Entire List.
One of the applications of Header node is the information portion of the Header node contains
the number of nodes (not including Header) in the List. In this Structure the Header must be
adjusted the total number of nodes when we apply addition or deletion operation on the List. We
can directly obtained the total number of nodes without traversing the entire List.
By using this application, we can develop Data Structure Stack easily. Since Header node
information field maintains the number of elements that the Stack contains.
Another application is we can simply develop the Data Structure Queue. Until now, two external
pointers, Front & Rear, were necessary for a List to represent a Queue. However, now only a
single external pointer is sufficient to maintain a Queue that is Head node. Because the Header
node next field behave like a Front and information field of Header node maintains last node
address so that it is behave like a Rear .
Another possibility for the use of the information portion of a List Header is as a pointer
to a Curr node in the List during a traversal process. This would be eliminate the node for an
external pointer during traversal.
#include
#include
#include
#include
struct node
{
char info;
struct node *next;
};
typedef struct node sl;
void display(sl *);
sl * create(sl *root)
{
sl *curr,*new;
char val;
printf(" Enter $ to STOP --- Otherwise Continue : ");
fflush(stdin);
scanf("%c",&val);
while(val != '$')
{
new=(sl *) malloc(sizeof(sl));
new->info = val;
new->next = NULL;
if(root == NULL)
root = new;
else
{
curr = root;
while( curr->next != NULL )
curr = curr->next;
curr->next = new;
}
printf(" Enter $ to STOP --- Otherwise Continue : ");
fflush(stdin);
scanf("%c",&val);
}
printf(" The Created Linked List Is  ");
display(root);
return root;
}
sl * delete(sl *root,char val)
{
sl *temp,*curr,*rear;
curr = root;
rear = NULL;
while( curr != NULL && val != curr->info )
{
rear = curr;
curr = curr->next;
}
if(curr == NULL)
{
if( rear == NULL)
{
printf(" Linked List is Empty");
printf(" Deletion is not Possible ");
}
else
{
printf(" deleted Node does not exist in List");
printf(" Deletion is not Possible ");
}
}
else
{
if( rear == NULL)
{
temp = root;
root = root->next;
}
else
{
temp = curr;
rear->next = curr->next;
}
printf(" Node is deleted ");
printf(" Deleted Node information is %c",temp->info);
free(temp);
}
display(root);
return root;
}
sl * insert(sl *root,char val)
{
sl *curr,*new;
new=(sl *) malloc(sizeof(sl));
new->info = val;
new->next = NULL;
if(root == NULL)
root = new;
else
{
curr = root;
while( curr->next != NULL )
curr = curr->next;
curr->next = new;
}
return root;
}
void display(sl *start)
{
printf(" ROOT-> ");
while(start != NULL )
{
printf("%c -> ",start->info);
start =start->next;
}
printf("NULL  ");
getch();
}
char menu()
{
char ch;
clrscr();
gotoxy(33,2); printf("MAIN MENU");
gotoxy(25,6); printf("Creation C");
gotoxy(25,8); printf("Insertion I");
gotoxy(25,10);printf("Removing R");
gotoxy(25,12);printf("Display D");
gotoxy(25,14);printf("Quit Q");
gotoxy(10,30);printf(" Enter Choice : ");
fflush(stdin);
scanf("%c",&ch);
return(ch);
}
main()
{
sl *insert(sl *,char),*delete(sl *,char),*create(sl *);
sl *root=NULL;
char item;
char choice;
char menu();
while( ( choice=menu() ) != 'Q' || ( choice != 'q') )
{
switch(choice)
{
case 'c':
case 'C': root = NULL;
root = create(root);
break;
case 'i':
case 'I': printf("Enter Character Item to be Inserted : ");
fflush(stdin);
scanf("%c",&item);
root = insert(root,item);
break;
case 'd':
case 'D': printf("The Current Linked List is : ");
display(root);
getch();
break;
case 'r':
case 'R': printf("Enter the Item wich you want to be Remove :");
fflush(stdin);
scanf("%c",&item);
root = delete(root,item);
break;
case 'q':
case 'Q': return;
}
}
}

More Related Content

Similar to ^^^Q2. Discuss about Header Node    And also write a program fo.pdf

Use the singly linked list class introduced in the lab to implement .pdf
Use the singly linked list class introduced in the lab to implement .pdfUse the singly linked list class introduced in the lab to implement .pdf
Use the singly linked list class introduced in the lab to implement .pdfsales87
 
For this homework, you will write a program to create and manipulate.pdf
For this homework, you will write a program to create and manipulate.pdfFor this homework, you will write a program to create and manipulate.pdf
For this homework, you will write a program to create and manipulate.pdfherminaherman
 
in C++ , Design a linked list class named IntegerList to hold a seri.pdf
in C++ , Design a linked list class named IntegerList to hold a seri.pdfin C++ , Design a linked list class named IntegerList to hold a seri.pdf
in C++ , Design a linked list class named IntegerList to hold a seri.pdfeyewaregallery
 
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...Balwant Gorad
 
How to delete one specific node in linked list in CThanksSolu.pdf
How to delete one specific node in linked list in CThanksSolu.pdfHow to delete one specific node in linked list in CThanksSolu.pdf
How to delete one specific node in linked list in CThanksSolu.pdffootstatus
 
Program In C You are required to write an interactive C program that.pdf
Program In C You are required to write an interactive C program that.pdfProgram In C You are required to write an interactive C program that.pdf
Program In C You are required to write an interactive C program that.pdfamitbagga0808
 
Unit ii(dsc++)
Unit ii(dsc++)Unit ii(dsc++)
Unit ii(dsc++)Durga Devi
 
Data Structures and Agorithm: DS 04 Linked List.pptx
Data Structures and Agorithm: DS 04 Linked List.pptxData Structures and Agorithm: DS 04 Linked List.pptx
Data Structures and Agorithm: DS 04 Linked List.pptxRashidFaridChishti
 
coding in C- Create a function called reverseList that takes the head.docx
coding in C- Create a function called reverseList that takes the head.docxcoding in C- Create a function called reverseList that takes the head.docx
coding in C- Create a function called reverseList that takes the head.docxtienlivick
 
pleaase I want manual solution forData Structures and Algorithm An.pdf
pleaase I want manual solution forData Structures and Algorithm An.pdfpleaase I want manual solution forData Structures and Algorithm An.pdf
pleaase I want manual solution forData Structures and Algorithm An.pdfwasemanivytreenrco51
 
Data Structures and Agorithm: DS 09 Queue.pptx
Data Structures and Agorithm: DS 09 Queue.pptxData Structures and Agorithm: DS 09 Queue.pptx
Data Structures and Agorithm: DS 09 Queue.pptxRashidFaridChishti
 

Similar to ^^^Q2. Discuss about Header Node    And also write a program fo.pdf (20)

Data structure
Data  structureData  structure
Data structure
 
Use the singly linked list class introduced in the lab to implement .pdf
Use the singly linked list class introduced in the lab to implement .pdfUse the singly linked list class introduced in the lab to implement .pdf
Use the singly linked list class introduced in the lab to implement .pdf
 
linkedlist.pptx
linkedlist.pptxlinkedlist.pptx
linkedlist.pptx
 
For this homework, you will write a program to create and manipulate.pdf
For this homework, you will write a program to create and manipulate.pdfFor this homework, you will write a program to create and manipulate.pdf
For this homework, you will write a program to create and manipulate.pdf
 
Data structure
 Data structure Data structure
Data structure
 
in C++ , Design a linked list class named IntegerList to hold a seri.pdf
in C++ , Design a linked list class named IntegerList to hold a seri.pdfin C++ , Design a linked list class named IntegerList to hold a seri.pdf
in C++ , Design a linked list class named IntegerList to hold a seri.pdf
 
Linear data structure concepts
Linear data structure conceptsLinear data structure concepts
Linear data structure concepts
 
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
 
Adt of lists
Adt of listsAdt of lists
Adt of lists
 
DS Unit 2.ppt
DS Unit 2.pptDS Unit 2.ppt
DS Unit 2.ppt
 
Unit - 2.pdf
Unit - 2.pdfUnit - 2.pdf
Unit - 2.pdf
 
Linked list
Linked listLinked list
Linked list
 
How to delete one specific node in linked list in CThanksSolu.pdf
How to delete one specific node in linked list in CThanksSolu.pdfHow to delete one specific node in linked list in CThanksSolu.pdf
How to delete one specific node in linked list in CThanksSolu.pdf
 
Program In C You are required to write an interactive C program that.pdf
Program In C You are required to write an interactive C program that.pdfProgram In C You are required to write an interactive C program that.pdf
Program In C You are required to write an interactive C program that.pdf
 
Unit ii(dsc++)
Unit ii(dsc++)Unit ii(dsc++)
Unit ii(dsc++)
 
Data Structures and Agorithm: DS 04 Linked List.pptx
Data Structures and Agorithm: DS 04 Linked List.pptxData Structures and Agorithm: DS 04 Linked List.pptx
Data Structures and Agorithm: DS 04 Linked List.pptx
 
coding in C- Create a function called reverseList that takes the head.docx
coding in C- Create a function called reverseList that takes the head.docxcoding in C- Create a function called reverseList that takes the head.docx
coding in C- Create a function called reverseList that takes the head.docx
 
pleaase I want manual solution forData Structures and Algorithm An.pdf
pleaase I want manual solution forData Structures and Algorithm An.pdfpleaase I want manual solution forData Structures and Algorithm An.pdf
pleaase I want manual solution forData Structures and Algorithm An.pdf
 
C Exam Help
C Exam Help C Exam Help
C Exam Help
 
Data Structures and Agorithm: DS 09 Queue.pptx
Data Structures and Agorithm: DS 09 Queue.pptxData Structures and Agorithm: DS 09 Queue.pptx
Data Structures and Agorithm: DS 09 Queue.pptx
 

More from arjunhassan8

Explain how substances get across membranes and into the cell.Sol.pdf
Explain how substances get across membranes and into the cell.Sol.pdfExplain how substances get across membranes and into the cell.Sol.pdf
Explain how substances get across membranes and into the cell.Sol.pdfarjunhassan8
 
Does yeast have a post translation pathway for protein synthesisIf .pdf
Does yeast have a post translation pathway for protein synthesisIf .pdfDoes yeast have a post translation pathway for protein synthesisIf .pdf
Does yeast have a post translation pathway for protein synthesisIf .pdfarjunhassan8
 
Determine whether the following statements about human ABO Wood group.pdf
Determine whether the following statements about human ABO Wood group.pdfDetermine whether the following statements about human ABO Wood group.pdf
Determine whether the following statements about human ABO Wood group.pdfarjunhassan8
 
Describe a similarity transformation that maps trapezoid WXYZ to tr.pdf
Describe a similarity transformation that maps trapezoid WXYZ to tr.pdfDescribe a similarity transformation that maps trapezoid WXYZ to tr.pdf
Describe a similarity transformation that maps trapezoid WXYZ to tr.pdfarjunhassan8
 
blackboard.ecu edu Take Test Exam ll-Blou2300601201730 he map above .pdf
blackboard.ecu edu Take Test Exam ll-Blou2300601201730 he map above .pdfblackboard.ecu edu Take Test Exam ll-Blou2300601201730 he map above .pdf
blackboard.ecu edu Take Test Exam ll-Blou2300601201730 he map above .pdfarjunhassan8
 
Bitcoin as an Ethical Dilemma closing case (Question below article).pdf
Bitcoin as an Ethical Dilemma closing case (Question below article).pdfBitcoin as an Ethical Dilemma closing case (Question below article).pdf
Bitcoin as an Ethical Dilemma closing case (Question below article).pdfarjunhassan8
 
2. This seasons flu virus is spreading based on a logistic functio.pdf
2. This seasons flu virus is spreading based on a logistic functio.pdf2. This seasons flu virus is spreading based on a logistic functio.pdf
2. This seasons flu virus is spreading based on a logistic functio.pdfarjunhassan8
 
Write the code segments to create a monitor that has the same behavi.pdf
Write the code segments to create a monitor that has the same behavi.pdfWrite the code segments to create a monitor that has the same behavi.pdf
Write the code segments to create a monitor that has the same behavi.pdfarjunhassan8
 
Which of the following is NOT a rationale for using mRNA intermed.pdf
Which of the following is NOT a rationale for using mRNA intermed.pdfWhich of the following is NOT a rationale for using mRNA intermed.pdf
Which of the following is NOT a rationale for using mRNA intermed.pdfarjunhassan8
 
Which elements are in series and which are in parallel in Figure P1.3.pdf
Which elements are in series and which are in parallel in Figure P1.3.pdfWhich elements are in series and which are in parallel in Figure P1.3.pdf
Which elements are in series and which are in parallel in Figure P1.3.pdfarjunhassan8
 
What domain is horizontal gene transfer most common within Multiple .pdf
What domain is horizontal gene transfer most common within Multiple .pdfWhat domain is horizontal gene transfer most common within Multiple .pdf
What domain is horizontal gene transfer most common within Multiple .pdfarjunhassan8
 
This problem is based on the B92 method of quantum key distri.pdf
This problem is based on the B92 method of quantum key distri.pdfThis problem is based on the B92 method of quantum key distri.pdf
This problem is based on the B92 method of quantum key distri.pdfarjunhassan8
 
The _ operator can be used to determine a variable address The variab.pdf
The _ operator can be used to determine a variable address The variab.pdfThe _ operator can be used to determine a variable address The variab.pdf
The _ operator can be used to determine a variable address The variab.pdfarjunhassan8
 
The main difference between passive and active transport is the spec.pdf
The main difference between passive and active transport is  the spec.pdfThe main difference between passive and active transport is  the spec.pdf
The main difference between passive and active transport is the spec.pdfarjunhassan8
 
The opposite movement of supination is ___. Pronation flexion exte.pdf
The opposite movement of supination is ___.  Pronation  flexion  exte.pdfThe opposite movement of supination is ___.  Pronation  flexion  exte.pdf
The opposite movement of supination is ___. Pronation flexion exte.pdfarjunhassan8
 
The latter or final stages of an RNA based heriditary world were lik.pdf
The latter or final stages of an RNA based heriditary world were lik.pdfThe latter or final stages of an RNA based heriditary world were lik.pdf
The latter or final stages of an RNA based heriditary world were lik.pdfarjunhassan8
 
The following table is a summary of randomly chosen student evaluati.pdf
The following table is a summary of randomly chosen student evaluati.pdfThe following table is a summary of randomly chosen student evaluati.pdf
The following table is a summary of randomly chosen student evaluati.pdfarjunhassan8
 
A female carrier of Tay-Sachs wants to have a child with a male carri.pdf
A female carrier of Tay-Sachs wants to have a child with a male carri.pdfA female carrier of Tay-Sachs wants to have a child with a male carri.pdf
A female carrier of Tay-Sachs wants to have a child with a male carri.pdfarjunhassan8
 
So I dont understand explicit equations. Whats the formula and how.pdf
So I dont understand explicit equations. Whats the formula and how.pdfSo I dont understand explicit equations. Whats the formula and how.pdf
So I dont understand explicit equations. Whats the formula and how.pdfarjunhassan8
 
Sapling Learning Select the statements that explain why duplication i.pdf
Sapling Learning Select the statements that explain why duplication i.pdfSapling Learning Select the statements that explain why duplication i.pdf
Sapling Learning Select the statements that explain why duplication i.pdfarjunhassan8
 

More from arjunhassan8 (20)

Explain how substances get across membranes and into the cell.Sol.pdf
Explain how substances get across membranes and into the cell.Sol.pdfExplain how substances get across membranes and into the cell.Sol.pdf
Explain how substances get across membranes and into the cell.Sol.pdf
 
Does yeast have a post translation pathway for protein synthesisIf .pdf
Does yeast have a post translation pathway for protein synthesisIf .pdfDoes yeast have a post translation pathway for protein synthesisIf .pdf
Does yeast have a post translation pathway for protein synthesisIf .pdf
 
Determine whether the following statements about human ABO Wood group.pdf
Determine whether the following statements about human ABO Wood group.pdfDetermine whether the following statements about human ABO Wood group.pdf
Determine whether the following statements about human ABO Wood group.pdf
 
Describe a similarity transformation that maps trapezoid WXYZ to tr.pdf
Describe a similarity transformation that maps trapezoid WXYZ to tr.pdfDescribe a similarity transformation that maps trapezoid WXYZ to tr.pdf
Describe a similarity transformation that maps trapezoid WXYZ to tr.pdf
 
blackboard.ecu edu Take Test Exam ll-Blou2300601201730 he map above .pdf
blackboard.ecu edu Take Test Exam ll-Blou2300601201730 he map above .pdfblackboard.ecu edu Take Test Exam ll-Blou2300601201730 he map above .pdf
blackboard.ecu edu Take Test Exam ll-Blou2300601201730 he map above .pdf
 
Bitcoin as an Ethical Dilemma closing case (Question below article).pdf
Bitcoin as an Ethical Dilemma closing case (Question below article).pdfBitcoin as an Ethical Dilemma closing case (Question below article).pdf
Bitcoin as an Ethical Dilemma closing case (Question below article).pdf
 
2. This seasons flu virus is spreading based on a logistic functio.pdf
2. This seasons flu virus is spreading based on a logistic functio.pdf2. This seasons flu virus is spreading based on a logistic functio.pdf
2. This seasons flu virus is spreading based on a logistic functio.pdf
 
Write the code segments to create a monitor that has the same behavi.pdf
Write the code segments to create a monitor that has the same behavi.pdfWrite the code segments to create a monitor that has the same behavi.pdf
Write the code segments to create a monitor that has the same behavi.pdf
 
Which of the following is NOT a rationale for using mRNA intermed.pdf
Which of the following is NOT a rationale for using mRNA intermed.pdfWhich of the following is NOT a rationale for using mRNA intermed.pdf
Which of the following is NOT a rationale for using mRNA intermed.pdf
 
Which elements are in series and which are in parallel in Figure P1.3.pdf
Which elements are in series and which are in parallel in Figure P1.3.pdfWhich elements are in series and which are in parallel in Figure P1.3.pdf
Which elements are in series and which are in parallel in Figure P1.3.pdf
 
What domain is horizontal gene transfer most common within Multiple .pdf
What domain is horizontal gene transfer most common within Multiple .pdfWhat domain is horizontal gene transfer most common within Multiple .pdf
What domain is horizontal gene transfer most common within Multiple .pdf
 
This problem is based on the B92 method of quantum key distri.pdf
This problem is based on the B92 method of quantum key distri.pdfThis problem is based on the B92 method of quantum key distri.pdf
This problem is based on the B92 method of quantum key distri.pdf
 
The _ operator can be used to determine a variable address The variab.pdf
The _ operator can be used to determine a variable address The variab.pdfThe _ operator can be used to determine a variable address The variab.pdf
The _ operator can be used to determine a variable address The variab.pdf
 
The main difference between passive and active transport is the spec.pdf
The main difference between passive and active transport is  the spec.pdfThe main difference between passive and active transport is  the spec.pdf
The main difference between passive and active transport is the spec.pdf
 
The opposite movement of supination is ___. Pronation flexion exte.pdf
The opposite movement of supination is ___.  Pronation  flexion  exte.pdfThe opposite movement of supination is ___.  Pronation  flexion  exte.pdf
The opposite movement of supination is ___. Pronation flexion exte.pdf
 
The latter or final stages of an RNA based heriditary world were lik.pdf
The latter or final stages of an RNA based heriditary world were lik.pdfThe latter or final stages of an RNA based heriditary world were lik.pdf
The latter or final stages of an RNA based heriditary world were lik.pdf
 
The following table is a summary of randomly chosen student evaluati.pdf
The following table is a summary of randomly chosen student evaluati.pdfThe following table is a summary of randomly chosen student evaluati.pdf
The following table is a summary of randomly chosen student evaluati.pdf
 
A female carrier of Tay-Sachs wants to have a child with a male carri.pdf
A female carrier of Tay-Sachs wants to have a child with a male carri.pdfA female carrier of Tay-Sachs wants to have a child with a male carri.pdf
A female carrier of Tay-Sachs wants to have a child with a male carri.pdf
 
So I dont understand explicit equations. Whats the formula and how.pdf
So I dont understand explicit equations. Whats the formula and how.pdfSo I dont understand explicit equations. Whats the formula and how.pdf
So I dont understand explicit equations. Whats the formula and how.pdf
 
Sapling Learning Select the statements that explain why duplication i.pdf
Sapling Learning Select the statements that explain why duplication i.pdfSapling Learning Select the statements that explain why duplication i.pdf
Sapling Learning Select the statements that explain why duplication i.pdf
 

Recently uploaded

SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code ExamplesPeter Brusilovsky
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesPooky Knightsmith
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi RajagopalEADTU
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...Gary Wood
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhleson0603
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...Nguyen Thanh Tu Collection
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17Celine George
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...Nguyen Thanh Tu Collection
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................MirzaAbrarBaig5
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportDenish Jangid
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismDabee Kamal
 
Book Review of Run For Your Life Powerpoint
Book Review of Run For Your Life PowerpointBook Review of Run For Your Life Powerpoint
Book Review of Run For Your Life Powerpoint23600690
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptxPoojaSen20
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxCeline George
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project researchCaitlinCummins3
 
PSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxPSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxMarlene Maheu
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxneillewis46
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...Nguyen Thanh Tu Collection
 

Recently uploaded (20)

Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical Principles
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in Hinduism
 
Book Review of Run For Your Life Powerpoint
Book Review of Run For Your Life PowerpointBook Review of Run For Your Life Powerpoint
Book Review of Run For Your Life Powerpoint
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptx
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptx
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
 
PSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxPSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptx
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptx
 
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 

^^^Q2. Discuss about Header Node    And also write a program fo.pdf

  • 1. ^^^ Q2. Discuss about Header Node? And also write a program for unordered single linked list and linked implementation of QUEUE? Solution Header node: Sometimes it is desire to keep an extra node at the front of a List. Such a node doesn’t represent an item in the List and is called a Header Node or a List Header. The Information field of such Header node might be unused but the Next field maintains the first node address. More often the information of such a node could be used to keep Global Information about the Entire List. One of the applications of Header node is the information portion of the Header node contains the number of nodes (not including Header) in the List. In this Structure the Header must be adjusted the total number of nodes when we apply addition or deletion operation on the List. We can directly obtained the total number of nodes without traversing the entire List. By using this application, we can develop Data Structure Stack easily. Since Header node information field maintains the number of elements that the Stack contains. Another application is we can simply develop the Data Structure Queue. Until now, two external pointers, Front & Rear, were necessary for a List to represent a Queue. However, now only a single external pointer is sufficient to maintain a Queue that is Head node. Because the Header node next field behave like a Front and information field of Header node maintains last node address so that it is behave like a Rear . Another possibility for the use of the information portion of a List Header is as a pointer to a Curr node in the List during a traversal process. This would be eliminate the node for an external pointer during traversal. #include #include #include #include struct node { char info; struct node *next;
  • 2. }; typedef struct node sl; void display(sl *); sl * create(sl *root) { sl *curr,*new; char val; printf(" Enter $ to STOP --- Otherwise Continue : "); fflush(stdin); scanf("%c",&val); while(val != '$') { new=(sl *) malloc(sizeof(sl)); new->info = val; new->next = NULL; if(root == NULL) root = new; else { curr = root; while( curr->next != NULL ) curr = curr->next; curr->next = new; } printf(" Enter $ to STOP --- Otherwise Continue : "); fflush(stdin); scanf("%c",&val); } printf(" The Created Linked List Is "); display(root); return root; } sl * delete(sl *root,char val) { sl *temp,*curr,*rear; curr = root;
  • 3. rear = NULL; while( curr != NULL && val != curr->info ) { rear = curr; curr = curr->next; } if(curr == NULL) { if( rear == NULL) { printf(" Linked List is Empty"); printf(" Deletion is not Possible "); } else { printf(" deleted Node does not exist in List"); printf(" Deletion is not Possible "); } } else { if( rear == NULL) { temp = root; root = root->next; } else { temp = curr; rear->next = curr->next; } printf(" Node is deleted "); printf(" Deleted Node information is %c",temp->info); free(temp); } display(root);
  • 4. return root; } sl * insert(sl *root,char val) { sl *curr,*new; new=(sl *) malloc(sizeof(sl)); new->info = val; new->next = NULL; if(root == NULL) root = new; else { curr = root; while( curr->next != NULL ) curr = curr->next; curr->next = new; } return root; } void display(sl *start) { printf(" ROOT-> "); while(start != NULL ) { printf("%c -> ",start->info); start =start->next; } printf("NULL "); getch(); } char menu() { char ch; clrscr(); gotoxy(33,2); printf("MAIN MENU"); gotoxy(25,6); printf("Creation C");
  • 5. gotoxy(25,8); printf("Insertion I"); gotoxy(25,10);printf("Removing R"); gotoxy(25,12);printf("Display D"); gotoxy(25,14);printf("Quit Q"); gotoxy(10,30);printf(" Enter Choice : "); fflush(stdin); scanf("%c",&ch); return(ch); } main() { sl *insert(sl *,char),*delete(sl *,char),*create(sl *); sl *root=NULL; char item; char choice; char menu(); while( ( choice=menu() ) != 'Q' || ( choice != 'q') ) { switch(choice) { case 'c': case 'C': root = NULL; root = create(root); break; case 'i': case 'I': printf("Enter Character Item to be Inserted : "); fflush(stdin); scanf("%c",&item); root = insert(root,item); break; case 'd': case 'D': printf("The Current Linked List is : "); display(root); getch(); break; case 'r':
  • 6. case 'R': printf("Enter the Item wich you want to be Remove :"); fflush(stdin); scanf("%c",&item); root = delete(root,item); break; case 'q': case 'Q': return; } } }