Professional Documents
Culture Documents
All components
within the list are of same data type stored in nodes. Thus it is also a homogenous data structure.
To locate a specific node in the list, we must sequentially traverse through the list (Sequential
access). In a linked list, each item is allocated a space in memory as it is added to the list. A link is
kept between each item with the next item in the list. Each node of the list has following two
elements:
A data type is an instance of data that may be native to the language or defined by the user. And a
composition of data types, which forms some kind of systematic organization, is called Data
Structure.
Simple Data structure can be used as building blocks of complex data structure.
Array is a simple type of Data structure by using which we can build more complex data structure.
Data structure can be classified according to the following four types.
1. Linear & Non-linear: The data stored in a sequence is called Linear, while the other is called
Non-linear e.g. Array is Linear & Tree is Non-linear.
2. Homogenous & Non-homogenous: The data structure, which contains single type of data, is
known as Homogenous whereas others are Non- homogenous. For example, Array is an ordered set
of homogenous elements stored in a contiguous memory location. And Record (structure) is a Non-
Homogenous.
3. Static & Dynamic: This means the allocation of memory, either Static or Dynamic.
4. Direct access & Sequential access: The ability of directly referring to an item without having access
to any other is called Direct access. Sequential access is searching through a number of items before
finding a specific item i.e. an item, which is not directly accessible. For example, arrays provide a
direct access to any element within the array by means of an index (direct access). But in linked lists,
we must traverse through the list to locate a specific node (sequential access). Some of the data
structures, which will be discussed in detail later in the book, are given below.
Note: Arrays will not be discussed hereafter in this book. It will be presumed that the
reader is familiar with arrays.
Queues Queue is also a linear data structure of dynamic height, which contains single type of
data. Thus it is a homogenous data structure, all components of which are of same data type. A
queue is, also, called a First-In-First-Out (FIFO) system, in which insertion of a component can
take place only at one end, called “rear” end of the queue and deletion of a component can take
place only at other end, called “front” end of the queue (Sequential access). The word “queue” is
thus like the queue at a counter for service, in which customers are dealt with in the order in which
they ar- rive.
Stacks Stack is a linear data structure of dynamic height, all components of which are of same data
type (Homogenous components). A stack is also called a Last-In- First-Out (LIFO) system, in
which insertion and deletion of any component can take place only at the top of the stack, where
‘top’ is an end of the stack. That is, at any given time, the only item, which can be accessed to, is
on the top of the stack (sequential access). A common example of a stack is a dish or a coin
stacker. Dish- es are "pushed" onto the top and "popped" off the top.
Data Structures in C are used to store data in an organised and efficient manner.
The C Programming language has many data structures like an array, stack, queue,
linked list, tree, etc. A programmer selects an appropriate data structure and uses it
according to their convenience.
Array
Stack
Queue
Linked List
Trees
Hashing
ARRAY
Basic Operations
Following are the basic operations supported by an array.
Traverse - print all the array elements one by one.
Insertion - Adds an element at the given index.
Deletion - Deletes an element at the given index.
Search - Searches an element using the given index or by the value.
Update - Updates an element at the given index.
LIFO
STACK
QUEUE
A Queue is a linear data structure that stores a collection of elements. The queue
operates on first in first out (FIFO) algorithm.
LINKED LIST
A Linked List is a data structure. It is linear. The Linked List is like an array but, the Linked
List is not stored sequentially in the memory. Every linked list has 2 parts, the data
section and the address section that holds the address of the next element in the list,
which is called a node.
TREES
HASHING
A[5]
1
2
3
4
5
6