0% found this document useful (0 votes)
17 views9 pages

Lecture-17 (LinkedList and Its Representation)

Uploaded by

zainakbardaudani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views9 pages

Lecture-17 (LinkedList and Its Representation)

Uploaded by

zainakbardaudani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Lecture: 17

Data Structures and Algorithm Analysis


Batch: 18CS, Semester: Second, Year: Second

Linked List and its Representation

Presented by: Dr. Sammer Zai


Assistant Professor
Department of Computer Systems, Mehran, UET.

1
Fair Use Notice

The material used in this presentation i.e., pictures/graphs/text, etc.


is solely intended for educational/teaching purpose, offered free of
cost to the students for use under special circumstances of Online
Education due to COVID-19 Lockdown situation and may include
copyrighted material - the use of which may not have been
specifically authorized by Copyright Owners. It’s application
constitutes Fair Use of any such copyrighted material as provided in
globally accepted law of many countries. The contents of
presentations are intended only for the attendees of the class being
conducted by the presenter.
Contents

• What is Linked List?


• Memory Representation of Linked List
• Schematic Representation of linked List

3
Introduction to Linked List
• Linked list, or one-way list, is a linear data structure consists of data record
in a sequence, with reference data fields in each record to link each record
to the subsequent data field.
• In case of arrays, it is relatively expensive to insert and delete elements in
an array.
• Also, since an array usually occupies a block of memory space, one cannot
simply double or triple the size of an array when additional space is
required.
• For this reason, arrays are called dense lists and are said to be static data
structures.
• In case of linked list, successive elements in the list need not to occupy
adjacent space in memory.

4
Introduction to Linked List

• It consists of a sequence of nodes, each containing arbitrary data field and one or
two reference (links) pointing to the next and/or previous nodes.
• Linked List consist of nodes.
• A node is the building block of a linked list which consists of two parts:
– A data element(information part) representing the information in the current
position
of the list.
– A pointer/link/address to the next node in the list.
• The START pointer points to the first node of the list.
• The last node of Linked List has its Link portion null indicating end of Linked List
• No node in Linked List has its data portion empty.

5
Schematic Diagram of a linked list with 6
nodes

Figure 1: Schematic Representation of a Linked List with six nodes

6
Description of Linked List
• Figure 1 shows a schematic diagram of a linked list with 6 nodes. Each node is
pictured with two parts. The left part represents the information part of the
node, which may contain an entire record of data items (e.g., name, address, . . .).
The right part represents the nextpointer field of the node, and there is an arrow
draw from it to the next node in the list. This follows the usual practice of drawing
an arrow from a field to a node when the address of the node appears in the
given field. The pointer of the last node contains a special value, called the null
pointer, which is any invalid address. In actual practice, 0 or a negative number is
used for the null pointer. The null pointer, denoted by x in the diagram, signals
the end of the list. The linked list also contains a list pointer variable called START
which contains the address of the first node in the list; hence there is an arrow
drawn from START to the first node. Clearly, we need only this address in START to
trace through the list. A special case is the list that has no nodes. Such a list is
called the null list or empty list and is denoted by the null pointer in the variable
START.

7
Representation of Linked List in Memory
• Let List be a linked list. Then LIST will be maintained in memory,
unless otherwise specified or implied as follows.
• First of all , LIST requires two linear arrays we will call them here INFO
and LINK such that INFO[K] and LINK[K] contain , respectively , the
information part and the nextpointer field of a node of LIST .
• As noted above ,LIST also requires a variable name such as START
which contains the location of the beginning of the list, and a
nextpointer sential denoted by NULL which indicates the end of the
list.
• Since the subscripts of the arrays INFO and LINK will usually be
positive , we will choose NULL is = 0 ,unless otherwise stated.
8
Representation of Linked List in Memory
Example indicates that the
nodes of the list need not
occupy adjacent elements in
the arrays INFO and LINK ,and
that more than one list may be
maintained in the same linear
arrays INFO and LINK however ,
each list must have its own
pointer variable giving the
location of its 1st node.

LINK[PTR] =LINK[9]=3

Figure 2: Representation of Linked List in Memory 9

You might also like