Académique Documents
Professionnel Documents
Culture Documents
Linked List
Dr.Aruna Malapati Asst Professor Dept of CS & IT BITS Pilani, Hyderabad Campus
First semester 2011-12 BITS Pilani Hyderabad campus TA C252 COMPUTER PROGRAMMING II
Implementation of an ADT
Choose a data structure to represent the ADT E.g. arrays, records, etc. Each operation associated with the ADT is implemented by one or more subroutines Two standard implementations for the list ADT Array-based Linked list
Array Implementation
Elements are stored in contiguous array positions
Linked Lists
A Head
node
A
data pointer
Hence a Linked List is a collection of structures ordered not by their physical placement in memory (like an array) but by logical links that are stored as part of the data in the structure itself. Such structure is represented as follows:
node
item
next
The structure may contain more than one item with different types
member1
member2
Member N
next next
Linked-list also called as one-way list is a collection of data elements called as nodes. The linear order is given by pointers. Each node has two parts.(Data & link field)
Example
Its a dynamic data structure Hence it can grow or shrink as needed It can be made just as long as required No wastage of memory space Not necessary to specify the number of nodes Easy to insert and delete items and rearrangement is very easy
Linear list
Circular list
1. What is wrong with the following declaration? struct element { double value; struct element link; };