data structures notes
data structures notes
Note: Data structures like stack , queue , tree and graph can be
static or dynamic depending on, whether these are implemented
using an array or a link list.
3. Homogeneous and Non-homogeneous data structures
Homogeneous data structure are those in which data of same type
can be stored.
Example: Array
Non-Homogeneous data structure are those in which data of
different type can be stored.
Example: Link list.
TREE
A tree t can be a defined as finite(means limit or not infinite) set of
nodes in which there is one specially designated node known as root
of the tree.
and the remaining nodes are partitioned into disjoint sets t1, t2….tn
such that each t1 is itself a tree and is known as sub-tree of its root.
A general tree
A line which is connects a parent node to its child node is called
an edge or branch.
All the nodes in a tree except the root node, has a parent node
associated with it.
A node in the tree can have zero or more children called
its successors.
A node having no child is called a leaf node or terminal node.
sometimes, it is also known as external nodes and non-terminal
nodes are called internal nodes.
Nodes having same parent node are called siblings or brothers.
The length of a path zero from every node to itself. In the above
figure, A->N->E->K which is length 3.
The height of any node in a tree is the length of the longest path
from that node to a terminal node i.e node B is at height of 2 and
node E is at height of 1.
The degree of node can be defined as number of child nodes it has.
Node A has degree 3 and G has degree 1.
The weight of the tree is the number of external nodes available in
that tree. In the above figure, weight is 7 i.e K,L,F,M,H,N and J are
external nodes.
Each node is assigned a level number which comes from the length
of the path from the root to that node. Root of a tree is said to be at
level 0.
The level also known as depth of the tree, of any node is the
number of edges that are to travelled from the root node to that
particular node.
What is binary numbers?
Binary means two numbers i.e 0 or 1.
What is binary addition and subtraction?
Addition and subtraction are arithmetic operators.
Binary addition means adding between two binary numbers.
Binary subtraction means subtracting between two binary numbers.
Overflow rule:
In general term, overflow means , a thing more than capacity and it
is wastage.
In computer organization,Overflow occurs when the resulting value
of an operation performed on valid representations of numbers is
out of the range of valid values. That is, the resulting value is
greater than max or less than min.
How overflow occurs depends:
1. Add −8 to +3
-----------------
Add −5 to −2
-----------------
• 1011 + 10010 =
1 1 0 0 1
0 1 0 1 0 1 1 0
0 0 0 0 1 0 1 1
+ 0 1 0 1 1
+ 0 0 1 1 0 1 0 0
+ 0 0 0 1 0 0 1 0
0 0 1 0 0
1 0 0 0 1 0 1 0
0 0 0 1 1 1 0 1
1101010:
1 1 1 1 1
1 1
0 0 1 1 0 0 0 1 1 0 0 1 1
0 1 0 1 0 0 0 1
+ 1 1 1 0 0 1 0 0
+ 0 1 0 0 1
+ 0 0 0 1 1 0 0 1
0 0 0 1 0 1 0 1
1 1 1 0 0
0 1 1 0 1 0 1 0
Overflow. The carry-out is discarded, and
No overflow. Sum is corre
No overflow. Sum is the sum is not correct
correct.
(+A) + (+B) = −C
(−A) + (−B) = +C
(−7) 1001
+(−6) 1010
------------
BINARY SUBTRACTION
(+A) − (−B) = −C
(−A) − (+B) = +C
---------- -----
13 1101 = −8 + 5 = −3 : Overflow
fig. (a) A
binary tree
Here, the node A is the root of the binary tree which is the top of
the tree.
B and C are the left and right sub-trees of the root A, respectively.
Two trees are called similar if both are having same structure but
the elements in both the tree can be different as shown in fig. b
fig. b similar binary tree
The file organization is the study of storing the data records into the
files. There are various file organization techniques like sequential
organization , random file organization and indexed file
organization. These file organization techniques differ in record
sequencing and retrieval methods used.
A data structure and a file organization are same but differ in the
following aspects:
In implementation
In access Methods
Data structure are thought of as in main memory like RAM and
file organization as in auxiliary storage like disks.
INTERRUPT
Interrupt signal is – active low (0) or active high (1) signal used to
send to a device to say “stop doing what you’re doing and listen to
me. I’ve got something for you”.
1. INTERNAL INTERRUPT
2. SOFTWARE INTERRUPT
3. EXTERNAL INTERRUPT
1. Hardware Interrupts
2. Software Interrupts
A software interrupts is a particular instructions that can be
inserted into the desired location in the program. There are eight
Software interrupts in 8085 Microprocessor.
1. RST0
2. RST1
3. RST2
4. RST3
5. RST4
6. RST5
7. RST6
8. RST7
1. TRAP—————-0024
2. RST7.5————–003C
3. RST6.5————–0034
4. RST5.5————–002C
5. INTR
TRAP has highest priority and RST7.5 has second highest priority and so on.
TRAP
RST7.5
When RST6.5 pin is at logic 1, INTE flip-flop is set. RST 6.5 has third
highest priority and RST 5.5 has fourth highest priority.
INTR