You are on page 1of 4

Linked Lists Linked list is again a linear data structure of dynamic length.

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:

Introduction to Data Structures

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.

Data structure = Organized data + Allowed operations

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.

Arrays This is a simplest type of linear data structure (one dimensional array), by


means of which a set of finite number say n of similar data elements can be referenced
by a set of n consecutive numbers 1, 2, 3, …….. n. For example, consider the following list
of elements:  5, 6, 8, 4, 3, 1, 2, 56, 67, 78 This list of 10 elements can be stored in an array
of size 10 as
follows:  

 
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.

Let us look into some of these data structures:

 Array
 Stack 
 Queue
 Linked List
 Trees
 Hashing

ARRAY

An Array is a sequential collection of elements, of the same data type. They are


stored sequentially in memory. An Array is a data structure that holds a similar type
of elements.

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

A stack is a linear data structure. It follows the last in first out approach. A


new item is added at the top of a stack. Both insert and deletion operation is
performed from one end of the 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

A tree is a data structure that has one root node and many sub-nodes. It is another


one of the data structures which are designed on top of a linked list.

HASHING

Hash table is another data structure. It is used to implement an associative array, a


structure that can map keys to values. Hash table uses a hash function to compute
an index into an array of buckets. Hash tables are very useful data structures.
Graph:
In this case, data sometimes hold a relationship between the pairs of elements
which is not necessarily following the hierarchical structure. Such data structure is
termed as a Graph.

A[5]

1
2
3
4
5
6

You might also like