Notes DSA
Notes DSA
Data:
Types of Data
Basic
o Numeric
o Integer
o Real Number
o Character
Abstract
o Developed from basic data types
o Used in place of basic data types to handle large amount of data
o It is for ease of use
o Array/ list/strings
Types of Abstract
o Linear
The type in which data is stored in sequence and is used in a sequence.
o Non-Linear
The type in which data is neither stored nor used in sequence.
Algorithm:
1. Start
2. Take two no.
3. Add these no.
4. Show sum
5. End
Stack:
A type of linear data structure used to store data or delete data from one end. It has two
functions;
Pointer:
It is used to store and address or represent a value at that address. A pointer used in stack is TOP.
Basic Principle
Linked List
In a single linked list, the address of the first node is always stored in a reference node known as
"front" (Sometimes it is also known as "head"). Always next part (reference part) of the last node
must be NULL.
Node
Data Address
The pointer used for link list is a variable which has the address of the starting node. It is name is
start. It is used to represent the status of a node.
The address of the first node is given to the pointer while the address of the second node is given
to the first node and so on.
A Doubly Linked List is represented using the Linear Arrays in memory where each memory
address stores 3 parts: Data Value, Memory address of next Element and Memory Address of the
previous Element.
Previous Address
Data
Address Next
The circular linked list is a linked list where all nodes are connected to form a circle. In a circular
linked list, the first node and the last node are connected to each other which forms a circle.
Basic functions of linked list
Insert first
Insert last
Insert specific
Delete first
Delete last
Delete specific
Structure
Structure is a collection of variables of different data types under a single name. It is similar to
a class in that, both holds a collection of data of different data types.
Queue
A linear data structure that is open from both ends to perform. (FIFO)
FIFO (Basic Principle)
Function:
o En-queue
o De-queue
Pointer used:
o Rear
o Front
“Like top to check the state of queue”.
To enter a value we start from tail.
To delete a value we start from head.
Types of Queue
It has non-linear behavior is a hierarchical structure used to represent and organized data in a
way that is easy to use and navigate.
Types of Trees
Binary tree
Ternary tree
Full/ Partial binary tree
Binary Search tree
AVL binary tree
B-Tree
Binary Tree
If a root node has only two leaves nodes it is a binary. It has different levels. Complexity of
binary tree = 2n
Ternary Tree
If a root has three branches / leaves node then it is called ternary tree.
Basic Operation of Tree
Create
Insert
Search
Traversal
o In-order
o Pre-order
o Post-order
Tree Traversal
Depth first
Breath first