Introduction to Data Structure & Linked List
Objective
• What are Data Structures
• Need of Data Structures
• Types of Data Structures
• Built In Data Structures
• Linked List Implementation
What are Data Structures
• It is a way of organizing all data items that considers not only the elements stored
but also their relationship with each other
• In computer science, a data structure is a particular way of storing and organizing
data in a computer so that it can be used efficiently.
• Data structure mainly specifies:
– Organization of data.
– Accessing methods.
– Degree of associativity.
– Processing alternative for the information.
Need of Data Structure
• Different kinds of data structures are meant for different kinds of applications,
and some are highly specialized to specific tasks.
• Data structures are important for the following reasons:
Data structures are used in almost every program or software system.
Specific data structures are essential ingredients of many efficient algorithms, and make possible
the management of huge amounts of data, such as large integrated collection of databases.
Some programming languages emphasize data structures, rather than algorithms, as the key
organizing factor in software design.
Type of Data Structure
• Linear data structure: A linear data structure traverses the data elements
sequentially, in which only one data element can directly be reached. Example:
Arrays, Linked Lists
• Non-Linear data structure: Every data item is attached to several other data
items in a way that is specific for reflecting relationships. The data items are not
arranged in a sequential structure.
Example: Trees, Graphs
Built In Data Structures
• Arrays
User Defined Data Structures
• Linked List
• Stack
• Queue
• Tree
• Graph
• Many more…..
Introduction to Linked List
In computer science, a linked list is a data structure that consists of a sequence of
data records such that in each record there is a field that contains a reference (i.e.,
a link) to the next record in the sequence.
Thus, every node in a linked list has two components: one to store the relevant
information (that is, data) and one to store the address, called the link, of the
next node in the list.
data link
Structure of a Node
Linked lists are among the most common data structures, and are used to
implement many important data structures, such as stacks, queues.
Linked lists allow insertion and removal of nodes at any point in the list, with a
constant number of operations.
Defining a Node
struct LinkedList
{
int info;
struct LinkedList *link;
};
Linked lists contain nodes which have a data field as well as a link field,
which points to the next node in the linked list.
Operations on Linked List
Search an item
Insert an Item
Insert item at Beginning
Insert item at end
Insert item after search position
Delete an Item
Delete item from Beginning
Delete item from end
Delete item after search position
Linked List Example