What is a singly linked list- What is a doubly linked list- What is a.docx

dorisc7 19 views 2 slides Feb 06, 2023
Slide 1
Slide 1 of 2
Slide 1
1
Slide 2
2

About This Presentation

What is a singly linked list? What is a doubly linked list? What is a circulary linked list? Give the class definition for doubly linked list, and show an implementation for the insertNode() member function.
Solution
single linked list:single linked list consists of two fields. those are
1) first fi...


Slide Content

What is a singly linked list? What is a doubly linked list? What is a circulary linked list? Give
the class definition for doubly linked list, and show an implementation for the insertNode()
member function.
Solution
single linked list:single linked list consists of two fields. those are
1) first field contains node that is which stores the element
2) second field contains the pointer which stores the address of the nextnode.
double linked list:double linked list consists of three fields.those are
1)node to store the element
2)pointer which stores the address of the previous node
3)pointer which stores the address of the next node
circular linked list:single circular linked list is connected in a circular fashion
it consists of two fields
1)first field to store the node
2) pointer second field to store the address of the next field
for the last node the ponter points to the first field.
class definition of doubly linked list:
}
// inserting the node at the beginning

function insert( list l, Node nN)
if l.fN == null
l.fN = nN
l.lN = nN
nN.prev := null
nN.next := null
else
insertBefore(l, l.fN, nN)
function insertEnd( List l, Node nN)
if l.lN == null
insertBeginning(l, nN)
else
insertAfter(l, l.lN, nN)
};
Tags