0% found this document useful (0 votes)
137 views166 pages

370 FORMULA Book Free Unacademy

Uploaded by

Sachin Dwivedi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
137 views166 pages

370 FORMULA Book Free Unacademy

Uploaded by

Sachin Dwivedi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 166

350 FORMULA BOOK

Revise all 350+ Formulae


For GAT CS IT

MUST WATCH SESSION Sweta Kumari


TELEGRAM Link to get NOTES :
https://t.me/SWETAKCS
Referral Code : HELLOSONU01
ABOUT ME
FOUNDER AT GATE
NOTEBOOK
Mentored 81,000+ Students |
My Multiple Students secured
AIR Below 100 in GATE |
Joined top IISc, IITs & NITs |
Joined PSUs |
Sweta Kumari
6 Years Teaching Exp.

Expertise in : TOC, Computer


Networks , Operating
systems , DBMS, Compilers ,
NEW BATCH

HELLOSONU01
NEW BATCH

HELLOSONU01
COMPLETED 10 LECTURES
TODAY LIVE CLASS - REGULAR EXPRESSIONS
You can expect FULL MARKS in TOC
NEW

BEST FOR BEGINNERS

BEST FOR REPEATERS

HELLOSONU01
MY UPCOMING COURSES
COMPLETE COURSE ON DISCRETE
MATHEMATICS STARTING
From 8th NOV
For GATE 2023/24/25

COMPLETE COURSE ON ALGORITHMS


For GATE 2023/24/25 STARTING
From 13th NOV
BEST REVISION Book For GATE CS IT
(Covers all the Important Concepts , All the Important PYQs , Important Formulae , Short Tricks
From All the Units of Computer science subjects + General Aptitude)
FOR NEW SUBSCRIBERS
Free with
Unacademy
Subscription using
referral code
HELLOSONU01
(ALSO DISCOUNT
Code)
HAMILTONINAN CIRCUIT (n>=3) = Passes through every vertex
Check Planarity of graph Bipartite graph = No odd
1. e, v where v >= 3 DIRAC’S THEOREM = Degree of every vertex should be at least n/2 GRAPH
length cycle
Circuits of length 3 THEORY
ORE’S THEOREM = deg(u) + deg(v) >= n (non adjacent)
Revise in 1
E <= 3v-6 E(G’) + E(G) = Complete graph
NOTE – Degree of 1 vertex means not Hamiltonian circuit Page
2. e, v where v >= 3 E(G’) = n(n-1)/2 - E(G)
No Circuits of length 3
E <= 2v-4 strongly connected components = edge EULER GRAPH = Passes through every edge
between every pair of vertex VERTICES OF EVEN DEGREE =
Single Revision Page (SRP) EULER CIRCUIT
Maximum number of edges in a
Handshaking thm :
Sum of degree of vertices = 2 x edges
PYQs connected planar, simple graph = 3n-6 EXACTLY 2 VERTICES OF ODD DEGREE =
EULER PATH BUT NOT CIRCUIT
Four Color thm : 4 colors are sufficient to color planar 90 Minutes Lecture Converted in 1 Page
graph Kn,n => K3,3
Kn+1,n => K8,9 Isomorphic Graphs = Count nodes , count edges ,
Always Hamiltonian circuit.
Self Complementary graph – Isomorphic to its Check degree of each vertex , check length of cycle
complement (in both graphs)
DISCRETE MATHEMATICS
= Half no. of edges in complete graph = n(n-1)/4 (must
be disable by 4 or 0) Maximum number of edges in undirected
A connected graph ‘G’ may have graph
C5 cycle is the only graph which is self complementary
at most (n–2) cut vertices. = n(n-1)/2
Euler’s formula : R = E – V + 2 (Always 1 region is
the maximum number of cut No. of graphs can be constructed = 2 n(n-1)/2
bounded)
edges possible is ‘n-1’.
Undirected Graph :
If all weights distinct in MST ,
Number of odd degree vertices is even.
1. Always contain emin
Sum of degree of all vertices is even. Maximum number of edges in Complete 2. Unique MST
bipartite graph = n2/4 3. Emax present in MST
Max. edges in connected graph which doesn’t form cycle
= (n-1) Circuit Rank = m-(n-1)
5000+ FROM WHERE YOU
PRACTICE
QUESTIONS
SHOULD PRACTICE ?
CS IT WORKBOOK
TEST SERIES : 350 ASK A DOUBT
12 GATE CS IT BOOKS That will be delivered to your home

Only With ICONIC


SUBSCRIPTION
HELLOSONU01
24 months PLUS 6 months PLUS 24 months ICONIC
SAVE 58% SAVE 10% SAVE 59%
₹2,351 /mo ₹5,079 /mo ₹2,794 /mo
2025 2025
₹74,500
₹62,693 ₹33,859 ₹67,050
₹56,424 ₹30,473 18 months
18 months 4 months SAVE 53%
SAVE 53% SAVE 23% ₹3,200 /mo
₹2,624 /mo ₹4,329 /mo ₹64,000
₹52,472 ₹19,240 ₹57,600
₹47,225 ₹17,316 15 months
SAVE 48%
15 months 3 months ₹3,540 /mo
SAVE 50% 2023 ₹5,622 /mo 2024 ₹58,999
2024 ₹2,820 /mo ₹18,740 ₹53,099
₹46,999 ₹16,866 12 months
₹42,299 SAVE 42%
12 months ₹3,975 /mo
SAVE 45% ₹53,000
₹47,700
₹3,092 /mo 9 months
₹41,228
₹37,105
UNACADEMY SAVE 29%
₹4,875 /mo
9 months
SAVE 34%
PLUS/ ICONIC ₹48,750
₹43,875
₹3,711 /mo 6 months
₹37,106 Use Code : HELLOSONU01 to ₹6,863 /mo
₹45,750
₹33,395 get max discount & 350 SRPs
₹41,175
Book Free
DISCRETE
MATHEMATICS
LIVE NOW : Revise 80+ Formulae of Discrete Mathematics in 60 minutes only.

1 to 4

1. p → q = ∼p ∨ q.
2. p → q = ∼q → ∼p.
3. Biconditional is equivalent to EX-NOR Gate.
4. p ↔ q = (p ∧ q) ∨ (∼p ∧ ∼q).

Use HELLOSONU01 code to get max discount On


subscription & 350 SRPs Book Free
LIVE NOW : Revise 80+ Formulae of Discrete Mathematics in 60 minutes only.
Word Replacement
And Conjunction (∧)
5 to 13
Or Disjunction (∨)
But And
Whenever If
When If
Either p or q p or q

Neither p nor q Not p and Not q

p unless q ∼q → p

p is necessary but not


(q → p) and ∼(p → q)
sufficient for q

Use HELLOSONU01 code to get max discount On subscription & 350


Use HELLOSONU01SRPs code toFree
Book get max discount On
subscription & 350 SRPs Book Free
LIVE NOW : Revise 80+ Formulae of Discrete Mathematics in 60 minutes only.

13 - 15

For a conditional statement p → q only ,


The converse statement is q → p
The inverse statement ∼p → ∼q
The contrapositive statement is ∼q → ∼p

Use HELLOSONU01 code to get max discount On subscription & 350


Use HELLOSONU01SRPs code toFree
Book get max discount On
subscription & 350 SRPs Book Free
LIVE NOW : Revise 80+ Formulae of Discrete Mathematics in 60 minutes only.

16 - 17
For a conditional statement p → q,
1. Its converse statement (q → p) and inverse statement
(∼p → ∼q) are equivalent to each other.
2. p → q and its contrapositive statement (∼q → ∼p) are
equivalent to each other.

Use HELLOSONU01 code to get max discount On subscription & 350


Use HELLOSONU01SRPs code toFree
Book get max discount On
subscription & 350 SRPs Book Free
LIVE NOW : Revise 80+ Formulae of Discrete Mathematics in 60 minutes only.

30

Use HELLOSONU01 code to get max discount On subscription & 350


Use HELLOSONU01SRPs code toFree
Book get max discount On
subscription & 350 SRPs Book Free
LIVE NOW : Revise 80+ Formulae of Discrete Mathematics in 60 minutes only.
Complement of a Graph 2. The sum of total number
of edges in G and G’ is
equal to the total number
of edges in a complete
graph.

|E(G)| + |E(G’)|
= C(n,2)
= n(n-1) / 2

1. Number of vertices in G = Number of vertices in G’.

|V(G)| = |V(G’)| 41

Use HELLOSONU01 code to get max discount On subscription & 350


Use HELLOSONU01SRPs code toFree
Book get max discount On
subscription & 350 SRPs Book Free
LIVE NOW : Revise 80+ Formulae of Discrete Mathematics in 60 minutes only.

42 - 45
If |V1| = m and |V2| = n, then the complete bipartite graph is denoted by Km, n.
1. Km,n has (m+n) vertices and (mn) edges.
2. Km,n is a regular graph if m=n.
In general, a complete bipartite graph is not a complete graph.
3. Km,n is a complete graph if m=n=1.
4. The maximum number of edges in a bipartite graph with n vertices is ⌊n2 /4⌋

Use HELLOSONU01 code to get max discount On subscription & 350


Use HELLOSONU01SRPs code toFree
Book get max discount On
subscription & 350 SRPs Book Free
LIVE NOW : Revise 80+ Formulae of Discrete Mathematics in 60 minutes only.

Simple Graph 46 - 47
A graph with no loops and no parallel edges is called a simple graph.
•The maximum number of edges possible in a simple graph with ‘n’ vertices
is nC2 where nC2 = n(n – 1)/2.
•The number of simple graphs possible with ‘n’ vertices = 2nc2 = 2n(n-1)/2.

Use HELLOSONU01 code to get max discount On subscription & 350


Use HELLOSONU01SRPs code toFree
Book get max discount On
subscription & 350 SRPs Book Free
LIVE NOW : Revise 80+ Formulae of Discrete Mathematics in 60 minutes only.

SIMPLE LOGIC TO CHECK


PLANARITY OF GRAPH
48 - 49
LIVE NOW : Revise 80+ Formulae of Discrete Mathematics in 60 minutes only.
50 - 51
HAMILTONINAN CIRCUIT (n>=3)
DIRAC’S THEOREM = Degree of every vertex should be at least n/2
ORE’S THEOREM = deg(u) + deg(v) >= n (Non Adjacent Vertices)

Use HELLOSONU01 code to get max discount On subscription & 350


Use HELLOSONU01SRPs code toFree
Book get max discount On
subscription & 350 SRPs Book Free
LIVE NOW : Revise 80+ Formulae of Discrete Mathematics in 60 minutes only.
52
74
Power Sets
The power set is the set all possible subset of the set S. Denoted by P(S).
Example: What is the power set of {0,1,2}?
Solution: All possible subsets
{∅}, {0}, {1}, {2}, {0,1}, {0,2}, {1,2}, {0,1,2}.
Note: Empty set and set itself is also the member of this set of subsets.

Cardinality of power set is

2^n

Use HELLOSONU01 code to get max discount On subscription & 350


Use HELLOSONU01SRPs code toFree
Book get max discount On
subscription & 350 SRPs Book Free
LIVE NOW : Revise 80+ Formulae of Discrete Mathematics in 60 minutes only.

Number of Reflexive Relations on a set with n 53


elements : 2n(n-1).

Use HELLOSONU01 code to get max discount On subscription & 350


Use HELLOSONU01SRPs code toFree
Book get max discount On
subscription & 350 SRPs Book Free
LIVE NOW : Revise 80+ Formulae of Discrete Mathematics in 60 minutes only.

Number of Symmetric Relations on a set with n 54


elements : 2n(n+1)/2

Use HELLOSONU01 code to get max discount On subscription & 350


Use HELLOSONU01SRPs code toFree
Book get max discount On
subscription & 350 SRPs Book Free
LIVE NOW : Revise 80+ Formulae of Discrete Mathematics in 60 minutes only.
Number of Anti-Symmetric Relations on a set with n 55
elements: 2n 3n(n-1)/2.

Use HELLOSONU01 code to get max discount On subscription & 350


Use HELLOSONU01SRPs code toFree
Book get max discount On
subscription & 350 SRPs Book Free
LIVE NOW : Revise 80+ Formulae of Discrete Mathematics in 60 minutes only.

Number of Asymmetric Relations on a set with n 56


elements: 3n(n-1)/2.

Use HELLOSONU01 code to get max discount On subscription & 350


SRPs Book Free
LIVE NOW : Revise 80+ Formulae of Discrete Mathematics in 60 minutes only.

Irreflexive Relations on a set with n elements : 2n(n-1). 57

Use HELLOSONU01 code to get max discount On subscription & 350


Use HELLOSONU01SRPs code toFree
Book get max discount On
subscription & 350 SRPs Book Free
LIVE NOW : Revise 80+ Formulae of Discrete Mathematics in 60 minutes only.

Reflexive and symmetric Relations on a set with n elements : 2n(n-1)/2.

58

Use HELLOSONU01 code to get max discount On subscription & 350


Use HELLOSONU01SRPs code toFree
Book get max discount On
subscription & 350 SRPs Book Free
LIVE NOW : Revise 80+ Formulae of Discrete Mathematics in 60 minutes only.

59 TRANSALTE IN
PROPOSITIONAL LOGIC
“I will not go to school unless you come.”
This QUESTION is of the form- “p unless q”.

So, the symbolic form is ∼ q → p where-


p : I will go to school
q : You come

Use HELLOSONU01 code to get max discount On subscription & 350


Use HELLOSONU01SRPs code toFree
Book get max discount On
subscription & 350 SRPs Book Free
LIVE NOW : Revise 80+ Formulae of Discrete Mathematics in 60 minutes only.

If G is a connected planar simple graph with ‘e’ edges, ‘v’


60
vertices and ‘r’ number of regions in the planar
representation of G, then-

r=e–v+2

This is known as Euler’s Formula.


It remains same in all the planar representations of the
graph.

Use HELLOSONU01 code to get max discount On subscription & 350


Use HELLOSONU01SRPs code toFree
Book get max discount On
subscription & 350 SRPs Book Free
LIVE NOW : Revise 80+ Formulae of Discrete Mathematics in 60 minutes only.
In Graph Theory,
Handshaking Theorem states in any given graph,
61
Sum of degree of all the vertices is twice the number of edges contained in it.

In any graph,
•The sum of degree of all the vertices is always even.
•The sum of degree of all the vertices with odd degree is always even.
•The number of vertices with odd degree are always even.

Use HELLOSONU01 code to get max discount On subscription & 350


Use HELLOSONU01SRPs code toFree
Book get max discount On
subscription & 350 SRPs Book Free
LIVE NOW : Revise 80+ Formulae of Discrete Mathematics in 60 minutes only.

62

Use HELLOSONU01 code to get max discount On subscription & 350


Use HELLOSONU01SRPs code toFree
Book get max discount On
subscription & 350 SRPs Book Free
LIVE NOW : Revise 80+ Formulae of Discrete Mathematics in 60 minutes only.
63

Because, In Binary Tree, number of leaf nodes is always one more than nodes with
two children.

L=T+1
where, L=Number of leaf nodes

T=Number of internal nodes with two children.

199

Use HELLOSONU01 code to get max discount On subscription & 350


Use HELLOSONU01SRPs code toFree
Book get max discount On
subscription & 350 SRPs Book Free
LIVE NOW : Revise 80+ Formulae of Discrete Mathematics in 60 minutes only.
67

Use HELLOSONU01 code to get max discount On subscription & 350


Use HELLOSONU01SRPs code toFree
Book get max discount On
subscription & 350 SRPs Book Free
LIVE NOW : Revise 80+ Formulae of Discrete Mathematics in 60 minutes only.

Let G be a finite group on 84 elements. The size of a largest


possible proper subgroup of G is _______ . GATE CS 2018
Note – This was Numerical Type question.
(A) 42
(B) 84
(C) 1
(D) 28 According to Lagrange’s theorem, states that for any finite
group G, the order (number of elements) of every subgroup
H of G divides the order of G.

Therefore, possible subgroups of group on 84 elements are :


76 1, 2, 3, 4, 6, 7, 12, 14, 21, 28, 42, 84.
Subgroups with element 1 and 84 are trivial groups.
The size of a largest possible proper subgroup of G is 42.

Use HELLOSONU01 code to get max discount On subscription & 350


Use HELLOSONU01SRPs code toFree
Book get max discount On
subscription & 350 SRPs Book Free
LIVE NOW : Revise 80+ Formulae of Discrete Mathematics in 60 minutes only.
77

For complete graph the no . of


spanning tree possible = nn-2

Use HELLOSONU01 code to get max discount On subscription & 350


Use HELLOSONU01SRPs code toFree
Book get max discount On
subscription & 350 SRPs Book Free
LIVE NOW : Revise 80+ Formulae of Discrete Mathematics in 60 minutes only.
78

The no. of complete matchings for Kn.n = n!

Use HELLOSONU01 code to get max discount On subscription & 350


Use HELLOSONU01SRPs code toFree
Book get max discount On
subscription & 350 SRPs Book Free
LIVE NOW : Revise 80+ Formulae of Discrete Mathematics in 60 minutes only.
79

The no. of perfect matchings for a complete graph


(2n)/(2nn!)

Use HELLOSONU01 code to get max discount On subscription & 350


Use HELLOSONU01SRPs code toFree
Book get max discount On
subscription & 350 SRPs Book Free
LIVE NOW : Revise 80+ Formulae of Discrete Mathematics in 60 minutes only.
80

To guarantee that a graph with n vertices is connected,


minimum no. of edges required = {(n-1)*(n-2)/2 } + 1

Use HELLOSONU01 code to get max discount On subscription & 350


Use HELLOSONU01SRPs code toFree
Book get max discount On
subscription & 350 SRPs Book Free
LIVE NOW : Revise 80+ Formulae of Discrete Mathematics in 60 minutes only.
81
Minimum no. of edges to have connected graph with n vertices = n-1

Use HELLOSONU01 code to get max discount On subscription & 350


Use HELLOSONU01SRPs code toFree
Book get max discount On
subscription & 350 SRPs Book Free
LIVE NOW : Revise 80+ Formulae of Discrete Mathematics in 60 minutes only.
82

No. of edges in a complete graph = n(n-1)/2

Use HELLOSONU01 code to get max discount On subscription & 350


Use HELLOSONU01SRPs code toFree
Book get max discount On
subscription & 350 SRPs Book Free
LIVE NOW : Revise 80+ Formulae of Discrete Mathematics in 60 minutes only.
83

Maximum no. of connected components in graph with n


vertices = n

Use HELLOSONU01 code to get max discount On subscription & 350


Use HELLOSONU01SRPs code toFree
Book get max discount On
subscription & 350 SRPs Book Free
LIVE NOW : Revise 80+ Formulae of Discrete Mathematics in 60 minutes only.
84

If |A| = m and |B| = n, then


No. of functions from A to B = nm

Use HELLOSONU01 code to get max discount On subscription & 350


SRPs Book Free
ALGORITHMS
COMPLETE COURSE ON DISCRETE MATHEMATICS
STARTING TOMORROW AT 6:15 PM

#include <stdio.h>
int main()
{
printf("Hello World"); 1
}

TIME COMPLEXITY–

ANNOUNCEMENTS
4 BIG Announcements :
Use HELLOSONU01 code to get max discount On
1. New Batch For GATE 2023 Starting from 3rd Nov
2. Iconic Subscription (GATE) Price hiking to 7.5% from 1st Nov
subscription & 350 SRPs Book Free
3. Plus subscription 12 + 4 months Offer last date – 31st Oct
4. Plus subscription 4 + 1 months Offer last date – 31st Oct
Use COMPLETE
code HELLOSONU01COURSE to getON DISCRETE
maximum MATHEMATICS
discount on Unacademy Subscription.
STARTING
Also get 350 SRPs TOMORROW
book (Best revision ATIT)6:15
book for GATE CS & 3500PM
+ Practice questions.

for(i=0; i < N; i++) { statement; } 2


TIME COMPLEXITY

ANNOUNCEMENTS
4 BIG Announcements :
Use HELLOSONU01 code to get max discount On
1. New Batch For GATE 2023 Starting from 3rd Nov
2. Iconic Subscription (GATE) Price hiking to 7.5% from 1st Nov
subscription & 350 SRPs Book Free
3. Plus subscription 12 + 4 months Offer last date – 31st Oct
4. Plus subscription 4 + 1 months Offer last date – 31st Oct
Use COMPLETE
code HELLOSONU01COURSE to getON DISCRETE
maximum MATHEMATICS
discount on Unacademy Subscription.
STARTING
Also get 350 SRPs TOMORROW
book (Best revision ATIT)6:15
book for GATE CS & 3500PM
+ Practice questions.

#include <stdio.h>
void main()
3
{
int i, n = 8;
for (i = 1; i <= n; i++) {
printf("Hello Word !!!");
}
}

TIME COMPLEXITY – O(1)

ANNOUNCEMENTS
ANNOUNCEMENTS
4 BIG Announcements :
Use HELLOSONU01 code to get max discount On
1. New Batch For GATE 2023 Starting from 3rd rd Nov
2. Iconic Subscription (GATE) Price hiking to 7.5% from 1stst Nov
subscription & 350 SRPs Book Free
3. Plus subscription 12 + 4 months Offer last date – 31stst Oct
4. Plus subscription 4 + 1 months Offer last date – 31stst Oct
Use COMPLETE
code HELLOSONU01COURSE to getON DISCRETE
maximum MATHEMATICS
discount on Unacademy Subscription.
STARTING
Also get 350 SRPs TOMORROW
book (Best revision ATIT)6:15
book for GATE CS & 3500PM
+ Practice questions.

for(i=0; i < N; i++) 4


{
for(j=0; j < N;j++)
O(N2)
{
statement;
}
}

ANNOUNCEMENTS
ANNOUNCEMENTS
4 BIG Announcements :
Use HELLOSONU01 code to get max discount On
1. New Batch For GATE 2023 Starting from 3rd rd Nov
2. Iconic Subscription (GATE) Price hiking to 7.5% from 1stst Nov
subscription & 350 SRPs Book Free
3. Plus subscription 12 + 4 months Offer last date – 31stst Oct
4. Plus subscription 4 + 1 months Offer last date – 31stst Oct
Use COMPLETE
code HELLOSONU01COURSE to getON DISCRETE
maximum MATHEMATICS
discount on Unacademy Subscription.
STARTING
Also get 350 SRPs TOMORROW
book (Best revision ATIT)6:15
book for GATE CS & 3500PM
+ Practice questions.

Cubic, order of growth N^3 5


int x = 0;
for (int i = 0; i < N; i++)
for (int j = 0; j < N; j++)
for (int k = 0; k < N; k++)
x=x+2

ANNOUNCEMENTS
ANNOUNCEMENTS
4 BIG Announcements :
Use HELLOSONU01 code to get max discount On
1. New Batch For GATE 2023 Starting from 3rd rd Nov
2. Iconic Subscription (GATE) Price hiking to 7.5% from 1stst Nov
subscription & 350 SRPs Book Free
3. Plus subscription 12 + 4 months Offer last date – 31stst Oct
4. Plus subscription 4 + 1 months Offer last date – 31stst Oct
Use COMPLETE
code HELLOSONU01COURSE to getON DISCRETE
maximum MATHEMATICS
discount on Unacademy Subscription.
STARTING
Also get 350 SRPs TOMORROW
book (Best revision ATIT)6:15
book for GATE CS & 3500PM
+ Practice questions.

while(low <= high) { 6


mid = (low + high) / 2;
if (target < list[mid])
high = mid - 1;
else if (target > list[mid])
low = mid + 1;
else break;
}

O(Log n) break a set of numbers into halves, to search a particular.

ANNOUNCEMENTS
ANNOUNCEMENTS
4 BIG Announcements :
Use HELLOSONU01 code to get max discount On
1. New Batch For GATE 2023 Starting from 3rd rd Nov
2. Iconic Subscription (GATE) Price hiking to 7.5% from 1stst Nov
subscription & 350 SRPs Book Free
3. Plus subscription 12 + 4 months Offer last date – 31stst Oct
4. Plus subscription 4 + 1 months Offer last date – 31stst Oct
Use COMPLETE
code HELLOSONU01COURSE to getON DISCRETE
maximum MATHEMATICS
discount on Unacademy Subscription.
STARTING
Also get 350 SRPs TOMORROW
book (Best revision ATIT)6:15
book for GATE CS & 3500PM
+ Practice questions.

void quicksort(int list[], int left, int right)


{ int pivot = partition(list, left, right);
quicksort(list, left, pivot - 1);
quicksort(list, pivot + 1, right); }
7
O(n * log n) = In Quick Sort, we divide
the list into halves every time, but we
repeat the iteration N times(where N is
the size of list).

ANNOUNCEMENTS
ANNOUNCEMENTS
4 BIG Announcements :
Use HELLOSONU01 code to get max discount On
1. New Batch For GATE 2023 Starting from 3rd rd Nov
2. Iconic Subscription (GATE) Price hiking to 7.5% from 1stst Nov
subscription & 350 SRPs Book Free
3. Plus subscription 12 + 4 months Offer last date – 31stst Oct
4. Plus subscription 4 + 1 months Offer last date – 31stst Oct
Use COMPLETE
code HELLOSONU01COURSE to getON DISCRETE
maximum MATHEMATICS
discount on Unacademy Subscription.
STARTING
Also get 350 SRPs TOMORROW
book (Best revision ATIT)6:15
book for GATE CS & 3500PM
+ Practice questions.

int count=0,N; --------(1) 8


for(i=0;i<N*2;i++){ ----->0(n)
for(j=0;j<i/3;i++){ 0(n/3)
for(k=0;k<j*j;k++){ 0((n*n)/3)
count++;
}
}
}

Here we are using the for loop so that 0(n*(n/3)*(n*n)/3) so that 0(n^4)

ANNOUNCEMENTS
ANNOUNCEMENTS
4 BIG Announcements :
Use HELLOSONU01 code to get max discount On
1. New Batch For GATE 2023 Starting from 3rd rd Nov
2. Iconic Subscription (GATE) Price hiking to 7.5% from 1stst Nov
subscription & 350 SRPs Book Free
3. Plus subscription 12 + 4 months Offer last date – 31stst Oct
4. Plus subscription 4 + 1 months Offer last date – 31stst Oct
Use COMPLETE
code HELLOSONU01COURSE to getON DISCRETE
maximum MATHEMATICS
discount on Unacademy Subscription.
STARTING
Also get 350 SRPs TOMORROW
book (Best revision ATIT)6:15
book for GATE CS & 3500PM
+ Practice questions.

for i <--- 1 to n 9
for j <---- 1 to n/2
X=X+1
(i and j both are incrementing by 1)
Outer runs for n times and inner for
n+1
Inner runs for n/2 + 1 times
So will it be n(n/2) => O(n^2) times...

ANNOUNCEMENTS
ANNOUNCEMENTS
4 BIG Announcements :
Use HELLOSONU01 code to get max discount On
1. New Batch For GATE 2023 Starting from 3rd rd Nov
2. Iconic Subscription (GATE) Price hiking to 7.5% from 1stst Nov
subscription & 350 SRPs Book Free
3. Plus subscription 12 + 4 months Offer last date – 31stst Oct
4. Plus subscription 4 + 1 months Offer last date – 31stst Oct
Use COMPLETE
code HELLOSONU01COURSE to getON DISCRETE
maximum MATHEMATICS
discount on Unacademy Subscription.
STARTING
Also get 350 SRPs TOMORROW
book (Best revision ATIT)6:15
book for GATE CS & 3500PM
+ Practice questions.

for (int i = 1; i <=m; i += c) {


10
// some O(1) expressions }
for (int i = 1; i <=n; i += c) {
// some O(1) expressions }
O(m+n)

ANNOUNCEMENTS
ANNOUNCEMENTS
4 BIG Announcements :
Use HELLOSONU01 code to get max discount On
1. New Batch For GATE 2023 Starting from 3rd rd Nov
2. Iconic Subscription (GATE) Price hiking to 7.5% from 1stst Nov
subscription & 350 SRPs Book Free
3. Plus subscription 12 + 4 months Offer last date – 31stst Oct
4. Plus subscription 4 + 1 months Offer last date – 31stst Oct
Use COMPLETE
code HELLOSONU01COURSE to getON DISCRETE
maximum MATHEMATICS
discount on Unacademy Subscription.
STARTING
Also get 350 SRPs TOMORROW
book (Best revision ATIT)6:15
book for GATE CS & 3500PM
+ Practice questions.

O(Logn) Time Complexity of a loop is


considered as O(Logn) if the loop variables
is divided / multiplied by a constant
amount.
for (int i = 1; i <=n; i *= c) {
// some O(1) expressions }
11
for (int i = n; i > 0; i /= c) {
// some O(1) expressions }

ANNOUNCEMENTS
ANNOUNCEMENTS
4 BIG Announcements :
Use HELLOSONU01 code to get max discount On
1. New Batch For GATE 2023 Starting from 3rd rd Nov
2. Iconic Subscription (GATE) Price hiking to 7.5% from 1stst Nov
subscription & 350 SRPs Book Free
3. Plus subscription 12 + 4 months Offer last date – 31stst Oct
4. Plus subscription 4 + 1 months Offer last date – 31stst Oct
Use code HELLOSONU01 to get maximum discount on Unacademy Subscription.
Also get 350 SRPs book (Best revision book for GATE CS IT) & 3500 + Practice questions.

12
O(LogLogn) Time Complexity of a loop is considered as O(LogLogn) if
the loop variables is reduced / increased exponentially by a constant
amount.
// Here c is a constant greater than 1
for (int i = 2; i <=n; i = pow(i, c)) { // some O(1) expressions }
//Here fun is sqrt or cuberoot or any other constant root
for (int i = n; i > 1; i = fun(i)) { // some O(1) expressions }

ANNOUNCEMENTS
4 BIG Announcements :
1. New Batch For GATE 2023 Starting from 3rd Nov
2. Iconic Subscription (GATE) Price hiking to 7.5% from 1st Nov
3. Plus subscription 12 + 4 months Offer last date – 31st Oct
4. Plus subscription 4 + 1 months Offer last date – 31st Oct
Use COMPLETE
code HELLOSONU01COURSE to getON DISCRETE
maximum MATHEMATICS
discount on Unacademy Subscription.
STARTING
Also get 350 SRPs TOMORROW
book (Best revision ATIT)6:15
book for GATE CS & 3500PM
+ Practice questions.

13

ANNOUNCEMENTS
ANNOUNCEMENTS
4 BIG Announcements :
Use HELLOSONU01 code to get max discount On
1. New Batch For GATE 2023 Starting from 3rd rd Nov
2. Iconic Subscription (GATE) Price hiking to 7.5% from 1stst Nov
subscription & 350 SRPs Book Free
3. Plus subscription 12 + 4 months Offer last date – 31stst Oct
4. Plus subscription 4 + 1 months Offer last date – 31stst Oct
13
Use COMPLETE
code HELLOSONU01COURSE to getON DISCRETE
maximum MATHEMATICS
discount on Unacademy Subscription.
STARTING
Also get 350 SRPs TOMORROW
book (Best revision ATIT)6:15
book for GATE CS & 3500PM
+ Practice questions.

15
16
17

19
20
DATA STRUCTURES
Use COMPLETE
code HELLOSONU01COURSE to getON DISCRETE
maximum MATHEMATICS
discount on Unacademy Subscription.
STARTING
Also get 350 SRPs TOMORROW
book (Best revision ATIT)6:15
book for GATE CS & 3500PM
+ Practice questions.

22 - 26
COMPLEXITIES RELATED TO LINKED LIST

i. Reverse the singly linked list - O(n)


ii. Reverse the doubly linked list - O(n)
iii. Reverse a doubly circular linked list - O(n)
iv. Reverse the circular linked list - O(n)
v. Reverse an array - O(n)

ANNOUNCEMENTS
ANNOUNCEMENTS
4 BIG Announcements :
Use HELLOSONU01 code to get max discount On
1. New Batch For GATE 2023 Starting from 3rd rd Nov
2. Iconic Subscription (GATE) Price hiking to 7.5% from 1stst Nov
subscription & 350 SRPs Book Free
3. Plus subscription 12 + 4 months Offer last date – 31stst Oct
4. Plus subscription 4 + 1 months Offer last date – 31stst Oct
Use COMPLETE
code HELLOSONU01COURSE to getON DISCRETE
maximum MATHEMATICS
discount on Unacademy Subscription. 27 - 40
STARTING
Also get 350 SRPs TOMORROW
book (Best revision ATIT)6:15
book for GATE CS & 3500PM
+ Practice questions.
COMPLEXITY
Time complexity for the following operations on Singly
Linked Lists of n nodes: TRICKS
Add a new node to the beginning of list: O(1) Time complexity for the following operations on
Add a new node to the end: O(n) Doubly Linked Lists of n nodes:
Add a new node after k'th node: O(n)
Search a node with a given data: O(n) Add a new node to the beginning of list: O(1)
Add a new node after a node with a given data: O(n) Add a new node to the end: O(n)
Add a new node before a node with a given data: O(n) Add a new node after k'th node: O(n)
Traverse all nodes: O(n) Search a node with a given data: O(n)
Delete a node from the beginning: O(1) Add a new node after a node with a given data: O(n)
Delete a node from the end: O(n) Add a new node before a node with a given data: O(n)
Delete a node with a given data: O(n) Traverse all nodes: O(n)
Delete the k'th node: O(n) Delete a node from the beginning: O(1)
Modify the data of all nodes in a linked list: O(n) Delete a node from the end: O(n)
Delete a node with a given data: O(n)
ANNOUNCEMENTS
ANNOUNCEMENTS Delete the k'th node: O(n)
4 BIG Announcements :
Modify the data of all nodes in a linked list: O(n)
1. Use
NewHELLOSONU01 code
Batch For GATE 2023 to get
Starting 3rd
max
from discount On
rd Nov
2. Iconic Subscription (GATE)
subscription PriceSRPs
& 350 hikingBook from 1stst Nov
to 7.5%Free
3. Plus subscription 12 + 4 months Offer last date – 31stst Oct
4. Plus subscription 4 + 1 months Offer last date – 31stst Oct
UseCOMPLETE
code HELLOSONU01COURSE to getON DISCRETE
maximum discount on
Unacademy Subscription. 40-COMPLEXITY
41 52 COMPLEXITY
MATHEMATICS STARTING
Also get 350 SRPs book (Best TOMORROW
revision book
AT
for GATE CS IT) & 3500
6:15questions.
+ Practice PM TRICKS
TRICKS
Time complexity for the following operations on Circular Singly Linked Time complexity for the following operations on
Lists of n nodes: Circular Doubly Linked Lists of n nodes:
Add a new node to the beginning of list: O(n)
Add a new node to the end: O(n) Add a new node to the beginning of list: O(1)
Add a new node after k'th node: O(n) Add a new node to the end: O(1)
Search a node with a given data: O(n) Add a new node after k'th node: O(n)
Add a new node after a node with a given data: O(n) Search a node with a given data: O(n)
Add a new node before a node with a given data: O(n) Add a new node after a node with a given data:
Traverse all nodes: O(n)
O(n)
Delete a node from the beginning: O(n)
Delete a node from the end: O(n) Add a new node before a node with a given
Delete a node with a given data: O(n) data: O(n)
Delete the k'th node: O(n) Traverse all nodes: O(n)
Modify the data of all nodes in a linked list: O(n) Delete a node from the beginning: O(1)
Delete a node from the end: O(1)
ANNOUNCEMENTS
ANNOUNCEMENTS
4 BIG Announcements : Delete a node with a given data: O(n)
1. Use
NewHELLOSONU01 code
Batch For GATE 2023 to get
Starting from 3rd
max discount On
rd Nov Delete the k'th node: O(n)
2. Iconic Subscription (GATE)
subscription PriceSRPs
& 350 hikingBook from 1stst Nov
to 7.5%Free Modify the data of all nodes in a linked list: O(n)
3. Plus subscription 12 + 4 months Offer last date – 31stst Oct
4. Plus subscription 4 + 1 months Offer last date – 31stst Oct
UseCOMPLETE
code HELLOSONU01COURSE to getON DISCRETE
maximum discount on
MATHEMATICS Unacademy Subscription.
STARTING TOMORROW AT 53 - 73 COMPLEXITY
Also get 350 SRPs book (Best revision book for GATE CS IT) & 3500
6:15questions.
+ Practice PM TRICKS
PARAMETERS LINKED LIST ARRAY DYNAMIC ARRAY
Indexing O(n) O(1) O(1)
Insertion/Deletion at O(1) O(n), if array is not full O(n)
Beginning
Insertion at ending O(n) O(1), if array is not full O(1), if array is not full
O(n), if array is full
Deletion at ending O(n) O(1) O(n)
Insertion in middle O(n) O(n), if array is not full O(n)
Deletion in middle O(n) O(n), if array is not full O(n)
Wasted space O(n) 0 O(n)
(for pointers)
ANNOUNCEMENTS
4 BIG Announcements :
1. Use
NewHELLOSONU01 code
Batch For GATE 2023 to get
Starting 3rd
max
from discount On
rd Nov
2. Iconic Subscription (GATE)
subscription PriceSRPs
& 350 hikingBook from 1stst Nov
to 7.5%Free
3. Plus subscription 12 + 4 months Offer last date – 31stst Oct
4. Plus subscription 4 + 1 months Offer last date – 31stst Oct
Sort Average Best Worst
Bubble sort O(n^2) O(n^2) O(n^2)
Modified Bubble
O(n^2) O(n) O(n^2)
sort
Selection Sort O(n^2) O(n^2) O(n^2)
Insertion Sort O(n^2) O(n) O(n^2)
Heap Sort O(n*log(n)) O(n*log(n)) O(n*log(n))
Merge Sort O(n*log(n)) O(n*log(n)) O(n*log(n))
Quicksort O(n*log(n)) O(n*log(n)) O(n^2)
Bucket Sort O(n+k) O(n+k) O(n^2)
Radix Sort O(nk) O(nk) O(n+k)
Tim Sort O(n) O(nlogn) O(nlogn)
Shell Sort O(n) O((nlogn)^2) O((nlogn)^2)
Counting Sort O(n+k) O(n+k) O(n+k)
Randomized O(nlogn) O(nlogn) O(nlogn)
Quick Sort 74 - 103
4
4 BIG
BIG Announcements
Announcements ::
ANNOUNCEMENTS
ANNOUNCEMENTS COMPLEXITY
1. New Batch rd
1. Use Batch For
For GATE
NewHELLOSONU01 GATE 2023 Starting
code
2023 from
to get
Starting from 3
max rd Nov
3rd discountst On
Nov
2. Iconic Subscription
subscription (GATE)
& PriceSRPs
350 hikingBook from 1stst Nov
to 7.5%Free TRICKS
3. Plus
3. Plus subscription 12 ++ 4
subscription 12 4 months
months Offer
Offer last date –– 31
last date 31ststst Oct
Oct
date –– 31
4. st
4. Plus subscription 4
Plus subscription 4 ++ 1
1 months
months Offer
Offer last
last date 31stst Oct
Oct
Use code HELLOSONU01 to get maximum discount on Unacademy
Subscription. 104 - 108
Also get 350 SRPs book (Best revision book for GATE CS IT) & 3500 + Practice
questions. COMPLEXITY
TRICKS

O(V+E) = Strongly connected components ,


Topological ordering, BFS,DFS, Articulation
points

ANNOUNCEMENTS
4 BIG Announcements :
1. New Batch For GATE 2023 Starting from 3rd Nov
2. Iconic Subscription (GATE) Price hiking to 7.5% from 1st Nov
3. Plus subscription 12 + 4 months Offer last date – 31st Oct
4. Plus subscription 4 + 1 months Offer last date – 31st Oct
Use code HELLOSONU01 to get maximum discount on Unacademy Subscription.
Also get 350 SRPs book (Best revision book for GATE CS IT) & 3500 + Practice questions.

109 – 118 COMPLEXITY TRICKS

ANNOUNCEMENTS
4 BIG Announcements :
1. New Batch For GATE 2023 Starting from 3rd Nov
2. Iconic Subscription (GATE) Price hiking to 7.5% from 1st Nov
3. Plus subscription 12 + 4 months Offer last date – 31st Oct
4. Plus subscription 4 + 1 months Offer last date – 31st Oct
Use COMPLETE
code HELLOSONU01COURSE to getON DISCRETE
maximum MATHEMATICS
discount on Unacademy Subscription.
STARTING
Also get 350 SRPs TOMORROW
book (Best revision ATIT)6:15
book for GATE CS & 3500PM
+ Practice questions.

119 - 123
COMPLEXITY TRICKS

ANNOUNCEMENTS
ANNOUNCEMENTS
4 BIG Announcements :
1. Use
NewHELLOSONU01 code
Batch For GATE 2023 to get
Starting 3rd
max
from discount On
rd Nov
2. Iconic Subscription (GATE)
subscription PriceSRPs
& 350 hikingBook from 1stst Nov
to 7.5%Free
3. Plus subscription 12 + 4 months Offer last date – 31stst Oct
4. Plus subscription 4 + 1 months Offer last date – 31stst Oct
Use COMPLETE
code HELLOSONU01COURSE to getON DISCRETE
maximum MATHEMATICS
discount on Unacademy Subscription.
STARTING
Also get 350 SRPs TOMORROW
book (Best revision ATIT)6:15
book for GATE CS & 3500PM
+ Practice questions.

124 - 129
COMPLEXITY
TRICKS

ANNOUNCEMENTS
ANNOUNCEMENTS
4 BIG Announcements :
1. Use
NewHELLOSONU01 code
Batch For GATE 2023 to get
Starting 3rd
max
from discount On
rd Nov
2. Iconic Subscription (GATE)
subscription PriceSRPs
& 350 hikingBook from 1stst Nov
to 7.5%Free
3. Plus subscription 12 + 4 months Offer last date – 31stst Oct
4. Plus subscription 4 + 1 months Offer last date – 31stst Oct
Use COMPLETE
code HELLOSONU01COURSE to getON DISCRETE
maximum MATHEMATICS
discount on Unacademy Subscription.
STARTING
Also get 350 SRPs TOMORROW
book (Best revision ATIT)6:15
book for GATE CS & 3500PM
+ Practice questions.
130 - 149
COMPLEXITY
DATA ACCESS SEARCH INSERTION DELETE
STRUCTURE
TRICKS

STACK O(n) O(n) O(1) O(1)


QUEUE O(n) O(n) O(1) O(1)
BST O(n) O(n) O(n) O(n)
B-TREE O(log(n)) O(log(n)) O(log(n)) O(log(n))

AVL TREE O(log(n)) O(log(n)) O(log(n)) O(log(n))


ANNOUNCEMENTS
ANNOUNCEMENTS
4 BIG Announcements :
1. Use
NewHELLOSONU01 code
Batch For GATE 2023 to get
Starting 3rd
max
from discount On
rd Nov
2. Iconic Subscription (GATE)
subscription PriceSRPs
& 350 hikingBook from 1stst Nov
to 7.5%Free
3. Plus subscription 12 + 4 months Offer last date – 31stst Oct
4. Plus subscription 4 + 1 months Offer last date – 31stst Oct
Use COMPLETE
code HELLOSONU01COURSE to getON DISCRETE
maximum MATHEMATICS
discount on Unacademy Subscription.
STARTING
Also get 350 SRPs TOMORROW
book (Best revision ATIT)6:15
book for GATE CS & 3500PM
+ Practice questions.
150 - 153
QUEUE BASIC OPERATIONS :
COMPLEXITY
1. Enqueue() − Insert Element at TRICKS
REAR / TAIL.
2. Dequeue() − Delete Element at
FRONT / HEAD.
O(1)

QUEUE FUNCTIONS :
1. isfull() − Checks if the queue is
full.
2. isempty() − Checks if the
queue is empty.

ANNOUNCEMENTS
ANNOUNCEMENTS
4 BIG Announcements :
1. Use
NewHELLOSONU01 code
Batch For GATE 2023 to get
Starting 3rd
max
from discount On
rd Nov
2. Iconic Subscription (GATE)
subscription PriceSRPs
& 350 hikingBook from 1stst Nov
to 7.5%Free
3. Plus subscription 12 + 4 months Offer last date – 31stst Oct
4. Plus subscription 4 + 1 months Offer last date – 31stst Oct
OPERATING
SYSTEMS
FORMULA 1
Total no. of process created ={ (2n) -1)+1 }

ANNOUNCEMENTS
ANNOUNCEMENTS
4 BIG Announcements :
Use HELLOSONU01 code to get max discount
1. NEW Batches
New Batch For 2023
For GATE GATEStarting
Startingfromfrom
3rd 20th Oct on Unacademy plus.
rd Nov
2. Iconic Subscription (GATE) Price hiking to 7.5% from 1stst Nov
On subscription & 350 SRPs Book Free
3. Plus subscription 12 + 4 months Offer last date – 31stst Oct
4. Plus subscription 4 + 1 months Offer last date – 31stst Oct
FORMULA 2
size of memory = 2n x Size of one location.

Use
NEWHELLOSONU01 code
Batches For GATE Starting fromto
20thget max
Oct on discount
Unacademy plus.

On subscription & 350 SRPs Book Free


Waiting Time = TAT –BT FORMULA 3
(Time in ready queue)

Use
NEWHELLOSONU01 code
Batches For GATE Starting fromto
20thget max
Oct on discount
Unacademy plus.

On subscription & 350 SRPs Book Free


FORMULA 4
Turn Around Time = CT- AT
(Time to execute)

Use
NEWHELLOSONU01 code
Batches For GATE Starting fromto
20thget max
Oct on discount
Unacademy plus.

On subscription & 350 SRPs Book Free


FORMULA 5
Highest Response Ratio Next (HRRN)
Response Ratio =
(Waiting Time + Burst time) / Burst time

Use
NEWHELLOSONU01 code
Batches For GATE Starting fromto
20thget max
Oct on discount
Unacademy plus.

On subscription & 350 SRPs Book Free


2. Based on Exponential Averaging-

•Given n processes P1, P2, … , Pn and burst time of each process Pi as ti.
•Then, predicted burst time for process Pn+1 is given as-

FORMULA 7 Τn+1 = αtn + (1 - α)Τn


where α = is smoothing factor and 0 <= α <= 1 ,
tn = actual burst time of nth process,
Τn = predicted burst time of nth process.

Use
NEWHELLOSONU01 code
Batches For GATE Starting fromto
20thget max
Oct on discount
Unacademy plus.

On subscription & 350 SRPs Book Free


SEMAPHORES Wait(S) Signal(S)
{ {
While (S<=0); S=S + 1;
N- PROCESS SOLUTION
S=S-1; }
SIMPLE INTEGER VALUE }

FORMULA 11-12

NEW Batches For GATE Starting from 20th Oct on Unacademy plus.
FORMULA 13
n bits of address →
2 ^ n memory locations

Use
NEWHELLOSONU01 code
Batches For GATE Starting fromto
20thget max
Oct on discount
Unacademy plus.

On subscription & 350 SRPs Book Free


For Process-
FORMULA 14 - 16

Virtual Address Space = Size of process


Number of pages the process is divided = Process size / Page size
If process size = 2X bytes, then number of bits in virtual address
space = X bits

Use
NEWHELLOSONU01 code
Batches For GATE Starting fromto
20thget max
Oct on discount
Unacademy plus.

On subscription & 350 SRPs Book Free


For Main Memory - FORMULA 17 - 22
Physical Address Space = Size of main memory
Size of main memory = Total number of frames x Page size
Frame size = Page size
If number of frames in main memory = 2X, then number of bits in frame number = X
bits
If Page size = 2X Bytes, then number of bits in page offset = X bits
If size of main memory = 2X Bytes, then number of bits in physical address = X bits

Use
NEWHELLOSONU01 code
Batches For GATE Starting fromto
20thget max
Oct on discount
Unacademy plus.

On subscription & 350 SRPs Book Free


FORMULA 23
EMAT (with page faults) =
Page fault rate x {EAT without page fault + Page fault
service time} +
(1- Page fault rate) x {EMAT without page fault}

Use
NEWHELLOSONU01 code
Batches For GATE Starting fromto
20thget max
Oct on discount
Unacademy plus.

On subscription & 350 SRPs Book Free


FORMULA 24
In a segmentation scheme, the generated logical address consists of two parts-
1.Segment Number
2.Segment Offset

We know-
•Segment Offset must always lie in the range [0, limit-1].
•If segment offset becomes greater than or equal to the limit of segment, then
trap addressing error is produced.

Use
NEWHELLOSONU01 code
Batches For GATE Starting fromto
20thget max
Oct on discount
Unacademy plus.

On subscription & 350 SRPs Book Free


FORMULA 25
EAT = Hit Ratio (Access Time of TLB + Access Time of main
memory)
+ Miss Ratio of TLB (Access Time of TLB + (L+1) x Access time of
main memory)

Use
NEWHELLOSONU01 code
Batches For GATE Starting fromto
20thget max
Oct on discount
Unacademy plus.

On subscription & 350 SRPs Book Free


FORMULA 26
For page table, to fit well in one page, we
must have-
Page table size <= Page size

NEW Batches For GATE Starting from 20th Oct on Unacademy plus.
FORMULA 27
Page table size
= Number of entries in the page table x Page table entry size

Use
NEWHELLOSONU01 code
Batches For GATE Starting fromto
20thget max
Oct on discount
Unacademy plus.

On subscription & 350 SRPs Book Free


FORMULA 28
Optimal page size
= (2 x Process size x Page table entry size) 1/2

Use
NEWHELLOSONU01 code
Batches For GATE Starting fromto
20thget max
Oct on discount
Unacademy plus.

On subscription & 350 SRPs Book Free


FORMULA 29
EAT = Hit Ratio of TLB x {Access time of TLB + Access time
of main memory} +
Miss ratio of TLB x {Access time of TLB + 2 x Access time of
main memory}

Use
NEWHELLOSONU01 code
Batches For GATE Starting fromto
20thget max
Oct on discount
Unacademy plus.

On subscription & 350 SRPs Book Free


The largest value of Processes that will
always avoid deadlock is _______
FORMULA 30
R ≥ P(N − 1) + 1

Use
NEWHELLOSONU01 code
Batches For GATE Starting fromto
20thget max
Oct on discount
Unacademy plus.

On subscription & 350 SRPs Book Free


FORMULA 31
Inode Total Size:

•Number of disk block address possible to store in 1 disk block


•= (Disk Block Size / Disk Block Address).

Use
NEWHELLOSONU01 code
Batches For GATE Starting fromto
20thget max
Oct on discount
Unacademy plus.

On subscription & 350 SRPs Book Free


FORMULA 32
Number of times string printed is equal to number of process created. Total
Number of Processes = 2n

Use
NEWHELLOSONU01 code
Batches For GATE Starting fromto
20thget max
Oct on discount
Unacademy plus.

On subscription & 350 SRPs Book Free


FORMULA 32 - 35
Wake up: Block  ready
Block: running  block
Timer run out: running  ready
Dispatcher : Ready  Running

Use
NEWHELLOSONU01 code
Batches For GATE Starting fromto
20thget max
Oct on discount
Unacademy plus.

On subscription & 350 SRPs Book Free


FORMULA 37

Use
NEWHELLOSONU01 code
Batches For GATE Starting fromto
20thget max
Oct on discount
Unacademy plus.

On subscription & 350 SRPs Book Free


COA
Use HELLOSONU01 code to get max discount
On subscription & 350 SRPs Book Free
FORMULA 1

Overflow flag = Cin XOR Cout

Use HELLOSONU01 code to get max discount


On subscription & 350 SRPs Book Free
Seek Time : Time to TRICKS
Seek = 1/3 (3 chakkar
kate sick ho gaye)

locate Track

FORMULA 2

Use HELLOSONU01 code to get max discount


On subscription & 350 SRPs Book Free
Calculating Non-Pipelined Execution Time-
FORMULA 3
In non-pipelined architecture,
•The instructions execute one after the other.
•The execution of a new instruction begins only after the previous instruction has executed
completely.
•So, number of clock cycles taken by each instruction = k clock cycles

Thus,
Non-pipelined execution time
= Total number of instructions x Time taken to execute one instruction
= n x k clock cycles

Use HELLOSONU01 code to get max discount


On subscription & 350 SRPs Book Free
Calculating Pipelined Execution Time-
FORMULA 4
In pipelined architecture,
•Multiple instructions execute parallely.
•Number of clock cycles taken by the first instruction = k clock cycles
•After first instruction has completely executed, one instruction comes out per clock cycle.
•So, number of clock cycles taken by each remaining instruction = 1 clock cycle

Thus,
Pipelined execution time
= Time taken to execute first instruction + Time taken to execute remaining instructions
= 1 x k clock cycles + (n-1) x 1 clock cycle
= (k + n – 1) clock cycles

Use HELLOSONU01 code to get max discount


On subscription & 350 SRPs Book Free
FORMULA 5
Speed Up-

It gives an idea of “how much faster” the pipelined execution is as compared to


non-pipelined execution.

Speed Up = NP execution time/ Pipeline Execution time

Use HELLOSONU01 code to get max discount


On subscription & 350 SRPs Book Free
Calculating Speed Up-

Speed up
FORMULA 6
= Non-pipelined execution time / Pipelined execution time
= n x k clock cycles / (k + n – 1) clock cycles
= n x k / (k + n – 1)
= n x k / n + (k – 1)
= k / { 1 + (k – 1)/n }

•For very large number of instructions, n→∞. Thus, speed up = k.


•Practically, total number of instructions never tend to infinity.
•Therefore, speed up is always less than number of stages in pipeline.

Use HELLOSONU01 code to get max discount


On subscription & 350 SRPs Book Free
Efficiency- FORMULA 7

Efficiency = Speedup/ Number of stages in Pipeline

Use HELLOSONU01 code to get max discount


On subscription & 350 SRPs Book Free
Types of pipeline
1) Uniform delay pipeline = all the stages will take same time to complete an operation.
In uniform delay pipeline, Cycle Time (Tp) = Stage Delay
If buffers are included between the stages then,
Cycle Time (Tp) = Stage Delay + Buffer Delay
FORMULA 8 - 9
2) Non-Uniform delay pipeline = different stages take different time to complete an operation.
In this type of pipeline, Cycle Time (Tp) = Maximum(Stage Delay)
For example, if there are 4 stages with delays, 1 ns, 2 ns, 3 ns, and 4 ns, then
Tp = Maximum(1 ns, 2 ns, 3 ns, 4 ns) = 4 ns
If buffers are included between the stages,
Tp = Maximum(Stage delay + Buffer delay)

Use HELLOSONU01 code to get max discount


On subscription & 350 SRPs Book Free
Data Hazards Let there be two instructions I and J, such that J
Data hazards occur when instructions that exhibit data follow I. Then,
dependence, modify data in different stages of a pipeline.
Hazard cause delays in the pipeline. RAW hazard occurs when instruction J tries to read
data before instruction I writes it.
1) RAW (Read after Write) [Flow/True data dependency] Eg:
I: R2 <- R1 + R3
2) WAR (Write after Read) [Anti-Data dependency] J: R4 <- R2 + R3
3) WAW (Write after Write) [Output data dependency]
WAR hazard occurs when instruction J tries to write
data before instruction I reads it.
FORMULA 10, 11 , 12 Eg:
I: R2 <- R1 + R3
J: R3 <- R4 + R5

WAW hazard occurs when instruction J tries to write


output before instruction I writes it.
Eg:
I: R2 <- R1 + R3
J: R2 <- R4 + R5
WAR and WAW hazards occur during the out-of-
order execution of the instructions.
Speed Up (S) = Performancepipeline / Performancenon-pipeline

 S = Average Execution Timenon-pipeline / Average Execution Timepipeline

=> S = CPInon-pipeline * Cycle Timenon-pipeline / CPIpipeline * Cycle Timepipeline

Ideal CPI of the pipelined processor is ‘1’. But due to stalls,


FORMULA 13, 14 , 15 it becomes greater than ‘1’.

S = CPInon-pipeline * Cycle Timenon-pipeline / (1 + Number of


stalls per Instruction) * Cycle Timepipeline

As Cycle Timenon-pipeline = Cycle Timepipeline,

Speed Up (S) = CPInon-pipeline / (1 + Number of stalls per


instruction)
Direct Mapping –
FORMULA 20

i = j modulo m
where

i=cache line number

j= main memory block number

m=number of lines in the cache


3. K-way Set Associative Mapping- FORMULA 21

Cache set number


= ( Main Memory Block Address ) Modulo (Number of sets in Cache)

Use HELLOSONU01 code to get max discount


On subscription & 350 SRPs Book Free
Special Cases- FORMULA 22 - 23
•If k = 1, then k-way set associative mapping becomes direct mapping i.e.

1-way Set Associative Mapping ≡ Direct Mapping

•If k = Total number of lines in the cache, then k-way set associative mapping becomes fully associative
mapping.
M/M Organization

1. Sequential M/M Organization = CPU connected to all the levels of


memory
2. Hierarchical M/M Organization

FORMULA 24

Tavg = H1T1 + (1-H1)H2T2 + (1-H1)(1-H2)H3T3 + ….


M/M Organization

1. Sequential M/M Organization = CPU connected to all the levels of


memory
2. Hierarchical M/M Organization = CPU always access data only from level 1
m/m

CPU L1 L2 L3
FORMULA 25

Tavg = H1T1 + (1- H1)H2(T2 + T1)+ ……


HIT RATIO
Hit ratio = hit / (hit + miss) = no. of hits/total accesses

FORMULA 26
FORMULA 27 - 30
Instruction set size – It tells the total number of instructions defined in the processor.
Opcode size – It is the number of bits occupied by the opcode which is calculated by taking log of instruction set size.
Operand size – It is the number of bits occupied by the operand.
Instruction size – It is calculated as sum of bits occupied by opcode and operands.
FORMULA 31 , 32
In Horizontal micro-programmed control unit, the control signals are
represented in the decoded binary format, i.e., 1 bit/CS. Here ‘n’ control
signals require n bit encoding. On the other hand.

In Vertical micro-programmed control unit, the control signals are


represented in the encoded binary format. Here ‘n’ control signals require
log2n bit encoding.
FORMULA 33 , 34
What is throughput ( in terms of instruction execution in a pipelined architecture )

Throughput = the no. of instruction executed per unit time( 1 sec )


= 1 / Tp
Here 800 psec is needed to execute 1 instruction.
so In 1 sec, this much instruction will get executed= 1 / 800 psec
OR
Throughput = no.of instructions executed / total time taken to execute these instructions = n / (K+(n-1))*
Tp
If the no. of instructions to be executed is not given(n not given) then use the 1st formula.
FORMULA
FIND WINDOW SIZE AND TOTAL NUMBER OF
REGISTERS?
40 , 41
TREE DATA
STRUCTURES
FORMULA 1

Any connected graph with n vertices and (n-1) edges is a


tree.
FORMULA 2

Number of binary trees possible with n


unlabeled nodes
= 2 x nCn / (n + 1)
FORMULA 3

Number of binary trees possible with 3


labeled nodes
= { 2 x nCn / (n + 1) } x n!
A
B C
FORMULA 4 - 9
TRICK
FORMULA 9 - 14
TRICK
FORMULA 15
FORMULA 16

If there are n nodes in an AVL Tree, maximum


height can not exceed 1.44log2n.
In other words, Worst case height of an AVL Tree
with n nodes = 1.44log2n.
FORMULA 17

Maximum number of nodes in an AVL


Tree of height H = 2H+1 – 1
FORMULA 18

Minimum number of nodes in a


binary tree of height H = H + 1
FORMULA 19

Minimum height of an AVL Tree


using N nodes = floor(log2N)
FORMULA 20

leaf nodes in a Binary Tree =


Degree-2 nodes + 1
FORMULA 21

Find the minimum number of nodes required to construct an AVL Tree of


height h.

N(H) = N(H-1) + N(H-2) + 1

where N(0) = 1 and N(1) = 2.


FORMULA 22

Maximum number of nodes at any


level ‘L’ in a binary tree = 2L
FORMULA 23

L = (n-1)*I + 1
FORMULA 24
e=v–1
Degree = 2 * e
FORMULA 25

Degree = 2 * e
FORMULA 26

Inorder traversal of a BST always gives elements in


increasing order.
FORMULA 27
PERFECT BINARY TREE

All leaves are at the same depth

Height h

2h+1 – 1 nodes
FORMULA 28
PERFECT BINARY TREE

All leaves are at the same depth

Height h

2h - 1 non leaf nodes


FORMULA 29

PERFECT BINARY TREE

All leaves are at the same depth

Height h

2h leaf nodes
FORMULA 30

A strict binary tree with ‘n’ nodes always have ‘2n-1’


intermediate nodes.
FORMULA 31 - 34

• PREORDER = ROOT, LEFT , RIGHT


• INORDER = LEFT,ROOT,RIGHT
• POSTORDER= LEFT , RIGHT , ROOT
• Breadth First Or LEVEL ORDER = TOP TO
BOTTOM & LEFT TO RIGHT
COMPUTER
NETWORKS
FORMULA 1

1. In mesh topology, every device is connected to


another device via particular channel.
If suppose, N devices , then Ports & Links ?
Total number of ports = N-1.
Total number of dedicated links = NC2 i.e. N(N-1)/2.

Ports = 2
Links = 3

N= 3
Efficiency of Stop & Wait protocol
Efficiency (η) = Useful Time / Total Time

where-
•Useful time = Transmission delay of data
packet = (Transmission delay)packet
•Useless time = Time for which sender is
forced to wait and do nothing = 2 x
Propagation delay

•Total time = Useful time + Useless time

FORMULA 7
20 Questions (DLL)

Parameters Stop and Wait Go back N Selective Repeat


ARQ
Efficiency 1 / (1+2a) N / (1+2a) N / (1+2a)

FORMULA 8,9,10

Unacademy Plus With 1 Year Subscription Offer :


Use HELLOSONU01 code
Get 4 Months Free till to get max
10th Oct discount
On
Use code HELLOSONULIVE
subscription & 350
to getSRPs Book Free
discount
, offer & Single Revision pages
20 Questions (DLL)

Parameters Stop and Wait Go back N Selective Repeat


ARQ
Window Size Sender Window Sender Window Size = N Sender Window Size
Size Receiver Window Size = 1 =N
=1 Receiver Window Size = N
Receiver Window
Size
=1

FORMULA 11,12,13

Unacademy Plus With 1 Year Subscription Offer :


Use HELLOSONU01 code
Get 4 Months Free till to get max
10th Oct discount
UseOn HELLOSONULIVE
codesubscription & 350
to getSRPs
discountBook Free
, offer & Single Revision pages
20 Questions (DLL)

Parameters Stop and Wait Go back N Selective Repeat


ARQ
Minimum number of 2 N+1 2xN
sequence numbers
required

FORMULA 14,15,16

Unacademy Plus With 1 Year Subscription Offer :


Use HELLOSONU01 code
Get 4 Months Free till to get max
10th Oct discount
On
Use code HELLOSONULIVE
subscription & 350
to getSRPs Book Free
discount
, offer & Single Revision pages
Detecting the Collision-
FORMULA 17
In CSMA / CD,
•It is the responsibility of the transmitting station to detect the collision.
•For detecting the collision, CSMA / CD implements the following condition.
•This condition is followed by each station-

Transmission delay >= 2 x Propagation delay

Meaning-

According to this condition,


•Each station must transmit the data packet of size whose transmission delay is at least twice
its propagation delay.
•If the size of data packet is smaller, then collision detection would not be possible.

Unacademy Plus With 1 Year Subscription Offer :


Use HELLOSONU01
Get 4 Months Free tillcode
10th Octto get
max discount
Use code HELLOSONULIVE to get discount
On, subscription & 350 SRPs Book Free
offer & Single Revision pages
Probabilistic Analysis-

Let us perform the probabilistic analysis to find the average number of collisions before a successful
transmission.

Consider-
•Number of stations connected to a CSMA / CD network = n
•Probability of each station to transmit the data = p FORMULA 18
Transmission will be successful only when-
•One station transmits the data
•Other (n-1) stations do not transmit the data.

Thus, Probability of successful transmission is given by-

Unacademy Plus With 1 Year Subscription Offer :


Use HELLOSONU01
Get 4 Months Free tillcode
10th Octto get
max discount
Use code HELLOSONULIVE to get discount
On, subscription & 350 SRPs Book Free
offer & Single Revision pages
Given the following IP address 38.9.211.19 with a subnet mask of 255.255.255.240 , determine :

1. Network address = 38.0.0.0 (class A network portion :1st octet)


2. Default Subnet mask = 255.0.0.0
3. Broadcast address of the network = 38.255.255.255 (change all HID bits to 1)
4. Subnet ID = IP & Subnet mask = 38.9.211.16
5. Broadcast address of the subnet = Replace HID bits in SID with 1s = 38.9.211.31
6. First host address in subnet = Replace HID with 0 except last 1
7. last host address = Complement of First HID

IP 00100110.00001001.11010011.00010011
Mask 11111111.11111111.11111111.11110000

Subnet ID 00100110.00001001.11010011.00010000
Broadcast 00100110.00001001.11010011.00011111
SID = 38.9.211.16

First Host ID 00100110.00001001.11010011.00010001 = 38.9.211.17


Last Host ID 00100110.00001001.11010011.00011110 = 38.9.211.30
TCP reacts to congestion by reducing the sender window
1.Receiver window size
2.Congestion window size FORMULA 30

Receiver window size is an advertisement of-


“How much data (in bytes) the receiver can receive
without acknowledgement?”

•Sender should not send data greater than receiver window size.
•Otherwise, it leads to dropping the TCP segments which causes TCP Retransmission.
•So, sender should always send data less than or equal to receiver window size.
•Receiver dictates its window size to the sender through TCP Header.

Unacademy Plus With 1 Year Subscription Offer :


Use HELLOSONU01
Get 4 Months Free tillcode
10th Octto get
max discount
Use code HELLOSONULIVE to get discount
On, subscription & 350 SRPs Book Free
offer & Single Revision pages
2. Congestion Window- FORMULA 30
•Sender should not send data greater than congestion window size.
•Otherwise, it leads to dropping the TCP segments which causes TCP Retransmission.
•So, sender should always send data less than or equal to congestion window size.
•Different variants of TCP use different approaches to calculate the size of congestion window.
•Congestion window is known only to the sender and is not sent over the links.

Sender window size = Minimum (Receiver window size, Congestion window size)

Unacademy Plus With 1 Year Subscription Offer :


Use HELLOSONU01
Get 4 Months Free tillcode
10th Octto get
max discount
Use code HELLOSONULIVE to get discount
On, subscription & 350 SRPs Book Free
offer & Single Revision pages
TCP Congestion Policy-

1. Slow Start
2. Congestion Avoidance
3. Congestion Detection FORMULA 31
1. Slow Start Phase-

•Initially, sender sets congestion window size = Maximum Segment Size (1 MSS).
•After receiving each acknowledgment, sender increases the congestion window size by 1 MSS.
•In this phase, the size of congestion window increases exponentially.

Congestion window size = Congestion window size + Maximum segment size

Unacademy Plus With 1 Year Subscription Offer :


Use HELLOSONU01
Get 4 Months Free tillcode
10th Octto get
max discount
Use code HELLOSONULIVE to get discount
On, subscription & 350 SRPs Book Free
offer & Single Revision pages
•After 1 round trip time, congestion window size = (2)1 = 2
MSS
•After 2 round trip time, congestion window size = (2)2 = 4
MSS
•After 3 round trip time, congestion window size = (2)3 = 8
MSS and so
This phase on.
continues until the congestion window size reaches
the slow start threshold.

Threshold
= Maximum number of TCP segments that receiver window can
accommodate / 2
= (Receiver window size / Maximum Segment Size) /2

Unacademy Plus With 1 Year Subscription Offer :


Use HELLOSONU01 code
th
Get 4 Months Free till 10 Oct
to get max
discount On subscription
Use code HELLOSONULIVE to get & 350 SRPs
discount
Book
, offer & Single Free
Revision pages
2. Congestion Avoidance Phase-
FORMULA 32
After reaching the threshold,
•Sender increases the congestion window size linearly to avoid the congestion.
•On receiving each acknowledgement, sender increments the congestion window size by 1.

Congestion window size = Congestion window size + 1

Unacademy Plus With 1 Year Subscription Offer :


Use HELLOSONU01
Get 4 Months Free tillcode
10th Octto get
max discount
Use code HELLOSONULIVE to get discount
On, subscription & 350 SRPs Book Free
offer & Single Revision pages
3. Congestion Detection Phase-
FORMULA 33
Case-1: Detection On Time Out-

•Time Out Timer expires before receiving the acknowledgement for a segment.
•This case suggests the stronger possibility of congestion in the network.
•There are chances that a segment has been dropped in the network.

Reaction-

In this case, sender reacts by-


•Setting the slow start threshold to half of the current congestion window size.
•Decreasing the congestion window size to 1 MSS.
•Resuming the slow start phase.

Unacademy Plus With 1 Year Subscription Offer :


Use HELLOSONU01
Get 4 Months Free tillcode
10th Octto get
max discount
Use code HELLOSONULIVE to get discount
On, subscription & 350 SRPs Book Free
offer & Single Revision pages
Case-2: Detection On Receiving 3 Duplicate Acknowledgements-
FORMULA 34
•Sender receives 3 duplicate acknowledgements for a segment.
•This case suggests the weaker possibility of congestion in the network.
•There are chances that a segment has been dropped but few segments sent later may have reached.

Reaction-

In this case, sender reacts by-


•Setting the slow start threshold to half of the current congestion window size.
•Decreasing the congestion window size to slow start threshold.
•Resuming the congestion avoidance phase.

Unacademy Plus With 1 Year Subscription Offer :


Use HELLOSONU01
Get 4 Months Free tillcode
10th Octto get
max discount
Use code HELLOSONULIVE to get discount
On, subscription & 350 SRPs Book Free
offer & Single Revision pages
A computer on a 10Mbps network is regulated FORMULA 35
by a token bucket. The token bucket is filled at
a rate of 2Mbps. It is initially filled to capacity
with 16Megabits. What is the maximum
duration for which the computer can transmit
GATE
at the full 10Mbps?
(A) 1.6 seconds
(B) 2 seconds
(C) 5 seconds
(D) 8 seconds

Unacademy Plus With 1 Year Subscription Offer :


Use HELLOSONU01
Get 4 Months Free tillcode
10th Octto get
max discount
Use code HELLOSONULIVE to get discount
On, subscription & 350 SRPs Book Free
offer & Single Revision pages
A computer on a 10Mbps network is regulated
by a token bucket. The token bucket is filled at
a rate of 2Mbps. It is initially filled to capacity
with 16Megabits. What is the maximum
duration for which the computer can transmit
GATE
at the full 10Mbps?
(A) 1.6 seconds
New tokens are added at the rate of r bytes/sec which is 2Mbps in
(B) 2 seconds the given question.
(C) 5 seconds Capacity of the token bucket (b) = 16 Mbits
(D) 8 seconds Maximum possible transmission rate (M) = 10Mbps
So the maximum burst time = b/(M-r) = 16/(10-2) = 2 seconds

Duration = C/x-y, where C is the initial capacity, x is outgoing


rate and y is incoming rate.
Unacademy Plus With 1 Year Subscription Offer :
Use HELLOSONU01 codeth
Get 4 Months Free till 10 Oct
to get max
discount
Use On subscription
code HELLOSONULIVE & 350
to get discount
, offer SRPs
& SingleBook
RevisionFree
pages
Suppose host A is sending a large file to host B over a TCP connection. The two end hosts are 10 msec
apart (20 msec RTT) connected by a 1 Gbps link. Assume that they are using a packet size of 1000 bytes to
transmit the file. For simplicity, ignore ack packets. If channel utilization is 100% , then what is the windo
size ?

For 100% efficiency,


Window size GATE
= Maximum number of bits that can be transmitted in 1 RTT
= 1 Gbps x 20 msec
= (109 bits per sec) x 20 x 10-3 sec
= 20 x 106 bits = 2 x 107 bits

Unacademy Plus With 1 Year Subscription Offer :


Use HELLOSONU01
Get 4 Months Free tillcode
10th Octto get
max discount
Use code HELLOSONULIVE to get discount
On, subscription & 350 SRPs Book Free
offer & Single Revision pages
How many check bits are required for 16 bit data word
to detect 2 bit errors and single bit correction using FORMULA 37, 38
hamming code?

Unacademy Plus With 1 Year Subscription Offer :


Use HELLOSONU01
Get 4 Months Free tillcode
10th Octto get
max discount
Use code HELLOSONULIVE to get discount
On, subscription & 350 SRPs Book Free
offer & Single Revision pages
Important Notes-

Default mask for different classes of IP Address are-


•Default subnet mask for Class A = 255.0.0.0
•Default subnet mask for Class B = 255.255.0.0
•Default subnet mask for Class C = 255.255.255.0

FORMULA 40

Unacademy Plus With 1 Year Subscription Offer :


Use HELLOSONU01
Get 4 Months Free tillcode
10th Octto get
max discount
Use code HELLOSONULIVE to get discount
On, subscription & 350 SRPs Book Free
offer & Single Revision pages
FORMULA 41 - 65
Total Number 1st Octet Number of Default
Class of IP Hosts per
of IP Decimal Networks Subnet
Address network
Addresses Range available Mask
Class A 231 1 – 126 27 – 2 224 – 2 255.0.0.0
128 –
Class B 230 214 216 – 2 255.255.0.0
191
192 – 255.255.25
Class C 229 221 28 –2
223 5.0
224 – Not Not
Class D 228 Not defined
239 defined defined
240 – Not Not
Class E 228 Not defined
254 defined defined

You might also like