You are on page 1of 11

Department of Computer Science and Engineering (CSE)

HEADER LINKED LIST


A header linked list is a type of linked list that includes a special
node called a header node at the beginning of the list. The header
node serves as a container or holder for additional information
about the linked list.

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

REPRESENTATIONS

[1]

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

TYPES OF HEADER LINKED LIST


1. Grounded Header Linked List

It is a list whose last node contains the NULL pointer. In the


header linked list the start pointer always points to the header
node. start -> next = NULL indicates that the grounded header
linked list is empty. The operations that are possible on this
type of linked list are Insertion, Deletion, and Traversing.

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

TYPES(Contdd…)

2. Circular Header
Linked List

In Circular header
linked list the link
of the last node
will point back to
the header node.

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

TRAVERSING A CIRCULAR HEADER LINKED LIST


1. Set PTR = Link[Start]
2. Repeat Steps 3 & 4 while PTR != Start
3. Write Info[PTR]
4. Set PTR = Link[PTR]
5. Exit

NOTE: In case of Grounded Repeat steps 3 & 4 while PTR !=


NULL

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

INSERTION IN A HEADER LINK LIST-AT BEGINNING


1. Set PTR= Start
2. Repeat Steps while(Link[PTR] != Start)
3. PTR=Link[PTR]
4. Link[PTR] = New
5. Link[new] = Head
6. Head = New

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

INSERTION IN A HEADER LINK LIST-AT END


1. Set PTR=Start
2. Repeat while(Link[PTR] != Start)
3. PTR = Link[PTR]
4. Link[PTR] = New
5. Link[New] = Head

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

DELETION IN HEADER LINK LIST


In stage I we will find location LOC pf node which is to be deleted & we
will also find the location of preceiding node which is denoted by LOCP.

Find BHL(Info ,Link, Start, Item, LOC, LOCP)


1. Save= Start, PTR = Link[Start]
2. Repeat while info[PTR] != Item and PTR != Start
Set Save = PTR ,PTR = Link[PTR]
3. If Info[PTR] = Item
Set LOC = PTR & LOCP = Save
Else
Set LOC = NULL
4. Exit

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

DELETION(Conttd…)
DELLOCHL(Ifo, Link, Start, Avail, Item)
1. Call Find BHL(Info ,Link, Start, Item, LOC, LOCP)
2. If LOC = NULL then write Item not in List and Exit
3. Set Link[LOCP] = Link[LOC]
4. Set Link[LOC] = Avail & Avail = LOC
5. Exit

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Books Recommended
• Lipschutz, Seymour, “Data Structures”, Schaum's Outline Series,
Tata McGraw Hill.
• Gilberg/Forouzan,” Data Structure with C ,Cengage Learning.
• Augenstein,Moshe J , Tanenbaum, Aaron M, “Data Structures
using C and C++”, Prentice Hall of India.
• Aho, Alfred V., Ullman, Jeffrey D., Hopcroft ,John E. “Data
Structures and Algorithms”, Addison Wesley.

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

THANKS

University Institute of Engineering (UIE)

You might also like