2. Data Structures
Data Structure can be defined as the group of data elements
which provides an efficient way of storing and organizing data
in the computer so that it can be used efficiently.
3. Applications
Data Structures are widely used in almost every
aspect of Computer Science i.e. Operating
System, Compiler Design, Artificial intelligence,
Graphics and many more.
Data Structures are the main part of many
computer science algorithms as they enable the
programmers to handle the data in an efficient
way.
It plays a vital role in enhancing the performance
of a software or a program as the main function of
the software is to store and retrieve the user’s
data as fast as possible.
5. Primitive DataType:
• Primitive data types are predefined types of
data, which are supported by the
programming language.
• integer, character, & string are all primitive
data types.
• They are predefined in any programing
language.
6. Type Storage size Value range
char 1 byte -128 to 127 or 0 to 255
unsigned char 1 byte 0 to 255
signed char 1 byte -128 to 127
int 2 or 4 bytes
-32,768 to 32,767 or -2,147,483,648 to
2,147,483,647
unsigned int 2 or 4 bytes 0 to 65,535 or 0 to 4,294,967,295
short 2 bytes -32,768 to 32,767
unsigned
short
2 bytes 0 to 65,535
long 4 bytes -2,147,483,648 to 2,147,483,647
unsigned long 4 bytes 0 to 4,294,967,295
DATA TYPES & RANGE
7. Algorithm:
• It is a step by step
procedure, which
defines the collection
of set of well defined
instructions to
perform a specific
task.
• Every task or program
In any language has a
specific algorithm.
8. Example:
TASK− Design an algorithm to add two numbers
and display the result
Step 1 − START
Step 2 − declare three integers a, b & c
Step 3 − define values of a & b
Step 4 − add values of a & b
Step 5 − store output of step 4 to c
Step 6 − print c
Step 7 − STOP
10. Non primitive:
• Non-primitive data types are not defined by
the programming language, but are instead
created by the programmer.
• They are sometimes called "reference
variables," or "object references," since they
reference a memory location, which stores the
data.
• In data structures they classified into two
ways
11. Static Datastructure:
In Static data structure the size of the structure is fixed.
Dynamic Data structure:
In Dynamic data structure the size of the structure in
not fixed and can be modified during the operations
performed on it.
12. Arrays in Data Structures
• An array is a collection of values of same datatype
stored at contiguous memory locations.
• It is used to store the multiple values of same
datatype together.
• It easier to calculate the position of each element
& simply adding and subtracting to a base value is
possible.
Syntax:
data_type array_name [array_size];
13. Linked list:
• A linked list is a linear data structure, in which
the elements are not stored at contiguous
memory locations.
• The elements in a linked list are linked using
pointers.
14. Singly linked list:
• Each node has data and a pointer is assigned
to the next node.
Doubly Linked List:
A Doubly Linked List (DLL) contains an extra
pointer, typically called previous pointer,
together with next pointer and data which are
there in singly linked list.
15. Circular Linked List:
• A circular linked list is a variation of linked
list in which the last element is linked to the
first element. This forms a circular loop.
16. STACK:
• Stack is a linear data structure which follows a
particular order in which the operations are
performed.
• The order may be LIFO(Last In First Out) or
FILO(First In Last Out).
17. Queue
• A Queue is a linear structure which follows a
particular order in which the operations are
performed.
• The order is First In First Out (FIFO).
18. Trees
• Tree is a hierarchical data structure which stores the
information naturally in the form of hierarchy style.
• It represents the nodes connected by edges.
Tree Terminology
Node
Root
Parent
Child
19. Binary Tree:
A binary tree is a tree data structure in which each node
has at most two children, which are referred to as the left
child and the right child.
There are four types of binary tree:
1. Full Binary Tree
2. Complete Binary Tree
3. Skewed Binary Tree
4. Extended Binary Tree
20. Graphs:
• A Graph is a non-linear data structure
consisting of nodes and edges.
• The nodes are sometimes also referred
to as vertices and the edges are lines
or arcs.
22. Summary
Data structures are useful because they allow us to
organize and store data in a way that is efficient and
effective for various computational tasks. They provide a
way to access and manipulate data, and they can be used
to solve a wide range of problems in computer science and
related fields.
By choosing the appropriate data structure, we can optimize
algorithms and reduce the time and resources required for
computational tasks. For example, arrays and hash tables
provide fast access to individual elements, while linked lists
and trees allow for efficient manipulation and traversal of
data.
Overall, data structures are an essential part of computer
science and programming, and understanding how to use
them effectively can greatly improve the efficiency and