You are on page 1of 13

CSE 1315

Data Structure
Lecture-10

Prithwiraj Bhattacharjee
B.Sc in CSE at SUST
Adjunct Faculty, Dept. of CSE
Leading University, Sylhet
List
● Data Processing
○ Storing
○ And organized processing in a list
● One way is Linear array
● Linear relationship of the data elements are reflected by
○ Physical relationship of the data on memory
○ Not by the information contained in data elements
● Computing memory address is easy
List
● Disadvantage of Array
○ Expensive to Insert and delete
○ Occupies the block of memory
■ Can not double or triple the size of an array when required
○ Dense list or static data structure
● Another way
○ Take a field with the data elements named link or pointer
○ That link will contain the next data element address
○ Successive element need not occupy adjacent memory space
○ Thus Insert and delete is easy
○ This is called the Linked list
Linked List
● One way list
● Linear connection of data elements called nodes
● Linear order is given by means of pointer
● Node has two parts
○ Information of the element or data
○ Next pointers which contains the next node’s address
Schematic Diagram of Linked List

● Head or start pointer contains the first node address


● Last node has a Null pointer [ 0 or negative number actually]
● If start has 0 in it, then the list is??
Linked List
Linked List
● INFO is element array
● LINK is pointer array
● Start= 9, End = Null = 0
● Find the word?
● INFO[9]=N, LINK[9]=3
● INFO[3]=O, LINK[3]=6
● INFO[6]=[], LINK[6]=11
● INFO[11]=E, LINK[11]=7
● INFO[7]=X, LINK[7]=10
● INFO[10]=I, LINK[10]=4
● INFO[4]=T, LINK[4]=0
Linked List
Linked List
● Bond - ?
● Kelly - ?
● Hall - ?
● Neison - ?
Traverse a Linked list
● Linked list = LIST
● Linear array = INFO and LINK
● START = pointing first element
● NULL = pointing end of LIST
● PTR = pointer variable
● LINK[PTR] = pointing next node
Traverse a Linked list
Searching
● When Linked list is Unsorted:
Searching
● When Linked list is Sorted:

You might also like