Sunteți pe pagina 1din 2245

GATE

Overflow Book
April 2016
GATE Overflow April 2016 1 of 2244

GATE Overflow Book

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2 of 2244

This book was created programatically by GATE


Overflow on May 1, 2016. If you feel any doubt
regarding the answer, click on the question link
and give a comment on the site. Studying all
these questions might get you 60 marks in GATE
but that might not be enough for an IIT. So, read
standard books, solve exercise questions and use
these questions for cementing the concepts and
aim 75+. At least if you are not getting solution
to a given problem first refer standard book. If
any error is found on any question it shall be
updated at http://gateoverflow.in/corrections.
Also please update the book on next release
which will be with in 3 months as more questions
are being added and many corrections going on.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 3 of 2244

GATE Overflow was started just a year ago and


a lot of people have dedicated their time and
effort in bringing this book now. Initiated by
Omesh Pandita and Arjun Suresh as a Q/A
platform for CSE students, Kathleen was
instrumental in geting all previous year GATE
questions here. Then experts like Praven Saini,
Happy Mittal, Sankaranarayanan, Suraj etc.
have contributed a lot to the answers here.
Pragy Agarwal even after topping GATE has
continuously contributed here with his knowledge
as well as in making the contents beautiful with
fine latex skills. We also have to thank the work
by Jothee, Misbah, Ishrat and Nataliyah who
are continuously adding and keeping the
contents here neat and clean. There are also
many toppers of GATE 2015 and probable ones
of GATE 2016 who are contributing a lot here.
The list of all the contributors can be found here
but even that do not include the contributions of
some like Arif Ali in helping design this book,
Arvind Devaraj and others who have provided
guidance and help etc. Last but not the least, we
thank all the users of GATE Overflow.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 4 of 2244

Table of Contents
Algorithms
Access Time
Ace Test Series
Activity Selection
Algorithm
Algorithms
Asymptotic Notations
B Tree
Bfs
Binary Heap
Binary Search
Binary Search Tree
Binary Tree
Bst
Chaining
Cyclomatic Complexity
Dfs
Dijkstras Algorithm
Dynamic Programming
Gcd
Geek Mock 2016
Generating Functions
Graph Algorithms
Greedy Algorithm
Hashing
Heap
Heap Sort
Huffman Code
Inversions
Knapsack
Loop
Loop Invariants
Madeeasy
Madeeasy Testseries
Master Method
Master Theorem
Merge Sort
Merging
Minimum Spanning Trees
Mst
P Np Npc Nph
Placement Questions
Quicksort
Recurrence
Recurrence Eqation
Recurrence Equation
Recursion
Recursion Tree
Shortest Path
Sorting
Space Complexity
Spanning Tree
Stack
Testbook
Time
Time Complexity
Topological Sort
Why
Programming & DS
Arrays
Programming In C
Engineering Mathematics
Compiler Design
Compiler Tokenization
Derivation Tree
Grammar
Intermediate Code
Lexeme
Lexical Analysis
Live Variable
Ll1
Lr Parser
Marks

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 5 of 2244

Parsing
Programming In C
Register Allocation
Regular Language
Scope
Sdd
Shift
Shift Reduce
Syntax Directed Translation
Target Code Generation
Testbook
Tokens
Top Parsing
Variable Binding
CO & Architecture
Access Time
Ace Test Series
Address Translation
Addressing Modes
Arrays
Associative Memory
Average Stall Cycle Per Ins
Branch Conditional Instructions
Byteaddressable
Cache
Cache Memory
Car
Cisc
Clock Time
Clockcycle
Coa
Computer Organization
Control Unit
Cpu
Cycle
Data Dependencies
Data Hazards
Data Path
Direct Mapping
Disk
Dma
Dram Refreshing
Effective Memory Access
Fault
Floating Point Representation
Gmr
Horizontal
Ieee Representation
In
Instruction Format
Interrupts
Io
Io Organization
Lockup Free Cache
Look Aside
Machine Instructions
Madeeasy
Madeeasy Testseries
Memory
Memory Interfacing
Memory Management
Microprogramming
Misses
Multiplexer
Number
Number Representation
One
One Task Execution
Operand Forwarding
Page Replacement
Pipeline
Preparation
Priority
Ram
Reference Book
Secondary Storage

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 6 of 2244

Speedup
Stack
Stall
Stealing
Testbook
Throughput
Tlb
Track
Virtual Memory
Virtualgate
Write_through
Operating System
Ace Test Series
Address
Bitmap
Cache Memory
Computer Organization
Concurrency
Context Switch
Deadlock
Demandpaging
Disk
Disk Scheduling
Dram Refreshing
Effective Memory Access
Exponential Averaging
File System
Fork
Inode
Inter Process Communication
Internal Fragmentation
Io Handling
Linked Lists
Madeeasy
Maths
Memory Allocation
Memory Management
Misses
Multitasking
Mutex
Operating_system
Page
Page Fault
Page Replacement
Page Table
Paging
Process
Process Schedule
Process Synchronization
Resource Allocation
Resource On
Secondary Storage
Segmentation
Semaphore
Set Associative
Software Testing
Testbook Test Series
Thrashing
Tlb
Virtual Memory
Virtualgate
Databases
B
B Tree
Bcnf Decomposition
Candidate
Canonical Cover
Canonical Normal Form
Cartesian Product
Concurrency
Conflict_serializable
Data
Data Isolation
Database
Database Constraints
Database Normalization

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 7 of 2244

Dbms
Ddl
Decomposition
Dependency Preserving
Er
Er Diagram
Er Model
File
File System
Foreign
Form
Functional Dependencies
Indexing
Minimal Cover
Multivalued Dependency 4nf
Natural Join
Query
Referential Integrity
Regular Language
Relational Algebra
Relational Calculus
Relations
Sql
Testbook
Transactions
Tree
Update
View_serializable
Virtual
Virtualgate
Where
Theory of Computation
Automata
Cbt 1
Chomsky Normal Form
Closure Property
Combinations
Compound Automata
Context Free
Context Sensitive
Counting
Csl
Dcfl
Decidability
Dfa
Finite Automata
Flip Flop
Grammar
Identify Class Language
Inherently Ambiguous
Ldentify Language
Made
Madeeasy
Madeeasy Testseries
Minimal State Automata
Myhill Nerode
Nfa
Non Regular
Normal Pda
Number Of Dfa
Pda
Pumping Lemma
Pushdown Automata
Rank Of Nonterminal
Recurrence
Recursive Recursively Enumerable
Reduction
Regular Expressions
Regular Language
Regular Set
Rel
Testbook
Time Complexity
Turing Machine
Virtualgate
Computer Networks

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 8 of 2244

Ace Test Series


Back Off Delay
Computer
Congestion Control
Crc Polynomial
Cryptography
Csma Cd
Delay
Distance Vector Routing
Error Correction
Error Detection
Ethernet
Expectation
Fragmentation
Frame
Go Back N
Hamming Code
Ip
Ip Packet
Ipv6
Jnuee 2006
Leaky Bucket
Network Addressing
Network Protocols
Network Security
Network Switching
Numerical Type
Osi Protocol
Peterson Davie
Probability
Pure_aloha
Reference Book
Ring
Routers Bridge Hubs Switches
Routing
Routing Table
Rsa
Rto
Serial Communication
Sliding Window
Slotted_aloha
Stop And Wait
Subnetting
Tcp
Throughput
Token Ring
Wifi
Workbook Question
Digital Logic
Adder
Bcd
Binary Codes
Boolean Algebra
Boolean Expressions
Booths Algorithm
Canonical Normal Form
Circuits
Clock Frequency
Combinational
Counter
Data Hazards
Decoder
Demux
Digital
Dual Function
Flip Flop
Floating Point Representation
Functional Completeness
Functional Dependencies
Gray Code
Ieee Representation
K Map
Logic
Multiplexer
Nand Nor
Network Switching

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 9 of 2244

Number Representation
Overflow
Pla
Radix
Self
Sequential
System
Systems
General Aptitude
Cbt 1
Verbal Ability
Algebra
Made Easy_test Series
Mocktest
Number Series
Testbook
Venn Diagrams
Numerical Ability
Ace Pregate
Ace Test Series
Algebra
And
Binary Tree
Cat2009
Combinations
Combinatorics
Expectation
Geometry
Logarithms
Logical Reasoning
Modular Arithmetic
Probability
Probability Using Tree Method
Quadratic Equations
Ratios
Test Cases
Virtualgate
Work Time
Mathematical Logic
Eigen Value
Equivalence Classes
First Order Logic
Groups
Kenneth Rosen
Mathematical Logic Virtualgate
Matrices
Probability
Random Variable
Probability
Bayes Theorem
Binomial Theorem
Coin
Conditional Probability
Expectation
Independent Events
Made Easy_test Series
Mode
Modular Arithmetic
Pgee
Probability
Random Variable
Statistics
Testbook
Variance
Set Theory & Algebra
Ace Test Series
Boolean Algebra
Equivalence Classes
Functions
Generators
Group
Groups
Hasse Diagram
Kenneth Rosen
Lattice
Madeeasy

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 10 of 2244

Partial Order
Pigeonhole
Relations
Sets
Summation
Theory
Combinatory
Combinatory
Arrangement
Combinations
Combinaton
Combinatorics
Counting
Generating Functions
Made Easy_test Series
Permutation
Pigeonhole
Placement Questions
Probability
Recurrence
Recurrence Eqation
Graph Theory
Ace Test Series
Bfs
Graph Coloring
Graph Isomorphism
Graph Matching
Graph Planarity
Haming Distance
Recurrence
Linear Algebra
Complex Number
Eigen Value
Eigen Vector
Lu Decomposition
Matrices
Number Series
Polynomials
Calculus
Complex Number
Integration
Limits
Maxima Minima
Mocktest
Parabola
Study Resources
Virtualgate
Programming
Ace Test Series
Array Of Pointers
Arrays
Avl Tree
B Tree
Barc2016
Binary Tree
Bst
Compiler Tokenization
Confusing
Divide And Conquer
Functions
Geeks
Graph Algorithms
Hashing
Heap Sort
Identify Function
Linked Lists
Loop
Memory Management
Minimum Spanning Trees
Output
Parameter Passing
Pointers
Programming In C
Recurrence Equation
Recursion
Scope

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 11 of 2244

Sorting
Stack
Storage Classes In C
Structures
Syllabus
Time Complexity
Variable Binding
DS
Arrays
Asymptotic Notations
Avl Tree
B Tree
Binary Heap
Binary Search
Binary Search Tree
Binary Tree
Bst
Chaining
Clrs
Combinatorics
Dfs
Hashing
Linked Lists
Permutation
Pointers
Postfix
Programming In C
Queues
Recursion
Rmo
Sorting
Stack
Trees
Universal Hash
Admissions
IISc/IITs
Admissions
Area Of Interest
Cse
Cutoffs
Eligibility
Iisc
Iit
Iit Bombay
Iit Madras
Ms
Obc Ncl
Qualify
NITs
Cutoffs
Placements
IIITs
Other Colleges
Ism Dhanbad
Others
Psu
Study Resources
Arjunsir
Guidance
Mocktest
Preparation
Repeating Gate
Study Resources
GATE Application
Eligibility
Registration
Revision
Associative Memory
Lru
Null
Written Exam
Iisc
Interview Questions
Iitd 2011
Puzzles
Puzzle

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 12 of 2244

Puzzles
Algorithm Challenges
Algorithm Challenge
Placement Questions

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 13 of 2244

1 Algorithms top
1.1 Access Time: Arranging files to optimize access time ISRO_2015 gateoverflow.in/37207

top

Six files F1, F2, F3, F4, F5 and F6 have 100, 200, 50, 80, 120, 150 records respectively. In what order should they be stored
so as to optimize act. Assume each file is accessed with the same frequency

(a) F3, F4, F1, F5, F6, F2


(b) F2, F6, F5, F1, F4, F3
(c) F1, F2, F3, F4, F5, F6
(d) Ordering is immaterial as all files are accessed with the same frequency.

The answer is A. However, why should we search sequentially? Can't we arrange the files as F1,F2...F6, and then do binary
search?

effective-memory-access time access-time isro2015

Ans.A

 0 votes -- gkumar kumar ( 27 points)

1.2 Ace Test Series: Algorithms : True/False top gateoverflow.in/37529

Which of the following statement is true?

A. Binary insertion sorting (insertion sort that uses binary search to find each insertion point) requires O(nlogn) total
operations.
B. In the merge-sort execution tree, roughly the same amount of work is done at each level of the tree.
C. In a min-heap, the next largest element of any element can be found in O(logn) time.
D. In a BST, we can find the next smallest element to a given element in O(1) time.

ace-test-series algorithms time-complexity


Selected Answer

Insertion Sort with Binary search : yes no comparison surely reduced bt no of swaps still be there.. Time complexity
remain O(n2).
Time complexity of Merge Sort T(n) = T(n/2) + O(n) here O(n) is level cost.
In min heap for next max it will take O(n) time .
Let element is X .. then Find X will take O(n) in worst case then constant time to find next min. Total O(n)

only B is correct .

 0 votes -- Digvijay Pandey ( 26245 points)

1.3 Ace Test Series: True/False top gateoverflow.in/36658

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 14 of 2244

asymptotic-notations ace-test-series algorithms

i am not sure so, don't know about that balanced tree.

but ya 1 and 3 are correct.

 0 votes -- Shah Himadri Satishbhai ( 171 points)

1.4 Activity Selection: What is the time complexity of job sequencing with
deadline using greedy algorithm? top gateoverflow.in/28992

What is the time complexity of job sequencing with deadline using greedy algorithm?

O(n)
O(log n)
O(n log n)
O(n2)

Made Easy

Full Syllabus Test-6 : Basic Level : Practice Test-14

Q 19

Please give reference for this answer to this algorithm.

greedy-algorithm activity-selection deadlines algorithms

1) To sort N Job - O(nlogn).

2) Take each job and start where the deadline is given ans keep searching for the vaccant location. So if there are N jobs
for each job we need to search N slots. i.e O(n^2)

so total time complexity is O(n^2)

http://www.geeksforgeeks.org/job-sequencing-problem-set-1-greedy-algorithm/

 0 votes -- Prasanna Ranganathan ( 2045 points)

1.5 Activity Selection: Greedy Approach - Task selection top gateoverflow.in/35964

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 15 of 2244

algorithms activity-selection deadlines

1.6 Algorithm: what will be the time complexity for the below question ? top
gateoverflow.in/41775
Let an array A[1,....n] has n elements, and every element of an array is less than or equal to n. An element is said
to be "majority element" if it is occurred in more than n/2 positions of an array. what is the time complexity to check
whether the majority element exist or not?

algorithm time-complexity

//Deleted

As I didn't see geeksforgeeks solution

I had mention about binary search algorithm

 0 votes -- HvnCool ( 37 points)

1.7 Algorithms : How to Solve this recursive equation top gateoverflow.in/42329

F(n) = 2F(n-1)+1 using back substitution.

Kindly explain like I'm a naive person solving this. Thanks!

algorithms- recursion

http://gateoverflow.in/32159/complexity-recurrence-relation-using-substitution-method

 0 votes -- Manojk ( 3365 points)

1.8 Asymptotic Notations: Let n = m!. Which of the following is true? gateoverflow.in/30720

top

(a) m = Θ(logn / loglogn)

(b) m = Ω (logn / loglogn) but not m = Ο(logn / loglogn)

(c) m = Θ ( (logn)^2)

(d) m = Ω ( (logn)^2) but not m = Ο( (logn)^2)

(e) m = Θ ( (logn)^1.5)

tifr2016 asymptotic-notations

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 16 of 2244

m n=m! log n/log log n


4 24 4/2 = 2
6 720 9/3 = 3
8 720*56 15/3 = 5
10 720*56*90 21/4 = 5

If we see, m is growing at same rate as log n/log log n.

 2 votes -- Arjun Suresh ( 124125 points)

1.9 Asymptotic Notations: Let f(x), g(x) and h(x) be function which of
following statement is false? top gateoverflow.in/36477

Q16). Let f(x),g(x) and h(x) be functions which of the following statement is false?

a). if f(x) is O(g(x)) and g(x) is O(h(x)) then f(x) is O(h(x)).

b). if f(x) is Ω(g(x)) and f(x) is Ω(h(x)) then g(x) is Ω(h(x))

c). Both (a) and (b)

d). Neither (a) nor (b)

I mean according to me , option (a) is correct , right ? by the rule of transitivity .

Please correct me , if I am wrong.

asymptotic-notations algorithms


Selected Answer

A.
f(x) = O(g(x)) i.e. f(x) <= g(x) ...........(1)
g(x) = O(h(x)) i.e. g(x) <= h(x) ...........(2)

from (1) and (2),


f(x) <= g(x) <= h(x)
f(x) = O(h(x))

B.
f(x) = Ω(g(x)) i.e. f(x) >= g(x) ...........(1)
g(x) = Ω(h(x)) i.e. g(x) >= h(x) ...........(2)

from (1) and (2),


f(x) >= g(x) >= h(x)
f(x) = Ω(h(x))

both are true..

TRANSITIVITY holds for O, Ω as well..


PS : in case of small O & Ω only reflexivity & Symmetricity faiils.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 17 of 2244

 1 votes -- Digvijay Pandey ( 26245 points)

yeah that's right , option (a) is correct

 1 votes -- Daddy's little gal ( 247 points)

1.10 Asymptotic Notations: Asymptotics top gateoverflow.in/34389

Find the False statement.

a. O(2n ) = O(3n )

b. O(logn2 ) = O(logn)

(
c. f(n) = O (f(n))2 )

d. 22log n (logn) = O(n2 logn)

algorithms asymptotic-notations


Selected Answer

A, C are False. B, D are True.

What is O(g(n))?

It is the set of all functions that grow no faster than g(n).

O(g(n)) =
{ f(n):
there exist positive constants c and n 0 such that
0 ≤f (n ) ≤c⋅g (n ) for all n ≥n 0 }
What does it mean to say f(n) = O(g(n))?

This is an abuse of notation (but not a misuse!)

When we say f(n) = O(g(n)), we actually mean f(n) ∈ O(g(n)), that is, the function f(n) is an element of the set of all functions
that grow no faster than g(n). In other words, f(n) doesn't grow faster than g(n)

Note: We are allowed to abuse the notation because it makes life easier. However, we must take care not to misuse the
notation!

We should make sure, however, to understand the precise meaning of the notation so that when we abuse, we
do not misuse it. - CLRS (3rd edition, Page 44)

If A and B are two sets, what does it mean to say A = B?

It means that every element in A also exists in B, and every element in B also exists in A.

Coming back to the question,

Option A: False

O(2n ) is a set of all functions that grow at most as fast as 2n .


O(3n ) is a set of all functions that grow at most as fast as 3n .

Consider the function 2.5n . It belongs in O(3n ), but not in O(2n ). Hence, the two sets can't possibly be equal.

Option B: True

( )
log n2 = 2logn.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 18 of 2244

Since constant multiplicative factors do not matter in asymptotic complexity, O(log(n2 )) = O(logn)

Option C: False.

1 1
2
As mentioned by amarVashishth, x grows faster than x . Hence, f(x) ∉ O(f2 (x))

Options D: True.

Let the base of the log be 2 (anything will work).

(
22log n ⋅ logn = 2log n )2
⋅ logn = (n)2 ⋅ logn.

 5 votes -- Pragy Agarwal ( 13675 points)

1.11 Asymptotic Notations: Below question asked in GATE 1993. In this


1<=k<=n mentioned however k not using anywhere in notation. top gateoverflow.in/33230

∑ (range − > 1 <= k <= n)O(n), where O(n) stands for order n is -

a) O(n) b) O(n 2)

c) O(m 3) d) O(3n 2)

asymptotic-notations

Yes,'K' is used as follows:

1<= k<= n => we have add O(n) 'n' times since 'k' is 1 to n. 'K' is like iterator .

Hence : O(n) +O(n) +O(n) +...........n times = nO(n) = O(n 2)

Hence ans: (b)

 1 votes -- Shashank Kumar ( 2029 points)

1.12 Asymptotic Notations: Asymtotic Analysis top gateoverflow.in/26333

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 19 of 2244

asymptotic-notations algorithms

All options are abusing asymptotic notations. Please change the source of your practice :(

 3 votes -- Arjun Suresh ( 124125 points)

1.13 Asymptotic Notations: Let f(n) , g(n) be two functions of n , which one
the following is correct top gateoverflow.in/15289

f(n) = n2 logn

g(n) = n (logn) 10

Ans given as g(n) = O(f(n)) and f(n) != O(g(n))

But , if I take base of log as 2

then for random value of n ( say 16)

g(n) = 16 * ( log 216)10 = 16 * ( 4 ) 10

and f(n) = 256 * log 216 = 256*4

So , will it not be f(n) = O(g(n)) ?

asymptotic-notations


Selected Answer

f(n) = n2 logn, g(n) = nlog10n

Dividing both these functions by (nlogn), we get:

F(n) = n, G(n) = log9 n

Since any polynomial function grows faster than any logarithmic function, we have:

F(n) grows faster than G(n)

 f(n) grows faster than g(n)

 nlog10n = O(n2 logn)

 4 votes -- Digvijay Pandey ( 26245 points)

1.14 Asymptotic Notations: Let f(n) = O(n), g(n) = θ(n), and h(n) = Ω(n).
Then f(n). h(n) + g(n) is_______________ top gateoverflow.in/7224

let us consider f(n) is log(n) and g(n) = n and h(n) = n^2.

since logn<= n

n2 >= n for all values so given above equality holds true

but when we substitute n+((logn)(n2) = O(n2) but ans is Ω(n) can somebody wxplain this plz

algorithms asymptotic-notations

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 20 of 2244

You can also take h(n) = n 3, and then the upper bound changes. But whatever you take the lower bound of f(n) won't
change and remains n because of the θ(n) term.

 2 votes -- Arjun Suresh ( 124125 points)

1.15 Asymptotic Notations: Asymptotic Notation top gateoverflow.in/10781

Describe a Θ(nlgn)-time algorithm that, given a set S of n integers and another integer x, determines whether or not there
exists two elements of S whose sum is exactly x.

asymptotic-notations algorithms

1. Apply Merge or Heap sort for sorting..


2. An sorted array A[n].
i=0,
j= n-1
While (i!=j)
If (A[i] + A[j] = x) return( A[i], A[j])
Else
{
If ( A[i] + A[j] < C)
{ i++ }
else j--
}
Time complexity will be O(nlogn) + O(n)

 0 votes -- Digvijay Pandey ( 26245 points)

1.16 Asymptotic Notations: Complexity top gateoverflow.in/25893

Consider two natural-valued functions f: N  N, and g:N  N. Which of the following statements canNOT be True?

a. f ∈ O(g) and g ∈ O(f)


b. f ∈ Θ(g) and g ∈ Θ(f)
c. f ∈ Ω(g) and g ∈ Ω(f)
d. f ∈ O(g) but g ∉ Ω(f)

asymptotic-notations

f∈O(g) = f≤c.g(n) g∈O(f) = g≤ c 1f(n)


if we take same function for both f and g then a b and c can be possible for some constant.
a) f∈O(g) and g∈O(f)
b) f∈Θ(g) and g∈Θ(f)
c) f∈Ω(g) and g∈Ω(f)
d) f∈O(g) but g∉Ω(f)
f∈O(g) = f≤c.g(n) for some constant and it also implies that g∈Ω(f) coz for some constant g≤ c.f(n) is possible
so i think option D.

 1 votes -- Umang Raman ( 10379 points)

1.16 Asymptotic Notations: T1(N)=OF(N),T2(N)=OF(N) THEN


T1(N)+T2(N)=OF(N) is it true explain top gateoverflow.in/12648

asymptotic-notations

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 21 of 2244


Selected Answer

Yes this is true .

say O (F(n)) = O(n 2) (assume )

T1(n) = O (n 2) and T 2(n) = O (n 2)

then T1(n) + T 1(n) = 2 O (n 2) = O (n2) (constant term dont affect the complexity )

eg :

F(n) = 2n 2 +n+1 then

O (F(n))= n 2

 3 votes -- Pranay Datta ( 6113 points)

1.17 Asymptotic Notations: Let f(n)= Ω(n), g(n)= O(n) and h(n)= Ѳ(n). top
gateoverflow.in/11232

Let f(n) = Ω(n), g(n) = O(n) and h(n) = Ѳ (n). Then [f(n). g(n)] + h(n) is:

A. Ω (n)
B. O (n)
C. Ѳ (n)
D. None of these

asymptotic-notations


Selected Answer

f(n). g(n) - here the individual bounds are ≥n and ≤n respectively. So, for their product we can just say it is ≥ n or Ω(n)
provided g is a non-decreasing function. But h = Θ(n)  h = O(n) ∧ h = Ω(n). So,

[f(n). g(n)] + h(n) = Ω(n).

(whatever be the complexity of f(n). g(n), h(n) grows at least at the rate of n and hence the whole expression too, due to '+')

 6 votes -- Arjun Suresh ( 124125 points)

1.18 Asymptotic Notations: Asymptotic Analysis top gateoverflow.in/5150

Why is this order true.... 2^sqrt (log n) is exponential.. so it should be greater than n^1/4?

algorithms asymptotic-notations

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 22 of 2244

n = 16 n = 256 n = 2256 n = 265536 n = 2256k

6553616 (256k)18

lognlog log n 16 512 2563 = 224 ( )


= 216
16
( )
= 218
18

= 2256 = 2324

2√log n 4 2√8 216 2256 2512


1
4 2 4 264 216384 264k
n

We can see that the growth of the first function is the least, then the second and the last one is growing the fastest. So,
(a) choice is correct.

 6 votes -- Arjun Suresh ( 124125 points)

1.19 Asymptotic Notations: What is the simplification of the below


mentioned expression - top gateoverflow.in/33226

n^(1/(2^(log2log2n)))

asymptotic-notations

Ans: 2

Just apply formula a log ab = b

we have ,2 log 2log 2n = log 2n

Hence questions reduces to n 1/log2n = n log n2 = 2

hence simplified value is '2'

 1 votes -- Shashank Kumar ( 2029 points)

1.19 Asymptotic Notations: T(A)=OT(B) which algorithm is better? O=big oh


why? top gateoverflow.in/12515

algorithms asymptotic-notations

It's equivalent to writing ta <= tb so ta must be faster than tb

 1 votes -- Bhagirathi Nayak ( 10239 points)

1.20 Asymptotic Notations: let f(n) and g(n) be asymptotically non negative
functions which of the following is correct? top gateoverflow.in/13101

If f(n) and g(n) be asymptotically non negative functions then which of the following is correct?

A).Θ(f(n) ∗ g(n)) = max(f(n), g(n))

B).Θ(f(n) + g(n)) = max(f(n), g(n))

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 23 of 2244

asymptotic-notations algorithms

f(n) ≤ f(n) ∗ g(n) and g(n) ≤ f(n) ∗ g(n).

Hence, max(f(n), g(n)) ∈ O(f(n) ∗ g(n))

if f(n) or g(n) =0 then f(n) ∗ g(n) <= max(f(n), g(n))

Hence, max(f(n), g(n)) ∈ Ω(f(n) ∗ g(n)

so max(f(n), g(n)) ∈ Θ(f(n) ∗ g(n)) (i`m not sure please correct me if i`m wrong :) )

f(n) ≤ f(n) + g(n) and g(n) ≤ f(n) + g(n).

Hence, max(f(n), g(n)) ∈ O(f(n) + g(n)) just multiplying a constant,

f(n) + g(n) ≤ 2 ∗ max(f(n), g(n)). Hence, max(f(n), g(n)) ∈ Ω(f(n) + g(n))

Hence, we get that max(f(n), g(n)) ∈ Θ(f(n) + g(n))

REF: http://math.stackexchange.com/questions/267252/how-to-prove-that-maxfn-gn-thetafn-gn

 1 votes -- Pranay Datta ( 6113 points)

1.21 Asymptotic Notations: which function has higher growth rate among n 3
and (logn)! ? top gateoverflow.in/27704

According to me n3 should be asymptotically greater since (logn)! is computed like logn will be a small constant less than n and
when I calculate its factorial it will obviously be less than n3 .

asymptotic-notations


Selected Answer

You should not say "small constant"- "much smaller value than n" is correct. But after taking factorial how can we be sure
this will remain smaller?

We can take log for both.

( )
log n3 = 3 ⋅ logn

( )
We also know that log(x!) = Θ x ⋅ log(x) (Stirling's approximation)

Putting x = (logn), we get:

( ) (
log (logn)! = Θ logn ⋅ log(logn) )
So, the second one (2) is asymptotically larger than (1), as log(logn) is asymptotically larger than 3.

 8 votes -- Arjun Suresh ( 124125 points)

The fact that (logb n)! grows faster than n3 can be somewhat counterintuitive.
So, here's a way you can make it more sensible.

Think of what would happen if instead of having a factorial, we had an exponential. That is, instead of having (logb n)!, we
had e logb n.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 24 of 2244

Since exponentials and logarithms are inverses of each other, we can simplify it a bit.

(
e logb n = b logb e ) logb n
(
= b logb n ) logb e
= n logb e

This means that is we use an exponential instead of a factorial, we get a polynomail with degree logb e. Depending on the
value of b, this degree could be anything between ( − ∞, ∞), and thus, even greater than 3!

So, by using exponentials, we can surpass n3 .

But that is not all. We also know that factorials grow faster than exponentials! That is, x! = ω(cx). So, if we have a factorial
with the (logn), we are already growing faster than any polynomial nc!

And thus, (logb n)! grows faster than n3

 4 votes -- Pragy Agarwal ( 13675 points)

1.21 Asymptotic Notations: Let f(n) = Ω(n), and g(n) = O(f(n)). Then g(n) =
_______ [Assume n > 0] 1. Ω(n) 2. O(n) 3. θ(n) 4. Ω(1) top gateoverflow.in/36807

asymptotic-notations algorithms

F(n)=omega(n)=n,n2 ,n3 etc

So g(n)=O(n),O(n2 ),O(n3 ) etc , So option O(n) matches.

 0 votes -- chat28 ( 495 points)

1.22 Asymptotic Notations: Given two positive functions f(n) and g(n).If
f(n)/g(n)=c , for some constant c >=0 , which of the stmts are true ? gateoverflow.in/38379

top

If c is non-negative but not infinite then :

1.f(n)=O(g(n))

2.f(n)=⊖(g(n))

According to me :

it is saying that c is non-negative and not infinite so if g(n) tends to zero then c will tend to infinite but it is given that it is not infinite therefore clearly g(n) should be larger than f(n) , so more
precisely we can say f(n)=O(g(n)) ,plz correct me ,if I am wrong

asymptotic-notations

It could be (-)g(n) as c is a constant and > 0 i.e. F(n) has same order of growth as g(n)

 0 votes -- akshay kapase ( 35 points)

1.23 Asymptotic Notations: true or false? top gateoverflow.in/17960

T1(n)=O(f(n))

T2(n)=O(f(n))

then check T/F?

.T1(n)+T2(n)=O(f(n))

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 25 of 2244

.T1(n)=O(T2(n))

.T1(n)=ω(T2(n))

.T1(n)=Θ(T2(n))

asymptotic-notations


Selected Answer

T1(n)=O(f(n)) => T1(n) < c 1 * f(n) where c 1 is +ve constant (from Big O Def)

T2(n)=O(f(n)) => T 2(n) < c 2 * f(n) where c 2 is +ve constant (from Big O Def)

a] True

Since T1(n) + T 2(n) < (c 1+c2) * f(n), So we can say T 1(n) + T 2(n) = O(f(n))

b] False

Let T 1(n) = n 2 and T 2(n) = n and f(n) = n 3

Clearly T1(n) >T 2(n),So T 1(n) = O(T 2(n)) is not possible.

c] False

Let T 1(n) = n and T 2(n) = n 2 and f(n) = n 3

Clearly T1(n) < T 2(n),So T 1(n) = ώ(T 2(n)) is not possible.

d] False

Take the same assumptions as above then

You can say, T 1(n) < C 1 * T 2(n) for C1 = 1 but

T1(n) > C 2 *T2(n) is not possible for any positive constant

Then T 1(n)= Θ(T 2(n)) is not possible.

 1 votes -- IgnitorSandeep ( 425 points)

1.24 Asymptotic Notations: True/False top gateoverflow.in/33231

(logn)1/2=O(loglogn)

asymptotic-notations


Selected Answer

(logn)1/2 = O(loglogn) => (log) 1/2 ≤ loglogn

Taking log both side

1/2 loglogn ≤ logloglogn ==> FALSE since loglogn > logloglogn .

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 26 of 2244

Hence loglogn ≤ (logn) 1/2 => loglogn = O(√logn)

 1 votes -- Shashank Kumar ( 2029 points)

1.25 Asymptotic Notations: true / false top gateoverflow.in/29492

i geeting ans 1 and 2 are true but ans given only 2 is true explain it

asymptotic-notations

(n+1)! = (n+1)* (n)*(n-1)*........1 = (n+1)*(n!) > n!

Hence n! = O((n+1)!) => option (1) is wrong.

log4n = (1/2)* log 2n, So we can write log 2n as follows:

(1/2)* log2n ≤ (1/2)* log 2n ≤ log 2n => (1/2)* log 2n = ⊝(log 2n) => log 4n = ⊝(log2n) Hence (!!) is correct.

√logn ≥ loglogn => loglogn = O( √logn) => (!!!) is wrong.

Hence only (!!) is correct. Hence option (C) is correct.

 0 votes -- Shashank Kumar ( 2029 points)

1.26 Asymptotic Notations: How do O and Ω relate to worst and best case? top
gateoverflow.in/32570
I am unable to get the actual significance of the asymptotic notations with respect to best , worst and average
case , for instance why is worst case of insertion sort theta(n^2) , why not O(n^2) more specifically .

Also why does Binary search takes Theta(log n ) time and not O(log n ) time ,since in best case we may find the element at
first position only so it will take omega(1) time then so why do we consider Theta(log n) .

Even I am not getting that do we have to associate best and worst cases with these asymptotic notations , say If I have to
insert an element into an unsorted linked list , then what is the terminology of best case ,worst case here , it is obvious that
it will always take O(n) ,Now even if I have one node here and I am inserting an element after that node ,it will take
constant time ,it will take so what should I say that time complexity is omega(1) or O(1) or theta(1) more tightly .

I have gone through this link but still I am under lots of confusions ,please clarify this precisely .

http://cs.stackexchange.com/questions/23068/how-do-o-and-%CE%A9-relate-to-worst-and-best-case

asymptotic-notations

An algorithm does nt take same amount of time for all possible instances of input.for some instances it could be larger
than for the other instance.so,if we have 2 algo for same problem ,we decide their relative awsmness by asymptotic
analysis. if we know that for the worst instance on input the algo will take f(n) time or lesser then we can say that T(1st
algo)=0(f(n))

so,by calculating the T(2nd) algo and comparing their value we can decide that which one is better.

for most of the instance of the i/p ,what is the time complexity of the problem is called average case.ssso,it will be less
than the worst case and greater than the best case.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 27 of 2244

similliarly ,for the best instance of i/p,the T(algo) is the bes case.

in worst case ,binary search will recurse till there will be only one element in the divided subproblem(element does nt exit
in the array or it exists in a pos which will be find out in the last recursion of bst) and then it will produce the result.no of
comparision in this case= height of the tree 0(logn) => worst case =>gives the upper bound of the algo

in best case,the element will be present in the middle,which will be find out in first iteration.time complexity=omega(1)

generally we should use avg case time complexity .

 0 votes -- Saurav Kumar Gupta ( 1455 points)

1.27 Asymptotic Notations: Asymptotics top gateoverflow.in/32880

Ans given is D. Is it because, in analyzing this we would ignore the constants involved in the equation?

asymptotic-notations algorithms

No its not the case. Its because all options a,b,c are correct so ans is option d.

Given function is f(n) = 2 n-4

Lets take each options one by one

(a) f(n) is ⊖(2 n+3)

f(n) = ⊖(g(n)) means there exist two constant C1 and C2 such that

f(n) <= C1 g(n)

f(n)>=C2 g(n)

just take C1 = C2 = 2 7 and you will get the both the conditions are satisfying.

b) f(n) is Ω(n 1000)

clearly f(n) is exponential and n 1000 is polynomial so it is also true. or you can put a number n = 1000000 or more than
this get this. This one you may find that 'n' value is large but anyway we do analysis of functions asymptotically so no
issue with large number.

c) f(n) is O(2 n-10)

g(n) = 2n-10

f(n) <= c.g(n)

where c can be any number more than 2 6

So this way you all three options are true.

 2 votes -- Sandeep Singh ( 5939 points)

1.28 B Tree: ugc net top gateoverflow.in/43898

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 28 of 2244

b-tree


Selected Answer

It should be O(t logtn)

h=O(logtN)

So total time =O(t h)

 0 votes -- Manojk ( 3365 points)

1.29 Bfs: Breadth-first search time for given vertex in complete graph gateoverflow.in/38611

top

Argument: As it a complete tree, maximum BFS level possible are log(n). And as BFS time is O(n+E) , taking E as path cost ,
it will give O(n+logn) which is O(n). So, I ticked B. Answer is given as C. But, if we take a vertex just in the first level , so
the time cost will be Omega(1). So, C must not be true. Where am I going wrong??

bfs graph-algorithms ace-test-series

consider a binary tree in which 1,2,3,4,5,6,7 are inserted in level order.Then node 7 will be the last one to get inserted.
Now we want to find the worst case search time to find 7. Consider this BFS order 1,2,3,4,5,6,7 in which we need to
traverse all the 7 nodes to reach 7 i.e O(n). And the best case BFS order to find 7 is is 1,3,2,7,6,4,5 I hope this helps!

 0 votes -- Susheel_Sriram ( 19 points)

1.30 Binary Heap: What is the complexity of finding 50th smallest element in
an already constructed binary min-heap? top gateoverflow.in/5915

What is the complexity of finding 50th smallest element in an already constructed binary min-heap?

a. θ(1)
b. θ(logn)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 29 of 2244

c. θ(n)
d. θ(nlogn)

algorithms binary-heap heap


Selected Answer

It is constant.as long as number is independent of n it can be found with k×k-1/2 Comparisons.

 4 votes -- Anurag Semwal ( 4775 points)

Deletion of min element from min-heap can be done in logn time. To find the 50th min element we have to perform 49
deletion of min element from the binary min-heap.

Therefore, total time to extract 50th min element = 49 lgn

= theta(lgn)

 1 votes -- suraj ( 3299 points)

1.31 Binary Search: When is searching O(logn) in an array? top gateoverflow.in/14320

Consider the problem of searching an element x in an array arr of size n. When can the problem can be solved in O(logn) time?

1. Array is sorted
2. Array is sorted and rotated by k. k is given to you and k ≤ n.
3. Array is sorted and rotated by k. k is NOT given to you and k ≤ n
4. Array is not sorted


(A) 1 Only
(B) 1 & 2 only
(C) 1, 2 and 3 only
(D) 1, 2, 3 and 4

I am clear with 1 and 2 option but not getting about option 3.


algorithms binary-search

lets analyze the options one by one....

1> Clearly binary search can be implemented if the array is sorted. Hence search can be performed in O(logn).

2>Lets take an example first..

Consider an array with elements 1234567. Now, suppose the array is rotated by 2 then the new array will be 3456712.
Here k is 2. As, k is known to us finding the pivot point is easy it will be just = (n-1)-k ;where n is the size of the array.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 30 of 2244

Here it is 4. Now, to search for an element divide the array in two subarrays . Now compare the number with the 0th
element, if the number is greater than the 0th element then apply binary search in left subarray to pivot else apply binary
search to right subarray...Hence searching can be performed in O(logn).

3>Here k is not known. Hence the pivot point is not known, if we can get the pivot point then we can apply the same
method as above.

Now cosider the above example. The pivot point has the property that the pivot point element is the only element whose
next element is smaller than it in the array.Hence we can find the pivot in O(logn) applying binary search like seaching.
and the rest are same as above Hence the total complexity becomes O(logn)+O(logn)=O(logn).

Hence 1,2 and 3 are correct options

 3 votes -- debanjan sarkar ( 775 points)

1.32 Binary Search: how many searches are required on the average ,if
binary search is employed ? top gateoverflow.in/16124

suppose there are 11 items in sorted order in an array.how many searches are required on the average ,if binary search is
employed and all searches are successful in finding the item?

a) 3.00 b) 3.46 c) 2.81 d) 3.33

binary-search

if binary search tree is constructed, for root element one comparison for level 1, two comparisons and so on. There are 1,
2, 4 and 4 elements at levels 1, 2, 3, 4 respectively. So, avg. no of comparisons = (1*1+ 2*2+4*3+4*4)/11 = 3 as for
level we need comparisons to reach there.

Ans is a.

 1 votes -- Pooja ( 22773 points)

1.33 Binary Search: #doubt on heaps and binary search top gateoverflow.in/31046

Consider the process of inserting an element into a max heap, where the max heap is represented by an array.Suppose we
perform a binary search on the path from the new leaf to the root to find the position for newly inserted element, the
number of comparisons performed is? # i m getting as O(logn) as upon applying binary search we wud compare O(logn)
elements(neighbours and its own root only) plz clr my confusion

algorithms data-structure binary-search

Yes, number of comparisons would be O(log n). But if you apply binary search, then there is no use of heap and actual
insertion is much costlier, comparison O(log n) + O(n)shifting.

If you use heapify procedure you'll get O(log n) in total for insertion.

 1 votes -- Monanshi Jain ( 5827 points)

1.33 Binary Search: Average number of comparisons in a binary search on a


sorted array of 10 consecutive int. starting from 1? top gateoverflow.in/16831

binary-search


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 31 of 2244

Array is [1,2,3,4,5,6,7,8,9,10].

Average number of comparisons depend on how likely each element is to be searched. Suppose each element is equally
likely to be searched i.e. every element has 1/10 prob of being searched.

Now searching 5 takes only 1 comparison (it will be found in first trial only).

Then searching 2 or 8 takes 3 comparisons (1 for equality with 5, which was failed, then 1 for less than or greater than,
then 1 for equality with 2 or 8).

Then searching 1 or 3 or 6 or 9 takes 5 comparisons (again 1 for less than or greater than, and 1 for equality)

Finally, searching 4 or 7 or 10 takes 7 comparisons.

1 +2 ∗ 3 +4 ∗ 5 +3 ∗ 7
10
So average number of comparisons = = 4.8.

 9 votes -- Happy Mittal ( 9253 points)

Its 2.9 on average; the question asked average number of comparisons on binary search; so as per algo first the middle,
then since it is sorted while computing for the middle and equating to it at the same time it is determined which way to go
further left or right;

1 2 3 4 5 6 7 8 9 10
For 5: 1
For 2,8 : on second comaprison, i.e., 2
And similarly
For 1,3,6,9: 3
And for 4,7,10: 4

compute it: (1*1 + 2*2 + 4*3 + 3*4)/2 = 2.9

 1 votes -- micky08 ( 119 points)

1.34 Binary Search: Binary Search - Average Number of Comparisons. gateoverflow.in/29654

top

Let you are given an array of nine elements in increasing order. If you want to implement binary search on the given array of
element then the number of comparisons per successful search on an average will be:

Average is 2.78,

should I answer this question with or without rounding off 2.78, as number of comparisons is an integral value?

binary-search algorithms


Selected Answer

It is to be answered without rounding off, i.e, 2.78 or whatever you calculated being the correct answer.

 1 votes -- micky08 ( 119 points)

1.35 Binary Search Tree: Test Series QS - Algorithms top gateoverflow.in/29992

When searching for the key value 50 in a binary search tree, node containing the key values 10, 30, 40, 70, 90, 120, 150, 175 are traversed, in any order. The number of
different orders passing in which these keys values can occur on the search path from the root to node containing the value 50 are ________.

binary-search-tree algorithms

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 32 of 2244

left side of 50 contains 10,30,40 total 3 elements..

right side of 50 contains 70,90,120,150,175 total 5 elements..

so no of different passing from root to node is = 8!/(3! *5!) = 56.

 0 votes -- Sayantan Ganguly ( 5061 points)

1.36 Binary Tree: What will be the recurrence relation of the given below
program for Preorder traversing technique? top gateoverflow.in/32314

Preorder(root)

Printf("root.data");

Preorder(root.leftsidetree);

Preorder(root.rightside);

binary-tree


Selected Answer

T(n)=2T(n/2)+c

 0 votes -- Pooja ( 22773 points)

.....depends on the no of nodes in left subtree and right subtree.

 1 votes -- Saurav Kumar Gupta ( 1455 points)

1.37 Binary Tree: Answer the following question top gateoverflow.in/5416

In 28 my answer is c but answer given is d.

binary-tree

The first inserted element must become the root and as per question we have p elements on right subtree which means p
elements are larger than the root. So, out of n elements, the root must be n − p.

 1 votes -- Arjun Suresh ( 124125 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 33 of 2244

1.38 Binary Tree: The maximum number of nodes on level i of a binary tree
top gateoverflow.in/36354

Level of a node is distance from root to that node. For example, level of root is 1 and levels of left and right children of root is 2. The maximum
number of nodes on level i of a binary tree is

In the following answers, the operator '^' indicates power

a) 2^i-1
b)2^i
c)2^i+1
d)2^(i+1/2)

binary-tree data-structure


Selected Answer

The answer should be 2^i-1 i.e. option (a).

 2 votes -- Saumik Sarkar ( 157 points)

1.39 Bst: how to construct BST by given preorder and postorder traversal top
gateoverflow.in/29918

Given preorder and postorder traversal of binary search tree.


Preorder: 50, 27, 16, 4, 12, 34, 29, 44, 88, 65, 52, 77, 93, 92
Postorder: 12, 4, 16, 29, 44, 34, 27, 52, 77, 65, 92, 93, 88, 50
The number of nodes present at level 3 are _________. Assume root is present at level 0.

data-structure bst


Selected Answer

Refer this: http://www.geeksforgeeks.org/full-and-complete-binary-tree-from-given-preorder-and-postorder-traversals/

Try this:

Preorder: 50, 27, 16, 4, 12, 34, 29, 44, 88, 65, 52, 77, 93, 92
Postorder: 12, 4, 16, 29, 44, 34, 27, 52, 77, 65, 92, 93, 88, 50

Inorder: 4,12,16,27,29,34,44,50,52,65,77,88,92,93

now from preorder and inorder try to construct a tree.

50 - root

{4,12,16,27,29,34,44} - left subtree of root

{52,65,77,88,92,93} - right subtree of root and do it recursively you contruct a tree.

 0 votes -- Prasanna Ranganathan ( 2045 points)

1.40 Chaining: Hashing top gateoverflow.in/19938

Consider a hash table with n buckets, where external(overflow) chaining is used to resolve collision. The hash function is

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 34 of 2244

1
n
such that the probability that a key value is hashed to a particular bucket is . The hash table is initially empty and k distinct
values are inserted in the table.

Q) What is the probability that bucket number 1 is empty after the kth insertion?

a. n
b. (n − 1)k
c. ((n − 1)/n)k
d. ((n − 1)/k)n

Q). What is the probability that no collision has occurred in any of the k insertions?

a. n(n − 1)(n − 2)(n − k + 1)/nk


b. n(n − 1)(n − 2)(n − k − 1)/nk
c. both (a) and (b)
d. none

hashing chaining probability

Q1) If bucket no 1 is empty after k insertions that means keys must have mapped to remaining n − 1 locations. k insertions
n −1

means k keys mapped. Probability of bucket 1 being empty =


( )
n
k

Q2) no collision in k insertions

Insertion 1: n (key can go to any one of n positions)

n −1

Insertion 2: n (key can go to any one of n − 1 remaining positions).

n −2

insertion 3: n and continuing in same way

n − (k−1 )
n
Insertion k:

so we get

n . (n −1 ) . (n −2 ) … (n −k+1 )
nk
probability of no collision =

ans a

 4 votes -- Pooja ( 22773 points)

Q.1] probability that the hash fun mapping a key to a bucket number 1= 1/n
probability that the hash fun not mapping a key to a bucket number 1= 1-(1/n)
probability that the bucket no. 1 is empty after 2 iteration= First Time Missed And Second Time Missed = (n-
1/n) (n-1/n)
none of these k keys mapped to bucket no. 1 after k Iteration=(n-1/n) (n-1/n) (n-1/n)...k times =
(n-1/n)^k Option C

For K=1, it's 1. For K=2, the second item must miss the bucket of the first item.
So it has n−1 places it can go safely. The probability of success is therefore n−1/n
So the probability for K=3is 1*n−1/n*n−2/n.
similarly for P(k) = 1*n−1/n*n−2/n*n-3/n............n+1-k/n

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 35 of 2244

 1 votes -- Umang Raman ( 10379 points)

1.41 Chaining: Hashing top gateoverflow.in/31123

hashing chaining

Probability will be .2

 0 votes -- Sayantan Ganguly ( 5061 points)

1.42 Chaining: hashing top gateoverflow.in/19062

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 36 of 2244

hashing chaining


Selected Answer

Number of worst case comparisons in linear probing = Size of largest cluster + 1

In this case, we have two clusters of size 3 (abc, efg). Worst case can occur when we are searching for a non-existent
element, that should have mapped to either the location of a:0, or the location of e:6.

So, number of comparisons in worst case for this Hash Table are:

Size of largest cluster + 1 = 3 + 1 = 4

 0 votes -- Pooja ( 22773 points)

1.43 Chaining: What is time complexity of inserting an element in


chaining(outside) hashing technique? top gateoverflow.in/32158

If we are inserting an element in chaining(outside) hashing technique, then what will be the time complexity in best case,
average case and Worst case.

chaining hashing

If we are using chaining technique for collision resolution in hashing, then the minimum chain length will be 1 (not zero,
since then there will be no chain). The maximum chain length will be Ο(n) since we can have all the elements in one slot.
An example of this worst case could be: hash function h(k) = k mod 10 and the elements as 2,12, 22, 32, 42, 52, 62, 72,
82, 92

The average case would be an average of all the intermediate cases, (best case + worst case)/2 i.e., Ο(n).

This is the time complexity for the chaining element access.

 1 votes -- Utk ( 1385 points)

1.44 Cyclomatic Complexity: What is the Cyclomatic Complexity of the


pseudo code ? top gateoverflow.in/18266

while (m
if (x>y) and (a
a= a+1

y=y-1

end if

m=m+1

end while

a. 2

b. 3

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 37 of 2244

c. 4

d. 5

cyclomatic-complexity


Selected Answer

Cyclomatic complexity = no of predicate nodes +1

=3+1

One for while, two for if bcoz of two conditions as if first condition then if second condition then do given.

 0 votes -- Praveen Saini ( 34299 points)

1.45 Dfs: Does a DFS produce same no of tree edges in an undirected graph
? top gateoverflow.in/12485

Does a DFS for an undirected graph always produce the same number of tree edges irrespective of the order in which we
visit the vertices ?

dfs

Yes , it will produced same number of edges in an undirected graph . The minimum edges required to visit all vertices is n-
1 ( for n vertices ) . For a connected graph with n vertices DFS required n-1 edges and it form a tree .

 1 votes -- Pranay Datta ( 6113 points)

1.46 Dfs: Recursive calls in DFS top gateoverflow.in/38965

algorithms ace-test-series dfs recursion

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 38 of 2244


Selected Answer

(b) 6

You can achieve the maximum depth of 6 recursive calls when you have following elements on the stack :

0, 1, 2, 3, 4, 6

(6 being the element on the top and 0 being the element at the bottom.)

Once you reach this state, you have to start popping the elements from the stack.

You can find a similar, but better question here.

 1 votes -- Gaurav Sharma ( 1383 points)

1.47 Dfs: Dfs top gateoverflow.in/33821

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 39 of 2244

Q). Consider the vertices V1 and V2 that are simaltaneously on the function call stack at some point during the execution of
depth -first search from vertex S in a digraph.Which of the following must be true?

I. There exist directed path from s to V1 and directed path from s to V2

II. There exist both a directed path from V1 to V2 and a directed path from V2 toV1 .

III. If there is no directed path from V1 to V2 then there exist a directed path from V2 to V1 .

Which of the above statement is/are true?

dfs

1.48 Dfs: Edge type in Undirected Graphs on Depth First Tree top gateoverflow.in/20525

Assume WHITE vertices that are yet to be discovered, BLACK vertices are finished vertices and GRAY vertices are frontier
betweeen WHITE and BLACK in Depth First Search.

Now, What are the various edge types like TREE-EDGE and BACK-EDGE possible between any pair of vertices during a Depth
First Search in an Undirected graph.

Confused about the edge type between WHITE and GRAY type vertices.

[ CLRS (3rd Edition) : 22-3:1; Page # 610 ]

graph-theory graph-algorithms dfs

An edge (u,v) is said to be TREE-EDGE if either u is ancestor of v or v is ancestor of u.


An edge (u,v) is said to be BACK-EGE if the edge between u and v discovered during the traversal from v to u.

If we can have a TREE-EDGE between any pair of types of vertices in an undirected graph, we can also have BACK-EDGE
in that same pair of types of vertices.

Possible types of edges in undirected graph during DFS at


any stage
WHITE GRAY BLACK
WHITE Tree, Back Tree, Back None
GRAY Tree, Back Tree, Back Tree, Back
BLACK None Tree, Back Tree, Back

 0 votes -- Salman ( 615 points)

1.49 Dfs: Problem on DFS top gateoverflow.in/26573

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 40 of 2244

Answer given: C
Please explain

algorithms dfs


Selected Answer

Explanation on how answer could be option C

v7 is the last node that should be pushed on the stack.

But there is a possibility that there exists some code which does not push the last node on the stack,
for doing such a thing it is required, say, to maintain a counter for number of nodes being pushed to the stack. Its good to
maintain such a counter, this saves us from unnecessary push and checks for visited marked nodes, once nodes except
one are already traversed.

v7 turns out to be the last node.

Hence, answer = option C

 2 votes -- Amar Vashishth ( 17865 points)

Adjacent element of v7 i.e. 6 and 8 already visit by v4 and v6..thats y need nod to push inti stack

 2 votes -- Anirudh Pratap Singh ( 4091 points)

1.50 Dfs: Which of the following statement is correct regarding DFS? gateoverflow.in/5424

top

Which of the following statement is correct regarding DFS? 1) All the vertices are pushed in the stack during DFS Traversal.
2) No vertex is pushed more than once in the stack during traversal.

algorithms graph-algorithms dfs

first one is true but second one is false in case of digaph

 0 votes -- admin ( 1411 points)

1.51 Dijkstras Algorithm: Dijkstra’s algorithm top gateoverflow.in/36486

Assume priority queue in Dijkstra’s algorithm is implemented using a sorted link list and graph G (V, E) is represented using
adjacency matrix. What is the time complexity of Dijkstra’s algorithm (Assume graph is connected)?

How to solve this kinds of problems ? Changing DS used in one algorithm . Do I need to study the entire algorithm ?

algorithms dijkstras-algorithm


Selected Answer

Dijkstra algorithim uses 3 basic operations->

1.Build heap->O(V)

2.extract min->O(log V)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 41 of 2244

3.Relax operation-:decrease key-->>O(logV)

extract min will be on maximum as the number of vertices(O(V logV) and relax operation will be in Worst case on the
number of edges(O(E logV)..

so tightest upper bound=O(ElogV)

now if we use sorted list-->operations are->

extract min(O(1))

decrease key-O(V)

now from above concept extract min will be on V vertices i.e O(V^2) and decrease key on maximum E edges O(EV)

so tightest upper bound =O(VE)

in worst case E=V^2..

so time complexity=O(V^2*V)=O(V^3)

 3 votes -- sourav anand ( 1585 points)

1.52 Dijkstras Algorithm: Dijkstra single source path top gateoverflow.in/37253

Answer is given as (B). But, shouldn't it relax point 'c' via 'a' .. So, i guess answer should be D. Is it?

graph-algorithms dijkstras-algorithm ace-test-series

1.53 Dynamic Programming: common data Linked quetion :- 1) which of the


following is correct recurrence formula of I(j) 2)how to evaluate this R.R top
gateoverflow.in/9345

At the end of it's 5 th Successful season,The siruseri Permier league is planning to give an award to most improved bowler
over 5 years . For this an important Index will be computed for each bowler,This is defined as the longest Subsequence of
strictly decreasing economy rate's by the bowler among all his matches over 5 season's.For example seasons are
(10.0,5.0,8.9,6.7,4.2,5.5,2.2,3.4,6.0,2.3,2.0) so his improvement index is 7 based on sequence (10.0 ,8.9, 6.7, 5.5, 3.4,
2.3, 2.0)

Now let E[1...........N] Donates a sequence of n economy rates for which improvement index is to be calculated
for 1 ≤ j ≤ n,Let I[j] denotes the improved index for the prefix of score E[1.......j ] ending at E[j]

1. Which of the following is correct recursive formulation of I(j) ?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 42 of 2244

a) I(1)=1
for j ∈ 2,3,......,n I(j) = 1+ max {I(k)/ 1 ≤ K<j, E[k] > E[j]}

b) I(1)=1
for j ∈ 2,3,......,n I(j) = 1+E(j-1) if E(j-1)<E(j)
1 otherwise

C) I(1)=1
for j ∈ 2,3,......,n I(j) = 1+ max {I(k)/ 1 ≤ K<j, E[k] < E[j]}

d)I(1)=1
for j ∈ 2,3,......,n I(j) = 1+E(j-1) if E(j-1) > E(j)
1 otherwise
2. How to evaluate this Recursive definition Using Dynamic programming?
a) A 2-D table T of Size N X N to be filled row wise from T[1][1] to T[n][n]

b) A 1-D table T of Size N to be filled from T[n] to T[1]

C) A 2-D table T of Size N X N to be filled row wise from T[n][n] to T[1][1]

d) A 1-D table T of Size N to be filled from T[n] to T[1]


3. What is the Time complexity in Dynamic programming ?
a) O(n)
b) O(nLog n)
c) O(n 2)
d) O(n3)

algorithms dynamic-programming recurrence


Selected Answer

1. Answer is a. Reading the problem statement 4-5 times gives this :)

The current considered element must be smaller than ALL previous entries. So, b, c, and d are false.

2. 1-D table filled from T[1] to T[n]

3. O(n)

 2 votes -- Arjun Suresh ( 124125 points)

1.54 Gcd: GCD top gateoverflow.in/40362

Let (x ′, y ′) correspond to gcd(b, a mod b), i.e. gcd(b, a mod b) = x ′ ·b + y ′ · (a mod b). Then show that gcd(a, b) = y ′ · a + (x ′ − q)b where q is the quotient of the integer
division of a by b.

Can anyone help me with this?


gcd algorithms easy

1.55 Geek Mock 2016: GEEK_MOCK_QUETION_14 top gateoverflow.in/37892

QUESTION 14 : Consider the below Pseudo code written in C style


bool fun(int arr[], int n, int X) {
if (X == 0)
return true;
if (n == 0 && X != 0)
return false;
if (arr[n–1]*arr[n–1] > X)
return fun(arr, n–1, X);
// Here "|| "indicates logical or
return fun(arr, n–1, X) || fun(arr, n–1, X – arrr[n–1]*arr[n–1]);
}

Which of the following is true about above code.


A) Time Complexity of fun() is O(2n) and it requires O(n) extra space

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 43 of 2244

B) Time Complexity of fun() is O(2n) and it requires O(n2) extra space


C) Time Complexity of fun() is O(n2) and it requires O(n) extra space
D) Time Complexity of fun() is O(n2) and it requires O(n2) extra space
Correct – A

How to calculate space complexity?

space-complexity time-complexity geek-mock-2016


Selected Answer

See how many function calls are active in the stack. Here, function 'fun(n)' can give a call to fun(n-1), which inturn will
call fun(n-2) and so on.. till n=0.

When n becomes 0, fun will start returning, ie, it starts popping out of the stack. So, at max, there are n to 0, functions in
the stack. Hence space complexity is O(n).

 3 votes -- Tehreem Ansari ( 1327 points)

1.56 Generating Functions: Below is the question that was asked in GATE
1987, can you give the answer with explanation for the same? top gateoverflow.in/33228

What is the generating function G(z) for the sequence of Fibonacci numbers?

generating-functions

Fibonacci series : 1,1,2,3,5,8,13..........

Its generating function is :

1*z0 + 1*z 1 +2*z2 +3*z3 +5*z4+-----------∞ = G(z)

Above series can be rewritten as :

1 + (z +z 2) + (z+z2)2 +....................∞ = G(z)

1/(1 - (z+z 2) = G(z)

Hence generating function G(z) = 1/(1- z -z 2)

 2 votes -- Shashank Kumar ( 2029 points)

1.57 Graph Algorithms: Articulation points top gateoverflow.in/1874

What will be the time complexity of an efficient algorithm which will calculate the no of articulation points?

algorithms graph-algorithms


Selected Answer

O(V + E) as we can do this using DFS.

http://www.eecs.wsu.edu/~holder/courses/CptS223/spr08/slides/graphapps.pdf

 1 votes -- Arjun Suresh ( 124125 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 44 of 2244

1.58 Graph Algorithms: What is the exact difference between prim's


minimum spanning tree algorithm and dijkstra's single source shortest path
algorithm? top gateoverflow.in/12392

I mean if we run prim's algorithm on a weighted directed graph, will it give the same shortest path? And vice-versa?

Also if we run dijkstra's algorithm on a graph with negative weight cycle reachable from source, what will happen?

What if we run kruskal's MST algorithm on a graph with negative weights and negative weight cycles?

Thanks in advance.

graph-algorithms


Selected Answer

1.from prims algo. - we will get MST

from dijsktra algo - we will get shortest path from source(i.e single source) to destination.

2. if we run dijsktra on graph with negative weight edges then dijsktra algo is going to compute the shortest path but it
may or may not be correct .since it is not a sin to run dijsktra algo with graph having negative weight edges .And becoz of
this demerit of dijsktra algo. we switch to bellman ford algo.

since practically it is not possible to have negative wieght edges (for ex -travelling salesman problem ) therefore dijskta
algo is more practically used as compared to bellman ford algo.

3. kruskal algo is also an algo so u can run it with graph containing negative weight edges and negative weight cycles
since the output will be an tree(without cycles) not an graph.

 1 votes -- shabi ( 317 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 45 of 2244

Please refer to this.I hope your doubt will get clear:http://cs.stackexchange.com/questions/18797/minimum-spanning-


tree-vs-shortest-path

 1 votes -- Rohan Ghosh ( 1515 points)

1.59 Graph Algorithms: Single source shortest path problem top gateoverflow.in/26906

graph-algorithms

min heap is used always for speedup

 4 votes -- Manojk ( 3365 points)

1.60 Graph Algorithms: Complexity of Union Find Algorithm top gateoverflow.in/41042

I am referring http://www.geeksforgeeks.org/union-find/
I am getting worst case complexity as O(V2), whereas on geeksforgeeks it is given O(ElogV).
My Approach:-
Consider a graph 1---->2----->3----->4------>5------>6------>7------->.......V
1+2+3+.....V = O(V 2).

Kindly explain with proper explanation

algorithms time-complexity graph-algorithms

1.61 Graph Algorithms: single source shortest path algorithm top gateoverflow.in/11994

When can we have single source shortest path algorihm runs in Big Oh of number of edges.

Options are like weighted graph, undirected graph, undirected and weighted, not possilbe (i dont remember all the options)

graph-algorithms

Ya it can be done when the graph is unweighted using BFS.

http://cseweb.ucsd.edu/~kube/cls/100/Lectures/lec12/lec12-28.html

 0 votes -- sonu ( 1267 points)

1.62 Greedy Algorithm: In Optimal merge pattern when do we get more than
one tree? top gateoverflow.in/31011

In Optimal merge pattern when do we get more than one tree(Sub trees) when creating a merge pattern?
Can you explain/draw optimal merge tree for n=7, <8,15,3,10,20,2,30>

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 46 of 2244

algorithms greedy-algorithm


Selected Answer

Caption

 1 votes -- Sandip Shaw ( 755 points)

1.63 Greedy Algorithm: Optimal solution with greedy algorithm top gateoverflow.in/36539

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 47 of 2244

Q: There are n white dots and n black dots, equally spaced in a line. We want to each white dot with some black dot in on-
to-one fashion with a minimum total length of the wire. (See diagram above). Greedy algo. gives optimal solution for..

A) Only i

B) Only ii

C) Both

D) None

How to approach to such type of questions ?

algorithms greedy-algorithm made-easy

1.64 Greedy Algorithm: AlGO: Madeeasy:TS Greedy Method How to approach


top gateoverflow.in/38415

There are n white dots and n black dots. Equally spaced in a line. You want to connect each white dot with some block dot in one to one fashion with a minimum total
length of wire.
Consider 2 examples:


Greedy algorithm gives optimal solution for

a. Only (i )

b. Only (ii)

c. Both (i) and (ii)

d. None of these

algorithms greedy-algorithm made-easy_test-series

1.65 Hashing: Hashing top gateoverflow.in/4644

Consider the following, five binary strings of length 8.

01010010, 11011011, 10011010, 11111011, 01110010

A hash table of size M = 8 (0 to 7) is using open addressing for hashing the binary strings. Assume finding an empty slot
directly without collision or after collision is also a probe. Calculate the total number of probes that occur while hashing five
strings using linear probing.

hashing

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 48 of 2244


Selected Answer

In linear probing if the hashed location is not empty, a linear probe is done to find an empty slot.

Assuming mod 8 function for hashing

01010010 mod 8 = 010 = 2 (1 probe, goes to slot 2)

11011011 mod 8 = 011 = 3 (1 probe, goes to slot 3)

10011010 mod 8 = 010 = 2 (3 probes, goes to slot 4, unsuccessful probes at slots 2 and 3)

11111011 mod 8 = 011 = 3 (3 probes, goes to slot 5, unsuccessful probes at slots 3 and 4)

01110010 mod 8 = 010 = 2 (5 probes, goes to slot 6, unsuccessful probes at slots 2, 3, 4, and 5)

So, total number of probes = 13

http://webdocs.cs.ualberta.ca/~holte/T26/open-addr.html

 2 votes -- Arjun Suresh ( 124125 points)

1.66 Hashing: Consider a hash table with ‘m’ slots that uses chaining for
collision resolution. top gateoverflow.in/13601

Consider a hash table with m slots that uses chaining for collision resolution. The table is initially empty. What is the
probability that after 4 keys are inserted that at least a chain of size 3 is created? (Assume simple uniform hashing is used)

A. m – 2
B. m – 4
C. m – 3 (m– 1)
D. 3m – 1

data-structure hashing


Selected Answer

We have two cases which are mutually exclusive

1. A chain of length exactly 3


2. A chain of length 4

Our required probability will be the sum of these 2 cases.

1 1 1 m−1 m−1
3
Probability of length exactly 3 = No. of ways of selecting a slot × Probability of exactly 3 hashing going to that slot = mC1 × 4C1 × m m m m = 4 m

1 1 1 1 1
3
Probability of length 4 = No. of ways of selecting a slot × Probability of 4 hashing going to that slot = mC1 × m m m m = m

m−1 1 4.m−3
m3 m3 m3
So, our required probability = 4. + = .

 7 votes -- Arjun Suresh ( 124125 points)

Consider any one slot among N slots.The probability that three elements will be entered in same slot is 1/m*1/m*1/m =
m^-3.As there are m slot you can choose any slot among m slot.So answer is m*m^-3 = m^-2

 4 votes -- pratikb ( 323 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 49 of 2244

Chain of three means , all 4 elements are hashed into single slot ,

So , is it (1/m)^4 ?

 1 votes -- Shounak Kundu ( 3757 points)

1.67 Hashing: Hash table top gateoverflow.in/27427

A Hash table has space for 100 records. Then the probability of collision before the table is 10% full is?

A 0.45
B 0.5
C 0.3
D 0.34 (approximately)

hashing probability


Selected Answer

Table has 100 slots. So, for 10% filling it must take 10 slots. Now, the question is like this- collision before 10% full. This
should mean the first collision happened before the 10th entry is made. So, the first collision can happen from 2nd entry
(for 1st entry there won't be a collision) to 10th entry. So required probability

100.1 100.99.2 100.99.98.3 100.99.98…92.9


2
100 3 100 4 100 10
= 100 + + +…+ ≈ 0.35

 5 votes -- Arjun Suresh ( 124125 points)

1.68 Hashing: Hashing top gateoverflow.in/4916

Consider a hash table using uniform hashing with number of slots as m = 6 and number of keys, k = 8. Collisions are resolved
by chaining. Assuming direct hashing is used, what is the expected number of slots that ends not being empty?

algorithms hashing difficult


Selected Answer

We want to find expected no. of slots not being empty which

= ∑6i =1 1 × P(Sloti is not empty).

P(Sloti is not empty) = 1 − P(Sloti is empty)

(6 −1 )8 58

So, our required expectation = ∑6i =1 1 × (1 − P(Sloti is empty)) = ∑6i =1 1


(
× 1− 68
) ( )
=6× 1− 6
8
= 4.604.

Alternative way

Expected number of non-empty slots


= 1. P(1) + 2. P(2) + … + 6. P(6), where P(i) is the probability that exactly i number of slots are non-empty.

Since, collisions are resolved by chaining, if 8 keys go to the same slot, 5 other slots will be empty.

Now, number of favourable cases for P(i) is equal to the number of ways in which we can place 8 distinct balls into i
distinct bins such that no bin is empty. This is given by i!. S(8, i) where S is the Stirling's number of second kind.

We have S(1, 1) = 1, S(n, r) = S(n − 1, r − 1) + r × S(n − 1, r)


So, using this we can get the triangle of Stirling's numbers

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 50 of 2244

1
1 1
1 3 1
1 7 6 1
1 15 25 10 1
1 31 90 65 15 1
1 63 301 350 140 21 1
1 127 966 1701 1050 266 28 1

So, if F(i) denote the no. of favourable cases for P(i)

F(1) = 6 C1 . 1. 1! = 6

F(2) = 6 C2 . 127. 2! = 3810

F(3) = 6 C3 . 966. 3! = 115920

F(4) = 6 C4 . 1701. 4! = 612360

F(5) = 6 C5 . 1050. 5! = 756000

F(6) = 6 C6 . 266. 6! = 191520

So, our expected number


1 ×6 +2 ×3810+3 ×115920+4 ×612360+5 ×756000+6 ×191520
68
=

= 4.604

 3 votes -- Arjun Suresh ( 124125 points)

Slot =6, keys =8

So Prob. of hashing to a particular slot = 1/m

Prob. of not hashing to a particular slot = (m-1)/m

Prob that particular slot ends up being empty = [(m-1)/m] k

Prob that particular slot is not being empty =1- [(m-1)/m] k

the prob. is same for all slot & hence expected no. will be same for all slots = m[1-[(m-1)/m] k ]

& m=6, & k=8 is given....So put the values you will get = 4.604

 2 votes -- amansaini ( 31 points)

1.68 Hashing: What is perfect hashing technique? top gateoverflow.in/32313

hashing

no of collision in perfect hashing = 0(zero)

 1 votes -- Saurav Kumar Gupta ( 1455 points)

1.69 Heap: "Max Heapify" algorithm top gateoverflow.in/32950

Consider the following "Max Heapify" algorithm. Array has atleast n and 1<=i<=n. After applying the Max-heapify rooted at

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 51 of 2244

A[i], the result will be subtree of A[1,....n] rooted at A[i] is max heap. [Assume that except root A[i], all its children satisfied
heap property]

Max-heapify(int A[], int n, int i)

int p,m;

p=i;

while(X)

if(Y&&Z)

m=2p+1;

else m=2p;

if(A[p]<A[m])

Swap(A[p],A[m]);

p=m;

else

return;;

Find missing statements at X, Y and Z respectively to apply the heapify for subtree rooted at A[i].

a) p<=n, (2p+1)>=n, A[2p+1]>A[2p]

b) 2p<=n, (2p+1)<=n, A[2p+1]>A[2p]

c) 2p<=n, (2p+1)>=n, A[2p+1]<A[2p]

d) p<=n, (2p+1)<=n, A[2p+1]<A[2p]

heap

should be b

 0 votes -- Pooja ( 22773 points)

1.70 Heap Sort: Heap Sort best case top gateoverflow.in/36854

What is the Best Case run time of Heap Sort ?

A. O(1)

B. O(n)

C. O(nlogn)

D. O(logn)

algorithms sorting heap heap-sort


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 52 of 2244

option C. Best, average and worst case time complexity of heap sort is O(nlogn).

 2 votes -- Arjun Suresh ( 124125 points)

1.70 Heap Sort: The recurrence relation for MAX-HEAPIFY function of


heapsort algorithm is T(n) <= T(2n/3) + O(1). How is it 2n/3 ? top gateoverflow.in/43251

algorithms time-complexity recurrence heap-sort heap

In a tree where each node has exactly either 0 or 2 children, the number of nodes with 0 children is one more than the number of nodes with 2
children.

ROOT
L R
/ \ / \
/ \ / \
----- -----

Let k be the number of nodes in R. The number of nodes in L is k + (k + 1) = 2k + 1. The total number of nodes is n = 1 + (2k + 1) + k = 3k + 2 (root
plus L plus R). The ratio is (2k + 1)/(3k + 2), which is bounded above by 2/3. No constant less than 2/3 works, because the limit as k goes to infinity is
2/3.

 0 votes -- Nishant Arora ( 213 points)

1.71 Heap Sort: K sorted list,n/k elements what is time complexity?please


specifiy ur ans in detail top gateoverflow.in/42856

K sorted lists of n/k elements each. What is time complexity to sort them?please specifiy ur ans in detail

heap-sort


Selected Answer

k sorted lists, total n elements.


Construct a min heap by taking the first element from all the arrays.
Extract the min element and print. Take the next element from the array in which the min element was present (the heap
entry should store the origin array information), and insert to min heap. Continue till min heap becomes empty.

Time Complexity = O(k) {min heap construction} +O(nlogk) {n time extract min from heap} = O(nlogk).

 5 votes -- Digvijay Pandey ( 26245 points)

1.72 Huffman Code: Huffman top gateoverflow.in/35961

huffman-code algorithms


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 53 of 2244

Length of M1 = 1 Frequency of M1 = 0.51


Length of M2 = 2 Frequency of M2 = 0.25
Length of M3 = 3 Frequency of M3 = 0.13
Length of M4 = 3 Frequency of M4 = 0.11

Expected length = ∑ Li*Fi


= 1*0.51 + 2*0.25 + 3*0.13 + 3*0.11
= 1.73

 1 votes -- Digvijay Pandey ( 26245 points)

1.73 Huffman Code: huffman code query top gateoverflow.in/39223

Alice needs to send a large message to Bob using only five words. Seeing that the message is too long she decides to
compress the message using Huffman coding algorithm.

If the respective frequencies of words are given in the table, what would be the hamming code for w 3 w1 w2 that she was
supposed to use?

a 100011011

b 100011101

c 100001101

d 111011000

huffman-code algorithms made-easy_test-series

option b) w3=1000 w1=11 w2=101.

Hint : try with the two smallest frequency and then iterate for the next two and go on. now to the left branch assign 0 and
right branch assign 1.

 0 votes -- Ritaban Basu ( 255 points)

1.74 Huffman Code: Average code length using Huffman coding top gateoverflow.in/34187

A file contains characters a,e,i,o,u,s and t with frequencies 10,15,12,3,4,13 and 1 respectively. If we use Huffman Coding for
data compression then the average code length will be -

a) 140/58

b) 146/58

c) 150/58

d) 174/58

huffman-code

B is right option

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 54 of 2244

 1 votes -- Jaikishan Apurva ( 787 points)

1.75 Inversions: Number of Inversions top gateoverflow.in/31125

A) 192

B) 120

c) 188

D) 176

algorithms inversions insertion-sort


Selected Answer

Maximum inversion occurs when an array is in reverse order.

So,max no of inversion in an array is

(n-1)+(n-2)+.........+1=n*(n-1)/2

Here n=16

So, max no of inversion is 120.

Now minimum no of inversion occurs when array is in sorted

Then minimum no of inversion in array is 0.

The difference is 120

 3 votes -- Sayantan Ganguly ( 5061 points)

1.76 Knapsack: Algorithm: Difference fractional Knapsack and 0/1 knapsack


top gateoverflow.in/34766

The difference between maximum possible profit for 0/1 Knapsack and fractional Knapsack problem with capacity (W) = 20.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 55 of 2244


Solution Given:


I know how to do both the greedy and Dynamic programming. But i know only tabulation method,the solution above given shows some easy way to do it. don't know what
shortcuts they used above. please suggest is there any easy way to other than tabulation method ?

algorithms knapsack

1.77 Loop: How many number of times '0' is printed ? top gateoverflow.in/36512

loop algorithms testbook


Selected Answer

FIRST LOOP:intializes i=1 SECOND LOOP:intializes i=1; THIRD LOOP intializes i=1 and run till i=n^6 .. and when i checks
for second iteration for 1st loop get.. condition failed ..and loops out ... THATS WHY ONLY n^6 times it get printed.

 1 votes -- Deepesh Kataria ( 1207 points)

1.78 Loop Invariants: loop invariant question top gateoverflow.in/4551

reversing the digits in a given integer to obtain a new integer letn=D1D2-------Dm

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 56 of 2244

int n,rev;
rev=0;
while(n>0)
{
rev=rev*10+n%10;
n=n/10;
}

the loop invariant condition at the end of the i th iteration is

(A) n=D1,D2,-------Dm-i and rev=DmDm-1-----Dm-i+1

(B)n=Dm-i+1----Dm-1Dm and rev=Dm-1----D2D1

(C)n!=rev

(D)n1=D1D2-----Dm and rev=DmDm-1---D2D1

algorithms loop-invariants

Loop invariant must hold at the end of the iteration. In the given code, the least significant digit is taken from n and
added to rev. So, at the end of ith iteration, n will have its least significant bits removed and they will be seen in rev. So,
answer is (A).

 1 votes -- Arjun Suresh ( 124125 points)

1.79 Madeeasy: Consider the following recurrence top gateoverflow.in/36889

T(n) = 2T( 2 ) + nlogn for n>=2 and T(1)=0, then T(n) is

(a.) O(n)

(b.) O(nlogn)

(c.) O(n(logn)2 )

(d.) O(n2 )

Answer given is (c.) The solution is done using subsitution, n = 2k

But if we do with Master's theorem, then we will get option (b.) and this a case for Master's theorem, right?

recurrence made-easy madeeasy made-easy_test-series


Selected Answer

This is not the case for master theorem because after applying master theorem the 2 expr are not polynomial time to
each other so....by using substitution ans is C.

T(n)=2T(n/2)+nlogn

=2(2T(n/2^2)+n/2logn/2)+nlogn

-------------------------upto kth terms....

2^kT(n/2^k)+nlog n/2^k-1 +..........

by using logrithim properties.....simplified.

n+n(1+2+3+4+5..........+log n)

=O(n (log n)^2)

 1 votes -- Kamalkant Patel ( 145 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 57 of 2244

1.80 Madeeasy: Algorithm to find the maximum sum of contiguous


subsequence of a given array of n numbers top gateoverflow.in/35117

Given an array of n numbers, give an algorithm for finding a contiguous subsequence A(i) ...A(j) for which the sum of
elements is maximum.

Eg. [-2, 11, -4, 13, -5, 2] → 20

If dynamic programming approach is used then what is time complexity and space complexity?

(a.) O(n 3), O(1)

(b.) O(n), O(n)

(c.) O(n3), O(n)

(d.) O(n2), O(1)

Given answer is option (b.)

made-easy madeeasy algorithms normal

1.81 Madeeasy Testseries: Asymptotic Analysis formula top gateoverflow.in/39004

Let f(n) = Ω(n) and g(n) = O(f(n)). Then g(n) = _______ [Assume n>0 ]

(a.) Ω(n)

(b.) O(n)

(c.) θ(n)

(d.) Ω(1)

According to me, the answer should be (b.) since, f(n) has lowest bound n and g(n) has f(n) as upper bound. Answer given
is (d.)

I am confused about the answer.

asymptotic-notations algorithms made-easy made-easy_test-series madeeasy madeeasy-testseries


Selected Answer

Ans is omega(constant) because f(n)>=c.n and g(n)<=c1.n and g(n)=O(f(n)) .Take a scenario where g(n) s a constant
value so it is loosely bounded by Bigoh of f(n) then g(n)= omega(1) stands ..

take another scenario where g(n)=n+1 and f(n) be n+1/n^2/n^3 ,still omega(1) holds. since we cannot be sure of the
upper limit of f(n) so g(n) cannot be O(n).

 1 votes -- Ritaban Basu ( 255 points)

1.82 Master Method: How to Solve Questions based on varients of Master


Method top gateoverflow.in/31689

T(n) = a 1 T(n/b) + a 2 T(n/b)

eg T(n) = T(n/4) + T(3n/4) + n

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 58 of 2244

algorithms master-method master-theorem

1.83 Master Method: Recurrence: How to approach top gateoverflow.in/28204

Solve Recurrence

A) T(n) = T( √ n) + Θ(lg lg n)

B) T(n) = T(n/2 + √ n) + √ 6046

C) T(n) = T(n − 2) + lg n

D) T(n) = √ n T( √ n) + 100n

master-method algorithms recurrence

1.84 Master Theorem: Master theorem details? top gateoverflow.in/26821

There are different versions of master theorem available. I want to know whether the version given in Cormen book is
sufficient for GATE?

algorithms master-theorem


Selected Answer

IITs prefer this method... Go for it...

http://www.iitg.ernet.in/psm/indexing_ma353/y09/LectureNoteMA515Aug7.pdf

 1 votes -- abby murali ( 431 points)

1.85 Master Theorem: Algorithms: Master Method Testbook top gateoverflow.in/36579

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 59 of 2244

algorithms master-theorem

1.86 Master Theorem: Recurrence, master theorem not applicable top gateoverflow.in/41232

T(n) = T(2n/3) + 1

Find the order of algorithm?

recurrence master-theorem

2n

T(n) = T
( )3
+1

So, at level n of the algorithm we are recursively calling the problem for 2n/3 and the cost specific to a level is 1. So, we
just need to count the number of levels (recursive calls) and that will be the total cost.
2n 4n

T(n) = T
( )3
+1=T
( )
9
+ 2 = … = T(1) + k.

(We need not reach T(1), but the smallest value possible for a given n where recursion ends. But using T(1) is fine for
asymptotic analysis).

2 2 2 3
k 3
Here, k is such that 3 n ≤ 1  klg 3 + lgn ≤ 0  − klg 3 ≥ lgn  klg 2 ≥ lgn  k ≥ lg 2 n.

So, T(n) = Θ(lgn) assuming T(n) = c, for n ≤ 1.

Alternatively we can use Extended Master theorem (easier for this question though previous method is needed for some
questions).

Here, case is 2.a as a = 1, b = 2 , k = 0, p = 0.

So, T(n) = Θ(logn).

 2 votes -- Arjun Suresh ( 124125 points)

1.87 Master Theorem: Time complexity top gateoverflow.in/31017

How to apply Master's Theorem


n

(i) T(n) = T( 2 ) + 2n

(ii) T(n) = 2n T( 2 ) + nn

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 60 of 2244

master-theorem

T(n) = T(n/2)+2 n

Applying Master theorem n log 21 =n0=1

f(n)=2 n

Here 2n >1

So, T(n)= O(2 n)

T(n)=2n.T(n/2)+nn

Applying Master theorem n log 2^n =nn

f(n)=n n

So, T(n)=O(nn log n)

 1 votes -- srestha ( 11585 points)

1.88 Master Theorem: Solve recurrence using Master theorem top gateoverflow.in/42285

T(a) = 0 if a = 1

T(a) = 2T(a/2) + ak if a = 2p , p > 0

where a = k

Answer: Θ(nlog( k )), This is while (n/k) is power of 2.

How can I solve it using master theorem?

master-theorem algorithms time-complexity


Selected Answer

Forget all the complex part and just focus on the given recurrence relation.

T(a) = 0 if a = 1

T(a) = 2T(a/2) + ak if a = 2p , p > 0

Since we are applying Master's theorem and in the above recurrence relation independent variable is 'a' (not 'n') we
calculate alog b (c) = alog 2 (2 ) = a

Note here that we are comparing the above recurrence relation to the following generalized recurrence relation.

T(a) = cT(a/b) + f(n)

Now from Rule 3. of Master Theorem T(a) = θ(aloga)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 61 of 2244

At last substitute the value of a to get T(a) = T(n/k) = θ nlog k


( ( ))
 0 votes -- Prateek Dwivedi ( 845 points)

1.89 Master Theorem: find order of this algorithm? top gateoverflow.in/41224

T(n) = T(n/2) + n1 / 2 .

recurrence master-theorem


Selected Answer

According to Extended Masters Theorem,

T(n) = aT(n/b) + nklogp n, a ≥ 1, b > 1, k ≥ 0 and p can be a real number

1. if a > bk
T(n) = Θ nlogb a ( )
2. if a = bk

( )
a. if p > − 1, T(n) = Θ nlogb a logp +1 n

b. if p = − 1, T(n) = Θ (n loglogn ) log b a

c. if p < − 1, T(n) = Θ (n ) log b a

3. if a < bk

(
a. if p ≥ 0, T(n) = Θ nklogp n )
b. if p < 0, T(n) = O (n ) k

in the given question, a = 1, b = 2, k = 1/2 and p = 0

here a < bk and p = 0 (case 3(a))

so T(n) = Θ nklogp n ( )
T(n) = Θ n1 / 2 ( )

Alternatively we can apply Master theorem as given in Cormen,

T(n) = aT(n/b) + f(n)

Here, a = 1, b = 2, f(n) = n1 / 2 , f(n) = Ω nlogb a +ϵ ( )n 1/2


( )
= Ω nlog2 1 +ϵ , is true for any ϵ < 2 , and thus we have some positive ϵ. So,
Case 3 of Master theorem. But Case 3 also requires regularity condition which states,

af
()
b
≤ cf(n)

for some c < 1.

Here, we get

n n n1 / 2

af
() ()
b
=f 2
=
√2
≤ cf(n),

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 62 of 2244

1
√2
for any c ≤ .

( )
So, regularity condition also satisfied and we get T(n) = Θ(f(n)) = Θ n1 / 2 .

 2 votes -- vamsi2376 ( 1185 points)

1.90 Master Theorem: substitution or Master Method top gateoverflow.in/28168

What to use for this Master or Substitution Method ?

T(1) = 1, and for all n ≥ 2 a power of 2, T(n)=2T(n/2) + 6n − 1.

If it is possible in Master Method how ?

Even,Substitution is also accecpted here.

Edit: In substitution Method

Suppose T(1) = 1, and for all n ≥ 2 a power of 2, T(n)=2T(n/2) + 6n − 1.

If n is large enough, then by repeated substitution,

T(n)=2T(n/2) + 6n − 1 (after one substitution)

= 2(2T(n/4) + 6n/2 − 1) + 6n − 1

= 4T(n/4) + (6n − 2) + (6n − 1) (after two substitutions)

= 4(2T(n/8) + 6n/4 − 1) + (6n − 2) + (6n − 1)

= 8T(n/8) + (6n − 4) + (6n − 2) + (6n − 1) (after three substitutions).

Therefore, after i substitutions,

T(n) = 2iT(n/2i) + 6in − ∑ij −1


=0 2
j
( )
This can be verified easily by induction. Hence, taking i = log n,

T(n) = nT(1) + 6nlogn − ∑logn


j =0
−1 j
2 ( )

= n + 6n log n − (2log n − 1)

= 6n log n + 1.

algorithms recurrence master-theorem

given Recurrence satisfy aT(n/b) + f(n) where a>=1, b>1, f(n) is polynomial of 'n'.

here a=2, b=2, f(n) = 6n-1 (Linear function in 'n')


Apply masters answer is Θ(nlogn).
https://en.wikipedia.org/wiki/Master_theorem

 1 votes -- Digvijay Pandey ( 26245 points)

1.91 Merge Sort: Merge sort state after 2 recursive calls top gateoverflow.in/38604

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 63 of 2244

I don't find any option to be correct: Argument (a check for option B): For a straight merge sort, it is not possible to sort
directly 2 halves. In a two way merge sort. say if items are greater than 8, then in just two calls, it is not possible to sort
two halves.

Answer is given as B. Any suggestions?

algorithms merge-sort ace-test-series

1.92 Merging: time complexity top gateoverflow.in/39212

time complexity for merging m sorted lists, each with n/m elements

time-complexity merging sorted lists

o(nlog(n/m))

 3 votes -- Nachiket Karambelkar ( 61 points)

1.93 Minimum Spanning Trees: Do Prim’s and Kruskal’s algorithms still work
if the edge weights are allowed to be negative? top gateoverflow.in/19537

shortest-path graph-algorithms minimum-spanning-trees


Selected Answer

The concept of MST allows weights of an arbitrary sign. The two most popular algorithms for finding MST (Kruskal's and
Prim's) work fine with negative edges.

Actually, you can just add a big positive constant to all the edges of your graph, making all the edges positive. The MST
(as a subset of edges) will remain the same.-ref:http://stackoverflow.com/questions/10414043/is-minimum-spanning-
tree-afraid-of-negative-weights

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 64 of 2244

 3 votes -- Rohan Ghosh ( 1515 points)

1.94 Mst: Minimum Spanning tree top gateoverflow.in/41428

An undirected graph G has n nodes. Its adjacency matrix is given by an n × n square matrix whose (i)
diagonal elements are 0‘s and (ii) non-diagonal elements are 1‘s. which one of the following is TRUE?

1) Graph G has multiple spanning trees of different costs

2) Graph G has multiple distinct MSTs, each of cost n-1


3) Graph G has a unique MST of cost n-1
4) Graph G has no minimum spanning tree (MST)

barc2016 algorithms mst easy


Selected Answer

I think the answer is Option 2 as the weight are not unique....

 2 votes -- saif ahmed ( 931 points)

1.94 P Np Npc Nph: the traveling salesman problem can be solved in


polynomial time using backtracking. is this true or false? top gateoverflow.in/13100

algorithms p-np-npc-nph

As per i know travelling salesman problem is a Np hard not p . if the traveling salesman problem can be solved in
polynomial time using backtracking then it will become a P . So its false , it cant be solved in polynomial time by
deterministic way .

 3 votes -- Pranay Datta ( 6113 points)

1.95 Placement Questions: How to manipulate the given linked list in the
following manner in O(n) time ? top gateoverflow.in/42252

If we are given a linked list then we have to manipulate such that even indexed node are arranged together and odd
indexed nodes are arranged together after even indexed nodes

for instance the given linked list is 1-->2-->3-->4-->5-->6 , so the op should be

2-->4-->6-->1-->3-->5

linked-lists placement-questions descriptive

Firstly we place a pointer at middle element of the link list.This can be done in n/2 or O(n) by

initially keeping two pointers pointing to start node.Incrementing one ptr by 1(let say p=p->next) and other
by 2(let say q=q->next->next) till (q!=null && q->next!=null&& q->next->next!=null).When this loop
terminates ptr p will be at middle of link list(LL).

This middle node will be even numbered node if there are even no. of node in LL.Now we need to increment
p by 1 and need a new ptr (let say odd) which points to starting node.After this we just need to swap the
data (of node to which ptrs are pointing ) and increment both ptrs( odd and p) by 2 .

If no. of nodes in LL are odd then the (extra)increment of p by 1 which was done previously is not needed .

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 65 of 2244

finding if LL contains even or node no. of nodes can be done in the same loop which is used to
find middle ele of LL .So no extra time required.
pls correct me if I am wrong.

 1 votes -- rdfan19 ( 21 points)

p = LL->HEAD
odd=p
p = p->NEXT
even = p
p = p->NEXT
while(p!=NULL)
{
odd->next = p
p=p->NEXT
odd = odd->next
even->next = p
p=p->NEXT
even = even->next
}
even->next = odd_orig
LL->HEAD = even_orig

 1 votes -- radha gogia ( 4369 points)

1.96 Quicksort: Give the result of partitioning the keys after the 1st pass of
quicksort. top gateoverflow.in/13696

THISCOURSEISOVER
Choose the last elements as pivot elements (R). Also for duplicates, adopt the convention that both pointers stop.

a) EHIOCOIERRUSSVTS

b) EHISCOIERRUSOVTS

b) EHIOCOUESRTSSVTR

c) EHIOOCIERRUSSVTS

sorting algorithms quicksort

the answer is hicoeioerssuvrs prany datta is right. and saurabh sharma the question may be wrong or it must be incomplete because they may ave used some other
implementation of quick sort.

 0 votes -- Ravi Singh ( 7303 points)

1.97 Quicksort: Quick Sort top gateoverflow.in/36401

Consider an array with the following elements: 12, 18, 17, 11, 13, 15, 16 and 14.
How many element will change their initial position after completion of partition algorithm by choosing 15 as pivot?

Given Answer : 7 ( only 16 is not swapped )

My Answer : 6 ( 16 and 11 are not swapped )

My approach

12, 18, 17, 11, 13, 15, 16 and 14. 15 is pivot swap it with leftmost element

15 | 18, 17, 11, 13, 12, 16 , 14 18>15 & 14 <15


15 | 14, 17, 11, 13, 12, 16 , 18 17>15 & 12<15

15 | 14, 12, 11, 13, 17, 16 , 18 i and j meet each other at 13 so swap with pivot value

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 66 of 2244

13 14 12 11 15 17 16 18

So 11 and 16 are not changed all other elements have changed their position

Correct me if i am wrong

algorithms quicksort

1.98 Quicksort: quick sort time complexity top gateoverflow.in/41179

the worst case time complexity of quicksort for an elements when the median is selected as the pivot

a. o(n^2)

b.o(n)

c.o(nlogn)

d.o(logn)

algorithms time-complexity quicksort


Selected Answer

Answer C) O(nlogn), when median selected as pivot, partition method will divide array into equal halves.. so logn level
recursion tree will form with cn work(partition method) at each level..
The recurence would be..
T(n) = 2T(n/2) + Θ(n)
Therefore total time complexity =Θ(nlogn) in all cases

Note:O(n) time algo available for median finding


https://en.m.wikipedia.org/wiki/Median_of_medians

 1 votes -- Anurag Semwal ( 4775 points)

1.99 Recurrence: T(n) = T(n/2) + n recurrence equation solution? T(1) = 1.


top gateoverflow.in/16246

suppose you are given n bit integers asuming for common sense n as power of 2 .it is required to multiply them using divide
and conquer method .what is the divide and conquer recurrence that would arise for the problem

a) T(n)=4T(n/2)+c

b) a) T(n)=2T(n/2)+n

c) a) T(n)=4T(n/2)+n2

d) a) T(n)=4T(n)+n

algorithms recurrence


Selected Answer

T(n) = T(n/2) + n

Here, a = 1, b = 2, f(n) = n, hence the Master Method is applicable.

nlog2 (1 ) = n0 = 1 < f(n)

So, the answer will be O(n)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 67 of 2244

 1 votes -- Digvijay Pandey ( 26245 points)

1.100 Recurrence: How to solve this Recurrence ? top gateoverflow.in/37909

T(n) = ∑n0 −1 T(i) + cn

recurrence algorithms time-complexity

T(n) = T(n-1) + cn

Ans) O(n^2)

 0 votes -- Prasanna Ranganathan ( 2045 points)

1.101 Recurrence: time complexity top gateoverflow.in/16668

Find time complexity


int R(int n) {
if(n<=1)
return 1;
else {
int sum=0;
for(int i=1;i<=n;i=i*2)
for(j=1;j<=i;j=j*2){
sum=sum+i;
sum=sum*R(n/2);
}
}
return sum;
}

time-complexity recurrence

For(int i=1;i<=n;i=i*2){
For(j=1;j<=i;j=j*2){
Sum=sum+i;
Sum=sum*R(n/2);
}
}

First of all recursive call happens inside the inner loop, so solving will be difficult. Still, lets try.

Outer loop runs log2 n times and inner loop runs log2 i times for each i and i is multiplied by 2 after each iteration. So, the no.
of times the inner loop runs will be
(lg n ) . (lg n +1 )

( ) [ ]
lg1 + lg2 + lg4 + … + lgn = lg(1.2.4.…. n) = lg 20 . 21 . 22 . …2lg n = lg 2 (0 +1 + … +lg n ) = 2

So, our recurrence relation will be


(lg n ) . (lg n +1 )
2
T(n) = T(n/2) + c

Now, lets try substitution assuming c = 1.

T(1) = 1
T(2) = 2
T(4) = 6
T(8) = 36
T(16) = 360
T(32) = 5400

I suppose all choices should be eliminated by now - the growth rate is higher than that of n2 .

#include<stdio.h>

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 68 of 2244

int count = 0;
int R(int n) {
if(n<=1) {
count++;
return 1;
}
else {
int sum=0,i,j;
for(i=1;i<=n;i=i*2)
for(j=1;j<=i;j=j*2){
sum=sum+i;
count++;
sum=sum*R(n/2);
}
return sum;
}
}
int main(int argc, char* argv[]) {
R(atoi(argv[1]));
printf("count = %d\n", count);
}

 0 votes -- Arjun Suresh ( 124125 points)

1.102 Recurrence: What is the time complexity of the given recurrence


relation ? top gateoverflow.in/17029

Consider the given recurrence relation , find the time complexity ?


T(n)=2T(n-1)+T(n-2)+C, T(0)=T(1)=1

time-complexity recurrence

T(n) = 2T(n-1) + c
So by recursive method
T(n) = 2^n + nc
So O(2^n)

 0 votes -- Abhinav Rana ( 489 points)

1.103 Recurrence: Difficult Reccurance top gateoverflow.in/28187

Solve the recurrences.

A) T(1) = 1, T(2) = 6, T(3) = 13, and for all n ≥ 4, T(n) = T(n − 3) + 5n − 9.

B) T(1) = 1, and for all n ≥ 2, T(n)=2T(n − 1) + n2 − 2n + 1.

difficult recurrence algorithms

T(n) =T(n-3)+5n- 9

T(n)=T(n-3)+O(n)

Now use T(n)=aT(n-b)+O(n^k)

Condition if a=1 then T(n)=O(n^(k+1))

So and is O(n^2)

2- for second use conditiontion

If a>1 then T(n)=O{n^k a^(n/b)}

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 69 of 2244

 0 votes -- Savir husen khan ( 121 points)

1.104 Recurrence: How to solve below recurrence relation ? top gateoverflow.in/34569

T(n)=2T(n-1)+n-1, T(1)=1 , n>=2

T(n)=2kT(n-k)+2 (k-1)(n-(k-1))+2(k-2)(n-(k-2))+.......+n

Now k=n-1

T(n)=2(n-1)(1)+2(n-2)(2)+2(n-3)(3)+.......+2(n-n)(n)

T(n)=2(n)[ 1/1 + 2/2 (2) +3/2 (3) + 2/ 2 (4) +....] + n

Now I am struck at this point how to proceed from here ?

recurrence algorithms

1.105 Recurrence: Can masters theorem solve the recurrence 4T(n/2) +


(n^2).logn ? top gateoverflow.in/14231

Can masters theorem solve the recurrence 4T(n/2) + n 2.logn ?

it is said that it falls between the case 2 & 3 and no solution possible with this method .can anyone explain it clearly ?

algorithms recurrence


Selected Answer

nlogb a = nlog2 4 = n2

(
i.e. f(n) = Ω nlogb a . )
( )
Now, to apply Master theorem case 3, we need a positive constant ϵ such that f(n) = Ω nlogb a +ϵ . But here we can't get any
such constant and hence we can't apply Master theorem. So, solving by expansion:

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 70 of 2244

T(n) = 4T () 2
+ n2 logn

n n

= 16T 2
2
() + n2 logn + n2 log
() 2

n n

[
= 4lg n + n2 logn + log 2
() + … + log 2
lg n
( )]
n n

= 4lg n + n2 ⋅ log n × 2 × … × ( 2lg n


)
nlg n +1

= n2 + n2 ⋅ log
( 2lg n ⋅ (lg n +1 ) / 2
)
nlg n +1

= n2 + n2 ⋅ log n
(
(lg n +1 ) / 2
)
(
= n2 + n2 ⋅ log n (lg n +1 ) / 2 )
lgn + 1

= n2 + n2 ⋅ 2 ⋅ logn

(
T(n) = Θ n2 log2 n )

Actually we can even use Extended Master theorem which directly gives the asymptotic bound as Θ n2 log2 n . ( )

 3 votes -- Arjun Suresh ( 124125 points)

a=4,b=2,k=2,p=1

if a=b k then

if p>-1 then t(n)=Θ(n log ba.logp+1n)

so,here 4=22

and p>-1

so,T(n)=Θ(n2.log2n)

 1 votes -- sumt.kr09 ( 21 points)

1.106 Recurrence: How to remove recurrence relation when two or more are
combined top gateoverflow.in/37883

What should be the approch to solve these relations?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 71 of 2244

Consider the recurrence relation T(n) = T(n–1) + T(n/2) + n.

Which of the following is a good tight upper bound on T(n)

(A) Θ(n2 )
(B) Θ(n2 log n)
(C) Θ(2 (log n)2)
(D) Θ(n (log n)2)

algorithms recurrence

1.107 Recurrence: RECURRENCES 1 top gateoverflow.in/28167

How to solve ?

T(1) = 8, and for all n ≥ 2, T(n)=3T(n − 1) − 15.

My Attempt:

T(n)=3T(n − 1) - 15 (after one substitution)

= 3(3T(n − 2) - 15) - 15

= 9T(n − 2) - 15 · 3 -15 (after two substitutions)

= 9(3T(n − 3) - 15) - 15 · 3 - 15

= 27T(n − 3) - 15 · 9- 15 · 3 - 15 (after three substitutions).

After this How to approach ?

recurrence algorithms normal


Selected Answer

What each substitution is doing?

Each substitution is giving us a new way of expressing T(n) in terms of some T(n − k) where k is an integer between 1 & n.

We know the value of T(1) so we should try to write T(n) in terms of T(1).

It is not possible to start with T(n) & exhaustively back substitute until we reach 1, since n is unknown to us.

So we have to observe & generalise the changing pattern in the expression for T(n).

To observe the pattern, instead of multiplying numbers it would be better to keep them apart.

so we get

T(n) = 31 ⋅ T(n − 1) − 30 × 15 ( )
after first substitution.

(
T(n) = 32 ⋅ T(n − 2) − 31 × 15 − 30 × 15 ) ( )
after second substitution.

( ) ( ) (
T(n) = 33 ⋅ T(n − 3) − 32 × 15 − 31 × 15 − 30 × 15 )
after third substitution.

( ) ( ) (
T(n) = 34 ⋅ T(n − 4) − 33 × 15 − 32 × 15 − (3 × 15) − 30 × 15 )
after fourth substitution and so on.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 72 of 2244

……

So after kth substitution we will get

( ) (
T(n) = 3k ⋅ T(n − k) − 3k × 15 − 3k−1 × 15 … − 32 × 15 − 31 × 15 − 30 × 15 ) ( ) ( ) ( )
we can also write it as

T(n) = 3k ⋅ T(n − k) − 15 ⋅ ∑k−1


i =0 3
i
( )
On summing up the geometric series we get,

( 3 −1 )
k

2
T(n) = 3k ⋅ T(n − k) − 15 ⋅

We know T(1) = 8, so we must choose k such that

T(n − k) = T(1)

or (n − k) = 1

⇒ k = (n − 1)

On putting k = (n − 1) in the generalized recurrence, we get:

(3 (n − 1 )
−1 )
2
T(n) = 3 (n −1 ) ⋅ T(n − (n − 1)) − 15 ⋅

(3 (n − 1 )
−1 )
2
⇒ T(n) = 3 (n −1 ) ⋅ T(1) − 15 ⋅

(3 (n − 1 ) −1
)
⇒ T(n) = (3 (n −1 ) )
× 8 − 15 ⋅ 2

( ) (
⇒ T(n) = 8 × 3 (n −1 ) − 7.5 × 3 (n −1 ) + 7.5 )
(
⇒ T(n) = 0.5 × 3 (n −1 ) + 7.5 )
1

(
⇒ T(n) = 2 3 (n −1 ) + 15 )

 1 votes -- Anurag Pandey ( 8183 points)

T(n)=3T(n − 1) - 15 (after one substitution)

= 3(3T(n − 2) - 15) - 15

= 9T(n − 2) - 15 · 3 -15 (after two substitutions)

= 9(3T(n − 3) - 15) - 15 · 3 - 15

= 27T(n − 3) - 15 · 9- 15 · 3 - 15 (after three substitutions).

...........

=3 k T(n - k) - 15(3k +3 k-1+.............3 2+3 1+3 0)

=3 n-1T(1) - 15 ((3n-1 -1)/(3-1))

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 73 of 2244

=3 n-1 . 8 - 15/2(3n-1 -1)

=3 n-1(8 - 15/2)+15/2

=1/2(3n-1+15)

 1 votes -- srestha ( 11585 points)

1.108 Recurrence: recurrence relation top gateoverflow.in/39452

how to apply master's theorem in given problem

t(n) = 3t(n/4) + nlogn.

please explain ..

recurrence algorithms

For T(n)= aT(n/b)+n^k log^p n

for a>=1, b>1, k>=0,p real no.


compare a and b^k,
1. if a>b^k then T(n)=n^(log a/log b)
2. if a=b^k then
.if p>-1, T(n)=n^(log a/log b) log^(p+1) n
.if p=-1, T(n)=n^(log a/log b) log log n
.if p<-1, T(n)=n^(log a/log b)
3. if a<b^k then
.if p>=0, T(n)=n^k log^p n
.if p<0, T(n)=n^k

compare a and b^k i.e a=3, b^k=4^1 which implies a<b^k

Since, p >=0, so, T(n)=n log n

 0 votes -- Rajib Das Bhagat ( 23 points)

1.109 Recurrence: Solve the recurrence relation B(n) = 3B(n/log (n)) + θ(n)
2 gateoverflow.in/41833

top

What is the solution of following recurrence relation.

$B(2) = 1$

B(n) = 3B(n/log2 (n)) + θ(n)​

algorithms time-complexity recurrence

put n=2^k eq-1

B(2^k) = 3B(2^k/k) + 2^k

B(2^k/k) = 3B(2^k/k^2) + (2^k)/k

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 74 of 2244

B(2^k/k^2) = 3B(2^k/k^3) + (2^k)/k^2

................=3B(2^k/k^x) + (2^k)/k^(x-1)

put 2^k/k^x=2...........eq-2

= 3B(2) + (2^k)/k^(x-1)+...........+ (2^k)/k^2 + (2^k)/k + 2^k

=3*1+(2^k)[1/k^0 + 1/k^1 + 1/k^2+ 1/k^3 +1/k^4 +1 /k^(x-1)] apply g.p formula=a(1-r^n)/1-r

=3+(2^k)[(1-(1/k)^x)/1-1/k]

=3+( 2^k) *k*[(k^x-1)]/(k-1) k^x

put k^x=2*2^k from eq-2

=(k.2^K)/(k-1)

put 2^k=n from eq-1

=n.logn is the answer

 2 votes -- Tauhin Gangwar ( 509 points)

1.110 Recurrence: Solve the recurrence top gateoverflow.in/13587

T(n) = T(n - 1) + 1/n

a) O(1)

b) O(n)

c) O(log n)

d) O(log log n)

algorithms recurrence

T(n) = T(n-1) + 1/n

= T(n-2) + 1/(n-1) + 1/n

...

= 1 + 1/2 + 1/3 + .... + 1/n

= O(log n) (Sum of first n numbers in Harmonic series)

Ref: https://en.wikipedia.org/wiki/Harmonic_series_(mathematics)

 4 votes -- Arjun Suresh ( 124125 points)

1.111 Recurrence: How to solve this using recursion tree method top gateoverflow.in/41608

algorithms recurrence

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 75 of 2244

---

HTH

 1 votes -- Prateek Dwivedi ( 845 points)

1.112 Recurrence: what is difference between following recurrence question


top gateoverflow.in/30593

Please explain the difference between the following question or are they same..??

Q1. Find complexity of the recurrence given by

T(n)=2*T(n-1)-1 if n>0

1 otherwise

Q2. Find complexity of algorithm given by..

T(n)=T(n-1) + T(n-2) - T(n-3) if (n>3)

N otherwise

If in the first question it means that given recurrence is for value and in second it means to directly solve the recursion, then
how could a running time recurrence have a negative term...??

time-complexity recurrence

1.113 Recurrence: Recurrence relation with multiplication of two time


complexities top gateoverflow.in/43706

Given T(1) = a, T(2) = b


Solve T(n) = T(n-1) * T(n-2)

algorithms recurrence time-complexity

T(1) = a

T(2) = b

T(3) = ab

T(4) = ab2

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 76 of 2244

T(5) = a2 b3

T(6) = a3 b5

T(n) = ap −1 bp , where p is the (n − 1)th Fibonacci number.

nth Fibonacci number is exponential in n, so T(n) is double exponential in n.

 2 votes -- Arjun Suresh ( 124125 points)

1.114 Recurrence: Recurrence relation explanation top gateoverflow.in/32924

Whenever we have a recurrence relation of type

T(n) = a * T(n/b) + c

here a is the number of sub problems.

what will be Size of sub problems ? Is it n/b ?

recurrence time-complexity algorithms


Selected Answer

yes..its meaning is as follows:

By doing 'c' amount of work on a n size bigger problem

we are able to reduce it into 'a' number of SubProblems each of size (n/b)

eg Merge sort T(n)=2T(n/2) +n

by doing O(n) amount of work [Divide time(constant)+combine Time(merge algo ->O(n) time) later ] we are
able to devide a large n array size sorting problem to two smaller size array sorting problems each of size
(n/2)

 3 votes -- Anurag Semwal ( 4775 points)

1.115 Recurrence: Find the recurrence top gateoverflow.in/26668

recurrence algorithms

1.116 Recurrence: Calculating time compleity of recurrence relations. gateoverflow.in/36393

top

I am having some problems in calculating time complexities for recurrence relations. In one of the books, I saw two

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 77 of 2244

questions-

1.

A(n)

if(n<=1) return (n);

else

{ return ( A(n/2)+ A(n/2)+ n);

The recurrence for this is given as

T(n)= T(n/2)+T(n/2) +c if n>1

But then another question follows-

Q2.

A(n)

if(n<=1) return (n);

else

{ return ( 2*A(n/2)+ 6*A(n/2)+ n^2);

The recurrence for this is given as

T(n)= T(n/2)+T(n/2) +c if n>1

I think it should be T(n)= 2T(n/2)+6T(n/2) +n^2

What am I missing here ?

algorithms recurrence

No, your answer is incorrect.


Suppose, 2*T(n/2) means calling T(n/2) twice. But in question they have multiply it by 2 not called it twice.

 2 votes -- Monanshi Jain ( 5827 points)

1.117 Recurrence: How to solve following recurrence ? top gateoverflow.in/32142

Let h be the homomorphism defined by h(a) = 01, h(b) = 10, h(c) = 0, and h(d) = 1. If we take any string w in
(0+1)*, h-1(w) contains some number of strings, N(w). For example, h -1(1100) = {ddcc, dbc}, i.e., N(1100) = 2. We
can calculate the number of strings in h-1(w) by a recursion on the length of w. For example, if w = 00x for some
string x, then N(w) = N(0x), since the first 0 in w can only be produced from c, not from a.

Complete the reasoning necessary to compute N(w) for any string w in (0+1)*. Then, choose the correct value of
N(10100101).

a) 15
b) 34
c) 128
d) 25

recurrence theory-of-computation algorithms

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 78 of 2244

1.118 Recurrence: Question on finding complexity top gateoverflow.in/26925

Given answer: A
Please explain

time-complexity algorithms recurrence


Selected Answer

It's a homogeneous recurrence relation, and can be solved easily:

T(n) = T(n − 1) + T(n − 2) − T(n − 3)


an = an −1 + an −2 − an −3 ; rewriting recurrence relation

The characteristic equation will be of the form:

r3 = r2 + r − 1
(r + 1)(r − 1)3 = 0

You can now solve it on your own and get T(n) = O(n)

answer = option A

 4 votes -- Amar Vashishth ( 17865 points)

ans will be O(3 n).. quetion asking about time complexity not value..

evry time 3 call ..and maximum we have n level.. because T(n-1) is given.

 2 votes -- Anirudh Pratap Singh ( 4091 points)

Given recurrence relation

T(n)=T(n-1)+T(n-2)-T(n-3) n>3

=n otherwise

So we can write T(1)=1,T(2)=2 and T(3)=3 when n<=3

Now, putting T=4 in the given equation we get,

T(4)=T(3)+T(2)-T(1)

=3+2-1=4

Similarly,T(5)=T(4)+T(3)-T(2)

=4+3-2=5

and T(6)=T(5)+T(4)-T(3)=5+4-3=6;

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 79 of 2244

so in general,we get,T(n)=T(n-1)+T(n-2)-T(n-3)=(n-1)+(n-2)-(n-3)=n

Therefore,T(n)=o(n)

 1 votes -- sampad ( 361 points)

1.119 Recurrence: how to solve this recurrence relation top gateoverflow.in/39465

T(n) = 2*T(n/2) + n*logn


please explain

recurrence algorithms

For T(n)= aT(n/b)+n^k log^p n

for a>=1, b>1, k>=0,p real no.

compare a and b^k,

1. if a>b^k then T(n)=n^(log a/log b)

2. if a=b^k then

.if p>-1, T(n)=n^(log a/log b) log^(p+1) n

.if p=-1, T(n)=n^(log a/log b) log log n

.if p<-1, T(n)=n^(log a/log b)

3. if a<b^k then

.if p>=0, T(n)=n^k log^p n

.if p<0, T(n)=n^k

compare a and b^k i.e a=2, b^k=2^1 which implies a=b^k

Since, p >=(-1), so, T(n)=n log^2 n

 0 votes -- Rajib Das Bhagat ( 23 points)

1.120 Recurrence: Can these be solved by Master's theorem? top gateoverflow.in/25346

1)) T(n)=T(n/2)+2^n

2)) T(n)=2T(n/2)+n/logn

3)) T(n)=16T(n/4)+n!

4)) T(n)== √2T ( n/2 ) + log n

algorithms recurrence

1,3,4 can be solved by Master's Theorem, not sure about 2

1. f(n)= 2n , a=1, b=2

f(n)= Ω(n^(log b a + ∈ ) so, T(n) = ⊖(f(n)) = ⊖( 2n )

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 80 of 2244

3. f(n) = n! , a = 16, b = 4

f(n) = Ω(n^(log b a + ∈ ) so, T(n) = ⊖(f(n)) = ⊖( n! )

4. f(n) = log n , a =
√2, b = 2

f(n) = O(n^(log b a - ∈ ) take ∈ = .1

so, T(n) = ⊖( n^(log 2 √2) = ⊖( √n )

 1 votes -- Himanshu Agarwal ( 8861 points)

1.121 Recurrence: How to solve below recurrence relation ? top gateoverflow.in/33989

T(n)=2√nT(√n)+n

In this If we take n=2m then and I divide the entire equation by n so I will get

T(2m) /2m=2T(2 m/2) + 1

Now T(2m)/2m=S(m), so equation becomes

S(m)=2S(m/2)+1 therefore S(m)=⊝(m) so T(2 m)/2m=⊝(m) , T(2m)=2 m⊝(logn)=⊝(nlogn)

Is this correct approach or not ,since I am unable to do it with tree method .

recurrence algorithms

O( n log log n )
Using Back substitution

 1 votes -- Akhil Nadh PC ( 1967 points)

1.122 Recurrence: What will be the time complexity of below code? top gateoverflow.in/18734

main(){
while(n>2)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 81 of 2244

n=n/log(n);
}

recurrence time-complexity

T(n) = T lg n
( ) +1

=T
( lg nlg (n / lg n )
) + 2 (Going 1 level into recursion)

( )
n
lg2 n −lg nlg lg n
=T +2

Since the second term (lgnlglgn) is asymptotically lower than lg2 n, we can ignore it and assume that the recurrence stops
when the denominator is half of the numerator (when we get T(2)) which happens after k steps and since the complexity
at each step is 1, the total complexity will be k.

lgkn = n/2

lgn = (n/2)1 / k

lglgn = (1/k)(lgn − 1)

k = (lgn − 1)/lglgn

lg n

So, time complexity = Θ lg lg n


( )
 0 votes -- Arjun Suresh ( 124125 points)

1.123 Recurrence: How can one solve the following recurrence? top gateoverflow.in/18652

T(n) = T(n − 1) + T
()
2
+n

n ≥ 1, T(1) = 1

recurrence time-complexity

I dont know the exact answer but this is my approach.

let the T(n-1)=T(n/2) T(n/2)=T(n-1)

T(n)= 2T(n/2)+n < T(n)=T(n−1)+T(n/2)+n < T(n)=2T(n−1)+n

Ώ(nlogn) < T(n) < O(2n)

so i guess answer should in exponential term for big-Oh.

 0 votes -- Umang Raman ( 10379 points)

1.124 Recurrence: When do floors and ceilings matter while solving

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 82 of 2244

recurrences? top gateoverflow.in/11348

every time while finding recurence solution (in CLRS book , page 88) a statement "Floors and ceilings usually do not matter
when solving recurrences" but my doubt is when they matter ?

algorithms recurrence

Whenever we need to find exact recurrence expression then floor and celing matters.. otherwise it is useless because one
or two, in general constant people doesn't affect time Complexity..

Let , (n/2) and n is odd then we can take value as Floor (n/2) or Ceil (n/2).. difference between floor and ceil value is one
.. here n is no of input.. one less or one more input doesn't affect asymptotic complexity..

But whenever we need to find something like exact no of comparison then we need floor ceil precisely..

 2 votes -- Digvijay Pandey ( 26245 points)

1.125 Recurrence: What is the complixity of following recurrence top gateoverflow.in/38931

recurrence programming-in-c algorithms time-complexity


Selected Answer

O(2^N)

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

draw a recurrce tree.here you will get a complete(perfect tree) and splitting a node into 2 will take o(1) time.

so at head n is split into 2 (n-1),(n-1) size subproblems(nodes) doint work of contsant time(o(1)).

at any level work done will be constant *no . of subproblems at that level.

so its 2^0+2^1+2^2+2^3+......2^n.

take GP sum and you will be o(2^n)

rather igonre all other terms last term is 2^n .

and all other terms as they are addtitive. so,directly (2^n).

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 83 of 2244

and forming some recurrecre relations directly looking at the question required some experience.

so just forget if you are not able to derive the relation below directly.

T(N)=2*T(N-1) +o(1)

 0 votes -- viv696 ( 1431 points)

1.126 Recurrence: Mcs-033 top gateoverflow.in/39411

set up a recurrence relation for the number of n digit sequences on integers 0,1,2,3 having an even number of 0's

recurrence

an=3C1an-1+ (4n-1-an-1)

3C a
1 n-1= where a n-1 valid and last bit as 1/2/3

(4n-1-an-1) = any 4 digit number -invalid bit of (n-1) and 1 zero

 0 votes -- srestha ( 11585 points)

1.127 Recurrence: How to find the complexity of T(n)=T(sqrt(n)) + 1 ? top


gateoverflow.in/11211
Please tell me the complete steps how to solve this problem.

algorithms recurrence


Selected Answer

For objective exams do:

Since we have a sqrt term, considering only perfect squares and those which are multiple of 2 as that can take care of log.

T(2) = 1//assume

T(22 ) = T(2) + 1 = 2
2
T(22 ) = T(4) + 1 = 3

T 22( ) 3
= T(16) + 1 = 4

T 22( ) 4
= T(256) + 1 = 5

So, we are getting T(n) = lglgn + 1  T(n) = O(loglogn)

 7 votes -- Arjun Suresh ( 124125 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 84 of 2244

log (logn)

u can find it by back subsitution method

 2 votes -- shabi ( 317 points)

1.128 Recurrence Eqation: Order and run time of the algorithm? top gateoverflow.in/37206

Running time of an algorithm T(n), where n is input size is given by T(n) = 8 T(n/2) + qn, if n>1 T(n) = p, if, n=1 where p and q are constants. The order of algorithm
is
A. n2
B. nn
C. n 3
D. n

algorithms recursion recurrence-eqation


Selected Answer

Case 1 of master theorem as

( ) (
f(n) = O nlogb a −ϵ = O nlog2 8 −ϵ = O n3 −ϵ ) ( )
is true for any 0 < ϵ ≤ 2.

Now, the complexity is Θ nlogb a = Θ n3 . ( ) ( )


 1 votes -- Arjun Suresh ( 124125 points)

1.129 Recurrence Equation: A better guess on upper bound top gateoverflow.in/42716

It's a question from Cormen book Exercise 4.4-5 and is described like this:

Use a recursion tree to determine a good asymptotic upper bound on the recurrence T(n) = T(n − 1) + T( 2 ) + n

asymptotic-notations recurrence-equation

it think it will be O(n^2)..bcozT(n/2)+n->time complexity is O(n) by master's theorem and let O(n)=Cn where C is any
constant

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 85 of 2244

Now T(n)=T(n-1)+Cn

if we solve through recursion tree it will give O(n^2)

 0 votes -- sethi ( 31 points)

1.130 Recursion: Finding Time complexity top gateoverflow.in/26926

Given answer: B
Please explain

time-complexity algorithms recursion


Selected Answer

the inner loop is additive increase this makes growth as O(n)

the outer loop is multiplicative decrease, this makes shrinkage as O(log2 (n))

(
both are in serial connection, therefore Time Complexity = O nlog2 (n) )
answer = option B

the recurrence relation that governs the value of j is given as:

jm = jm−1 + m
an = an −1 + n ; rewriting the relation

such a recurrence relation is non-homogeneous recurrence relation.


whose solution is in the form

an = apn + ahn
= Particular Solution + Homogeneous Solution

for homogeneous solution we can see it directly as r = 1 so ahn = ch where ch is a constant.


the F(n) here is a linear function whose trial solution will be in the form d0 + d1 n

combining which gives us that the inner loop is O(n)

 4 votes -- Amar Vashishth ( 17865 points)

1.131 Recursion: time complexity=? top gateoverflow.in/26146

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 86 of 2244

void xyz(char *s)


{
if(s[0]=='\0')
return;
xyz(s+1);
xyz(s+1);
printf("%c",s[0]);
}
void main()
{
xyz("123");
}

if the input string constant is of length n then what is the time complexity?

A. O(2n )
B. O(n2 )
C. O(n)
D. O(nlogn)

recursion


Selected Answer

Since in the output is of length 7 it means that there were 7 non trivial function calls in total which is (2 n - 1) and hence
the time complexity is O(2n ).

 3 votes -- Riya Roy ( 4767 points)

1.132 Recursion: Size of stack required is ? top gateoverflow.in/10795

A(n)
{
if(n>=1)
{
A(n-1); // statement 1
print n; //statement 2
A(n-1);// statement 3
}
}

recursion


Selected Answer

Size of stack is of the order of the number of recursive calls which are currently live. (It is not equal because we save
many info on the stack during a call like local variables, return address etc. )

Here, we have two recursive calls with value (n-1) for input n. But before the second one starts, the first one finishes. So,
total number of recursive calls for n can be given by

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 87 of 2244

Solve recurrence T(n) = 2T(n-1) + 1 (1 for the stack space required for the current process) with T(0) = 1.

and the number of live recursive calls (recursion depth) is given by

T(n) = T(n-1) + 1 which is O(n).

 6 votes -- Digvijay Pandey ( 26245 points)

1.133 Recursion: Finding time complexity of Dynamic programming problem


top gateoverflow.in/26513

The answer to the above problem is A but I am expecting it to be D as constant amount of work is required to solve each
subproblem.

algorithms time-complexity recursion data-structure


Selected Answer

THIS IS WELL KNOW FLYOD WARSHAL PROBLEM WHICH IS HAPING COMPLEXITY 3 N WITHOUT DYNAMIC PROGRAMMING
BUT USING DYNAMIC O(n3).

 3 votes -- Anirudh Pratap Singh ( 4091 points)

1.134 Recursion Tree: How to solve the following Recurrance top gateoverflow.in/31860


T(n) = T(n/4) + T(3n/4) + n ⟩
a) Using Varience of master theorem
b) Using Recursion Tree

Please elaborate your answer so that i can understand the concepts :)

recursion-tree time-complexity

1.135 Shortest Path: dijkstra's algo top gateoverflow.in/19504

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 88 of 2244

graph-algorithms shortest-path

after analysis on this i found.

1) yes but they all infinite distance apart from source.

2)yes as mentioned in algorithm while(Q!=phi) dijkstra's will always terminate

3)yes because for each vertex call extract min which is take O(log v) i.e total O(v log v) and in that for each edge we have
relax all the adjacent edge which internally call decrease function call which take O(log v) i.e for each edge relaxation will
be done only once so tatal for this O(e logv)

so total time O((v+e)logv) but in worst case there may be chance that no relaxation performed in that case time O(vlogv
+e).

4)when no relaxation will performed in that case all vertices have cost infinity so simply extract one of them

 0 votes -- yes ( 1251 points)

1.136 Sorting: Sorting - which will perform Better top gateoverflow.in/36415

If input is sorted in reverse order , then which sorting algorithm will perform best -

A) Insertion Sort

B) Merge Sort

C) Heap Sort

D) Quick Sort

sorting algorithms normal

C) HeapSort

Reference:http://www.sorting-algorithms.com/reversed-initial-order

 2 votes -- Prasanna Ranganathan ( 2045 points)

1.137 Sorting: In quick sort , for sorting n elements , the (n/4)th smallest
element top gateoverflow.in/18925

In quick sort , for sorting n elements , the (n/4)th smallest element is selected as pivot using an O(n) time algorithm. What
will be the time complexity?

it is Θ(n2 ) , right ?

algorithms sorting time-complexity

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 89 of 2244


Selected Answer

It would be Θ(nlogn).

At each level, the array of size n is getting divided in to 2 sub arrays of size (n/4) and (3n/4) along with an extra work for
choosing pivot which requires O(n) time.

n 3n

So recurrence will be of the form: T(n) = T 4


() ( ) +T 4
+ O(n)

This can be solved using recursion tree.

( ) ( )
Lower bound for this recurrence will be Ω nlog4 n , & upper bound will be O nlog 3 n ,
4

which gives T(n) = Θ(nlogn).

 5 votes -- Anurag Pandey ( 8183 points)

T(n)=T(n/4)+T(3n/4)+O(n)

Solving this using recurrence tree we get

T(n)=O(nlogn)

 1 votes -- Pooja ( 22773 points)

1.138 Sorting: To sort n randomly generated numbers. One should prefer


which sorting algo ,Quick or Heap top gateoverflow.in/16934

To sort n randomly generated numbers. One should prefer which sorting algo ,Quick or Heap?

sorting

Quick sort performs very gud if the elements are randomly generated. even if Quick Sort and Merge Sort have same
complexity on average and in best case scenario, the constants (hidden by the big-O notation) are much smaller in Quick
Sort leading to a smaller running time on average. looking at the table we can easy know that the comparision is between
mege and quick . heap is not so efficient to be compared,(http://ddeville.me/2010/10/sorting-algorithms-comparison/)

 1 votes -- Ravi Singh ( 7303 points)

I feel heap sort is preferable as at any moment if we wish to add any randomly generated element to the list then the list
needs to be sorted after it to get the element in sorted order. so we can just add the element and call maxheapify or
minheapify as our requirement and get it sorted for the randomly added element

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 90 of 2244

I feel if our list is static i.e data need not be added later then we can go ahead with sorting as the sorted order wont be
affected later

but if we want to make any changes either add or delete any element then i feel heap is the best as it does minimal work
for moving element and even maintaining the property

 1 votes -- ANI ( 503 points)

1.139 Sorting: Which of the following sorting methods will be the best if
number of swapping top gateoverflow.in/18924

Which of the following sorting methods will be the best if number of swapping done is the only measure of efficiency

I am getting Bubble sort , is it right ?

algorithms sorting


Selected Answer

Selection sort is best if efficiency is in terms of swaps.No of swaps in selection sort is of O(n)

 2 votes -- Pooja ( 22773 points)

1.140 Sorting: Insertion sort on small arrays in merge sort top gateoverflow.in/29493

Although merge sort runs in Θ(n lg n) worst-case time, and insertion sort runs in Θ(n 2 ) worst-case time, the
constant factors in insertion sort make it faster for small n. Thus, it makes sense to use insertion sort within
merge sort when subproblems become sufficiently small. Consider a modification to merge sort in which n/k
sublists of length k are sorted using insertion sort and then merged using the standard merging mechanism,
where k is a value to be determined.

a. What is the worst-case time to sort the n/k sublists (each of length k)?

b. Show that the sublists can be merged in Θ(n lg(n/k)) worst-case time.

c. What is the largest asymptotic (Θ-notation) value of k as a function of n for which the modified algorithm
has the same asymptotic running time as standard merge sort?

d.How should we choose k in practice?

sorting algorithms

1.141 Sorting: How does merge sort proceed ? top gateoverflow.in/30053

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 91 of 2244

According to the algo specified If I consider the case for the 1st sub-array right=1 and left=0 so B[0]=A[left]=4 ,Now using
this algo when will the array size become 1 ,I am not getting the base condition here ,plz clarify this where is the mistake ?

sorting

1.142 Sorting: What is the proper order in which we can arrange the sorting
algos in terms of the number of swap operations they do ? top gateoverflow.in/13320

I am not getting which algorithm has minimum no of swap operations , acc to me both selection and insertion should be at
the lowest level as well as merge sort since after dividing the arrays we merely merge them where do we swap in that ,
please clarify this , I am a bit confused regarding counting the no of swap operations .

sorting


Selected Answer

In the worst case answer should be selection sort. Because we use a temp variable for finding the maximum value in each
iteration and do a swap only once for the inner loop. In this way we swap only n times for the whole algorithm in any
case.

Think of it like sorting a structure containing multiple objects. So, swap operation is heavy. So, here selection sort makes
sense.

In insertion sort- for each element after finding its position we are shifting all elements to the right. These shifts can also
be considered as swaps as they are swapping the positions.

For merge sort we are using an auxiliary array and we can assume all elements are swapped.

http://gatecse.in/wiki/Complexities_of_Basic_Sorting_Algorithms

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 92 of 2244

 2 votes -- Arjun Suresh ( 124125 points)

1.143 Sorting: Which of the following changes to typical QuickSort improves


its performance on average and are generally done in practice ? top gateoverflow.in/13321

1) Randomly picking up to make worst case less


likely to occur.
2) Calling insertion sort for small sized arrays
to reduce recursive calls.
3) QuickSort is tail recursive, so tail call
optimizations can be done.
4) A linear time median searching algorithm is used
to pick the median, so that the worst case time
reduces to O(nLogn)

I am not getting points 2 and having confusion in point 3 that how quicksort can be tail-recursive since we have 2 function
calls at the end , and why is option 4 wrong ,since if we pick the pivot as median then surely It will divide the array equally
into two halves therefore worst case time complexity must be O(n log n ) , plz correct me where am I wrong ?

sorting


Selected Answer

these links may clear your doubt

http://www.geeksforgeeks.org/iterative-quick-sort/

http://stackoverflow.com/questions/12454866/how-to-optimize-quicksort

https://en.wikipedia.org/wiki/Quicksort#Optimizations

in 4th option we can use in theory but not in practice bcoz choose median as pivot in large array has many overhead ...

 2 votes -- sonam vyas ( 6441 points)

1.144 Sorting: why is merge sort better if we try to do sorting on linked lists
and also insertion sort and why not any other algo like quick sort or
selection sort ? top gateoverflow.in/13353

If we talk about that since since we cant access any random element in a linked list for that reason quick sort cant be used
for linked lists ,then in merge sort also we need a middle element for splitting so then how do we actually use merge sort
then , also even if chosing the pivot takes O(n) time then it will only add up with the time taken for partition as such no
issue in it then why can't we use quicksort for implementing linked lists?

sorting

There is no issue in implementing quick sort with link list but it does not enhance performance of quick sort while in case
of merge sort the time complexity being the same it improves space complexity and through link list it can be done in-
place (without using extra space)

 0 votes -- Abhishekcs10 ( 1001 points)

1.145 Sorting: ISRO-2013-12 top gateoverflow.in/43802

Which of the following sorting algorithms has the minimum running time complexity in the best and average case?

A. Insertion sort, Quick sort


B. Quick sort, Quick sort
C. Quick sort, Insertion sort
D. Insertion sort, Insertion sort

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 93 of 2244

isro2013 sorting


Selected Answer

Insertion sort best case O(n)

Quick sort avg case O(n log n)

Ans (A)

 2 votes -- srestha ( 11585 points)

A. Insertion sort (n) , Quick sort( n logn)


B. Quick sort (n logn), Quick sort(n logn)
C. Quick sort (n), Insertion sort(n2)
D. Insertion sort (n), Insertion sort(n2)

 1 votes -- Anirudh Pratap Singh ( 4091 points)

1.146 Sorting: How does partitioning step acts as a conquering step in quick
sort ? top gateoverflow.in/30096

T(n)=aT(n/b) +f(n) here f(n) is the cost of conquering the sub-problems i.e. cost of merging
all the sub-problems in order to solve the problem but in case of partioning we are dividng the array around
a particular pivot point so while calcualting the time complexity of quick-sort why do we take O(n)
time for f(n) ,how is acting as a conquering step?

sorting


Selected Answer

Here , conquering cost is O(1)

and partition algo { O(n) } is the cost for dividing the big problem into small sub-problems.

So, T(n) = O(n) + T(k * n ) + T( (1-k)* n ) + O(1)

Divide cost Sub-problems' cost Combine-Cost

Note: f(n) as u described is Divide + Conquer cost , not just conquer.

 2 votes -- Himanshu Agarwal ( 8861 points)

1.147 Sorting: CLRS 8-2 Sorting in place in linear time top gateoverflow.in/41735

n
Suppose that we have an array of n data records and that the key of each record has the value 0 or 1. An algorithm for
sorting such a set of records might posses some subset of the following three desirable characteristics:
1. The algorithm runs in O(n) time
2. The algorithm is stable.
3. The algorithm sorts in place, using no more than a constant amount of storage space in addition to the original array.

Do the following:
1. Give an algorithm that satisfies criteria 1 and 2 above
2. Give an algorithm that satisfies criteria 1 and 3 above
3. Give an algorithm that satisfies criteria 2 and 3 above

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 94 of 2244

n
4. Can you use any of your algorithms from parts (a)-(c) as the sorting method used in line 2 of RADIX-SORT , so that RADIX-SORT sorts records with b-bit keys
in O(bn) time? Explain how or why not.
n
5. Suppose that the n records have keys in the range 1
to k
. Show how to modify counting sort so that it sorts the records in place in O(n+k) time. You may use O(k) storage outside the input array. Is your algorithm
stable? (Hint: How would you do it for k=3? )



Can somebody please provide solution with an example?

sorting data-structure

1.148 Sorting: median of two sorted Arrays top gateoverflow.in/31122

algorithms time-complexity sorting

1.149 Sorting: Below is the question, Please explain it.. top gateoverflow.in/32944

A sort method is said to be stable if the relative order of keys is the same after the sort as it was before the sort. In which of
the following pairs both sorting algorithms are stable?

a) Quick sort and insertion sort

b) Insertion sort and Bubble sort

c) Quick sort and Heap sort

d) Quick sort and Bubble sort

sorting


Selected Answer

A Sorting Algorithm is said to be stable if it preserves the order of equal items.

Here is an example ( source).

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 95 of 2244

There are algorithms which are stable naturally like Bubble sort and Insertion sort. And there are algorithms which need
modification to exhibit this stable sorting property, example of such sorting algorithm is Quick Sort.

The only way to know if the sorting algorithm is stable is to execute the algorithm on an input with more than one
duplicate elements. And check if their ordering is preserved after complete execution of the algorithm.

Click here to know about other stable sorting algorithms.

ANSWER: B) INSERTION SORT and BUBBLE SORT

 1 votes -- Prateek Dwivedi ( 845 points)

1.150 Sorting: If the number of records to be sorted is small, then which


sorting can is efficient? top gateoverflow.in/38035

If the number of records to be sorted is small, then ...... sorting can be efficient.
A. Merge

B. Heap

C. Insertion

D. Bubble

algorithms sorting


Selected Answer

Insertion Sort

The constants in the time function in insertion sort is small. When the input size is small ,other algos prove to take greater
time .

but when input is large enough nlogn algos are efficient.

 2 votes -- Saurav Singh ( 105 points)

1.151 Sorting: Assume that a CPU can process 10 8 operations per second.
Suppose you have to sort an array with 10 6 elements. Which of the following
is true? top gateoverflow.in/13259

Assume that a CPU can process 108 operations per second. Suppose you have to sort an array with 106 elements. Which of
the following is true?

1. Insertion sort will always take more than 2.5 hours while merge sort will always take less than 1 second.
2. Insertion sort will always take more than 2.5 hours while quicksort will always take less than 1 second
3. Insertion sort could take more than 2.5 hours while merge sort will always take less than 1 second.
4. Insertion sort could take more than 2.5 hours while quicksort will always take less than 1 second.

algorithms sorting time-complexity


Selected Answer

Merge sort complexity is Θ(nlgn), and so we need 106 lg106 ≈ 20 × 106 and assuming the constant factor is less than 5, number
of instructions would be less than 108 and can be run within a second.

Worst case complexity of insertion sort is O(n2 ) and to sort 106 elements it needs 1012 operations and with 108 operations
per second this would need 104 seconds = 2 hours 46 minutes.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 96 of 2244

Now, best case complexity of insertion sort is O(n). So, "always" in options 1 and 2 make them false.

Similarly worst case of quick sort is O(n2 ) and this makes option 4 false.

So, option 3 is the answer.

 3 votes -- Arjun Suresh ( 124125 points)

1.152 Sorting: Given the sequence of n integers in the order: top gateoverflow.in/34562

algorithms sorting

B should be the correct choice.

 0 votes -- rids123 ( 17 points)

1.153 Sorting: How to find number of swappings in bubble sort in least


possible time ( any shortcut available ) top gateoverflow.in/14398

1. The number of swappings needed to sort the numbers: 8, 22, 7, 9, 31, 19, 5, 13 in ascending order using bubble sort is—
(a) 11 (b) 12
(c) 13 (d) 14

I know how to solve it using straightforward method.

What I did was to write every pass and check the swappings. But , it takes too much time.

Is there any shortcut possible ?

sorting algorithms


Selected Answer

In Bubble sort, largest element moves to right. So a swapping is done, when a smaller element is found on right side.

So to count number of swaps for an element, just count number of elements on right side which are smaller than it.

Array is [8, 22, 7, 9, 31, 19, 5, 13].

For 8, number of elements on right side which are smaller : 2 (7 and 5)

For 22 : 5 (7,9,19,5,13)

For 7 : 1, for 9 : 1, for 31 : 3, for 19 : 2, for 5 : 0, for 13 : 0

Adding all these, we get : 2+5+1+1+3+2 = 14

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 97 of 2244

So 14 swaps will be done.

 6 votes -- Happy Mittal ( 9253 points)

1.154 Sorting: Sorting under restriction top gateoverflow.in/1589

Array of n elements with first 10 and last 50 elements unsorted..find an algo which runs faster a)merge sort b)quick sort
c)insertion sort d)bubble sort Explain

algorithms sorting normal

Insertion Sort.

To sort the first 10 elements- maximum O(102 ) = O(1) time complexity.

Next, n − 60 elements take Θ(n − 60) time as these would involve no shifting among themselves)

Final 50 elements take Θ(50n) = Θ(n) time in worst case to place each of the 50 elements in position.

So, totally Θ(n).

 1 votes -- Arjun Suresh ( 124125 points)

1.155 Sorting: Time Complexity of a Custom Quick Sort Design top gateoverflow.in/13680

Given an instance of custom quick sort in which the Pivot element is always the
n
()4
th
smallest element. GIven a large array

th
()
as input and an implementation of this custom quick sort such that the 4 smallest element is found in O(n) time. What is

the time complexity of this Custom Quick Sort?


A) O(nlogn)
B) O(n2 )

algorithms time-complexity sorting


Selected Answer

T(n) = T(n/4) + T(3n/4) + O(n)

Should give O(nlogn)

 4 votes -- Arjun Suresh ( 124125 points)

1.156 Sorting: Internal Sorting top gateoverflow.in/38034

State True or False for internal sorting algorithms:


(i) Internal sorting are applied when the entire collection if data to be sorted is small enough that the sorting can take place within
main memory.
(ii) The time required to read or write is considered to be significant in evaluating the performance of internal sorting.
A. (i)- True, (ii)- True

B. (i)- True, (ii)- False

C. (i)- False, (ii)- True

D. (i)- False, (ii)- False

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 98 of 2244

algorithms sorting


Selected Answer

Internal sorting . when the elements to be sorted are all in the main memory while in external sort all are not present in
memory during sorting . as in internal sort all elements are in main memory the time to read write is not that much
significant as compared to external sorting .

so true false

 2 votes -- Ravi Singh ( 7303 points)

1.157 Space Complexity: What is the time complexity? top gateoverflow.in/208

double foo(int n)
{
int i;
double sum;
if(n == 0)
{
return 1.0;
}
else
{
sum = 0.0;
for(i = 0; i < n; i++)
{
sum += foo(i);
}
return sum;
}
}

The time complexity of the above code is?

time-complexity space-complexity algorithms normal


Selected Answer

Answer is O(2n )

The last cn is for the n times the for loop is executing.

T(0) = 1
T(1) = 2
T(2) = 5
T(3) = 11
T(4) = 23
T(5) = 47

So,

T(n) = 2n + 2n −1 − 1 = O(2n )

 7 votes -- Arjun Suresh ( 124125 points)

1.158 Spanning Tree: Calculation of the number of spanning trees top gateoverflow.in/30141

Hi,I just encountered problems about calculation of the number of spanning trees,like this one:

http://gateoverflow.in/10154/find-out-the-no-of-spanning-tree-possible

I am able to proceed to choose the number of edges.But I am unable to understand the calculation of the number of cycles
to subtract.Can anyone help me in understanding the same?Also,Kirchoffs theorem leads to calculation of large determinants

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 99 of 2244

for such problem,which is not feasible.Are you aware of any other method to do the same?

spanning-tree

1.159 Spanning Tree: Minimum cost spanning tree top gateoverflow.in/5100

Please explain why the answer is a)

algorithms spanning-tree

Ans: because we have given wavy edges form MST So, for verification of option A we have to check that with MST how
many cost to reach at a->b then we will get a->e->d->b = -2+5+3 = 6 so in given option a with cost(a,b)>= 6 this is
posible coz , cost equal then we can reach at a to b with that edge but we don't consider that edge while making MST so
cost must be >6 not equal to 6 so option A is Need Not HOLD. Like wise if you check for other option then enequality is
holding...

 0 votes -- Jayesh Malaviya ( 1075 points)

1.159 Stack: evaluation of prefix expression takes O(n^2)....true? top gateoverflow.in/20715

stack

considering n as length of expression

now lets evaluates and follow this algo:

begin :

count=0; one stack/array;

add to stack if it operator or increment count if operand

now if count==2 pop top two elements and top operand and make count=0

apply operation and push the result into stack and increment count

end:

apply his algo on

this prefix: -++xyzl

stack:: - + + x count=1

- + + x y count=2 and now pop xy and + add them letrs say m=x+y

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 100 of 2244

- + m push z - + m z

now pop and add them as above y=m+z and put it back on stack

- y l

and thus complexity is O(n)

 0 votes -- admin ( 1411 points)

1.160 Testbook: TestBook Live Test 2 Question 21 Algo top gateoverflow.in/36720

test-series testbook algorithms sorting

A. insertion sort - gives time complexity of O(n^2)

B. Quick sort - Ads the array is in reversed order, it is worst case for it, so time complexity O(n^2)

C. Merge sort - time complexity is O(nlogn), but takes additional time for unnecessary division.

D. Heap Sort - complexity O(nlogn). (Answer)

 0 votes -- Abhijit Pal ( 11 points)

1.161 Testbook: TestBook Live Test 1 Q No 20 top gateoverflow.in/36122

I got that Statement 3 can be false in case we have function 1/n, then its square become 1/n^2. But I don't think statement
2 is true either. Please prove whether I'm correct or wrong.

test-series testbook algorithms time-complexity

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 101 of 2244

1.162 Time: Madeeasy top gateoverflow.in/33898

Which of the following is true?

a. f(n) = O (f(n))2 ( )
b. f(n) = O(g(n)) ⇒ 2f (n ) = O 2g (n ) ( )
c. f(n) + O(f(n)) = θ(f(n))
d. Both (a) and (b)

time time-complexity asymptotic-notations


Selected Answer

Both a and b are false for decreasing functions like n .

Option C is always true.

 2 votes -- Arjun Suresh ( 124125 points)

1.163 Time Complexity: How to solve this series ? top gateoverflow.in/31730

How to Solve series like this

n(n-1)+ (n-1)(n-2) + (n-2)(n-3) + ...........

time-complexity


Selected Answer

n(n − 1) + (n − 1)(n − 2) + (n − 2)(n − 3) + . . .

n(n − 1) + (n − 1)((n − 1) − 1) + (n − 2)((n − 2) − 1) + . . . . .

= n2 − n + (n − 1)2 − (n − 1) + (n − 2)2 − (n − 2) + . . .

= (n2 + (n − 1)2 + (n − 2)2 + . . . ) − (n + (n − 1) + (n − 2) + . . . )

n (n +1 ) (2n +1 ) n (n +1 )
6 2
= −

n (n 2 −1 )
3
=

Note:

n (n +1 )

∑ni=1 i = 2

n (n +1 ) (2n +1 )

∑ni=1 i2 = 6

 8 votes -- Praveen Saini ( 34299 points)

1.164 Time Complexity: Time complexity top gateoverflow.in/31698

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 102 of 2244

Why [logn]! is not polynomial bounded where [loglogn]! is polynomial bounded? Note [ ] is greatest integer function

time-complexity

1.165 Time Complexity: time complexity top gateoverflow.in/26889

int fun(int n)
{
int count = 0;
for (int i = n; i > 0; i /= 2)
for (int j = 0; j < i; j++)
count += 1;
return count;
}
what is the time complexity

time-complexity


Selected Answer

i =n n/2 n/4 n/8 ....................logn times


j=n n/2 n/4 n/8 ...........logn tmes

T(n) = n+ n/2 + n/4 + n/8 + ...........logn time


= n(1+ 1/2 + 1/4 + .............logn times) Decreasing GP
=O(n)

 0 votes -- Umang Raman ( 10379 points)

1.166 Time Complexity: What will be the time complexity of recurrence


relation T(n)=2T(n-1)+c using substitution method? top gateoverflow.in/32159

Where c is constant.

time-complexity algorithms


Selected Answer

I am getting Θ (2^n) .

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 103 of 2244

 4 votes -- Riya Roy ( 4767 points)

1.167 Time Complexity: What is the order top gateoverflow.in/31622

a) Order of finding k th Root ( express in terms of k and n where k represent 3 for cube root , n represent size of input )

algorithms time-complexity

1.168 Time Complexity: Find the order of val(j) top gateoverflow.in/31631

n n n

Q1 ) j = 2 + 4 + 8 + ....... + 1 = O ( ?? )

1 1 1

Q 2 ) j = 1 + + + 4 +..... = O ( ?? )
2 3

Q3 )

while ( i=n >0)


{
j=i/2
i--
}
Q4)

While (i=0 <= n)


{
j=i*2
i++
}
Q5

while ( i=n >0)


{
j=j+i
i=i/2
}

time-complexity algorithms

1. O(n)
2. O(log n)
3.O(n)
4.O(n)
5. O(log n)

 1 votes -- Sumit Joshi ( 21 points)

1.169 Time Complexity: Below is the Question, Can anyone explained it in a


detailed way?? top gateoverflow.in/32922

Consider the following c code :

int f(int x)

{ if(x<1) return 1;

else return f(x-1) + g(x);

int g (int x)

if(x<2) return 1;

else return f(x-1)+g(x/2);

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 104 of 2244

Of the following, which best describes the growth of f(x) as a function of x?

a) logarithm b) quadratic

c) linear d) exponential

time-complexity

It is exponential only.

recurrence functions will look like

f(n) = f(n-1) + g(n)

g(n) = f(n-1) + g(n/2)

When you are calling f(n), if you will draw a tree it will be at least n level tree on left most and (log n) level tree on right most.

if you want to take upper bound then take the maximum level possible and assume the tree to be complete binary tree in worst case so this way, there will be
O(2^n) function call. In each fn call takes constant time so time complexity will be O(2^n) i.e exponential.

 0 votes -- Sandeep Singh ( 5939 points)

1.170 Time Complexity: Below is the question - top gateoverflow.in/33233

The time complexity of computing the transitive closure of a binary relation on a set of n elements is know to be a -

1) O(n) 2) O(nlogn)

3) O(n3/2) 4) O(n 3)

time-complexity

Ans : O(n3)

Transitive closure of relation can be represented using directed graph. And in that graph ,using Floyd-Warshall
algorithm,one can find out transitivity in time complexity of O(n3)

 0 votes -- Shashank Kumar ( 2029 points)

1.171 Time Complexity: Time complexity top gateoverflow.in/30064

Consider the code


j = n ;

while (j >= 1){

for (i = 1 to j )

x = x + 1 ;

j = n/2 ;

}
What is the time complexity?

O(nlogn)
O(n logn)
O(n )

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 105 of 2244

None of the above

time-complexity

if n>=1
then j will never change and always be true.

so i will run every time j =n/2 time


so it will be infinte loop program will run till stack overflow.

 1 votes -- Umang Raman ( 10379 points)

1.172 Time Complexity: TestBook Test Series Algo Q top gateoverflow.in/34313

Q). What is the complexity of finding the 50th smallest elements in an already constructed binary min-heap?

1. θ(1)
2. θ(logn)
3. θ(n)
4. θ(nlogn)

solution:

Exact complexity would be 50logn for heapify when we do heap sort iteration 50 times

test-series algorithms time-complexity


Selected Answer

I think answer for this question should be O(1).

We need to find 50th smallest integer in min heap. Which can be easily done by checking first 2 50 no in arrays (Checking
first 50 levels of heap !) . It does not depend on size of heap. We can have min heap of size n = 2^250000000000still no of
comparisons is fixed. It does not change with no of elements in heap.

 1 votes -- Akash ( 26315 points)

1.173 Time Complexity: Increasing Growth order top gateoverflow.in/36049

algorithms time-complexity

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 106 of 2244

1.174 Time Complexity: Made Easy FLT 5 Question 19 top gateoverflow.in/29360

Q.19

Consider the following function.

What is the worst case running time of the function f for any positive value of n?

O(1)
O(n)
O(n2)
O(n3)

made-easy algorithms time-complexity


Selected Answer

Outer loop is run 100 times only. so max O(n2).

two loop run

for 100 times.


for( j=0 ; j<n ;k++)

for( j=0 ; k<j ;k++)

 3 votes -- Anirudh Pratap Singh ( 4091 points)

1.175 Time Complexity: Finding complexity in case ratio of two compexity is


constant. top gateoverflow.in/28970

f (n )
g (n )
Given two positive functions f(n) and g(n). If = c, for some constant c ≥ 0 and c is non-negative but not infinite then
which of the following is correct?

f(n) = O(g(n))
f(n) = θ (g(n))
f(n) = Ω (g(n))
None of these

------------------------------------------------------------------------------------------------------------------------------------------------

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 107 of 2244

-------------------

Here I strongly believe that Answer should be the f(n) = θ (g(n)). Other two are correct, but this is strongest statement !

As f(n) / g(n) = constant is only possible if they are of same order.

In that case they are both upper & lower bounds of each other !

Q 47

From Made Easy FLT 6-Practice Test 14

algorithms time-complexity

IT seems here I made mistake in analysis.

Here c = 0 is possible as pointed out by @Amar Sokt !

In that case f(n) can be 0, & in that case g(n) is always bigger than f(n).g(n) = 0 is not allowed, otherwise whole thing will
go to infinity & it is said c can not be 0.

f(n) = θ (g(n)) will be false. As g(n) will not be lowerbound of f(n).

So A is correct answer.

 0 votes -- Akash ( 26315 points)

1.176 Time Complexity: Asymptotic notations top gateoverflow.in/27980

The increasing order of following functions in terms of asymptotic complexity is:

f1 (n) = n0.999999logn / /logn is not power of nf2 (n) = 10000000 ∗ nf3 (n) = 10000000n f4 (n) = n2

(a) f1(n); f4(n); f2(n); f3(n)


(b) f1(n); f2(n); f3(n); f4(n)
(c) f2(n); f1(n); f4(n); f3(n)
(d) f1(n); f2(n); f4(n); f3(n)

algorithms time-complexity


Selected Answer

Incorrect Solution:

critical problem in this question is to find out which is greater between f1 and f2 , for that purpose we take log on both functions:

for f1 :

loglogn + 0.999999logn

for f2 :

logn + log107

in f1 we are adding a non-constant entity but that's not the case with f2 . Hence, f1 is greater.

we get answer = option C like this. BUT this is FALSE. Even after taking log we cannot deduce a meaningful conclusion coz Product terms
cannot be ignored, See discussion in comments below.

So, a more robust approach is to see mathematically what happens when n → ∞

Correct Solution:

let us assume that 0.999999 = 0.5, just to make things simple, it is a constant & also a fraction so it will continue to maintain its nature
during this process, so this move is ok. Now, we have:

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 108 of 2244

f1 (n) √nlogn
n →∞ 2
| |
lim f (n) lim
= n →∞ n

1 log n
√n 2 √n
+
lim
= n →∞ 1
2 + logn
lim 2√ n
= n →∞
1

0+ n
1
lim 2 √n
= n →∞ 2 ×
1
lim n
= n →∞

=0

since, at n → ∞ shows that the value of the expression = 0 this means that for sufficiently large n the denominator has to be a much bigger
value that is making the expression = 0. So, f2 is asymptotically bigger.

Hence, answer = option D

 2 votes -- Amar Vashishth ( 17865 points)

1.177 Time Complexity: complexity comparison of heap sort,quick sort and


merge sort !! top gateoverflow.in/34635

Q:- which one is the best among heap sort ,quick sort and merge sort in terms of complexity ? please answer with explanation!!

algorithms time-complexity

1.178 Time Complexity: what is the time complexity top gateoverflow.in/29566

algorithms time-complexity

f(n) is greater than n.

g(n) is grater than n 2

f(n) +g(n)= max (f(n),g(n)) = lower bound n 2

 0 votes -- Anirudh Pratap Singh ( 4091 points)

1.179 Time Complexity: Question on time complexity top gateoverflow.in/36375

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 109 of 2244

Given answer is B. I believe that is should be D. Please check

algorithms time-complexity

1.180 Time Complexity: Find time complexity of following code: top gateoverflow.in/33406

time-complexity algorithms

This question can be solved by taking first some initial values of k={1,2,3,4,5.....} and then using the coming relation find
out the relationship between k and n.

for k=1 ,n will be 4 so i will iterate for 4 times(ie..,n times) and j=2 and each time incrementing in terms of square(j). so j
will be 2 and 4 i.e., pf will be printing 2 times for each i thus it will be printed total of n*2.

for k=2 ,n will be 16 so i will iterate for 16 times(ie.. n times) and j=2 and each time incrementing in terms of square(j).

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 110 of 2244

so j will be 2 and 4 and 16 i.e., pf will be printing 3 times for each i thus it will be printed total of n*3.

for k=3 ,n will be 256 so i will iterate for 256 times(ie.. n times) and j=2 and each time incrementing in terms of
square(j). so j will be 2 and 4 and 16, and 256 i.e., pf will be printing 4 times for each i thus it will be printed total of n*4
or(n*(3+1)).

for k=k times , it wil be executing n*(k+1) times

n= square(square(k))

log n= square(k) (base 2)

or k= log log (n).

time complexity will be O(log log (n)) for each n and thus printing will be done =n *(K+1)=O(n*k) =O(n*log*log (n))

 2 votes -- Anirudh Pandey ( 343 points)

1.181 Time Complexity: Fill the complexity table and correct mistakes if any
top gateoverflow.in/30554

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 111 of 2244

worst
name best avg space work soace

Min max 1 3n/2-1 3n/2-1 c + n + log log n


n

N3
Matrix multiplication N3 N3

Merge Sort ( Top c+ n + n +


n log n n log n n log n n+ log n
Down ) logn

Merge Sort ( Bottom


n log n n log n n log n c+ n+ n n
Up )
nlog 2 7
Strassens

n2
Integer
multiplication

n1.58
Anatolli karatsuba logn

nlog k (2k-1)
Toom and cooks

n2
quicksort n log n n log n logn

log n (
complete
Binary Search 1 log n tree ) n+ logn log n
n ( skewed
Tree)

time-complexity algorithms

1.182 Time Complexity: Comparing Time complexities top gateoverflow.in/26927

Consider the following functions:

n 4/3
n
F(n) = G(n) = 22

2
H(n) = 2n I(n) = n!

J(n) = 2n

Which of the following is True?

A. F(n) = Ω G(n) ( )

B. G(n) = O H(n) ( )

C. F(n) < J(n) < I(n) < G(n) < H(n)

D. I(n) = O H(n) ( )

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 112 of 2244

time-complexity algorithms


Selected Answer

Answer is Option D.

Function Taking log

F(n) = n 4 / 3 (
Θ logn ) 3
is a const.

G(n) = 2 2
n
( )
Θ 2n

H(n) = 2 n
2
( )
Θ n2

I(n) = n! (
Θ nlogn ) Striling ′ s
Approximation

J(n) = 2 n ()
Θ n

Now, we can use the standard ordering.


(a, b, c, k are constants)

Logarithms grow much slower than polynomials. logkn ≪ n


Polynomials are ordered based on their order. na ≤ nb  a ≤ b
When there is a mixture, we can simply divide by common factor to order 2 functions. So, n < nlogn because 1 < logn
Exponentials grow crazy fast! nc ≪ kn

Using this, we can obtain the following ordering:

F(n) < J(n) < I(n) < H(n) < G(n)

Thus, we have that I(n) = O H(n) ( )

 4 votes -- Riya Roy ( 4767 points)

1.183 Time Complexity: Order of growth top gateoverflow.in/35015

Arrange the following functions in ascending order according to their order of growths.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 113 of 2244

f1 = 100000 ⋅ n

f2 = 30 ⋅ n2

f3 = (logn)200

f4 = 2n

f5 = n ⋅ logn

time-complexity algorithms


Selected Answer

f1 (linear) < f5 (log linear * linear) < f2 (quadratic) < f4 (exponential)

16
( )
Now, f3 is actually growing smaller than n. For example, take n = 22 = 265536 , log2 n200 = 216
200
= 23200.For all larger n, f3 has
lower value than n. (This is true for lognk for any constant k. So,

f3 < f1 < f5 < f2 < f4.

 3 votes -- Arjun Suresh ( 124125 points)

1.184 Time Complexity: Maximum depth of recursion tree top gateoverflow.in/26935

Given answer: C
Please explain

algorithms time-complexity

Since there are n sorted lists of size n the no of elements is n 2 .

At depth k suppose the division would be like n 2 / (2k) which should be equal to the size of list at that time . According to
the question it is given as n.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 114 of 2244

Hence answer is Option C.

 3 votes -- Riya Roy ( 4767 points)

its log2 n.. like

at last level u have n list combine two into pair so

at 2nd last level = n/2 ...

at 3rd level = n/2 2

at one level 1 list.

take sum u will get log 2n

 1 votes -- Anirudh Pratap Singh ( 4091 points)

1.185 Time Complexity: Fill the Complexity Table From Greedy Strategy top
gateoverflow.in/30555

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 115 of 2244

Problem Solution Space Complexity Space


Job Sequencing with deadline 2n n2 n


Knapsack - Binary 2n
Knapsack - Real infinty

Optimal Merge Pattern n ! n2 (linear list)


n logn (Non-Linear)

n2 (conventional)
Prims Algorithm nn
n+e log n (heap)

Kruskal e log n
Dijikstra n2
Bellman-Ford ne

time-complexity algorithms

1.186 Time Complexity: Time comlexity=? top gateoverflow.in/17923

main()
{
for(i=1;i<=n;i++)
{
for(i=1;i<=n*n;i++)
{
for(i=1;i<=n*n*n;i++)
{
x=y+z;
}

}
}
}

time-complexity


Selected Answer

0(n^3) because the internal loop runs n^3 times and now it does not satisfy the condition of 1st and 2nd loop so it comes
out of the loop

 0 votes -- Saurav Kumar Gupta ( 1455 points)

1.187 Time Complexity: What is the growth function of every case (a-d)? top
gateoverflow.in/4624

a)

for(i = 1; i*i <= N; i = 2*i);

b)

for(i = 1; i <= N; i = 2*i);


for(j = 1; j <= i; j = j+1);

c)

for(i = 1; i*i <= N; i=i+1);


for(j=1; j <= i ; j=j+1);

d)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 116 of 2244

for(i = 1; i*i <= N; i=i+1)


for(j = 1; j <= i ; j = 2*j);

time-complexity


Selected Answer

Using lg for log 2

(a)

for(i = 1; i*i <= N; i = 2*i);

i is multiplied by 2 in each iteration and stops when equals √N. So, loop will run for lg (√N) times and time complexity =
Θ(lg(√ N))

(b)

for(i = 1; i <= N; i = 2*i)


for(j = 1; j <= i; j = j+1);

Outer loop runs for lg(N) times. For each i, Inner loop runs for i times. So, total number of iterations

= 1 + 2 + 4 + 8 + ... N (Sum to N terms of GP with a = 1, r = 2, and number of terms = log n)


= Θ(N)

(c)

for(i = 1; i*i <= N; i=i+1)


for(j=1; j <= i ; j=j+1);

The outer loop runs for √N times. For each i, the inner loop runs i times. So, number of iterations

= 1 + 2 + ... + √N

= √N * (√N+1) /2 = Θ(N)

(d)

for(i = 1; i*i <= N; i=i+1)


for(j = 1; j <= i ; j = 2*j);

The outer loop runs for √N times. For each i the inner loop runs lg i times. So, total number of iterations

= lg 1 + lg 2 + lg 3 + ... lg √N
=lg (1 * 2 * 3 * ... *√N)
=lg ((√N)!)
= Θ(√Nlg√N) using Stirling's approximation)
http://mathworld.wolfram.com/StirlingsApproximation.html

 1 votes -- Arjun Suresh ( 124125 points)

1.188 Time Complexity: What is the worst case time complexity of this
function? top gateoverflow.in/14419

int fun(int n)
{
int count=0;
for (int i= n; i> 0; i/=2)
for(int j=0; j< i; j++)
count+= 1;
return count;
}

algorithms time-complexity data-structure programming programming-in-c

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 117 of 2244


Selected Answer

Outer loop executes logn times ...

For i = n, inner loop will execute n times.

n n

For i = 2 , inner loop executes 2 times. And so on...

n n

count+=1 statement is in the inner loop, and will be executed n + 2 + 4 + … + 1 times.

Solving,
n n
2
n+ + 4 +…+1

log n terms

1 − (1 / 2 )log n
1/2
=n⋅ (using GP, first term = 1 and common ratio = 1/2)

= 2n(1 − n ) = 2n − 2

complexity = O(n)

 5 votes -- Pooja ( 22773 points)

The worst case time complexity of this function is O(n)..... the outer loop iterates for O(logn) as the value of n is changing
like this.....n,n/2,n/4......1(assuming n is power of 2). Therefore say the ith term will be n/2^(i-1)...now equating this to 1
we get i as O(logn). Hence the number of iterations of the outer loop(the total number of terms in the series) is O(logn).
Now for each iteration of the outer loop the inner loop is iterating depending on the value of i i.e for 1st iteration of outer
loop inner loop is iterating n times, for 2nd iteration of the outer loop inner loop is iterating n/2 times ..like..this.
Therefore the total time complexity becomes ...n+n/2+n/4+.....+1(assuming n power of 2)......therfore, its the sum of
g.p series with logn number of terms in it....hence the sum becomes 1.(2^(logn)-1)/(2-1)...which equates to O(n)...

 3 votes -- debanjan sarkar ( 775 points)

1.189 Time Complexity: Complexity top gateoverflow.in/37748

Consider two natural-valued functions f : N → N and g : N → N . Which of the following statements cannot be true?

f ∈ O(g) and g ∈ O(f )


f ∈ Θ (g) and g ∈ Θ (f )
f ∈ Ω (g) and g ∈ Ω (f )
f ∈ O(g) but g ∉ Ω(f )

time-complexity

1.190 Time Complexity: find timecomplexity top gateoverflow.in/4622

Algorithm Power(n)
Pre: n :: Integer, n > 0
i = 1
while (i < n)
print i
i = i * 3
done

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 118 of 2244

time-complexity


Selected Answer

In each iteration i is multiplied by 3. So, the loop will iterate log 3 n times and O(log n) is the complexity.

 4 votes -- Arjun Suresh ( 124125 points)

1.191 Time Complexity: timecomplexity top gateoverflow.in/4560

for(int i=0; i<n; i++)


for(int j=i+1; j<n; j++)
for(int k=j+1; k<n; k++)

time-complexity


Selected Answer

Counting the number of times the inner most loop gets executed equals,

n-2 + n-3 + n-2 + ....1


+n-3 + n-2 + .... + 1
+
...
+ 3 + 2 + 1

= (n-2)(n-1)/2 + (n-3)(n-2)/2 + ... + 3*4/2

= (n2 - 3n + 2 + n 2 - 5n + 6 + .... )/2

= O(n3) as there are n terms and n 2 is the dominating term in each of them.

 2 votes -- Arjun Suresh ( 124125 points)

1.192 Time Complexity: Time complexity? top gateoverflow.in/4550

We are given a sequence of n nos. a1, a2, a3,.......an, we will assume that all the nos. are distinct. We say two indices i < j
form an inversion if ai > aj .

How much time will it take to find total no. of inversions in the given array?

a) O(n 2) b) O(nlogn) c) O(n) d) none of these

algorithms time-complexity


Selected Answer

Take array as: 4 1 5 3 2

Sorted: 1 2 3 4 5

Number of inversions:

for 1: 1 (how many numbers larger than 1 are on the left side of 1 in initial array)
for 2: 3
for 3: 1
for 4: 0
for 5: 0

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 119 of 2244

So, total inversions = 1+3+1 = 5.

Now, given the initial array and the final sorted array we can get the number of inversions for an element at position i in
the initial array and position j in sorted array as max(i-j,0). So, we can find the number of inversions in an array by
sorting the array. Similarly, we can also say that if we are given all the inversions in an array (to count we need to find an
inversion), we can very well sort the array. So, the complexity of finding the total no. of inversions in an array should be
same as complexity for sorting the array- O(nlogn)

http://stackoverflow.com/questions/21933717/counting-number-of-inversions-in-an-array

 3 votes -- Arjun Suresh ( 124125 points)

1.193 Time Complexity: time complexity for nestedloops top gateoverflow.in/4558

for(i=1;i<=n;i++,x=1)
{
for(j=1;j<=i;j++)
{
for(k=1;k<=j;x+=a,k*=a)
{
}
}
}

find time complexity?

algorithms time-complexity

It can be solved same like here, and we will get O(n 3)

http://gateoverflow.in/4560/timecomplexity

 0 votes -- Arjun Suresh ( 124125 points)

1.194 Time Complexity: The time complexity of producing a sorted list? top
gateoverflow.in/16103

Suppose there are logn sorted lists and each list contains n/logn elements. The time complexity of producing a sorted list of all
these elements is (using merge algorithm)?

algorithms time-complexity

please tell someone what is wrong in this..

assume that there are k sorted files and each file contain n/k elements.To sort all these k files in to a single files we use merge algorithm that is first merge file1 and file 2 and later
resultant file will be merged with third file continue this process until all files are merged.and we know that time taken for merging two sorted files of length m and n is O(m+n).

since we are merging two files of length n/k so it takes O(n/k+n/k)=O(2n/k)

merging resultant file with third file takes O(2n/k+n/k)=O(3n/k)

continue this process then total time complexity=

O(2n/k)+O(3n/k)+O(4n/k)+O(5n/k)+-------------------+ O(kn/k)

=O(n/k)(2+3+4+5+6+----------------------+k)

=O(n/k)(k(k+1)/2)

=O(nk)

here k=logn

time complexity=O(nlogn)

 0 votes -- ajit ( 1369 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 120 of 2244

1.195 Time Complexity: Time Complexity top gateoverflow.in/43789

What is the complexity of the following code?



i = n
while (i>=1){
for j = 1 to n
x=x +1
i = i/2
}

a. Θ(n)
b. Θ(log2 n)
c. Θ(n/log2 n)
d. Θ(nlog2 n)

time-complexity


Selected Answer

The outer while loop runs logn times because every time n is getting divided by 2 ie {n/2 , n/4 , n/8 , ......1 }

For every iteration of outer loop inner loop runs n times .

Therefore the complexity is Θ(nlogn)

Ans : Option D.

 3 votes -- Riya Roy ( 4767 points)

1.196 Time Complexity: Time complexity top gateoverflow.in/42371

Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.time complexity using DAC ??.

time-complexity

1.197 Time Complexity: daa top gateoverflow.in/39229

Q). Consider the following functions are

f(n) = 3n√ (n )

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 121 of 2244

g(n) = 2√ (n ) logn2

h(n) = n!

Which of the following option is true?

(A) f(n) is O(g(n))

(B) h(n) is O(g(n))

(C) g(n) is not O(f(n))

(D) h(n) = O(f(n))

time-complexity

Option D. we can also prove it by saying that all other options are false

 0 votes -- Sreyas S ( 1353 points)

1.198 Time Complexity: What is the time complexity ? top gateoverflow.in/10485

time complexity question

Sum=0
for(i=1; i<=n;i++)
{
for(j=1;j<=i;j++)
{
if(j%i==0)
{
for(k=1;k<=n;k++)
{
sum=sum+k;
}
}
}
}

algorithms time-complexity

for each i value j loop running i times and k loop n times..


total no of time j loop running is sum of i natural no .
for i = 1 j loop 1 times
for i = 2 j loop 2 times
for i = 3 j loop 3 times
.
.
for i = n j loop n times
total = 1+2+3+4+.....+n
= O(n*n)
for each i , k loop ll executes n times.
complexity = O(n*n) + n*O(n)
= (n*n)

alternatively :
complexity = 1<i<n { summation of (i + n } // for each i (j loop running i times and k loop n times
=O(n*n) +n*O(n)
= O(n*n)

 3 votes -- Digvijay Pandey ( 26245 points)

i=1

J=1 time

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 122 of 2244

K=n time

i=2

j=1,2(2time)

k=n time

i=3

j=1,2,3(3 time)

k=n time

i=4

j=1,2,3,4(4 time)

k=n time

i=5

j=1,2,3,4,5( 5 time)

k=n time

i=6

j=1,2,3,4,5,6,(6 time)

k=n time

i=7

j=1,2,3,4,5,6,7(7 time)

k=n time

….

i=n

j=1 ton

k=n time

T(n)=n+n+n+………n times

=n* n

=O(n^2)

 1 votes -- Anu ( 6731 points)

1.199 Time Complexity: Algorithms top gateoverflow.in/41154

Given n linearly ordered distinct elements. What is the worst case running time to find i th smallest element (1<=i<=n) from
those n elements?

a) O(log n)

b) O(n)

c) O(n log n)

d) O(n2)

algorithms time-complexity

The worst case for this would be to traverse the array from i = 1 to n and stop when you've found the number equal to or

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 123 of 2244

greater than the number you're searching for.

Time Complexity: O(n)

 0 votes -- Sona Praneeth Akula ( 3473 points)

1.200 Time Complexity: Time complexity of a while loop top gateoverflow.in/11035

Assuming n>2

A()

while(n>1)

n = n/2;

algorithms time-complexity


Selected Answer

T(n) = T(n/2) + c , // c is constant

Solve recurrence by Master method or recursive tree method..

Complexity will be logn ..

 4 votes -- Digvijay Pandey ( 26245 points)

log n

 1 votes -- kaushal ( 41 points)

1.201 Time Complexity: The Solution to the recurrence is : top gateoverflow.in/26665

algorithms time-complexity


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 124 of 2244

Option B must be the right answer.

2k

2k−1 = 2

So the given recurrence can be written as

()
2k

T ( ) = 3T
2k 2
+1

Now let 2k = n then our recurrence will look like

T(n) = 3T 2
() +1

We know that any constant is bounded by Θ(1), so 1 = Θ(1) & We get the recurrence :

T(n) = 3T 2
() + Θ(1)

This recurrence can be solved by by Master Theorem or Recurrence Tree Method.

Solution to this recurrence will be Θ nlog2 3 . ( )


On putting back n = 2k the solution to this recurrence will be Θ 2k⋅log2 3 . ( )
( )
Now using the property p ⋅ logxy = logxyp of logarithms we get

(
Θ 2log2 3 .
k
)
( )
Using the property plogp q = q of logarithms we get

( )
Θ 3k as our final solution to this recurrence.

Now Theta is something more than Big Oh, That is

( ) ( )
Θ 3k = O 3k and Ω 3k . ( )
( )
Hence Option B i.e. O 3k will be the correct answer.

 2 votes -- Anurag Pandey ( 8183 points)

1.202 Time Complexity: Find Time complexity top gateoverflow.in/13770

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 125 of 2244

algorithms time-complexity

1) 1^2+2^2+3^2+.......n^2= n(n+1)(2n+1)/6

So it's O(n^3)

2) 1+1/2+1/3+......1/n =log no

So it's O (log n)

3)1/2+1/4+1/8+.... 1/2^n

4) x+x^2+x^3+.......x^x

​Here dominating term is x^x so it O( x^x)

5) x+2x+...... To infinity

Here O(infinity)

6) for n! it's order of O(n^n)

Log n! = O of Log n^n and ( log n!)! = O((log n^n) ^ log n^n)

I'm not sure about 3 and 6

 1 votes -- Pranay Datta ( 6113 points)

1.203 Time Complexity: Algorithms top gateoverflow.in/41955

Consider the following code fragment

for i=1 to n/2 do


for j=i to n-1 do
for k=1 to j do
output ''foobar''

Assume n is even Let T(n) denote the number of times 'foobar' is printed as a function of n.

a. Express T(n) as three nested summations.


b. Simplify the summation. Show your work.

time-complexity


Selected Answer

a. T(n) = ∑ni =1
/ 2 n −1 j
∑j =i ∑k=1 1

The 1 is used for constant no. of operations. We can also use c for it.

1 1

b. ∑ni =1
/ 2 n −1 j
∑j =i ∑k=1 1 = ∑ni =1
/ 2 n −1
∑j =i j = 2
∑ni =1
/2
(n − 1)n − i(i + 1) = 2 ∑ni =1
/2 2
n − n − i2 − i

n3

We need not solve further as the first term itself gives our answer which is 4 = Θ n3 . ( )
n . (n +1 )

PS: In the summation formula for the sum of first n natural numbers
( 2
) and the sum of the squares of first n

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 126 of 2244

n . (n +1 ) . (2n +1 )

natural numbers ( 6
) are used.

 2 votes -- Arjun Suresh ( 124125 points)

1.203 Time Complexity: why we use log2 n otherthan log10 n in computer


science algorithums (calculating time complexities top gateoverflow.in/12641

algorithms time-complexity

https://en.wikipedia.org/wiki/Binary_logarithm

 1 votes -- Rohan Ghosh ( 1515 points)

1.204 Time Complexity: TIME COMPLEXITY top gateoverflow.in/4543

int fun(int n)
{
int count=0;
for(int i=n; i>0; i/=2)
for(int j=0; j<i; j++)
count += 1;
return count ;
}

algorithms time-complexity


Selected Answer

Outer loop runs log2 n times.

For i = n, inner loop runs n times.

For i = n/2, inner loop runs n/2 times.

For i = 1, inner loop runs 1 time.

So, overall, the inner loop runs for

T(n) = 1 + 2 + 4 + 8 + … + n times.

This is a Geometric Progression, which can be written as:

T(n) = 1 + 2 + 4 + 8 + … + n = 2n − 1 = O(n)

Hence, option C is correct.

 2 votes -- Pooja ( 22773 points)

for(int i=n; i>0; i/=2) -------------L1


for(int j=0; j<i; j++)------------L2

L1 stops when (n/2 k=1)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 127 of 2244

or k=log 2n

L2 iterrates total = n + n/2 + n/2 2 + ... + n/2 log 2n (for log2n time) (it is finite series)

=n 1. ( (1- 1/2 log 2n)/(1-1/2))

=n x ( (1-1/n) / (1/2) )

= 2n-2

So it is O(n) ...

 1 votes -- Palash Nandi ( 1373 points)

The outer loop iteration variable i is halved in each iteration. The inner loop will execute i times for each iteration of the
outer loop. So, the

count += 1;

statement, which is the most repeated one and hence the one contributing to time complexity will be done

n + n/2 + n/4 + .... 1 times, which is a GP and we can approximate it as an infinite GP, so the summation will be a/(1-r),
where a is the first term and r is the common ratio.

n/(1-1/2) = 2n = O(n)

 1 votes -- Arjun Suresh ( 124125 points)

1.205 Time Complexity: Time Complexity top gateoverflow.in/4696

i=0
for(i=1;i<=n;++i)
for(j=1;j<=i*i;++j)
if((j%i)==0)
for(k=1;k<=j;++k)
c=c+1;

find time complexity of these program?

algorithms time-complexity


Selected Answer

(The third loop executes only when j%i == 0, which will be true for j = i, 2i, 3i, ... i*i. i.e., it also executes i times. )

We have to count the number of times the statement c = c + 1; is executed.

the outer i loop executes from 1 to n.

for i = 1, 2, 3, 4, ... n

the k loop will execute for

1, 2 + 4, 3 + 6 + 9, 4 + 8 + 12 + 16, ... ,n + 2n + 3n + ... n 2

So, we have to count the iterations for k, which will give


n +1 i +1

∑ni=1 ∑ij =1 j × i = 1 + 6 + 18 + 40 + . . . + n × n × 2 = ∑ni=1 i × i × 2 = O(n4 )

(We can assume the sum to the cubes of first n natural numbers)

 3 votes -- Arjun Suresh ( 124125 points)

I am not sure but see what we get.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 128 of 2244

i = 1 | 2 | 3 | 4 | 5 | 6 ........................n

j = 1t | 4t | 9t | 16t | 25t |36t.................n^2t. (t represent times)

k = 1 | (2t 4t) | (3t 6t 9t) | .................................

seeing just last value in every set we have

n(1 + 4 + 9 + 16 +...............n^2) + some constant

which is O(N4).

 1 votes -- Arpit Dhuriya ( 1791 points)

1.206 Time Complexity: T.C of T(n)=2T(n-1)+n,n >1 ,T(1)=1 ? top gateoverflow.in/19033

T.C of T(n)=2T(n-1)+n,n > 1 ,T(1)=1 ?

time-complexity


Selected Answer

T(n) = 2T(n) + n = 22 T(n − 2) + 2(n − 1) + n = 23 T(n − 3) + 22 (n − 2) + 2(n − 1) + n. . . = 2n −1 T(n − (n − 1)) + 2n −2 (n − (n − 2)) + 2n −3 (n − (n − 3)) + … + 2(n − 1
→ (1)

Now multiply T(n) By 2

2T(n) = 2n + 2n −1 .2 + 2n −2 .3 + … + 22 (n − 1) + 2n → (2)

Now
(2 n −1 )

(2) − (1)  T(n) = 2n + 2n −1 + 2n −2 + 2n −3 +…+ 22 +2−n= 2n + 2n −1 + 2n −2 + 2n −3 +…+ 22 + 2 − n = 2. (2 −1 ) (Sum to n terms of GP with a = r = 2) − n

Alternatively,

T(1) = 1
T(2) = 2.1 + 2 = 4
T(3) = 2.4 + 3 = 11
T(4) = 2.11 + 4 = 26
T(5) = 2.26 + 5 = 57
T(6) = 2.57 + 6 = 120

T(n) = 2n +1 − (n + 2)

 1 votes -- Umang Raman ( 10379 points)

1.207 Time Complexity: Time Complexity top gateoverflow.in/19698

I have one doubt. Like we say some program have BigO(N3). So it is right to say that same program can have
BigO(N4) or BigO(N5) or any more than cubic. What i think is we can only say it with small O notation not big O
because if some procedure will have order of cubic polynomial how it can reach more higher order polynomial
with just multiplication of constants.

Same doubt for Omega

time-complexity

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 129 of 2244

It feels like you haven't read these topics from any standard book. Honestly, have you?

( )
O n3 is the set of all functions whose growth is upper bounded by n3 . What are some such functions?
f(n) = logn, g(n) = 61n3 / 2 , h(n) = 9n3 , ϕ(n) = (n/logn) are some of them.

( )
When we say that f(n) = O n3 , we actually mean that f(n) ∈ O n3 ( )
It is good that you're trying to think about these things, but you should first read the definition of it from a standard book
(like CLRS). Unless you know what the Big-Oh notation means formally, there is no point in thinking about how it works.

 0 votes -- Pragy Agarwal ( 13675 points)

1.208 Time Complexity: time complexity=? top gateoverflow.in/17935

main() {
for(i=1;i<=n;i++) {
if(n%i==0) {
for(j=1;j<=n;j++) {
x=y+z;
}
}
}
}

where n is prime no.

time-complexity


Selected Answer

O(n) since prime number is divisible by 1 and itself so inner loop will execute only two time i.e 2n

Therefore T.C= O(n)

 1 votes -- Umang Raman ( 10379 points)

1.209 Time Complexity: Complexity of the following program segment gateoverflow.in/26337

top

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 130 of 2244

time-complexity algorithms


Selected Answer

C o n s i d e r X = 101010…10. Now, f will be called for 1, 2, 3, …n/2 and the time complexity will be

(( ) ) ( ( ))
n n
2 2
( ) ( ) ( )
O 12 + O 22 + O 32 + … + O 2
=O 1+4+9+…+ 2

n . (n +1 ) . (2n +1 )

( )
We know that sum of the squares of first n natural numbers is Θ n3 as this is equal to 6
.So, here we get

( ) ( )
O (n/2)3 = O n3 and hence option C.

A related previous GATE question:

http://gateoverflow.in/1076/gate2004_82

 3 votes -- Arjun Suresh ( 124125 points)

1.210 Time Complexity: Consider the following three claims for time
complexity top gateoverflow.in/18926

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 131 of 2244

In my opinion , Option a is correct . Am i right ?

algorithms time-complexity


Selected Answer

Only (I) seems correct to me.

2n should not bound be an upper bound for n n + 1 since n is a variable & 2 is a constant.

(III) is trying to bound square of a function by the function itself so it should be wrong.

I guess only I is correct & II and III are incorrect.

 1 votes -- Anurag Pandey ( 8183 points)

1.211 Time Complexity: Determine the Time Complexity top gateoverflow.in/26334

time-complexity algorithms

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 132 of 2244

Selected Answer

We have to count the maximum no. of times any instruction is executed- which would be inside the inner most loop. So,
we can count the no. of times for loop and while loop execute independently and their product will be our answer.

for loop:

j = 1, 1 + 2, 1 + 2 + 3, . . . , 1 + 2 + . . . + l, where l is the no. of times the loop iterates (for one iteration of while loop).

From loop exit condition,

1+2+…+l>n

l . (l +1 )
2
>n

So, l = Θ(√ n).

(See, I used Θ meaning l and √ n have the same order of growth. If LHS has lower or same growth rate we should use big-
O and not big-Theta)

while loop

Now, we have to solve the outer while loop. Here i goes like n, n/2, n/4, …n/2m, where m is the no. of times the loop iterates.
As per the loop exit condition, we can get

2m > n (which gives an integer value 0)

 m > logn

m = Θ(logn).

So, time complexity of code is m. l = Θ(logn√ n).

Θ means both O and Ω are also true. Hence option d is correct.

As per definition of big O, even options A and B are correct though D is the best pick.

 2 votes -- Arjun Suresh ( 124125 points)

1.212 Time Complexity: The running time of an algorithm is given by T(n) =


T(n-1) + T(n-2) - T(n-3) , if n>3 top gateoverflow.in/18927

algorithms time-complexity


Selected Answer

n should be the correct answer.

T(n) = T(n - 1) + T(n - 2) - T(n - 3)

T(n - 1) = T(n - 2) + T(n - 3) - T(n - 4)

T(n - 2) = T (n - 3) + T(n - 4) - T(n - 5)

T(n - 3) = T (n - 4) + T(n - 5) - T(n - 6)

T(n - 4) = T (n - 5) + T(n - 6) - T(n - 7)

.....................................................

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 133 of 2244

.....................................................

T(6) = T(5) + T(4) - T(3)

T(5) = T(4) + T(3) - T(2)

T(4) = T(3) + T(2) - T(1)

On Adding all the above recurrences, all the red terms of a recurrence will be cancelled out with the red terms of
consecutive recurrences, similarly all the blue terms of a recurrence will be cancelled out with the blue terms of
consecutive recurrences.

Thus we get

T(n) = T(n - 2) + T(3) - T(1),

but since T(3) =3 & T(1) = 1

so our final recurrence will be T(n) = T(n - 2) + 2

Solution of T(n) = T(n - 2) + 2 will be n.

 2 votes -- Anurag Pandey ( 8183 points)

T(n) = { T(n − 1) + T(n − 2) − T(n − 3) if n > 3


n if n ≤ 3

From the definition, we can see that:

T(1) = 1
T(2) = 2
T(3) = 3
T(4) = T(3) + T(2) − T(1) = 3 + 2 − 1 = 4
T(5) = T(4) + T(3) − T(2) = 4 + 3 − 2 = 5
T(6) = T(5) + T(4) − T(3) = 5 + 4 − 3 = 6

We can observe the pattern. It looks like T(n) = n, but we need to prove it.

Proof by strong induction:


Hypothesis: T(n) = n

Base Case: T(1) to T(6) have been shown above.

Assume, for the sake of induction T(x), ∀x ∈ [1, n − 1]

Then,

T(n) = T(n − 1) + T(n − 2) − T(n − 3)


= (n − 1) + (n − 2) − (n − 3)
=n

QED

So, the answer is option A) n

 2 votes -- Umang Raman ( 10379 points)

1.213 Time Complexity: What is the time complexity of the following C code?
top gateoverflow.in/19027

int Test(int n) {
if (n<=0) return 0;
else {
int i = random(n-1);
return Test(i) + Test(n-1-i);
}

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 134 of 2244

Suppose the function random() takes constant time, then what is the time complexity of T(n)?

algorithms time-complexity


Selected Answer

This function looks very close to recurrence of QUick Sort . It is recurrence of Quick Sort ! Just instead of partitioning
function, we are calling function which has O(1) time. I.e. Constant

So In best case i will be midpoint then !

T(N) = 2(N/2) +c

T(N) = ϴ(lon 2n)

So best case => Ω((lon 2n)

In The worst case, we will alwyas chose i = 0.

Then it will be like

T(N) = T(1) + T(n-1) + c

It will be ϴ(N) in worst case.

 1 votes -- Akash ( 26315 points)

1.214 Time Complexity: Time and Space Complexity of the following function
top gateoverflow.in/26470

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 135 of 2244

algorithms time-complexity


Selected Answer

T(n) = 2T(n/2) + O(n), n > 1T(1) = O(1),

is the recurrence relation for time complexity.

Since this is the recurrence relation for merge sort, we know the answer as Θ(nlogn).

For space complexity if we see the code there is only constant amount of space used (no array usage) and hence the
recursion depth will give the space usage (in stack). Don't confuse this with the total no. of recursive calls as when a
function returns, that space (space use by it on stack for its activation record) can be reused.

If we draw a tree for recursive calls, we can get the longest branch going like T(n) − T(n/2) − T(n/4) − … − T(1), and its length
will be lgn and so the space usage will be c. lgn for some constant c, = Θ(logn).

Now what if B(n) uses space which is not constant? Insufficient data to answer that.

 1 votes -- Arjun Suresh ( 124125 points)

1.214 Time Complexity: Is the following statement valid?

log(n!) = Θ(nlogn)

top gateoverflow.in/179

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 136 of 2244

algorithms time-complexity normal


Selected Answer

I think it is sterling's approximation

lnN! = NlnN − N + ln√ 2πn

 4 votes -- Arpit Dhuriya ( 175 points)

n! corresponds to n*(n-1)*(n-2)*....*1 which is Θ(nn ). So by taking log to both terms, the answer comes out to be Θ(nlogn).

 1 votes -- vivek puri ( 21 points)

1.215 Time Complexity: Time complexity! top gateoverflow.in/17603

void find (int n) {


if (n < 2) return;
else {
sum = 0;
for (i = 1; i <= 4; i++)
find(n / 2);
for (i = 1; i <= n*n; i++)
sum = sum +1;
}
}

assume that the division operation takes constant time and sum is global variable. what is the time
complexity of find(n) ?

time-complexity algorithms

Recurrence equation:

T(n)=4T(n/2)+n^2

solving this we get

T(n)=O(n^2 logn )(master theorem case 2)

 1 votes -- Pooja ( 22773 points)

1.216 Time Complexity: What is an Inversion ?? top gateoverflow.in/26471

algorithms time-complexity

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 137 of 2244


Selected Answer

If the given array is already sorted and maximum n inversion is possible then insertion sort gives best case for that array
because array is already sorted.i.e O(n)

e.g. = 10 20 30 40 50 60 1 :
here 6 inversion and array is almost sorted so it will take 6 comparison and 6 swaps

if array is of n element and 1 element is not sorted then : O(n) for searching the position
n swap
O(2n)
for n element n*2n = O(n 2)

So we can say if in array there are I inversion is there then Time Complexity = O(n + I)
O(n) for best case for I= n
O(n2) for worst case if I is more than n
​optiion A

 2 votes -- Umang Raman ( 10379 points)

Insersion sort will take O( n 2 ) using merge sort complexity will be O(nlogn)

 1 votes -- Anirudh Pratap Singh ( 4091 points)

1.217 Time Complexity: max min top gateoverflow.in/151

Simple linear search to find max min algo

maxmin(a,n,max,min)
{
max=min=a[1];
for i=2 to n do
{
if a[i]>max then
max:=a[i];
else if a[i]<min then
min:=a[i];
}
}

1.Average case complexity of the above algo given that the first if conditions fails for n/2 elements

2.Average case complexity of the above algo if the first condition fails 1/2 times

plz xplain

algorithms time-complexity easy


Selected Answer

Complexity of the algorithm is O(n) and is irrespective of the success of if case as both if as well as else are O(1)
operations.
If you say exactly, the complexity in terms of comparisons will be

1. n − n/2 − 1 (number of elements for which first if succeeds) +2 × (n/2) (number of elements for which first if fails)

= 3n/2 − 1

2. (n − 1)/2 + 2 × (n − 1)/2
= 3(n − 1)/2

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 138 of 2244

 3 votes -- Arjun Suresh ( 124125 points)

1.218 Topological Sort: Topology top gateoverflow.in/34567

How many topological sorts of the following directed graph are possible?

topological-sort


Selected Answer

The topological sorts can exchange the position of any pair node which have no directed path between them. So nodes
(b,c) , (e,f) , (h,i) are interchangeable as there is no path between them . So for each pair there are 2 permutation so
total no of permutations are 2^3 = 8

 2 votes -- Vikram Bhat ( 587 points)

1.219 Why: find complexity?? top gateoverflow.in/35558

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 139 of 2244

why b time-complexity ace-test-series

Take , n=5 (say) and see what values j assumes. You will find that , j assumes values like 1,3,6 for k=1,2,3 , thus j
assumes values like k(k+1)/2. Now the for loop runs for k times , and j=k(k+1)/2, so equating with n on RHS , k^2=n or
k=sqrt(n). So for loop runs sqrt(n) times.
Outer while is of the form [where i=n]

while(i>0){
i=i/2
} and so complexity is log n. Hence for each of these log n times the for runs sqrt(n) times , complexity=O(logn*sqrt(n)).

 1 votes -- chat28 ( 495 points)

1.220 How to evaluate below expression involving asymptotic notations? top


gateoverflow.in/33216

If

f(n)=ϴ(n),g(n)=ϴ(n)

and

h(n)=Ω(n)

Then how to evaluate f(n)g(n)+h(n) ?

I am getting expression such that it is equivalent to O(n^2 ) , since f(n)g(n)=theta(n^2),Now I am just confused at one point that how to proceed for
calculating f(n)g(n)+h(n) ,theta(n^2)+h(n) ?

algorithms


Selected Answer

f(n)=ϴ(n) =>

c1*n ≤ f(n) ≤ c2*n ------(A)

g(n)=ϴ(n) =>

c3*n ≤ g(n) ≤ c 4*n ------(B)

h(n)=Ω(n) =>

c5*n ≤ h(n) -----(C)

from (A) and (B), we have,

c1*c3*n2 ≤ f(n)*g(n) ≤ c2*c4*n2 ----(D)

From (c) and (D), we can find only lower limit of f(n)*g(n) + h(n) since we don't know the upper bound of h(n).

c 1*c 3*n 2 + c 5*n ≤ f(n)*g(n) + h(n)

=> f(n)*g(n) + h(n) = Ω(n2) (Taking only asymptotically tight lower bound)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 140 of 2244

 1 votes -- Shashank Kumar ( 2029 points)

1.221 Maximum weighted spanning tree top gateoverflow.in/33018

Let G be a simple undirected complete and weighted graph with vertex set V={0,1,2..99}.Weight of edge (u,v) is |u-v|
where 0<=u,v<=99 and u not equal to v.Weight of the corresponding maximum weighted spanning tree is
(a)4950(b)4451(c)7350(d)7351

Apply kruskal for max weight to find the spanning tree.

v99 is connected to vertices v0 to v49 and weights are 99+98+97+....+ 50 = 3725

and v0 is connected to v50 to v99 and weights are (we will not include 99 again as we have already added) 98+97+....+
50 = 3626

So finally Weight of the corresponding maximum weighted spanning tree is = 3725 + 3626= 7351

 2 votes -- Anoop Sonkar ( 4167 points)

1.222 how to solve this problem using graph ? top gateoverflow.in/41900

An international cellphone company provides service on 7 different frequencies. They wish to set up business in Tamil Nadu
and have fixed the locations of 100 towers for their new service. The company has to ensure that two towers broadcasting
on the same frequency are at least 100 km apart, so that there is no interference of signals.

(i) Model this problems using graphs.

(ii) Describe an algorithm which will answer the question “Is it feasible to set up towers at the given locations and provide
service on 7 different frequencies?”. Your algorithm should say “feasible” if it is feasible, otherwise output the minimum
number of frequencies needed to utilize all 100 towers.

algorithms descriptive

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 141 of 2244

7 different frequencies will act as 7-color problem ...and towers within 100 Km ...will be considered adjacent

 1 votes -- Deepesh Kataria ( 1207 points)

1.223 Prefix code top gateoverflow.in/33012

How to solve this ? I am getting 1111 , the given answer is 1011.


Selected Answer

--> Do it by huffman coding. [d = 1011]


© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 142 of 2244

 1 votes -- Vinay Yadav ( 1739 points)

1.224 Binary trees top gateoverflow.in/41884

3. A weight-balanced tree is a binary tree in which for each node. The number of nodes in the left sub tree is at least half and at most
twice the number of nodes in the right sub tree. The maximum possible height (number of nodes on the path from the root to the
farthest leaf) of such a tree on n nodes is best described by which of the following?
a) log2 n
b) log4/3 n
c) log3 n
d) log3/2 n

Answer is D

You can refer Here http://gateoverflow.in/842/gate2002_2-12


 0 votes -- saif ahmed ( 931 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 143 of 2244

1.225 hashing top gateoverflow.in/41262

A hash table can store a maximum of 10 records.Currently there are records in locations 1,3,4,7,8,9,10.The probability of a
new record going into location 2,with a hash function resolving collisions by linear probing is?


Selected Answer

For the New Record to go to location number 2 it has the choices as 1,2,7,8,9,10
Total number of Records is 10

Probablity is (6/10)

 3 votes -- saif ahmed ( 931 points)

1.225 Find oder of this algorithm:T(n)=T(n-1)+1\n ? if n>1 top gateoverflow.in/41209


Selected Answer

ANSWER: O(logn)

Solution:

We can solve this recurrence relation using substitution method, as follow -


1

T(n) = T(n − 1) + n

1
n −1
Substituting T(n − 1) = T(n − 2) + in above equation

1 1
n −1
T(n) = T(n − 2) + +n

$T(n) = T(n-3) + \frac{1}{n-2} + \frac{1}{n-1} + \frac{1}{n}$

Performing subsitution n time we get

$T(n) = T(n-k) + \frac{1}{n-(k-1)} + \frac{1}{n-(k-2)} +...+\frac{1}{n}$

Assuming T(1) = 1

we can substitute k = n-1

$T(n) = T(1) + \frac{1}{n-(n-2)} + \frac{1}{n-(n-3)} +...+\frac{1}{n}$

$T(n) = 1 + \frac{1}{2} + \frac{1}{3} +...+\frac{1}{n}$

This is a harmonic series, therefore,

T(n) = O(logn)

 1 votes -- Prateek Dwivedi ( 845 points)

1.226 How many element will change their initial position after completion of
partition algorithm ? top gateoverflow.in/33387

Consider an array with the following elements: 12, 18, 17, 11, 13, 15, 16 and 14.
How many element will change their initial position after completion of partition algorithm by choosing 15 as pivot?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 144 of 2244

algorithms made-easy test-series


Selected Answer

Answer will be (7).

 1 votes -- nitish ( 349 points)

7 ans

 1 votes -- Anurag Semwal ( 4775 points)

1.227 sparse matrix top gateoverflow.in/41263

How many real links are required to store a sparse matrix of 10 rows , 10 columns ,and 15 non zeros entries.(pick up the
closest answer)

Full matrix = 10 * 10 = 100


Sparse matrix = 100/2 = 50
because in most of the cases sparse matrix take half the size of full matrix as in triangular matrix.

 0 votes -- vamsi2376 ( 1185 points)

1.228 Hashing top gateoverflow.in/41264

Consider a hashing function that resolves collision by quadratic probing.Assume the address space is indexed from 1 to 8
.which of the following locations will never probed if a collision occurs at position 4?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 145 of 2244

The Eqaution For quadratic Probing(hashing) Is

h'(k) = (h(k) + C1i + C2i^2) mod m

The problem with Quadratic probing is it will not probe all the location..
We should visit 'm' location by doing m probes which is not done by quadratic probing...

Considering the size of the hash table given in the equation is 8


So the address space will be from 0 to 7 not from 1 to 8 I think..

Assuming C1=1 and C2=1 and m=8

We will start Probing at location number 4,If it finds collision there


It will go to location number as follows:

h'(k) =h(k) + 1 + 1 = 6 mod 8 = 6 another collision


h'(k) = h(k) + 2 + 2^2 = 10 mod 8 = 2 another collision
h'(k) = h(k) + 3 + 3^2 = 16 mod 8 = 0 another collision
h'(k) = h(k) + 4 + 4^2 = 24 mod 8 = 0 another collision
h'(k) = h(k) + 5 + 5^2 = 34 mod 8 = 2 another collision
h'(k) = h(k) + 6 + 6^2 = 46 mod 8 = 6 another collision.......So on

It will repeat that sequence not in order.....


So the leftout position is 1 ,3 , 5 and 7

If anything is wrong here Please Correct me....

 1 votes -- saif ahmed ( 931 points)

1.229 Heap Sort top gateoverflow.in/41929

4) The number of elements that can be sorted in Θ(logn) time using heap sort is
(A) Θ(1)
(B) Θ(sqrt(logn))
(C) Θ(Log n/(Log Log n))
(d) Θ(Log n)

To Sort x Elements Heap Sort takes xlogx time...

So Lets us assume we have Log n/Log Log n elements..

Substitute this in place of x and we get Time Complexity as O(logn)

So The Correct Answer Is Option C)


 1 votes -- saif ahmed ( 931 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 146 of 2244

1.230 Introduction to algorithms,Thomas h cormen question:6.3-3 top gateoverflow.in/41776

algorithms

1.231 Question of BFS top gateoverflow.in/31929

Consider two vertices a and b that are simultaneously on the FIFO queue at same point during the execution of breadth first
search from s in an undirected graph.
Which of the following is true?
1. The number of edges on the shortest path between s and a is atmost one more than the number of edges on the shortest
path between s and b.
2. The number of edges on the shortest path between s and a is atleast one less than the number of edges on the shortest
path between s and b.
3. There is a path between a and b.

Can you please explain this question a bit ? I can not find any counter example .

algorithms


Selected Answer

Here (i) is satisfying condition 1 and 3

and (ii) is satisfying condition 2 and 3

 1 votes -- srestha ( 11585 points)

1.232 The minimum number of comparisons required to find the minimum


and the maximum of 100 numbers is ________ top gateoverflow.in/42073

i cannot understand the following explanation..how solution is (3/2)n-2???

If n is a power of 2, then we can write T(n) as:


T(n) = 2T(n/2) + 2

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 147 of 2244

After solving above recursion, we get


T(n) = 3/2n -2
Thus, the approach does 3/2n -2 comparisons if n is a power of 2. And itd oes more than 3/2n -2 comparisons if n is not a
power of 2.
So, here in this case put n=100 and we will get (3/2)(100) - 2 = 148 comparison .....


Selected Answer

The idea is to compare pairs of values (n/2 - 1 comparisons) to get an array of high values and an array of low values.
With each of those arrays we again compare pairs of values (2 * n/2 - 1 comparisons) to get the highest and lowest
values respectively.

n/2 -1 + 2*n/2 - 1 = 1.5n - 2 comparisons

 1 votes -- Digvijay Pandey ( 26245 points)

1.233 complexity of algo for detection of universal sink in directed graph top
gateoverflow.in/32435
minimum running time of algo that determines universal sink in a directed graph G={V,E} - a vertex with
indegree |V|-1 and outdegree 0, given an adjacency matrix for G is:

omega(V^2) O(V) O(V+E) none

http://stackoverflow.com/questions/29259365/how-to-find-the-universal-sink-of-a-directed-graph-with-an-adjacency-
matrix-repr

 0 votes -- radha gogia ( 4369 points)

1.234 splay tree top gateoverflow.in/44104

algorithms


Selected Answer

A splay tree is a self-adjusting binary search tree with the additional property that recently accessed elements are quick
to access again. It performs basic operations such as insertion, searching and deletion in O(log n) amortized time

So option D is correct.

 2 votes -- Manojk ( 3365 points)

1.235 Sorting top gateoverflow.in/32720

Sorting is useful for—

(a) report generation

(b) minimizing the storage needed

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 148 of 2244

(c) making searching easier and efficient

(d) both (a) and (c)

Sorting is useful for both report generation and making search easier and efficient . But sorting does not minimize the
storage needed.

so Option D.

 1 votes -- Humaya ( 23 points)

1.236 golden ratio top gateoverflow.in/44240


Selected Answer

Golden ratio is represented by the symbol ϕ(Phi), and its conjugate is –ϕ(phi, also called as silver ratio). Both are
satisfied by the equation, x2 – x– 1 = 0, as given in the explanation for Golden ratio. Since this equation is a quadratic
equation, we are going to solve it the usual way, by calculating its roots.

−b ± b 2 −4ac

2a
Roots = .

Given the equation, x2 – x– 1 = 0, value of a = 1, b = − 1 and c = − 1. So, the equation for calculating root will become

1 ± √1 +4
2

1 ± √ (5 )
2
=

If we calculate the roots we will get the value 1.61 and -0.61 which are actually the values of Golden ratio and its
conjugate. So, the Golden ratio and its conjugate both satisfy the equation x2 – x– 1 = 0. The answer is C.

If you want to know more then, Here is the reference. He has explained very beautifully. Have a look.

 3 votes -- Rude Maverick ( 3063 points)

1.237 solve the recurrence top gateoverflow.in/32013

2T(n/2)+Theta(n)

Using Master's theorem, we can have a = 2, b = 2 and f(n) = θ(n)

Now, n log 22 = n and its order is equal to θ(n)

So, case 1 and we have T(n) = O(n)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 149 of 2244

 0 votes -- Utk ( 1385 points)

1.238 ugc net top gateoverflow.in/44255

Answer will be B. It is famous Strassen Algorithm.

 3 votes -- Rude Maverick ( 3063 points)

It should be O(n^2.81) using strassen matrix multiplication.

 2 votes -- Manojk ( 3365 points)

1.239 Dynamic programming top gateoverflow.in/32041

Given an array which contains both positive and negative integers in it and asked to design an algorithm to find
the maximum sum which does not contain two consecutive numbers.What is the time comlexity of efficient
algorithm
A) Θ(nlogn)
B) Θ(n)
C) Θ(n2)
D) Θ(n2logn)

its O(n)

http://www.geeksforgeeks.org/maximum-sum-such-that-no-two-elements-are-adjacent/

 0 votes -- Abhishekcs10 ( 1001 points)

1.240 All sorting techniques top gateoverflow.in/41200

Please explain all the sorting techniques with examples,

1.241 what is the relation between two functions ? top gateoverflow.in/32898

A) nlg c , clg n ,

B) lg(n!) , lg(n n)

I guess both are equivalent so then how to represent them using asymptotic notation ?

A.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 150 of 2244

nlg c = nk has polynomial growth since k = lgc is a constant.

clg n is exponential in lgn and hence O(n).

So,

( )
nlg c = Θ clg n .

B.

lg(nn ) = nlgn

lg(n!) = Θ(nlgn) (Stirling's approximation)

So,

lg(n!) = Θ(lgnn ).

 1 votes -- Arjun Suresh ( 124125 points)

1.242 Algorithms ,finding the upper bound n0 and constants top gateoverflow.in/41999

2n^2 +nlogn =theta(n^2) ,I have done the lower bound..Like finding out the n0 and the constant.. Help me with the upper
bound constant and n0

2n^2+ n logn <=3n^2

where n^2>=nlogn or, n>=logn

So, n0 >=logn ,c=3

 0 votes -- srestha ( 11585 points)

1.242 c++ program to find maximum and second maximum using n+logn-2
comparisons top gateoverflow.in/41970

The optimal algorithm uses n+log n-2 comparisons. Think of elements as competitors, and a tournament is going to rank them.

First, compare the elements, as in the tree

|
/ \
| |
/ \ / \
x x x x

this takes n-1 comparisons and each element is involved in comparison at most log n times. You will find the largest element as the winner.

The second largest element must have lost a match to the winner (he can't lose a match to a different element), so he's one of the log n elements the
winner has played against. You can find which of them using log n - 1 comparisons.

Reference: http://stackoverflow.com/questions/3628718/find-the-2nd-largest-element-in-an-array-with-minimum-number-of-comparisons

 2 votes -- Rude Maverick ( 3063 points)

1.243 Book for Algorithms other than Coreman? top gateoverflow.in/41949

I would like to know if there is any other Algorithm and data structure book(other than coreman) available for beginners for
Gate preparations like we have Let Us C(Y. Kanetkar) for C (Ansi version)?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 151 of 2244

1. The Algorithm Design Manual (steve skeina)

.2. Algorithms Horowitz and Sahni.

 0 votes -- Ritaban Basu ( 255 points)

1.244 ugc net 15 top gateoverflow.in/44273

1.245 N cube Graph top gateoverflow.in/43176

In N-cube graph we have no. of vertices = 2N and no. of edges = N ∗ 2N −1


Can anyone explain how we get this no. of edges?

graph-theory algorithms

Hi ,

I would like to explain the above question :)

Look For a N Cube graph : This graph has got its name as "N "cube because here each vertex is represented By N bits .

Say for 1 cube graph : we would have vertex represented by 1 bit . so number of vertex possible with 1 bit is 0/1 ( 2
vertex==2n where n is 1)

Similarly take for 2 cube graph : here each vertex would be represented by 2 bits . so number of vertex possible is
00,01,10,11

So there are 4 vertex possible ( 4=2 2 where n is 2)

Hence in this way we can generalize that For N cube graph we can have vertex which is represent which is rep By N bit
and number of vertex possible is 2^N

And now let us see How to find the no of edges :

( If you seen the dig given below ) A vertex is joined by another vertex if its both vertex bits representation differ by
atmost 1 bit .

say if A has 001 and B has 101 we can join AB but if C has 110 so here we cant join neither AC Or BC.

So if a vertex is rep by N bit then it can be associated with other (n-1) vertex with change in any of these N bit at distance
of 1 ( Only 1 bit to differ in any vertex ) . However this condition should be maintained if we are joining vertex .

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 152 of 2244

Hence no of edges = N * 2 N-1 (where first N mean change in any of N bit and 2 n-1 mean it can/cant be associated with
neighbouring vertex with the above condition specified )

 3 votes -- Dexter ( 1933 points)

1.245 How to solve reccurence relation of type t(n)=t(n/5)+t(7n/10)+n ?plz


specify in detail. top gateoverflow.in/43840

You see, the important point to note in this recurrence relation is that there are two unequal recursive calls. That's the
reason behind my choice of solving this recurrence relation using recursion tree method.

Another point to note here is that the cost of cost of combining the solution at the top most level of the tree is n. At the
lower level of tree the cost is computed by adding the value of n at each level.

Since the first recursive call takes 1/5th of the total input and the second call takes 7/5th of the total input, the two sub-
tree(left sub-tree and right subtree) will not have same height. But here we can make a sloppy assumption that it is a
complete binary tree with log10/ 7 n levels, this will help us in computing the upper bound of the tree.

HTH

 1 votes -- Prateek Dwivedi ( 845 points)

1.246 How to solve below recurrence relation using subtitution method ? top
gateoverflow.in/32928

T(n)=T(n-3)+cn2

T(n-3)=T(n-6)+c(n-3) 2

T(n-6)=T(n-9)+c(n-6) 2

Continuing like this I am getting T(n)=T(n-3k)+cn 2+c(n-3k)2+c(n-(3k+3))2+c(n-(3k+6))2+c(n-(3k+9))2+......

Now let k=(n-1)/3 ,I am only able to get terms like cn 2+c+4c+25c +64c, with which I am unable to reach any conclusion ,
so how to proceed through this .

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 153 of 2244

algorithms


Selected Answer

Please go through my solution:

I suggest ,download the image first then view it for better clarity.

 2 votes -- Shashank Kumar ( 2029 points)

1.247 Minimum number of comparisons top gateoverflow.in/32948

The minimum number of comparisons required to sort 5 elements is -

a) 4

b) 5

c) 6

d) 7


Selected Answer

Minimum number of comparisons =  log (n!) = ⌈log(5!)⌉ =⌈log(120)⌉ = 7

Ref:http://en.wikipedia.org/wiki/Comparison_sort#Number_of_comparisons_required_to_sort_a_list

 3 votes -- Ashish Gupta ( 631 points)

1.247 how many recursive calls are there in tower of hanoi, is it 2^n-1 or
2^(n+1)-1?? top gateoverflow.in/39168


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 154 of 2244

The Recursive equation will be T(n) = 2T(n-1) + 1


BASE CASE will be T(n)=1 if n=0;

Using back substitution method solve the above equation we will get

Number of Invocation/recursion as 2^(n+1) -1

 1 votes -- saif ahmed ( 931 points)

2^(n+1) -1

 1 votes -- Nischal Gote ( 21 points)

1.248 Algorithms top gateoverflow.in/37212

Can anyone explain me the time complexity of Prim's algorithm?

Suppose you implement prims algo by adjacency matrix, Then after selecting the minimum vertex, you ll have to go
through V entries corresponding to that vertex in matrix and select the minimum. So on, you do this for V vertices. So,
complexity becomes O(V2)

 0 votes -- Anmol1933 ( 11 points)

1.249 hashing Clusterng problems top gateoverflow.in/37192

Identify the false statements


1. Linear probing suffers from both primary clustering and secondary clustering.
2. Quadratic probing suffers from both primary clustering and secondary clustering.
3. Double hashing do not suffers from primary clustering but suffers from secondary clustering only to a small extent.

I : 1st is true. 2nd is false. 3rd is true

ME: 1st and 2nd are false, 3rd is true.

 0 votes -- Aspi R Osa ( 1305 points)

1.250 Algorithm: Array Fill the Blank top gateoverflow.in/34773

Consider a square matrix of N × N in which the values are located from A[1, 1] to A[N, N]. For all i and j, A[i, j] = A[i – 1, j – 1] where i > 1 and j > 1. In order to reduce the
space complexity we avoid redundant storage. All the elements of above square matrix are stored in the Linear array B starting from index 0 in row major order. The

following code is used to retrieve the (i, j)th element of A index in the array.

Find the correct expression for ‘X’.

a. B [2N + i – j – 1]

b. B [2N + j – i – 1]

c. B [N + j – i – 1]

d. B [N + i – j – 1]

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 155 of 2244

How to solve this ?

algorithms

1.251 Median top gateoverflow.in/34975

what is the time complexity to find median of array with n elements??

Sorted array: Θ(1) always.

Unsorted array: O(n) worst case. Performs in sublinear time if some structure is present.

https://en.wikipedia.org/wiki/Selection_algorithm

http://sarielhp.org/research/CG/applets/linear_prog/median.html

 0 votes -- Pragy Agarwal ( 13675 points)

1.251 how to solve the recurrence relatio t(n)=t(sqrt(n))+1 top gateoverflow.in/37327

1.252 Aspi_R_Osa Asymptotics1.1 top gateoverflow.in/37454

Arjun sir please help.

Actually none of the options are correct check this

http://gateoverflow.in/36807/let-f-n-%CF%89-n-and-g-n-o-f-n-then-g-n-_______-assume-n-0-1-%CF%89-n-2-o-n-3-
%CE%B8-n-4-%CF%89-1

 2 votes -- shivanisrivarshini ( 2067 points)

NOTA
. g(n) can be 1/N

http://stackoverflow.com/questions/905551/are-there-any-o1-n-algorithms

 1 votes -- Aspi R Osa ( 1305 points)

1.253 Consider the following instance of knapsack problem with capacity W


= 6. top gateoverflow.in/37658

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 156 of 2244

Where did I make mistake ? plz help me :(

algorithms

There is no greedy solution to 0-1 knapsack problem. But, it is fairly easy in GATE to do substitution:

Option A: P(1) + P(2) = 20 + 15 = 35

Option B: P(2) + P(4) = 15 + 35 = 50

Option C: P(3) + P(5) = 10 + 15 = 25

Option D: P(3) + P(4) = 10 + 35 = 45.

Hence, option B.

 2 votes -- Arjun Suresh ( 124125 points)

1.254 Consider the following function f. top gateoverflow.in/37657

now , the question says , worst case time complexity. So, in the worst case , the inner loop condition is not satisfied , so ,
won't it be O(n 2) ?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 157 of 2244

algorithms


Selected Answer

Lets trace it,

i=1; then j=i=1 => inside A[ i ] != A[ j ] condition false => Execute 'else' part. Break inner loop

i=1; then j=i=2 => inside A[ i ] != A[ j ] condition false => Execute 'else' part. Break inner loop

repeat unto i's counter i.e., n....Thus, it only executes n times. Hence, O(n)

 1 votes -- Tushar Shinde ( 1523 points)

1.255 Made Easy FLT top gateoverflow.in/37475

Assume A m × n , B n × p and Cp × q are matrices where m > n > p > q. How many minimum number of multiplications are required to perform
the following operation?

A m × n × B n × p × Cp × q [= (A B C)m × q]

a) mnp+npq

b) mnp+mpq

c)mnq+npq

d) mnq+mpq

There are two possible to ways to do it :

(A*B)*C or A*(B*C)

In first case T1 = mnp + mpq = mp(n+q)

In second case T2 = npq + mnq = nq(m+p)

Let q = x , p = x+1 , n = x+2 , m = x+3

After substitution

T1 = (x+3)(x+1)(x+2+x) = 2(x+3)(x+1)(x+1)

T2 = (x+2)x(x+3+x+1) = 2(x+2)x(x+2)

T1 - T2 = 2x^2 + 6x + 3

as x >= 1 so T1-T2 > 0

hence T1 > T2

T2 requires less multiplications so the answer is c)

 1 votes -- Vikram Bhat ( 587 points)

1.256 time complexity top gateoverflow.in/34976

what is the worst case time complexity to construct a

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 158 of 2244

1-binary search tree

2-avl tree with n nodes???

1.257 How to find complexity of below code ? top gateoverflow.in/37172

for (int i=3;i*i<n ;i=i+2)


{
while(n%i ==0 )

{
printf("%d",i);
n=n/i;

}
}

In this one worst case will be when n is some prime number for which the loop will run O(sqrt(n) ) times but how to deal
with the best case , when n is some multiple of i then only inner loop will run , so even if I try forming some series like
i+2i+3i+.... then what should be the last term of this series for the evaluation of while loop .

Best case is when n = 3k, and the code runs k times.

 1 votes -- Arjun Suresh ( 124125 points)

1.258 quick sort top gateoverflow.in/35627

Is Quicksort is in place algorithm?

yes,

quicksort is inplace algo.

 0 votes -- rids123 ( 17 points)

1.259 Question regarding Djisktra algorithm top gateoverflow.in/31919

Regarding the point 1 , please correct me if I am wrong - I knew Djisktra fails only if there is negative weight cycle. So , it is
correct , right ?

Also , under the same condition , the algorithm might fall into a infinite loop .

algorithms

Dijkstra fails when there are negative weights and it will not go into infinite loop because Relaxation only happens E times. Bellman ford fails when there is a

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 159 of 2244

negative weight cycle.

 0 votes -- Shaun Patel ( 5445 points)

1.260 space complexity top gateoverflow.in/36577

what is the stack space required by the given function

gate(n)

if(n!=0)

return gate(n-1);

else

printf("gate2016");

Gate(n)=gate(n-1)+1

Space complexity is length of longest branch in tree..

Gate(n)-->gate(n-1)+.......gate(1)

So space complexity =O(n)

 1 votes -- Pooja ( 22773 points)

1.261 Alg top gateoverflow.in/36424

1.261 depth of the binary tree with n node? top gateoverflow.in/35262

logn

 0 votes -- Naveen Chowdary ( 23 points)

1.262 Final Analysis DIJIKSTRA ALGORITHM top gateoverflow.in/35239

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 160 of 2244

Acc. to dijkstra's algorithm:


What will be the shortest path from A to B ?

1) When the edge of length 15 is present.


2) when the edge of length 15 is removed.

algorithms


Selected Answer

Final Answer

A) 15
B) 2 10 13

 0 votes -- Aspi R Osa ( 1305 points)

if path of 15 is there

then it will be considered as shortest path..dikjstra algo wont update it..updation takes place only when distance is less
than current distance

coming to second que

if path of 15 is not there

then path 2-13 choosen or 2-10-3 will be choosen...

say 2-13 edge vertices are labelled as CD

and on 2-10-3 vertices are labelled as EF

(assuming alphabetic order while processing ie removind C first from priority,2-13 path will choosen)

 2 votes -- Pooja ( 22773 points)

Here all paths from A to B are of 15 weight. But when dijkshtra's algo run,

it should give path A --- B (direct edge).

Why only this path ?

Ans: when we run dijikshtra, taking A as source, in first iteration we are able

to reach B(but we are not selecting this in 1st Iteration, just updating the

distance to B) i.e. a direct edge from A to B.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 161 of 2244

so, it will only be updated when we get some shorter path, but it is not the case.

 1 votes -- Himanshu Agarwal ( 8861 points)

1.263 Difference between two below functions top gateoverflow.in/35062

What is the difference between log m n and (log n) m. Can anyone explain?

algorithms

Both are same .

 2 votes -- Pranay Datta ( 6113 points)

1.264 What is the time complexity of this problem ? top gateoverflow.in/35065

Given an array S containing n real numbers, and a real number x. We want to find any two elements p and q in the array
such that their sum is greater than the real number x. What is the best possible time complexity to find p and q ?

O(1)

O(n2 log n)

O(n)

O(n log n)

Question asks about Best case time complexity . So , if it happens , in the first and second element's sum is greater than x ,
then it can be done in O(1) time , right ?

Please correct me.

algorithms


Selected Answer

No, in question, best time complexity means best algorithm i.e. what is worst case time complexity of best algorithm.

I think the answer is O(n).

We can find largest and second largest numbers in S in O(n) time. Now see if their sum is greater than x, if it is, return
these two numbers, otherwise there can't be any pair whose sum is greater than x.

 3 votes -- Happy Mittal ( 9253 points)

1.265 Graphs top gateoverflow.in/37049

How does adding a vertex into a graph represented by adjacency matrix take O(n^2) time where n is no of nodes in graph?
What is the complexity of adding a vertex into a graph represented by adjacency list?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 162 of 2244

complexity is o(1) same as insertion in single link list

 0 votes -- Nachiket Karambelkar ( 61 points)

1.266 time complexity top gateoverflow.in/34492

max(f(n),g(n)).

f(n)+g(n) is also correct. They are asking order. Anyway you'll get max of both.

 2 votes -- Monanshi Jain ( 5827 points)

1.267 Huffman top gateoverflow.in/34469

Using Huffman code the number of bits required to have {a,b,c} with frequences 10,10,10 for each letter then the binary
codeof bits are ???

Its

a-10
b-11
c-0

 0 votes -- Rohit Mallik ( 131 points)

1.267 find the average number of comparisons in binary search on a sorted


array of 10 consecutive integers starting from 1? top gateoverflow.in/40925

1.268 what is the weight of minimum -weight spanning tree in the graph ? top
gateoverflow.in/40520

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 163 of 2244

I tried by taking n=2 , and took points (1,1) ,(1,2) ,(2,2),(2,1) and I got the minimum weight to be 3 , which is n+1 but
according to answer it is n-1

The length of an MST (number of edges required to make it) in an nXn grid where each square is a vertex is always n^2-1 ...(1)

Further, if an edge is axial (vertical or horizontal), then its weight should be 1 according to the formula given in the problem. ...(2)

Now since we are taking only axial edges, the total weight of the MST from (1) & (2) comes out to be: (n^2-1)*1

So the weight of the MST of this graph should be n^2-1 according to me.

 1 votes -- Somesh Singh ( 27 points)

1.269 file size top gateoverflow.in/39151

Let F1 , F2 , . . . . . . . . . . . . . . Fn be files with length L1 , L2 . . . . . . . . Ln we would like to merge all of the files together to make a single
file .The cost of merging files is m + n if the files have length m and n .Find the minimum cost of merging ten files whose
length are 5, 3, 10, 20, 15, 10, 5, 1, 2, 4 is _____________.


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 164 of 2244

Check this in this just merge 2 files with least cost always so we start with files whose cost is 3 (1,2 ) by this we move
forward by merging least cost files then we add all the internal nodes to have the cost of merging the files

https://xlinux.nist.gov/dads//HTML/optimalMerge.html

 0 votes -- shivanisrivarshini ( 2067 points)

1.269 How to apply the master theorem to equations containing f(n) other
than n^d. For e. g. F(n) = log n. top gateoverflow.in/38979

not applicable master therom

 0 votes -- Registered user 7 ( 343 points)

1.269 What is the difference between double hashing and rehashing? gateoverflow.in/33924

top

algorithms

1.270 arrangements preserving the effect of first pass partition algorithm are
top gateoverflow.in/40990

consider an array consisting of following elements in an unsorted order but 60 as first element 60,80,15,95,7,12,35,90,55 quick sort partition algorithm is
applied by choosing first element as pivot total number of arrengements of array integers is possible preserving the effect of first pass of partition
algorithm are

first choosing 60 as pivot element and applying first pass of Quick Sort we get

55 15 7 12 35 60 80 90 95.

Now left side of 60 can be arrange in 5! and right side can be arrange in 3! ways.

Total ways=5!*3!=720

 0 votes -- Leonidas Leonidas ( 97 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 165 of 2244

1.271 Which of the following statements is/are true? top gateoverflow.in/33388

Which of the following statements is/are true?


S1: Dijkstra’s algorithm is not affected by negative edge weight cycles in the graph and gives correct shortest path.
S2: Bellman ford algorithm finds all negative edge weight cycles present in the graph.

a) Only S2

b) Only S1

c) Both S1 and S2

d) Neither S1 and nor S2

algorithms made-easy test-series

Both are wrong . dijisktra algorithm i not affected by negative weights till there is a negative weight cycle.

bellman ford use the logic that in a graph .the shortest path contain atmost ( n-1) edges. it does not find all the cycles .
and i think finding all the cycles in the graph will be exponential time because in the worst case every vertex will have a
cycle . and we may have to look n vertices ( n*n)

 1 votes -- Ravi Singh ( 7303 points)

1.272 HOW TO FIND NO OF PASSES IN MERGE SORT top gateoverflow.in/33613

IF ONE USES STRAIGHT MERGE SORT TO THE FOLLOWING ELEMENTS 20,47,15,8,9,4,40,30,12,17 THEN THE ORDER OF
THE ELEMENTS AFTER 2ND PASS OF THE ALGORITHM

My Answer is

IN straight Merge sort we use 2 tapes


initally 1/2 of input is taken on tape1 and next 1/2 is taken on tape2
Let a,b be 2 tapes
i/p is 20,47,15,8,9,4,40,30,12,17
a : 20 | 47 | 15 | 8 |9 | (half of input is considered in a tape)
b : 4 | 40 | 30 | 12 | 17 |
Now merge them in another tape let it be c
c: 4 20 | 40 47 | 15 30 | 8 12 | 9 17| ------this is pass 1
for pass 2 again c is stored in 2 tapes as
a: 4 20 | 40 47 | 15 30 |
b: 8 12 | 9 17 |
then merge a and b in c
c: 4 8 12 20| 9 17 40 47 |15 30| --- this is 2nd pass

 0 votes -- shivanisrivarshini ( 2067 points)

1.273 We are given n keys and an integer k such that 1<=k<=n.Give an


efficient algo to find any one of the k smallest keys . top gateoverflow.in/41080

How many key comparisons are there , what is the lower bound and upper bound ?

For calculating the lower bound , should we consider the case when the keys are all in non-increasing fashion and then after
n-k comparisons we shall find one of the K keys and then we are done , and for calculating upper bound then , what should
be the case considered for the order of keys ?

algorithms


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 166 of 2244

I suppose here the upper bound and lower bound cases would be same.
To find one of the k smallest keys, we need to look at n-k+1 elements atleast to be sure that we have chosen one among
k smallest keys.. So, total n-k comparisons
In the question nothing about the order of the keys is mentioned. so we must look for n-k+1 elements, so n-k
comparisons.
Time complexity should be ϴ(n-k).

 2 votes -- Abhilash Panicker ( 6527 points)

1.274 complexity top gateoverflow.in/38804

Assume that array A and B are sorted, each contain 'N' element . What is the worst case time complexity to find the median
of A ∪ B?

a) O(log(N))

b)O(N)

c)O(Nlog(N))

d)O(N2)

a) is the answer logn

 0 votes -- Tauhin Gangwar ( 509 points)

1.275 Algorithm top gateoverflow.in/38803

Consider the following set of processes with the arrival time and CPU burst time.

Assume above processes are scheduled by RR scheduler with time quantum of 2 units. What is the average turn
around time of all processes?

10 units. Please verify the answer 'cause this question is slightly tricky....

 0 votes -- Nirmal S ( 27 points)

1.276 Time Complexity top gateoverflow.in/34442

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 167 of 2244

given answer is ( A)

1.277 Huffman code top gateoverflow.in/34465

1.278 complexity top gateoverflow.in/37870

QUESTION 41 : Consider the recurrence relation T(n) = T(n–1) + T(n/2) + n.

Which of the following is a good tight upper bound on T(n)

(A) Θ(n2 )
(B) Θ(n2 log n)
(C) Θ(2 (log n)2)
(D) Θ(n (log n)2)

1.279 Number of bits top gateoverflow.in/34466

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 168 of 2244

Q). After scanning a file , we found the following character frequencies.

Character Frequencies
a 12
b 2
c 7
d 13
e 14
f 85

Now, we encode each character using Huffman coding algorithm . What is the maximum number of bits required to encode
any character?

1.280 hashing top gateoverflow.in/34419


Selected Answer

order is 10,5,15.

now size of table is 8.

10%8 = 2.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 169 of 2244

at first it will go to 2,now 2 is occupied 1st collision,next it will go 3,same happened 2nd collision,next it will go 4,3rd
collision,now it will go to 5,it is empty so 10 took that position. so for inserting 10 , 3 collision has occured.

5 % 8 = 5.

now at first it will go to 5,but it is occupied ,so it will go to 6,but it is occupied also ,next it will go to 7,it is empty,so 5 can
take that place. so for inserting 5 , 2 collision has occured.

15 % 8 = 7

now at first it will go to 7,but it is occupied ,so it will go to 0,but it is occupied also ,next it will go to 1,it is empty,so 15
can take that place. so for inserting 15 , 2 collision has occured.

total =5 + 2 + 2 =7 collisions

 0 votes -- Sayantan Ganguly ( 5061 points)

1.281 Made Easy test full length top gateoverflow.in/37983

main()
{
int sum= 0;
for(int bound = 1;bound <= n; bound *=2)
{
for (int i=0;i<bound;i++)
{
for(int j=0;j<n;j+=2)
{
sum=sum+j;
}
for(int j=1;j<n;j*=2)
{
sum*=j;
}
}
}
}

options are : a)O(nlogn)

b)O(n^2 logn)

c)O((logn)^2)

d)O(n(logn)^2)

The answer given is B

BUT Shouldn't the answer be D ? I was thinking that if the outer loop runs logn times...the middle loop and
outer loops together should run (logn *(logn+1)) times...Am I wrong ?

Also could someone please help me understand the difference between log(logn), log^2n(log square n) and
(logn)^2 ?


Selected Answer

The complexity should be

n n n n n n n

T(n) = ∑nbound =1 bound × 2 = 1. 2 + 2. 2 + 4. 2 + … + n. 2 = 2 . [1 + 2 + 4 + … + n] = 2 2lg n −1 = Θ(n2 ).

If two sibling loops are there we need to only consider the most critical one for time complexity. But here the middle loop
is dependent on outer loop iteration variable and so we cannot find its complexity separate and multiply.

 1 votes -- Arjun Suresh ( 124125 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 170 of 2244

1.282 merge algo top gateoverflow.in/38583

Number of comparisions in worst case required to merge two sorted arrays of size 40 and 60 are-------


Selected Answer

Total number of comparison in worst case are m+n-1 .


So 60+40-1 = 99

 1 votes -- Digvijay Pandey ( 26245 points)

1.283 job scheduling top gateoverflow.in/38170

algorithms

Put the job with maximum profit in last possible slot where it executes before deadline. continue this for other jobs utill u
dont find any job that can be executed within deadline. here put p1 first in slot 1-2 then put p4 in slot 0-1.

no more jobs can be scheduled now so profit is 100+27=127

 1 votes -- sachin pandey ( 33 points)

1.284 recursive top gateoverflow.in/38018

I know solving using tree method could someone help solving this in easy way

1.285 Consider vertices V1 and V2 that are simultaneously on function call


stack at some point during DFS from vertex s top gateoverflow.in/41180

Which of the following are always true for this digraph ?

1. There exists a directed path from s to V1 and s to V2 .

2.There exists a directed path from V1 to V2 and a directed path from V2 to V1 .

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 171 of 2244

3.If there exists no directed path from V1 to V2 , then there exists a directed path from V2 to V1 .

why is option 1 always true , I think it must be true only if they mention that there is a directed path from s to V1 and s to
V2 via V1 because if we have s to V1 and s to V2 separately then also we will have V1 and V2 simulatenously on call stack if
we have a path from s to V2 via V1 .

In DFS we go upto maximum depth and then backtrack.

2. is not possible. As here loop concept will not work

3. same concept as 2

here only concept is the maximum depth of the graph and then only operation is backtracking

 0 votes -- srestha ( 11585 points)

1.286 asymtotic notations top gateoverflow.in/29302

Q). Consider the following functions


4
3
f1 = n

n
f2 = 22

2
f3 = 2n

f4 = n!

f5 = 2n

Which of the following is true?

A). f1 is Ω(f2 )

B). f2 is O(f3 )

C). f1 < f5 < f4 < f2 < f3

D). f4 is O(f3 )

Function Take log in every function


f1=n4/3 4/3 log n

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 172 of 2244

f2 = 22^n
2n

f3=2n^2 n
2

f4 = n! n log n

f5=2n
n

Logarithmic growth rate of f1 is less than all other functions growth rate

Linear growth rate of f 5 is more than logarithmic growth rate of f 1

Linear growth rate of f 4 is more than logarithmic growth rate of f 5

Non linear growth rate of f 3 is more than linear growth rate of f 4

Exponential growth rate of f 2 is more than non linear growth rate of f 3

So, f1 < f5 < f4 < f3 < f 2

So, ans will be (D)

 2 votes -- srestha ( 11585 points)

I think option D is true. first of all . 1 is a linear function, secondly in exponential we have 2 functions that are f4,f5. in
which n^n has a much bigger growth than 2^n. and then we have 2 super exponential functions that are f2 and f3. as
2^n has a much greter growth than n^2. f3=O(f2). now just compare n^n and 2^ n^2.

taking log both side. nlogn =n^2 log 2

nlogn=n2. so option d .

 2 votes -- Ravi Singh ( 7303 points)

1.287 How to solve the below question of Directed graph ? top gateoverflow.in/12699

Let G(V, E) be a directed graph with n vertices.

A path from vi to vj in G is sequence of vertices (vi, vi +1 , …, vj) such that (vk, vk+1 ) ∈ E for all k in i through j– 1.

(A simple path is a path in which no vertex appears more than once.)

Let A be an n × n array initialized as follow:


Consider the following algorithm.

for i = 1 to n
for j = 1 to n
for k = 1 to n
A [j , k] = max (A[j, k] (A[j, i] + A [i, k]);

Which of the following statements is necessarily true for all j and k after termination of the above algorithm?

(A) A[j, k] = n
(B) If A[j, k] = n– 1, then G has a Hamiltonian cycle
If there exists a path from j to k, then A[j, k] contains the
(C)
longest path length from j to k
If there exists a path from j to k, then every simple path
(D)
from j to k contain most A[j, k] edges.

I am confused between option C and D , answer given is D .

I traced it with 4 vertex .. i didnt get logest path after terminate the algo... but option d follow ... option c may be
changed by changing in no of vertex ...

aur one more thing if directed graph has loop then option c always wrong bcoz longest path will be tends to infinite

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 173 of 2244

 1 votes -- sonam vyas ( 6441 points)

1.287 which of the following is asymptotically smaller? A.lg(lg*n) B.lg*(lgn)


C.lg(n!) D.lg*(n!) top gateoverflow.in/12692

algorithms


Selected Answer

lg *n, (Inverse Ackermann function) is the number of times we can take log repeatedly until we get 1. This function can
almost be considered constant for all practical purposes.

There shouldn't be any confusion regarding options C and D as n! is asymptotically larger than lg n.

A) lg (lg * n)
B) lg * (lg n)

As per the definition of lg *, we can write B as

lg * (lg n) = lg * n - 1.

So, A is asymptotically lower than B.

A < B < D < C.

 0 votes -- Arjun Suresh ( 124125 points)

1.288 What is the maximum number of topological sorting possible ? gateoverflow.in/12486

top

For a given set of vertices , can we compute the maximum number of topological sortings possible ?

This question can be form like this , how many DAG ( Direct Acyclic Graph) are possible with a given vertex ( say with n
vertices ) .If a graph contains any cycle then topological sorting isn`t possible .

I think with n vertices number of DAG possible are n! .

 1 votes -- Pranay Datta ( 6113 points)

1.289 The problems 3-SAT and 2-SAT are top gateoverflow.in/12420

a)Both in P

b)Both NP-complete

c)NP-complete and P respectively

d)Undecidable and NP-complete respectively

option C

3 Sat is np complete

2 Sat is p

 2 votes -- Pranay Datta ( 6113 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 174 of 2244

1.290 How to solve below question of undirected subgraph for finding


shortest path ? top gateoverflow.in/12700

Let G = (V, E) be an undirected graph with a subgraph G1 = (V1, E1). Weights are assigned to edges of G as follows :

w(e) = 0 if e belongs to E1

1 otherwise

A single-source shortest path algorithm is executed on the weighted graph (V, E, w) with an arbitrary vertex v1 of V1 as the source. Which of the following can always be inferred from the path
costs computed?
(A) The number of edges in the shortest paths from ν1 to all vertices of G
(B) G1 is connected
(C) V1 forms a clique in G
(D) G1 is a tree

Plz tell the approach........

Answer is (B).

We can decide whether G1 is connected or not, because if it is connected then at least one path cost must be 1 because in
shortest path computed from v1 to some vertex not in G1, we must include an edge not in G1, and weight of that edge is
1.

If path cost is 0 for all vertices, that means all the edges included were of weight 0 i.e. of G1 only, hence G1 is not
connected.

 1 votes -- Happy Mittal ( 9253 points)

I can certainly decide G1 is connected or not.initially I will set shortest distance from v1 to every vertex to infinity, then I
will try to find the shortest path from v1 to all vertices. Now after this algorithm terminates I will check if a vertex
belongs to set V1 and contains infinity as the shortest distance then G1 is disconnected graph else the graph is connected

 1 votes -- Bhagirathi Nayak ( 10239 points)

1.291 What is the difference between Topological sort and bellman-ford


Algorithm ? top gateoverflow.in/12728

A) Do following for every vertex u in topological order.


………..Do following for every adjacent vertex v of u
………………if (dist[v] > dist[u] + weight(u, v))
………………………dist[v] = dist[u] + weight(u, v)

B) Do following |V|-1 times where |V| is the number of vertices in given graph.
…..a) Do following for each edge u-v
………………If dist[v] > dist[u] + weight of edge uv, then update dist[v]
………………….dist[v] = dist[u] + weight of edge uv

Now A is topological sort and B is Bellman ford , Both are following similar steps , so then why is the time complexity of bellman-ford O(VE) while for toplogical sort
it is O(V+E) ?

algorithms

In topological sort, in the inner loop we consider only "adjacent vertex". So, the complexity at max can be O(|V| 2) which
happens when |E| = |V|2.

In Bellman Ford algorithm, the inner loop is run for each and every edge.

 0 votes -- Arjun Suresh ( 124125 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 175 of 2244

1.292 Why is the below expression correct for a cross edge in case of DFS ?
top gateoverflow.in/12731

Cross Edge(a,b) is defined as an edge between two non-ancestor nodes in DFS , so my query is that how is this stmt true :

arrival[b] <departure[b] <arrival[a] <departure[a] ...

algorithms

since for cross edge(u,v)

d(u)........f(u) , d(v)......f(v)

discovery and finishing time of one vertex will be different from other vertex for cross edges .

i dont think so that statement is correct..

 0 votes -- shabi ( 317 points)

1.293 Can we modify Dijkstra algorithm for computing maximum distance


problem top gateoverflow.in/12730

Following statement is true or false?


If we make following changes to Dijkstra, then it can be used to find
the longest simple path, assume that the graph is acyclic.

1) Initialize all distances as minus infinite instead of plus infinite.

2) Modify the relax condition in Dijkstra's algorithm to update distance


of an adjacent v of the currently considered vertex u only
if "dist[u]+graph[u][v] > dist[v]". In shortest path algo,
the sign is opposite.
(A) True
(B) False

I think it must be true but answ given is false , its says that In shortest path algo, we pick the minimum distance vertex from the set of vertices for which distance is
not finalized yet. And we finalize the distance of the minimum distance vertex.
For maximum distance problem, we cannot finalize the distance because there can be a longer path through not yet finalized vertices.

Now I am nt getting that when all are initialized with minus infinty so then maximum can be found , so then whats the issue why cant we finalize it ?

algorithms

Longest simple path cannot be computed like this. To understand why you need to know that Dijikstra's algorithm works
using Greedy principle. That is, at each vertex we choose the best neighbour and include that in the shortest path. Doing
like this in end, we get the best path- greedy approach works. But this approach need not work in many cases and longest
path one is just an example. A simple example can be shown as follows.

Consider shortest path from a-c

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 176 of 2244

 1 votes -- Arjun Suresh ( 124125 points)

1.294 In bellman ford algo why are the no of passes |V|-1 ? top gateoverflow.in/12729

Bellman-ford algo

1) This step initializes distances from source to all vertices as infinite and distance to source itself as 0. Create an array dist[]
of size |V| with all values as infinite except dist[src] where src is source vertex.

2) This step calculates shortest distances. Do following |V|-1 times where |V| is the number of vertices in given graph.
…..a) Do following for each edge u-v
………………If dist[v] > dist[u] + weight of edge uv, then update dist[v]
………………….dist[v] = dist[u] + weight of edge uv

in bellman ford algo v-1 times will give you the shortest path but if there is any -ve edge cycle to check you have to
perform 1 more cycle .

Why V-1times ?

simple , a vertices is connected to atmost V-1 vertices to check them you need V-1 times ( there is no -ve edge cycle ) .

 0 votes -- Pranay Datta ( 6113 points)

1.295 How does huffman encoding involve the concept of build-heap


algorithm ? top gateoverflow.in/12389

Though the parent node is maximum of both the child nodes but still the procedure we follow is chosing the minimum at each step and adding them to produce a
parent node, so how come heapify procedure is called here ?

algorithms

every time we join the least two node (which are having some values)

we get a new value which need to be shifted in its correct postion in the heap thats where we need to "build heap".

 0 votes -- shabi ( 317 points)

1.296 plz answer ! top gateoverflow.in/12012

consider the msg -

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 177 of 2244

aabbbbabccdddccccbbdd

ques 1. the number of bits required for huffman encoding of the above msg is-

a.38 b 30. c 42. d.46

ques 2. what is the decoded msg for 110100

1. abc 2 acb 3 bcd 4 bda

B) 11 01 00

b d a

 2 votes -- Pranay Datta ( 6113 points)

1.C i.e 42 bits

2.D i.e bda

 1 votes -- shabi ( 317 points)

1.297 which of the following is correct top gateoverflow.in/10580

which of the following is correct?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 178 of 2244

obviously 1st one is correct.basic arithmetic question . Refer any 10 std maths book

 3 votes -- sumit kumar singh dixit ( 1625 points)

2nd one is correct..

 2 votes -- Digvijay Pandey ( 26245 points)

definately first one is correct...

log^k (n) = (log n)^k

log .log n = log (logn)

 1 votes -- shabi ( 317 points)

2 is correct

 1 votes -- ish.nit513 ( 65 points)

1.298 doubt top gateoverflow.in/10493

How n + n/2 + n/4 + .... 1 can approximate it as an infinite GP?

Is it =1+2+4+8+..........n/4 + n/2 +n ?

=O(2^n) ?

1 to n der are logn terms.


apply GP sum formula = a(r^b-1)/(r-1) //b is no of terms in GP
here a = 1, b = logn, r = 2
= 1*(2^(logn) -1)/(2-1)
= n-1 // 2^logn = n
= O(n)

 0 votes -- Digvijay Pandey ( 26245 points)

1.299 doubt top gateoverflow.in/10486

Is it loglog(2^2^2^2)=4

Let n=(2^(2^(2^2)))=2^16

Loglogn=4

T(n)=1+T(2^8)=2+T(2^4)=3+T(2^2)=4+T(2)=5

Let n= (2^(2^(2^(2^(2^2)))))=2^(2^65536)

Loglog n = 65536

Yes. For 2 2 (
something
)
, log2 x = 2something and log2 log2 x = something

 1 votes -- Arjun Suresh ( 124125 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 179 of 2244

1.300 Big O top gateoverflow.in/10481

The concept of order (Big O) is important because—


(a) it can be used to decide the best algorithm that solves a given problem
(b) it determines the maximum size of a problem that can be solved in a given system, in a given amount of time
(c) it is the lower bound of the growth rate of the algorithm
(d) Both (a) and (b)

let problem A of size is n.


Big O says time taken by best algorithm that solve every case(best, avarage, worst) of problem A completely.
in general Big O is "The Best algorithm of worst case input".
it also determines the max size of problem that can be solved in given amount of time.

 2 votes -- Digvijay Pandey ( 26245 points)

 1 votes -- Savir husen khan ( 121 points)

1.301 a machine need min. of 100 sec to sort 1000names by quicksort.the


min time needed to sort 100 names?? top gateoverflow.in/10595


Selected Answer

Running time of quick sort = c n lg n

For n = 1000, we get

100 = c * 1000 * lg 1000 => c = 0.01

So, for n = 100, we get running time = 0.01 * 100 * lg 100 = 6.7

 2 votes -- Arjun Suresh ( 124125 points)

min no of comparison for quick sort = nlogn

so to sort 1000 names 1000*3 ie 3000 comparisons are needed.

For 3000 comparisons we need 100s , thus for 1 comparison we need 0.033s

To sort 100 names we need 200 comparisons thus time needed is 0.033*200 s = 6.67 s

 1 votes -- komal07 ( 905 points)

1.302 recurrence top gateoverflow.in/10619

solve the recurrence T(n)=2T(n/2)+n/lgn


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 180 of 2244

Case 2.b.

Should be O(nloglogn)

http://homepages.math.uic.edu/~leon/cs-mcs401-s08/handouts/extended_master_theorem.pdf

 3 votes -- Digvijay Pandey ( 26245 points)

n n

T(n) = 2T ()
2
+
lgn

n n

For Master theorem, a = 2, b = 2, nlogb a = n. f(n) = lg n . We cannot say f(n) = O(nlogb a −ϵ), as the difference between n and lg n is
not polynomial. So, we cannot apply Master theorem. So, trying substitution. Since, we have a lg term, we can try all
powers of 2.

T(1) = 1, assuming.

T(2) = 2T(1) + lg 2 = 4

T(4) = 8 + 2 = 10

T(8) = 20 + 3 = 22.66

T(16) = 45.3 + 4 = 49.3

T(32) = 98.6 + 6.4 = 105

T(64) = 210 + 10.6 = 220.6

Not able to reach a conclusion. We can see that the recurrence is between case 1 and case 2 of Master theorem. So, it is
Ω(n) and O(nlgn). So, lets solve the recurrence directly.

n n

T(n) = 2T () 2
+ lg n

n n n

()
= 22 T 4 + lg n −1 + lg n

n n n

= 2lg n T(1) + 1 + 2 + … + lg n

1 1 1

=n+n ( 1
+ 2
+…+ lg n
)
= n + n(lglgn + γ) = Θ(nlglgn)

The sum of lgn terms in HP approximated to lglgn + γ where γ is Euler Mascheroni constant.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 181 of 2244

Ref: https://en.wikipedia.org/wiki/Euler%E2%80%93Mascheroni_constant

 1 votes -- Arjun Suresh ( 124125 points)

1.303 ugc net paper 2 computer science code 87 must tell me top gateoverflow.in/11839

http://ugcnetonline.in/question_papers_december2012.php

Q no 34 how relate depth of Btree ??? with order

& Q no 45 how to predect "&" this operator??????

Max no of nodes of order m and depth d is : m^(d+1)-1


(1&2) + (3&4) //& is bitwise AND
= (00000000 00000001 AND 00000000 00000010) + (00000000 00000011 AND 00000000 00000100)
= 00000000 00000000 + 00000000 00000000

=0

 1 votes -- Digvijay Pandey ( 26245 points)

1.304 arrange the following in terms of asymptotic complexity top gateoverflow.in/11016

arrange the following in the increasing order of their asymptotic complexity in big theta notation


Selected Answer

Log n! has same asymptotic growth as n log n as shown by Stirling approximation.

Log n log n = log n log n which is asymptotically lower than n log n.

So the order would be

Log n log n , log n!, (3/2) n, 2n, 22n

 3 votes -- Arjun Suresh ( 124125 points)

1.305 DATA STRUCTURES top gateoverflow.in/10643

Suppose we are comparing implementations of insetion sort and merge sort on the same machine. For inputs of size n,
insertion sort runs in 8n^2 steps, while merge sort runs in 64nlgn steps. For which values of n does insertion sort beat
merge sort?

algorithms

I know that Insertion sort is better as compared to Merge sort only for small set of Imputs . Here if i put n=2 then i get 32
steps for merge and 128 steps . SO here only Insertion has beat Merge sort . Continuing in this manner at n =43 i would
get 14792 steps and 147933.806 steps in merge . After this the whole scenario changes Merge Sort wins ! So the answer
for above will be from 2 to 42 right or just 42 ?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 182 of 2244

 0 votes -- spriti1991 ( 1127 points)

1.305 (logn)! and (loglogn)! are polynomially bounded ? anybody can prove? top
gateoverflow.in/12928


Selected Answer

We have Stirling's approximation which says

logn! = Θ(nlogn)

(
So, (logn)! = elog (log n ) ! = Θ e (log nlog log n ) = Θ ) (( elog n )
log log n
) (
= Θ nlog log n . )
Hence, polynomially lower bounded but not upper bounded. For polynomial, we need nc, where c is a constant, which is
not the case here.

( )
(loglogn)! = elog (log log n ) ! = Θ e (log log nlog log log n ) = Θ (( elog log n )
log log log n
) ( ) (
= Θ (logn)log log log n = O(n) ∵ nlog log n = O(en ), detailed at end, and replace

Hence polynomially upper bounded.

log log n
nlog log n = elog n = elog nlog log n = O(en )

 2 votes -- Arjun Suresh ( 124125 points)

1.306 whicc of the following is correct..... top gateoverflow.in/13381

let f(n)=omega(n) g(n)=O(n) and h(n)=⊖(n) then g(n)+f(n).h(n)=...................

<a>. omega(n)

<b>.omega(n^2)

<c>.⊖(n)

<d>.⊖(n^2)

ANS- A,B

Let f(n) = n 2, g(n) = n and h(n) =n

than g(n)+f(n).h(n)= n+ n 3 = omega (n2)

= omega (n)

 0 votes -- shreshtha5 ( 1227 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 183 of 2244

1.307 A average number of comparison performed by the merge sort


algorithm ,In Merging two sorted lists of length 2 is top gateoverflow.in/14355

If I have two lists of length 2 then no of comparisons in the worst case would be 2 only , since If I have say 10,20 in list A
and 5,7 in list B so then on merging 10 is compared with 5 then 20 is compared with 7 so finally in 2 comparisons I have
merged both the lists , so then how to calculate the average no of comparisons here ?

algorithms


Selected Answer

First of all, worst case would be 3 comparisons. For example, A = [10,20], B = [15,30]. Here number of comparisons
would be 3.

Now for expected number of comparisons, suppose we are given two lists A = [x1,x2], B = [x3,x4]. For simplicity,
suppose all 4 elements are distinct.

If we were to write all possible results of merging x1,x2,x3,x4, we have following ( 2 ) = 6 possibilities (Note that in each
possibility, x1 has to come before x2, and x3 before x4 because A and B are sorted)

x1,x2,x3,x4
x1,x3,x2,x4
x1,x3,x4,x2
x3,x4,x1,x2
x3,x1,x4,x2
x3,x1,x2,x4

Now we can have either 2 comparisons or 3 comparisons. We have 2 comparisons if either both x1,x2 < x3 or both
x3,x4<x1, so P(2 comparisons) = 2/6

We will have 3 comparisons in rest of the 4 cases (you can verify), so P(3 comparisons) = 4/6

So E[num comparisons] = 2 ∗ P(2 comparisons) + 3 ∗ P(3 comparisons)

2 4 16 8

=2∗ 6 +3∗ 6 = 6 = 3

2m

We can generalize it for two lists A and B of size m. Number of ways in which final merged list C can be formed is ( m ),
because we have total 2m locations in C, out of which we can choose any m locations to put elements of A, rest are filled
by B.

Now we count number of comparisons done during merging. Suppose during merging, A finishes first (other case is
symmetrical, and we will multiply the count by 2). So number of comparisons will be size of list C when A finishes. So we
argue on size of C (let we call it S when A finishes).
Minimum value of S is m because when A finishes, C must contain at least m elements, and maximum value of S is 2m − 1,
which happens when B is left with just 1 element when A finishes. So we make cases on S :

S = m : Only 1 case, when all elements of A are smaller than of B.


S = m + 1 : C contains m + 1 elements, out of which m are of A, 1 is of B, that 1 element of B can take any location out of m
m

locations in C, so ( 1 ) choices.
S = m + 2 : C contains m + 2 elements, out of which m are of A, 2 are of B, those 2 elements of B can take any location out of
m+1

m + 1 locations in C, so ( 2 ) choices.
2m−2

This can go on till S = 2m − 1 : ( m−1 ) choices.

So total number of comparisons in all cases


m 2m−2

(
= 2 ∗ m ∗ 1 + (m + 1) ∗ ( 1 ) + … + (2m − 1) ∗ ( m−1 ) )
Multiplication by 2 outside is due to symmetry.

Finally, expected value of number of comparisons

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 184 of 2244

m 2m− 2

(
2 ∗ m∗ 1 + (m+1 ) ∗ ( 1 ) + … + (2m−1 ) ∗ ( m− 1
) )
2m
m
( )
=

We can generalize it similarly for different size lists.

 3 votes -- Happy Mittal ( 9253 points)

In Merge Procedure we generally have infinity( ∞) at the end of the array we like to merge

Here largest element of one array is smallest than the smallest element of another array

a = [10,20]

b = [5,7]

In Example 1 the smallest array(ie a) smallest element is greater than the largest element of array b.Here number of
comparsion is 5

In Example 2 the smallest array (ie b) the largest element is smaller than the smallest of array b.Here number of
comparison is 3.

Thus it depends on array that how many comparison their will be.B ut the mandatory condition that (the smallest element
of one array is larger than the largest of another) is to be fulfilled.

In your case the number of comparison is 2(as it fulfills the mandatory condition).

NOTE

*The infinity is put at the end of both the array because in (above discussed) array the element to compare with will be
over at certain time, then ∞ plays a immense role.

 1 votes -- Saurabh Gupta ( 27 points)

1.308 Given n points in the xy plane, what is the time complexity to find the
closest pair? top gateoverflow.in/14354

what is the approach of this question , Is it that first we will traverse all the pairs then find the minimum distance between
all the pairs

algorithms

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 185 of 2244

By divide and conquer

T(n)= 2T(n/2)+O(n)

= O(nlogn )

here distance between pairs calculate by ab=squr((ax-bx)^2+(ay-by)^2)

ref : http://www.dcs.gla.ac.uk/~pat/52233/slides/ClosestPoints1x1.pdf

 1 votes -- sonam vyas ( 6441 points)

1.309 In sorting algo which has a running time that is least dependent on
initial ordering of inputs top gateoverflow.in/14296

options

A. insertion

B. quick

C. selection

D. merge


Selected Answer

ans D

insertion sort : if the initial ordering is in reverse order it takes O(n 2).

quick sort :if the initial ordering is in reverse order or sorted it takes O(n 2)

selection sort : best case and worst case O(n 2 ) it does not depend upon the order but swaping takes less (if sorted )

merge sort : in all cases O(nlogn) and its the ans ( i guess)

 4 votes -- Pranay Datta ( 6113 points)

1.309 Hi.i need a correct explanation on binary search..how it will be log n. top
gateoverflow.in/13869

algorithms


Selected Answer

T(n) = T(n/2) + 1

This is the recurrence relation as after '1' search we eliminate n/2 elements.

Solving we get

T(n) = T(n/2) + 1 = T(n/22 ) + 2 = … = T(n/2lg n ) + lgn = T(1) + lgn = 1 + lgn

 4 votes -- Arjun Suresh ( 124125 points)

1.309 What is the smallest value of n such that an algorithm whose running
time is 100n^2 runs faster than an algorithm whose running time is 2^n on
the same machine? top gateoverflow.in/14395

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 186 of 2244


Selected Answer

At n = 14, 2n − 100n2 = 214 − 100 ∗ 142 = − 3216

At n = 15, 2n − 100n2 = 215 − 100 ∗ 152 = 10268

So at n = 15, 2n becomes greater than 100n2

 5 votes -- Happy Mittal ( 9253 points)

1.310 For each function f (n) and time t in the following table, determine the
largest size n of a problem that can be solved in time t , assuming that the
algorithm to solve the problem takes f (n) microseconds. top gateoverflow.in/14397

please explain the method.

For 1 second ,and first example function:

lg (n) = 10^3

n=2^(10^3)

You can go ahead and fill table similarly.

 0 votes -- vishal8492 ( 245 points)

1.311 Path matrix top gateoverflow.in/15614

given a graph G,a matrix P k represent a matrix in which each entry p k[i][j] represent the shortest path from node i to
node j in G which uses only nodes 1,2,3.............k-1 .The corresponding graph formed by using matrix P k[i][j] is termed as
Gk .

Gk can be calculated by taking the square of adjacency matrix of G k times and replacing each multiplication and addittion
operation by AND and OR operation.(concept of warshall's algorithm of unweighted graph) .now my question is how to find
Gk if the graph G is represented by using adjacency list and what will be the time complexity to do it ??

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 187 of 2244

what i think is O(v^4) may be the answer.


first of all the data is in adhency list like this

to compute inital distances time taken will be o(v3) as suppose i am calculating a then for the idstnce to b i have to seach
all the adjency nodes of a . which may be v in worst case. and for c again and so v time i have to search v nodes which is
v2 and i have to do so for v times . so v3. now when i have calculated the initial matrix distances. and such v matrix have
to be calculated . else u may think this way .

now for distance of a to c through b we will hav to first find the distance from a to b which is v time and then from b to c
which is also v time now . and then compare with the inital distances . so time complexity will be (v+V+1)=O(v) this is
just one entry . such v^2 nodes have to calculated in worst case i.e. complete graph . and such v passes will be made so
v*v^2*v=O(V^4).

answer may be wrong . what is the answer.

 0 votes -- Ravi Singh ( 7303 points)

1.312 BFS and DFS predecessor subgraph top gateoverflow.in/15606

The predessor subgraph of BFS is a tree but the predecessor subgraph of DFS is a forest ?? please explain why??

bfs goes breath wise imagine a tree step wise

dps grows like depth wise it will go on untill there is a cycle

 0 votes -- goku ( 101 points)

1.313 How does Kruskal algorithm detect cycle in the graph and what is the
time taken ? top gateoverflow.in/14587

Does it tale constant time or the time taken proportional to search in the entire partition of elements to find whether the
component lies in that same component or not ?

algorithms

To detect if two nodes are in same partition, it calls find() function (of disjoint-set data structure) two times. Amortized
time complexity of find function is O(α(V)), where α(V) is inverse Ackermann function, which we can assume to be constant
for all practical purpose. So yes, detecting cycle takes almost constant amount of time.

In the worst case, we have 2 ∗ E find calls, and hence detecting cycles in whole algorithm is O(E), but since sorting takes
O(ElogE) time, overall complexity of algorithm is still O(ElogE).

 1 votes -- Happy Mittal ( 9253 points)

I think, Kruskal's algorithm can be sure of a cycle when , for an edge (u,v), the condition FindSet(u) == FindSet(v)
evaluates to true, which means that both belong to same set.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 188 of 2244

The time , it would take would be atleast E*log(E) since it has to sort the edges first, before doing anything. In the worst
case , the edge causing cycle may be the last edge to be examined in the for loop(see CLRS). Thus in the worst case it is
same as running time of algo i.e E*log(V), since |E| < |V|^2.

 1 votes -- lowOnATP ( 135 points)

1.314 What does fun2() do in general in the below recursive code ? top gateoverflow.in/13860


int fun(int x, int y)
{
if (y == 0) return 0;
return (x + fun(x, y-1));
}

int fun2(int a, int b)


{
if (b == 0) return 1;
return fun(a, fun2(a, b-1));
}

algorithms


Selected Answer

Recurrence relation for fun(x, y) is

fun(x, y) = x + fun(x, y − 1) = 2x + fun(x, y − 2) = … = yx + fun(x, 0) = yx

That is fun(x, y) returns the product of x and y.

Now, recurrence relation for fun2 is

fun2(a, b) = a × fun2(a, b − 1) = a × a × fun2(a, b − 2) = … = ab × fun2(a, 0) = ab × 1 = ab .

Just a small change of

if (b == 0) return 1;

to

if (b == 0) return 0;

will have made fun2 return 0 always.

The given code returns ab .

 1 votes -- Arjun Suresh ( 124125 points)

its just doing this : X y

 1 votes -- Pranay Datta ( 6113 points)

1.315 How to calculate the computations performed on asymptotic notations


? top gateoverflow.in/13682

If I have f(n)= omega(n) and G(n)= Big O(n) then what would be f(n)*G(n)

also can we compute f(n) / g(n) and f(n)- G(n)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 189 of 2244


Selected Answer

Part 1 ans:

Let us say here "n" represent some function say h(n) so that we can more intuitively define the function,

Now, if f(n) = Ω(n) means in ours terms we can say f(n) = Ω.h(n) hence similarly g(n) = Ο.h(n)

Then according to the definition

f(n) = Ω.h(n) if

f(n) ≥ c.h(n) and -----------------(1)

g(n) = O.h(n) if

g(n) ≤ c.h(n) -----------------(2)

Now, g(n) ≤ c.h(n) ≤ f(n)

case 1: IF f(n), g(n) and c.h(n) are equal then,

f(n) * g(n) = [c.h(n)] 2

case 2: In all cases f(n) is greater than g(n) according to the definition (1) & (2)

Notion : f(n) > g(n)

or c 1.h(n) > c2.h(n) so as due to the const. "c 1" f(n) becomes larger than g(n).

Hence in this case: f(n) * g(n) = c 1.c2.[h(n)]2.

Part 2 ans: f(n)/g(n) always greater than or equal to 1.

Part 3 ans: f(n)-g(n) is always positive.

 2 votes -- Sanjay Kumar Monu ( 111 points)

1.316 Do we categorize all optimization problems in NP ? top gateoverflow.in/13433

I just want to confirm whether all optimization problems are in NP or not say to find the shortest path this can be done in
polynomial time and If I am given a graph and I have to find whether there exists any path between 2 vertices of length K so
after calculating shortest path I can check whether path exists so that means I can do it in polynomial time but in general
given a graph and If I have to find whether path exists or not ,its an NPC problem ,so is it that the optimization version of a
problem is polynomial solvable and its similar decision version is NP.

algorithms

not all optimization problem are in p,np. some are NP hard like longest path e.t.c.

what u have to understand -

DECISION PROBLEM ARE EASIER THAN SOLVING OPTIMIZATION PROBLEM.

i.e. a function is computable only when it is decidable.

decision problem are the problem which have answer in yes or no form

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 190 of 2244

see this theory and u may understand.-

we convert our optimization problem into decision problem so that it can become easy.

Take for example the Halting Problem of a Turing Machine, suppose someone asked you after how many steps the Turing
Machine will halt on a given input. To answer the exact number you first have to answer whether the Turing Machine is
going to halt or not. Then i may count the steps.
What we do is to convert our optimization problem to a decision problem. And if we are not able to give answer of that
decision problem we cannot compute it. So, computing is harder than saying yes or no. So if the problem is undecidable
then it will be also non computable.
so now u may understand where u are wrong if u can solve it in polynomial time definitely the decision problem will be
solved in polynomial time.

 0 votes -- Ravi Singh ( 7303 points)

1.317 what is the use of reducing a problem for which no polynomial time
algorithm exist into some another problem ? top gateoverflow.in/13393

If I have a problem A for which no polynomial time algo exists then what do we achieve by reducing it to another problem
B and then proving by contradiction that if we could solve B in polynomial time then we could even solve A but since no
polynomial time algorithm exists for A hence no polynomial time algorithm can exist for B also , hence A cannot be solved
in polynomial time

algorithms

we reduce a problem which is not polynomial to some other problem because we dont have any solution for for present
time..but in future we may have a polynomial solution....and such problems are called NP problems.We change these
problems in some other problem in polynomial time called NP hard problems...so that many NP problms can be converted
into one NP hard solution..and we have to find solution for only one NP hard problem inspite of many NP problms....

 0 votes -- nehab.sairam ( 23 points)

1.318 How does encoding of the problem instance affects the time
complexity of the algorithm ? top gateoverflow.in/13391

If I take a problem instance in unary representation then will the algorithm take exponential time and what if the problem
instance is converted into binary representation then will the time complexity remain same or will it be polynomial in time ?

algorithms

If you change the encoding of the input, you've changed the formal definition of the problem, which means it's a different
problem. The complexity of the original problem doesn't change

 0 votes -- Rohan Ghosh ( 1515 points)

1.318 Let s be a sorted array of n integers. Let t(n) denote the time taken for
the most efficient algorithm to determined if there are two elements with
sum less than 1000 in s.What will be the time complexity??????? top gateoverflow.in/13441

O(1) since the array is sorted we have to find the sum of first two elements only if their sum is less than 1000 than
output will be yes if not than since the elements are sorted if the sum of first two elements is not less than 1000 than the
sum of no two elements would be less than 1000 and output would be no.

 3 votes -- shreshtha5 ( 1227 points)

1.319 Given an unsorted array. The array has this property that every

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 191 of 2244

element in array is at most k distance from its position in sorted array


where k is a positive integer smaller than size of array. Which sorting
algorithm can be easily modified for sorting this array and what is the
obtainable time complexity? top gateoverflow.in/13511

(A) Insertion Sort with time complexity O(kn)


(B) Heap Sort with time complexity O(nLogk)
(C) Quick Sort with time complexity O(kLogk)
(D) Merge Sort with time complexity O(kLogk)

what is the approach of doing this question ?

algorithms


Selected Answer

We can perform this in O(nlogK) time using heaps...

First, create a min-heap with first k+1 elements.Now, we are sure that the smallest element will be in this K+1
elements..Now,remove the smallest element from the min-heap(which is the root) and put it in the result
array.Next,insert another element from the unsorted array into the mean-heap, now,the second smallest element will be
in this..extract it from the mean-heap and continue this until no more elements are in the unsorted array.Next, use simple
heap sort for the remaining elements.

Time Complexity---

O(k) to build the initial min-heap

O((n-k)logk) for remaining elements...

Thus we get O(nlogk)

Hence,B is the correct answer

 4 votes -- debanjan sarkar ( 775 points)

1.320 How many recursive calls are made by gcd function ? top gateoverflow.in/13660

I have already gone through the links of stackoverflow on this topic but still couldn't understand it clearly , so please explain
the logic behind this .

algorithms


Selected Answer

The key to understand this is to observe that "when a is divided by b, remainder is always less than or equal to a /2
". Why ? Because if remainder is more than a/2, and since divisor is always greater than remainder, then divisor is also
more than a/2, and so sum of divisor and remainder becomes more than a, which can't be possible.

Now when we find gcd(a, b), (suppose a > b, if not, swap a and b), in the first step, a is dividend and b is divisor, we find
some remainder r1 . Then in second step, r1 becomes divisor and b becomes dividend. Now again we divide b by r1 and get
some remainder r2 , but due to above property, r2 ≤ b/2.

So in two steps, remainder is at most b/2. We terminate the process once we reach remainder of 0. In the worst case,
every 2-step reduces remainder to b/2, and thus we need log2 b such 2-steps, or total 2log2 b steps.

So gcd(a, b) requires at most 2log2 b recursive calls where b is min (a, b).

It is worth noting that number of recursive calls depends only on smaller number (not larger number).

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 192 of 2244

 3 votes -- Happy Mittal ( 9253 points)

1.321 what is the tightest lower bound of the below pseudo-code ? top gateoverflow.in/13659

int isprime(int n )
{
for(int i=2;i<=sqrt(n) ; i++)
{
if(n%i==0)
{
not prime
}
}

algorithms

I think tightest lower bound is Ω(1) .

if you input is say 2 or 3 then it will i<=sqrt(n) become false and exit . and its worst case O(n^0.5)

this prog will be more efficient if there is break statement in the if part .

int isprime(int n )
{
for(int i=2;i<=sqrt(n) ; i++)
{
if(n%i==0)
{
not prime
break ;

}
}

 2 votes -- Pranay Datta ( 6113 points)

1.322 Are all NP problems reducible to NPC ? top gateoverflow.in/13570

I am a bit confused in this logic according to me all NPC are NP so that means all NPC are reducible to NP but since NPC are
NP-hard as well so I guess that is not possible since if x is reduced to y that means y must be harder than or equal to x that
means x cant be NPC since NP-hard is not easier than NP , so is it that all NP are reducible to NPC or all NPC are reducible to
NP , I am a bit confused in this , so please help.

algorithms

Any NP problem is reducible to any NP-Complete problem. Because that is how NP-complete problems are defined.

If a NP-complete problem is reduced to a NP problem, then that NP problem also becomes NP-complete- again, definition
of NP-complete problem.

 0 votes -- Arjun Suresh ( 124125 points)

1.323 BFS DFS top gateoverflow.in/10479

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 193 of 2244

1st : statement is definition of BSF search.


Bnd : BFS uses queue while DFS uses STACK.
3rd : if branching factor is 1 and hight is d then complexity of BFS ll be constant (according given statement) but BFS
search having linear complexity.
4th :Hill climbing algo perform this way.
first and last are true..

 1 votes -- Digvijay Pandey ( 26245 points)

1.323 how to calculate a,b,c,d value? top gateoverflow.in/10451

O(m+logn) = O(n^0 logn^1) + O(m^1logm^0)


compare this with O(n^a logn^b) + O(m^clogm^d)
a=0 , b=1 , c=1 , d=0

 0 votes -- Digvijay Pandey ( 26245 points)

1.324 question: top gateoverflow.in/5337

answer is c.
Can Any body suggest some analytical approach to solve it.

http://articles.leetcode.com/2011/01/find-k-th-smallest-element-in-union-of.html

 1 votes -- Arjun Suresh ( 124125 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 194 of 2244

1.325 Question: top gateoverflow.in/5326

Please answer both Question 9 and 10 both with approach.


Also in Question 9th which algorithm they assume since I believe answer varies according to algorithm as well.
In Question 10 answer given is 1.
Question 9 answer is d

9. Yes. it varies with algorithm and hence we must choose the best possible algorithm. Here, the best algorithm given only
n/2 swaps in the worst case. All given options are wrong.

http://gatecse.in/wiki/Moving_Negative_Numbers_to_the_Beginning_of_Array

10. Probability that a given number comes to its own position = 1/n.

So, expectation of X = 1 * 1/n + 1 * 1/n + ... + 1 * 1/n

= n/n = 1.

 1 votes -- Arjun Suresh ( 124125 points)

1.326 based on asymptotics, which of the following is true? top gateoverflow.in/5305

f(n) = O(g(n))
So, f(n) has growth less than or equal to g(n)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 195 of 2244

g(n) ≠ O(f(n))
So, based on first condition, f(n) has growth strictly lower than g(n).

g(n) = O(h(n)) and h(n) = O(g(n))


g(n) and h(n) have same rate of growth.

So, f(n) = O(h(n)) and g(n) ≠ O(f(n))

So, (b) and (c) are true. The inequality of (d) is false and it should be the answer.

I don't know how to interpret a choice.

 1 votes -- Arjun Suresh ( 124125 points)

I think it's option D

 1 votes -- sairamcsiiit ( 23 points)

1.327 Dijkstra shorest path algorithm top gateoverflow.in/5290

if Dijkstra shorest path algorithm takes 8 second for a graph of 1000 nodes then approximatly how much time would it take
for a graph of 1000000 nodes.

a) 8000000 sec.
b) 8000 sec.
c) 16000 sec.
d)16000000 sec.

The ans is D.

Dijkstra algo take E log V (v for vertices and e for edge ) and e is o(v^2)

so we can say V 2 log V ..........

with 1000 node no. of comparison done is (1000^2 log 1000) = X (say) .....

with 1000000 node no. of comparison done is (1000000^2 log 1000000) = Y (say) .......

X many comparison is done in 8 sec

1 many comparison is done in 8/X sec

Y many comparison is done in 8Y/X sec

and if you compute the result will be option d ...... peace

 0 votes -- Pranay Datta ( 6113 points)

1.328 question top gateoverflow.in/5353

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 196 of 2244

d. http://www.cs.cmu.edu/~avrim/451f11/lectures/lect1004.pdf

 1 votes -- Arjun Suresh ( 124125 points)

1.329 Answer the following questions top gateoverflow.in/5413

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 197 of 2244

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 198 of 2244

1.329 Best algorithm in terms of time to sort numbers within range 1 to n^5
top gateoverflow.in/5927

radix sort

 1 votes -- Vikrant Singh ( 10051 points)

1.330 Answer the following question top gateoverflow.in/5415

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 199 of 2244

1.331 Answer the following question top gateoverflow.in/5414

Please show steps for the question 20 and 14.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 200 of 2244


Selected Answer

Q.20) 1st pass [20,47], [8,15],[4,9],[30,40],[12,17]

2nd pass [8,15,20,47],[4,9,30,40],[12,17] So (B) is the answer

Q.14) http://lcm.csa.iisc.ernet.in/dsa/node112.html

 0 votes -- Keith Kr ( 5467 points)

1.332 sorting top gateoverflow.in/5057

B. It is same as selection sort. .

 3 votes -- shreya ghosh ( 2801 points)

1.333 time complexity of for loops of program is? top gateoverflow.in/4987

for(i=1;i<=n;i++)

for(j=1;j<=n;j=j+i)

x=x+1;

i = 1 | 2 | 3 | 4 | 5 |.................n

j =nt | n/2t | n/3t | n/4t | n/5t |..................|1| + C

total = n(1+1/2+1/3+1/4+1/5.............1/n)+C

O(nlogn).

 3 votes -- Arpit Dhuriya ( 1791 points)

1.334 Time Complexity top gateoverflow.in/4691

f(n)= n^0.0000001

g(n)=lg n(base 2)

Is g(n)=O(f(n))...?

For the large values of n

n= 10^8 f(n)= 1.0000018 , g(n)=26.565

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 201 of 2244

n=10^10 f(n)=1.0000023, g(n)=33.21

So I am getting f(n)=O(g(n))...

Can anyone please explain why g(n)=O(f(n))....?

There is no limit on a large value being considered.

f(n)= n^0.0000001 = n^(10^-7)


g(n)=lg n(base 2)

n= 10^8 f(n)= 1.000001842 , g(n)=26.565

Now, I take n = 10^(10^8)

f(n) = n^(10^-7) = (10^(10^8))^(10^-7) = 10^(10^(8-7)) = 10^10


g(n) = 10^8 log10 2

So, f(n) becomes larger. Thus for any x, we can have an n, where n x becomes larger than log n and stays larger from there
on wards for any higher n.

 0 votes -- Arjun Suresh ( 124125 points)

1.335 Omega notation top gateoverflow.in/4657

Is sqrt(n)+ log n = omega(log n)? If yes then please explain why...?

1.336 B+ Trees Problem top gateoverflow.in/4564

Construct a B+tree for the following set of key values:


(2, 3, 5, 7, 11, 17, 19, 23, 29, 31)
Assume that the tree is initially empty and values are added in ascending order. What will be
the root of the constructed B+ tree if the number of pointers that will fit in one node is six?
(A) 7, 11 (B) 7, 19 (C) 19 (D) 11

Ans is B...Please explain.....


Selected Answer

http://www.cs.ucla.edu/classes/fall04/cs143/solutions/chap12a.pdf

 0 votes -- Keith Kr ( 5467 points)

1.336 What will be the complexity to find the 7th smallest element in a heap?
top gateoverflow.in/3430

It is a GATE 2003 question- you can see answer here.


http://gateoverflow.in/1110/gate2003_23

 1 votes -- Arjun Suresh ( 124125 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 202 of 2244

1.337 DFS cross edges, forward edge and back edges top gateoverflow.in/4774

Please explain....why answer is d)

Tree edges{(a,b),(b,e),(e,c)} Cross edges{(d,a),(d,b)} Back edges{(c,b)}

 0 votes -- Bhagirathi Nayak ( 10239 points)

1.338 Time Complexity- Why n is not considered in recurrence relation...? top


gateoverflow.in/4790

1.339 time complexity of a program is? top gateoverflow.in/4986

for(i=1;i<=n;i++)

for(j=n/3;j<=2n;j+=n/3)

x=x+1;


Selected Answer

it should be O(n). inner loop runs for constant number of times for every iteration of outer loop, hence we need to
consider only outer loop complexity.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 203 of 2244

 2 votes -- Laxmi ( 683 points)

inner loop is independent of outer loop. no need of unrolling.

outer loop run for n time and inner loop jump for n/3 which is may be logn. so total will be

O(nlogn).

 1 votes -- Arpit Dhuriya ( 1791 points)

1.340 fine the recurrence relation and time complexity of this question? top
gateoverflow.in/4921
5. Determine the average processing time T(n) of the recursive algorithm:
1 int myTest( int n ) {
2 if ( n <= 0 ) return 0;
3 else {
4 int i = random( n - 1 );
5 return myTest( i ) + myTest( n - 1 - i );
6 }
7 }
providing the algorithm random( int n ) spends one time unit to return
a random integer value uniformly distributed in the range [0, n] whereas
all other instructions spend a negligibly small time (e.g., T(0) = 0).

Hints: derive and solve the basic recurrence relating T(n) in average to
T(n−1), . . . , T(0). You might need the equation 1/1·2 + 1/
2·3 +· · ·+ 1/n(n+1) =n/n+1 for deriving the explicit formula for T(n).

T(n)=n/n+1 so T(n)=O(n)

and yes thank you for posting such an awesome question

regards

grv.

 1 votes -- gaurav bajpai ( 27 points)

1.341 Explain top gateoverflow.in/4918

algorithms

Here, because of adjacency matrix it will take V 2 and because of linked list we have to traverse all nodes therefore it will
take V time.

hence O(V 3)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 204 of 2244

 1 votes -- jayendra ( 5797 points)

1.342 Prim's Algorithm top gateoverflow.in/6275

Which one of following statement is false about prim's algorithm?

a) It use a running time of O(Elog 2V) using binary heap

b) It may use a binomial max-heap to represent the priority queue.

c) A fibonacci heap imlementation require O(E+V log 2V)

d) Initially all keys of nodes in priority queue are set to infinity . The root's key is set to 0.

answer should (b)

prims algo can be implemented using without heap (O(n^2)) , with binary heap ( O(VlogV+ElogV+O(E) = O(ElogV)) and
fibonacci heap (O(VlogV+E)) so option a,c are correct .

for option d this is initial step for implementation

option b which is wrong ...https://en.wikipedia.org/wiki/Binomial_heap

 2 votes -- sonam vyas ( 6441 points)

a.is ans ..correct is O(E+V)Logv

 2 votes -- Prashant Singh ( 73 points)

1.342 How can we found second smallest element with n+[lgn]-2


comparisons in worst case ?? top gateoverflow.in/6520

divide and conquer approach gives min element with n-1 comparison..
for 2nd minimum element search on d root to leaf path from where max element coming.. reason is second minimum
element must compared with minimal element when we were finding minimum element.. so ,

divide and conquere based on binary tree approach so no of elements from root to leaf path is logn .. finding min from
logn elements takes logn -1 comparison..
total n-1+logn-1 = n + logn -2 comparison

 1 votes -- Digvijay Pandey ( 26245 points)

1.343 Time complexity top gateoverflow.in/9704

In the best case, the number of comparisons needed to search a single linked list of length n for a given element is is ............

and

In the best case, the number of comparisons needed to search a double linked list of length n for a given element is ................

and is it possible to apply binary search on single linked list if the elements are sorted?

in worst case n comparison are needed to search for an element in single linked list.
in best case double linked list / single linked list ll take single comparison for an element . complexity will be O(1)..

Binary search works on linked list too but it is notefficient because it will take O(n) time to find middle element, after that
it ll take some more time to processe algo ..

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 205 of 2244

O(n) time + extra time .. it is not efficient bcause O(n) time already elapsed what is use of Binary search ? same can b
done by sequential search by exact n comparison..

 3 votes -- Digvijay Pandey ( 26245 points)

1.344 Time complexity top gateoverflow.in/9703

T(n+1)=T(n)+ceil[√(n+1)] , n>1

=1,n=1

T(1) = 1

T(n) = T(n-1) + ceil (√(n)

T(2) = 1 + 2 = 3 = 2n - 1

T(3) = 3 + 2 = 5 = 2n - 1

T(4) = 5 + 2 = 7 = 2n - 1

T(5) = 7 + 3 = 10 = 2n

T(6) = 10 + 3 = 13 = 2n + 1

T(7) = 13 + 3 = 16 = 2n + 2

T(8) = 16 + 3 = 19 = 2n + 3

T(9) = 19 + 3 = 22 = 2n + 4

T(10) = 22 + 4 = 26 = 2n + 6

The term after + is growing in the order of √n. So, we can say T(n) = 2n + O(√n) = O(n).

 1 votes -- Arjun Suresh ( 124125 points)

1.345 Time comp top gateoverflow.in/9702

T(n)=√nT(√n)+√n , n>2

=2 ,n=2

T(2) = 2

T(4) = 2T(2) + 2 = 6

T(16) = 4T(4) + 4 = 28

T(256) = 16T(16) + 16 = 464

So, T(n) = O(n).

 1 votes -- Arjun Suresh ( 124125 points)

1.346 Time com top gateoverflow.in/9649

Consider a binary tree having 'n' elements or 'n' nodes the tree is organised in such a way that at every level 'i' there are 'i'
nodes assuming root to be at level 1 the height or depth of binary tree is O(......)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 206 of 2244


Selected Answer

at ith level total i node..


total nodes = 1+2+3+4+5........i
= i(i+1)/2
=O(i^2)

but it ia given no of nodes = n


O(i^2)= n
i= O(root n)
i is depth of tree.

 3 votes -- Digvijay Pandey ( 26245 points)

1.347 Greedy method top gateoverflow.in/10031

what approch does the greedy method follows

a)Top down b)Bottom up

I heard the answer as Top down why it is? can any one explain me please

What does a greedy man do? He always chooses the best available option at the moment. Similarly, greedy algorithm
chooses the best available option at the moment and proceeds further and there is no comeback. So, it is a Top Down
Approach as we start from the top of the problem and gradually reaches the bottom.

On the other hand bottom up approaches like backtracking explores a solution till the end as as soon as it finds that
unfeasible backtracks and then proceeds on a different route. So, this can be considered finding the solution from the
bottom.

 3 votes -- Arjun Suresh ( 124125 points)

1.348 Optimal binary search tree top gateoverflow.in/10032

Given the following table of data what are the minimum expected no.of comparisons required for an Optimal

i 0 1 2 3 4
Pi 3/16 3/16 1/16 1/16
Qi 2/16 3/16 1/16 1/16 1/16

BST that can be constructed with the given data

Just finding the expected number of comparisons:

1 * 3/16 + 2 * 3/16 + 3 * 1/16 + 4 * 1/16 + 0 * 2/16 (when no external nodes are accessed) + 1 * 3/16 + 2 * 1/16 + 3
* 1/16 + 4 * 1/16

= 1 + 12/16 ≈ 2 comparisons.

But I don't get the meaning of "optimal BST that can be constructed". Something else meant in the question?

 0 votes -- Arjun Suresh ( 124125 points)

1.349 find the running time of the following nested loop top gateoverflow.in/10444

for(i=1;i<=n;i=i*2);

for(j=1;j<=i;j=j+1);

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 207 of 2244

if i*2 = 2i then :

for i = 1 , 2nd for loop executes 1 time.


for i = 2 , 2nd for loop executes 2 times.
for i = 4 , 2nd for loop executes 4 times..
for i = 8 , 2nd for loop executes 8 times.
.
.
for i = logn , 2nd for loop executes logn times..
complexity = O(1+2+4+8+16+.........+logn)
= O{1(2^logn-1)/(2-1)}
= O(1*(n-1)/1) = O(n)

if i*2 = i^2 then :


for n=0 complexity will be constant.
for n>=1 infinite loop

 1 votes -- Digvijay Pandey ( 26245 points)

1.350 find out the no. of spanning tree possible top gateoverflow.in/10154

total 9 edges and 6 vertices..


for spanning tree we need 6 vertices and 5 edges..
no of graphs with 5 edges : 9C5
no of graph with 3 length cycle (may be disconnected) = select any cycle of length 3 (select any small triangle) and then
out of 6 vertices select any 2..
= (6C2)*3 + 12(for middle triangle) = 57

find no of 4 length cycle = select 4 length cycle and for rest 1 edge select those edges which doesn't produces 3 length
cycle..
= 4 + 4 + 4 = 12

no of 5 length cycle = 3

total spanning tree = 126 - (57 + 12 + 3)


= 126 - 72
= 54

 1 votes -- Digvijay Pandey ( 26245 points)

1.351 Give an algorithm to finding duplicate parenthesis in a expression ? top


gateoverflow.in/10069
suppose expression is like : ((a+b)+((c+d))), so how to find duplicate parenthesis in the given expression ?

algorithms

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 208 of 2244

We can have a basic parenthesis matching algorithm were we use a stack and match each opening and closing braces.
Now, along with an opening brace we can also store its index and while matching the closing brace, we can find duplicates
if the matches are consecutive. i.e.; if the closing braces are consecutive and the indices of their matching opening braces
are consecutive, then they are duplicates.

 1 votes -- Arjun Suresh ( 124125 points)

1.352 Time complexity top gateoverflow.in/9648

Consider a sorted array of 'n' elements an element in the array is said to be majority element if it is occuring more than n/2
times of the array, the time complexity of algorithm which is most efficient to determine if the array contains majority
element or not is O(... )?

O(Log n) by Divide and conquer

 0 votes -- Murali ( 153 points)

1.352 f(n)=n+ logn is O(n) and Ω(n) can any one explain me please top gateoverflow.in/9647

Yes. Both are true and hence we can also use theta notation. This basically means f(n) has the same order of growth
(asymptotically) as n. So, for very large n, value of f(n) will be growing same like n (log n will become negligible).

 3 votes -- Arjun Suresh ( 124125 points)

1.353 Master Theorem top gateoverflow.in/6979

When do we say that 2 functions are polynomially comparable for applying master theorem...? We can apply the theorem for T(n)=3T(n/4)+nlgn but cant
apply it for T(n)=2T(n/2)+nlgn ...please explain..?

T(N)=3T(N/4)+NLOGN

T(N)=THETA(NLOGN)

HERE a=3,b=4 k=1,p=1,

a<b^k

AND p>0

T(N)=THETA(N^K LOGP(BASE N))

 0 votes -- sourav anand ( 1585 points)

1.354 What is the Generating function G(z) for the sequence of Fibonacci
numbers? top gateoverflow.in/6694

Actually i want to know the method for finding Generating function.

http://db.math.ust.hk/notes_download/elementary/algebra/ae_A11.pdf

http://www.cut-the-knot.org/blue/GeneratingFunctions.shtml

 0 votes -- Keith Kr ( 5467 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 209 of 2244

1.355 If lower bound and upper bound of a recurrence relation are not
asymptotically equal, then is it possible for it to have a theta notation? top
gateoverflow.in/6657
Is theta notation possible for all recurrence relation?

No.

See this question from CLRS 3rd edition, page 53 (page 74 if including the cover, index and all)

 3 votes -- Pragy Agarwal ( 13675 points)

1.355 can any1 explain how to find maximum flow in graph from source to
sink. pls top gateoverflow.in/7351

Maximal flow algorithms are in Cormen.

http://en.wikipedia.org/wiki/Maximum_flow_problem

 0 votes -- Arjun Suresh ( 124125 points)

1.356 What is the worst case time complexity to find the gcd(m,n) using best
algorithm known? top gateoverflow.in/7693

What is the worst case time complexity to find the gcd(m,n) using best algorithm known?

A. O(log(min(m,n)))

B, O(log(max(m,n)))

algorithms

Check http://mathworld.wolfram.com/EuclideanAlgorithm.html

Lamé showed that the number of steps needed to arrive at the greatest common divisor for two numbers less than n is

So O(log min(a, b)) is a good upper bound.

 0 votes -- Bipin.B ( 63 points)

1.357 How could you find first occurence in Logn time using a variant of BS?
top gateoverflow.in/9240

I mean i guess it should be in O(n/2) i.e. O(n) time. Because one must check for every element starting from the first one till
n/2 th element & for each of which one must whether A[i]==A[n/2 +i].

Please explain.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 210 of 2244

Let for a particular index i check that condition A[i]==A[i+1] or not..


if it is true then (check A[2i]==A[n/2+1] or not )
else select i+1 for same purpose..

let size of array is 100 and A[0]=A[2]=A[4]!=A[8]


then dont check for A[2] as well as A[4]..
this ll reduce no of comparison to logn..

 1 votes -- Digvijay Pandey ( 26245 points)

1.357 How to build the decision tree?? top gateoverflow.in/9223

A[i] > max

this is a node in decision tree. With n-1 such comparisons we can get the max element. Now, the second max element will
be compared to the max element during any one such comparison. So, to find the second largest element, we just need
to save all the elements being compared to "max" and getting the max of them.

 0 votes -- Arjun Suresh ( 124125 points)

1.358 minimum number of comparison required to compute the largest and


second largest element in an array is top gateoverflow.in/8963

a) n- ( lg(n)) - 2

b) n + (lg(n)-2)


Selected Answer

we can start comparing the elements pair wise and build a decision tree in which case it takes n-1 comparisons to obtain the highest element.

In order to get the second highest element we need to check only those elements which were compared with the highest element while building the decision tree, now as the height of
the tree is logn as logn comparisons are required for the highest element to reach the top, so to obtain second highest element one need logn-1 comparisons so all together n-1+logn-
1=n+logn-2 comparisons are required.

 2 votes -- computer science research ( 255 points)

1.359 The number of leaf nodes in the recurrence tree of the recurence T(n)
= T(n/4) + T(n/2) + n^2 top gateoverflow.in/15776

The number of leaf nodes in the recurrence tree of the recurence

T(n) = T(n/4) + T(n/2) + n^2


Selected Answer

i think exact number of leaf nodes is somewhat hard here. what we can do is can find upper bound and lower bound .

upperbound - the greater function is n/2. so if we draw the tree of the function it will half full . for upperbound consider it
to be fuly filled . and as n/2 is going till the end .

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 211 of 2244

height of tree will be logn base 2 . taking only n/2 in consideration.


no . of leafs at height h =2^logn base 2 which will be equal to n.

lower bound . consider it fully filled by taking n/4 in consideration.

so no of leafs in that case = 2^logn base 4

n^0.5
no of nodes will be betwen n^0.5 to n .

 0 votes -- Ravi Singh ( 7303 points)

1.360 tree top gateoverflow.in/15783


Selected Answer

Should be 2^n, every node having two choices either left or right.
Degree of internal nodes should be 2 and degree of leave and root should be 1.

 0 votes -- Digvijay Pandey ( 26245 points)

1.361 dijkstra's negative weight yr ans required top gateoverflow.in/30567

the answer should be none . as both 1 and 2 are true. it doesn't matter the graph is directed or undirected., the minimum
cost spanning tree will not change by adding constants till the weights are kept unique. while dijisktra gives the right
answer if made to run on a graph with no negative cycle. so c is true. 1 and 2 are wrong

 0 votes -- Ravi Singh ( 7303 points)

1.362 O(klogk) time algorithm to find kth smallest element from a binary
heap... top gateoverflow.in/30524

time complexit..?

Q1. to find kth smallest element from a binary heap...

a) O(k log k) b) O(k log n) c) O(1) d)O(nk) e) a,b both

Q2. Print the biggest K elements in a given heap in O(K*log(K))____________?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 212 of 2244

Q.3 how to determine if the kth largest element of the heap is greater than x____?

1.363 Please help top gateoverflow.in/30515

Can someone plz help me understand union find algo?

Or provide a good resource other thah GfGeeks,for this

1.364 successful and unsuccessful in hashing top gateoverflow.in/30378

i'm confused where and when to use these two formula, someone explain plz

1.365 How to solve the fractional knapsack problem using heap ? top gateoverflow.in/30649

If I use the values of profit/weight and apply build-Max-heap to these values then I will get a max-heap in order(n) time
,Now the confusion is how to delete-the maximum value since after I delete the maximum value how will I come to know
what is the weight associated and the profit associated with the node stored in the heap since heap stores only the values
associated with profit/weight .

So to perform further calculations like reducing the capacity of the knapsack and adding profit values to already obtained
profit values ,how will I do these calculations ?

1.366 merge sort top gateoverflow.in/30716

merge sort algo takes 30sec for input size of 64 in worst case, then max input size solvabe in 6 minutes?

512 64 1024 2048


Selected Answer

Worst case of merge sort = n * log n

For n = 64, it takes 30sec:


=> 30 = k * (64 * log 64)
=> k = 0.078125sec.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 213 of 2244

Therefore, in 6 min. = 6*60sec. = 360sec.


=> 360 = 0.078125 * n * log n
=> n * log n = 4608
=> n = 512.

 2 votes -- Monanshi Jain ( 5827 points)

1.367 what is "DAC Max-Min algorithm" | ME Basic test algorithms top gateoverflow.in/30787

Consider a set of 20 elements.


To find maximum and minimum element in the given set, the minimum number of comparisons required is _________?
(using DAC Max-Min algorithm)


Selected Answer

DAC max min algo = >U sing Divide and conquer Finding maximum and minimum in a array.

T(n) = 0 if n=1
1 if n=2
2T(n/2) +2 if n>2

therefore T(n) = 1.5n - 2 = O(n)


for 20 element 1.5*20 -2 = 28

 0 votes -- Umang Raman ( 10379 points)

1.368 How to solve: Partition(Quick sort) with pivot not in center? top gateoverflow.in/30782

simply make one move in the beginning to swap the 15 to position from where u are comfortable to apply quick sort
algorithm either at middle, first position or last.

 0 votes -- Abhishekcs10 ( 1001 points)

1.369 recurrence relations top gateoverflow.in/30781

Solution for recurrence relation T(n)=T(n/2 + 2)+n using recursion tree method?

1.370 Parameter Passing | GATE 1993 | common data questions 6 marks top
gateoverflow.in/30298

Consider the block of code given below:

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 214 of 2244

Program PARAM(input,output);
var m,n:integer;

procedure P(var x,y:integer);


var m:integer;
begin
m:=1;
x:=y+1;
end;

procedure Q(x:integer; var y:integer);


begin
x:=y+1;
end;

begin
m:=0; P(m,m);write(m);
n=0; Q(n*1,n);write(n)
end;

30. The value of m, output by the program PARAM is


a)1, because m is a local variable in P
b)0, because m is the actual parameter that corresponds to the formal parameter in P
c) 0, because both x and y are just reference to m and y has the value 0
d)1, because both x and y are just references to m which gets modified in procedure p

31. The value of n, output by the program PARAM is


a)0, because n is the actual parameter corresponding to x in procedure Q
b)0, because n is the actual parameter to y in procedure Q
c)1, because n is the actual parameter corresponding to x in procedure Q
d)1, because n is the actual parameter corresponding to y in procedure Q
e)None of the above

32. What is the scope of m declared in the main program?


a)PARAM,P,Q

b)PARAM,P

c)PARAM,Q

d)P,Q

30. Option b, 0, because goobal m is not modified, m is just passed to formal arguments of P.

31. Option e, 0, because n is just passed to formal parameters of Q and no modification in global n.

32. Option a, since m is defined global it is visible inside all the procedures.

 1 votes -- Monanshi Jain ( 5827 points)

1.371 what is the effect of problem size of the complexity of divide and
conquer algorithms and why ? top gateoverflow.in/30187

Considering the partition algorithm in quick-sort , depending on any input sequence it will be called n times only so then
what is the usage of dividing the problem into equal halfs , through recurrence relation formation I am able to figure out that
time complexity is less if we have problem to be divided at each level in equal halfs but I am not getting logic behind this .

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 215 of 2244

algorithms

1.372 P, NP ,NP complete top gateoverflow.in/29303

Q) If the lower bound for the running time of an algorithm to solve a problem L is O(22n ) and L is in NP class. Which of the
claims is/are true?

1). P = NP

2). P! = NP

3). P <= NP

4). L is NP complete

A). only II

B). II and III

C). II,III and IV

D). None of the above is true

1.372 Do i need to study P, NP computational problems like vertex cover


problem also for gate 2015 or only the basic definitions? top gateoverflow.in/115


Selected Answer

You would need to know some examples (not all) of NP Complete problems and why they are NP Complete. For example 3SAT problem is
NPC and in GATE they have asked about 2SAT. So, just learning some examples won't be enough.

 4 votes -- Arjun Suresh ( 124125 points)

Yes you need to study P, NP computational problems

 2 votes -- Omesh Pandita ( 2209 points)

1.373 huffman coding top gateoverflow.in/29250

we use huffman encoding to encode a b c with frequency fa fb fc.Which of the following code sequence is not possible?

code 1={0,10,11}

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 216 of 2244

code 2={0,00,1}

code 3={10,00,01}

Only code 1 is possible

Code 2 and code 3 is not possible.

Code 2 => 0 & 00. Here give 000, we can not distinguish 0 00 and 00 0 and 0 0 0.

Code 3 => Here issue is that this code can not be generated by Huffman algorithm in first place. It is simply not possible.
(Try to take any example you can see you can not generate this. You can generate (00,01,10,11) but not just 3 of those
!)

 1 votes -- Akash ( 26315 points)

Huffman coding makes sure that there is no ambiguity when we decode the bit stream code .so the The variable-length
codes assigned to input characters are Prefix Codes, means the codes (bit sequences) are assigned in such a way that the code
assigned to one character is not prefix of code assigned to any other character.

so code 1 which is possible ...this follow the prefix property ... ( no prefix is otherone prefix)..

code 2 which is not possible ... bcoz 00 does not follow the prefix property , 0 is code 00 also contain 0 as
prefix ,

code 3 it follows prefix property but one of them should be only one bit code ....so its not possible..

ref :http://www.geeksforgeeks.org/greedy-algorithms-set-3-huffman-coding/

 1 votes -- sonam vyas ( 6441 points)

b is not posiible

try to make tree like huffman algo quetion.

http://www.cs.umd.edu/class/fall2012/cmsc132h/Projects/P7/project7.html

 1 votes -- Anirudh Pratap Singh ( 4091 points)

1.374 longest common subsequence top gateoverflow.in/28916

For X= BDCABA and Y=ABCBDAB find length of lcs and no of such lcs..(solve it using table method)

The length of LCS is 4

BCAB,BCBA,BDAB

This will help you as you requested in tabulation method.

https://www.youtube.com/watch?v=P-mMvhfJhu8

 1 votes -- Prasanna Ranganathan ( 2045 points)

1.375 NP complete top gateoverflow.in/29304

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 217 of 2244

Q). Which of the following can we infer from the fact that the travelling salesperson problem is NP-complete.if we assume
that P is not equal to NP ?

A). There does not exist an algorithm that solves arbitrary instances of TSP problem.

B). There does not exist an algorithm that efficiently solves arbitrary instances of the TSP problem.

C). There exists an algorithm that efficiently solves arbitrary instances of the TSP problem , but no one has been able to find
it.

D). None of these

i think b is true. we can solve travelling salesman problem but the complexity is exponential . so can say better algorithm
does not exist

 2 votes -- Ravi Singh ( 7303 points)

1.376 Computing the value of P top gateoverflow.in/29412

programming algorithms


Selected Answer

From i=1 to n

"if(j<i)" this condition true till only for every j=i-1 times
So, P=0+1+2....+(n-1)=n(n-1)/2

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 218 of 2244

and for i=(n+1) to (2n-1)

"if(j<i)" This will true n-1 times


P= n(n-1)

Total value of P=n(n-1)+(n(n-1))/2=3(n 2-n)/2


 2 votes -- Avdhesh Singh Rana ( 1509 points)

1.376 why does quick-sort work better than merge-sort for small inputs ? top
gateoverflow.in/30097

For smaller inputs quick sort perform better than the merge sort, due to the fact the merge sort is not in place unlike
quick sort. We need more amount of space in case of merge sort.

 0 votes -- Monanshi Jain ( 5827 points)

1.377 time complexity top gateoverflow.in/29773

1. n > (log n) log n

2. 2n > n√n

3. 2n > n log n

explain plz


Selected Answer

1. n > (log n) log n

take log on both side

we get logarithmic value of n is log n.............i

logarithmic value of (log n) log n is log n(log log n)..................ii

Now put n=22^x

putting it in i we get log n =2 x

putting it in ii we get (log n) log n = log n(log log n) =2 x . x

then n < (log n) log n

2. take log in both the function

2n taking log value will be n log 2 =n .................i

n√n taking log value will be √n log n ...................ii

again take n=2x

2n =n log 2 =n taking n=2x value will be 2x ...................... iii

n√n = √n log n taking n=2 x value will be 2x/2 . x ............iv

Here 2x > 2 x/2 . x

So, 2n > n √n

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 219 of 2244

3. take log on both side

2n taking log value will be n

nlog n taking log value will be log n . log n =(log n) 2

Here too linear value of n will be greater than logarithmic value of (log n) 2

So, 2n > n log n

 3 votes -- srestha ( 11585 points)

1.378 asymptotic notation top gateoverflow.in/29499

show that k lnk =ϴ(n) then k= ϴ(n/lg n)

klogk = Θ(n)

⇒ c1 ⋅ n ≤ klogk ≤ c2 ⋅ n

Now assuming n and k are greater than 1, taking log of each of the terms above will not change the inequality so we can
write,

log(c1 ⋅ n) ≤ log(k ⋅ logk) ≤ log(c2 ⋅ n)

⇒ (log(c1) + log(n)) ≤ (log(k) + log(logk)) ≤ (log(c2) + log(n))

Now since we know that

log(logk) ≤ log(k)

let us write (log(k) + log(logk)) = 2log(k).

To maintain the inequality,

(log(k) + log(logk)) ≤ (log(c2) + log(n)),

after changing (log(k) + log(logk)) to 2log(k),

we should multiply (log(c2) + log(n)) by 2, to compensate the increment in the middle term.

⇒ (log(c1) + log(n)) ≤ 2log(k) ≤ 2(log(c2) + log(n))

To make this inequality more clear let's write it using new constants as follows,

c3(log(n)) ≤ c4(log(k)) ≤ c5(log(n))

On dividing c1 ⋅ n ≤ klogk ≤ c2 ⋅ n by the above inequality we get,


c1 n 1 klog k c2 n

( )( ) ( )( ) ( )( )
c3 log (n )
≤ c4 log (k)
≤ c5 log (n )
.

c1 n 1 c2 n


( )( ) ( ) ( )( )
c3 log (n )
≤ c4
k≤ c5 log (n )

c1 ⋅c4 n c2 ⋅c4 n


( )( ) ( )( )
c3 log (n )
≤k≤ c5 log (n )

( )
⇒ k = Θ log (n ) .

PS - I am not very sure about the inequalities division step.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 220 of 2244

 0 votes -- Anurag Pandey ( 8183 points)

1.379 are these two recurrences equivalent? top gateoverflow.in/30832

Do they differ or are they same?

they are confusing me/


Selected Answer

yes both the recurrences are same here.

Just to give you an idea about where may be the difference of recurrence relation.Consider two functions A() & B().

A(n) {

if(n<=1) return 1;

else

return ( A(n/2) + A(n/2) + n );

Recurrence for Time Complexity : T(n) = 2*T(n/2) + 1

Recurrence for Value : T(n) = 2*T(n/2) + n

B(n) {

if(n<=1) return 1;

else

return ( 2*A(n/2) + n );

Recurrence for Time Complexity : T(n) = T(n/2) + 1

Recurrence for Value : T(n) = 2*T(n/2) + n

In this A and B both will return the same value so for getting value for some number n,they will result in same but both
the functions having different time complexity as you can see we are getting separate recurrence relation for time
complexity.

For Function A, we are getting 2*T(n/2) because we are going to call same function 2 time but in function B,we are taking
only T(n/2) because we are calling function only one time after getting the value of T(n/2) we are simply multiplying it by
2.

 0 votes -- Sandeep Singh ( 5939 points)

1.380 spanning tree top gateoverflow.in/30853

104. An undirected graph ( , ) contains ( > 2) nodes named 1 , 2 , . . . . Two nodes


, are connected if and only if 0 < | | ≤ 2 Each edge ( , ) is assigned a weight �
� + ��. What will be the cost of the minimum spanning tree (MST) of such a graph with �� nodes?

A.(11��− 5��) B. ��2− �� + 1 C. 6�� − 11 D. 2�� + 1

105. The length of the path from �� to �� in the MST of previous question with �� = 10 is

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 221 of 2244

A. 11 B. 22 C. 27 D. 31

104) ans will be (C)

105) ans will be 60-11=49 (not given in option)

 0 votes -- srestha ( 11585 points)

1.381 algo top gateoverflow.in/31561

if all edge in the graph have distinct weight the the sortest path between two vertex is unique?/

Maybe not possible if total weight from source to destination vertex is equal for two different routes.

But if you use min priority queue then may be possible that it will give same shortest path always.

 1 votes -- ASHUTOSH KAKADIYA ( 55 points)

1.382 probability of split in partitioning procedure of quicksort top gateoverflow.in/31482

consider modifying partitioning procedure of quicksort by randomly picking up three elements from array and computing
their median(middle of 3 elts). Approximate probablility of getting at worst ab a to (1-a) split in the range 0<a<1?

1.383 Is it possible to delete intermediate node/number in Heap? top gateoverflow.in/31408

Is it possible to delete intermediate node/number in Heap? Not a root or last.

algorithms

Yes you will have to traverse the entire heap in worst case and then delete it, then replace that position with the last
element and then call Build-heap procedure.

 1 votes -- radha gogia ( 4369 points)

1.384 probability of a split in partitioning procedure of quicksort top gateoverflow.in/31403

probability of a split more balanced than a to (1-a) split in partitioning procedure of quicksort where 0<a<=1/2?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 222 of 2244

1-3a 1-2a a+1 none

I believe (1 − 2a) should be the right answer.

Partition will divide original array into two sub arrays.

I am using a random variable X to denote the fractional length of smaller partition of the original array with respect to the
length of original array.

Consequently, the fractional length of the larger partition will be (1 − X) with respect to the length of original array.

For example suppose, X = 0.2 then it will indicate that our smaller sub array (among the two sub arrays that we got after
partitioning) is 0.2 time the original array.

and hence the larger sub array is (1 − 0.2) or 0.8 times the original array.

Since X is denoting the fractional length of smaller sub array after partition, its value can not exceed more than 0.5 times
the original array otherwise it will no longer be the smaller sub array.
1 1

( ]
Hence the domain of random variable X is 0, 2 , that is X can take any values between 0 and 2 .

1 1

It can be inferred that as X approaches to 2 , (1 − X) also approaches to 2 , that is the sizes of two sub arrays are being
equal or in other words the partition becomes more balanced.

X = 2 means we have got two sub arrays of equal size,and both of them are 0.5 times the original array, this is the most
desirable situation from the efficiency's point of view.

As X approaches to 0, the partition becomes more unbalanced.

1
( ]
Now if we want a split more balanced than a ∣ (1 − a) where a ϵ 0, 2 , we have to set our random variable X ′ s value larger
1

than a, so that our random variable is more nearer to 2 , then the a is (as a value nearer to 2 implies a more balanced
partition).
1

So to get a partition more balanced than a ∣ (1 − a), X must lie in the range a, 2 .
( ]
Hence the probability of getting a more balanced split than a ∣ (1 − a) is same as P(X > a),
length of favourable domain of X

And P(X > a) = length of complete domain of X .


1

( ) 2
−a

⇒ P(X > a) =
( ) 2
−0

⇒ P(X > a) = (1 − 2a).

It can also be observed that using the above formula when a becomes 2 there is 0 probability of getting a more balanced
split, and when a tends to 0, there is almost full probability of getting a more balanced split.

So derived formula for probability is consistent with our intuition.

 1 votes -- Anurag Pandey ( 8183 points)

1.385 finding pair of an element in the array such that diff will be given no. top

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 223 of 2244

gateoverflow.in/31624

what i think the answer should be B as i am using this method in the sorting technique and also in the search approach..
well someone can do it using A so it can be the answer. what i tried is this.

sort elements in nlogn time

now pic the middle element and subtract from the last one. ( as the difference should be positive , if negative pic the
starting element)

** further i m describing for positive difference. the algorithm can be ,modified for negative as well .

now subtract the mid and last element . if the diffrence we get is more than the difference we need. then we will set mid
as the lower and again calculate the mid , as by moving toward more big numbers only the difference will decrease.
like here

take array

6 4 9 2 1

sort .

1 2 4 6 9 .

suppose i want 3 as a difference, then

picking middle element i.e =4. that is 9-4 = 5. . so as the answer is greter than what we ned then we have to move
toward 9 because then only we can decrease our answer, if i move toward 1 the difference will increase. so in this way i
can use the binary search type method to get . make such n iterations. each time leaving the highest element that has
been examined.

time complexity . = (nlogn)+ n*logn. = (nlogn) .

i don't think repeating subproblems are there , and divide and conquer , as used . may be the answer

 0 votes -- Ravi Singh ( 7303 points)

1.386 how many threads are there. top gateoverflow.in/31646

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 224 of 2244

By definition (as I remember) a right in-threaded tree will have a pointer for the inorder successor for a node with no right
child.

Thus, the threads are as follow:

1 D -> B

2 B -> A

3 G -> H

4 J -> E

Since F is the last element in inorder sequence for the tree, there will be NULL pointer in the pointer field for the node.

 1 votes -- Utk ( 1385 points)

1.387 BFS traversal top gateoverflow.in/31852

Consider two vertices a and b that are simultaneously on the FIFO queue at same point during the execution of breadth first
search from s in an undirected graph.
Which of the following is true?
1. The number of edges on the shortest path between s and a is atmost one more than the number of edges on the shortest
path between s and b.
2. The number of edges on the shortest path between s and a is atleast one less than the number of edges on the shortest
path between s and b.
3. There is a path between a and b.

a.1 only

b.1 and 2 only

c. 2 only

d. 1, 2 and 3

data-structure

Answer is D . All are true.


BFS and DFS traversal are using for knowing the connected component of given graph.So , if a and b are in

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 225 of 2244

FIFO queue then must be a path between a and b. We can't say surely about the which one have more total
edges then others because in a queue all are unvisited neighbour node of some node.

 0 votes -- ASHUTOSH KAKADIYA ( 55 points)

1.388 complexity of quicksort using insertion sort top gateoverflow.in/31845

Upon running quicksort on a subarray with fewer than k elements, it returns without sorting subarray. After top level call to
quicksort returns, insertion sort is run on entire array to finish sorting. Then the sorting algo runs in:

O(n lg(n/k) ) O(n+ n lg(n/k)) O(nk + n lg(n/k)) none

ans is C

 0 votes -- Riya Roy ( 4767 points)

1.389 why do we run bellman-ford algorithm n-1 times ? top gateoverflow.in/31656

I am unable to get the logic behind running bellman-ford for n-1 times , I have already gone through this link , but still
couldn't get it clearly .

http://cs.stackexchange.com/questions/50557/why-do-we-need-to-run-the-bellman-ford-algorithm-for-n-1-times

algorithms

When we run BellmanFord Algorithm on a connected graph what we get as an output is a single source shortest path
graph which is actually a tree. Since a tree has only n-1 edges ,so maximum the path length between a source S and its
destination will be atmost n-1 . What we do in BellmanFord is we relax edges of path length 1 , then in next iteration we
relax edges of path length 2 ......so on till we relax edges of path length n-1 . Therefore the loop runs for n-1 times.

 3 votes -- Riya Roy ( 4767 points)

1.390 Algorithm top gateoverflow.in/31219

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 226 of 2244

Given two arrays of numbers a1, a2, a3,…an and b1, b2, .. bn where each number is 0 or 1, the fastest algorithm to find the
largest span(i, j) such that ai + ai+1, ….aj = bi , bi+1, .. bj . or report that there is not such span,

(a) Takes O (n3) and Ω (2n) time if hashing is permitted

(b) Takes O (n3) and Ω (n2.5) time in the key comparison model

(c) Takes θ (n) time and space

(d) Takes O (√n) time only if the sum of the 2n elements is an even number

1.391 Algorithms top gateoverflow.in/31216

In a permutation a1…..an of n distinct integers, an inversion is a pair (ai , aj) such that i < j and ai > aj .

What would be the worst case time complexity of the Insertion Sort algorithm, if the inputs are restricted to permutations of
1…..n with at most n inversions? A. Θ (n2 ) B. Θ (n log n) C. Θ (n1.5) D. Θ (n)

Ans is D: ⊝(n),

Insertion sort runs in Θ(n + f(n)) time, where f(n) denotes the number of inversion initially present in the array being sorted.

Read more at http://geeksquiz.com/gate-gate-cs-2003-question-62/

 0 votes -- Tehreem Ansari ( 1327 points)

1.392 Number of nodes of distinct degree top gateoverflow.in/30991

In a simple connected undirected graph with n nodes(where n≧2), The maximum number of nodes with distinct degrees is

1. n-1
2. n-2
3. n-3
4. 2

Answer will be (A)

for 3 nodes in a simple connected undirected graph degree can be 2,1,1

for 4 nodes in a simple connected undirected graph degree can be 3,2,2,1

By these degree we can draw a simple connected undirected graph (havel hakimi theorem)

 3 votes -- srestha ( 11585 points)

min degree of node is 1

max degree= n-1

so we have n vertices

2 vertices will have some degree acc to pigeon hole principle

so max no of nodes with distinct degree= n-1

 1 votes -- Pooja ( 22773 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 227 of 2244

1.393 Travelling salesman problem vs. Minimum cost spanning tree vs.
Shortest path top gateoverflow.in/30914

i want to understand these better....


please explain someone.
Travelling salesman problem vs. Minimum cost spanning tree vs. Shortest path

Also I was just wondering if there was any relation of TSP to GOOGLE's maps finding shortest distance?
because travelling salesman problem in O(n!) and there is no better solution other than dynamic programming. So do they
use dynamic programming only?


Selected Answer

not important for gate! :P

 0 votes -- Aspi R Osa ( 1305 points)

1.394 ME advanced | Probability question HASHING Chaning top gateoverflow.in/30894


Selected Answer

What i thought was that, after mapping these elements using chaining, there are 5 slots left.

So any element that comes afterwards will want to be mapped to any of the 11 slots but it has only 5
available. Probability of all the 11 slts are the same since mod function is uniformally distributed.
So the required probability will be 5/11=0.45

what M.E. says: any element will map to 1 of the 5 slots so it will be 1/5=0.2

 1 votes -- Aspi R Osa ( 1305 points)

1.395 Time Complexity top gateoverflow.in/31176

T(n) = 16T(n/4) + n!

i got its ans as logn* n!

is it correct ?


Selected Answer

Here a = 16 and b = 4 . So n ^ (log16 base 4) , which is n^2 . Comparing it with n! , we will get ans as
O(n!)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 228 of 2244

 2 votes -- Nitish Vashisth ( 593 points)

1.396 GCD time complexity top gateoverflow.in/31191

I think this function is wrong

ans b is correct. but implementation of function is incorrect . plz check

1.397 Plz xplain top gateoverflow.in/31214

Which of the following sorting algorithm is of priority queue sorting type?

ans is selection sort

But why


Selected Answer

Because at each step, it finds the minimum/maximum element.

 0 votes -- Monanshi Jain ( 5827 points)

1.398 Please solve top gateoverflow.in/31205

. Consider the following message: aabbbbabccdddccccbbdd

Find the number of bits required for Huffman encoding of the above message:

(a) 30 (b) 38 (c) 42 (d) 46 Ans is c

If Huffman tree coded as left child with ‘0’ and right child with ‘1’ from every node then what is the decoded message for
110100? (a) abc (b) bcd (c) acb (d) bda ans given is d

HUFFMAN :

-First calculating the frequencies of a – 3, d-5, c-6, b-7 for message string that is given.

-Then adding in min priority queue with respect to their frequencies

-Dequeue until queue is not empty and make a huffman tree..

- Huffman tree is :

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 229 of 2244

Now four charecters ,so 4 combinations therefore we required 2 bits.


This 4 characters repeat 21 times,so total bits are required is 21 * 2 = 42.
For answer B , if we go left for 0 and right for 1 then

11 - right – right = b

01 - left – right = d

00 - left – left = a Ans :- bda.

 0 votes -- ASHUTOSH KAKADIYA ( 55 points)

1.399 Heap Sort top gateoverflow.in/31204

statement is true or false

Heap sort is inplace algorithm. it is given as true

but heapsort uses maxheapify procedure which requires extra stack ., then how it is inplace..?

The answer given is true. Heapsort indeed an inplace algorithm but not stable.

go through this.. www.csl.mtu.edu/cs2321/www/newLectures/09_Inplace_Heap_Sort.html

 0 votes -- Sayantan Ganguly ( 5061 points)

1.400 BST top gateoverflow.in/28886

certain file system stores records as per binary search tree principles.If the preorder traversal is
90,40,30,190,140,100,290.What is the expected number of comparisons when we randomly request one of the records?

Construct bst from given sequence ..now there will be 1 node at level 0,2 at level 1 ,3 at level 2 and 1 at level 3 no of
expected comparisons=1*1+2*2+3*3+1*4/7=18/7=2.57

 2 votes -- Pooja ( 22773 points)

1.401 inverion pairs top gateoverflow.in/28881

assume that A be an array of 16 elements.What is the difference between maximum and minimum number of inversion
pairs in worst case?


Selected Answer

Minimum number of inversion is 0 in a Sorted Array.

Maximum number of inversion are n(n-1)/2 in an array sorted in decreasing order.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 230 of 2244

 2 votes -- Digvijay Pandey ( 26245 points)

first boil down the problem to the lower level .

first case . if it is in ascending order no inversion pair. as inversion pair means first elements should be larger and second
should be smaller.

1 2 3 4 5 6 : zero

now for maximum inversion pair , i have to take descending order

6 5 4 3 2 1.

now 6 can be taken and combined with any (n-1) elements to pair . similarly 5 with (n-2) elements can make a inversion
pair. so

it will be (n-1) + (n-2)....0.

so here it is 16. so it will be 15+14+13+12....0 which is the sum of first 15 natural number , = 120.

 1 votes -- Ravi Singh ( 7303 points)

1.402 Is array implementation better or the min heap in case of Prims


algorithm top gateoverflow.in/20172

For prim's algorithm array implementation takes O(V^2) while min heap takes O(ElogE)time. For dense graph E = O(v^2)
.....

So is array implementation considered better or the min heap???

Does the min heap would run better for graph with less edges..??

For dense graph E=O(V^2)

Min heap takes O((E+V)log V) time

array implementation rakes O(V^2)

So for dense graoh

Min heap takes O((V^2+V)log V) which us more than V^2

So heap implementation is suitable for sparse graph and array for dense graph

 0 votes -- Pooja ( 22773 points)

1.403 spanning tree top gateoverflow.in/19753

Suppose that edge weights are uniformly distributed over half open interval[0,1).Which algorithm krushkal's or prim's can
make you run faster?

In this scenario kruskal's algorithm will run faster than prim's. The time complexity of kruskal's algorithm is

O(E log E) <--(time taken to sort E edges) + (E α(V)) <-- find set and union operations

Given that edge weights are uniformly distributed over half open interval [0,1), we can sort the edge list in O(E) time
using bucket sort (see CLRS Bucket sort).

So now the running time of kruskal's MST algorithm will become

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 231 of 2244

O(E) + (E α(V))

where α(V) is the inverse ackermann function whose value is less than 5 for any practical input size 'n'. (ref wiki)

so, the running time of kruskal's MST algorithm is linear, where prim's will still work in O((V+E)log V)

 0 votes -- Sujit Kumar Muduli ( 169 points)

1.404 ISRO_A 2015/13 top gateoverflow.in/19474

Six files F1,F2,F3,F4,F5 and F6 have 100,200,50,80,120,150 records respectively.In what order should they be stored so as
to optimize act.Assume each file is accessed with the same frequency

a)F3,F4,F1,F5,F6,F2

b)F2,F6,F5,F1,F4,F3

c)F1,F2,F3,F4,F5,F6

d)Ordering is immaterial as all files are accessed with the same frequency

F1,F2,F3,F4,F5,F6

 0 votes -- Hareesh Vajja ( 13 points)

1.405 partitioning top gateoverflow.in/19278

Consider the following array...

12 18 17 11 13 15 16 14

Find the no of elements which will change their position when partitioning algorithm is applied on array .pivot choosen is 15

12 18 17 11 13 15 16 14
First swap the pivot element to first place of array so 15 18 17 11 13 12 16 14

Now after the partition algo ( i followed this algo)


partition(a,p(first element),q(last element))

{
x=a[p];
i=p;
for(j=p+1;j<=q;j++)

{
if(x>=a[j])
{
i=i+1;
swap(a[i],a[j]);
}
swap(a[i] ,a[p]);
return 0 ;
}

e.g
x
i j
15 18 17 11 13 12 16 14 condition fails
j
15 18 17 11 13 12 16 14 condition fails
i j

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 232 of 2244

15 18 17 11 13 12 16 14 condition true i will be incremented swap a[i],a[j]


15 11 17 18 13 12 16 14 after swap again loop will check
i j
15 11 17 18 13 12 16 14 condition true i will be incremented swap a[i],a[j]
15 11 13 18 17 12 16 14 after swap again loop will check
i j
15 11 13 12 17 18 16 14 condition true i will be incremented swap a[i],a[j]
15 11 13 12 17 18 16 14 after swap again loop will check
i j
15 11 13 12 17 18 16 14 condition fails
i j
15 11 13 12 17 18 16 14 condition true i will be incremented swap a[i],a[j]
15 11 13 12 14 18 16 17 here j>q so loop ends

now swap a[i] a[p] 14 11 13 12 15 18 16 17

14 11 13 12 15 18 16 17
So 7 element changed their position after the partition algo.

 0 votes -- Umang Raman ( 10379 points)

1.406 Solve for x : top gateoverflow.in/26000

I have an equation Xlog(X) = logN. Can anybody solve for X from this equation?

algorithms


Selected Answer

If you are asking this for the purpose of GATE, you have to find the (approximate) numerical value of x for a given N by
hit and trial.

You can use bisection method to quickly approach the answer (or other faster converging methods if you like).

f(x) = xx − N

Bisection Method:

Find points xlow and xhigh such that f(xlow) < 0 and f(xhigh) > 0

Repeat:

xhigh − xlow

xmid = xlow + 2

if f(xmid ) is sufficiently close to 0, exit the loop.

If f(xmid ) > 0, then xhigh = xmid

Else if f(xmid ) < 0, then xlow = xmid

The desired solution is xmid logxmid ≈ logN

For example: N = 12345

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 233 of 2244

Iteration xlow xhigh xmid f(xmid ) error

1 0.0000 10.0000 5.0000 −9220.000 74.69 %


2 5.0000 10.0000 7.5000 3643261.791 29512.04 %
3 5.0000 7.5000 6.2500 81898.218 663.41 %
4 5.0000 6.2500 5.6250 4229.453 34.26 %
5 5.0000 5.6250 5.3125 −5213.997 42.24 %
6 5.3125 5.6250 5.4688 −1497.607 12.13 %
7 5.4688 5.6250 5.5469 1056.190 8.56 %
8 5.4688 5.5469 5.5078 −289.806 2.35 %

We get a satisfactory answer after 8 iterations. This calculation can be easily done with a calculator within 2 minutes.

Newton Raphson:
f ′ (x) = xx(1 + logx)

f(xn )
f ′ (xn )
xn +1 = xn −

xxnn − N

xxn(1 + logxn )
= xn − n

For example: N = 12345

We need to make an initial guess which is sufficiently close to the answer, else the algorithm won't converge.
We guess x = 5

Iteration x f(x) error xnext

1 5.0000 −9220.000 74.69 % 6.1307


2 6.1307 54944.165 445.07 % 5.8404
3 5.8404 17602.403 142.59 % 5.6278
4 5.6278 4357.900 35.30 % 5.5322
5 5.5322 532.647 4.31 % 5.5169
6 5.5169 11.126 0.09 % 5.5169

We converge to a better answer in lesser iterations.

The above methods are the easy ways of finding the solution.

If the value of N is nice, for example, N = 46, 656, hit and trial will only take a few steps and can be done mentally to get
x = 6.

You shouldn't be looking for formulas for x in terms of N, because your equation won't have a pretty formula.

If you insist, then try this: http://www.wolframalpha.com/input/?i=x*log%28x%29%3Dlog%28y%29+solve+for+x

 1 votes -- Pragy Agarwal ( 13675 points)

1.407 The Number of Comparisons is : top gateoverflow.in/26666

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 234 of 2244

algorithms


Selected Answer

2 ⋅ n − 2 comparisons are sufficient but not necessary.

We can find both maximum & minimum in using less than 2 ⋅ n − 2 comparisons.

Superficially, if you are doing (n - 1) comparisons to find maximum of n elements, then minimum can be found by
comparing between those numbers who lost in their first comparison.

Here is an interesting excerpt from Cormen's book that might be useful:

Simultaneous Minimum & Maximum

"It is not difficult to devise an algorithm that can find both the minimum and
the maximum of n elements using Θ(n) comparisons, which is asymptotically
optimal.Simply find the minimum and maximum independently, using n − 1
comparisons for each, for a total of 2n − 2 comparisons.
In fact, at most 3 * Floor(n/2) comparisons are sufficient to find both the
minimum and the maximum. The strategy is to maintain the minimum and
maximum elements seen thus far. Rather than processing each element of the
input by comparing it against the current minimum and maximum, at a cost of
2 comparisons per element,we process elements in pairs. We compare pairs of
elements from the input first with each other, and then we compare the smaller
to the current minimum and the larger to the current maximum, at a cost of 3
comparisons for every 2 elements.
Setting up initial values for the current minimum and maximum depends
on whether n is odd or even. If n is odd, we set both the minimum and
maximum to the value of the first element, and then we process the rest of the
elements in pairs. If n is even, we perform 1 comparison on the first 2
elements to determine
the initial values of the minimum and maximum, and then process the rest of
the elements in pairs as in the case for odd n.

Let us analyze the total number of comparisons. If n is odd, then we


perform 3*Floor(n/2) comparisons. If n is even, we perform 1 initial
comparison followed by 3(n − 2)/2 comparisons, for a total of 3n/2 − 2. Thus,
in either case, the total number of comparisons is at most 3 *Floor(n/2)."

- Introduction to Algorithms(CLRS),
3rd Edition,Page No 184 - 185

On removing the floor function it can be observed that


n

1. If n is even, 3 ⋅ 2 − 2 comparisons will be required.


n

2. If n is odd, 3 ⋅ 2 − 1.5 comparisons will be required.

So I guess Option C will be the correct answer.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 235 of 2244

3 ⋅ 2 − 1 comparisons will be sufficient without odd, even concern, for finding both maximum & minimum out of n numbers.

 2 votes -- Anurag Pandey ( 8183 points)

1.408 Recurrence Relation top gateoverflow.in/27325

T(n) = T(n-1) + T(n-2) + c i want solve it using substitution method..

T(n) <= 2 T(n-1) + c is this a correct way ??

plz explain ...

if its wrong then what is correct way

yes u can solve like that.but

use intuition when such kind of qus comes

dnt go for substitution bcz it takes lot of time..

 1 votes -- Manojk ( 3365 points)

1.409 comparison=? top gateoverflow.in/26765

A hash table of size 10, is shown in the figure with symbols stored from a to g using some hash function with linear probing.

The worst case number of comparisons required when the symbol being searched is not in the table is?

number of comparisons=size of largest cluster + 1

so 3+1=4

 3 votes -- Pinky Choudhary ( 69 points)

answer is 4.cause.as it is given worst case scenario..so hash function will look for the element in the biggest cluster
available in the table..In this case,there is two case, 1.a,b,c and 2.e,f,g. In both case it will search for element,so,for 3
elements 3 comparison and one more cause it will also compare with just next available blank space in the table in both
cases.so total 4 comparison.

 1 votes -- Sayantan Ganguly ( 5061 points)

1.410 dynamic programming top gateoverflow.in/26726

http://gateoverflow.in/?qa=blob&qa_blobid=11412484315430083479

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 236 of 2244

1.411 max subarray problem top gateoverflow.in/19086

What does find max subarray rwturn when all elements of array are negative?

When we implement max subarray problem. We just include maximum and minimum values a machine can have.
It depends on implementation.

 0 votes -- Avdhesh Singh Rana ( 1509 points)

1.412 What is K -way merge sort.... !!!!! top gateoverflow.in/18781

What is K -way merge sort.... !!!!! i m very confused....if we say 2-way merge sort..does it mean dividing array into 2 parts
or dividing array in size of 2!!!!

Straight 2 way merge sort means take 2-set for each pass and merge sort them.

e.g. 94 27 14 17 5 2 pass 3 2 5 14 17 27 94

pass 2 14 17 27 94 2 5

pass1 27 94 14 17 2 5 after first pass 27 94 14 17 and 2 5 become one set

94 27 14 17 5 2

similarly k merge sort!

 1 votes -- Umang Raman ( 10379 points)

1.413 what is the divide and conquer recurrence that would arise for the
problem top gateoverflow.in/16209

suppose you are given n bit integers asuming for common sense n as power of 2 .it is required to multiply them using divide
and conquer method .what is the divide and conquer recurrence that would arise for the problem

a) T(n)=4T(n/2)+c

b) a) T(n)=2T(n/2)+n

c) a) T(n)=4T(n/2)+n2

d) a) T(n)=4T(n)+n

A=(an,an-1,an-2................a0)2 and B=(bn,bn-1,.....................b0) be 2 n bit no

then A can be written as A=2^n/2A msb+Alsb

B= 2^n/2Bmsb+Blsb

Amsb is the n/2 most significant bit of A ie n/2 leftmost bit of the no.

Alsb is the n/2 least significant bit of A ie is n/2 rightmost bit of the no.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 237 of 2244

so A*B=(2^n/2Amsb + Alsb )( 2^n/2Bmsb + Blsb ) = 2^n*A msb*Bmsb + 2^n/2(Amsb * Blsb + Alsb *Bmsb ) +
Alsb Blsb

this equation says that mul of 2 n bit no can be carried out using mul of 4 n/2 digit no +some shift operatin

so the required corresponding recurrence if T(n)= time complexity to mul 2 n bit no

T(n) = 4*T(n/2) +Cn

but it can also be solved in T(n)= 3*T(n/2) +cn

for more optimiation ---https://en.wikipedia.org/wiki/Karatsuba_algorithm

 0 votes -- Saurav Kumar Gupta ( 1455 points)

1.414 complexity top gateoverflow.in/15785

ans;-theta(n)

Since,the above recurrence is homogenous linear recurrence relation of degree 3.So,we can solve these kind
of problem by a formal way...

assuming the sol of the recurrence is r^n we can write

r^n =r^(n-1) +r^(n-1) -r^(n-3)

so , dividing both the side by r^(n-3)

r^3 = -1+r+r^2

so,r= -1,+1,+1

so, its solution will be t(n)= a.(-1)^n +(b +cn)(+1)^n

which is clearly theta(n).

note:- u can calculate the value of the constatnts a,b,c by using the initial condition .

 0 votes -- Saurav Kumar Gupta ( 1455 points)

1.415 BST top gateoverflow.in/15784

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 238 of 2244

Ans is C

 0 votes -- aankitroy ( 11 points)

1.416 if this problem is solved using divide and conquer method ,then the
algorithm run in top gateoverflow.in/16210

given a sorted array of distinct integers A[1........n], you want to find out whether there is an index i for which A[i]=i.if this
problem is solved using divide and conquer method ,then the algorithm run in

a) O(n) a) O(nlogn) a) O(logn) a) O(n 2)

algorithms


Selected Answer

Ans- 0(logn)

Algorithm

int special_search(int a[],int l,int r)

int mid;

if(l<r)

mid=l+(r-l)/2;

if(a[mid]==mid) return mid;

else if(a[mid]>mid) return special_search(a,l,mid-1);

else return(a,mid+1,r)

 1 votes -- Saurav Kumar Gupta ( 1455 points)

1.417 How many comparisons are needed to sort an array of length 5 gateoverflow.in/17268

top

How many comparisons are needed to sort an array of length 5 if a straight selection sort is used and array is already in the
opposite order?

a)1

b)10

c)15

d)20

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 239 of 2244

b) 10

each cell denote the total number of comparison performed to select the element to be placed in that cell.

4 3 2 1 0

 1 votes -- Amar Vashishth ( 17865 points)

1.418 the minimum no of comparisons required to find Majority Element in a


sorted array (note that key is not given). top gateoverflow.in/18668

for example array contain a[1 2 3 3 3 3 3 4 5] then retun(1)

if any element is present more than n/2 times in the array then that element is called majority element.The best way to
implement this is through a BST.Node of the Binary Search Tree: struct tree { int element; int count; }BST; Insert
elements in BST one by one and if an element is already present then increment the count of the node. At any stage, if
count of a node becomes more than n/2 then return. ref:http://www.geeksforgeeks.org/majority-element/

 0 votes -- Rohan Ghosh ( 1515 points)

1.419 which of the functions is greater ? top gateoverflow.in/18535

F1 =(logn)! F2=(log(n!)) F3 = (logn)^logn

Just one query n! would be a constant rght , so in F1 we are taking factorial of a constant while in second one we are taking log of a constant so definitely F2 should be less than F1 .Am I
correct or wrong at this point ?

F1 =(logn)! F2=(log(n!)) F3 = (logn)^logn

now F2 can be wriiten as n logn (n!=n^n)

let logn=x

F1=x!

F2=nx

F3=x^x

now F2<F1<F3

 0 votes -- Pooja ( 22773 points)

1.420 which of the following are true? top gateoverflow.in/17957

which is true please explain..

.f(n)=O(f.(n)2)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 240 of 2244

.if f(n)=Og(n)

then 2 f(n)=O(2g(n))

.2n≄O(nk) where k is constant

.lognlogn>2logn>nlogn


Selected Answer

option c is correct

a) FALSE Since it is true for increasing function but false for decreasing function

b) FALSE let f(n) = 2n and g(n) = n then 2 2n= O(2n) which is false

c)TRUE Since exponential in bigger than polynomial therefore nk=O(2n) is true not the reverse so given statement is true

d) FALSE logn is a decreasing function put the value for n and check n^logn will be biggest among all but its given reverse

 0 votes -- Umang Raman ( 10379 points)

1.421 Calculate the time complexity top gateoverflow.in/27394

Let f(n) = Ω(n), g(n) = O(n) and h(n) = θ(n). Then [f(n) ⋅ g(n)] + h(n) is _______.

f(n) = Ω(n)
f(n) >=c. n
g(n) = O(n)
g(n) <= c1.n
h(n) = Θ(n)
h(n) = n.
So [f(n) . g(n)] + h(n)
lets take all f(n) g(n) h(n) be n
[n ⋅ n] + n
= Θn^2 + Θn = Ω(n)
Since upper bound depends f(n) value if it is n^4 then O(n^4).

 0 votes -- Umang Raman ( 10379 points)

1.422 Algorithm top gateoverflow.in/27420

A polynomial p(x) is such that p(0)=5 ,p(1)=4 ,p(2)=9 and p(3)=20 The minimum degree it can have is..

The degree can't be 0 since that will give us a constant polynomial, but we have 4 different points to satisfy.
p (1 ) −p (0 ) p (2 ) −p (1 )
1 −0 2 −1
The points that we need to satisfy aren't co-linear either. For example, = −1 ≠ 5=

Let's try to fit a parabola.

Let p(x) = ax2 + bx + c

Since p(0) = 5, we have that:

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 241 of 2244

a ⋅ 02 + b ⋅ 0 + c = 5
c=5

 p(x) = ax2 + bx + 5

Also, p(1) = 4. Thus,

\begin{align}
a\cdot 1^2 + b\cdot 1 + 5 &= 4\\[1em]
a + b &= -1\tag{1}\label{1}
\end{align}

Finally, p(2) = 9. This gives us:

\begin{align}
a\cdot 2^2 + b\cdot 2 + 5 &= 9\\[1em]
4a + 2b &= 4\\[1em]
2a + b &= 2\tag{2}\label{2}
\end{align}

Using (1) & (2) we get:

+( 2a + b =2 )
−( a+b = −1 )

 a =3
b = −4

So we have p(x) = 3x2 − 4x + 5.

Testing it on our final point, we have that p(3) = 3 ⋅ 32 − 4 ⋅ 3 + 5 = 27 − 12 + 5 = 20, which is equal to the given value of p(3).

Hence, the minimum degree is 2 and the polynomial is p(x) = 3x2 − 4x + 5.

 0 votes -- Pragy Agarwal ( 13675 points)

1.423 time complexity top gateoverflow.in/27945

n

i =0 i3 =X

and following choices for X

1.Θ(n4 )

2.Θ(n5 )

3. O(n5 )

4.Ω(n3 )

possible values of X

X i.e. Complexity will be 1 3+23+...........n3=(n(n+1)/2)2

=theta(n 4)

 0 votes -- srestha ( 11585 points)

1.424 Recurrence top gateoverflow.in/27930

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 242 of 2244

How to build Recurrence relation for Time complexity

double foo(int n)
{
int i;
double sum;
if(n == 0)
{
return 1.0;
}
else
{
sum = 0.0;
for(i = 0; i < n; i++)
{
sum += foo(i);
}
return sum;
}

If n ≤ 0, the function takes Θ(1) time, because it just declares some variables, does a fixed number of logical comparisons
and then returns a value.

If n > 0, the function:

declares some variables and initializes them in Θ(1) time



In a loop, it calls all the values of foo(i) for i ∈ [0. . n) and does an additional Θ(1) work in each iteration.
Note: foo(i) takes T(i) time.

Returns the answer.
n −1

Thus, if n > 0, it takes a total of Θ(1) + i =0 (T(i) + Θ(1) ) + Θ(1) time.

Thus, the recurrence for the time complexity can be given by:

{
Θ(1) if n ≤ 0

T(n) = n −1

Θ(n) + i =0 T(i) if n > 0

 1 votes -- Pragy Agarwal ( 13675 points)

1.425 Sorting top gateoverflow.in/27904

Consider an array with the following elements 12,18,17,11,13,15,16, and 14 .how many elements will change their initial
position after completion of partition algorithm by choosing 15 as pivot.

We can choose any random element as pivot

Here 3rd last element 15 as pivot

So, as 17, 18 greater than pivot ,17, 18 will go after 15

and 14 less than pivot, so,14 will come before 15

12,11,13,14,15,18,17,16......................here 3 element change its position

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 243 of 2244

Now 13 pivot, No change in element

Now 12 as pivot 11 will change its position........... here 1 element change position

11,12,13,14,15,17,16,18

Now 18 as pivot 2 element change its position


12,11,13,14,15,17,16,18........................here 2 element change position

Now 17 as pivot 16 will change its position.............. here 1 element change its position

Here total no of element change its position is 7

 0 votes -- srestha ( 11585 points)

1.426 Dijkatra algorithm for unweighted graph top gateoverflow.in/27768

hi all ,

Please tell me how much does dijkastra algoritm would take for unwaited and martix implementation

1.427 Asymptotic notations top gateoverflow.in/27969

Let f(n)= Ω(n), g(n)= O(n) and h(n)= Ѳ(n).

Then [f(n). g(n)] + h(n) is:


(a) Ω (n) (b) O (n)
(c) Ѳ (n) (d) None of these

explain it

1.428 no. of multiplications top gateoverflow.in/27993

Consider the polynomial

p(x) = a 0 + a 1x + a 2x2 +a3x3, where a i ≠ 0, for all i.

The minimum number of multiplications needed to evaluate p on an input x is:


(a) 3 (b) 4
(c) 6 (d) 9

Answer will be 3

mul= pair of brackets

p(x)=a0+x(a1+x(a2+a3(x)))

 1 votes -- srestha ( 11585 points)

1.429 Algorithms:Which of the following statements is/are true? top gateoverflow.in/28628

Which of the following statements is/are true?

S1: Dijkstra’s algorithm is not affected by negative edge weight cycles in the graph and gives correct shortest path.

S2: Bellman ford algorithm finds all negative edge weight cycles present in the graph.

a) Only S2

b) Only S1

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 244 of 2244

c) Both S1 and S2

d) Neither S1 and nor S2

Ans) D how ?

But My ans only s2

algorithms


Selected Answer

Dijkstra’s algorithm is not affected by negative edge weight cycles in the graph and gives correct shortest path. = false

Reason : Dijkstra’s algorithm works correct when their negative edge weight bit when negative edge weight cycles in the
graph present then it gives incorrect MCST.. b/c do one time decrese key on one edge but we need to do n-1 time .

Bellman ford algorithm finds all negative edge weight cycles present in the graph. = false

one thing missing .. if and only if negative edge weight cycles reachable from source.

 4 votes -- Anirudh Pratap Singh ( 4091 points)

1.430 Find complexity of T(n)=64T(n/8)-n^2lgn top gateoverflow.in/28274

Which is right method to apply for this substitute or recursion...

Can we convert it in master theorem format

T(n) = 64 T(n/8) − n2 logn


1
= 64 T(n/8) + n log n
2

this does not satisfy the generic form of master method. It is close to the case of Master Method, where :

but fails so do other cases too. So, one of the method to do this is Akra–Bazzi Method.

here,
we need to choose p such that ∑ki=1 aibpi = 1
1

64 8 ()
p
| |
= 1satisfies for p = 2 and also, g ′ (x) ≤ xc for some c ∈ R

so,

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 245 of 2244

( )
u2 log u
x p +1
T(x) = Θ xp + xp ∫ 1 u du

u2 logu

(
= Θ x2 − x2 ∫ 1
x u3 du
)
(
= Θ x2 − x2 ∫ 0
log x
t dt )
x2

( x2 − 2 {logx}2
)
x2 1

(
= Θ x + logx . log x
2 2
)
x2 1


( 2 x
log logx
)
n2 1

T(n) = Θ
( 2 log n logn
)
 0 votes -- Amar Vashishth ( 17865 points)

1.431 C prgram top gateoverflow.in/28129

x– = y+1; does the same as:


(a) x= x –y +1 (b) x= – x –y – 1
(c) x= –x + y +1 (d) x= x – y – 1

is ans is a ?

given d


Selected Answer

ans is D )

"+" has higher precedence than "- ="

so 1st + will perform then -= wil perform .

x-=(y+1)

=> x=x-(y+1) = x-y-1 .

 3 votes -- Pranay Datta ( 6113 points)

1.432 job scheduling top gateoverflow.in/27612

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 246 of 2244


Selected Answer

DEADLINE 1 2 3 4 5 6 7 8
JOB J3 J7 J4 J5 J6 J1 J2 J8

PROFIT 15 29 17 16 24 21 0 0

max profit is(15+29 + 17+16+24+21 )=122

 1 votes -- srestha ( 11585 points)

1.433 Max Heap top gateoverflow.in/27517

Extract Min from Max heap

1. search at last level = O(n)

2.Replace element with last element and decrese heap size by 1 = O(1)

3. Apply max heapify on replaced element = O(log n)

Total Time = O(n)+O(1)+O(log n) = O(n)

is it correct ?

1.434 Hash table top gateoverflow.in/27425

A hash table can store max of 10 records,currently there are records in locatio 1,3,4,7,8,9,10. The probability of a new
record going into location 2,with a hash function resolving collisions by linear probing is..

ASSUMING that "the hash function is fair & uniformly distributes the universe of keys to all the 10 locations",

the probability should will be 6/10.

Due to uniform distribution, the probability that the new record will be placed to any location i will be same for any
1
10
i ϵ (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) & will be equal to .

Now if the hash function will try to place the new record in to any of the locations 1, 7, 8, 9, 10, the record will be redirected
to location 2 due to collision resolution by linear probing.

And if hash function will try to place the new record into 2, since location 2 is available, the record will go to location 2.

So The probability of going new record into location 2, will be same as probability that the output of hash function is any
one of (1, 2, 7, 8, 9, 10) out of (1, 2, 3, 4, 5, 6, 7, , 8, 9, 10), where each location is equally likely.
6
10
So the chances will be .

 2 votes -- Anurag Pandey ( 8183 points)

1.435 order of the algorithm top gateoverflow.in/27424

T(n) = T(n-1)+ 1/n if n>1

=1 otherwise

The order of the algorithm is

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 247 of 2244

T(n) = T(n-1) + 1/n


= T(n-2) + 1/(n-1) + 1/n
= T(n-3) + 1/(n-2) + 1/(n-1) + 1/n
.
.
.
1 1 1 1 1

= T(n-(n-1)) + n − (n −2 ) + n − (n −3 ) + ............+ n −2 + n −1 + n
1 1 1 1

= T(1) + 2 + 3 + 3 ..........+ n
its Harmonic Series
T(n) = O(logn)

 1 votes -- Umang Raman ( 10379 points)

1.436 Algorithm top gateoverflow.in/27421

When s be a sorted array of n integers , and t(n) s the time taken for the most efficient algorithm to determine if there are 2
elements with sum less than 1000 in s, then which of the following statements is true?

t(n) is O(1)
n<=t(n)<= n logn
n logn<= t(n) <(n/2)
t(n) =(n/2)

This can be done in O(1) time.

Since S is a sorted array the smallest two elements will be at the endpoints of the array.

Also if the sum of two smallest elements is less then 1000 we can say "yes there are two elements in the array whose sum
is less than 1000".

In case their sum is greater than or equal to 1000, we can say "No" because rest all the numbers in the array must be
equal to or greater than the larger number among the two smallest numbers.

But since in the sorted array the smallest element might be at position S[0] or at S[n - 1], we should check the location of
smallest number first.

Here is the pseudo code.

Checksum(S, n)

If (S[0] <= S[n - 1] ) //To check the position of the smallest number in Array S.

{ If(S[0] + S[1] < 1000) return YES;

Else return NO;

Else

{ If(S[n - 1] + S[n - 2] < 1000) return YES;

Else return NO;

 3 votes -- Anurag Pandey ( 8183 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 248 of 2244

1.437 Hashing function top gateoverflow.in/27426

Consider a hashing function that resolves collision by quadratic probing. Assume the address space is indexed from 1 to 8.If
a collision occurs at position 4, then the location which will never be probed is..

Locations are 1 to 8.

Hash Function used is : h'(k,i) = (h(k)+i^2)

As given h(k) = 4 {for i=0}

So, for i=1 , h'(k) = 4 + 1 = 5

for i=2, h'(k) = 4 + 4 = 8 & continue like this 8 times..

Only probed locations are 4,5,8..

So, Locations that are not probed are 1,2,3,6,7..

 0 votes -- Himanshu Agarwal ( 8861 points)

1.438 Hashing top gateoverflow.in/27429

A machine took 200 sec to sort 200 names using bubble sort. In 800 sec, it can approximately sort..

Another way

for 200 names =200*199/2

=19900 comparison

19000 c=200 sec

n(n-1)/2=800 sec

so n(n-1)/2=79600

n=400 apx

 2 votes -- Manojk ( 3365 points)

To Find solution these kind of quetion u have to know What is the time complexity of given algorithm

like in above quetion Bubble sort

Best case = O(n 2) without modified

Worst case = O(n 2)

Now take quetion If he say how many time to sort 800 names.

200 sec to sort 200 names using bubble sort.

Bubble sort take for n names = O(n 2)

here take 200 = 200sec

but in actual it take O(2002)= 40000sec

now simple math apply inplace of 40000/200 = 200 it take 200 sec

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 249 of 2244

for 800 bubble sort actualy take o(8002)= 160000 sec

But like above divide ans by 200 so 640000/200= 3200sec

but he is asking for how many name sort in 800 sec ..

so to in 200 sec= 200 name

but actualy it want 40000sec

in quetion 1 sec= 1name

wat is relation b/w program and actual algorithm time complexity

so 1 sec = 200/40000= 1/200 name

so in 800 sec= O(n 2)

since 800 sec= O(n 2)/200

= 160000= O(n 2)

take log both side

u get n= 400

 1 votes -- Anirudh Pratap Singh ( 4091 points)

1.439 Relation between graphs top gateoverflow.in/27460

Is there is any relation between bipartite graph, complete bipartite and planar graph?

graph-theory

bipartite graph, and complete bipartite graph but can not contain a cycle of odd length. that's all i know, planer is not in
syllabus i think

 0 votes -- Ravi Singh ( 7303 points)

1.440 Recurrence relation top gateoverflow.in/27434

Recurrence relation T(1)=1

T(n)=2T(n-1)+n n>=2 evaluates to ..

Pls explain with detailed steps..

If f(x)=square(x)

then f(x-1)=square(x-1).

Similarly,

T(n)=2*T(n-1)+n

=2* {2*T((n-1)-1)+n-1} + n /* replace n by n-1 in T(n) */

= 2^2*T(n-2) +2*(n-1) + n

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 250 of 2244

=2^i * T(n-i) + 2*sum(n-i) +n where n-i>1 or n>i+1

when n=i+1,

T(n)= 2^(n-1) *T(1) +2*(n-1+n-2+n-3+.....1) +n

=2power(n-1) + square (n)

 0 votes -- Vikranth Inti ( 239 points)

1.441 Recurrence relation top gateoverflow.in/27432

How to solve the Recurrence relation T(n)=T(n/4)+T(3n/4)+n

using recursive tree method ans will come as O(nlog4/3n)

 0 votes -- kunal chalotra ( 3567 points)

1.442 What are the time complexities of following operatons ? Justify gateoverflow.in/31869

top

Q1) Conversion from Tree to Heap (max heap and min heap)
Q2) Conversion from Max Heap to Binary Search Tree

Q3) Conversion from Min Heap to Binary Search Tree

( NB:Please justify your answer so that one who reads could understand the concepts behind
including me :p )

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 251 of 2244

2 Programming & DS top


2.1 Arrays: Array Definition - ISRO 2008/1 top gateoverflow.in/18461

Which of the following is an illegal array definition?

a. Type COLONGE : (LIME, PINE, MUSK, MENTHOL);

var a : array [COLONGE] of REAL;

a. var a : array [REAL] of REAL;


b. var a : array [‘A’…’Z’] of REAL;
c. var a : array [BOOLEAN] of REAL;

isro arrays

2.2 Programming In C: What is the output of the following program ? gateoverflow.in/39214

top

What is the output of the following program ?


void main() {
int x=40, y=30, z=80;
if(x<y<z)
printf(“\n Hello world”);
else
printf(“\nGood by”);
}
A] Hello world

B]Good by

C]Compile time error

D]None of these

programming-in-c algorithms


Selected Answer

IT WOULD PRINT HELLO WORLD

X<Y<Z will be evaluated like this

comparison operator associativity is left to right ...SO Y will be associated with LEFT first

that is ....(.X<Y)<Z ...

AS X is not less than Y (0)<Z will evaluate 1

and IF will be excetued and will print hello world

 2 votes -- Deepesh Kataria ( 1207 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 252 of 2244

3 Engineering Mathematics top


3.1 vector vector top gateoverflow.in/35069

qu num 43nd 44

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 253 of 2244

4 Compiler Design top


4.1 Compiler Tokenization: TestBook Live Test 2 Q 19 top gateoverflow.in/36715

I think answer should be 13.

We got 13 tokens

printf ( "string" ++ & & * * * a ) ;

test-series testbook compiler-tokenization

printf

"string"

++

& &

12 tokens

 3 votes -- sonu ( 1267 points)

My answer is

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 254 of 2244

 1 votes -- shivanisrivarshini ( 2067 points)

4.2 Compiler Tokenization: Question on SDTS top gateoverflow.in/37152

Given explanation

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 255 of 2244

Couldn't understand the explanation. Please explain

compiler-design compiler-tokenization

My Answer is

Here we use bottom up approach

we have to construct parse tree for given input

then first we get id--F =>print wool

F--T=> ,baa

T---E =>,black

i d--F => wool

F--T=> ,baa

id--F => wool

T*F ---T =>,baa

E+T ---E=>,sheep

E dollarsymbol --- E1 => dollarsymbol

By printing all we get wool,baa,blackwool,baawool,baa,sheepdollarsymbol

 0 votes -- shivanisrivarshini ( 2067 points)

4.3 Compiler Tokenization: ace test series top gateoverflow.in/35404

what lexical analysis phase use. regular expression , regular grammar , ??

compiler-tokenization compiler-design

4.4 Derivation Tree: Nodes in a derivation tree for grammar in CNF top gateoverflow.in/36558

Number of nodes in the derivation tree when a word of length 2k is derived from a grammar in CNF?

A. 2k+1 − 1
B. 3.2k+1 − 1
C. 2k+1 + 1
D. 2k+1 + 1

compiler-design derivation-tree testbook-test-series


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 256 of 2244

In CNF, every production is of the form

1. A → BC
2. A → d (d is a terminal).

We are given a word of length 2k meaning we reached 2k terminals during parsing. If we consider the start symbol as root,
the parse tree will be a strict binary tree (need not be a complete binary tree, a strict binary tree is a binary tree where
every non-leaf node has two children). So, our problem now reduces to the number of nodes in a strictly binary tree with
2k leaf nodes.

If you know the property of strict binary tree answer is 2k+1 − 1. Otherwise we can see the binary tree as a graph with n
nodes and n − 1 edges. We have 2k nodes of degree 1 (leaf nods), a root node of degree 2 and n − 2k nodes of degree 3. So,
sum of degrees = 2k + 2 + 3.(n − 2k − 1).

In a graph, sum of degrees = 2. number of edges.

So,

2k + 2 + 3.(n − 2k − 1) = 2(n − 1)  n = 2.2k − 1 = 2k+1 − 1.

Ref: http://web-ext.u-aizu.ac.jp/~hamada/AF/Compact-L5-Final-2.pdf

 5 votes -- Arjun Suresh ( 124125 points)

4.5 Grammar: compiler design top gateoverflow.in/33393

I want to know which grammars are used while various phases of compiler . like we use the regular languages for
verification of tokens, and this the question why i want to know it . plz verify the question and answer given is B . and plz
explain all the grammars used in various phases .

compiler-design grammar


Selected Answer

Regular Sets - Finite Automata

DCFL - Parsing

CFL - Syntax Specification

CSL - Semantics

Recursive sets - Statistically determinable and verifiable

 1 votes -- Monanshi Jain ( 5827 points)

4.6 Grammar: Deciding grammar type top gateoverflow.in/27074

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 257 of 2244

compiler-design grammar


Selected Answer

grammar is LR(0). there is no conflict. so SLR(1) , LR(1).None of the options matches except d.

 1 votes -- pritika kundu ( 677 points)

4.7 Grammar: Deciding grammar top gateoverflow.in/27073

Given answer: D
Solution to this problems says that the grammar is same as dangling else problem. Please explain me how.

compiler-design grammar

the grammar is left factoring.so ambiguous.answer is d.

 0 votes -- pritika kundu ( 677 points)

4.8 Grammar: the next three questions are based on the following grammar:
top gateoverflow.in/18640

E-->E/X | X

X--> T-X | X*T | T

T--> T + F | F

F-->(E) | T

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 258 of 2244

my doubt is how can we decide left or right associativity and another doubt was how can we decide precedence of the
operator...i got confusion

can any one explain plzzz...

grammar


Selected Answer

X->T-X as X is occuring to right of - - is right associative

Similarly X->X *T * is left associative as X is to left of *

Similarly + and / is left associative

Coming to precedence operators at lowe level in tree have higher precedence so + has higher precedence with respect to
* and - .- and * have equal precedence precedence of / is least

 1 votes -- Pooja ( 22773 points)

4.9 Grammar: Identify the grammar represented by the following production


rules top gateoverflow.in/7758

S → CCC → cC | d

theory-of-computation grammar

Grammar free from left recursion and common prefixes ..


First (S) = first (C) = {c,d}
follow (S) = Follow (C) = {c,d,}
S ----> CCC //single production so no conflict
C ----> cC| d
First of {cC} ^ First of {d} = phi, so no conflict
Grammar is LL(1).

 1 votes -- Digvijay Pandey ( 26245 points)

4.10 Grammar: Which statements are true? top gateoverflow.in/33756

Which is true?

a) Recursive Decent Parsers may suffer from infinite loop.

b) Every LR grammer is unambiguous.

c) Both a & b

d) None

Doubt: RDP and LL(1) can go in loop if it is not left-factorized and contains left recursion. But as for constructing these
parsers themselves require unambiguous, left-factorized and left-rec. free grammer. So, how can it go to infinite loop.
Answer given was (c).

made-easy compiler-design grammar

Seems they are testing verbal ability by putting the word 'may'. Yes it may go in infinite loop if the grammer is having a
left recursion.

 0 votes -- bahirNaik ( 2479 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 259 of 2244

4.11 Intermediate Code: quadruple notation top gateoverflow.in/33315

compiler-design intermediate-code


Selected Answer

t1=-c

t2=b*t1

t3=a+t2

a=t3

so we get a=a+b*-c

so option c

 1 votes -- Pooja ( 22773 points)

4.12 Intermediate Code: Is Intermediate code generation part of analyis or


synthesis phase? top gateoverflow.in/30336

During code generation, we need to do register allocation (kind of machine dependent stuff). So, I think it must be the part
of Synthesis phase?

compiler-design intermediate-code


Selected Answer

intermediate code generation is part of analysis phase...target code generation is part of synthesis phase

 1 votes -- Pooja ( 22773 points)

4.13 Intermediate Code: Tracing intermediate code in quadraples format top


gateoverflow.in/35416

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 260 of 2244

A) a & b both are wrong

B) a & b both are correct

C) a is correct & b is wrong

D) b is correct & a is wrong

How to solve such qstn??

compiler-design intermediate-code test-series ace-test-series

Code A is correct as per explanation given in question. 2 JMP instructions in statements 2 and 4 are exactly as they should
be for the given code.

Code B is wrong- the JMP in statement 4 is wrong (statement 2 is a typo?).

 1 votes -- Arjun Suresh ( 124125 points)

4.14 Lexeme: Calculating number of tokens top gateoverflow.in/36640

Given solution:

Please explain how the number of tokens are 11.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 261 of 2244

lexeme tokens compiler-design compiler-tokenization


Selected Answer

Actually there are 12 tokens.


they Left semi colon (;) ..

 3 votes -- Digvijay Pandey ( 26245 points)

We may a have a confusion of slecting && a single token or & as 2 diff token

Similarly the same thing goes for + or ++

The concept that come "MAximal match ".If you have + and may with one look ahead you have encountered ++ then in
that case you will take maximal one . ie ++ so it would be considered ++ as token under relational operator token class

similarly a & is address operator and && is a logical so you take max of both of them so its &&

Now but in case of *** you cant have "all" of them as a single token . or we dont have any opearator (***) -we are
extending the indirection property .There is no such token class , Infact each of * will come under one token class . SO all
3 in one token class

So the token are printf

"what up %id "

++

&&

ALl of these counts to 12 ! :)

 1 votes -- spriti1991 ( 1127 points)

/* abc*/ gives 0 token bcz lexical analyzer avoid the comment

printf count as 1 token

( count as 1 token

"whats up %d" count as 1 token

,count as 1 token

++ is increment operator so count as 1

&& is also logical AND operator so count as 1

*** are count as 3 token

a count as 1 token

) count as 1 token

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 262 of 2244

; count as 1 token so

tatal 12 token plz correct me if i am wrong

 1 votes -- rajan ( 1287 points)

4.15 Lexical Analysis: CFG for lexical analysis top gateoverflow.in/27634

A context free grammar can be used to model the lexical concerns of a HLL. This is not normally done and a regular
grammar is used for the structure of lexemes because
(A) The cfg will blow up unnecessarily
(B) The structure of lexemes can be described by the simpler regular grammar
(C) There is a separation of concerns which controls complexity.
(D) All of the above

compiler-design lexical-analysis

Ans should be D) All the above

A) yes it is true , as we know regular languages are implemented by finite automata which is more efficient to implement
than context free languages implementation (using push down automata which is used stack ) .

B) structure of lexeme usually be in letter(letter+digit )* and regular grammar describe it .

c) same reason as option a) .

for more detail ref: http://www.iith.ac.in/~ramakrishna/Compilers-Aug15/slides/02-lexical-analysis-part-1.pdf

 3 votes -- sonam vyas ( 6441 points)

4.16 Lexical Analysis: Question on lexical analyzer top gateoverflow.in/27076

Given answer: D
Please explain

compiler-design lexical-analysis

Regular expressions, Finite Automata and NFA with e-moves have the same power of lexical analyser. See the
equivalance of automata and regular expressions in ullman text.But grammars have higher power than the previous 2
models.Hence D.

 0 votes -- Vikranth Inti ( 239 points)

4.17 Lexical Analysis: Error during compilation of code.. top gateoverflow.in/41709

a = 1+1+1+ 1+1+1 1+1;

as far as i think, it will pass the lexical phase.. it should b syntax error.. correct ??

compiler-design lexical-analysis

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 263 of 2244

No, All the tokens are not valid.

There is a specific rule in "integer constant creation" that you can not have a blank space between a number.

In the above line after 5th 1, "1 1", cause an error. because compiler consider it one single integer constant token, which
have a blank space between it.

Thx. All the best.

 3 votes -- Rude Maverick ( 3063 points)

Yes , this error will be generated at the time of syntax analyzer . you cant make a parse tree for this

 1 votes -- RItesh Kumar Singh ( 23 points)

4.18 Live Variable: DRDO 2009 top gateoverflow.in/18940

A variable X has been assigned fresh values in statements numbered 6, 9 and 12 in a 25- statement program which does not have any jump instructions.This variable is used
in statements numbered 7, 8, 10, 16 and 17.the statement range where the register, used by the variable X, could be assigned to some other variable are-

(A.) 8-9, 10- 12, 17- 25


(B.) 11, 18-25
(C.) 17-25
(D.) Non of the above

live-variable

After the last use of a variable and next assignment, there is no use to preserve the variable. So, option B is the answer.

 1 votes -- Arjun Suresh ( 124125 points)

4.19 Ll1: Identify LL(1) or not top gateoverflow.in/33319

compiler-design ll1


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 264 of 2244

Ans) A.

 4 votes -- Morphine ( 273 points)

S->aA {a} S->B {b,c} so {a} ∩ {b,c}= ∅;

{First of the respective RHS}

A->aA {a} A->b {b} so, {a} ∩ {b} = ∅

B->bB {b} B->c {c} so, {b} ∩ {c} = ∅

Therefore LL(1) grammar.Hence Deterministic,Not ambiguous and Not Left Recursive.

 1 votes -- Mahesh Kumar ( 153 points)

4.20 Ll1: Give LL(1) parsing table. I/P ="ab*" top gateoverflow.in/36590

compiler-design grammar ll1

4.21 Lr Parser: Test Series Qs Compiler Design LR(0) top gateoverflow.in/33631

Consider the following grammar.

S → (S)S | ∊

How many conflicts occur in LR (0) parser for the above grammar?

compiler-design lr-parser

4.22 Lr Parser: LR(1) parser query 1 top gateoverflow.in/30780

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 265 of 2244

Ques:- Check whether the following grammar is clr(1) grammar or not or lalr grammar or not.

S -> (S)

S -> a

Problem-

The work( for checking the given grammar is LR(1) or not) done by me as shown in figure....is it right approach for LR(1)?

compiler-design lr-parser

By merging the common productions state but various input symbols We get the table. From this we will tell is it LALR(1)
or not. From the productions we merge the states I2 and I 5 then we get

I25:- goto(Io, ()

S->(.S), $/)

S->.(S), )

S->.a,)

and similarly 3 and 6 made 36, 4 and 8 48, 7 and 9 79.

 0 votes -- Anupoju Satish Kumar ( 219 points)

4.23 Lr Parser: LR(1) states top gateoverflow.in/36372

Here what will be the lookahead for first state?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 266 of 2244

Here is given answer:

parsing compiler-design lr-parser

Well I made the DFA but i didn't find any conflicts in any state...So the answer should be option d.

 0 votes -- Saumik Sarkar ( 157 points)

4.24 Marks: What could be the revised weightage per subject in GATE 2016
CS? top gateoverflow.in/33602

As some of the subjects are removed, is there any chance of compiler design getting more weightage?

or

Are they going to distribute those marks among all other subjects?

gate marks distribution wieghtage

You'll need to wait for GATE 2016 paper for revised weightage

But I'm sure it'll be same mostly !

http://www.gatecse.in/mark-distribution-in-gate-cse/

 0 votes -- Akash ( 26315 points)

4.25 Parsing: Is $ a terminal or not ? top gateoverflow.in/33091

Follow(S) comes as {(, ). $ } So, do we count $ as terminal or not.

Could anyone please tell me, $ should be considered as terminal or not ?

** Although I think, I should not count it as a terminal because we do not put $ in the terminal set of CFG.

See here : https://en.wikipedia.org/wiki/Context-free_grammar#Example

$ is also marker to identify that parsing of string has been successfully completed.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 267 of 2244

compiler-design context-free parsing

}

number of terminal=2;

follow of S will be{ ), hence included as terminal

 0 votes -- sourav anand ( 1585 points)

4.26 Parsing: What happens if LALR(1) machine is constructed for the below
grammer ? Justify Each Option top gateoverflow.in/27388

Grammar
S → S1

S1 → S1 = S1 | a

Where = is the assignment operator in C

1. LALR(1) Machine cannot be constructed with this grammer


2. inadequate states can be resolved using the fact that the = is left associative
3. inadequate states can be resolved using the fact that the = is right associative
4. Both 2 and 3

parsing compiler-design

GIVEN GRAMMAR IS OPERATOR PRECEDENCE GRAMMAR,SO WE CAN CONSTRUCT THE PARSING TABLE,EVEN THOUGH IT
IS AMBIGUOUS

 0 votes -- Santhosh Devulapally ( 159 points)

4.27 Parsing: Identify the type of Grammar top gateoverflow.in/27348

The Grammar E → EE | a is

1. LR(1)
2. SLR(1)
3. LR(0)
4. None

parsing theory-of-computation

We can not parse ambiguous grammar by these( SLR(1),LALR(1),CLR(1),LL(1),LR(0) ) parsers.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 268 of 2244

Given grammar is ambiguous.

Hence (D) none is the Answer.

 3 votes -- Leen Sharma ( 2935 points)

4.28 Parsing: Find out the number of rightmost derivations top gateoverflow.in/20130

Why only one derivation??

S-> E -> E+E -> E+a -> a+a

S-> E+E -> E+a -> a+a

Are these two derivations possible??

parsing


Selected Answer

Yeah, for sure there will be exactly two right most derivations of the sentence "a + a" from the given grammar. You are
right.

 2 votes -- Anurag Pandey ( 8183 points)

4.29 Parsing: If a grammar is parsed by LR(0) will it always be LL(1)..?? top


gateoverflow.in/31694

Q1. Are all LR(0) grammars LL(1) ...??

Please provide an example if not.

Q2. Does all parsing methods parses only DCFL ..??

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 269 of 2244

PS. Is it true for general case that LR(k) => LL(k +1)

parsing

no not necessary...

if a grammar is LALR then it will necessarily be LL(1)

 0 votes -- sourav anand ( 1585 points)

4.30 Parsing: Identify the type of Grammar ? top gateoverflow.in/27402

Identify the type of the grammar and give justification

S → XYc

X → Yb | a

Y → c | ϵ

1. SLR(1)
2. Not SLR(1)
3. LR(1)
4. LALR(1)

Someone please explain me it with state diagram . I'm confused with ϵ in the I 0 Closure

parsing

At level I 0

y-> epsilon will be reduced production and with lookahead b and there will be shift production y->c with look ahead b .

so there is SR conflict .

so option B is correct .

 2 votes -- Pranay Datta ( 6113 points)

4.31 Parsing: Given a left recursive grammar. Whether LL(1) or not? gateoverflow.in/20508

top

Do we directly say it is not LL(1) because it is left recursive or do we eliminate the left recursion, create the parsing table and
then make a decision.

parsing compiler-design


Selected Answer

Yes, you can directly say that left recursive grammar is not LL(1) .But after eliminating the Left recursion also, there is no
100% surity that it will become LL(1).

 2 votes -- Vivek sharma ( 1177 points)

4.32 Parsing: ISRO-2013-6 top gateoverflow.in/43760

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 270 of 2244

Which of the following productions eliminate left recursion in the productions given below:

S → Aa ∣ b

S → Ac ∣ Sd ∣ ϵ

A. S → Aa ∣ b, A → bdA ′ , A ′ → A ′ c ∣ A ′ ba ∣ A ∣ ϵ
B. S → Aa ∣ b, A → A ′ ∣ bdA ′ , A ′ → cA ′ ∣ adA ′ ∣ ϵ
C. S → Aa ∣ b, A → A ′ c ∣ A ′ d, A ′ → bdA ′ ∣ cA ∣ ϵ
D. S → Aa ∣ b, A → cA ′ ∣ adA ′ ∣ bdA ′ , A ′ → A ∣ ϵ

isro2013 parsing grammar

Your question is wrong

It should be

S-->Aa/d

and

A--> Ac / Aad/ epsilon

Then for this Option B is correct !

 0 votes -- Dexter ( 1933 points)

4.33 Parsing: LL(1) top gateoverflow.in/29377

Consider the grammar

S → AaAb ∣ BbBa
A→ϵ
B→ϵ

This grammar is LL(1)- True or false

parsing


Selected Answer

Hence Grammar is LL(1).

http://cs.stackexchange.com/questions/6768/how-is-this-grammar-ll1

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 271 of 2244

 7 votes -- Leen Sharma ( 2935 points)

First(S)={a,b}

First(A)=First(B)={∈}

Follow(A)=Follow(B)={a,b}

LL1 Table

a b $
S S->AaAb S->Baba
A A->∈ A->∈
B B->∈ B->∈

 2 votes -- Pooja ( 22773 points)

4.34 Parsing: ISRO-2013-5 top gateoverflow.in/43755

Shift reduce parsing belongs to a class of

A. Bottom up parsing.
B. Top down parsing.
C. Recursive parsing.
D. Predictive parsing.

isro2013 parsing


Selected Answer

Option a is right Shift reduce belong to bottom up.

Top down include

1) Recursive

2) Predictive

 1 votes -- Dexter ( 1933 points)

4.35 Parsing: Verifying Shift-Reduce conflicts in this SLR grammer top gateoverflow.in/33960

S -> BB

B -> aB | bB | a | b

How many SLR conflicts will occur when we try make parsing table for it.

a) 0 b) 1 c) 2 d) None of these

----------------------------------------------------------------

Doubt: Do we count 2 SR conflicts for the same state as 2 separate conflicts. I mean to say that 'SR conflicts in parse table
and SR conflicts in states can vary?' i.e, Suppose, as in one cell of parse table if we have 3 productions [ B -> a. ; B -> .a
; B -> .aB ] Then as you can see there are 2 SR conflicts in 1 state. So, do we count it as 1 conflict or 2 conflicts.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 272 of 2244

So, in the above parse table for given grammer (in Qstn). As you can see, there is such a situation in I3 (left-bottom) and in
I4 (right-bottom). So, how many SR conflicts are there 2 or 4 ??

compiler-design parsing


Selected Answer

My Answer is

We have 2 SR conflicts
i.e at I3 we have both final and non final items
such as B->a. and all other productions
so we get both shift and reduce under a (since follow of B is a,b)--its 1 conflict
and (same as I3 we have conflict at I4 ) -- 2nd conflict

 0 votes -- shivanisrivarshini ( 2067 points)

4.36 Parsing: plz explain why b is correct? top gateoverflow.in/5542

parsing

no answer is correct here . answer is n1=n3<=n2

 2 votes -- koushiksngh264 ( 203 points)

4.37 Parsing: Question on shift reduce parsing top gateoverflow.in/36019

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 273 of 2244

Given solution:

After reducing two 1's of expression to E, E*E should be reduced not the 3rd 1. So final output will be 112*311+2 instead of
the given output. Please check.

compiler-design parsing

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 274 of 2244

Bottom Up Parsing = http://dragonbook.stanford.edu/lecture-notes/Stanford-CS143/08-Bottom-Up-Parsing.pdf

 1 votes -- Amar Vashishth ( 17865 points)

4.38 Parsing: Compiler Design - Parsing Techniques top gateoverflow.in/36182

Consider the SLR(1) and LALR(1) parsing tables for a context free grammar. Which of the following statements is/are true?

a] The goto part of both tables may be different.

b] The shift entries are identical in both the tables

c] The reduce entries in the tables may be different

d] The error entries in the tables may be different.

compiler-design parsing gate1992

4.39 Programming In C: Error top gateoverflow.in/33255

What type of error in program

main()

int gate,exam;

gate=exam=10.3;

printf("%c",gate);

Lexical

Syntax

Semantic

None of these

programming-in-c compiler-design

It should be main() instead of Main().

 0 votes -- Monanshi Jain ( 5827 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 275 of 2244

4.40 Programming In C: Reference to a formal list of Tokens in C top gateoverflow.in/27964

How many tokens are there in each

1. ->
2. int *ptr = &x;
3. ++a
4. >=
5. !=
6. x += 10;

Token should be counted before pre-processing or after it?

from my experience only, I'm able to identify what are considered as tokens are and what not. I want a reliable reference to know what all
tokens are there in C. Does a token depends on what compiler is in use?

Create a standard list of tokens for GATE exam.

programming-in-c compiler-design

1. -> token = 1
2. int *ptr = &x; token = 7
3. ++a token = 2
4. >= token = 1
5. != token = 1
6. x += 10; token= 3

Find maximum length lexeme.which has some meaning

example ++ we can think it is two + but ++ has meaning of increament. so considerd as 1

 2 votes -- Anirudh Pratap Singh ( 4091 points)

4.41 Register Allocation: do we need register to allocate to all a,b,c


initially.....if following is program sequence top gateoverflow.in/7416

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 276 of 2244

register-allocation

If you'll use a good compiler then it'll find that both expressions can be evaluated as compile time since operands are
constants. So there is not any need of executing any expression at runtime.

But if constant propagation optimization is restricted, then it can be evaluated with the help of two registers.

d= a+b;

R1 <- R1 + R2 //before execution R1 : contains value of a, R2 : contains value of b,

c= e+d;

R1 <- R1 + R2 //before execution R1 contains value of variable d and R2 contains variable e, result will be in register R1

 1 votes -- suraj ( 3299 points)

4.42 Register Allocation: Register Allocation Algorithm top gateoverflow.in/33003

Could someone explain me register allocation algorithm in simple manner . I referred some text books but couldn't
understand properly . Please help me

register-allocation

4.43 Regular Language: LL(1) expressive power top gateoverflow.in/29489

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 277 of 2244

Does there exist LL(1) grammar for every Regular Language ?

OR

For Every Regular Language there exist atleast one LL(1) Grammar . True /False

compiler-design parsing theory-of-computation regular-language


Selected Answer

True : For every Regular Language there exists a LL(1) grammar.


This is true because we can always get a right recursive grammar for any LL(1) that generates a Regular language.

 6 votes -- Amar Vashishth ( 17865 points)

4.44 Scope: Scope top gateoverflow.in/42555

programming-in-c scope

static scoping will print 3,7 (as here static scoping printing local to the scope)

dynamic scoping will print 3,7 (it will be like call by reference)

 0 votes -- srestha ( 11585 points)

4.45 Sdd: L-attributed or S-attributed, inherited or synthesized? top gateoverflow.in/38095

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 278 of 2244

How to solve this question?

Attributes calculated from children are synthesized, while attributes calculated from parents and/or siblings is inherited. And
S-attributed are purely synthesized, while L-attributed are synthesized+inherited, is this right?

compiler-design sdd


Selected Answer

Answer is D.

In S-attribute grammar we can have only synthesized attributes.

In L-attribute grammar we can have both synthesized as well as inherited attributes, but the inherited attributes must
come from left side (not from right side) only. Here, Ri = Ti, Fi = Ri, Ei = Fi violate this making this not L-attributed grammar,

 3 votes -- Arjun Suresh ( 124125 points)

4.46 Shift: ugc net top gateoverflow.in/43915

shift parser

Answer is c

It suffer from both . infact all the Bottom up parser can suffer from both these conflicts !

 0 votes -- Dexter ( 1933 points)

4.47 Shift Reduce: When to shift and when to reduce? top gateoverflow.in/38017

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 279 of 2244

In the above grammar,

1. how to determine the precedence of the operator?

2. If there is shift and reduce conflict, in who's favor to resolve?

3. Why are we not reducing E-->E+E, instead we are shifting. But incase of E-->id, we are reducing.

compiler-design parsing shift-reduce grammar

when you can not derive any precedence out of the gramaar rules, use the general precedence of operators.

which is id > * > + > $

now if you know how the above algorithm works you will certainly know why i) has not been reduced and ii) also not
reduced

 0 votes -- confused_luck ( 205 points)

4.48 Syntax Directed Translation: SDT output expression evaluation top gateoverflow.in/36664

Consider the SDTS for the ambiguous grammar

E → E + E out( " 1 + 2 " )

E → E ∗ E out( " 2 ∗ 3 " )

E → num out(num. val)

Assume a shift reduce parser. The output is treated as an arithmetic expression in C & evaluated. The input is 1 ∗ 1 + 1.

The value obtained is _______.

EDIT: Here's the explanation given..

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 280 of 2244

syntax-directed-translation compiler-design ace-test-series

4.49 Syntax Directed Translation: For the below SDT, what will be the output
for the input string aaacb ??? top gateoverflow.in/31782

For the below SDT, what will be the output for the input string aaacb?
S → aAa {print "0"}
S → b {print "1"}
A → Sc {print "2"}

How to approach as S→ aAa then how we will get the string aaacb .

syntax-directed-translation compiler-design

String aaacb cannot be generated from the given Grammer

 1 votes -- Abhijit Borah ( 21 points)

4.50 Syntax Directed Translation: Which type of compiler conflict is detected


and resolving it top gateoverflow.in/33619

E --> number {E1.val = number.val}

E --> E+E {E.val = E.val+E.val}

E --> E*E {E.val = E.val*E.val}

The above grammar and the semantic rules are fed to a yacc tool (which is an LALR(1) parser generator) for parsing and
evaluating arithmetic expressions. Which one of the following is true about the action of yacc for the given grammar?

A) It detects recursion and eliminates it.

B) It detects RR conflict and resolves in favor of Shift

C) It detects SR conflict and resolves in favor of Reduce

D) It detects SR conflict and resolves in favor of Shift

-----------------------------------------

I have little confusion in drawing the states for such recursive grammers. And what does it mean to resolve a conflict in
favour of something???? (It will be very helpful if you also attact pic of state diagram along with the answer) Thnx

compiler-design syntax-directed-translation theory-of-computation

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 281 of 2244


Selected Answer

Yacc detects SR conflict and resolves in favor of Shift.


Resolves means what it will do on SR conflict.

 2 votes -- Monanshi Jain ( 5827 points)

4.51 Syntax Directed Translation: Tracing sdt for output top gateoverflow.in/35420

Fill in the blanks

Consider the SDTS below

E1 → E out( ∗ 2)

E → + T out( ′ 1 ′ )

E → T out(10 ∗ )

E → T ∗ F out( ′ ∗ ′ )

T → F out( ′ 100 + ′ )

F → num out(num val)

The input is 1 + 1 ∗ 1 and the output generated is evaluated as an arithmetic expression . The value obtained is
_____________.

Ans =2200

correct ans 2212

I am not getting the answer, plz help. [SDT tracing by default is left-recursive, right??]

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 282 of 2244

compiler-design syntax-directed-translation ace-test-series

4.52 Syntax Directed Translation: Test Series: Compiler: SDT top gateoverflow.in/31459

Consider the following SDT.


What is the output of the expression “10 + 4 ∗ 6”?

a. 29
b. 32

c. 30
d. 28

I Calculated I got 34 so I selected nearest answer 32. But the given answer is 30.

compiler-design syntax-directed-translation

10+4*6

10+24

34

 3 votes -- Pooja ( 22773 points)

4.53 Syntax Directed Translation: Consider the following SDT. A → BC *(I) B.i
= f(A.i) (II) B.i = f(A.S) (III) A.S = f(B.s) top gateoverflow.in/16165

Consider the following SDT.

A → BC *

(I) B.i = f(A.i) (II) B.i = f(A.S) (III) A.S = f(B.S)

which of the above is violating L – attributed definition?

(a) I only (b) II only (c) I, II (d) I, II, III

compiler-design syntax-directed-translation

ans:(b) II only

A->BC*

(I) B.i = f(A.i) //A is B's parent so Valid L Attributed rule

(III) A.S = f(B.S) //synthesized attribute so valid L attributed rule

as L attributed sdd can contain both left inherited and synthesized attributes

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 283 of 2244

(II) B.i = f(A.S) inherited attribute i is dependent on synthesized attribute s of A so its not a valid L Attributed sdd rule

//ur at B and want to calculate B.i but its dependent on A.s which will be calculated once u finish B and move up in syntax tree, so its a
cycle.

also a syntax-directed definition is Lattributed if each inherited attribute of Xj on the right side of A → X 1 X2 … Xn depends only on

1. the attributes of the symbols X 1, X2, …, Xj-1

2. the inherited attributes of A

reference:https://www.cs.fsu.edu/~engelen/courses/COP562107/Ch5a.pdf

 1 votes -- Anurag Semwal ( 4775 points)

4.54 Syntax Directed Translation: Consider the SDT , where S ->TR, R->
+TR|empty {print ("+")} , And T-> num {print(num)} And if the input is
given "9+5+2" What is output ? top gateoverflow.in/9019

Consider the SDT , where S ->TR, R-> +TR|empty {print ("+")} , And T-> num {print(num)} And if the input is given
"9+5+2" What is output ?

compiler-design syntax-directed-translation


Selected Answer

Input 952++
S-> TR

-> 9 R (print 9 by T -> num)


-> 9 +TR (R -> +TR)
-> 9 + 5 R (print 5 by T -> num)
-> 9 + 5 + TR (R -> +TR )
-> 9 + 5 + 2 R (print 2 by T-> num)
-> 9 + 5 + 2 (print + by R -> empty)
-> 9 + 5 + 2 (print + by R -> empty)

So, answer is 952++.

 0 votes -- Arjun Suresh ( 124125 points)

Answer is 95+2+
See this -

 2 votes -- Ankish ( 121 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 284 of 2244

4.55 Target Code Generation: Links to study Data flow analysis and register
allocation using graph coloring. top gateoverflow.in/25137

All the links that I could find on the web were too long. Kindly refer a video or a web link that you may find easier to grasp
from?

compiler-design target-code-generation

4.56 Testbook: TestBook Live Test 2 Q No 26 top gateoverflow.in/36725

Here n = > 2 k

Then 2n-1 => 2 * 2 k -1 => 2K+1 - 1

SO first option is correct as per me !

is my ans correct !

test-series testbook compiler-design

http://gateoverflow.in/36558/nodes-in-a-derivation-tree-for-grammar-in-cnf refer this same ans

 0 votes -- Anirudh Pandey ( 343 points)

4.57 Testbook: TestBookLive Test 1 Q 22 top gateoverflow.in/37017

testbook test-series compiler-design grammar


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 285 of 2244

yes option 3) is true .

1) Every regular grammar may or may not be LL1. Regular grammar can be left linear or right linear grammar and though
righ linear grammar is guaranteed to be recursion free as well as factoring free, left linear grammar allows both and such
a grammar cannot be parsed by LL1 parser. So it is false. (Even not all right linear grammars can be parsed by LL(1)- see
part 3)

2) this is false ...

by this picture (given in Stanford-CS143 ) it is clear every LL1 Is not LALR(1).

3) Ambiguity can even come from inherent property of language. So it need not be true always. counter eg :

s--> iEts/iEtses/a

s-->b

after removing left factoring

s--> iEtss'/a

s'---> E/es

E--->b after removing left factoring we still come with ambiguity ..so this is true

for more clear picture

1) if it is ambiguous and right linear then also it will not be parsed by LL1 ..becoz LL1 does not parse ambiguous and left
recursive grammer

2)this is LL1 but not LALR


S ::= '(' X
| E ']'
| F ')'
X ::= E ')'
| F ']'
E ::= A
F ::= A
A ::= ε

3) if language is not inherently ambiguous after then it could be ambiguous ..bcoz inherently ambiguous property says for
given grammar , every language derived from it will be ambiguous .. while without this property , may also ambiguous ...
bcoz ambiguous means for same language or string we have 2 or more parse tree structure .. so if there is single
language from given grammar , for which we have more than 1 parse tree then it will be ambiguous.

 3 votes -- sonam vyas ( 6441 points)

4.58 Tokens: Number of tokens top gateoverflow.in/37487

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 286 of 2244

tokens lexeme compiler-design ace-test-series

Total tokens are |the|, quick|,brown|,fox|,jumps|,over|,the|,lazy|,dog|.| so total number of tokens are 10

 0 votes -- shivanisrivarshini ( 2067 points)

4.59 Top Parsing: Compiler general query LL(1) top gateoverflow.in/30571

check whether the following grammer is ll(1) grammar or not and also find the table entry of [A,a].

S ->A,

A->aB/Ab,

B->bBC/d,

C->d

Why is this not a LL(1) grammar?

compiler-design top-parsing


Selected Answer

It is not LL(1). For a grammar to be LL(1), it should be unambiguous, should be deterministic and should not have left
recursion.

The production A->Ab is left recursive.

Therefore, it is not a LL(1) grammar.

 6 votes -- Monanshi Jain ( 5827 points)

No it will not be LL(1)

Because First (S) ={a}

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 287 of 2244

First(A)={a}⋂{a} ={a} !=NULL

First(B)={b}⋂{d}=∅

First(C)={d}

for First(A) it will be not LL(1), because for LL(1) there First(A) should be NULL

 1 votes -- srestha ( 11585 points)

4.60 Variable Binding: ISRO-2013-7 top gateoverflow.in/43764

Consider the following psuedocode:


x: integer := 1
y: integer := 2
procedure add
x:= x + y
procedure second (P: Procedure)
x: integer := 2
p()
procedure first
y: integer := 3
second (add)
first ()
write_integer(x)

What does it print if the language uses dynamic scoping with deep binding?

A. 2
B. 3
C. 4
D. 5

isro2013 runtime-environments variable-binding

Deep binding binds the environment at the time the procedure is passed as an argument.

So using Dynamic scoping with deep acess it wil find global variable x and update x to 4 .

While Shallow binding binds the environment at the time the procedure is actually called.

Shallow binding just traverses up until it finds the nearest variable that corresponds to the name so the answer would be 2+3=5

 0 votes -- Manojk ( 3365 points)

4.61 ugc net paper 2 computer science code 87 must tell me top gateoverflow.in/11840

http://ugcnetonline.in/question_papers_december2012.php

Q18 how to find precedence the operator wch is near to leaf having hightest precedense but here how to implement ? must
reply

Q49 ans shd both na B & D bcz NAND & NOR both commutative but not associtave ..

Q18 yes which is near the leaf gets the highest precedence .

Precedence in a grammar is enforced by making sure that a production rule with higher precedence operator will never produce an expression with operator with lower
precedence.
In the given grammar ‘-’ has higher precedence than ‘*’

Q49 yes you are right . NAND & NOR both commutative but not associtave

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 288 of 2244

 1 votes -- Pranay Datta ( 6113 points)

4.62 Bottom up and top down parser's ? top gateoverflow.in/13281

q. 23 : can anyone explain why both statements are false? I thought option B is correct?

Bottom up parser tend to complicate if (k>1) : look ahead.

Isn't same true with ll(k)? Try constructing dfa for k>=5.

 0 votes -- vishal8492 ( 245 points)

4.63 Why is left recursion not a problem for bottom up parsers? top gateoverflow.in/13282

I know the parsing logic of bottom up parsers, that they start from the terminal and reduce it to the start symbol. But what
really confuses me is the construction of LR(0)/LR(1) sets :

Eg : S->Sa|a

Then in LR(0) set :

S'->.S

S->.Sa

S->.a

Now the dot is in front of S , so shouldn't the S production be generated again and again and make it go to an inf. loop?

The main reason why Bottom up parser doesnt have any problem with Left recursive is that it start building tree from
leaves . After seeing through a input you will check the next lookahead , if that lookahead lies in follow of a NT then you
will reduce and if not then shift .So by any mean you are not doing that recursive work Hence it doesnt have problem with
Left recursive .

Where as in top you start from Root

so if you have production s-->Sa

s->Saa

s-->Saaa

and so on

you may run to infinite ( or to precise till stack doesnt get full )

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 289 of 2244

 0 votes -- spriti1991 ( 1127 points)

4.64 Liveness of a variable top gateoverflow.in/9262

http://gateoverflow.in/?qa=blob&qa_blobid=6419625116648850773

compiler-design


Selected Answer

Live variable means those which will be used again- not necessarily by same block.

int a = 5;
if(a < b)
{
b = 7;
}
c = a;

Here the statements inside the if are in a separate basic block and a is live there because a is used again though in a
different block. Compiler use live variable analysis to see for which all variables it can free the registers.

 1 votes -- Arjun Suresh ( 124125 points)

4.65 To allow only one process in the critical section, value of a binary
semaphore is initialized to __? top gateoverflow.in/7708

operating-system

In case of 0 it blocks the calling process. It should be 1

 0 votes -- Anurag Semwal ( 4775 points)

4.66 L attributed Grammer top gateoverflow.in/36411

Statement : L attributed grammer can be evaluated using bottom up parsing.

Doubt : L attributed has both types, synthesized as well as left inherited grrammer. So in L attributed grammer how will be
left inherited attributes be evaluated (which need preorder traversal)?

Something like this :

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 290 of 2244

compiler-design

4.67 LALR vs. CLR vs. SLR top gateoverflow.in/37184

Could someone please help me check the conflicts in LALR parser. I never understand the difference between these CLR and
LALR. and because of this i even forget the SLR parser. please if someone can explain it easily?

every lalr is clr but converse may not true.

in clr we have to find lr(1) items first and we identify final items and check for conflicts

in lalr we have to merge equal states with lookaheads diffrent and find conflicts

if a grammar is not clr(1) grammar it definitely not lalr(1)

my suggestion is go this link and watch video:

https://www.youtube.com/playlist?list=PLEbnTDJUr_IcPtUXFy2b1sGRPsLFMghhS

 0 votes -- Registered user 7 ( 343 points)

4.68 Who create entries in Symbol Tables ? top gateoverflow.in/9122

Who create entries in Symbol Table ?

1. Lexical

2 . Synatx

3 both

4 Either 1 or 2

compiler-design

Both lexical and syntax anlysis. In lexical, symbol table entries are created for tokens. In later phase (syntax analysis)
most of attribute information of those tokens are entered.

 3 votes -- mallesham ( 63 points)

4.69 Unification Algorithm top gateoverflow.in/9210

Sir, Can you provide an example of Unification Algorithm . ?

compiler-design

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 291 of 2244

refer to this: http://basics.sjtu.edu.cn/seminars/c_chu/Algorithm.pdf

 1 votes -- Rohan Ghosh ( 1515 points)

4.70 Regular or Context Free Grammar? top gateoverflow.in/13397

Q4) Consider the following statement:

if (expression) statement else statement

Which of the following describe the above statement?

A). Regular grammar

B). Context free grammar

C). Both (A) and (B)

D). None of these

q4) : I do not understand.

context free grammar

treat it like

S->iESeS

E->(E)

 0 votes -- rajesh srivastava ( 77 points)

4.71 Which type of conflict is present ? top gateoverflow.in/16641

Hi , I am confused about this grammar .

I can find there is one SR conflict , please clarify.

S -> Aa | bAc | dc | bda

A -> d

Here , it is not LL1 as A -> bAc and S -> bda both need to placed in the same cell.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 292 of 2244

Also , should I say that S -> Aa and A -> d are also SR conflicts as they both derive d ?

And for that it is not LR(0) as well .

compiler-design

I hope this helps :)

 0 votes -- CrimeMasterGoGo ( 2221 points)

4.72 SET OF VIABLE PREFIXES FOR A GIVEN SLR(1) GRAMMAR IS REGULAR


LANGUAGE ? top gateoverflow.in/16458

If 20% of bolts produced by machine are defective determine probability that out of 4 bolts choosen number of defective
bolts is less than 2

1)27/64

2)81/256

3)27/256

4)512/625

compiler-design

Yes. From dragon book

"For every grammar G, the GOTO function of the canonical collection of sets of items defines a DFA that recognizes viable
prefixes of G"

 0 votes -- lowOnATP ( 135 points)

4.73 Symbol table Access time top gateoverflow.in/34850

Which of the following symbol table implementations is best suited if access time is to minimum?

(a) Linear list

(b) Search table

(c) Hash table

(d) Self-organization list

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 293 of 2244

4.74 Compiler question top gateoverflow.in/34819

I did in this way :

There is conflict , right ? As A -> g. and B -> g. both going to $ and g

compiler-design

4.75 parsing top gateoverflow.in/34542

4.76 Is there three SR conflict in the CLR(1) grammar top gateoverflow.in/34776

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 294 of 2244

Will not there be 3 SR conflicts in CLR(1) reduction ?

In fact their ans also says this :

In the state I1 , will it not be SR conflict ?

compiler-design


Selected Answer

We do not consider I1 state because that production has been added by us to show accept state, it is not a part of given
production

 2 votes -- UK ( 1341 points)

4.77 Access time of the symbol table will be logarithmic, if it is implemented


by a top gateoverflow.in/16194

Q - Access time of the symbol table will be logarithmic, if it is implemented by a

(a) linear list (b) search tree (c) hash table (d) none of the above

compiler-design

A. Linear list : on average O(n/2) i.e linear complexity

B. Search tree : on aaverage O(logn) i.e. logarithmic complexity. //Answer

C. Hash table : Perfect Hashing leads to O(1) i.e. constant complexity.

 0 votes -- Digvijay Pandey ( 26245 points)

4.78 Grammar Type? top gateoverflow.in/35639

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 295 of 2244

The grammar E → T + E ∣ T is?

A. LR(0) and LL(1)


B. Not an operator grammar
C. Ambiguous
D. SLR(1) but not LL(1)

As the question did not seem to be complete , I am trying to guess the question from the answer ( shame on these test
series guys , can't even proof-read question ).

compiler-design

4.79 error top gateoverflow.in/36047

identify the type of erroe

int main()

int gate,exam,rank;

gate=exam=rank=10.3;

printf("%c",gate);

a)lexical error

b)syntax error

c)semantic error

d)none of these

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 296 of 2244

compiler-design

It won't print anything as ASCII character for 10.3/10 is newline; so it won't print anything , but go to the next line. I
don't think any error is present. So, D

 0 votes -- Sourasekhar Banerjee ( 179 points)

4.80 operator grammar top gateoverflow.in/38265

Q). Consider the following operator grammar

S → BbA ∣ bA ∣ bBA

B → b ∣ c

A → a

Which of the following precedence relation is correct from above grammar? Assume x < y is used to represent y has highest
precedence than x and in expression y appears first then x appears next.

a). a < − b

b). c < a

c). Both (a) and (b)

d). None of these.

4.80 Can Regular Grammar be ambiguous ? top gateoverflow.in/14607

if a grammar is regular then it will be Context free also [as per chomsky hierarchy] it may be or may be not ambiguous
depending on grammar.

as
S->bS|aX
X->bS|aY
Y->aY|bY|^
is regular having regular expression (a+b)*aa(a+b)* and unambiguous

but grammar
S->aS|bS|aX
X->aY
Y->aY|bY|^
is also regular having regular expression (a+b)*aa(a+b)* and ambiguous.[check aaa]

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 297 of 2244

But it is sure any ambiguous regular grammar can be converted into unambiguous regular grammar.

 2 votes -- Praveen Saini ( 34299 points)

4.81 DAG top gateoverflow.in/35778

it is very confusing in upper part,someone xplain in details

compiler-design


Selected Answer

50..

 1 votes -- sonam vyas ( 6441 points)

4.82 shift reduce top gateoverflow.in/35757

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 298 of 2244

4.83 Postfix expression for the following image ? top gateoverflow.in/13283

q.26 : I do not understand the output . Why are real , integer and to coming?

Since precision wise real>Integer

Sum would be real value as well, and what you int to real is explicit casting.

​Answer : D

 0 votes -- vishal8492 ( 245 points)

4.84 S l attributed top gateoverflow.in/39068

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 299 of 2244

compiler-design

Q.in = f(A.s) // Q gets its value from parent i.e. L attributed

R.in = f(Q.s) // R gets its value from Left sibling i.e. L attributed

Both are L attributed but NOT S attributed.

 1 votes -- Digvijay Pandey ( 26245 points)

4.85 S-> iEtSS'|a S-> eS|epsilon E->b top gateoverflow.in/43249

The LL(1) parsing table for the above grammar is

Nonterminal a b e i t $
S S->a S->iEtSS'

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 300 of 2244

S' S' ->epsilon S'-


>epsilon
S' ->es
E E->b

By looking the parse table we found multiple entries in M [S',e] hence Grammar is not LL(1).

Now suppose I have to make a LL(1) parser but here I found grammar is ambiguous so I have to remove this ambiguity
otherwise we are not able to make LL(1) parser for this grammar .In order to remove ambiguity from grammar we always
choose the production S' ->eS to be present in parse table and remove S' ->epsilon and make it LL(1). So my question is
WHY we always choose S' ->eS production to remain in this parse table why not S' -> epsilon? Answer this..???

Hi i think s--> ietss'

s'-->es / epsilon ( you have mentioned S --es )see above

E--> b

But apart from that the LL1 table that you constructed is wrong

On top you have terminals along with $ . You have an entire coloumn for epsilon which is wrong

In LL 1 when ever we have NT --->∈ so in such case we find follow( NT ) , and what ever value we get ( say we get a and
b ) under a and b which are terminals we will put the NT --->∈ .

And i dont undersatnd your last statement can you elaborate it more :)

whereas For epsilon thing it has nothing to do with ambiguity . In ll1 we are looking 1 look ahead symbol then accordingly
we will use production ( in top down manner ) . So according to looakahead symbol we have to use which production is
summarized here :)

 0 votes -- Dexter ( 1933 points)

4.85 How much of SDT, Runtime Environment, Code Generation there in


GATE syllabus? top gateoverflow.in/43277

4.85 S-->A|B A-->a|epsilon B-->b|epsilon Is this grammar LL(1) ?? top gateoverflow.in/43037


Selected Answer

S→A∣B
A→a∣ϵ
B→b∣ϵ

Now if I want to generate empty string (ϵ) from above grammar, I have more than one option to generate it. Obviously
grammar is ambiguous. No parser will work.

So, just for answer : Grammar is NOT LL(1).

 3 votes -- Digvijay Pandey ( 26245 points)

4.86 Basics Compiler top gateoverflow.in/42596

In each activation of a procedure , the local variables names in that procedure is bound to ----------- storage location ?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 301 of 2244

1) Diff

2) same

3) None

compiler-design


Selected Answer

2}same

 0 votes -- srestha ( 11585 points)

4.87 Number of conflict top gateoverflow.in/42952

Consider the grammar given below

S SS | a | ∈

The number of inadequate states in the DFA of LR(1) items is

(a) 1 (b) 2 (c) 3 (d) 4

Ans 3

http://gateoverflow.in/?qa=blob&qa_blobid=11048084677475811705

 1 votes -- Manojk ( 3365 points)

4.88 ugc net top gateoverflow.in/43690

Option A is wrong , you cant have an Empty string

Option B is wrong : The second production has no terminals to it

Option d is wrong : You cant ever reach S1 production from S

Option C is correct . You can derive all the required string of teh form a^n b^m c ^ (m+n) where n ,m >= 0

 0 votes -- Dexter ( 1933 points)

4.89 ugc top gateoverflow.in/43696

26. Given the following statements :


S1 : SLR uses follow information to
guide reductions. In case of LR
and LALR parsers, the lookaheads
are associated with the

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 302 of 2244

items and they make use of the


left context available to the parser.
S2 : LR grammar is a larger subclass
of context free grammar
as compared to that SLR and
LALR grammars.
Which of the following is true ?
(A) S1 is not correct and S2 is not
correct.
(B) S1 is not correct and S2 is
correct.
(C) S1 is correct and S2 is not
correct.
(D) S1 is correct and S2 is correct

I dont understand the term left context here ? . I think it should make use of lookahead for reduction , if it then statement
1 is correct too

Statement 2 is correct .

 0 votes -- Dexter ( 1933 points)

4.90 Pépère après l'effort... Composition top gateoverflow.in/43778

Pépère après l'effort... Composition : dessus simili cuir - intérieur laine 100% - semelle feutre avec patin caoutchouc anti-dérapant. Mule avec l'intérieur de la charentaise procurant chaleur et
confort. Livrée avec une trousse cadeau. 2 articles ou plus : livraison gratuite http://www.paysdesgeants.fr/air-jordan-12-c-2_6.html

normal

4.91 Among LR(0), SLR(1) and LALR(1) which parser is going to detect error
faster and why?? top gateoverflow.in/351

Among LR(0), SLR(1) and LALR(1) which parser is going to detect error faster and why??

The basic difference between the parser tables generated with SLR vs LR, is that reduce actions are based on the Follows
set for SLR tables. This can be overly restrictive, ultimately causing a shift-reduce conflict.

An LR parser, on the other hand, bases reduce decisions only on the set of terminals which can actually follow the non-
terminal being reduced. This set of terminals is often a proper subset of the Follows set of such a non-terminal, and
therefore has less chance of conflicting with shift actions.

LR parsers are more powerful for this reason.

 1 votes -- Rohan Ghosh ( 1515 points)

4.91 LR(K) grammer can be ambigious or not? top gateoverflow.in/5347


Selected Answer

Yes as both LL grammer and LR grammer are sibset of unambiguous grammers

 2 votes -- Kuldeeppunjabi1729 ( 127 points)

4.92 according to me answer should be 3. give correct explanation. top gateoverflow.in/5533

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 303 of 2244

There is only one terminal in this i.e: id

and rest all the symbols used has to come down to id for satisfying the BNF grammar.so,

<expression>

<term>

<factor>

<expr>

are all non-terminals ending at terminal: id

 3 votes -- sumit kumar singh dixit ( 1625 points)

4.93 Consider the following grammar. How many back tracks are required to
generate the string aab from the above grammar? top gateoverflow.in/43709

Consider the following grammar. How many back tracks are required to generate the string aab from the above grammar?

S → aB | aAb

A → bAb | a

B → aB | ε

No of Backtrack=3

 1 votes -- Manojk ( 3365 points)

S->aB->aaB->aa unsuccessful

backtrack 1 time

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 304 of 2244

S->aAb->abAbb->ababb unsuccessful

backtrak

S->aAb->aab //successful , no backtrack

So, 2 backtracking required

 1 votes -- srestha ( 11585 points)

4.94 Basics Compiler top gateoverflow.in/42595

In each activation of a procedure , the local variables names in that procedure is bound to ----------- storage location ?

1) Diff

2) same

3) None

compiler-design

I guess Option 1)

 1 votes -- saif ahmed ( 931 points)

4.95 Binding top gateoverflow.in/42593

After the assignment pi=3.14 if the storage address 200 associated with varaible pi is used , then the assignment changes

1) Enviorment

2) state

c) binding

d) none

As far as i know Binding happen at run time . Now whenever we declare a variable we are binding name to storage
allocation . so this is is nothing but an Enviorment . Now assigning the value to this variable is a state .

So now after assignment the STATE would changes . am i right ?

compiler-design


Selected Answer

And you are absolutely right. Answer will be (2) i.e. State, Here is I am putting some snapshot of the Compiler books,
written by legendary Jeffrey Ullman, Alfred Aho, Monica S. Lam, Ravi Sethi.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 305 of 2244

 2 votes -- Rude Maverick ( 3063 points)

4.95 what is compiler? top gateoverflow.in/41643


Selected Answer

You write a C program to add two input numbers. Compile it and run - get the sum.

Now compiler comes in between here. What it does?

We are writing C code as per C syntax in English language. But the computer has a processor inside it where it takes
instructions in machine language and the instructions should be of the form prescribed by the processor maker (Intel for
example). These will be like

"MOV A, B;
ADD A,B;"

So, the compiler does this job. It converts the source program written by a programmer in a high level language like C to
the language the processor can understand- often called object file.

In the above example I used A and B which can be registers- which are memory locations fixed inside CPU. But these
registers are limited and when we need more memory (say finding the sum of 100 elements) we use main memory (RAM)
and then the address is used in then instruction - like 0x40000321 (of course converted to binary) instead of A. Then the
CPU will call its address handler - in a VM system this will be converted to a physical address, and that returns/stores the
content from/to that address. For this reason we study CO&A.

 2 votes -- Arjun Suresh ( 124125 points)

4.96 The identification of common sub-expression and replacement of run-


time computations by compile-time computations is ? top gateoverflow.in/7707

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 306 of 2244

compiler-design

Constants can b evaluated at compile time only so compiler removes this headache of run time by identifying the
subexpressions whose value dont change even if program runs,,ie the constants

eg:int a=5+b;

b=7;

above two lines can b evaluated at compile time during optimization as :

a=12

 3 votes -- Nisha kumari ( 365 points)

4.97 How do we find out whether a given grammer is SLR(1) or LR(0). top
gateoverflow.in/40932
Consider the following grammer:

S-> aAb | Sc

A-> d | Sd | S

The above grammer is:

a) SLR(1)

b) LL(1)

c) LR(0)

d) none of the above

compiler-design


Selected Answer

==>as the given grammar is left recursive (S->Sc),so it is not LL(1) grammar.

==>as the given grammar has SR conflict,it is not LR(0) grammar(A->S.d and A->S.)

==>it is SLR(1) as there is no any SR conflict

so answer is A) SLR(1)

 5 votes -- sourav anand ( 1585 points)

4.98 compilers top gateoverflow.in/39262

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 307 of 2244

It is useless grammar. It doesnot generate any terminals. May be ambiguois might be the answer. I dont know what they
meant

 1 votes -- Sreyas S ( 1353 points)

4.99 Associative top gateoverflow.in/38820

A---> A∗B i.e. * is Left associative


A--->B*A i.e. * is Right associative

P is Left associative . Associativity of Q is Not Defined.

 1 votes -- Digvijay Pandey ( 26245 points)

4.100 cd top gateoverflow.in/34358

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 308 of 2244

how ans is 30.?? isn't it 34??

4.100 Given the following expressions of a grammar top gateoverflow.in/42417

4.101 Which of the following is true? top gateoverflow.in/7705

compiler-design

Ans B

 3 votes -- Keith Kr ( 5467 points)

4.102 Lexical analysis top gateoverflow.in/42577

Which of the following statement is true For lexical analysis ?

a) Simplify the phases

b) Compiler effeciency improved

c) Portability is encahnced

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 309 of 2244

d)compiler work faster

compiler-design

a,b,c are true.

 0 votes -- Manojk ( 3365 points)

4.103 Compilers top gateoverflow.in/42592

System progarms such as Compiler are designed so that they are

1) Recursive

2) Serially usable

3) Non reusable

4) Reenterable

Please provide explnation too

compiler-design

Answer is (4) Reenterable.

Meaning of Reenterable is:

In computing, a computer program or subroutine is called reentrant if it can be interrupted in the middle of its
execution and then safely called again ("re-entered") before its previous invocations complete execution. The
interruption could be caused by an internal action such as a jump or call, or by an external action such as a
hardware interrupt or signal. Once the reentered invocation completes, the previous invocations will resume
correct execution.

This definition originates from single-threaded programming environments where the flow of control could be
interrupted by a hardware interrupt and transferred to an interrupt service routine (ISR). Any subroutine used
by the ISR that could potentially have been executing when the interrupt was triggered should be reentrant.
Often, subroutines accessible via the operating system kernel are not reentrant. Hence, interrupt service
routines are limited in the actions they can perform; for instance, they are usually restricted from accessing the
file system and sometimes even from allocating memory.

A subroutine that is directly or indirectly recursive should be reentrant. This policy is partially enforced by
structured programming languages. However a subroutine can fail to be reentrant if it relies on a global variable
to remain unchanged but that variable is modified when the subroutine is recursively invoked.

This definition of reentrancy differs from that of thread-safety in multi-threaded environments. A reentrant
subroutine can achieve thread-safety, but being reentrant alone might not be sufficient to be thread-safe in all
situations. Conversely, thread-safe code does not necessarily have to be reentrant.

Other terms used for reentrant programs include "pure procedure" or "sharable code"

 2 votes -- Rude Maverick ( 3063 points)

4.104 HASH TABLES top gateoverflow.in/42561

Hash tables can contribute to the following problems except

1) Counting distinct values

2) Dynamiic dictonary

3) Symbol table look up

4) Range search

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 310 of 2244

compiler-design

Answer is 4) Range search

Hashtables cannot contribute to the problems like Given values a and b, find all the records whose key value is in the
given range.

 1 votes -- vamsi2376 ( 1185 points)

I think answer should be range search..


All the rest are applications of Hashing..

1) Counting distinct values - can be easily done if we know the allowed range of numbers, say n and using the hashing
function :-
x mod n
2) and 3) are common applications of hashing..

4) Range search cannot be done by using hashing alone.

 1 votes -- Abhilash Panicker ( 6527 points)

4.105 ICG top gateoverflow.in/42560

In backpatching , what does the N mean in semantic rule for syntax rule ?

1.E1 or NE2

2.E1 and NE2

3.Not E1

a) It refer to the index of the first statement of second expression

b) It refer to the index of the first statement of first expression

c) it refer to the merging of list of 2 statements of 2 expression

d) it refer to creation of index of 2 statement

compiler-design

Here N is a marker nonterminal in the grammar causes a semantic action to pick up, at appropriate times, the index of
the
next instruction to be generated.

Consider semantic action E→E1 or NE2

If E1 is true, then E is also true

If E1 is false, however, we must next test E2 .This target is obtained using the marker nonterminal N. That nonterminal
produces, as a synthesized attribute N , the index of the next instruction, just before E2 code starts being generated.

 0 votes -- Manojk ( 3365 points)

4.106 Runtime Enviorment top gateoverflow.in/42558

Consider the following sentences :

1. Static allocation binding do not change at run time

2. Heap Allocation allocate and deallocate at run time

Which of the above is true ?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 311 of 2244

compiler-design


Selected Answer

Both the sentence is right. According to Aho-Ullman, Compiler Design book,

1) Static Allocation: It occurs before run-time and does not change during run-time

2) Dynamic Allocation: It occurs during run-time and changes during run-time

 2 votes -- Rude Maverick ( 3063 points)

4.107 DAG top gateoverflow.in/38375

Shouldn't the resulting expression be left associative ?

Q). Consider the following directed acyclic graph (DAG):

The expression represented by above DAG is:

(A) a + a + (a + a + a)

(B) a + a + (a + a + a + (a + a + a + a))

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 312 of 2244

(C) a + a + (a + a + a + (a + a + a))

(D) None

compiler-design

operator + is left associative.the expression has to be left asssociative. but the resulting grammar may be left of right
recursive.

and answer has 4 a's in the expression

 2 votes -- viv696 ( 1431 points)

4.108 Is the following grammar LL1 top gateoverflow.in/33980

In the explanation, it is mentioned as follows

Now , my question is how First(B) is a here. Can you please explain it ?

compiler-design


Selected Answer

here the grammar is LL1. there is no intersect between any of them.and for first of S they written first of B.but here first
of B not contain a..First(B)=(b,c)

First(S)=a,b,c

 5 votes -- pritika kundu ( 677 points)

4.109 lexical anayzer top gateoverflow.in/29863

can int a=a 10 is a lexical or not

if yes then why ???

if no then give reason?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 313 of 2244

The main aim of Lexical is to identify token . each lexeme in source language , it will be categorized into token class .

The following are well known token class 1. Opening braces 2. Closing braces 3. Identifier 4.Keywords 5.Digits 6.Other (
including punctuation marks and all )

now each lexeme is taken and it is matched using a pattern specified for a token class

Remember that white spaces tab etc are used as a seperator . Just like in English lang , these spaces help us to identify
words from sentences . The same thing is applied here

So according to me 'Int ---- Keyword

a--- identifier

= ---- operator

a--- identifier

now space is there it mean it was end of one token and begining of other token '

so 10 --- digit

I think its a lexical

And we shouldnt talk about semantic , we will get error at syntax phase only

 1 votes -- spriti1991 ( 1127 points)

4.110 How to evaluate given DAG ? top gateoverflow.in/30253

In this one I am unable to follow in the above node marked as "-" ,it has two edges one upward and one downward for "+"
node so then how to proceed with this ?


Selected Answer

This is not DAG. Remember defination of DAG ?

In mathematics and computer science, a directed acyclic graph (DAG) is a directed graph with no directed cycles.

Ref ->

https://en.wikipedia.org/wiki/Directed_acyclic_graph

This is some weird test series question, I think you should not, & Nobody should spent time on this !

 2 votes -- Akash ( 26315 points)

4.110 what is the difference between lookahead symbol and follow of a non-

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 314 of 2244

terminal ? top gateoverflow.in/29843

compiler-design

4.111 Compiler 1998 top gateoverflow.in/29743

Given the following expression grammer:-

E->E*F|F+E|F

F->F-|id

Which one of the following are true?

a)*has higher precedance than +

b)- has higher precedance than *

c)+ and - have same precedance

d)+has higher precedance than *


Selected Answer

F->F-E

Operator at lower level in tree has higher precedence than operator at upper levels

- has higher precedence than +and *

+ and * have equal precedence

 6 votes -- Pooja ( 22773 points)

4.112 Is there any difference between derivation tree and parse tree ? gateoverflow.in/29720

top

I have gone through this link and found that both are synonyms to each other but I am not getting that when we have more
than one parse tree for a string so do we say that the grammar is ambiguous since in the parse tree we haven't mentioned
whether it is a left-most-derivation tree or right-most-derivation tree and we say that for a grammar to be unambiguous we
should have a unique left-most derivation tree and unique right-most derivation tree .

http://stackoverflow.com/questions/5729961/any-differences-between-terms-parse-trees-and-derivation-trees

Both derivation tree and parse tree are same.

The tree made for each derivation (right most or left most) would be the same. So, for an unambiguous grammar be have
a single parse/derivation tree.

 1 votes -- Monanshi Jain ( 5827 points)

4.113 what is the lookahead symbol in LL(1) grammar ? top gateoverflow.in/29742

Top down parsers parse LL(K) grammar ,Now if we talk about recursive descent parsers they just scan each input symbol
and then perform their respective function calls ,or even LL(1) parsers also see the input symbol and accordingly chose the
production and then push the symbols onto stack so then where do they see the look-ahead symbols, I am not getting this .

compiler-design

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 315 of 2244

The input symbol is the look ahead. We would have constructed the parsing table to behave according to the current input
symbol. In recursive descent parsers we don't have parsing table hence we need backtracking. Also note that recursive
descent parsers also will accept all LL(1) languages.

 0 votes -- Mari Ganesh Kumar ( 1837 points)

4.114 LL(*) grammar top gateoverflow.in/30283

give example for LL(*) grammar

is it possible first of all...it will generate ambiguity.

 0 votes -- sultan ( 35 points)

4.115 syntax and semantic errors top gateoverflow.in/30530

What is the difference in between lexical, syntax and semantic errors?

Please give appropriate example also.

Lexical error: Error while identifying lexemes. Like inz a; instead of int a;.
Syntax error: Error in the syntax of some construct. Like printf 30; instead of printf("30");
Semantic error: Error in the meaning of the statement. Like, you have evaluated area of triangle as 2L*B. They are not detected by
compilers.

 2 votes -- Monanshi Jain ( 5827 points)

4.116 SR conflict top gateoverflow.in/30845

Which of the following could result in Shift-Reduce conflict in LR(0) parser?

1){ A→ b.c ,B→b. }

2){A→a.b,B→b. }

3) {A→∊. , B→.a}

4)All of these

all of these have shift reduce conflict.

1.A->b.c here 1 more shift is needed then final product and B->b. is final product(no more shift is need needed)

similarly 2

3.A gives final product and B is needed one shifting.

so all have shift reduce conflict.

 5 votes -- pritika kundu ( 677 points)

1) { A→ b.c ,B→b. } - Yes, chances of SR conflict. If we have shift move from this state. Here, B->b is reduced and
shift on c.

2) {A→a.b,B→b. } - Yes, chances of SR conflict. If we have shift move from this state. Here, B->b is reduced and
shift on b.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 316 of 2244

3) {A→∊. , B→.a} - Yes, chances of SR conflict. If we have shift move from this state. Here, A->∊. is reduced and
shift on a.

Therefore, option D is correct.

 2 votes -- Monanshi Jain ( 5827 points)

4.117 Compiler top gateoverflow.in/30846

Consider the following grammer

S→ bAd /bBe

A→a

B→a

The above grammer is ________________

1) SLR(1)

2) LALR(1) but not SLR(1)

3) CLR(1) but not LALR(1)

d) Not LR(1)


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 317 of 2244

Caption

check it.

 2 votes -- pritika kundu ( 677 points)

the grammar is SLR(1),CLR(1),and Also LALR (1)

so option 1 matches.

 1 votes -- pritika kundu ( 677 points)

4.118 CLR top gateoverflow.in/30802

S'→S

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 318 of 2244

S→A/B

A→fAi/n

B→fBii/d

For the above augmented grammer , the number of states in LR(1) parser are_______________


Selected Answer

20 states i guess..

 2 votes -- Khushboo Tak ( 1961 points)

4.119 CFG top gateoverflow.in/21039

Consider the following grammar

S → Aa ∣ B

B → a ∣ BC

C → a ∣∈

the no of productions in simplified cfg is

compiler-design

1.Removal of null production

S->Aa|B
B->a|B|BC
C->a

2.Removal of Unit production


S->Aa|a|BC
B->a|BC
C->a

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 319 of 2244

3.Removal of useless production

S->a|BC
B->a|BC
C->a
so total 5 production in simplified CFG.

 2 votes -- Umang Raman ( 10379 points)

4.120 Compiler top gateoverflow.in/30613

Consider the following statements

1.Compiler produce executable binary object file whereas an interpreter produce code , both executable can run many times.
2. Before translation , compiler and interpreter reads all of the input file.

Which of the following statement are true ?

compiler-design


Selected Answer

Both are false.

1. Compiler creates executable file and after that no need of compiler for running the program again and again while in case of
interpreter, it reads your program instruction by instruction and executes it that means you need interpreter each time you need to
run the program.
2. Before translation only compiler reads the complete input file while interpreter reads instruction by instruction as I mentioned
above.

 5 votes -- Monanshi Jain ( 5827 points)

4.121 Consider the following statements top gateoverflow.in/25290

Consider the following statements :

P:Every Regular Grammar is LL(1)

Q:Every regular set has a LR(1) grammar .

Which of the following is TRUE ?


a)both P and Q are true

b)P is true , Q is false

c)P is false and Q is true

d)Both P and Q is false

gate2007 compiler-design

4.122 Couting the number of reduce moves top gateoverflow.in/26242

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 320 of 2244

The maximum number of reduce moves that can be taken by a bottom-up parser with no epsilon and unit productions to
parse a string of length 3 tokens is ____ ?

compiler-design

if grammar is CNF then total reduce move are 2n-1. put n=3 here .

number of reduced move = 5

 1 votes -- Digvijay Pandey ( 26245 points)

4.123 how to solve it?? top gateoverflow.in/26716

Consider the following LL(1) grammar.


E → TE′
E′ → + E|ε
T → FT′
T′ → T|ε
F → GF′
F′ → *F′|ε
G → (E)|a|b|c
Initially stack contains two symbols. Bottom of stack symbol is andtopofstack(above) symbol is E where E is start symbol of the
grammar. The number of symbols on the stack after the sixth action taken by LL(1) parser to parse the input “ab*” are
______.

I guess, 3 should be the correct answer.

And the content of the stack should be T'E'$.

Here is the complete parsing of "ab*":

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 321 of 2244

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 322 of 2244

 1 votes -- Anurag Pandey ( 8183 points)

4.124 ambigious grammer top gateoverflow.in/26713

how to verify weather given grammer is ambigious or not???


Selected Answer

There is no general procedure or algorithm to tell whether any grammar is ambiguous or not.

To prove any grammar is ambiguous you just need one string that can be derived in more than one ways from the
grammar and has more than one, different Parse Trees/Left Most Derivations/Right Most Derivations.

To prove any grammar is not ambiguous you have to ensure for each and every string that can be derived from the
grammar that there is only a unique way to derive the string.This checking process might never end if infinite number of
strings can be generated from the grammar.

If you have a specific grammar, & if the grammar is simple enough that you can analyse its productions & tell what each
production is doing then perhaps you can say whether it is ambiguous or not.

Some tricks might be helpful in deciding ambiguity, like no LL(k), LR(k) etc. grammar can be ambiguous.

So if you can prove that your given grammar belongs to any of these classes then you can say that you grammar is
unambiguous.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 323 of 2244

But unfortunately there exists a class of grammars that is not in LL(k), LR(k) etc. classes & still is unambiguous.

 4 votes -- Anurag Pandey ( 8183 points)

4.125 Counting number of lexemes top gateoverflow.in/27071

The number of lexemes in the statement in FORTRAN


DO 10 I = 100
is __________ .

compiler-design fortran

Caption

 1 votes -- Anirudh Pratap Singh ( 4091 points)

4.126 Problem on syntax analyzer top gateoverflow.in/27075

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 324 of 2244

Given answer: C
But I believe that syntax analyzer is just for checking the form of the source code. The meaning of the program is
interpreted in semantic analyzer phase of the compiler. Please correct me if I am wrong.

compiler-design

yes,you r correct.i think option b is more appropriate.

 1 votes -- pritika kundu ( 677 points)

4.127 Dangling else problem top gateoverflow.in/27083

The dangling else problem in the construct If (E) sales S | is (E) S | a can be resolved IN SDTS by

(A) Using the associative & precedence of operating & the 'exe' munch principle
(B) By change the grammar to an unambiguous one
(C) Cannot be removed as It Is undecidable
(D) None of the above

compiler-design

Read the dangling else problem from here and it is an ambiguous case and it can be removed only if u convert the
ambiguous grammar to unambiguous one , so I guess answer is option B , it has nothing to do with precedence or
associativity.

https://en.wikipedia.org/wiki/Dangling_else

 1 votes -- radha gogia ( 4369 points)

The most appropriate answer is (A) [It can also be B, if its possible to reduce into unambiguous].

Let me explain...

'Dangling Else' problem is like deciding with WHICH 'if' some 'else' can go with. Say for following...

ex1) X --> S | b

S --> if E X else a | if E X

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 325 of 2244

ex2) S --> if E S else a | if E S | b

Both of the above cases suffers through Dangling Else problems. Why? Both can derive, " if E if E b else a" . (E stand for
some expression in Code.) Now, with which 'if' should we configure our 'else'. Compilers (LALR(1) in our day to day life)
uses the approach of choosing 'nearest if' . But this is just ONE of the way to resolve this so called ambiguity. Some other
methods are...

1) Associate dangling else with nearest if by using some matching/unmatching statemnets

2) By using something like 'endif' for marking the end of of conditional structure.

3) By using opening ( { ) and closing ( } ) curly braces around statements.

4) By using different precedence rules to associate the dangling else with nearest if. (By using lower
precedence for THEN and higher precedence for ELSE. Try it.) And by doing this and other techniques you are
HANDLING ambiguity in grammer.

5) By insisting space indentation.

A nice article on this by "Efstathios Chatzikyriakidis" (What a name :) ) Check it out


@ http://efxa.org/2014/05/17/techniques-for-resolving-common-grammar-conflicts-in-parsers/

 1 votes -- Tushar Shinde ( 1523 points)

4.127 Macro Expansion is done in which phase of compiler ? top gateoverflow.in/27086


Selected Answer

It is not done during compilation- rather just before it. This is done as by macro processor which is before any of the
compilation phase. You can see the output of macro expansion by using "-E" option in gcc.
gcc -E file.c

 3 votes -- Arjun Suresh ( 124125 points)

It is done in Preprocessor phase before compilation.

 1 votes -- Jyotsana Singh ( 153 points)

4.128 Syntax analyzer vs semantic analyzer top gateoverflow.in/27635

Choose the correct statement with respect to the syntax analysis of a compiler
(A) it can not always be modeled by a BNF grammar, but by a cfg
(B) it can be modeled by push down automata which is What a parser is all about
(C) it checks both the form & meaning of the program in a HLL
(D) none of the above

Given ans: C

compiler-design

4.129 how to solve this type of question?? top gateoverflow.in/26685

. Given the following expression grammar:


E -> E * F | F+E | F
F -> F-F | id
which of the following is true? (GATE CS 2000)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 326 of 2244

(a) * has higher precedence than +


(b) – has higher precedence than *
(c) + and — have same precedence
(d) + has higher precedence than *

Precedence of '*' = Precedence of '+' < precedence of '-' < Precedence of 'id'

 2 votes -- Digvijay Pandey ( 26245 points)

4.129 When LALR(1) is constructed form CLR(1) does not contain any shift
reduce conflicts? top gateoverflow.in/29365

When LALR1 is constructed from CLR1

1)LALR can have shift reduce conflicts only if CLR has shift reduce conflict

2)LALR may have reduce reduce conflict even if CLR dont have any conflict(conflict arises due to merging of states where
lookaheads are same)

 1 votes -- Pooja ( 22773 points)

4.130 number of productions in simplified CFG top gateoverflow.in/29368

in this question given ans is 9

s->Aa | a | bC | b

B->a | bC | b

C -> a

but here B is unreachable ans has to 5

clarify plz.....


Selected Answer

Simplified CFG means:

1. Remove useless productions.


2. Remove epsilon productions.
3. Remove unit productions.

S->Aa. since A is useless.

After step 1, grammar would be:


S->B
B->a|bC
C->a|^

After step 2, grammar would be:

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 327 of 2244

S->B
B->a|bC|b
C->a

After step 3, we will get:


S->a|bC|b
B->a|bC|b
C->a
Now, Production of B are useless (unreachable from S), so final CFG is

S-> a|bC|b

C->a

Therefore, total of 4 productions.

 4 votes -- Monanshi Jain ( 5827 points)

4.131 SDT top gateoverflow.in/29299

in top down parsing while constructing parse tree , semantic actions are considered as child of Variable (ie part of production
on RHS)

how we can decide this as the right child or left child in parse tree ?

if not getting my question ? explain sdt using top down parsing ?

See SDT simple meaning is that while traversing the parse tree only we perform the semantic actions and a semantic
action is performed when we actually reduce the symbols to a particular production , and as far as ur query is concerned
that whether semantic actions are left child or right child of the non-terminal that depends on whether u are having S-
attributed SDT or L-attributed , since in first one semantic actions are placed at right end of production while in the later
case semantic actions are placed anywhere in RHS ,Now just see that if u want to convert any infix expression to post-fix
expression , so obviously u will place the semantic actions as the right child so that after u traversed all the child nodes
,now u perform the semantic action ,See book u will get examples of SDT u will observe then when to make sematic
actions as right child or left child of the non-terminal.

 0 votes -- radha gogia ( 4369 points)

4.132 find viable prefix top gateoverflow.in/29094

Viable prefix : The prefixes of right sentential forms that can appear on the stack
of a shift-reduce parser are called viable prefixes.
simple design lr(1) dfa. then u get the ans.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 328 of 2244

ans will be d and b respectively.


http://www.cs.cornell.edu/courses/cs412/2007sp/lectures/lec09.pdf

follow this

 0 votes -- Anirudh Pratap Singh ( 4091 points)

4.133 LL(1)Grammar top gateoverflow.in/28557

First one not LL1 as it is ambigous,option c is left recursive,cant decide about option b.... plss help..

compiler-design


Selected Answer

Option B is ambiguous Grammar.

Generate string ab.


1st way : S---> aSb ---> ab
2nd way : S---> ab

Ambiguous so not LL(1).

EVEN option B having common prefixes so not LL(1).

 2 votes -- Digvijay Pandey ( 26245 points)

4.134 SR conflict top gateoverflow.in/30974

Which of the following set could result SR conflict in LALR(1)?

a) A→ a.b, {b}

B→ a. , {a}

b) A→ a.a , {a}

B→ a. , {b}

c) A→ b.a , {b}

B→ b.,{a}

d) A→ b.b , {a}

B→ b. , {a}


Selected Answer

I think option C should be answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 329 of 2244

reduce will be entered at 'a' in the table


and reading a we will got to next state A-> b.a , {b} -a-> A->ba. , {b} so shift will also be entered at a.

So SR conflict is possible.

 3 votes -- Umang Raman ( 10379 points)

4.135 Parsing top gateoverflow.in/31008

Can anybody enumerate the similarities and dissimilarities between LL, SLR, LALR and LR parsers.

http://stackoverflow.com/questions/2676144/what-is-the-difference-between-lr-slr-and-lalr-parsers

 0 votes -- srestha ( 11585 points)

4.136 Register Allocation top gateoverflow.in/19105

Could any one explain Register Allocation using graph coloring..with example!!!!!

4.137 Speed of Compiler vs Interpreter - ISRO 2008/38 top gateoverflow.in/18495

Relative to the program translated by a compiler, the same program when interpreted runs

A) Faster

B) Slower

C) At the same speed

D) May be faster or slower

isro compiler-design

A compiled language like C is usually compiled directly into machine code. When you run the code, it is executed directly by the CPU.

while in interpreted mode When you execute your code, the CPU executes the interpreter, and the interpreter reads and executes your source code
this makes it slower than compiler i guess!

 0 votes -- Umang Raman ( 10379 points)

4.138 ISRO_A 2015/25 top gateoverflow.in/19371

The number of token the following C statement is

printf("i=%d,&i=%x",i&i);

a)13

b)6

c)10

d)11

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 330 of 2244


Selected Answer

printf("i=%d,&i=%x",i&i); it has 9 token but option are not matching

the same question came in gate 2001 printf("i=%d,&i=%x",i,&i); with this statement it has 10 token

1.printf
2.(
3."i=%d,&i=%x"
4.,
5.i
6.,
7.&
8.i
9.)
10.;

 3 votes -- Umang Raman ( 10379 points)

4.139 Slr(1) top gateoverflow.in/33265

S->aAb/aBc/bAd/bBe

A->g

B->g

How many states in slr(1)

It contains 13 states and also one RR conflict

 0 votes -- Chandan Gurav ( 163 points)

4.140 Symbol table top gateoverflow.in/33257

During which phase symbol table is not modify

Lexical

Semantic

Both

None of these

compiler-design

Symbol table is modified in both of the given phases. So, none of these is the correct option.

 1 votes -- Monanshi Jain ( 5827 points)

4.141 Conflict top gateoverflow.in/33260

If lalr(1) has no conflict then clr(1) never contain any conflict

It is true or false

If it is false explain

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 331 of 2244

compiler-design


Selected Answer

It is true.

Because once we construct CLR table and it has no conflict then we go for merging the

states(LALR) and still there are chances for Reduce-Reduce Conflict in LALR table.

- But question says LALR has no conflict, then surely CLR has no conflict.

 1 votes -- Himanshu Agarwal ( 8861 points)

4.142 Difference between relocatable machine code and absolute machine


code!!!1 top gateoverflow.in/18466

Difference between relocatable machine code and absolute machine code!!!1


Selected Answer

when machine code is generated then the computer does not where the code will be placed at ram till run time . so
numbers all the line from 0-1-2.. so on. now suppose your program loaded at 230 address then this address on run time
will be converted to 230+0,230+1,230+2 means every line will just adjust acordingly . this type of address is call
relocatable address as we have to relocate the address it is a part of run time binding. whereas if i came to know at
compile time hat at what frame my program will be loading like i came to know my program will load at 530. i will make
all my line to start with 530. so that no address change will be required . so that is called absolute machine code . also
know as compile time binding.

 0 votes -- Ravi Singh ( 7303 points)

4.143 what is viable prefix? top gateoverflow.in/17819

Can someone describe what is a viable prefix with an example?

refer to this:http://stackoverflow.com/questions/4202181/explanation-about-viable-prefix

 0 votes -- Rohan Ghosh ( 1515 points)

4.144 The output for SDT top gateoverflow.in/16672

The output for SDT is

E -> E+E printf("+")

E -> a printf("a")

for a + a + a is

compiler-design

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 332 of 2244

sorry your question is very tough to understand but as much as i could understand input =a+a+a

i am getting the one of the output as aaa++ which is in the options

 0 votes -- ANI ( 503 points)

4.145 Finding number of right derivation top gateoverflow.in/27082

Given answer: 1
I am able to get 2 rightmost derivation of 'a+a'
First:
S -> E + E -> E + a -> a + a
Second:
S -> E + E -> E + a -> a + a

Total derivation -> 2

compiler-design

Two derivation tree are possible

1.S ---> E + E ---> E + a ----> a + a

2. S ----> E ----> E + E ---> E + a ----> a + a

 2 votes -- Digvijay Pandey ( 26245 points)

4.146 Type of error top gateoverflow.in/33851

The given statement has what type of error ?

in /* declare variable */ x;


Selected Answer

Should be syntax error.

lex phase treats misspelled keyword as id.

http://dragonbook.stanford.edu/lecture-notes/Stanford-CS143/03-Lexical-Analysis.pdf

 1 votes -- bahirNaik ( 2479 points)

4.147 What is the number of steps required to derive the string ((() ()) ())
for the following grammar. top gateoverflow.in/17222

What is the number of steps required to derive the string (( ) )


()() () for the following grammar?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 333 of 2244

S → SS
S → (S)
S → ε

a)10 b)12 c)15 d)16

ans -10

s -> (s)

-->(ss)

-->(s(s))

-->(s())

-->((s)())

-->((ss)())

-->(((s)s)())

-->((()s)())

-->((()(s))())

-->((()())())

 1 votes -- Saurav Kumar Gupta ( 1455 points)

4.148 Find First of Non Terminal top gateoverflow.in/17330

Find the first of RHS of A->AB/ϵ

compiler-design


Selected Answer

A ---> AB / epsilon
Here, A--->AB is useless production. So only production that matters is A---> epsilon. First of A is epsilon .

 1 votes -- Digvijay Pandey ( 26245 points)

4.149 Find number of variables in optimized code top gateoverflow.in/19505

Consider following 3 address code


t1 = t+e
t2 = g+a
t3 = t1*t2
t4 = t2+t2
t5 = t4+t3

The minimum number of temporary variables that can be used in equivalent 3-address code of above code is

Approach:

t = t+e, g = g+a, t = t*g, g = g+g,t = t+g. Hence 4 temporary variables are needed. Is this right?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 334 of 2244

compiler-design

t1=e+t

t2=g+a

t1=t1+t2

t2=t2+t2

t1=t1+t2

 1 votes -- yes ( 1251 points)

4.150 Compiler design question on LL(1) grammer top gateoverflow.in/20082

compiler-design

4.151 Which of the following is correct? top gateoverflow.in/21037

Which of following is correct?

1). Drawback with static allocation is that it does not support recursion.

2). Drawback with stack allocation is that, when function completes its execution it will be popped out from stack..

3). Both are correct

4).None of above

compiler-design


Selected Answer

1. is correct and recursion can never be done with static allocation.

2. is a bit ambiguous. But assuming a functional language feature, this is also true. In order to return a function, its
activation record must be alive even after function run. So, activation record is created on heap and not on stack for these
languages.

 5 votes -- Arjun Suresh ( 124125 points)

4.152 If an LL(1) parser carries out the SDT for a string output will be ?? top

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 335 of 2244

gateoverflow.in/31762

LL(1) uses left most derivation

E -> E * E

-> E ↑ E * E

-> id ↑ E * E

-> id ↑ id * E

-> id ↑ id * id

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 336 of 2244

 2 votes -- pramod ( 2071 points)

Should be c..

Depends on which production is used at starting E->E*E or E->E^E

 1 votes -- Pooja ( 22773 points)

4.153 No of tokens present top gateoverflow.in/31504

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 337 of 2244


Selected Answer

main

int

fl

10

20

Therefore, total of 17 tokens.

 2 votes -- Monanshi Jain ( 5827 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 338 of 2244

4.154 Grammar is LALR or not top gateoverflow.in/31502

I4 contains 2 productions and I7 contains only one production,so we cannot merge these two state.

when we merge is same productions but differ in lookahead symbols

so the grammmar is CLR(1) and LALR(1)

 0 votes -- Santhosh Devulapally ( 159 points)

4.155 Parsing2 top gateoverflow.in/31155

Can a grammar which is not LL can be SLR?

where will you fit LL in sequence below:

LR(0) => SLR => LALR => LR

* => stands for implies

Can a grammar which is not LL(1) can be SLR(0)? Yes, can be!

LR(0) => SLR(1) => LALR(1) => CLR(1)


and if LL(1) => LALR(1) => CLR(1)

 1 votes -- Monanshi Jain ( 5827 points)

4.156 Pankaj and Mythili were both asked to write the code to evaluate the
following expression top gateoverflow.in/239

Pankaj and Mythili were both asked to write the code to evaluate the following expression:

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 339 of 2244

a − b + c/(a − b) + (a − b)2

Pankaj writes the following code statements (Code A):

print (a-b) + c/(a-b) + (a-b)*(a-b)

Mythili writes the following code statements (Code B):

d = (a-b)
print d + c/d + d*d

If the time taken to load a value in a variable, for addition, multiplication or division between two operands is same, which of
the following is true?

Option 1 : Code A uses lesser memory and is slower than Code B


Option 2 : Code A uses lesser memory and is faster than Code B
Option 3 : Code A uses more memory and is faster than Code B
Option 4 : Code A uses more memory and is slower than Code B

compiler-design normal


Selected Answer

Option 1 : Code A uses lesser memory and is slower than Code B

In code A, three variables are used a, b and c to store values. The computation of a-b is repetitive and is performed 4
times in print statement requires more time compared to the computation of print statement of code B, because of the use
of additional variable d, to store the computed value of a-b. The print statement of code B replaces d with the already
computed value of a-b.

 3 votes -- Keith Kr ( 5467 points)

4.157 Eliminating Left factor top gateoverflow.in/31763


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 340 of 2244

D) none

S -> aS'

S' -> bS'' | ef

S'' -> c | d

 5 votes -- Sandeep Singh ( 5939 points)

4.158 Compiler design question on SDT : 2 top gateoverflow.in/20084

compiler-design

I got option b as answer...Is this the ryt answer and ryt method of solving this pbm?

 0 votes -- Sara ( 177 points)

4.159 Lr(k) top gateoverflow.in/32917

both are true.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 341 of 2244

 0 votes -- pritika kundu ( 677 points)

4.160 Compiler design question on SDT : 1 top gateoverflow.in/20083

compiler-design

The output Number is produced Without any Spaces is 412 .


 0 votes -- Leen Sharma ( 2935 points)

4.161 Go to top gateoverflow.in/32914

4.162 Complier top gateoverflow.in/32657

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 342 of 2244

test-series


Selected Answer

Its a CFG because its of type V --> (V+T) * where V is variable and T is terminal.

this grammer is ambiguous since there exist two parse tree for a string.

id - id * id

Only (ii) and (iii) are true.

 1 votes -- Sandeep Singh ( 5939 points)

4.163 compiler Design top gateoverflow.in/32461

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 343 of 2244

4.164 Evaluation of SDT top gateoverflow.in/34137

The way I solved it was :

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 344 of 2244

is this correct evaluation order ?

Because in the answer they have mentioned different order :

compiler-design

My solution is

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 345 of 2244

 0 votes -- shivanisrivarshini ( 2067 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 346 of 2244

5 CO & Architecture top


5.1 Access Time: Made Easy Test Series top gateoverflow.in/31264

access-time

Cache memory organisation is following hierarchical access as per question description.

So Average Access time can be calculated as

Tavg = H1*T1 + (1-H 1) * H2 * ( T 2 + T 1) + (1-H 1) *(1-H2)*H3* (T3+T2+T1)

Where,

H1 = hit ratio in level 1 i.e. cache memory ( 0.9 ) , T1 = Average Access time in level 1 ( 20 ns )

H2 = hit ratio in level 2 i.e. main memory( 0.6 ) , T2 = Average Access time in level 2 (60 ns)

H3 = hit ratio in level 2 i.e. hard disk ( 1 ), T3 = Average Access time in level 3 = ( 12 ms i.e 12000000 ns )

H3 will be 1 since its last level.

Tavg = 0.9* 20 + 0.1* 0.6*( 60+20 ) + 0.1*0.4*1 * ( 12000000 + 60 + 20 )

= 480026 ns

 0 votes -- Sandeep Singh ( 5939 points)

5.2 Ace Test Series: Radix of a number system top gateoverflow.in/35935

Can somebody please explain it?

co&architecture number-representation ace-test-series

5.3 Ace Test Series: Fastest addressing mode top gateoverflow.in/33890

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 347 of 2244

Given answer is A. I am doubtful between A and B why not B is faster than A. Please explain

co&architecture ace-test-series


Selected Answer

Think what would take more time, a register access or a memory access? Register Addressing Mode will have the operand
in the specified Register, while in Absolute Addressing mode, the operand will be in the memory, the location of memory
cell is in the instruction.

 2 votes -- Utk ( 1385 points)

(c) and (d) option cannot be answer becoz if they are compared with above two option than both c and d option are slow
(i,e take more time ) so they can be neglected now come to (a) option as register addressing in register addressing all
operand are present in register itself and after computation we store result in register itself also accessing of register is
much faster than than accessing the memory location ..one such common example is RISC processor which consists of
lots of register in which we can store the operands and because of this need of addressing mode is less, RISC proceesor
is costlier because of these registers only, where as CISC processor it is not fast becoz less use of register and more
addressing mode .
in (b) option absolute addressing there we have address in the instruction so with the helo of address we can fetch
operand from memormy which take time as compared to register accessing.. so (a) option true

 1 votes -- kunal chalotra ( 3567 points)

5.4 Address Translation: Address Translation Table Size? top gateoverflow.in/17362

What will be the size of Address Translation Table, for 32b addresses if there is an entry for: a) each byte; b) each word ,
word size is 32b; c) each 256B unit ?

operating_system co&architecture address-translation

ok. i think what they are trying to say is right. if there is a 32 bit address so it can interface 2^32 rows uniquely and now
they are saying every row should also be capable of identifying byte uniquely. size of each row will be 32 bit =4 bytes now
to represent 4 bytes uniquely i need 2 bits

so answer should be 2^32*2

for first byte i will use 00, for second 01, 10 and 11 , i can't get how they multiplied it by 4.

secondly for the second pat it should be 2^32 as every row can represent one word. i

can't get how they just did it. what i have read till now i will go with this . this is how we represent page in the page table
and map .

 0 votes -- Ravi Singh ( 7303 points)

5.5 Addressing Modes: which addressing modes in this question top gateoverflow.in/25028

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 348 of 2244

addressing-modes


Selected Answer

option B if X and Y are memory addresses.

Option C if X and Y are registers.

 5 votes -- CrimeMasterGoGo ( 2221 points)

5.6 Addressing Modes: Pc relative mode addressing top gateoverflow.in/1422

What is the intial pc value meaning

530=Pc + value

what should be the pc value

631 or 632 or 633 basically

the instruction length is not give so how can i determine the addr loaded in pc hen instructtion at 630 is executing because if
instruction length is 4 bytes it should be 634

thanks in advance

co&architecture addressing-modes

Since the address part of the instruction is 10 bits, I assume instruction length is 16 bits = 2 bytes.

So, PC value during execution of branch instruction = 630 + 2 = 632 (PC always contains the next instruction address)

Now, branch is PC relative and the address to jump is 530, the operand will be 530 - 632 = -102 = (10011010) 2 (2's
complement representation. )

 1 votes -- Arjun Suresh ( 124125 points)

5.7 Addressing Modes: Addressing mode used by PC top gateoverflow.in/29415

co&architecture addressing-modes

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 349 of 2244

Selected Answer

" We have defined the Index mode by using general-purpose processor registers. Some computers have a version of this mode in which
the program counter, PC, is used instead of a general-purpose register. Then, X(PC) can be used to address a memory location that is X
bytes away from the location presently pointed to by the program counter. Since the addressed location is identified relative to the
program counter, which always identifies the current execution point in a program, the name Relative mode is associated with this
typeof addressing.
Relative mode—The effective address is determined by the Index mode using the program
counter in place of the general-purpose register Ri. "

-[Computeranization And Embedded Systems, Hamacher, Vranesic, Zaky, Manjikian, 6Ed, Mgh, 2012]

 1 votes -- bahirNaik ( 2479 points)

5.8 Addressing Modes: CO: Addressing Modes top gateoverflow.in/34404

Consider 1GHz clock frequency processor, uses different operand access modes shown below:


Assume that 8 cycle consumed for memory reference, 4 cycles consumed for arithmetic computation and 0 cycles consumed when the operand is in register instruction
itself. What is the average operand fetch rate (in million words/sec) of the processor?

a. 117.45 M words/sec
b. 113.63 M words/sec
c. 217.45 M words/sec
d. 316.45 M words/sec

addressing-modes co&architecture


Selected Answer

Total no. Of cycles= addition of followings-

For register 0.20*0

For immediate 0.20*0

Fo memory indirect 0.40*(8+8)=6.4

For auto indexed 0.20*(4+8)=2.4

Total no. Of cycles= 2.4+6.4=8.8cycles

Frequency 1ghz then cycle time=10 -9 sec

Cpu time =total no.cycles*cycletime

Cpu time=8.8x10-9sec

Operand fetch rate(in million words per sec) =1/ 8.8x10-9sec

=113.636 M words per sec

 3 votes -- Khushboo Tak ( 1961 points)

5.9 Addressing Modes: memory addressing top gateoverflow.in/25891

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 350 of 2244

Consider 1GHz clock frequency processor,uses different operand accessing models shown below:

Operand Accessing Mode Frequency(%)


Register 10
Immediate 20
Direct 30
Memory Indirect 20
Indexed 20

Assume that 2 memory cycles consumed for memory reference ,3 cycles consumed for arithmetic computation and 1 cycle
consumed when the operand is in register(s) instruction itself . The average operand fetch rate (in millions words/sec) of
processor is __________ (upto 2 to decimal places).

addressing-modes

operand
frequency cycles
addressing mode
register 10% 1
immediate 20% 1
direct 30% 2 (2 memory read cycles)
4 (2 times 2 memory read
memory indirect 20%
cycles)
5 (2 memory read cycles +
indexed 20%
3 for index add)

1 ∗ .1 +1 ∗ .2 +2 ∗ .3 +4 ∗ .2 +5 ∗ .2
.1 +.2 +.3 +.2 +.2
Total number of cycle = = 2.7

Cycle time = 1Ghz = 1ns

1 operand -> 2.7 ns


? ->1 sec
1

Average fetch rate = 2.7 = .370370 op/ns


= .370370 109 op/s
= 370.37 MIPS

 5 votes -- Umang Raman ( 10379 points)

5.10 Arrays: Cache Memory and Arrays top gateoverflow.in/12880

Given an array A[100] of which each element size is 4 words. Processor uses a Cache Memory which is divided into 4 lines
each of size 8 words to execute the following code
for(i=0; i<100; ++i)
{
A[i] = A[i] + 10;
}

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 351 of 2244

What is the Hit Rate?


(assume storage in Row Major Order)

point I needed to extract from this question is : for calculation of hit ratio do we count a write operation as Hit or only Read
operations are counted

cache-memory co&architecture arrays


Selected Answer

we consider both read and write operation as hit

a[0] a[1] stored in one block.for first time a[0] for first reference(read) it is miss.for write it is not miss.for a[1] both read
and write are hit

hit ratio =3/4

 3 votes -- Pooja ( 22773 points)

5.11 Associative Memory: Which of the following are true about associative
memory. top gateoverflow.in/6308

Which of the following are true about associative memory.

S1: Associative memory is fast memory.


S2: Associative memory searches by content and not by accessing the address.

a) Both S1 and S2 are true and S2 is correct explanation of S1


b) Both S1 and S2 are true, and S2 is not correct explanation of S1
c) S1 is true but S2 is false
d) S1 is false but S2 is true

associative-memory


Selected Answer

d).

S2 is true and searching by content requires comparison and hence slower than accessing my address.

 0 votes -- Arjun Suresh ( 124125 points)

Both are Correct. Associative Memory is also called as Content addressable Memory..

 1 votes -- ansaritk ( 83 points)

5.12 Associative Memory: set associativity / full associativity top gateoverflow.in/12046

http://gateoverflow.in/?qa=blob&qa_blobid=3717160066093697882

associative-memory

design 1

block size= 1K words = 2 10 words

so the block size 2 10 *2 = 2 11 (16bit = 2B for 1 word) . 11 bit required .

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 352 of 2244

main mem address is 32 bit which includes 11 bits as word offset and remaining 21 bits as TAG

number of lines in cache = 2 18 / 2^7 =2^11

therefore no of TAG COMPARATOR is 2 11

design 2

8 way set associative

cache size 256 KB

block size= 64 words = 2 6 words

so the block size 2 6 *2 = 2 7 (16bit = 2B for 1 word) . 7 bit required .

sets required 256*210 /27+3 = 256

therefore 8 bits for set

and remaining bits for TAG FIELD IS (32-8-7)=17 bits

therefore TAG memory size =no of sets * No OF BLOCKS PER SET *NO OF TAG BITS

=256*8*17

= 34816 bits

 2 votes -- Pranay Datta ( 6113 points)

5.13 Associative Memory: set associativity / full associativity top gateoverflow.in/12047

http://gateoverflow.in/?qa=blob&qa_blobid=3717160066093697882

associative-memory

Q.30 ) Design 1 : Fully Associative Cache Memory

Word Size = 16 bits = 2 Bytes


256KB
2B
Cache Size = = 128Kwords
Block Size = 1K words
# Cache lines = 128K / 1K = 128

Therefore, # Tag Comparators required = # Cache Lines = 128

Q. 31 ) Design 2 : 8 Way Set Associative Cache Memory

Block Size = 64 words


# Cache Lines = 128K / 64 = 2K
#Sets = 2K / 8 = 28
Therefore, tag size = 32 - 8 - 6 = 18 bits

Tag Memory Size = #Cache lines * tag size = 2K * 18 bits = 4.5 KBytes

 1 votes -- Amar Vashishth ( 17865 points)

5.14 Associative Memory: Associativity of cache memory top gateoverflow.in/35988

Assume that 16 bit cache address memory with cache size 1024 bytes. Block size of cache memory is 8 bytes and tag size is
9 bits. What is the associativity of cache memory?

I am getting 8-way but answer is given as 4.

associative-memory co&architecture cache-memory made-easy

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 353 of 2244

Cache size = 1024 byte i.e. 10 bit to represent 1024


Tag size = 9 bit
Total Memory size = 16 bit
let Associativity is x bit .

Tag + (Cache size i.e. Block size + Number of Cache lines) - Associativity = 16 bit
9 + (10 - x) = 16

x = 3 bit

so Associativity is 2 3 = 8 way .

 0 votes -- Digvijay Pandey ( 26245 points)

5.15 Average Stall Cycle Per Ins: Q26 ch-5 M_E workbook top gateoverflow.in/21135

suppose that in 1000 memory reference there are 40 misses in the first level cache and 20 misses in the second level cache.
Assume miss penalty from the L2 cache to memory is 100 cycles the hit time of the L2 cache is 10 clock cycles.the hit time
of the L1 cache is 1 clock cycle.

Ques. if there are 1.5 memory references per instruction. What is the average stall cycles per instruction

a. 3.4 cycles b. 3.5 cycles c. 3.2 cycles d. 3.6 cycles

My work-

miss rate of L2 is 0.02 (global) and 0.5(local)

miss rate for L1 is 0.04

miss penalty for L1 is 60 cycles

for average stall cycles per instruction = (memory reference per instruction) x (miss rate) x (miss penalty)

right??

so which miss rate and miss penalty should i put here?

co&architecture cache-memory clockcycle average-stall-cycle-per-ins

1.5 memory references for 1 instruction...

1000 memory references for 2000/3 instruction

no of stall cycles=miss in l1*miss penalty in L1+miss in L2*miss penalty in L2

=40*10+20*100

=2400

so avg no of stalls per instruction=2400/(2000/3)

=3.6

 1 votes -- Pooja ( 22773 points)

5.16 Branch Conditional Instructions: pipelining top gateoverflow.in/37015

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 354 of 2244

Q31). Consider a pipeline "x" consist of 5 stages names as IF,ID,OF,EX and WB with the respective stage delays of 2ns ,5ns,
6ns and 1ns .The alternative pipeline "y" contains the same number of stages but EX stage is divided into 4 sub stages,
(EX1, EX2, EX3 and EX4) with equal delay i.e. (8ns/4) and ID stage is divided into 2 substages (ID1 and ID2) with equal delays of
(5ns/2). In the pipeline 'x' and 'y' memory reference instructions are not overlapped so the penalty of memory reference
instructions in the pipeline'x' is 4 cycles and in the pipeline 'y' is 8 cycles.If the program contains 30% of the instructions which
are memory based instructions, the speedup ratio of 'x' is speedup ratio of 'y' is _______

please elaborate on it ?

pipeline co&architecture branch-conditional-instructions

5.17 Branch Conditional Instructions: Conditional branch instruction gateoverflow.in/21292

top

An instruction pipeline has 5 stages where each stage takes 2 ns and all instructions use all 5 stages. Branch instructions are
not overlapped i.e. the instruction after branch is not fetched till the branch instruction is completed consider ideal
conditions.

If a branch instruction is a conditional branch instruction, the branch need not be taken, if the branch is not taken, the
following instruction can be overlapped. When 80% of the branch instructions are conditional branch instruction and 50% of
the conditional branch instruction are such that the branch is taken calculate average instruction execution time.

A. 5.26 ns b. 2.96ns c. 4.26ns d. 2.36ns

co&architecture pipeline branch-conditional-instructions

5.18 Branch Conditional Instructions: pipelining - branch delay slot top gateoverflow.in/32276

pipeline co&architecture branch-conditional-instructions

I'm not sure of the explanation however here is a try

For machine 70% of the delay slots are utilized so only 30% actually causes stalls. So taking stalls caused in machine 1 as

1(stage in which address is resolved -1 )*0.30≐.30 stalls/instruction.

Now avg stall created is

0.30*.20*.35≐0.021

therefore cpi≐1.021

For machine 2

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 355 of 2244

avg stall created ≐ 2*.20*.35≐0.14

therefor cpi≐1.14

Hope it helps..:)

 0 votes -- Abhishekcs10 ( 1001 points)

5.19 Branch Conditional Instructions: Q-26 ch-4 Branch conditional


instruction top gateoverflow.in/21293

Among the branch instructions 30% conditional and 70% of them does not satisfy the condition ( branch not taken). If there
is no stall due to them. What is average instruction execution time.

A. 28.96ns b. 30.2 ns

c. 32.27 ns d. 38.96ns

co&architecture pipeline branch-conditional-instructions

5.20 Byteaddressable: What is Byte Addressable and Word Addressable


means in computer Architecture ? Difference between them with examples?
top gateoverflow.in/29401

What is Byte Addressable and Word Addressable means in computer Architecture ? Difference between them with examples?

I also find some sources like stack overflow and wikipedia ? But still i couln't able to understand

http://stackoverflow.com/questions/2724449/different-between-word-addressable-and-byte-addressable

co&architecture byteaddressable

Byte addressable - To represent word in memory computer uses Bytes of code. i.e. called Byte Addressable

Word Addressable- It represents ordered Byte in a word.

If a memory block has 16 B word of data

and it is 8B word addressable

Then there are only 16/8 =2 words

 0 votes -- srestha ( 11585 points)

5.21 Cache: Size of Comparator? top gateoverflow.in/35128

co&architecture cache


Selected Answer

physical memory 32 bit

cache memory 256 KB = 2^18

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 356 of 2244

4 way set associative

cache block size 16B = 2^4

so block offset bit =4

no of blocks = 2^14

no of sets = 2^14 / 4 = 2^12

set offset bits = 12 bits

so tag bits = 32 - 12 - 4 =16 bits.

size of comparator=no of tag bits

size of comparator needed is 16 bits only.

(all options are wrong,basically they wanted to know the tag memory size)

no of tag bits in set associative cache is = 16

size of tag bits is = 16* 2^14 = 2^18.

 4 votes -- Sayantan Ganguly ( 5061 points)

5.22 Cache: cache top gateoverflow.in/19609

how many comparator and multiplexer are required in set assosiative maping technique . ?? what i know till now is if it is p
way set assosiative then p comparator will be required.. how many multiplexer will be required. ?

cache-memory co&architecture cache

Based on the set bits appropriate set circuitry is activated and the tag bits are fed into their respective 4bits-comparators
in parallel along with the TAG bits from the address; The result from all comparators goes through a multi-input OR gate
to denote hit/miss.

 1 votes -- Amar Vashishth ( 17865 points)

5.23 Cache: Which blocksize is considered for transfering words from mem
to cache incase miss if blocksize of memory & cache differ? top gateoverflow.in/17985

Case1) cache block size is 4 Words and memory block size is 8 Words

Case2) cache block size is 8 Words and memory block size is 4 Words

cache-memory co&architecture cache memory-management

Block size to be considered is for the requesting memory.

Case 1: during a cache miss 4 words will be taken from memory

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 357 of 2244

Case 2: during a cache miss 8 words will be taken from memory.

PS: I don't think "block size" is used for main memory. It is page size for memory and it is usually much bigger than cache
block size.

 1 votes -- Arjun Suresh ( 124125 points)

5.24 Cache: a 4-way set - associative top gateoverflow.in/18854

a 4-way set - associative cache memory unit with a capacity of 16kb is built using a block size of 8 words. the word length is
32 bits. the size of the physical address space is 4gb.the number of bits for the tag field is

i am geting the answer 21 tag field bit length

but answer is 22

can any explain this question if answer is 22...

cache

Memory is word adddressable

No. of words in physical memory = 4GB/4B = 1G

So no of bits required for Physical Address = 30 Bits

No. of bits required for block offset = 3 bits

No. of words in cache = 16KB/4B = 4KB

No. of blocks in cache = 4KB/8 = 512

No. of sets in cache = 512/4 = 128

So, no.of bits required to represent sets = 7 bits

Remaining bits are to represent TAG, so remaining bits are 30-(7+3) = 20 bits.

 0 votes -- admin ( 1411 points)

5.25 Cache: Finding Hit Ratio when memory references are given in Hex top
gateoverflow.in/32998

A byte addressable computer has a small data cache capable of holding eight 32 bit words. Each cache block consist of two
32 bit words. For the following sequence of addresses (in hexa decimal ). Find the hit ratio if two way set associative LRU
cache is used.

200, 204, 208, 20C, 2F4, 2F0, 2F4, 2F0, 21C, 218, 24C

Also find the number of... i) Misses ii) Compulsory Misses iii) Conflict iv) Capacity Misses.

--------------------------------------------------------------------------------------------------------------------------------

What bothers me is the answer given in Madeeasy Test Series. Here is my try.

A block consists of two 4B words. So, a block consists of 8B and as memory is byte addressable, 3 bits are used for offset.
As well as 4 blocks are possible with above scenario and 2 sets, as a result, 1 bit is used for set.

------ | Set | Offset

200 = 0010 0000 | 0 | 000 => Compulsory Miss

204 = 0010 0000 | 0 | 100 => Hit

208 = 0010 0000 | 1 | 000 => Compulsory Miss

20C = 0010 0000 | 1 | 100 => Hit

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 358 of 2244

2F4 = 0010 1111 | 0 | 100 => Compulsory Miss

2F0 = 0010 1111 | 0 | 000 => Hit

2F4 = 0010 1111 | 0 | 100 => Hit

2F0 = 0010 1111 | 0 | 000 => Hit

21C = 0010 0001 | 1 | 100 => Compulsory Miss

218 = 0010 0001 | 1 | 000 => Hit

24C = 0010 0100 | 1 | 100 => Compulsory Miss

(Other capacity and conflict misses are 0)

So, the hit ratio should be 6/11 = 0.54.

But, the answer given was 0.2

Where am I going wrong???

[P.S. - There is same qstn asked by someone previously, but I guess, that explaination is conflicting. You can check it here -
http://gateoverflow.in/29182/cache-miss-in-two-way-set-associative ]

cache-memory cache memory-management co&architecture

the ans is precisely 0.18..your aproach is right but in your xplanation you have done one mistake,the bit u choosed for set
determines in which set the address will go,that is either 0 or 1.that's it,but instead of determinning only that,u also
considered hit,miss by the set bit,there is only 2 hit .

2F4 = 0010 1111 | 0 | 100 => Hit


2F0 = 0010 1111 | 0 | 000 => Hit

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 359 of 2244

these 2,
set bit only determines in which set the address will go,
hit,miss will be decided by total address..
these 2 are hit cause set no 1 is already contain 2F4 and 2F0...
i think now you will understand your mstk..
other than u r aproach is very good,and this approach will help you determine capacity and conflict misses.

 0 votes -- Sayantan Ganguly ( 5061 points)

5.26 Cache Memory: cache top gateoverflow.in/38492

consider single level cache woth access time 5ns line size of 128 bytes and hit ratio is 0.97.Main memory uses block
transfer capability that has first 8 bytes access time 50 ns and for remaining words 10ns What is access time when there is
cache miss(Assume cache waits until line is fetched from memory and then reexecutes for hit)

cache-memory


Selected Answer

Access Time on miss = Cache access + Memory fetch + Cache access (re-access cache as mentioned in question)

= 5 + (50 + (128 − 8)/8 × 10) + 5 = 210ns

 1 votes -- Arjun Suresh ( 124125 points)

5.27 Cache Memory: if compulsory misses is problem in cache then designer


should increase the cache block size to take advantage of better locality top
gateoverflow.in/11950
TRUE OR FALSE

cache-memory


Selected Answer

true

The first access to a block is never in the cache. Also called cold start misses or first reference misses. and this type of
misses is called Compulsory misses . (Misses in even an Infinite Cache)

But here we increasing the block size then more adjacent words will be fetched on each miss, so references to these words
will not cause compulsory misses ( which can be reduced to 1 ) .

REF : http://courses.cs.washington.edu/courses/cse378/02sp/sections/section9-2.html

 2 votes -- Pranay Datta ( 6113 points)

5.28 Cache Memory: Consider a computer with the following characteristics:


top gateoverflow.in/11119

Consider a computer with the following characteristics: total of 1Mbyte of main memory; word size of 1 byte; block size of 16
bytes; and cache size of 64 Kbytes.

(a). For the main memory address CABBE, give the corresponding tag and offset values for a fully-associative cache and
tag,set and word offset for a two-way set-associative cache.

cache-memory

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 360 of 2244


Selected Answer

(a) fully associative cache..

tag(16 bit) word offset(4 bit)

CABBE :<1100 1010 1011 1011 1110>(in binary)

<1100 1010 1011 1011> <1110>

word offset is=14 th

(b) set associative

no of sets=2 11

ie 2048

tag(5 bit) sets(11 bit) word offset(4 bit)

CABBE :<11001> <01010111011> <1110>

word off set: 14

set no: 699.

tag: 25

 1 votes -- gatecse ( 9515 points)

5.29 Cache Memory: cache top gateoverflow.in/38885

A system has cache main memory and disk for virtual memory...if referenced word in cache 30 ns to access it..if it is not in
cache 80 ns to load it in cache and reference is started again ..if word not in memory 22ms to bring from disk to memory
and 80 ns from memory to disk and start again cache hit ratio is 0.8 memory hit ratio is 0.9

cache-memory

I did something Like this

0.8*30 + 0.2*0.9*(80+30) + 0.2 *0.1*(80+30 + (22000000))=440046 ns.

 1 votes -- Ritaban Basu ( 255 points)

5.30 Cache Memory: please see it once top gateoverflow.in/12044

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 361 of 2244

cache-memory

5.31 Cache Memory: 64 word cache and Main memory is divided into 16
words block. top gateoverflow.in/10668

64 word cache and main memory is divided into 16 words block.The access time of cache is 10ns/word and for main memory
is 50ns/word. The hit ratio for read operation is .8 and write operation is.9. Whenever there is a miss in cache, associated
block must be brought from main memory to cache for read and write operation. 40% reference is for write operation. Avg
access time if write through is used.

cache-memory


Selected Answer

Cache access time = 10 ns


1 block mm time = 50*16 = 800 ns (as from main memory, entire cache block is retrieved)

Then use this formula


TavgR = hr*tc+(1-hr)*(tm + tc) = 0.8 * 10 + 0.2 * (800 + 10) = 170 ns (Hierarchical access is default read)

Whenever cache is missed, data (entire cache block) must come from main memory for write as per question. So, for hit,
we have to assume hierarchical access.
TavgW = hw*(tm + tc ) + (1-hw) (tc + 800)

= 0.9 * 60 + 0.1 * 810 = 135 ns

Tavg= fr*TavgR+ fw*TavgW = 0.6 * 170 + 0.4 * 135 = 156 ns.

 1 votes -- aditya upadhyay ( 113 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 362 of 2244

5.32 Cache Memory: consider the following top gateoverflow.in/11135

Consider a single-level cache with an access time of 2.5 ns, a line size of 64 bytes, and a hit ratio of H 0.95. Main memory
uses a block transfer capability that has a first word (4 bytes) access time of 50 ns and an access time of 5 ns for each word
thereafter.

a. What is the access time when there is a cache miss? Assume that the cache waits until the line has been fetched from
main memory and then re-executes for a hit.

b. Suppose that increasing the line size to 128 bytes increases the H to 0.97. Does this reduce the average memory access
time?

cache-memory


Selected Answer

a. Hierarchical access is mentioned in question.

(
Tavg = timecache + 1 − hitcache )[timememory ]
= 2.5 + (1 − .95)[65]

as line size is 64 bytes and first word is of four bytes having acces time 50 and remaining three have access time 15(i.e.,
65)

= 2.5 + 3.25

= 5.75

(b)

now line size increases ie 128 bytes as now there are 32 words .

first word acces is 50 than after that 5 for each 31 words

= 50 + 155

= 205(block access time)

now hit ratio is .97

Tavg = 2.5 + (1 − .97)[205]

= 2.5 + 6.15

= 8.65

 1 votes -- gatecse ( 9515 points)

5.33 Cache Memory: COA top gateoverflow.in/11137

A computer has a cache, main memory, and a disk used for virtual memory. If a referenced word is in the cache, 20 ns are
required to access it. If it is in main memory but not in the cache, 60 ns are needed to load it into the cache, and then the
reference is started again. If the word is not in main memory, 12 ms are required to fetch the word from disk, followed by
60 ns to copy it to the cache, and then the reference is started again.The cache hit ratio is 0.9 and the main memory hit ratio
is 0.6.What is the average time in nanoseconds required to access a referenced word on this system

ans

tavg=Hit_cache*time_cache+(1-Hitcache)(hit_main)[60+20]+(1-hit_cache)(1-hit_mainmmry)[60+12+20]

cache-memory

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 363 of 2244


Selected Answer

Question shows a hierarchical memory system

(
Tavg = hitcache × timecache + 1 − hitcache )(hitmemory )[timecache + timememory ] + (1 − hitcache )(1 − hitmemory )[timecache + timememory + timedisk ]
= 0.9 × 20 + 0.1 × 0.6 × 80 + 0.1 × .4 × 12000080

We can also use the formula

(
Tavg = timecache + 1 − hitcache )[timememory ] + (1 − hitcache )(1 − hitmemory )[timedisk ]
= 20 + 0.1 × 60 + 0.1 × 0.4 × 12000000

 4 votes -- Arjun Suresh ( 124125 points)

5.34 Cache Memory: Given the following specifications for an external cache
memory top gateoverflow.in/11117

Given the following specifications for an external cache memory: four-way set associative; line size of two 16-bit words; able
to accommodate a total of 4K 32-bit words from main memory; used with a 16-bit processor that issues 24-bit addresses.
Design the cache structure with all pertinent information and show how it interprets the processor’s addresses.

cache-memory


Selected Answer

No. of entries in cache = 4K

Line size = 2 *16 = 32 bits = 1 word, for byte addressing (which is default) we need 2 offset bits to address 4 bytes.

So, number of cache lines = 4K

Number of lines in a set = 4 (4 way set associative)

So, number of sets = 4K / 4 = 1024.

So, we need lg 1024 = 10 set/index bits and 2 offset bits. Remaining 12 (24-10-2) bits must be tag bits.

 1 votes -- Arjun Suresh ( 124125 points)

5.35 Cache Memory: explain top gateoverflow.in/12045

Consider the given two statements S1 and S2

S1: If compulsory misses are most common then the designers should consider to increase the cache line size to take better
advantage of locality.

S2: If capacity misses are most common then the designer should increase the cache associativity, in order to provide more
flexibility when collision occurs.

Which of the following is correct?

A. S1 is true, S2 is false
B. S2 is true, S1 is false
C. Both are false
D. Both are true

cache-memory

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 364 of 2244


Selected Answer

A) is the answer

1st one

Compulsory misses means first time access to a cache block. By increasing the block size, this can be reduced as this
location might be fetched as part of a previous cache miss.

http://gateoverflow.in/11950/compulsory-problem-designer-increase-advantage-locality#c12032

2nd one is false. By increasing associativity we can only reduce "conflict" misses.

 1 votes -- Pranay Datta ( 6113 points)

5.36 Cache Memory: Set Associative Mapping top gateoverflow.in/38264

A byte addressable system with 16-bit address lines with a 2-way set associative, write back cache with perfect LRU
replacement. Assume 1 valid bit and 1 dirty bit maintains for each block. The tag store requires a total of 4352 bits of
storage. What is the block size of the cache? [in bytes]

cache-memory co&architecture

5.37 Cache Memory: 16 KB, 4-way set-associative cache, 32-bit address,


byte addressable memory, 32-byte cache blocks/lines top gateoverflow.in/11046

16 KB, 4-way set-associative cache, 32-bit address, byte addressable memory, 32-byte cache blocks/lines

1. How many tag bits?


2. Where would you find the word at address 0x200356A4?

co&architecture cache-memory


Selected Answer

Cache size = 16kB = 14 bit

Block size = 32B = 5 bit

No of sets = 4 = 2 bit

No of cache lines = 14 -(5+2) = 7 bit

No of tag bit = 32 - (#set bit) - (#block bit)

. = 32 - 7 - 5 = 20 bit

0x200356A4 = (<0010 0000 0000 0011 0101> <0110 101> <0 0100>)

=(<tag no><set no><block no>)

Set no = 0110101 = 53th set

Block no = 00100 = 4th block

 2 votes -- Digvijay Pandey ( 26245 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 365 of 2244

5.38 Cache Memory: cache memory top gateoverflow.in/11240

A computer system contains a main memory of 32K 16-bit words. It also has a 4Kword cache divided into four-line sets with
64 words per line. Assume that the cache is initially empty. The processor fetches words from locations 0, 1, 2, . . ., 4351 in
that order. It then repeats this fetch sequence nine more times.The cache is 10 times faster than main memory. Estimate
the improvement resulting from the use of the cache. Assume an LRU policy for block replacement.

cache-memory


Selected Answer

Memory access time without cache = 4352 × 10x = 43520x, where x is the time for one access.

In cache we have 64 words per line and 4 lines per set (4 way associativity) and total size is 4096 words. So,

4096
64×4
number of sets = = 16

So after accessing 16 × 64 = 1024 words (0-1023) all the sets will be filled with one entry each. But with 4-way associativity
each set has space for 3 more. So filling can go like this for 4096 words (0-4095). After this next entry (cache line from
4096-4159) will go to first set and will replace the cache line 0-63 due to LRU policy. Like wise total no. of cache
replacements = (4351-4096)/64 = 256/64 = 4.

Now for the second iteration the first four cache line accesses will be cache misses as they got replaced. But these cache
lines will be replacing the oldest used one in the set. For example cache line 0-63 will be replacing 1024-1095. Now the
cache line 1024-1095 will in turn be replacing 2048-2111 and likewise all new cache line accesses will be cache misses
(LRU works badly). This will trigger 16 cache line misses - 4 each from the first four sets. For 5th set to 16th set, there
won't be any cache miss. Now, for the cache lines 4096-4351, there will be 4 more cache misses which are again
coming from the first 4 sets. So, totally 16+4 = 20 cache misses. (Shown in figure at end)

Thus,

Access time with cache = No. of cache hits × hit time


+ no. of cache misses × memory access time
(Assuming simultaneous access possible to memory)
= (4284 + 9 × 4332) × 0.1x + (68 + 9 × 20)x
= 4574.9x

So,

43520x

Performance improvement = 4574.9x = 9.45 times

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 366 of 2244

 3 votes -- Arjun Suresh ( 124125 points)

5.39 Cache Memory: cache size top gateoverflow.in/12210

cache-memory


Selected Answer

Cache size = No. of sets * No. of blocks in a set * block size

= 128 * 2 * 16 = 4K words

= 4K * (32/8) bytes (as word size is 32 bits)

= 16K.

Now, cache must also need space for tag entries. So, we need to find the number of tag bits for each entry.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 367 of 2244

Memory is word addressable and a cache block size is 16 words meaning 4 offset bits.

128 sets mean 7 set bits are required.

We are given physical address size and not virtual address size. So, we can assume a physically indexed, physically tagged
cache. So, out of 21 physical address bits we used 4 + 7 = 11 bits for offset and tag. Remaining 10 bits are tag ones.
Total tag size

= 10 * No. of cache blocks bits

= 10 * 128 * 2 bits

= 2560 bits

= 320 bytes.

So, option B.

 0 votes -- Arjun Suresh ( 124125 points)

5.40 Cache Memory: Consider an L1 cache with an access time of 1 ns and a


hit ratio of H 0.95. top gateoverflow.in/11132

Consider an L1 cache with an access time of 1 ns and a hit ratio of H 0.95. Suppose that we can change the cache design
(size of cache, cache organization) such that we increase H to 0.97, but increase access time to 1.5 ns. What conditions
must be met for this change to result in improved performance?

plzz add more in this answer and correct the answer if wrong......

when we increase the hit ratio than the acces time is increased as given in the question..

i think we should use direct mapped cache...and we should increase the size of the cache as.. in direct cache we need
address...to identify the particular word.....so it easy to get word in less time due to avalibility of address...

but if we use associative cache than there is no need of address and so we have to search throught the cache which wiill
increase the cache accees time ..and performance will decreases.....

cache-memory


Selected Answer

The question says that increasing the cache size results in better hit rate and more access time. So, we need not think
about how this is achieved (direct or associative) but just give the equation for access time. Assuming simultaneous
access: (by default take hierarchical)

Tavg = 0.95 × 1 + 0.05 × Tmem

Tnew
avg = 0.97 × 1.5 + 0.03 × Tmem

0.505

Tnew
avg < Tavg  0.97 × 1.5 + 0.03 × Tmem < 0.95 + 0.05 × TmemTmem >
0.02
= 25.25ns

For hierarchical access:

Tavg = 1 + 0.05 × Tmem

Tnew
avg = 1.5 + 0.03 × Tmem

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 368 of 2244

0.5

Tnew
avg < Tavg  1.5 + 0.03 × Tmem < 1 + 0.05 × TmemTmem >
0.02
= 25ns

 2 votes -- Arjun Suresh ( 124125 points)

5.41 Cache Memory: What is the answer ? top gateoverflow.in/30326

Suppose that a cache is 20 times faster than main memory and cache memory can be used 80% of the time. The speed-up
factor that can be achieved by using the cache is _________.

co&architecture cache-memory


Selected Answer

let tm be access time of memory

so tc=tm/20

time without cache =tm

with cache =0.8*tm /20 +0.2*tm

=4.8/20 tm

speed up= time without cache/time with cache

=tm/(4.8tm/20)

=20/4.8

=4.16

 2 votes -- Pooja ( 22773 points)

5.42 Cache Memory: Q6 ch-5 me workbook top gateoverflow.in/20905

Suppose that a direct mapping cache has 2 9 lines, with 2 4 bytes per cache line. If cache items of a byte addressable
memory space of 229 bytes. How many bits of space will be required for storing tags( do not include bits for validity or other
tags; only consider the cost of tags themselves) [in bits].

A. 2 8 b. 2 13 C. 2 11

D. none of these

co&architecture cache-memory


Selected Answer

A tag is used to identify which of the memory block is currently present in a cache block. So, here you have to fin the no.
of distinct memory block (a block is the size of cache line- 16 bytes in this question) which can be mapped to a given
cache line. Say, this is x- now we need lgx tag bits as we store tag in binary. Now, this tag is needed for each cache line-
so multiply by the total no. of cache lines to get the total tag storage needed in bits.

Don't look below until you get an answer.

Calculations will be as follows:

2 29
4
No. of memory blocks = 2 = 225.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 369 of 2244

No. of memory blocks which can be mapped to a given cache line = Total no. of blocks/No. of cache lines (As direct
mapping is used)

2 25
9
= 2 = 216.

So, we need 16 tag bits for each cache line.

So, total tag storage required = 29 × 16 = 213bits.

 2 votes -- Arjun Suresh ( 124125 points)

5.43 Cache Memory: find number of replacements and cache utilization top
gateoverflow.in/17204

Consider the execution of the following program segment on a 4ⅹ10 array.


The two-dimensional array A is stored in the main memory in a column major order. Assume that there are eight blocks in the cache, each is just
one word, and that the LRU is used for replacement. Show a trace of the contents of the cache memory blocks for the different values of indices j and k
assuming three different cache memory organizations, that is, direct, associative, and set-associative mapping. Provide your observations on the results obtained

SUM: 0
For j: 0 to 9 do
SUM: SUM + A(0,j)
End for
AVE: SUM/10
For k: 0 to 9 do
A(0,k): A(0, k)/AVE
End for

co&architecture cache-memory

5.44 Cache Memory: CO: Main Memory Hit Ratio top gateoverflow.in/34108

Consider an array of 4 elements and each element occupies 4-words. A 16 word cache is used and divided into a
block of 8 words. If the following code is executed what is the hit ratio?

for (i = 0; i < 2; i++)

for (j = 0; j < 2; j++)

x = A[i, j] + A[j, i]

(a) 0.5 (b) 0.66 (c) 0.75 (d) 0.87

co&architecture cache-memory


Selected Answer

cache size=16 words

each block size=8 words;

number of blocks=2;

now given that each element occupies 4 words that means two elements of array can accomodate in 1 block.

ar[0][0],ar[0][1] and ar[1][0] ar[1][1] in block 1 and block 2nd respectively.

coming to program

i=0;j=0

x=ar[0][0]+ar[0][0]//1 miss 1 hit

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 370 of 2244

i=0 j=1

x=ar[0][1]+ar[1][0]//hit for ar[0][1] as it will be loaded when ar[0][0] was read and miss for ar[1][0]

i=1,j=0

x=ar[1][0]+ar[0][1]//hit and hit

i=1 j=1

x=ar[1][1]+ar[1][1];//hit and hit

total hit=6

so hit ratio=6/8=0.75

 3 votes -- sourav anand ( 1585 points)

5.45 Cache Memory: Mapping Strategies top gateoverflow.in/9067

A 2-way set associative cache consists of four sets. Main memory contains 2K blocks of eight words each.

a) Show the main memory address format that allows us to map addresses from main memory to cache. Be sure to include
the fields as well as their sizes.

b) Compute the hit ratio for a program that loops 3 times from locations 8 to 51 in main memory. You may leave the hit ratio
in terms of a fraction.

Hello Sir, I am write now solving sums from "The essentials of Computer architecture " I got this sum . and there is no
solution provided i just wanna ask you to check this

Solution :

No of lines in a set=2
No of set in Cache = 4
Block size=8 words

So, Size of each cache= No of set* No of line in set * Block Size= 8*4*2=64 Words

Size of MM= no of block in main memory * size of each block=(2^11)*(2^3)= 2^14 words

Bits used to represent Physical address = 14 bits

Field of Cache address will be


1. word offset = 3 bits
2. index bits = 2 bits
3.Therefore no of bits used to represent Tag field =(14-(3+2)) = 9 bits.

Now the solution for part b

Since the size of both memory is expressed in words

We have a cache size/ capacity = 64 words and Size of Main Memory as( 2 ^ 14 words )

And since the loop says it starts from location 8 to 51 then . No of elements that will be encountered = (51-8+1)= 44 which
is equivalent for running i from 0 to 43 times (for 44 words )

Since they have asked for 3 iteration,

we know that size of cache= 64 words

And the required data that we have is 44 words

Out of these 44 words there would be 22 words which would be mapped to set 0 and 22 words which would be mapped to
Set 1

Now in each Set , we have 2 lines and Each block has a size of 8 words ,

So in 16 words we have would have 2 miss

And so in reamining in (22-16) words we would have 6 words . to accomodate these 6 words again 1 block need to replaced

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 371 of 2244

So total miss in 1 set in first iteration is 3 miss

Similarly total miss in second set in first iteration = 3 miss

Total no of miss in first iteration = 6 miss

While in second iteration there would be again need of replacing 1 block to (first 8 words ) rest would be hit till and then
again 1 miss for (last 6 words ) this is just for 1 set

so total no of miss in second iteration=4 (both sets )

And similarly Total no of miss in third set = 4

And miss ratio would be equal to = (6+4+4)/(44+44+44)= 14/132.

Is this correct ? Please help . i am sorry to write such a big content . But this question need and to show my way of
approaching towards sums :)

co&architecture cache-memory


Selected Answer

Your first part is correct. But b part is not.

Actually in first part we got 9 tag bits, 2 index bits and 3 offset bits. So, these bits are like these:
tag bits | index bits | offset bits

That is, the lower bits are offset bits followed by index bits and then tag bits.

Our memory access starts from address 8. With 3 offset bits, this cache line reference will be from address 8 to address
15 (1000 - 1111 in binary). Say this cache line goes to cache set A during the memory access for address 8. Next 7
accesses are cache hits. When address 16 is accessed, its cache line goes to set B and not set A because after offset
comes the index/set bits so the set changes (this is made so that spacial locality won't reduce cache hits). Now, all
accesses till 23 are hits and 24 will be a miss and cache line for 24 goes to set C. Similarly, cache line for 32 goes to set
D. Now, for cache line of 40, it should go to set A. But it won't replace the cache line at set A, as each set has space for 2
cache lines (2-way associative). Similarly cache line of address 48 goes to set B. And that is the last cache miss in
iteration 1. So, we have 6 cache misses and 38 cache misses in iteration 1. For iterations 2 and 3, all are cache hits. So,

hit ratio = (38 + 44 + 44) / (3 * 44)

= 126/132

 3 votes -- Arjun Suresh ( 124125 points)

5.46 Cache Memory: cache block size top gateoverflow.in/19384

Consider a 64 KB cache with 256 sets. Addresses are 32 bits. Tags are 19 bits.

What is associativity (blocks per set) of this cache?

A. 4
B. 16
C. 2
D. 8

cache-memory


Selected Answer

I think its 8.

address size 32 and tag is 19 bit so

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 372 of 2244

32 - 19 =13 bit (set bit + offset)

and there are 256 sets so set bit = 8

word off = 13-8=5 bit

in set associative: size of cache = no. of sets * associativity * offset

216 =28 * associativity * 2 5= > associativity =2 3

 2 votes -- Pranay Datta ( 6113 points)

5.47 Cache Memory: Cache Coherence top gateoverflow.in/9070

Given a virtual memory system with a TLB, a cache, and a page table, assume the following:

•A TLB hit requires 5ns.

•A cache hit requires 12ns.

•A memory reference requires 25ns. •

A disk reference requires 200ms (this includes updating the page table, cache, and TLB). •

The TLB hit ratio is 90%. • The cache hit rate is 98%. • The page fault rate is .001%. •

On a TLB or cache miss, the time required for access includes a TLB and/or cache update, but the access is not restarted. •
On a page fault, the page is fetched from disk, all updates are performed, but the access is restarted. • All references are
sequential (no overlap, nothing done in parallel).

For each of the following, indicate whether or not it is possible. If it is possible, speciify the time required for accessing the
requested data. a) TLB hit, cache hit b) TLB miss, page table hit, cache hit c) TLB miss, page table hit, cache miss d) TLB
miss, page table miss, cache hit e) TLB miss, page table miss Write down the equation to calculate the effective access time.

please help and what we do mean by access is not restarted in above .

cache-memory

It is not directly mentioned, but it is clear that we are talking about a physically indexed cache (cache after address
translation)

a. TLB hit, cache hit:

5 + 12 = 17 ns

b. TLB miss, page table hit, cache hit

5 + 25 + 12 = 42 ns (when TLB misses, page table which is in main memory is accessed)

c) TLB miss, page table hit, cache miss

5 + 25 + 12 + 25 = 67 ns

d) TLB miss, page table miss, cache hit

When page table misses, cache hit cannot happen. Because when a page fault happens, we shouldn't check the cache as
it won't be having the requested data. At this point page fault service routine must be instantiated.

e) TLB miss, page table miss

5 + 25 + 200 + 5 + 12 = 247 ns

It is mentioned in question that access is restarted on a page fault. So, once page is fetched, there will be another page
request which will hit in TLB and also in cache.

( ) ( ( )) ( (
0.98 × 12 0.02(12 + 25) 0.98 × 12 0.02(12 + 25) 5 + 12
    
EAT = 0.9 5 + cache hit + cache miss (TLB hit) + 0.1 5 + 0.999 25 + cache hit + cache miss (TLB miss, page hit) + 0.1 5 + 0.001 25 + 200 + access restarted

 1 votes -- Arjun Suresh ( 124125 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 373 of 2244

5.48 Cache Memory: madeeasy test top gateoverflow.in/27364

A byte addressable system with 16-bit address lines with a 2-way set associative, write back cache with perfect LRU
replacement. Assume 1 valid bit and 1 dirt bit maintains for each block. The tag store requires a total of 4352 bits of storage.
what is the block size of the cache?[in bytes].

ans________

co&architecture cache-memory

Let the block size be 2x.

2 16

No. of memory blocks that can go to a cache set = x×#sets and we need to identify each of them with tag bits. So, no. of
2 16
#sets×2 x
tag bits, t = lg = 16 − x − lg(#sets).

Now, tag store size = No. of sets * (2 * t + 2 * dirty bits + 2 * valid bits + 1 * LRU bit).

(Each set is having 2 blocks and to identify the least recent use between 2 we need just 1 LRU bit)

4352 = 216−x−t(2t + 5)  17 × 28 = 216−x−t(2t + 5)  t = 6, x = 2.

So, block size = 2 × 2 = 4 bytes.

 1 votes -- Arjun Suresh ( 124125 points)

5.49 Cache Memory: ISRO-2013-16 top gateoverflow.in/43812

How much speed do we gain by using the cache, when cache is used 80% of the time? Assume cache is faster than main
memory.

A. 5.27
B. 2.00
C. 4.16
D. 6.09

isro2013 co&architecture cache-memory


Selected Answer

T cache << Tmemory

We can assume memory is accessed only on a cache miss (hierarchical memory access by default) and hence on cache
miss we first access cache and then only main memory (both times are added here)

MemoryAccessTime without Cache

Speed Gain = Memory Access Time with Cache

1
Tmemory T cache

T cache +0.20.Tmemory T memory


+0.20
= =
T cache
Tmemory
= x, 0 < x ≤ 0.1 ( Since cache (say last level cache) is faster than memory by at least 10 times)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 374 of 2244

Speed Gain = 0.20 +x  3.33 ≤ Speed Gain < 5

I will go through 4.16.

 2 votes -- Digvijay Pandey ( 26245 points)

5.50 Cache Memory: Total size of cache top gateoverflow.in/12746

Consider a 8 million word main memory and 256 block cache.Both partitioned into 64 words block.What is the size of
additional memory for tags? Size of the cache? consider direct mapping is used and word size 1 byte.

cache-memory co&architecture


Selected Answer

Main Memory Size = 2 23 words


so, Physical Address is 23 bits long

# cache lines = 256 = 2 8


so, to access lines we need 8 bits

block size = cache line size = 64 words = 2 6 words


so, to access a word in a block we need 6 bits

TAG = 23 - 8 - 6 = 9

TAG(9 bits) | LINE(8 bits) | BLOCK_OFFSET(6 bits)

Additional memory for TAGs = #CacheLines × Size of one TAG = 256 × 9 bits = 288 Bytes

Cache Memory Size = #CacheLines × Size of Each Line = 256 × 64 words = 2 14 words = 2 14 × 1 Byte = 214 Bytes

 3 votes -- Amar Vashishth ( 17865 points)

5.51 Car: Control address reg. And control data reg. top gateoverflow.in/34246

Using horizontal programming

If no. Of mircrooperations r 1200 and processor h/w supports 64 Cs and 16 flags.8 different branch condition are used to
control the branch logic. Then what is the size of CAR and CDR when one address address field in microinstruction to control
the branch logic??

What do CAR and CDR indicate in microinstructions ??

co&architecture car cdr horizontal_programming

Adrdress register = 11 bit

while data = 24 bit/

just compare the question like the instruction and address.

what should be the length of address register = number of bits to uniquely identify each row.

what is the length of instruction or data register. = the size of one word. if it. similarly

here the data register will be of the length of microprogramed control unit control word.

= log ( branch condition) + log ( flags ) + control signal + log ( control world memory)

= 3+4+64+11= 82

while address register will be 11 bit . as t need to only store address which should be able to identify uniquely one of the
1200 entries .

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 375 of 2244

 0 votes -- Ravi Singh ( 7303 points)

5.52 Cisc: Q-20 (control unit design) madeEasy workBook 2015 top gateoverflow.in/18875

Show below are sements of a code run on a CISC and RISC archy separately

CISC RISC

MOV AX,05 MOV AX,00

MOV BX,06 MOV BX,05

MUL AX,BX MOV CX,06

start:ADD AX,BX loop

loop start; loop till CX=0

If the MUL instruction takes 40 clock cycles,Which of the following statement is true?

(a) The CISC code will run faster by a factor of 1.8

(b) The RISC code will run faster by a factor of 2.8

(c) The CISC code runs slower by a factor of 0.025

(d) The RISC code will run faster by a factor of 40

cisc risc clockcycle co&architecture

CISC will take 42 cycles

RISC will take 15 cycles( 3 for move statements and 12 for loop)

so speed up=42/15

=2.8

So RISC code will run faster by factor of 2.8

 0 votes -- Pooja ( 22773 points)

5.53 Clock Time: Question on finding number of cycles to execute


instructions top gateoverflow.in/38552

Q).We have two dsigns D1 and D2 for a synchronous pipeline processor, D1 has 5 pipeline stages with execution times of
3nsec 2nsec ,4nsec ,2nsec and 3nsec , while the design D2 has a 8 pipeline stages each with 2nsec execution time. How much time
can be saved using design D2 over design D1 for executing 100 instructions ? 196 nsec (integer value only) .The correct
answer is 202

Please check how the answer would be 202.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 376 of 2244

co&architecture clock-time


Selected Answer

D1- tpd1= 4ns, no. of stages is 5, k=5

D2- tpd2= 2ns, no. of stages is 8, k=8

No. of instructions is ,n=100

Td1= (k+n-1)*tpd1= (5+100-1)*5 =104*4=416

Td2 = (k+n-1)*tpd2= (8+100-1)*2= 107*2=214

Td1-Td2= 416-214=202ns

 2 votes -- UK ( 1341 points)

5.54 Clockcycle: Whether to count MegaByte as 2^20 or 10^6 top gateoverflow.in/28966

The first word of the memory block (each block contains 4 words of 4 bytes each) takes 5 clock cycles and remaining 3
words are transferred in consecutive cycles. Given the clock rate is 100 MHz. The data rate (in MBps) of memory for
transferring one block of memory is ______.

------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------

Here my issue is that ->

I got answer as 200 * 10^6 Bytes.

Then I converted that no to Mega Bytes.

It becomes 190.73 MB (If you use 1 MB = 1024 KB = 1024*1024 B)

Answer is given as 200 MB. (Using 10 6 Bytes = 1 MB )

Just wondering what is best way to answer this kind of questions.As far as I know , those 10 6 powers are only used in case
of Network Data Bandwidth not in Memory Transfer speed topic of CO ! If you think otherwise , that this question should
have been answered as 200 MB please give reference. If you think otherwise it should be 190.73 MB, Please give me
reference for that ! (So I can be happy :D )

From Made Easy FLT 6-Practice Test 14

Q 61

computer-organization clockcycle

5.55 Clockcycle: Drd0 2008 q-11 ch-3 i/o interface top gateoverflow.in/21304

In an n- CPU shared bus system, if z is the probability that any CPU requests the bus in a given cycle, the probability that
only one CPU uses the bus is given by-

A. Nz(1-z) n-1

B. Z(1-z) n-1

C. N(1-z) n

D. (N-1)z(1-z) n

co&architecture clockcycle

OPTION A.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 377 of 2244

There are N - CPUs , and exactly one of them uses the bus.

Using binomial distribution, nCx * px * (1- p) n-x

{ Here x is number of success , p is probability of success in one trial,

n is total number of trials }

probability that only one CPU uses the bus = NC1 * z1 * (1-z) N-1 = A(Ans)


{Here z is probability of CPU using bus & we want exactly one Cpu to use the bus

at a time so, NC1 }..

 0 votes -- Himanshu Agarwal ( 8861 points)

5.56 Clockcycle: Q 37 me ch-5 top gateoverflow.in/21182

A hierarical cache memory subsystem has a cache access time of 50ns and the main storage access time is of 500ns . with the read hit ratio of 0.9,
what is the average access time of the system considering only memory read cycle in the write through scheme?

a. 10 ns b. 100 ns c. 50ns d. 500ns

co&architecture cache-memory clockcycle

5.57 Clockcycle: Made Easy CA pipeline q2 top gateoverflow.in/20293

A 5-stage pipeline is used to overlap all the instructions except the branch instructions. The target of the branch can't be
fetched till the current instruction is completed. What is the throughout of the system if 20% of instructions are branch
instructions ignore the overhead of buffer register. Each stage is having same amount of delay. The pipeline clock is 10ns
Branch penality if of 4 cycles.

A.55 MIPS

B.45 MIPS

C. 65 MIPS

D. None of these.

(explain the solution as well)

co&architecture pipeline clockcycle

5.58 Coa: How many one address instructions are required to evaluate?
ISRO_2015_29 top gateoverflow.in/37956

In X= (M + N x O)/(P x Q), how many one address instructions are required to evaluate it?

(a) 4 (b) 6 (c) 8 (d) 10

memory-interfacing coa isro2015 machine-instructions


Selected Answer

Accumulator CPU is example of One Address Instruction:

In Acc. CPU first alu operand is always required in the accumulator but second alu operand can be in the register or memory because of the
the availability of the one address along with the opcode.

Load and Store is One address Instruction

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 378 of 2244

X= (M + N x O)/(P x Q)

I1: Load P : ACC<--M[P]


//Load the P value from memory to ACCUMULATOR

I2: Mul Q: ACC<--ACC*M[Q] //Second alu operand is in memory and destination is Register

I3: Store T: M[T]<--ACC


//Store the Value in memory

I4: Load N : ACC<--M[N]

I5: Mul O : ACC<--ACC*M[O]

I6: Add M: ACC<--ACC+M[M]

I7: Div T: ACC<--ACC/M[T]

I8: Store X: M[X]<--ACC


//Finally store in value in memory

TOTAL 8 1 ADDRESS INSTRUCTION REQUIRED.

 1 votes -- Ankesh Gautam ( 665 points)

5.59 Computer Organization: Pipeline top gateoverflow.in/39159

A memory system has got the latency of 35 ns with 2 byte per operation. The system is pipelined so that 6 operations can
overlap during execution. The bandwidth of the system is

(A) 3.42 × 108 bytes/sec


(B) 2.68 × 108 bytes/sec
(C) 1.96 × 108 bytes/sec
(D) 4.12 × 10 8 bytes/sec

pipeline co&architecture computer-organization

(A)

1st process comes after 6 operations. Each take 2 byte.

Total data for 1 instrcution = 6*2 = 12 byte / instruction.

For one instruction time taken 35 ns . In 35 ns --- > 12 byte ... Bandwidth = 12 * 10^9 / 35 byte/sec = 3.42 * 10^8
byte/sec

 2 votes -- nitish ( 349 points)

5.60 Computer Organization: CO FLT Test Made Easy top gateoverflow.in/31552

Q.58

Consider 5 stage pipeline which allow all instructions except branch instruction. Program contain 30% conditional instructions
out of which 75% are branch instruction. Processor stop fetching the following instruction after the branch instruction untill
target address is available. Target address is available at the end of the pipeline stage.
All the stages are perfectly balanced with 20 GHz clock time. The processor is running with rate of ____________ (in MIPS).

Given answer -> 92

made-easy computer-organization

5.61 Computer Organization: CO Made Easy FLT Test top gateoverflow.in/31556

Q.42

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 379 of 2244

Three 4 bit shift registers are connected in cascade as shown in figure below. Each register is applied with

A 4 bit data 1011 is applied to the shift register 1. What is the minimum number of clock pulses required to get same input
data at output are with same clock?

11
12
13
14

Please answer !

made-easy computer-organization

SISO SIPO PISO


T0 0000 0000 0000
T1 1000 0000 0000
T2 1100 0000 0000
T3 0110 0000 0000
T4 1011 0000 0000
T5 0101 1000 0000
T6 0010 1100 1000
T7 0001 0110 1100
T8 0000 1011 0110
T9 0000 0101 1011
T10 0000 0010 0101
T11 0000 0001 0010
T12 0000 0000 0001
T13 0000 0000 0000

I have used the above approach according to this after 12 clock pulses, 1011 will be at output.

 0 votes -- UK ( 1341 points)

5.62 Computer Organization: co top gateoverflow.in/34484

my doubt is while finding no of blocks we need to have cache size and here cache is 4K with each word size is 16 bits so we
should take cache size as 4K or 4k*16 bits.??

computer-organization

5.63 Computer Organization: made easy top gateoverflow.in/39162

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 380 of 2244

arjun sir pls help.

test-series made-easy computer-organization

5.64 Computer Organization: Total latch latency top gateoverflow.in/30730

Suppose there is unpipelined processor with a cycle time 30 ns which is evenly divided into 5 pipeline stages. The total latch
latency of the pipeline will be _______________ ns.

computer-organization co&architecture

5.65 Computer Organization: What is the time required to execute program


without branch prediction ? top gateoverflow.in/30670

Program consists of 16 instructions (I 1, I 2, I 3, ...., I 16 ). In which I 6 is a unconditional branch instruction transfer the controls
of I12 . In the pipeline, branch target address will be available at the end of execute state. Each instruction spends the same
amount of time in all the pipeline stages. The cycle time of the pipeline is 10 nsec.

What is the time (in nsec) required to execute the above program without using branch prediction?

computer-organization

Let there be four stages


S1 = Instruction fetch
S2 = Instruction decode
S3 = Execute
S4 = Write back

Using (K+n-1)tp
1. I1 to I6 execute first
2. I7 & I8 will also be executed at this point I6 will reach to execute stage so it sends the control to I12
3.I12 to 116 will execute

so total 13 instruction
(13-1+4)10 = 160ns

 3 votes -- Umang Raman ( 10379 points)

5.66 Computer Organization: Speedup factor for pipeline top gateoverflow.in/35937

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 381 of 2244

The explaination is given assuming pipelined system having 1 cycle for each stage. My doubt is why to assume that? Is it
taken by default?? Explaination plz..

pipeline computer-organization ace-test-series

yes for ideal piepline CPI is considered as 1

 0 votes -- Rishabh Sharma ( 25 points)

5.67 Computer Organization: Problem on enhancement of CPU top gateoverflow.in/30423

In an enhancement of a design of a CPU, the speed of a floating point unit has been increased by 30% and the speed of a fixed
point unit has been increased by 20%. The overall speedup achieved if the ratio of the number of fixed point operation to floating
point operations is 4 : 6 and the floating point operation used to take twice the time taken by fixed point operation in the
original design (upto 2 decimal places) is_________.

computer-organization

5.68 Computer Organization: CO: SpeedUp in Pipeline top gateoverflow.in/34380

A non-pipeline processor has a clock rate 3 GHz and an average CPI of 4. An upgrade to the processor introduce 5 stage pipeline. How ever due to internal delay the clock
rate of the new processor has to be reduces to 2 GHz. What is the speed-up of pipeline over non-pipeline?

a. 3.1

b. 3.3
c. 3.5
d. 3.8

I got 2.66 But the Given is 3.3

computer-organization pipeline


Selected Answer

let us assume number of instructions=100

execution time without pipeline=number of instructions*no.of clocks per instruction*delay

=100*4*1/3*10^9=133.33 ns

execution time with pipeline=1(1st instruction)*number of stages*delay+(100-1)*1*delay

=1*5*1/2*10^9+99*1/2*10^9=52 ns

speed up=T without pipeline/T with pipeline=

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 382 of 2244

=133.33/52=2.56

hence the given answer is wrong

 0 votes -- sourav anand ( 1585 points)

5.69 Computer Organization: CO: Cache set Associative top gateoverflow.in/34204

A two way set associative cache has lines of 16 byte and a total cache size of 8 K bytes. The 256 M byte main
memory is byte addressable. Which one of the following main memory block is mapped on to the set ‘0’ of the
cache memory?

A) (CFED09B)16

B) (FCED90C)16

C) (CFED00B)16

D) (FECD10C)16

cache-memory computer-organization


Selected Answer

look, main memory 2^28

so 28 bit

now cache size 2^13

cache line size 2^4

no of block = 2^9

2 way set associative

so no of set 2^8.

now in 28 bit,

tag(16) | set(8) |
word offset (4)

look at the option 7 digit hex given

so total 28 bits.

last 4 bit for word offset.

for determinning set we have to look on the two digits before the last digit.

for set 0

as we can see set has 8 bits so put 00000000 which 00 in hex.

and only (CFED00B)16 this matched .

option C.

 4 votes -- Sayantan Ganguly ( 5061 points)

5.70 Computer Organization: Pipeline Speedup Factor top gateoverflow.in/36945

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 383 of 2244

Consider a pipeline ‘x’ consist of 5 stages named as IF, ID, OF, EX and WB with the respective stage delays of 2 ns, 5 ns, 6
ns, 8 ns and 1 ns. The alternative pipeline ‘y’ contain the same number of stages but EX stage is divided into 4 sub stages,
(EX1, EX2, EX3 and EX4) with equal delay i.e. (8 ns/4) and ID stage is divided into 2 substages (ID1 and ID2) with equal
delays of (5 ns/2). In the pipeline x and y memory reference instructions are not overlapped so the penalty of memory
reference instructions in the pipeline ‘x’ is 4 cycles and in the pipeline ‘ y’ is 8 cycles. If the program contain 30% of the
instructions which are memory based instructions, the speedup ratio of x to speedup ratio of y is _______.

pipeline computer-organization co&architecture

Since we know that speed up is given by

S= pipeline depth/1+(number of stalls per instruction)

and. no. of stalls per instruction = frequency* branch penality

so for pipeline(x) speed up = 5/1+(0.3*4)

=> 2.27

pipeline(y) speed up= 9/1+(0.3*8)

=> 2.64

ratio of speedup Sx/Sy= 2.27/2.64 => 0.859

 1 votes -- amit ambastha ( 37 points)

5.71 Computer Organization: ME_Test_Series - CO top gateoverflow.in/36648

Consider the addition of the two numbers 10001110 and 10000000 in an 8-bit ALU. Which of the following best summarizes
the result and the status of the Z(zero), S(sign), C(carry) and O(overflow) flags? Assume that the numbers are represented
in 2's Complement format and that S=1 if the result is negative.

a) Sum = 100001110, Z = 0, C = 1, O = 0, S = 1

b) Sum = 00001110, Z = 0, C = 0, O = 1, S = 0

c) Sum = 100001110, Z = 0, C = 0, O =1, S = 0

d) Sum = 100001110, Z = 0, C = 1, O =1, S = 0

made-easy test-series computer-organization


Selected Answer

A 10001110
B 10000000
SUM : 100001110

Z = 0 C = 1 S = 0

 1 votes -- Digvijay Pandey ( 26245 points)

5.72 Computer Organization: ME_Test_Series - CO : Cache Memory top gateoverflow.in/36674

Array A contains 256 elements of 4 bytes each. Its first element is stored at physical address 4,096. Array B contains 512
elements of 4 bytes each. Its first element is stored at physical address 8,192. Assume that only arrays A and B can be
cached in an initially empty, physically addressed, physically tagged, direct-mapped, 2K-byte cache with an 8-byte block
size. The following loop is then executed.
for (i = 0; i < 256; i++)
A[i] = A[i] + B[2 ∗ i];
During the execution of the loop, how many bytes will be written to memory if the cache has a write-through policy?

a) 0

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 384 of 2244

b) 256

c) 1,024

d) 2,048

made-easy test-series computer-organization

The answer is D) 2048 , as the cache block is eight bytes long , so whenever an element of A is updated you have to
write the entire block which contains the element to memory , as 256 elements are updated there will be that many cache
block writes to memory so in all 8*256 = 2048 bytes are written.

 0 votes -- Vikram Bhat ( 587 points)

5.73 Computer Organization: made easy mock test top gateoverflow.in/38622

Each word is 4b and there are 10 words


40 B
3000+40B +1
What is the actual solution ?

computer-organization made-easy test-series


Selected Answer

Word addressable memory ..


Starting address is always PC content..
LOAD : 3000 - 3001 //2 word
MOVE : 3002 - 3002
ADD : 3003 - 3003
INC : 3004 - 3004
INC : 3005 - 3005
LOAD : 3006 - 3006
STORE : 3007 - 3008 //2 word
HALT :3009 - 3009

Finally PC address is 3009

 2 votes -- Digvijay Pandey ( 26245 points)

3010

 1 votes -- Kiran Karwa ( 35 points)

5.74 Computer Organization: ME_Test_Series - CO : Identify the false

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 385 of 2244

statements: top gateoverflow.in/36608

Identify the false statements:


S1: Separate I/O address space does not necessarily mean that I/O address lines are physically separated.
S2: Address decoder is an essential part of I/O interface.

a) Only S 1

b) Only S 2

c) Both S 1 and S 2

d) Neither S 1 nor S 2

made-easy test-series computer-organization

5.75 Computer Organization: Computer Organization question top gateoverflow.in/32254

made-easy computer-organization


Selected Answer

1 instruction size = 1 word = 4 bytes = 32 bits

170 operations, so it need 8 bits for opcode

37 registers need 6 bits for register operand

So remaining bits will be for memory operand i.e., 32 bits - (8 + 6) bits = 18 bits.

With 18 bit memory address, memory address possible is 2 18.

As word size is 4 bytes, memory size = 2 18 * 4 bytes = 2 20 bytes = 1 MB.

 1 votes -- prathams ( 1141 points)

5.76 Control Unit: Microprogrammed control unit top gateoverflow.in/166

Microprogrammed control unit:

a)is faster than a hardwired control unit

b)facilitates easy implementation of new instructions

c)is useful when very small programs are to be run

d)usually refers to control unit of a microprocessor

[GATE 1987]

The answer given is (a). Wont it be (b)?? If it is (a) please explain.

microprogramming control-unit easy co&architecture

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 386 of 2244


Selected Answer

(a) is wrong. Microprogrammed CU can never be faster than hardwired CU. Microprogrammed CU it has an extra layer on
top of hardwired CU and hence can only be slower than hardwired CU.

(b) is a suitable answer as we can add new instruction by changing the content of control memory.

(c) is not correct as when only small programs are there, hardwired control makes more sense.

(d) control unit can also be hardwired, so this is also not correct.

Reference: http://www2.mta.ac.il/~carmi/Teaching/Architecture/SlidesOriginal/ch07%20-
%20Microprogrammed%20Control.pdf

 2 votes -- Arjun Suresh ( 124125 points)

5.77 Cpu: Cpu operand fetch speed top gateoverflow.in/35864

How many cycles here indexed addressing mode will take?

co&architecture computer-organization cpu

acc to me ans should be like this..

for register: (0.10*1)=0.10 cycles

for immediate= it should be zero

for direct = 0.30*2 =0.60 cycles (becz 1 mem ref and for 1 mem ref 2 cycles are required)

mem indirect= 0.20*4=0.80cycles

index = 0.20*6=1.2cycles

now 0.10+0.60+0.80+1.2 =2.7 cycles

1cycle required 1ns time

so Tavg =2.7 ns

1 instruction time =2.7 ns

so in 1 sec=1/2.7 ns

that is 370.37 million

 0 votes -- deep_down ( 99 points)

5.78 Cycle: DAM cycle stealing top gateoverflow.in/37254

How cycle stealing maximize i/o rate

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 387 of 2244

co&architecture dma cycle

5.78 Data Dependencies: In Operand Forwarding technique how does the


next instruction is able to access the dependent operand which is calculated
in the previous instruction in the same Cpu Cycle? top gateoverflow.in/9233

pipeline data-dependencies


Selected Answer

In the same CPU cycle is not possible. Operand forwarding happens in the next cycle after the operation producing the
operand is finished.

But there is a catch here:

If the operand forwarding happens from EX stage to EX stage, EX of the second instruction can proceed only in the next
clock cycle.

 4 votes -- Arjun Suresh ( 124125 points)

5.79 Data Dependencies: Why there is no RAW conflict in follwing code ?


Explain top gateoverflow.in/36856

I1 : R1 = 100

I4 : R4 = R 1 + R 3
I5 : R1 = R 1 + 30

co&architecture data-dependencies

5.80 Data Dependencies: pipelining - without operand forwarding top gateoverflow.in/32274

computer-organization pipeline data-dependencies

Inst1 2 3 4 5 6 7 8 9 10 11 12 13 14
I1 IF ID DF EX WB
I2 IF ID DF EX WB

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 388 of 2244

I3 IF ID DF STALL EX WB
I4 IF ID STALL DF STALL EX WB
I5 IF STALL ID STALL DF STALL EX WB
I6 STALL IF STALL ID STALL DF STALL EX WB

All I3 I4 I5 I6 dependent.

 0 votes -- Umang Raman ( 10379 points)

5.81 Data Dependencies: RAW dependencies top gateoverflow.in/17729

ADD R 1 , R 2, R 2;

ADD R 3, R 2, R 1;

SUB R 4, R 1 , R 5;

ADD R 3, R 3, R 4;

FIND THE NUMBER OF READ AFTER WRITE(RAW) DEPENDENCIES IN THE ABOVE CODE.

data-dependencies


Selected Answer

RAW dependency are those in which one instruction tries to read before its write operation and also they are occured only
in adjacent instruction:

1.
ADD
R1
,
R2,
R2;

ADD
R3,
R2,
R1;

2.
SUB
R4,
R1
,
R5;
ADD
R3,
R3,
R4;

total there are 2 (RAW) dpendecy..

 1 votes -- kunal chalotra ( 3567 points)

5.81 Data Dependencies: how many (RAW,WAR,WAW) dependencies exists


in the following set of instruction R1<-R2+R3 R3<-R1-R2 R4<-R1+R3 R1<-
R1*R3 top gateoverflow.in/7409

data-dependencies

5 RAW

3 WAR

1 WAW

 1 votes -- Anurag Semwal ( 4775 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 389 of 2244

5.82 Data Dependencies: number of WAR dependencies top gateoverflow.in/29896

co&architecture data-dependencies

RAW is true dependency,so RAW can only be found between two adjacent instructions.Here no two adjacent instructions
having RAW.

so,RAW =0

for WAR.... 1)I2,I3

2)I3,I4

3)I4,I5

total 3 WAR

for WAW... 1)I1,I2

2)I1,I5

3)I2,I5

total 3 WAW

So,sum of dependencies are 6.

ref : http://www.dauniv.ac.in/downloads/CArch_PPTs/CompArchCh06L03InstrPipeLineHazards.pdf page 19

 1 votes -- Sayantan Ganguly ( 5061 points)

5.83 Data Hazards: War raw waw top gateoverflow.in/21299

(common data q-30_31)

A pipelined processor uses a 4- stages instruction pipeline with the following stages. Instructions fetch (IF) , instruction
decode (ID), execute (EX) and write back (WB). The arithmetic operations as well as the load and store operations arr
carried out in the Ex stage. the sequence of instructions corresponding to the statement

X= ( s-r*(p+q))/t os given below:

The values of variables p,q,r,s and t are available in rhe resisters ro, r1, r2 and r4 respectively; before the execution of the
instruction sequence.

Add r5,r0,r1 r5 <- r0+r1<br />


Mul r6,r2,r5 r6 <- r2*r5<br />
Sub r5,r3,r6 r5 <- r3-r6<br />
Div r6,r5,r4 r6 <- r5 / r4<br />

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 390 of 2244

Store r6,x; x <-r6<br />


Q-30 the number of read-after-write(raw), write-after-read(war) nd write-after-write(waw) de dependencies in the sequence
of instructions are respectively.

A.2,2,4

b.3,2,3

c.4,2,2

d. 3,3,2

Q-31 the if,id and wb stages take 1-clock cycle each. The ex stage takes 1- clock cycle each for the add,sub and store
operations and 3-clock cycles each for mul nd div operations. Operand forwarding from the ex stage to the id stage is used.
The number of clock cycle required to complete the sequence of instructions is

A.10

b.12

C. 14

D. 16

(For q -31 my ans 12)

co&architecture pipeline data-hazards

Ans 31. 12 cycles

WB 1 2 3 4 5
EX 1 2 2 2 3 4 4 4 5
ID 1 2 3 4 5
IF 1 2 3 4 5

Ans 30. RAW- 4(ADD,MUL),(MUL,SUB),(SUB,DIV),(DIV,Store)

WAR-2 (MUL,SUB),(SUB,DIV)

WAW-2 (MUL,DIV) (SUB,STORE)

 3 votes -- sonu ( 1267 points)

5.84 Data Hazards: Hazards top gateoverflow.in/35286

data-hazards

5.85 Data Hazards: Data hazards: RAW,WAR,WAW top gateoverflow.in/5295

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 391 of 2244

Indicate the type of data hazards (RAW, WAR, and WAW) that exist between the following instructions:
I1:ADD R1, R2, R3 ; R1 = R2 + R3
I2:ADD R4, R1, R4 ; R4 = R1 + R4
I3:ADD R3, R1, R2 ; R3 = R1 + R2
I4:ADD R1, R1, R4 ; R1 = R1 + R4

Soln: Between I1 and I2 RAW(w.r.t. R1),


In I2 WAW (w.r.t R4 but I am not sure if this has WAR too)
Between I3 and I4 WAR (w.r.t. R1)
In I4 WAW (w.r.t R1 but I am not sure if this has WAR too)
Please correct me and My doubts, as follows:
i)Whether hazards can exist in single instruction?(as in I2 and I4)
ii)Do we have to consider only consecutive instructions? (as in I1 and I2) or can it be (I1 and I3) too?

data-hazards pipeline

According to me ,no hazards can not exists in single instruction. As we can change the sequence the of instructions but we
can not change sequence of instruction cycle (e.g you can not perform execute before fetch )

Also hazards need not be in consecutive instructions.It can be I1 and I3 also

 1 votes -- pratikb ( 323 points)

5.86 Data Path: CPU Datapath top gateoverflow.in/18916

data-path co&architecture

5.87 Data Path: The ALU, the bus and all the register are identical in size. the
instruction "memory write" top gateoverflow.in/27358

The ALU, the bus and all the register are identical in size. The instruction "memory write" has the register transfer
interpretation M[(R1)] ← R2. The minimum number of clock cycles needed for execution cycle of this instruction if memory
write completion takes 1 cycle is

a) 2 b)3

c)4 d)5

co&architecture data-path

It can be done in 3 cycles

1.R2out,MDRin

2.R1out,MARin

3.MARout,MDRout,WRITE(this write can be done in this cycle only)

Ref: https://en.wikipedia.org/wiki/Datapath

 1 votes -- sonu ( 1267 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 392 of 2244

5.88 Direct Mapping: Direct Mapped Cache top gateoverflow.in/35113

If we are given direct mapped cache, we have to add Multiplexer delay to the comparator delay ?

co&architecture cache-memory direct-mapping

If given then add, else it must be too small so neglected.

 0 votes -- Monanshi Jain ( 5827 points)

5.89 Direct Mapping: COA Adv practice test 27 q-22 top gateoverflow.in/37058

Consider the direct mapped cache organization which consists of m-lines with a line size of 2 w words/ bytes. Main memory
address can be viewed as consisting of three fields. The least significant w-bits identify a unique word within the block of
main memory. The remaining ‘S’ bits specify one of the 2 S block of main memory. Assume that cache is initially empty. Main
memory blocks are referenced by the CPU in a sequential order. Which one of the following sequence of the blocks are
mapped on the cache lines in sequential order from the initial line respectively.

2m + 1, 2m + 2,..., 3m – 1
2S – m, 2 S – m+1,..., 2 S – 1
1, 2, 3,..., m – 1
0, 2, 4,..., (m – 1)

i thought answer would be 1,2,3, ... (m-1)

but now i am confused what is asked in this ques.

test-series made-easy co&architecture direct-mapping

Offset bits = w and 2w is the cache line size. So, this much size is exactly fitting on cache line.

Now, cache is always organized such that consecutive memory blocks go to consecutive cache sets (to make use of
spacial locality) and this is the reason tag bits are the left most.

Now, answer is easy here but options are not. Answer must be option B. In option A, it should start from 2m and not 2m + 1
and similarly in C, it must start from 0.

 1 votes -- Arjun Suresh ( 124125 points)

5.90 Direct Mapping: Number of misses, compulsory misses, conflict misses


top gateoverflow.in/36519

I have got

- 5 compulsory misses for first 5 ref.

- 3 conflict misses for last 3 ref.

cache-memory co&architecture direct-mapping madeeasy

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 393 of 2244

5.91 Direct Mapping: Misses for a string of memory referances in direct


mapping top gateoverflow.in/35993

[MADEEASY]

Consider a cache as follows :

- Direct Mapped - 16 words total cache size - 4 words cache block size

A sequence of 9 memory reads is performed in order from following addresses

2, 13, 6, 16, 11, 3, 10, 2, 13.

What is maximum number of misses ?

A) 7

B) 4

C) 8

D) 6

----------- MY TRY---------------------------------

(Offset-Last 2 bits & Rest is block and tag)

2 => 000 | 10 - Miss

13 => 011 | 01 - Miss

6 => 001 | 10 - Miss

16 => 100 | 00 - Miss (overwritten first block)

11 => 010 | 11 - Miss

3 => 000 | 11 - Miss (again first is overwritten)

10 => 010 | 10 - Hit (in block 2)

2 => 000 | 10 - Hit (in block 0)

13 => 011 | 01 - Hit (in block 3)

Its giving (D) But answer is given as (C).

co&architecture direct-mapping cache-memory madeeasy

5.92 Disk: seek time top gateoverflow.in/18993

the seek time of a disk is 30ms.it rotates at the rate of 30 rotations/second.the capacity of each track is 300 words.the
access time is (approximately)

guys can any one solve this plzzzz...

disk

Access time is defined as time to access one word from memory

So, it may be the answer

1 rot = 1/30 sec

In 1 rotation ---> 100 words

For 1 word ---> 1/300 rotations

So, 1 word transfer time = 1/300*1/30 sec

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 394 of 2244

So, avg access time= 30 ms(seek time)+ 1/60 sec (avg rotational latency) + 1/ 9000 sec (transfer time)

= 30+16.6667+.1111 ms

= 46.78 ms(approx)

 0 votes -- admin ( 1411 points)

5.93 Dma: DRDO Q32 top gateoverflow.in/18941

A certain device dumps data into its interface register every 200 ns. The main memory access time is 50 ns. If the CPU were interfaced to his device in cycle stealing mode,
what percentage of time does the CPU be in hold state?
A. 20
B. 25
C. 50
D. None of these

co&architecture dma

answer = option A

 0 votes -- Amar Vashishth ( 17865 points)

5.94 Dma: ISRO-2013-14 top gateoverflow.in/43805

A processor is fetching instructions at the rate of 1 MIPS. A DMA module is used to transfer characters to RAM from a device
transmitting at 9600 bps. How much time will the processor be slowed down due to DMA activity?

A. 9.6ms
B. 4.8ms
C. 2.4ms
D. 1.2ms

isro2013 dma

Assuming Data Width of the System bus is Byte,DMA Will run every Cycle for every
Byte.which has arrived.

So,

10^6 bits in 1 second


1 bit in 1/10^6 second
9600 bits in 9600* 1/10^6 seconds
9600/8 bytes in 9600/8* 1/10^6 seconds

Which gives 1.2 ms or 1MIPS..

Option D)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 395 of 2244

 0 votes -- saif ahmed ( 931 points)

5.95 Dma: DMA transfer rate top gateoverflow.in/18172

An 8-bit DMA device is operating is cycle stealing mode (single transfer mode). Each DMA cycle is of 6 clock states and DMA
clock is 2MHz. Intermediate CPU machine cycle takes 2 microsecond, determine the DMA data transfer rate.

co&architecture dma

2MHz = 2 x 10^6 cycles/s DMA cycle = 6/(2 x 10^6) = 3 mic s (10^-6 s) Intermediate CPU cycle is 2 mic s So, every 5
mic s, we have a 8 bit transfer - 1Byte In 1s => 10^6/5 = 200 x 1000 B

 2 votes -- Arindam Sarkar ( 621 points)

5.96 Dma: Dma bus time top gateoverflow.in/603

Cycle steal mode

dma co&architecture normal

5.97 Dma: dma top gateoverflow.in/16662

A DMA controller transfers 16-bit word to memory using cycle stealing. The words assembled from a device that transmits
characters at a rate of 2400 characters per second. The CPU is fetching and executing instructions at an average rate of 1
million instructions per second.

By how much will the CPU be slow down because of DMA transfer when the
characters are represented with 8 bit ASCII?
(A) 0.0833% (B) 83% C) 17% (D) 17.33%

How much more percent the CPU slows down when 32 –bits words are
transferred to memory using cycle stealing?
(A) 83% (B) 23% (C) 0.0833% (D) 17.33%

dma

all options are wrong. what i think they have missed the number of instruction required to transfer the word . so
considering one instruction will be required.

time due to dma wasted = time taken when cpu address bus was taken / total time *100

total time = preparation time + transfer time .

time wasted when cpu address bus was taken = transfer time. ( dma concept)

preparation time =

2400 charcater in 1 sec.

1 charcter in 1/2400 sec . and 1 charcter =8 bit.

8 bit = 1/2400 so one bit = 1/(2400*8) /sec

so one bit will be taken from the device to dma in 1/(2400*8) sec.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 396 of 2244

so 16 bit = 1/(2400*8)*16= 1/1200seconds.

now transffer time.

cpu execute 1 million instructions . = 1*10^6 . in one second.

s 1 instruction in 1/10^6 seconds.

suppose one instruction is required to transfer 16 bit . ( which i think is missed in question).

so transfer time = 10^-6 sconds .

now applying above formula.

(10^-6 /(1/1200) + (10^-6)) *100 = 0.119 . = 0.12

second option . i am transfering 32 bit word which means preparation time is going to double . and now cpu will also take
2 instruction to transfer as i assumed 16 bit in one instruction . actually solving this u will see there is no effect on the
time of wastage . because wastage is time is due to the cpu was blocked. during preparation cpu never get blocked. so no
effect.

 3 votes -- Ravi Singh ( 7303 points)

5.98 Dma: DmA top gateoverflow.in/764

dma

for initialization and termination cpu need 400 and 500 clock cycle so for 900 clock cycle we need (900*3.3)=2970 ns
where 3.3ns is clock time derived from 300 MHZ.

for transfer 5GB=1sec -> 5mb = 1ms -> 200 mb = 40 ms.

hence the cpu time consumed is 2970/40000 =0.07425 =7.4% (is this correct?)

 1 votes -- sanjeev_zerocode ( 253 points)

5.99 Dma: A hard disk with transfer rate of 20 kbps is constantly


transferring data to memory using DMA cycle stealing mode top gateoverflow.in/35804

A hard disk with transfer rate of 20 kbps is constantly transferring data to memory using DMA cycle stealing mode. The size
of data transfer is 32 bytes. The processor runs at 800 kHz clock frequency. The DMA controller requires 12 cycles for
initialization of operation and transfer takes 4 cycles to transfer 2 byte of data from device to the memory. Then the transfer
time for transfer time ______(μs)

My question is : as it is cycle stealing mode and 2 Byte of data transferred at every 4 cycles. So , after every 2 Byte data
sent , DMA will give the control back to processor , is it correct ? So , will it not take 32/2 = 16 times to transfer the 32 B

The answer given as ::

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 397 of 2244

co&architecture dma

This Solution is wrong .As units are mismatched here

 0 votes -- Rahul Rai ( 41 points)

5.100 Dma: dma throughput top gateoverflow.in/25029

A DMA controller transfers 16 bytes to memory using cycle stealing with frequency 1.2GHz. The number of clock cycles used
for transfer of 16 bytes is 20 Clock cycles. Find the throughout?

dma

throughput of dma is the data rate of dma. or number of words it can transffer to memory in one seconds.
1
1.2∗ 109
1 clock time = seconds
20

16 bytes requires 20 cycles. so 1 byte requires 16 cycles.

20

so time taken to transffer one byte will be ( 16 cycles.* 1 cycle time) seconds

so in one second we can transfer 960 Mbps.

 0 votes -- Ravi Singh ( 7303 points)

5.101 Dma: please explain top gateoverflow.in/12197

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 398 of 2244

dma

FOR DMA TRANSFER

15 cycles for initialization +200 cycles for 100 bytes transfer=215 cycles

FOR INTERRUPT PROGRAM

consists of 5 instruction each inst takes 1 cycle after they say program will be executed for each byte transfer
so for 100 BYTES TRANSFER PROGRAM SHOULD RUN 100 TIMES as now PROGRAM CONSISTS of 5 instruction
therefore require total of 500 cycles to transfer 100 BYTES.

SPEED UP=500/215=2.32

 2 votes -- kunal chalotra ( 3567 points)

5.102 Dma: DMA Data trasnfer Rate top gateoverflow.in/9179

A progarm drive Data Transfer results overhead of 6 instruction per byte.System uses 100MHZ clock and need 4 clock on an
average for any instruction . what is maximum data transfer rate (Apprx) ?

dma

one instruction needs 40 ns

overhead is 6 instruction in transfering byte

overhead=240 ns

in 240 ns is byte is transfered

data rate=1/240ns

=4.16Mbps

data rate is approximatelly equal to 4 Mbps

 1 votes -- Pooja ( 22773 points)

5.103 Dma: DMA operation top gateoverflow.in/37355

A) consider 1mbps hard-disk is interfaced to the processor in a cycle stealing mode of DMA whenever 64 bytes of data is
available in the buffer,then it is transferred to main memory (word=64bits)...machine cycle time is 2 micro sec..percentage
of CPU time consumed for DMA operation is ???

B) P ercentage of CPU time consumed for DMA operation if burst mode is used ???

dma co&architecture

5.104 Dma: what is the processor time top gateoverflow.in/25030

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 399 of 2244

Consider the disk drive with the following specification 16 surface. 1024 tracks per surface. 1024 sectors/track, 1 KB /sector
rotation speed is 3000 rpm.The disk is operated in Burst Mode.The processor runs at 600 MHZ and takes 300 & 900 clock cycle
to initiate & complete DMA transfer respectively. If the size of transfer is 20KB

What is the percentage of processor time consumed for the transfer operation?

dma

total cycle which dma need to initiate and then complete the total cycles that will be required will be 1200 cycles. Total
time by dma will be ( initiate + transfer + complete ) out of which only transfer time will be useful time.

so wastage time = 1200 cycles * time of one cycle.


1
frequency
1cycle =
1
600Mhz
1 cycle=

1200 cycles = 2 micro second time.

now we have to calculate the time for transfer which can be easily calculated using the disk parameters given . assuming
a movable read write head is available . if it is movable in one round i will be able to read one track only else if it is fixed .
every surface will have a read write head and 16 tracks can be read in one rotation.

3000 rounds = 60 seconds

1 round = 50

total data on track = 1024 *1KB


1

1024*1KB data = 50 seconds


20

20 KB data = 50∗ 1024 = 390 micro second.

so total time = 392 micro second. whle transfer time is 390.


2 ∗ 100

cpu will be involved in the transfer time only . so percentage will be 392

 0 votes -- Ravi Singh ( 7303 points)

5.105 Dram Refreshing: Find the refresh overhead in terms of percentage top
gateoverflow.in/28984

All dynamic memories have to be refreshed. A typical DRAM takes 64 ms to refresh. Suppose there are 8 K rows and it takes
four clock cycles to access each row. If the clock rate is 133 MHz, find the refresh overhead in terms of percentage (upto 2
decimal places).

Made Easy FLT 6- Practice Test 14

Q 27

computer-organization dram-refreshing

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 400 of 2244


Selected Answer

no of cycles require to refresh= 8k ×4 = 2^15

amount of time to refresh = 2^15 × (1/133×10^6) secs =0.246 ms

%of overhead =( 0.246 /64)*100 =0.38 %

 3 votes -- pramod ( 2071 points)

5.106 Effective Memory Access: Effective access time vs average access time
top gateoverflow.in/36416

Can anyone explains when to use this formulas?

Average memory access time (AMAT)


AMAT = Hit Time + Miss Rate * Miss Penality

OR

• Effective Access Time:

1. Hit Rate * Hit time+ Miss Rate * Miss Penality

2. [ (H)(TLB access time + mem access time) + (1-H)(TLB access + PT access + mem access)]

co&architecture operating-system effective-memory-access time

When u get a hit in the TLB,it generates the physical address or the frame address that maps onto the appropriate frame
in the main memory...so TLB access time + main memory time..

But when its a miss, that means u have searched the entire TLB for the page number but u didnt get so TLB access is
there.. Now u have to access the page table to search the appropriate page number so the page table access time is
included. Now comes the mapping to the appropriate frame.. Once u do that main memory time wud be included.. Hence
the equation.. Remember that If u don't find the page in the page table it will generate a page fault then u have to fetch it
from the disk...

 0 votes -- Ritaban Basu ( 255 points)

5.107 Effective Memory Access: Memory Access Time top gateoverflow.in/37050

Actually there is solution also but not able to take screen shot.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 401 of 2244

My solution is :

TA1 = 0.95*30+0.05*300

TA2=0.95*30+0.05*270

TA1-TA2=3ns

Am I correct?

co&architecture effective-memory-access time


Selected Answer

TA1 = 0.95 * 30(HIT) + 0.05 * 330( CACHE ACCESS TIME + MEMORY ACCESS)

TA2 = 0.95 * 30(HIT) + 0.05 * 300(MAIN MEMORY ACCESS as searching is done simultaneously)

Therefore TA1 - TA2 = 1.5 ns

 2 votes -- Tushar Jain ( 105 points)

5.108 Fault: Average Access time in Memory Organization top gateoverflow.in/12843

Consider a Processor with two Caches which it can access directly in parallel L1 (80% hit rate) and L2 (90% hit rate) with
access times as 100ns and 200ns respectively. In case of miss in any of those it fetches the data from hard disk L3 (100% hit
rate) which has a latency of 500ns. What is the average access time(Tavg ) of the organization?

cache-memory co&architecture fault

(H1+H2)T2+(1-H1)(1-H2)(T3+T2)

 0 votes -- Er Lucky ( 309 points)

5.109 Floating Point Representation: IEEE754 For top gateoverflow.in/9221

http://gateoverflow.in/?qa=blob&qa_blobid=677596019370884012

floating-point-representation

http://steve.hollasch.net/cgindex/coding/ieeefloat.html

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 402 of 2244

 1 votes -- Arjun Suresh ( 124125 points)

5.110 Floating Point Representation: What is the answer 20 or 9? top gateoverflow.in/16714

floating-point-representation co&architecture

here, in question it is mentioned that excess 64 exponent it means that

here, bias is 64.

so , exponent 1010100 represents 84 in decimal no system.

to get exponent in decimal we subtract bias that is 64 from exponent part f floating point no.

so, 84-64=20

 0 votes -- saket nandan ( 1853 points)

5.111 Gmr: Gmr in multilevel caches top gateoverflow.in/34433

1.What are global miss rate and local miss rates in two level cache.

Lmr is no. of misses on cache / total no. Of access to the cache

Gmr is no. of misses on cache / total no. Of cpu generated ref.

2.Global miss rate of both levels of caches will be same or different?

3.What is no. Of stalls created per instruction in two level cache?(formula?)

I understood what lmr of any cache is.

but gmr is quite confusing.

For better understanding lets take an eg.

Cpu generates 10 mem. Ref.

L1 is closed to cpu then l2 and then main memory. So l1 is lower level and l2 is higher level. 6 mem. Ref. Are found in l1 and
for remaining 4 mem. Ref. L2 is accessed. and only 2 mem. Ref. Are found in l2.

gmr lmr co&architecture multilevel-cache

5.112 Horizontal: Resource for studying microprogramming top gateoverflow.in/33479

I want to know how much important topic is microprogramming for gate? And what and from where I should prepare for this
topic?

co&architecture horizontal microprogramming


Selected Answer

These two videos contain good content about microprogramming

https://www.youtube.com/watch?v=Ru6YeppPA0U
https://www.youtube.com/watch?v=zKCr6uDlq1o

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 403 of 2244

 0 votes -- Shikhar Vashishth ( 3439 points)

5.113 Horizontal: Microprogramming Control Unit top gateoverflow.in/18913

A hypothetical processor supports 256 instructions.Each instruction takes 12 cycles to complete the execution.
Processor supports horizontal control unit design. It has 24 control signals and 16 flags. What is the size of
microinstruction??

horizontal microprogramming co&architecture

No of control words=256*12=3072

12 bits required for address

As horizontal programming is used no of bits for control signal=24

No of bits for flags=4

Control word format is

Signal flags(condition codes) next address

So total no of bits in contol word=24+4+12=40

 0 votes -- Pooja ( 22773 points)

5.114 Ieee Representation: 16 Bit IEEE floating point format top gateoverflow.in/37652

Q: The decimal number -0.329 x 2^15 is to be represented using a 16 bit floating point format without normalization as
shown above. mantissa is pure fraction in sign magnitude form. Answer using rounding off is..

My Try: As it is 16 bit IEEE , so we should use [Exponent - 63 = 15] (coz, without normalization) which gives E = 78.

I dont know why they grouped 3-3 bits, so even if we group them by three.. So, 4th digit should br 1 and not 5.

(They have taken Expo - 64 = 15) why???

floating-point-representation co&architecture made-easy ieee-representation

its just octal convention.

 0 votes -- Aspi R Osa ( 1305 points)

5.115 In: Total latch latency (virtualgate 2016) top gateoverflow.in/34472

Suppose there is unpipelined processor with a cycle time 30 ns which is evenly divided into 5 pipeline stages. The total latch
latency of the pipeline will be _______________ ns (integer value only)

co&architecture virtualgate in pipeline computer-organization

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 404 of 2244

5.116 Instruction Format: Max number of one address instruction, when two
address instruction is given is? top gateoverflow.in/16361

A computer uses expanding opcode. It has 16 bit instructions 6 bit addresses, it supports one address, two address
instructions only. If there are n two address instructions, the maximum number of one address instructions are?

co&architecture addressing-modes machine-instructions instruction-format

We have 16 bits for instructions- no. of encoding = 216

Since, 6 bit addresses are used, and we have n two address instructions it would take 26 × 26 × n encoding.

Given, only one address and two address instructions are present. So, all remaining encoding can be used for one address

( )
instructions which will be 216 − 212 × n which will correspond to 216 − 212 × n /26 = 210 − n × 26 one address instructions as
address field needs 26 bits.

http://www.personal.kent.edu/~aguercio/CS35101Slides/Tanenbaum/CA_Ch05_PartII.pdf

 5 votes -- Arjun Suresh ( 124125 points)

16 bit instruction

6 bit address

so no of bits for opcode =4

so 16 instructions are possible

out of them n are two address

so no of one address instruction possible=(16-n)*2^6=(16-n)* 64

 2 votes -- Pooja ( 22773 points)

5.117 Interrupts: Address stored on stack on interrupting HALT top gateoverflow.in/37566

As far as I know, HALT is always implemented as...

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 405 of 2244

HALT = Here: JMP Here

Until user close the application, it keeps looping itself. So the address on the stack should be 1024 and not 1028.

co&architecture interrupts ace-test-series

5.118 Interrupts: testseries adv level coa Q14 top gateoverflow.in/36730

Consider a system employing interrupt driven input/output for a particular device that transfers data at an average of 16
KB/s on a continuous basis. Assume that interrupt processing takes 50 μsec (i.e., the jump to the interrupt service routine
(ISR), execute it and return to main program). The fraction of processor time is consumed by this input/output device if it
interrupt for every byte is ______ (upto 3 decimal places).

made-easy co&architecture interrupts


Selected Answer

Device interrupts for every byte and it can send 16KB/sec at a time, so time taken to send 1 byte= 1/(16*10 3)=
0.0625msec

Now, it is given that interrupt processing takes time= 50 micro sec

So, fraction of time consumed by I/O device if it interrupts for every byte= time taken to process interrupt / time taken by
device to send data= 50 * 10-6 / (0.0625 * 10 -3) = 0.8

P.S as per hint in question (upto 3 decimal places).. so they are considering 1KB= 2 10 bytes. Hence, answer might vary
accordingly i.e 16*210 * 50*10 -6 = 0.819

 1 votes -- Ashish Gupta ( 631 points)

5.119 Interrupts: What Happens If Interrupt raised while execution of a


program to contents of PC top gateoverflow.in/28622

Consider following program

MOV R1,5000

MOV R2,2000

ADD R2,R2,R3 //Interrupt raised here, Mem Add of this instruction is 1008

Now when ISR is served and program resumes from ADD instruction(1008), R1 and R2 will have different values then
intended. How is it taken care of?

case 1: All register values are stored before interuptt and replaced.

case 2: Program begins execution from MOV R1,5000 after interuptt is served.

interrupts stack

the answer is in how interrupts are handled in cpu. after every instruction the interrupt flag are checked. if there is a
interrupt then all the values of register and as well as program counter are stored in special registers. and the interrupt
vector address is pushed onto the stack. and after the service . all the pc and the registers are again set to the earlier
position ,and no need to restart the program.

 0 votes -- Ravi Singh ( 7303 points)

5.120 Interrupts: Interrupts top gateoverflow.in/20067

Can someone explain that will Interrupt Service routine will also follow that time sharing environment like other normal

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 406 of 2244

processes in system.?

I think not. But i want to know difference in execution of normal process and Interrupt subroutine.

@Arjun Sir

interrupts

interrupts follow time sharing approach ? the answer depend on the situation.

basically interrupts are of two types hardware and software. the hardware interrupts like cpu overheating will never follow
time sharing. they have to services as they can cause the failure of the cpu. but if a interrupt is generated by a process
definitely it will be context switched as the process will be pre empted. what matter here is the priority of interrupt. a flag
is used to do so.
Higher-priority interrupts can preempt interrupts that have lower priority. To allow you to control preemption, use the preemption flags to specify whether an interrupt can be
preempted.

Entering 1 indicates that the interrupt can be preempted.


Entering 0 indicates the interrupt cannot be preempted.

how interrupt handled is simple. interrupt is just a piece of code which is present at a special address. whenever an
interrupt occur cpu just go to that address, and execute that code. so a process generated an interrupt the cpu has to
execute that code first it goes to that address which i think is called "vector address". if it is a software interrupt it can be
preempted if the process can be preempted by the cpu and on the return the cpu will start servicing the interrupt where it
has left it.

so in some case yes and no in some cases.

 0 votes -- Ravi Singh ( 7303 points)

5.121 Io: Direct memory access is used for high-speed I/O devices. top gateoverflow.in/27032

Direct memory access is used for high-speed I/O devices.

Why this happens.what is co relation between speed of I/O and DMA transfer becoz anyway DMA is more efficient than other
modes such as interrupt driven, so why its not efficient for slower I/O devices?

co&architecture io dma

5.122 Io Organization: Method of connecting IO devices to CPU top gateoverflow.in/32996

please explain me the concepts behind

Memory Mapped IO
IO Mapped IO

What do they really mean ?

io-organization

5.123 Lockup Free Cache: Which of the following is true in case of lock up
free cache? top gateoverflow.in/21222

1. A cache structure allows a Cpu to access a cache while a hit is being serviced

2. A cache structure allows a Cpu to access a cache while a miss is being serviced.

3. A cache that can support multiple outstanding misses

4. A cache that can support multiple outstanding hits

And why?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 407 of 2244

cache-memory lockup-free-cache

5.124 Look Aside: Write Back and Write Through top gateoverflow.in/35154

A 64 word cache and main memory are divided into 16 word blocks. The main memory access time is 50 ns/word and the
cache access time is 10 ns/word. Hit ratio for read operation is 80% and for the write operation is 90%. Whenever a cache
miss happens, associated block must be brought from main memory to cache for both read and write operation. Let there be
40% references for write operations.

1) What is the throughput of the memory system for write through policy?

2) In the above problem if write back updation is used and at any point of time 30% cache blocks are modified, What is
Tavg in write back policy?

Ans for :

1) is 6.5 Million words/sec

2) is 176.4 ns

co&architecture look-aside cache-memory cache write_through


Selected Answer

First part answered here: http://gateoverflow.in/10668/64-word-cache-and-main-memory-is-divided-into-16-words-block

tm = 16 × 50 = 800ns for transferring a block to cache.

For write-back:

In write back, only when a block is being replaced from cache it will be written back to memory. And this write-back is
needed only if the block is dirty. So, for both read as well as write miss, 30% of time the block must be written back to
memory.

Tavg = hr × tc + (1 − hr) × (tm + tc + 0.3 × tm) = 0.8 × 10 + 0.2 × (800 + 10 + 240) = 218ns
R

Write-back avoids a memory access during a cache hit as compared to write-through.

Tavg = hw × tc + (1 − hw)(tc + tm + 0.3 × tm) = 0.9 × 10 + 0.1 × [810 + 240] = 114ns


W

So, Tavg = 0.6 × 218 + 0.4 × 114 = 176.4ns

 3 votes -- Arjun Suresh ( 124125 points)

5.125 Look Aside: Computer Org- write trhough and write back top gateoverflow.in/34061

co&architecture look-aside

5.126 Machine Instructions: Differencee Between DCR and DCRL Instruction.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 408 of 2244

top gateoverflow.in/28620

Want to know difference between :

DCR and DCRL

SUB and SUBL

machine-instructions

5.127 Machine Instructions: consider a hypothetical processor which support


both 1 address and zero address instruction. top gateoverflow.in/11060

Consider a hypothetical processor which support both 1 address and zero address instruction. It contain 6 bit instruction and
four bit address if there exists 2 one address instruction than how many zero address instruction can be formulated?

co&architecture machine-instructions


Selected Answer

6 bit instruction, so totally we can have 26 = 64 possible encodings.

There are 2 one address instructions, which would take 2 × 24 = 32 encodings as an address is of 4 bits. The remaining 32
encodings can be used for zero address ones and since they don't need any address part, each of them can be a separate
instruction. So, answer should be 32.

 2 votes -- Arjun Suresh ( 124125 points)

5.128 Madeeasy: Calculating branch frequency when speedup is given gateoverflow.in/35999

top

Assume that execution of 200 instructions on a 6 staged pipeline where the target address is available at 4th stage.Let X be
the probability of an instruction not being branch. The value of X such that speedup is atleast 5 is ________ ?

----------------------------------------------------

Doubt:

=> I know the normal method i.e. K stages / (1 + Branch freq * Stall cycles) = Speedup which yields near to
exact answer.

=> But I am unable to get the answer by : ( K stages * N instructions ) / [ (K + N - 1) + (freq * stalls) ]

Method 2) : 6 * 200 / [205 + (1 - X)*3]

=> 1200 / (208 - 3X) = 5

=> 1200 = 1040 - 15X

=> 15X = - 160 Which is not possible.

Where am I going wrong ??

co&architecture pipeline madeeasy


Selected Answer

Got it! Actually in second method I was directly considering the probability. But, its a percentage of number of instructions
which have taken the branch.

So, Y% instructions are branches = branch freq.

Hence, (200 * 6) / [205 + (Y/100 * 200 * 3)] Which gives Y around 6% and so our required X would be 94% which is

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 409 of 2244

0.94 [to be exact] :)

 2 votes -- Tushar Shinde ( 1523 points)

Speed up is at least 5.

(Nonpipelinedtime)
Pipelinetime
So , 5 ⩽

Here , target address is available at the 4th clock cycle. So , if we execute any instruction at the 1st clock cycle , we would
need to wait till 4th clock cycle to get the output. So, this is stall. So , stall cycle = (4-1) =3

So ,

(6 )

5 ⩽ (1 +stallfrequency∗ stallpenalty)

Now , here question asks about when not branch.

(6 )

5 ⩽ (1 + (1 −stallfrequency) ∗ stallpenalty)

(6 )

5 ⩽ (1 + (1 −X) ∗ 3 )

so , on solving , x comes 0.933

So , 1-x comes as 0.066. So , not to branch probability 0.07.

 1 votes -- Shounak Kundu ( 3757 points)

5.129 Madeeasy Testseries: madeeasy top gateoverflow.in/38151

Suppose that in 250 memory references there are 30 misses in first level cache and 10 misses in second level cache. Assume
that miss penalty from the L2 cache memory 50 cycles. The hit time of L2 cache is 10 cycles. The hit time of the L1 cache is 5
cycles. If there are 1.25 memory references per instruction, then the average stall cycles per instruction is ________.

answer given-4

madeeasy-testseries co&architecture

no of instruction 200 = (250/1.25).

now stall/instruction is = miss in L1 / inst. * hit in L2 + miss in L2 / inst. * miss penalty in L2

= ( 30/200)*10 +(10/200)*50 =4

 4 votes -- Sayantan Ganguly ( 5061 points)

first 1.25 memory references per instruction means total no. of instruction is 250/1.25 =200 instructions
Now total cycle required to execute all instruction
220*L1{Hit time} + 20*L2{Hit time} + 10*l2{penalty time}
220*5+20*10+10*50=1800 cycles

each instruction take 1800/200 =9 cycles


Now consider there is no misses and latency So all instruction execute in 200*5=1000 or say each instruction execute in 5
cycleSo stall is 9-5=4 cycle

 1 votes -- Jaikishan Apurva ( 787 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 410 of 2244

5.130 Memory: Made easy CA q16 top gateoverflow.in/20300

How many 512k x 8 static RAM chips are needed to design the 2M x 32 memory module.

a. 32 b. 8 c.16 d.64

co&architecture memory module

No of chips=2M*32/512K*8

=2^26/2^22

=2^4

=16

 1 votes -- Pooja ( 22773 points)

5.131 Memory Interfacing: How to calculate which memory block will go in


which block in set associative cache? top gateoverflow.in/17395

If there is k-set associative cache, with total x cache blocks, and 2^n main memory locations, how is the mapping
calculated?

cache-memory co&architecture memory-interfacing


Selected Answer

Let m be the memory block

Calculate no of sets(p)=x/k

Block m will be mapped to any one of block of set no m%p

In this way consecutive memory blocks will be going to different sets in cache there by making use of spatial locality.

 1 votes -- Pooja ( 22773 points)

5.132 Memory Interfacing: how many memory operations are required to


access the data? top gateoverflow.in/16286

Assume that a 16 bit cpu is trying to access a double word starting at an odd address.how many memory operations are
required to access the data?

a) 1 b ) 2 c) 3 d) 4

memory-interfacing


Selected Answer

3 for double word beginning at odd address.

2 for double word beginning at even address.

1 for single word beginning at even address.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 411 of 2244

2 for single word beginning at odd address.

Must read: https://courses.engr.illinois.edu/ece390/books/artofasm/CH03/CH03-1.html

 1 votes -- Arjun Suresh ( 124125 points)

5.133 Memory Management: memory management top gateoverflow.in/38732

Consider a direct mapped cache of size 16 KB and block size is 4 words. The word length is 16 bits. Find the number of bits needed for cache indexing if CPU
generates 32 bit address

memory-management


Selected Answer

block size=4*2=8 bytes

no of blocks =16kB/8=2048

so for cache indexing 11 bits are required

3 bit for offset (assuming byte addressing; 2 for word addressing)

and 32-14=18 for tag (19 if word addressing is used)

 2 votes -- Pooja ( 22773 points)

No of tag bits=19 = log(2^32 * 2B / 2^14 B)

block offset requires=11 bits

word offset requires=2 bits

index = (block offset + word offset)

but as i searched over google it's says that index meas only (block offset)...so 11 bits should be the ans...

http://cs.stackexchange.com/questions/13356/how-to-calculate-the-tag-index-and-offset-fields-of-different-caches

 1 votes -- Gabbar ( 469 points)

5.134 Memory Management: Q7 ch-5 memory org. top gateoverflow.in/20911

Let cache of 0.7 hit having average access time 9 times faster than that of memory. if average access time increases 40%
from 80ns. What would be new hit ratio.

A. 0.72 b. 0.36 c. 0.53 d. 0.80

My answer is 0.74

Am i correct?

co&architecture cache-memory memory-management

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 412 of 2244

Assuming hierarchical access:

800

80 = x + 0.3 × 9x  x = 37

800 7200

1.4 × 80 = 37 + (1 − h) 37  h = 0.53

 0 votes -- Arjun Suresh ( 124125 points)

5.135 Memory Management: Q 12-13 Common data ch-5 Ca top gateoverflow.in/21034

Consider two cache organization: the first one is 32 kB 2-way set associative with 32 B block size. The second one is of the
same size but direct mapped. The size of an address is 32 bit in both cases. A 2 to 1 multiplexer has latency of 0.6 ns while a
k-bit comparator has a latency of k/10 ns the hit latency of set associative organization is h1 while that of the direct
mapped one h2

Q.12 th value of h1 is

A. 2.4ns b. 2.3 ns

c. 1.8 ns d. 1.7 ns

Q.13 the value of h2 is

A. 2.4 ns b 2.3 ns c. 1.8ns d. 1.7 ns

My answers are as-

12. Op-a

Multiplexer latency+ comparator latency

= 0.6 + 18/10 as for set associative k=18 bit(tag bit)

= 2.4 ns

For 13. Op-d

Only comparator latency =k/10

=17/10 = 1.7 ns

Am i doing any thing wrong???

co&architecture memory-management

5.136 Microprogramming: Made easy workbook 2015 (CONTROL UNIT


DESIGN) top gateoverflow.in/18936

A micro instruction is to be designed to specify none/one of the three micro operations of one kind and none or upto 6 micro
operation of another kind. The minimum number of bits in the micro instruction is -

(a) 9 (b) 5 (c) 8 (d) none of these

co&architecture microprogramming

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 413 of 2244


Selected Answer

None/one = encoded binary format = log 2n bits /control signal


None/more than 1 = decoded binary format = 1bit /control signal
here none /1 = 3 micro operation so log23 = 2 bits
other i.e none/more than 1 = 6 micro operation so 6 bits

so total 6+2 = 8 bits

 3 votes -- Umang Raman ( 10379 points)

To specify none or one of 3 operations no of bits required=2

To specify none or upto 6 operations no of bits required=6

So total bits required=2+6=8 bits(added as there was and mention in question)

 2 votes -- Pooja ( 22773 points)

5.137 Microprogramming: Q 12 (control unit design) MadeEasy workBook top


gateoverflow.in/18935

a micro programmed control memory supports 256 instructions .Every instruction on average consume 8 micro operations
.The system supports 16 flag conditions and 48 control signals.If the horizontal micro programming is used,what is the size
of each control word let 1 address control instruction is used.

(a) 61 bits (b) 63 bits (c) 6 bits (d) 8 bits

co&architecture microprogramming


Selected Answer

No of control words=256*8=2048

11 bits for address

4 bit for flag

48 bits for signals

So total bits in control word=11+4+48=63

 1 votes -- Pooja ( 22773 points)

5.138 Microprogramming: microinstruction top gateoverflow.in/25032

microprogramming

Option C : 7 Bits

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 414 of 2244

We can't have totally Horizontal micro programming here.

If we use only Vertical micro programming here then we have to use atleast 2 decoders => Min number of bits required will be 7.

log 2x + log 2y = 25

If we take x = 2 and y = 5, it's minimum, will generate atmax 2 parallel signals and also we can represent all 25 control signals.

 0 votes -- CrimeMasterGoGo ( 2221 points)

5.139 Microprogramming: Microprogrammed control unit 1 top gateoverflow.in/34232

Ques:-

Control field of microinstruction contain two groups of control signal group 1 supports none or one of 64 control signals and
group 2 supports at most 6 from remaining. What is size of micro operation?

(what is the meaning of "from remaining" here?)

co&architecture microprogramming

It means that there are total 64 control signals available in the Control Unit, and there are two groups considered here.
One group will have either none or one control signal from the given 64 signals. The other group can have at most 6
control signals from the remaining 63 signals, if the previous group used one signal, or from 64 signals, if the previous
group didn't use any signal.

 1 votes -- Utk ( 1385 points)

5.140 Microprogramming: Q-13 (ch-2) Made easy workbook 2015 top gateoverflow.in/18870

The control field of 1-address control word has to support 2 groups of control signals.In the group-1 it is requires to generate
either 1 or none of the 63 control signals.In the group-2 at most 4 from the remaining.What will be the minimum no. bits
needed for control field.

option (A) 6

option (B) 10

option (c) 67

option (D) 81.

microprogramming co&architecture


Selected Answer

Question is combination of both vertical and horizontal micro programming...

1 or non of 63 vertical microprogramming... So takes 6 bits...

At most 4..means horizontal... So takes 4bits

Total= 10 bits required...

 3 votes -- Er Lucky ( 309 points)

5.141 Microprogramming: Micro INSTRUCTION top gateoverflow.in/38191

In Horizontal Micro Programming ONE Operation is executed in ONE Clock Cycle


In Vertical Micro Programming , IN one clock cycle ______ operations are executed

ONE
log2 N

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 415 of 2244

microprogramming


Selected Answer

if no data is said , micro programming also takes same number of instruction per clock cycle
here it will be ONE

 0 votes -- Akhil Nadh PC ( 1967 points)

5.142 Microprogramming: How many and what size of field exits in micro
operation field? top gateoverflow.in/16485

If a micro program supports 46 micro operations with parallelism of 2, how many and what size of field exits in micro
operation field?

How do we get the size of micro-operation field as 9?

co&architecture microprogramming


Selected Answer

parallelism is 2

so we divide operations into two sets of 16 and 30 so that requires 4 and 5 bits so total 9 bits

 1 votes -- Pooja ( 22773 points)

5.143 Microprogramming: micro programming top gateoverflow.in/37985

consider a micro programmed control unit each of which takes 16 micro operations.The system supports 16 flag conditions and
54 control signals .If horizontal microprogramming control is used then what is the length of control word(bits/word)?

microprogramming


Selected Answer

the no. of bits in control word = no. of bits for flag + no. of bits for control signal + no.of bits for control memory

bits for flag = log2(16)

bits for control signal = 54 (for horizontal )

bits for control memory = log2(no. of instruction * no. of micro operation per instruction) = log2(total micro operations)=
log2(16)= 4

therefore no. of bits in control word = 4+54+4=62

 1 votes -- Abhishekcs10 ( 1001 points)

5.144 Misses: direct mapping and types of misses top gateoverflow.in/30994

Consider a cache as follows:

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 416 of 2244

Direct mapped
8 words total cache data size
2 words block size

A sequence of eight memory read is performed in the order shown from the following addresses:

0 , 11 , 4 , 14 , 9 , 1 , 8 , 0

Calculate

1. No. of misses
2. No of compulsory misses
3. No. of conflict misses
4. No. of capacity misses

direct-mapping misses cache-memory co&architecture

Total cache size is 4 blocks.

Memory accesses are as follows: 0 , 11 , 4 , 14 , 9 , 1 , 8 , 0

So, the corresponding block numbers will be: 0, 5, 2, 7, 4, 0, 4, 0 (000, 101, 010, 111, 100, 000, 100, 000)

0, 5, 2, 7 and 4 causes compulsory misses as they are first accesses to blocks.

Next 0 is a conflict miss as 4 has replaced the previously accessed 0. It is also a capacity miss as after the previous
access to 0, we have 4 unique block accesses and we have capacity only for 4 − 1 = 3 more.

Next 4 is a conflict miss due to 0 replacing 4 but not a capacity miss.

Similarly final 0 is also a conflict miss but not capacity miss.

No. of misses = 8

No. of compulsory misses = 5

No. of conflict misses = 3

No. of capacity misses = 1

More Explanation: http://gateoverflow.in/20086/page-replacement

 3 votes -- Arjun Suresh ( 124125 points)

5.145 Misses: Conflict Misses top gateoverflow.in/37046

Will conflict misses increase if k-way set associative cache is used and we increase the cache capacity?

co&architecture cache-memory misses

5.146 Multiplexer: MULTIPLEXER top gateoverflow.in/43702

THE FUNCTION Z2 WILL BE ?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 417 of 2244

multiplexer

Z1=(ab+a'b')'c' +(ab+a'b')c

=a XOR b XOR c

Z2=(ab+a'b') 'b+(ab+a'b')c

=a'b+a'c+bc

 0 votes -- srestha ( 11585 points)

5.147 Number: Which of the following result overflow with 2's complement
arithmetic ? top gateoverflow.in/28431

1. 1 1 1 1 1 1 1 1 + 1 1 1 1 1 1 1 1
2. 0 1 1 1 1 1 1 1 + 1 1 1 1 1 1 1 1
3. 0 1 0 0 0 0 0 0 + 0 1 1 0 0 0 0 0

Please justify your answer. I'm not getting a clue whether the given number is in 2's complement . Should I have to find
2's complenet of the given number or not

number-representation number

Overflow = (Carry out of MSB) Ex-OR (Carry on MSB)

3rd will give Overflow.

Ref.http://sandbox.mc.edu/~bennet/cs110/tc/add.html

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 418 of 2244

 2 votes -- Digvijay Pandey ( 26245 points)

5.148 Number Representation: The square of the binary number 1001 in


hexadecimal is top gateoverflow.in/42223

The square of the binary number 1001 in hexadecimal is

a. 81 b. 51 c. 121 d. A1

number-representation


Selected Answer

it will be 9^2=81

hexadecimal of (81) 10 =(51)16

 3 votes -- srestha ( 11585 points)

5.149 One: ISRO 2015 top gateoverflow.in/38485

In
X=(M+N*O)/(p*Q)
How many one address instructions are required ?
What the asnwer would be if we use 2 address instrction , 3 address instruction and ZERO address instruction

one add

Is this answer Correct? pls correct if any mistakes


Zero Address

1. PUSH P
2. PUSH Q
3. MUL
4. PUSH O
5. PUSH N
6. MUL
7. PUSH M
8. ADD
9. DIV
10. POP X

One Address

1. LOAD P
2. MUL Q
3. STORE T
4. LOAD O
5. MUL N
6. ADD M
7. DIV T
8. STORE X

Two Address

1. MOV R1,N
2. MUL R1,0
3. ADD R1 ,M
4. MOV R2,Q
5. MUL R2,P
6. DIV R1,R2
7. MOC X,R1

Three Address

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 419 of 2244

1. ADD R1,P,Q
2. MUL R2,N,O
3. ADD R2,R2,M
4. DIV X,R2,R1

 1 votes -- Akhil Nadh PC ( 1967 points)

5.150 One Task Execution: Pipelining efficiency top gateoverflow.in/34260

Case:-1

When all the pipeline stages are perfectly balanced(uniform delay) then one task execution time in pipelining equal to one
task execution time of nonpipelining.

Then What are the performance gain and efficiency?

Ques1:-

If K=No. Of stages =4

Tp=2ns and

N= no. Of instruction =1

Case:-2

When all the pipeline stages are not perfectly balanced(non uniform delay) then one task execution time in pipelining greater
than one task execution time in nonpipelining.

Then What are the performance gain and efficiency?

Ques 2:-

If stage s1 takes 2ns

stage s2 takes 8ns

stage s3 takes 1ns

stage s4 takes 2ns

Then What are the performance gain and efficiency in both ques?

I think efficiency is 25% and performance gain is 1 in ques1.

pipeline co&architecture one-task-execution

5.151 Operand Forwarding: operand forwarding top gateoverflow.in/37223

please check the answer...

pipeline made-easy_test-series operand-forwarding computer-organization

5.152 Operand Forwarding: madeeasy testseries COA Q 29 operand


forwarding top gateoverflow.in/36734

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 420 of 2244

The following sequence of instruction is executed in a basic 5 stage pipelined processor ( S1, S2, S3, S4 , S5). Assume that
data dependency present in the program is resolved by operand forwarding techniques. Load instruction output present in 4th
stage ALU instruction output is available in 3rd stage. Assume each stage take 1 cycle.

What is the number of instructions must be inserted to achieve CPI = 1 by using operand forwarding.

co&architecture pipeline made-easy_test-series operand-forwarding

5.153 Page Replacement: Block replacement in set associative mapping


using FIFO top gateoverflow.in/35946

I guess explaination is wrong. I am getting 216.

cache-memory co&architecture ace-test-series page-replacement


Selected Answer

You are getting 216, because you are confusing it with LRU. In FIFO you have to take out 8, not 216.

 0 votes -- CrimeMasterGoGo ( 2221 points)

5.153 Pipeline: Please any body know how to prepare all the types of
numerical in cache and pipeline. top gateoverflow.in/198

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 421 of 2244

pipeline

Please read all the topics. If you have any doubt in question you can post here. We shall be posting questions in this topic
by November and we shall try to cover all types of problems.

 2 votes -- Arjun Suresh ( 124125 points)

5.154 Pipeline: Pipelining - without operand forwarding top gateoverflow.in/34735

An instruction pipeline consists of following 5 stages:


IF = Instruction Fetch, ID = Instruction Decode, EX = Execute, MA = Memory Access and WB = Register Write Back.
Now consider the following code:

1. LOAD R8, 0(R5); R8 = memory [R5]


2. LOAD R9, 4(R5); R9 = memory [R5 + 4]
3. ADD R7, R8, R9; R7 = R8 + R9
4. SUB R6, R7, R8; R6 = R7 – R8

Assume that each stage takes 1 clock cycle for all the instructions. How many cycles are required to execute the code,
without operand forwarding over a bypass network?

1. 9
2. 10
3. 11
4. 14

pipeline co&architecture


Selected Answer

1 2 3 4 5 6 7 8 9 10 11 12
I1 IF ID EX MA WB
I2 IF ID EX MA WB
I3 IF X X ID EX MA WB
I4 X X IF X X ID EX MA WB

WB and ID can go together in 1 cycle- WB writes to register file in first half of a cycle and ID reads it from the second half.
This is a common technique and need not be explicitly given in question. So, answer is 12 cycles without operand
forwarding. (Suppose this answer is not there in choice for GATE, we can do WB and ID in separate cycles and get the
answer in choice. But for previous GATE questions this was never the case).

With operand forwarding:

1 2 3 4 5 6 7 8 9
I1 IF ID EX MA WB
I2 IF ID EX MA WB
I3 IF ID X EX MA WB
I4 IF X ID EX MA WB

 7 votes -- Arjun Suresh ( 124125 points)

5.155 Pipeline: Execution time on a pipelined processor, given execution


time on a non-pipelined processor top gateoverflow.in/34449

A program executes on a non-pipelined processor in time t. The same program is executed on a m-stage pipelined

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 422 of 2244

processor, with each stage delay d. Then, how it is that the execution time of the program on the pipelined processor is
given in terms of t, m and d as follows

Execution Time on pipelined processor = ( t / m) + d * m

I understand the term "d * m" but how can we have this term " t / m". I can't understand the logic behind this term. Please
explain.

pipeline co&architecture


Selected Answer

A program executes on a non-pipelined processor in time t. {means all instruction is executed in t time}
single instruction take time in execution is m*d {number of stage m, each stage delay is d}
So number of instruction is t/(m*d)

now execution time on pipeline is (n-1+k)*d


where n=#'s of instruction , k=stage , d=stage_delay + buffer_delay {in this case ignore buffer_delay}

So [t/(m*d) -1 + m]*d
open bracket (t/m-d+m*d) {this is execution time on pipeline}

if seems anything wrong correct me!!

 4 votes -- Jaikishan Apurva ( 787 points)

5.156 Pipeline: pipeline cycles top gateoverflow.in/35374

I think they calculated whole things wrong.. with operand forwarding answer is 9,but they drew wrong diagram..and without
answer will be 14.as we can use id stage under wb stage. so answer shoyld be 5. @arjun sir.

pipeline co&architecture

Overflow only

 0 votes -- govind ( 255 points)

5.157 Pipeline: Total cycles for executing these Instructions in a Pipelined

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 423 of 2244

Architecture top gateoverflow.in/29411

pipeline co&architecture


Selected Answer

total 9 cycles.

https://courses.cs.washington.edu/courses/cse410/05sp/lectures/cse410-10-pipelining-a.pdf

 2 votes -- bahirNaik ( 2479 points)

5.158 Pipeline: pipelining top gateoverflow.in/12213

pipeline


Selected Answer

Average no. of cycles per instruction = 0.4 * 4 + 0.2 * 5 + 0.4 * 6 = 5

Average time for an instruction = CPI * clock time = 5 * 10 = 50 ns

So, number of instructions per second = 1/50 ns = 20 MIPS

With pipelining we can have an instruction completed every cycle assuming we handle pipeline hazards. I assume the 2ns
overhead given takes care of it. So, we can have CPI = 1.

Average time for an instruction = 1 * clock time + overhead = 10 + 2 = 12 ns.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 424 of 2244

So, number of instruction per second = 1 / 12 ns = 83.3 MIPS

 3 votes -- Arjun Suresh ( 124125 points)

5.159 Pipeline: buffer problem in CO top gateoverflow.in/18634

pipeline


Selected Answer

We cannot design a pipeline without the buffer registers . Therefore in between every pipeline stage there will be a
register buffer taking 20ns each . Therefore the time taken to complete first instruction is 100 + 20 + 100 + 20 + 100
+20 = 360 ns .

 1 votes -- Riya Roy ( 4767 points)

5.160 Pipeline: How will the compiler reorder the below statements so that it
doesn't have any stall cycle ? top gateoverflow.in/15588

How will the compiler reorder the below statements so that it doesn't have any stall cycle ?

Load R2, N // Load the size of the list.


Clear R3 //Initialize sum to 0
Move R4, #NUM1​ // Get address of the first number.
LOOP: Load R5, (R4)// Get the next number.
Add R3, R3, R5 // Add this numberto sum.
Add R4, R4, #4 //Increment the pointer to the list.
Subtract R2, R2, #1 // Decrement the counter.
Branch_if [R2]>0 LOOP //Branch back if notfinished.
Store R3, SUM //Store thefinal sum.

pipeline

Load R2, N // Load the size of the list.


Clear R3 //Initialize sum to 0
Move R4, #NUM1​ // Get address of the first number
. LOOP: Load R5, (R4)// Get the next number.
Add R3, R3, R5 // Add this numberto sum.
Add R4, R4, #4 //Increment the pointer to the list.
Branch_if [R2]>0 LOOP //Branch back if notfinished.
Subtract R2, R2, #1 // Decrement the counter.
Store R3, SUM //Store thefinal sum.

can we shift the sub instruction down to branch so that store will not be fetched since ID stage of Branch and If of sub will
overlap

and in ID satge Branch change the pc value and will transfer the control to loop if true .

 0 votes -- Umang Raman ( 10379 points)

5.161 Pipeline: Assume that 20 of the dynamic count of the total 100
instructions executed for a program are branch instructions. top gateoverflow.in/15589

Assume that 20 of the dynamic count of the total 100 instructions executed for a program are branch instructions. Delayed
branching is used, with one delay slot. Assume that there are no stalls caused by other factors. First, derive an expression

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 425 of 2244

for the execution time in cycles if all delay slots are filled with NOP instructions. Then, derive another expression that reflects
the execution time with 70 percent of delay slots filled with useful instructions by the optimizing compiler.

pipeline


Selected Answer

Out of 100 instructions 20 instructions creates 1stall.

So total no of stall cycle/instruction = 0.80*0 + 0.20*1 = 0.20 Stall/instruction

Total time = 1 + 0.2 = 1.20 Cycle

If 70%stall filled with useful instructions i.e. no stalls due to these 70% instructions, for rest 30%instructionder will be 1
Stall cycle,

Stall/instruction = 0.20*0.70*0 + 0.20*0.30*1 = 0.06

Total cycle time = 1 + 0.06 = 1.06 Cycle

 1 votes -- Digvijay Pandey ( 26245 points)

5.162 Pipeline: PIPELINING top gateoverflow.in/324

add $so,$to,$t1

sub $t2,$S0,$t3

Num of stall cyles i am getting 2 stall but the books says 3

1.No data data forwarding

2.Write to register file in first half and read from second half in clock cycle my timing dig goes like this

add IF ID EX MEM WB

NOP

NOP

IF ID EXE .....

pipeline

This will be the timing diagram. Three stall cycles are needed to ensure WB is completed before the ID stage of the SUB instruction. This assumes Register File
read is performed during the ID stage of the pipeline.

Clk1 Clk2 Clk3 Clk4 Clk5 Clk6 Clk7 Clk8 Clk9


ADD IF ID EX MEM WB
SUB IF Stall Stall Stall ID EX MEM WB

 0 votes -- gatecse ( 9515 points)

5.163 Pipeline: how many stall cycles in this system on cache miss ? top gateoverflow.in/18602

Directly coming to the question...(its a linked data type qstn)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 426 of 2244

A pipelined processor with separate instruction and data cache has 5 stages with a cycle time of 30 ns. It is used with copy-
back data cache with block size of 1 word. T(cache)=30ns ans T(RAM)=80ns. Hit ratio for cache is 90%. In this cache, if
missed word is not passed to the processor until entire block is received from ram.

Q.1. How many stall cycles occur when memory access instruction misses in cache?

A) 1. B) 2. C) 3. D) 4.

Q.2. What is avg. instruction throughout in MIPS?

What I thought was if a normal hit takes 30ns of IF then on miss it should take (block movement + IF from cache) i.e.,
({80+30} + 30) ... which will inturn give extra time of 110 ns resulting in 4 stall cycles. But the answer given is different.
And based on 1st qstn only you are able to solve second one.

Where am I going wrong??

co&architecture cache-memory pipeline

1. 5 stages must be IF, ID, PO, MA, WB

We are asked the no. of stall cycles when MA misses in cache. So, lets find the time on a cache miss:

Time on cache miss = Time to access cache + Time to access RAM for a cache block (block size = word size given in
question) = 30ns + 80ns = 110ns.

"word is not passed to the processor until entire block is received from ram"

So this should mean we have to add one more cache access time - 30ns, and total time on cache miss = 140ns.

So, there will be stall for (140 - 30)ns which will be 4 clock cycles as CPU is operating at 30ns and each stage can use
30ns without causing a stall.

2. We have hit ratio for cache- but without knowing the average no. of memory access per instruction we can't calculate
the throughput.

 1 votes -- Arjun Suresh ( 124125 points)

5.164 Pipeline: CA q 20 top gateoverflow.in/20306

Consider an instruction pipeline which has speed up factor IO. While operation with 80% efficiency. what could be the no. Of
stages in the pipeline?

a. 8 b. 10 c. 11 d. 13

co&architecture pipeline

Efficiency of a pipeline(Ek) = Speed Up / No of stages

No of Stages =Speed Up / Ek = 10 / .8 =12.5 ≏13

 0 votes -- Leen Sharma ( 2935 points)

5.165 Pipeline: Pipeline Stalls top gateoverflow.in/32896

What is the idea behind introducing pipeline stalls ?

On getting some instructions and stages How can one construct pipeline cycle

Eg:

I1 : LOAD R0,loc

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 427 of 2244

I2 : ADD r0,r0

I3 : Add r2 , r0

Stages

Instruction Fectch
Instruction Decode
Execute
Memory Access
Write Back

pipeline


Selected Answer

That's the simplest way to take care of dependency. For pipeline to run without any problem for any instruction, it should
not have any dependency with 'k' neighboring instructions where 'k' is the number of pipeline stages. If there is a
dependency from ith stage to jth stage (i < j), j-i-1 delay slots (pipeline stalls during these) are introduced so that ith
stage eventually gets the required data from jth one.

For the given code, I2 depends on I1 for R0. More specifically ID stage (during which register is read) of I1 depends on
WB stage of I0. So, (5 - 2 -1) = 2 delay slots are needed.

I3 also depends on I2. More specifically ID stage depends on WB stage (when registers are updated) of I2. So, again 2
delay slots are needed.

If we can do operand forwarding- where the required data is directly passed from a stage to a stage of new instruction, we
can avoid stalls in many cases. For this example, we can pass data from Memory Access Stage to EX stage for I1-I2 (this
still requires 1 delay) and from the output of EX stage of I2 to EX stage of I3 (no more stalls required).

 0 votes -- Arjun Suresh ( 124125 points)

5.166 Pipeline: Pipeline q21 Ca top gateoverflow.in/20310

Consider 2 pipelines A and B where pipeline A having 8 stages of uniform delay of 2 ns. the pipeline B is having 5 stages
with respective stage delays 2 ns, 3 ns, 1 ns, 2 ns ,2 ns. How much time ia saved if 100 instructions are pipelined using A
instead of B.

a. 90 ns b. 98 ns c. 88 ns d. 0 ns

co&architecture pipeline


Selected Answer

Time required i pipeline execution (T p)={ K + ( N - 1 ) }* t p

N=Number of instructions

K=Number of stages

tp =time period for the clock cycle in pipeline ={ MAX(t i) from i=1 to k + Buffer delay }

For A

Time required in pipeline execution (T pA)={ 8 + (100-1) } *2

=214 ns

For B

Time required i pipeline execution (T pB)={5+(100-1) } *3

=312 ns

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 428 of 2244

time saved =312 - 214 = 98 ns

 2 votes -- Leen Sharma ( 2935 points)

5.167 Pipeline: Risc Pipelining, CPI (cycles per instruction) top gateoverflow.in/30006

In a pipelined RISC computer where all arithmetic instructions have the same CPI (cycles per instruction), which of the
following actions would improve the execution time of a typical program?

I. Increasing the clock cycle rate

II. Disallowing any forwarding in the pipeline

III. Doubling the sizes of the instruction cache and the data cache without changing the clock cycle time

(A) I only (B) II only (C) III only (D) I and II (E) I and III

pipeline

Correct me if wrong...

1. True

2. It reduces the hazard so cant be correct, False.

3. True, bcz larger cache size will hold more data..leads to low cache miss.

 0 votes -- Bishnu Agrawal ( 96 points)

5.168 Pipeline: ISRO-2013-15 top gateoverflow.in/43806

A pipeline P operating at 400 MHz has a speedup factor of 6 and operating at 70% efficiency. How many stages are there in
the pipeline?

A. 5
B. 6
C. 8
D. 9

isro2013 co&architecture pipeline

Efficiency of K stage Pipeline = SpeedUp Factor (Sk) / Number of Stages (K)


0.70 = 6/K
K = 6/0.70 = 8.57 ≌ 9

Number of Stages = 9

 0 votes -- Digvijay Pandey ( 26245 points)

5.169 Pipeline: Q-27 ch-4 pipeline top gateoverflow.in/21296

Consider 2 pipeline with the following specification

Stall cycle for memory pipeline no. Of stage memory

1 A k single port

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 429 of 2244

0 B k dual port

The pipeline allows all instructions except memory based instructions. If 2 memory operations can not be done in same
clock. The penalty is 1 clock. Let there are 20% memory instructions obtain S a/Sb

A. 0.833 b. 0.53 c. 0.94 d. 0.24

co&architecture pipeline

speed Sa=k/1+0.2 speed Sb=k Sa/Sb=1/1.2=0.833

 0 votes -- Pooja ( 22773 points)

5.170 Pipeline: A 4-stage pipeline has .. top gateoverflow.in/20750

A 4-stage pipeline has the stage delays as 150,120,160 and 140 nanoseconds respectively . Registers that are used between
the stages have a delay of 5 nanoseconds each .Assuming constant clocking rate,the total time taken to process 1000 data
items on this pipeline will be

a)120.4 microseconds

b)160.5 microseconds

c)165.5 microseconds

d)590.0 microseconds

co&architecture pipeline

Maximum stage delay will be 160 ns and 5 ns uniform delay register are being used . so total time for each stage should
be 165ns so that every stage can work well.

tp = 165ns

formula is (k+(n-1)) tp. k=4 because stages are 4

(4+999) 165 ns = 165.5 micro seconds .

option c

 0 votes -- Ravi Singh ( 7303 points)

5.171 Pipeline: Pipeline MAL , throughput , Efficiency top gateoverflow.in/32919

Given Collision Vector : (1010)

What are permissible and forbidden latencies


Calculate MAL
Calculate throughput ?
Calculate Efficiency of pipeline ?
Also Draw a state diagram ?

I have a doubt in State diagram construction


Could someone explain these question and concepts behind this ?
There has to be a line from state 1011 to 1111 upon latency 1 applying to 1011 Isn't it ?
Someone pls explain this . and also how to calculate
Efficiency and throughput

pipeline

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 430 of 2244

I think that diagram has some flaw

See the ans of Arjun sir for this state diagram

http://gateoverflow.in/8560/gate2015-3_51

 0 votes -- srestha ( 11585 points)

5.172 Preparation: Can Anyone tell me to what depth should I cover the book
Computer Organization and Embedded systems(6th edition)? top gateoverflow.in/42173

I am reading Computer Organization and Embedded systems(6th edition).Do I have to read Ch 1-3,5,6,8,9 completely?
Specifically do I have to read Chapter 9( Arithmetic) completely?

preparation

Don't read blindly . check previous year quetion then u have idea about what u have to cover from book or what not .

 0 votes -- Anirudh Pratap Singh ( 4091 points)

5.173 Priority: Arrange according to priority order top gateoverflow.in/32970

" CPU Gives High Priority For Faster Devices "

Arrange the following operations according to validation of above statement .

Hard Disk
DVD Disk
Keyboard
Printer
CPU Temperature Sensors

priority io-organization


Selected Answer

Priority order (Highest to lowest)

CPU Temperature Sensors > Hard Disk > DVD disk > Printer >Keyboard

CPU Temperature is given highest priority to avoid serious damage of hardware.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 431 of 2244

 1 votes -- Shashank Kumar ( 2029 points)

5.174 Ram: How many 2K x 8 RAM chips are needed? top gateoverflow.in/4755

We want to build a memory with 4-byte words and a capacity of 2 21 bits.

1. How many 2K x 8 RAM chips are needed?


2. How many address lines are needed for the memory?
3. How many of these address lines are connected to the address inputs of the RAM chips?
4. How many of these address lines will be used to select the appropriate RAM chip(s)?
5. What size decoder is needed to build the memory?
A. 128, 16, 11, 5, 5 to 32
B. 256, 16, 11, 5, 5 to 32
C. 128, 16, 10, 6, 6 to 64
D. 512, 15, 10, 5, 5 to 32

memory-interfacing ram


Selected Answer

(1) Memory Capacity = 2 21 bits

RAM chip capacity = 2K * 8 bits = 2 14 bits

So, number of RAM chips required = 2 21 / 214 = 2 7 = 128

(2) Memory needs to address each word.


A word is 4 bytes. So, number of possible words = 221 /(4*8) = 221 /25 = 2 16
So, number of address lines needed for memory = 16

(3) A RAM chip has 2K rows of cells to select (each row has 8 cells of 1 bit each which will always be selected together).
So, we need 11 bits to select any of these 2K rows.

(4) 16-11 = 5 address lines will be used to select the appropriate RAM chip(s)- 5 address lines to select 128 chips doesn't
seem logical but this is how multi-byte words can be fetched from memory in parallel. At any time 4 RAM chips will be
selected together and a byte can be fetched in parallel from all these, resulting in 4 bytes being fetched in 1 memory
cycle. (See (s) in the question)

(5) We use 5 address lines to select the RAM chips. So, decoder needs to be 5 to 32.

(A) choice.

 4 votes -- Arjun Suresh ( 124125 points)

2^21/(2 X 2^10 X 2^3)=2^7=128

 2 votes -- Bhagirathi Nayak ( 10239 points)

5.175 Ram: how many address lines are needed to access RAM chips gateoverflow.in/15027

top

if each address space represents one byte of storage space , how many address lines are needed to access RAM chips
arranged in a 4 X 6 array ,where each chip is 8K X 4 bits ?

ram


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 432 of 2244

see in the array there are 6*4 =24 chip so to address them we need 5 bit .

and this is bye addressable "each address space represents one byte of storage space" .

so , for each chip 8k*4 bit = (2 13+2)/8 Byte =2 12

so for addressing we need (12 + 5 ) =17 bits line

 1 votes -- Pranay Datta ( 6113 points)

5.175 Ram: How many 256 X 4 RAM chips are needed to organize a memory
of capacity of 32KB? top gateoverflow.in/14672

co&architecture memory-interfacing ram


Selected Answer

256 x 4 bits is the capacity of a chip. So, to get 32 KB = 32 * 8 kbits = 218 bits we need

2 18 2 18
256 ×4 10
= 2 = 28 = 256

 1 votes -- Arjun Suresh ( 124125 points)

32KB= 2^15*8 bytes

nd we have ram chips of 256*4. which means there are 256 rows in the ram with 4 bits in each row that is one nibble of
data.

so answer is divide and remember always divide the * part separately which means don't involve the in division 4 with
2^15. use it in dividing 8 so here we go

2^(15-8)*2

which means 2^7*2

which is 128*2

this actually means we will be needing 128 rows and 2 columns of 256*4 chips

in case they ask the rows and columns there it will be needed

well total number will be 256.

 1 votes -- Ravi Singh ( 7303 points)

5.176 Ram: full syllabus test-10 adv. level MADEEASY top gateoverflow.in/38332

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 433 of 2244

A RAM chip has 32 rows and 16 columns each with a single bit. The number of address line input required to gain unique
addressing to every location is __________ .

made-easy co&architecture test-series ram

FOR UNIQUE ADDRESSING WE HAVE TO GIVE ONE INPUT TO EACH AND EVERY CHIP

We have 2^5 ROWS AND 2^4 COLUMNS

Hence we need 9:2^9 Decoder

Hence Total no of Address Line required is 9.

 0 votes -- Ankesh Gautam ( 665 points)

5.177 Reference Book: Understanding computer organisation and


architecture top gateoverflow.in/36099

What are some of the user friendly books for "computer organisation and architechture" which are best for self study. Such a
text that one can grasps the big picture, and understandhow various things are fitting with each other.

Topics include: machine instructions and addressing modes, ALU and data path , cpu control design, memory interface, I/o
interface (interrupt and DMA mode), instruction pipelining, cache and main memory.

Thanks

reference-book computer-organization digital-logic co&architecture

5.178 Secondary Storage: Consider a magnetic disk drive with 8 surfaces,


512 tracks per surface, and 64 sectors per track. Sector size is 1 KB. gateoverflow.in/18255

top

Consider a magnetic disk drive with 8 surfaces, 512 tracks per surface, and 64 sectors per track. Sector size is 1 KB.The
average seek time is 8 ms, the track-to-track access time is 1.5 ms, and the drive rotates at 3600 rpm. Successive tracks in
a cylinder can be read without head movement.
Estimate the time required to transfer a 5-MB file.

secondary-storage


Selected Answer

Cylinder capacity = 8*64*1 Kb = 512 kB

Seek time = 8ms

Rotational latency = 1/2*revolution time = 60/3600*2 = 8.3 ms

MB means we need 10 cylinder, so 9 times tack to track access time needed in order to access 10 cylinder. i.e. transfer
time + 9*track to track access time 1 track transfer time = 8*60/3.6 ms = 133.33 ms

Total time = seek time + 10*(per Tack transfer time + Rotational latency) + 9*(track to track access time)

= 8 + 10*( 133.33 + 8.3) + 9*1.5 = 1425.5 ms

 1 votes -- Digvijay Pandey ( 26245 points)

5.179 Speedup: Made easy CA q17 top gateoverflow.in/20302

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 434 of 2244

The time delays of 4 segments are 60 ns, 70 ns, 100 ns and 80 ns respectively. Interface registers are have the delay of 10
ns. what is the speed up?

a. 2.9 b. 2.6 c. 3.2 d. 1.8

co&architecture pipeline speedup


Selected Answer

S= tn/ tp = S1 + S2 +S3 + S4 / max ( S1+10 , S2+10, S3+10, S4+10)


=60+70+100+80/max(60+10, 70+10, 100+10,80+10)

= 310/110=2.818
≃2.9 option A

 1 votes -- Umang Raman ( 10379 points)

5.180 Speedup: Pipeline q 18 CA top gateoverflow.in/20303

A nonpipeline system takes 50 ns to process a task. The same task can be processed in a six segment pipeline with a clock
cycle of 10 ns. determine the speed up ratio of the pipeline for 100 tasks.

a. 3.76 b. 4.76 c. 5.76 d. 2.76

co&architecture pipeline speedup


Selected Answer

S= ntn/(n+k-1)tp = 100*50/(100+6-1)*10 = 4.76


Option B

 2 votes -- Umang Raman ( 10379 points)

5.181 Speedup: Made Easy Test Series top gateoverflow.in/31265

speedup

5.182 Stack: Is stack pointer affected by conditional branch? If no, why? top
gateoverflow.in/16358

A computer uses expanding opcode. It has 16 bit instructions 6 bit addresses, it supports one address, two address
instructions only. If there are n two address instructions, the maximum number of one address instructions are?

stack co&architecture


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 435 of 2244

No for conditional/unconditional JMP but Yes for conditional/unconditional CALL. Stack is used for current activation record
and this is per function. i.e., in each function memory for local variables are assigned with respect to SP and so whenever
there is a CALL, SP must be updated and not otherwise.

 0 votes -- Arjun Suresh ( 124125 points)

5.183 Stall: explain top gateoverflow.in/12286

stall pipeline

1 RAW hazard present btwn last two instruction --> DATA HAZARD

NO structural dependency & no control dependency ..

so (a) option correct

PLZ check!!

I1 IF ID OF PO WB
I2 IF ID OF PO WB
I3 IF ID ---- OF PO WB
I4 IF ID OF PO WB

 1 votes -- kunal chalotra ( 3567 points)


1 2 3 4 5 6 7 9 10 11 12
8
I1 F D OF PO WB
I2 F D OF PO WB
I3 - - F D OF PO WB
I4 F D OF PO WB

stall in pipeline at clock cycle 3 and 4 due to structural dependency (due to shared Instruction and data caches, OF and IF
of two instructions cannot happen in same clock cycle) and in 8 and 9 due to data dependency

so ans is d

 1 votes -- Pooja ( 22773 points)

5.184 Stall: stall cycle top gateoverflow.in/17136

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 436 of 2244

stall cycle pipeline

5.185 Stall: stall top gateoverflow.in/27947

lw R2, 100(R5)

sw R2, 200(R6)............ with out any bypass paths how many cycles does the sw instruction.. need to stall for? 5 stage
pipeline

pipeline stall

without bypass i.e. without operand forwarding

IF ID EX PO WB

IF - - - ID PO WB

there will be 3 stalls

 0 votes -- srestha ( 11585 points)

5.186 Stealing: DMA top gateoverflow.in/19916

http://gateoverflow.in/3547/gate2006-it_8

Arjun Sir plz anwser it.

cycle stealing

5.187 Testbook: TestBook Live Test Q No 31 top gateoverflow.in/36134

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 437 of 2244

testbook test-series computer-organization

5.188 Throughput: Throughput of the Pipeline top gateoverflow.in/34829

Consider a machine with 10 ns clock and it takes 4 clock cycle per ALU instruction, 5 clock cycle per branch instruction, 6
clock cycle memory instruction. There exists 40% ALU instruction, 20% branch instruction, and 40% memory instruction.
What is throughput of pipeline system if overhead is 2 ns? ______________ MIPS (integer value only).

pipeline co&architecture throughput


Selected Answer

Normal average execution time = (0.4 * 4 + 0.2 * 5 + 0.4 * 6) * 10ns = 50 ns.

10 − 6
50×10 − 9
So, MIPS = = 20.

Clock time with pipeline = 10 + 2 = 12 ns.

The no. of cycles are different for ALU, branch and memory instructions. But do they affect pipeline throughput? - depends
on data and structural hazards.

Do branch instruction affect pipeline- yes and depends on branch prediction and how much delay each branch causes. I'm
not able to calculate this based on information in question (where is the question from?)

Assuming everything is neglected or included in overhead, with pipeline we complete 1 instruction every clock cycle. i.e.,

10 − 6
−9
MIPS = 12×10 = 83.33.

 7 votes -- Arjun Suresh ( 124125 points)

83 MIPS

Avg time for 1 instruction non pipeline= (40% * 4 + 20% * 5 + 40%*6)10 ns =5* 10 ns =50 ns
Avg time for 1inst in pipeline would be just 10 +2 = 12 ns
12 ns --> 1 inst

1 sec ---> x inst

x= 12 ∗ 109 = 83MIPS

 3 votes -- bahirNaik ( 2479 points)

5.189 Tlb: TLB ,VGATE top gateoverflow.in/38067

@Arjun sir, I solved it by using the same concept of gate 2003 78,79 ..but techtud marked it as wrong..this qs has only one
confusion which is how to use page table walk and tlb update...I used it in the part of L3 ache miss of Tlb miss.. and used
this formula ...
Tavg = Tlb hit( Tlb time +L1 hit (cache time) + L1 miss(L2 hit(cache time) + L2 miss( L3 hit (cache time) + L3 miss(cache time+memory time ))))

+ Tlb miss(Tlb time + Memory time + L1 hit (cache time) + L1 miss(L2 hit(cache time) + L2 miss( L3 hit (cache time) + L3 miss(cache time+ page table walk and Tlb update ))))

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 438 of 2244

Sir,pls check this

tlb co&architecture cache


Selected Answer

Problem of using formula- we must know what's the use of a page table. It is to get actual physical address. TLB is a quick
look-up for page table.

Regarding question- it's a really well framed question like in GATE. Only issue is for me to read the small font.

So, memory access works like this - First look in cache and then go to RAM. But before looking in cache we need physical
address- because cache uses physical address as given in question. (it can use virtual addressing or virtually index and
physical tag also but this question is clear- physical index, physical tag).

Now what happens when a TLB miss happens? We look in page table which is in main memory. Can this page table be
cached? Yes, quite often. So, determining the time becomes complex. But see the question- it directly gives the time
during a TLB miss- so we are saved. Page walk just means looking up in page table.

If you haven't understood so far I suggest to better skip this portion for GATE. There is no use other than
getting negative if you read below without understanding above.

Average memory access time = Avg. address translation time + Avg. data access time

= (0.95 × 1 + 0.05 × (1 + 200)) + 0.95 × 1 + 0.05 × 0.80 × (1 + 8) + 0.05 × 0.2 × 0.5 × (1 + 8 + 50) + 0.05 × 0.2 × 0.5 × (1 + 8 + 50 + 100) = 11 + 0.95 + 0.36 + 0.295

 1 votes -- Arjun Suresh ( 124125 points)

Time = TLB access time + Miss rate TLB * TLB update time + L1 access time + Miss Rate L1 * L2 Access Time + Miss Rate of
L1 * Miss Rate L2 * L3 Access Time + Miss rate L3 * Memory Access time

= 1 + 0.05*200 + 1 + 0.05*8 + 0.05*0.20*50 + 0.50*0.20*0.50*100


= 1 + 10 + 1 + 0.40 + 0.50 + 0.50
= 13.40 ms

 4 votes -- Digvijay Pandey ( 26245 points)

5.190 Tlb: Find TLB Hit Ratio top gateoverflow.in/37740

Suppose TLB used in one level paging system with each look-up time of TLB 40 msec. Memory reference takes 120 msec. If
the effective memory reference time is 180 msec then page table references are found in TLB is ______

Answer Given in booklet (0.833)

co&architecture tlb


Selected Answer

I think they are asking of TLB hit ratio:

Effective access time = 180msec

TLB access time = 40msec

Main memory access time = 120msec

Therefore, 180 = x(40 + 120) + (1-x)(40 + 2*120)

x = 0.8333

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 439 of 2244

 1 votes -- Sandeepan Baidya ( 131 points)

5.191 Track: virtual gate 2016 Disk size top gateoverflow.in/34478

A disk has 16 equidistant tracks. The diameters of the outermost and innermost tracks are 16 cm and 1 cm respectively. The
innermost track has got the capacity of 20 MB. The total amount of data which can be stored on the disk if the drive rotates
at constant speed is ______________ MB (integer value only).

{capacity of each track is equal or outermost track has capacity greater than innermost track?? }

track co&architecture

5.192 Virtual Memory: Max size of main memory top gateoverflow.in/33692

why this qs has no effect of two level paging??i dont know if the answer given by madeeasy is right..

virtual-memory co&architecture

Page table entry is nothing but the frame number.

So the number of frames possible is 216.

Frame size = 1024 Bytes

Physical memory supported = number of frames * frame size

= 216 ∗ 1024 = 226 Bytes

= 64 MB

 0 votes -- Sandeep Singh ( 5939 points)

5.193 Virtualgate: Pipelining comparision between two devices_Virtual_Gate


2016 top gateoverflow.in/38683

For D1
1st instruction will take 3+2+4+2+3 = 16ns
rest 99 instruction will take 99*4=396
Hence total: 16+396=412
For D2
1st instruction will take 2+2+2+2+2+2+2+2 = 16ns
rest 99 instruction will take 99*2=198
Hence total: 16+198=214
Hence, 412-214=198 according to me
Where am I going wrong?

co&architecture pipeline virtualgate


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 440 of 2244

u have taken everything right . But u missed that in a pipeline . the clock is set such that the maaximum stage can
complete . so in the starting 1st instruction everything will be 4ns . = 20ns .
20+396 = 416ns
416-216= 202 ns .

 2 votes -- Ravi Singh ( 7303 points)

D1:
k = 100 , 5 stages , Stage Latency = 4ns
Total Time = (k+n-1)*t = (100+5-1)*4 = 104*4 = 416 ns

D2 :
k = 100 , 8 stages , Stage Latency = 2ns
Total Time = (k+n-1)*t = (100+8-1)*2 = 107*2 = 214 ns

Time Saved = 416 - 214 = 202 ns


 1 votes -- Digvijay Pandey ( 26245 points)

5.194 Virtualgate: cycle time (Virtualgate 2016) top gateoverflow.in/34474

An unpipelined processor has got the cycle time of 15 ns. Now the processor is pipelined into three stages and 15 ns is
divided among three stages as
Stage 1: 6 ns
Stage 2: 5 ns
Stage 3: 4 ns
The latch latency is 2 ns. Now the cycle time of new processor will be _______________ ns (integer value only).

I think cycle time should be 6 ns.

Latch latency should not be added in cycle time.

co&architecture pipeline virtualgate

why we didn't add latch latency

 0 votes -- Ankit Solanki ( 47 points)

5.195 Write_through: write through top gateoverflow.in/36252

write_through

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 441 of 2244

5.196 Write_through: Write Through Cache Policy Questions - As per me


answer should be 30, Given as 46 ns ! top gateoverflow.in/28959

Consider a two level memory hierarchy. L 1 (cache) has an accessing time of 10 ns and main memory has an accessing time
of 20 ns. Writing or updating contents into their memory takes 20 ns and 30 ns for L 1 and main memory respectively.
Assume L1 gives misses 80% of the time.
The average writing time for system (in ns) if it uses WRITE-THROUGH technique is ______.

------------------------------------------------------------------------------------------------------------------------------------------------
------------------

Here I think answer should be 30, as in write Through Main Memory is updated no matter what !

Made Easy FLT 6- Practice Test 14

write_through cache-memory cache

Answer should be 30, as in write Through Main Memory is updated no matter what !

 1 votes -- Akash ( 26315 points)

5.197 Write_through: madeeasy CA practice test 11 top gateoverflow.in/36552

Array A contains 256 elements of 4 bytes each. Its first element is stored at physical address 4,096. Array B contains 512
elements of 4 bytes each. Its first element is stored at physical address 8,192. Assume that only arrays A and B can be
cached in an initially empty, physically addressed, physically tagged, direct-mapped, 2K-byte cache with an 8-byte block
size. The following loop is then executed.
for (i = 0; i < 256; i++)
A[i] = A[i] + B[2 ∗ i];
During the execution of the loop, how many bytes will be written to memory if the cache has a write-through policy?

a. 0

b 256

c 1024

d 2048

made-easy test-series co&architecture cache-memory write_through

their are 128 misses for A , containing 2 element each

->256 * 4 = 1024 byte


since it is write through policy(word wise write not block wise)
ans.

 0 votes -- divyanshu ( 11 points)

5.198 General doubt in computer architecture top gateoverflow.in/38925

I want to know whether after executing HALT instruction is PC incremented or not?

co&architecture

Halt instruction when executed change the program counter to it's own address.

 1 votes -- Ravi Singh ( 7303 points)

5.199 Finding transfer time of a sector top gateoverflow.in/33886

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 442 of 2244

Given explanation of the problem:

I couldn't understand why to add average rotational latency. I think that transfer time of sector should be just 6 microsec. If
the same question comes in GATE what should I write?

co&architecture

10000 = 60 seconds

1 round = \fraction6010000seconds

1024 sector = \fraction6010000seconds

1 sector = \fraction6010000 ∗ 1024

 1 votes -- Ravi Singh ( 7303 points)

5.200 Pipeline top gateoverflow.in/33724

give proper explanation.

confusing.
Consider an instruction pipeline with five stages without any branch prediction: Fetch Instruction (FI), Decode Instruction (DI), Fetch Operand (FO), Execute
Instruction (EI) and Write Operand (WO). The stage delays for FI, DI, FO, EI and WO are 5 ns, 7 ns, 10 ns, 8 ns and 6 ns, respectively. There are intermediate
storage buffers after each stage and the delay of each buffer is 1 ns. A program consisting of 12 instructions I1, I2, I3, …, I12 is executed in this pipelined
processor. Instruction I4 is the only branch instruction and its branch target is I9. If the branch is taken during the execution of this program, the time (in ns) needed
to complete the program is :
1. 165
2. 190
3. 215
4.328

All instructions before I4 will be pipelined & then I9-I12 will be pipelined so . Tp = maxt + delay = 11

T = (n1-1+n2-1+2*k)*Tp , n1 is first 3 instruction and n2 is 4 instructions from 9-12 , k is total stages in pipeline

T = (3+4-2+2*5)*11 = 15*11 = 165

 0 votes -- Vikram Bhat ( 587 points)

5.201 Hazard top gateoverflow.in/33723

This Question creates confusion.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 443 of 2244

give its proper explanation...


Selected Answer

yeah,bro..and wrong answer is given by madeeasy.

WAW - 3 I1I2 , I1I5, I2I5

RAW - 4 I1I4 , I1I5 , I2I4, I2I5

WAW - 4 I2I3 , I2I4 , I3I4, I4I5

total = 11..

It will be the right answer.

 1 votes -- Sayantan Ganguly ( 5061 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 444 of 2244

5.202 Please help me out here :- top gateoverflow.in/43961

A byte-addressable memory organized in 32-bit words according to big-endian. A program reads ASCII characters and stores
them in successive byte locations, starting at location 1000. Show the contents of memory words at locations 1000,1004 for
name “ Johnson ” .

Each word has a unique address and we have 32-bit word. So why cant we take 8-bits for each letter and store 4 letters per
word.Thus we need only 2 addresses..

Where am i gng wrong ?

5.203 Find RAW Dependencies top gateoverflow.in/34667

What is correct?

3 RAW dependencies
or

co&architecture

visit :
http://cs.stackexchange.com/questions/47622/read-after-writeraw-hazard

answer = 5 RAW dependencies.

 3 votes -- Amar Vashishth ( 17865 points)

5.204 8085 microprocessor top gateoverflow.in/34493

Consider the following set of instructions executed by 8085 microprocessor MOV H,20 MOV L,10 MOV E,00 XCHG After the
execution, the contents of E register will be ______________ (integer value only).

i dont know how to solve this and


ques. based on 8085 microprocessor can be asked in GATE??

co&architecture

5.205 virtual gate 2016 pipeline top gateoverflow.in/34491

There are two processor M1 and M2. M1 uses four pipeline stages with the delay of respectively stage as 6 ns, 4 ns, 7 ns, 5
ns. M2 has got 7 pipeline stages with the delay of cache stage 4 ns. Then pick the correct option for executing 200
instructions on M1 and M2.

(A) M2 is faster by 600 ns

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 445 of 2244

(B) M2 is faster by 595 ns


(C) M2 is faster by 610 ns
(D) M2 is faster by 513 ns

co&architecture


Selected Answer

for M1 = (4 + (200-1) ) *7 = 1421

M2 = (7 + (200-1) )*4 = 824

so M2 is faster by (1421- 824) = 597 ms

most near ans is B

 3 votes -- Sayantan Ganguly ( 5061 points)

5.206 ugc net top gateoverflow.in/43685

(A) is the correct answer

 0 votes -- srestha ( 11585 points)

5.207 pc increment in cisc instructions top gateoverflow.in/39142

When is incremented value of PC(program counter) available in variable sized instructions?

during decode phase

after instruction execution

during fetch phase

none

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 446 of 2244

During fetch phase, the PC is incremented by one. The incremented value is available after Fetch phase.

 0 votes -- Nishu ( 433 points)

5.208 time top gateoverflow.in/42290

consider a case where 4-segment pipeline with a clock cycle time 20 ns in each sub operation to execute 100 tasks .Assume
that a non pipeline unit that can perform the same operation .Pipeline system will take how much time to complete task?


Selected Answer

Total 100 tasks.


Cycle time = 20 ns
Time taken by Pipeline System = (Number_of_Task + Number_of_Stages - 1) *Cycle_Time
Time = (100 + 4 - 1)*20 ns = 2060 ns

Additional :
Time taken by Non Pipelined System = Number_of_Task * (Cycle_Time*Number_of_Stages)
Time = 100 * 20*4 ns = 8000 ns

Speed Up = (Time taken by Non Pipelined System)/(Time taken by Pipeline System)


Speed Up = 8000/2060 = 3.8835

 3 votes -- Digvijay Pandey ( 26245 points)

5.209 co top gateoverflow.in/34917

A computer has a cache, main memory and a hard disk used for virtual memory. If referenced word is in cache, 20 ns are required to access it. If it is in main
memory but not in cache 60 ns are needed to load it into cache and then reference is started again. If word is not in main memory, 12 ms are required to fetch the
word from disk followed by 60 ns to copy into cache, the reference is started again. The cache hit ratio is 0.9 and main memory hit ratio is 0.6. The average time in
nano seconds required to access a referenced word on this system is ___________.

Solution: 480026


Selected Answer

tavg = .9 * 20 + .1( .6 * (60 +20) + .4 ( 60+20+12000000) ) = 480026 ns.

 1 votes -- Sayantan Ganguly ( 5061 points)

5.210 average memory access time top gateoverflow.in/34222

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 447 of 2244

Caption

4 memory reference per instruction.

total 1000 mem reference

so total instrucions are 250.

now, avg stall/instruction = (misses in L1/instruction )* hit time in L2 + (misses in L2/instruction) * miss penalty in L2

= (150/250)*50 + (100/250)*120

= 78 cycles/instruction

 0 votes -- Sayantan Ganguly ( 5061 points)

5.211 ugc net june 12 top gateoverflow.in/42935

For MUX1 output is z'x+zy'

For MUX2 output is y'(z'x+zy')+xy

F=xy'z' + zy' +xy

= xy+xy'z'+zy'

= x(y+y'z')+zy'

=x(y+z')+zy'

= xy+xz'+y'z

 2 votes -- shivanisrivarshini ( 2067 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 448 of 2244

5.212 ugc top gateoverflow.in/42666

Suppose a processor does not have any stack pointer registers, which of the following statements is true ? (A) It cannot have
subroutine call instruction. (B) It cannot have nested subroutine calls. (C) Interrupts are not possible. (D) All subroutine calls
and interrupts are possible.

The answer Is Option A)


Stack pointer register hold the address of top of stack..
Since in subroutine We need to maintain stack pointer to know from where we have
come and go back to the same place...
So if no SP then No Subroutine

 1 votes -- saif ahmed ( 931 points)

5.213 The bus which is used to transfer data from main memory to
peripheral device is top gateoverflow.in/42602

The bus which is used to transfer data from main memory to peripheral device is
a) data bus
b) input bus
c) DMA bus
d) output bus

Ans (A)Data bus

a) data bus used to carries data which needs processing

b) same as data bus

c)DMA bus contains both . data bus and address bus. Here CPU collect memory address via address bus

d)same as data bus

 0 votes -- srestha ( 11585 points)

5.214 ugc net dec 12 top gateoverflow.in/42659

In an enhancement of a CPU design,


the speed of a floating point unit has
been increased by 20% and the speed
of a fixed point unit has been increased
by 10%. What is the overall speed
achieved if the ratio of the number of
floating point operations to the number
of fixed point operations is 2 : 3 and
the floating point operation used to
take twice the time taken by the fixed
point operation in original design ?
(A) 1.62
(B) 1.55
(C) 1.85
(D) 1.285

http://gateoverflow.in/790/gate2004-it_50 follow link

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 449 of 2244

 0 votes -- Anirudh Pratap Singh ( 4091 points)

5.215 ugc net dec12 top gateoverflow.in/43110

Option D

 0 votes -- shivanisrivarshini ( 2067 points)

5.216 Pipeline problem top gateoverflow.in/34095

A 5 stage pipelined processor has instruction fetch (IF), operand fetch (OF). Instruction decode (ID), perform operation (PO)
and Write operand (WO) stages. The IF, ID, OF and WO stages takes 1 clock cycle each for any instruction. The PO stage
takes 1 clock cycle for ADD and SUB instruction, 2 clock cycles for MUL instruction and 4 clock cycles for DIV instructions
respectively. The number of clock cycles needed to execute the following sequence of instruction is ________.

In the explanation they have mentioned in this way :

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 450 of 2244

Now , my question is , Here I 1 and I 2 are dependent , so how can they start without any stall , no operand forwarding is also
mentioned.

co&architecture

Yes for I 2 5,6,7 should be a stall.It should have been - or a implicit NOP[no operation] .

 1 votes -- bahirNaik ( 2479 points)

5.217 minimum no. of tables required in M:N relationship among 2 entity


sets satisfying 3NF top gateoverflow.in/39143

if there is one to many relationship from entity set A to B; B has simple primary key and a multivalued attribute, then min
no. of tables satisfying 3NF?

4 tables 2 for entity one for relation one additional for multivalueed attribute

 1 votes -- Pooja ( 22773 points)

5.218 What will be the size of memory address space for a 16 bit data and 20
bit address bus? top gateoverflow.in/42603

What will be the size of memory address space for a 16 bit data and 20 bit address bus?
a) 1 MB
b) 64 KB
c) 2 MB
d) None of these

20 bits address bus

So, 2^20=1MB external memory

 0 votes -- srestha ( 11585 points)

5.219 Number of bits top gateoverflow.in/39234

A computer system has a main memory consisting of 1 M 16 bit words. It also has a 4 way set associative cache of size 4 K
words and 64 words per block. The number of tag bits are _______.

co&architecture

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 451 of 2244

log((2^20)/(2^12/2^2))

ans should be...10 bits

 0 votes -- Gabbar ( 469 points)

5.220 doubt top gateoverflow.in/34026

what is the meaning of below line ??

1 MB 16-way set associative virtually indexed physically tagged cache(VIPT).

co&architecture

Excellent resource to study for this :


http://www.dauniv.ac.in/downloads/CArch_PPTs/CompArchCh10L09CachesandVirtualMemory.pdf

Short version : virtually indexed means that you are determining the set number using the virtual address, and physically
tagged means that the TAG bits are used for determining the hit.

 0 votes -- Utk ( 1385 points)

5.221 Cache block size=16 words,set size=2blocks,no of sets=128,noof bits


in word=32bit top gateoverflow.in/39293

Cache block size= 16 words

Set size=2 blocks

No of sets=128

No of bits in words=32bits

Cache access time=20ns

5.222 ADVANCED PIPELINE top gateoverflow.in/43188

Advanced Pipeline topics Like, collision vector,Forbidden Latency etc to be covered totally from which book??

how is hanesey,patterson for this?

what I know is the question which has been asked in previous gate as well as this year
is from the basic Pipelining concepts such as Speedup,throughput,Number of cycles ,
frequency etc....

 1 votes -- saif ahmed ( 931 points)

5.223 multilevel paging technique top gateoverflow.in/43624

A virtual memory system is able to support virtual address space of 256 GB. An entry
in the page table is 4 bytes long.
(i) Calculate the minimum page size required for a three-level paging scheme.
(ii) Draw a diagram indicating how the bits of a virtual address will be interpreted by
the address translation mechanism. Indicate which bits (and how many) are used to
index the page tables at each level, and which bits form the page offset for the case

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 452 of 2244

above.

co&architecture


Selected Answer

Let size of a page be 2 P bytes - requires P bits for addressing.


Page Table Entry Size (PTES) = 4 Byte
Logical Address Space = 256 GB = 238 B

Size of page table = (LAS/page size)*PTES

Size of 1st level page table = (2 38 /2​P​ )*4


Size of 2nd level page table = (238 /2​2P
​ )*42
Size of 3rd level page table = (238 /2​3P
​ )*43

Size of 3rd level page table should occupy in one page.

(238 /2​3P
​ )*43 <= 2P
244 <= 24P
P >= 11 bit

Size of page = 2 P =211 B = 2KB

 2 votes -- Digvijay Pandey ( 26245 points)

5.224 made easy co test series top gateoverflow.in/38005

Given Ts : Transfer time.


b : Number of bytes to be transferred.
N : Number of bytes on a track.
r : Rotational speed.
Which of the following expression gives the total average access time?

5.225 instruction set top gateoverflow.in/37240

Consider the hypothetical processor which has 256 words memory. A 19 bits instruction is placed in 1 memory cell. It supports
2-address, 1-address and 0-address instructions. It uses expanding opcode technique. If there exist five 2-address instructions
and 760 1-address instructions, then number of 0- address instructions are _______.

co&architecture


Selected Answer

We have 19 bits for an instruction giving 219 possible encoding.

No. of encoding for 2 address instructions = 5 × 28 × 28 ∵ two 8-bit address fields = 5 × 216.

No. of encoding for 1 address instructions = 760 × 28 ∵ one 8-bit address field.

So, number of possible 0-address instructions

( )
= 219 − 5 × 216 − 760 × 28 = 28 211 − 5 × 28 − 760 = 28 (2048 − 1280 − 760) = 28 × 8 = 211 = 2048.

 5 votes -- Arjun Suresh ( 124125 points)

Here 19 bit instruction format.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 453 of 2244

There 256 words in memory and implicitly given one word is 19 bit and memory is word addressable.
So, to address memory there require 8bits.

3bit- 8bits- II
opcode 8bits- I address address

Type 2 address=5
Type 1 address=(23-5)*28 =3*256=768-8(this remain 8 addresses can used for type 0 instruction)= 760

Type 0 address=8*2 8=2048 addresses


 2 votes -- Avdhesh Singh Rana ( 1509 points)

5.226 program counter top gateoverflow.in/36419

5.227 Choosing most suitable partition allocation algorithm for variable


partitioning top gateoverflow.in/37221

Given answer: C. Please explain

co&architecture

5.228 CACHE INDexing1.1 top gateoverflow.in/37171

Consider a 32 bit microprocessor that has an on chip 16 Kbyte four way set associative cache. Assume that cache has a size
of four 32 bit words. The set number in the cache to which the word from memory location FFFAE8FA is mapped is
_________.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 454 of 2244


Selected Answer

Number of cache sets = 16K / (4 * 4 * 32 / 8) = 256.

Consecutive memory blocks will be mapped to consecutive cache sets (from left end, after offset bits we have index bits).
Here we have word addressing as question asks for "word at location". So, number of offset bits = 2. So, next 8 bits are
index bits. i.e., 8FA (top part of address won't affect the set) = 1000 1111 10 | 10

which will be 62.

 1 votes -- Arjun Suresh ( 124125 points)

5.229 made easy test series top gateoverflow.in/37300

Consider a pipelined processor with the stages IF, ID, EX and WB. IF, ID and WB. Stages takes one clock cycle each to
complete the operation and EX stage depends on the instruction. ADD and SUB need 1 clock cycle. MUL and DIV need 3
clock cycles each. What is the number of cycles needed to execute the following sequence of instructions?

(Assume there is no hardware to reduce stalls)

10
11
12
13

ya answer should be 11

 0 votes -- Gate Aspirant ( 23 points)

5.230 Lru tech(set associativ memory) top gateoverflow.in/37302

Consider a fully associative cache with 6 cache blocks (0 to 5) and the following sequence of memory block requests:
5, 4, 29, 18, 21, 7, 25, 18, 16, 35, 45, 22, 7, 16
If LRU replacement policy is used, which cache block is used for memory block 16? Assume initially 6 blocks are placed in a
cache according to lexicographic order of cache index.

explain in detail...

16 ll be in Block 1

0- 5-25(5 ll be replaced by 25)

1-4-16

2-29-35

3-18-7

4-21-45

5-7-22

 0 votes -- Richa ( 131 points)

5.231 Pipelining1.1 top gateoverflow.in/37481

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 455 of 2244

For an unpipelined multicycle CPU clock cycle time = 10 ns. Memory operation, branch operation and ALU operations with
instruction frequencies 40%, 20% and 40% respectively. If pipelining adds 2ns to the CPU cycle time then what is speed up
in instruction executing from pipeline (assume each operation take 5 cycles)


Selected Answer

speed up=50/12

=4.16

 1 votes -- Pooja ( 22773 points)

5.232 computer organisation top gateoverflow.in/37426

5.232 What can I deduce if its given that the processor is 32 or 64-bit
processor? top gateoverflow.in/36040

co&architecture

For 64 bit processor, I think the processor can deal with 64 bits simultaneously or perform operations on 64 bits
simultaneously. This speaks mostly about ALU.

 1 votes -- Sushant Gokhale ( 51 points)

5.232 Which devices should get higher priority in assigning interrupts? top
gateoverflow.in/36211

5.233 MEMORY CONCEPT---ME GATE MOCK 1 top gateoverflow.in/37070

A main memory has 4096 blocks each consisting of 128 word of 32 bit. memory is word addressable.The number of bits
require for main memory adress is_____________

I did as 4096 block=12 bit

128 word=7 bit

each word 4 byte=2 bit 19+7+2=21 bit

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 456 of 2244

but answer given as 12+7=19 bit WHY SO?

is it beacuse of the term word adressable

My Answer is

Given is Word addressable then why to convert it into bytes its just 2 12 * 27 = 219

so the number of bits are 19

if its byte addressable and given in words then we convert word to byte

 1 votes -- shivanisrivarshini ( 2067 points)

5.234 CACHE CONCEPT------ME GATE MOCK1 ----URGENT HELP NEEDED top


gateoverflow.in/37069
Assumr computer has MAin Memory consisting 1 M 16 bit word.It has also a 4-way set assosiative cache of 4K
word and 64 word per block.the number of tag bits are-------------

Ans: given as 4K word/(64 x 2 byte) word = 32 number of blocks and then continued.....

my question is if 64 word is multiplied with 2 byte then why not 4K word also??

i did it like (4Kx2)/(64x2) please explain it

You are right there approach is wrong : there should be 64 blocks

 0 votes -- Sumit1311 ( 641 points)

5.235 Consider 1 Ghz clock frequency processor , uses different operand


accessing models shown below top gateoverflow.in/36684

My question is : in the last indexed instruction , will it not be this way :

1 Memory Access + 1 Arithmetic computation + 1 Memory access = 2 + 3 + 2 = 7 clock cycles ?

co&architecture


Selected Answer

for operand fetching (i.e. instruction is present in IR) in indexed mode Effective address= [BaseRegister]+ [Index Register]

and then data =[Effective Address]

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 457 of 2244

therefore 1 reg reference + 1 arithmetic operation + 1 Memory reference i.e. 1+3+2

 1 votes -- Abhishekcs10 ( 1001 points)

5.236 Register Overflow top gateoverflow.in/36899

Consider the addition of the two numbers 10001110 and 10000000 in an 8-bit ALU. Which of the following best summarizes
the result and the status of the Z(zero), S(sign), C(carry) and O(overflow) flags? Assume that the numbers are represented
in 2's Complement format and that

when you will add the given two numbers , the status of the flag will be ZERO FLAG-: 0, bcoz after addition the ALU
output(acc) is not zero so flag will be reset

SIGN flag-: 0, bcoz MSB bit is not 1 after addition so it will reset

CARRY flag-: 1, bcoz there is an extra bit out of the MSB so flag will be set.

OVERFLOW flag-: 1, bcoz their is a carry out of the MSB ,but not in the MSB so flag will be set

10001110

10000000

........................

00001110(output with carry 1)

 1 votes -- amit ambastha ( 37 points)

5.237 co top gateoverflow.in/36820

the three outputs x1x2x3 from the 8x3 priority encoder are used to provide a vector address of the form 101x1x2x300. what
is the second highest priority vector address in hexadecimal if the vector addresses are starting from the one with the
highest priority

1 0 1 X1 1 0 0 0

 0 votes -- Sushant Gokhale ( 51 points)

5.238 cache write policies..urgent* top gateoverflow.in/36756

The cache memory hit ratios for read and write operations are 80% and 90% respectively.
If there is a miss then 2 word block is to be through from main memory to cache.
Consider 30% updations and the cache access time is 20ns/word and memory access time 100 ns/word. Then calculate the
efficiency of write back and write through scheme

5.239 ques-1 top gateoverflow.in/36906

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 458 of 2244

hi all! i am not able to understand why one extra stall is used after WB and EX of second and third instruction..plllzzzz
help..above is the question and its solution.

yes ; you are right .. it has 12 cycles without bypassing and 9 with bypassing...

see this....

http://gateoverflow.in/34735/pipelining-without-operand-forwarding

 0 votes -- Kapil Phulwani ( 51 points)

5.240 cache miss top gateoverflow.in/36913

5.241 Question on calculating return address top gateoverflow.in/36602

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 459 of 2244

Given explanation:

I read somewhere that PC value is not incremented when HALT instruction is executed so I guessed the answer to be 1024.
Please check whether my understanding is correct?

co&architecture

5.242 madeeasy-test COA Adv : Practice Test - 27 q-11 top gateoverflow.in/37056

The format of a double operand instruction of a CPU consist of 4 bit op-code and 4 bits for source and destination. 12 double
operand instructions and 24 single operand instructions must be implemented. Op-code field must identify the three groups
of n-operand instructions. Calculate the total number of zero operand instructions that can be implemented?

co&architecture made-easy test-series

There are total 2^4 = 16 starting nibble value for all instructions, Out of these there are 12 reserved for 2 operand
instructions , for 1 operand instruction we can use 8 bit opcode and 4 bit operand so 24 instructions can be made by 2
values in first nibble and 2^4 bits in second which 2^5 > 24 . So you can only assign 2 values in first nibble for zero
operand instructions and 2^8 values for remaining bits so that total number zero operand instuctions are 2^9 = 512

 1 votes -- Vikram Bhat ( 587 points)

5.243 hit ratio top gateoverflow.in/36916

a byte addressable computer has a small data cache capable of holding eight 32 bit words.Each cache block consists of two
32 bit words.For the following sequence of addresses( in hex), the hit ratio if the two way set associative LRU cache is used
is....

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 460 of 2244

200,204,208, 20C,2F4,2F0,2F4,2F0,21C,218,21C

3/11

 1 votes -- Sushant Gokhale ( 51 points)

5.244 cache miss top gateoverflow.in/36914

5.245 What is hit ratio? (including read and write) top gateoverflow.in/37588

In a system, integer has size of 4 bytes. The system have 1024 KB set associative cache with associativity equal to 2 and
block size of 32 bytes. Consider the program below. Assuming that initially A was not present in cache, cache hit ratio is ____

for(int i = 0; i < 64; i + + )

A[i] = A[i]+2;
A[i + 1] = A[i]+3;


Selected Answer

Size of one Block = 32B = 8 Integer

1 miss for 8 'i' value.


Total 8 miss for 64 i values..
1 more miss for A[64] ..

Miss Ratio = 9/64


Hit Ratio = 55/64

 0 votes -- Digvijay Pandey ( 26245 points)

5.245 Difference between simultaneous and hierarchical memory access with


formula? When to apply which one? top gateoverflow.in/37639

5.246 Storage on tapes top gateoverflow.in/35025

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 461 of 2244

Consider a tape of length 4m containing 80 parallel tracks and moving with a linear velocity
of 32cm/sec and it employs the recording density of
512 KB/cm-track. If the tape is divided into records of size 8cm and length of the gap
between the records is 2cm, then calculate effective data transfer time.

To calculate effective data transfer rate,do we need to consider the entire length(i.e 32cm) or only recording length? i.e ( for
every 10 cm,recording length is 8cm,hence for 32 cms recording length will be 26cm)

5.247 Speedup top gateoverflow.in/35073

my ans 2.64


Selected Answer

I am also getting 2.66

speed up = ET nonpipe/ETpipe

= 4 * (Clock time in non pipe)/ 1 Clock time in pipe

= (4 */3G) / (1/2G)

= 8/3

= 2.66

 2 votes -- Sandeep Singh ( 5939 points)

5.248 pipeline cycles top gateoverflow.in/35074

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 462 of 2244

IF ID EX MA WB LOAD
IF ID EX MA WB LOAD
IF ID - - EX MA WB ADD
IF ID - - - - EX MA WB SUB

IS THIS CORRECT ?

 0 votes -- Parimal Andhalkar ( 1311 points)

5.249 average access timr top gateoverflow.in/38215

the memmory access time is 1 nanosecond for a read

operation with a hit in cache, 5 nanoseconds


for a read operation with a miss in cache, 2 na
noseconds for a write operation with a hit in cache
and 10 nanoseconds for a write operation with a
miss in cache. Execution of a sequence of
instructions involves 100 instruction fetch opera
tions, 60 memory operand read operations and 40
memory operand write operations. The cache hit-ratio
is 0.9. The average memory access time (in
nanoseconds) in executing the sequence of instructions is __________.

5.250 DMA top gateoverflow.in/38223

a 8 bit DMA is operating in cycle stealing mode.each DMA cycle is of 6 clock states and DMA clock is 2MHz if the cpu cycle
takes 2microsecond what would be DMA data transfer rate?

co&architecture

5.251 made easy top gateoverflow.in/38259

they have not given the number of cycles taken by ADD/LOAD..i have taken as 1..correct if i am wrong

The following sequence of instruction is executed in a basic 5 stage pipelined processor ( S1, S 2, S 3, S 4, S 5). Assume that

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 463 of 2244

data dependency present in the program is resolved by operand forwarding techniques. Load instruction output present in 4th
stage ALU instruction output is available in 3rd stage. Assume each stage take 1 cycle.

What is the number of cycles are saved by using operand forwarding.

made-easy test-series


Selected Answer

i can't upload my answer here due to maximum answer lenght. plz check here and comment here only if u find anything
wrong
https://docs.google.com/document/d/1KQVugaIWSz_OIPUFeEFkH6uQlRzSJOIWwqx5r8Tccqg/edit?usp=sharing

 1 votes -- Ravi Singh ( 7303 points)

5.252 made easy top gateoverflow.in/38389

Consider 1 GHz clock frequency processor, uses different operand accessing models shown below:

Assume that 2 memory cycles consumed for memory reference, 3 cycles consumed for arithmetic computation and 1 cycle
consumed when the operand is in register(s) instruction itself. The average operand fetch rate (in million words/sec) of
processor is __________ (upto 2 to decimal places).(ANSWER-344.82)

made-easy test-series


Selected Answer

Register-1 reg reference required -1Cycle

Immediate-1Cycle

Direct-1 mem ref-2 Cycle

Memory Indirect-2 mem ref-4 Cycle

Indexed-1 reg ref,1 arith,1 mem-6 Cycle

Total clock cycle for 1 instruction:-0.1*1+0.2*1+0.3*2+0.2*4+0.2*6=2.9 cycle

Time req for 1 instruction= 2.9*10^9 (Since CPU is 1 GHZ) ==2.9 nano sec

1 instruction----2.9 nano sec

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 464 of 2244

#instruction? in 1 sec= 1/2.9*1000=344.82MIPS

 4 votes -- Ankesh Gautam ( 665 points)

5.253 interrupt top gateoverflow.in/34948

consider a system employing interrupt driven input /output for a particular device..that transfers at avg of 16Kb/s on
continuous basis.assume interrupt pricessing takes 50us(jump to interrupt processing routine execute it and return to main
program ) . Find the fraction of processor time is consumed by this input output device if it is interrupted for every byte

5.254 RAW hazard top gateoverflow.in/35004


Selected Answer

(1,2)

(1,3)

(2,3)

(2,4)

(3,4)

so as per me too 5

 2 votes -- Vertika Srivastava ( 273 points)

5.255 miss ratio top gateoverflow.in/35009

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 465 of 2244

I guess its like

Let y is cache miss ratio

40= 150y+ (1-y)50

Solving it u will get y= .10 so In % it is 10

 1 votes -- Khushboo Tak ( 1961 points)

5.256 No of Cycles top gateoverflow.in/38054

5.257 Computer Arch. top gateoverflow.in/35126

Given a 32 bit processor with 16 MB main memory, 32 KB 4 way set associative on chip cache and block size of 16 words,
The number of tag bits in memory address format are : ?

Here we will take the length of instruction as 32 bits or 24 ? Why ?

co&architecture

32 bit processor means vitual address 32 bits

main memeory or physical address is 2^24 that is 24 bits

32 KB 4 way set associative on chip cache and block size of 16 words

block size of 16 words = 2^4 (here i have a doubt ,in this qs word size is not given,should i take standard word size 4 B..then block size will be 64 B,then 2^6)

cache size = 2^15

no of blocks = 2^9

no of sets = 2^9 /4 = 2^7.

so tag bits = 24 - 6- 7 =11 (considering word size as 4 B...dont know i am right or wrong)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 466 of 2244

 0 votes -- Sayantan Ganguly ( 5061 points)

5.258 concurrent top gateoverflow.in/37882

Distinct values of y is 3 y ={2,3,4}

 0 votes -- Khushboo Tak ( 1961 points)

5.259 what is valid PC after execution of these instruction top gateoverflow.in/35906

Consider the following program segment:

Instruction Meaning Size (words)

I1 LOAD r0, 500 2

I2 MOV r1, r0 1

I3 ADD ro, r1 1

I4 INC r0 1

I5 INC r1 1

I6 ADD r0, r1 1

I7 Store r1, 2

I8 Halt Stop 1

Assume that memory is word addressable with word size 32 bits. Program is loaded into memory location (3000) 10 onwards.
The value of PC at the end of execution of above program is _____

5.260 Dram refreshing top gateoverflow.in/37872

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 467 of 2244

time required for refresh in ms 4


refresh interval in ms 133 ∗ 106
Refresh overhead = length of refresh cycle = = 30nstime required for refresh = (length of refresh cycle) ∗ (rows) = (30 ns) ∗ (8K

ref : https://en.wikipedia.org/wiki/Memory_refresh

 1 votes -- prathams ( 1141 points)

5.261 cache write thru top gateoverflow.in/37834

WHY hit ratio is 1.

in average read time why hasn't the cache time been added to the main memory time in case of miss?

5.261 Decoder top gateoverflow.in/35603

5.262 number of time cycles required top gateoverflow.in/35589

Assume a simple 5 stage pipeline (IF, ID, DF, EXE, WB) each stage takes a single cycle. How many cycles the following code
takes to execute. If there is no special hardware to improve the performance in presence of hazards?

I1 MOV A, C ; A ← C

I2 MOV B, C ; B ← C

I3 ADD A, B ; A ← A+B

I4 MOV C, A ; C ← A

I5 MOV D, C ; D ← C

I6 MOV A, D ; A ← D

5.263 co top gateoverflow.in/38007

The format of a double operand instruction of a CPU consist of 4 bit opcode


and 4 bits for source and destination. 12 double operand
instructions and 24 single operand instructions must be implemented.
Opcode
field must identify the three groups of noperand
instructions.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 468 of 2244

Calculate the total number of zero operand instructions that can be


implemented?

answer given as -512

dnt knw about answer want ur option with correct explanation

5.264 Calculating average number of cycles per operand fetch top gateoverflow.in/36808

Solution:

The solution given doesn't look correct please check

co&architecture

5.265 geeksforgeeks mocktest top gateoverflow.in/37989

Consider register reference instructions.

Which one of the following is true:

A) First 12 bits (0 – 11) specify register operation, last 4 bits (12 – 15) are always 1111

B) First 11 bits (0 – 10) specify register operation, last 5 bits (11 – 15) are always 01111

C) First 12 bits (0 – 11) specify register operation, last 4 bits (12 – 15) are always 0111

D) First 4 bits (0 – 3) are always 0111, last 12 bits (4 – 15) specify register operation

5.266 cache_average access time question top gateoverflow.in/35586

Hit ratio of the cache memory read request is 85% and the cache memory is 5 times faster than main memory. Block size in
memory organization is 4 words. The access time of the main memory is 72 ns per word. Write through protocol
(simultaneous memory organization) is used in the system. CPU generates 60% of the read requests to read the data and
the remaining for write operation. What is the average access time (in ns) of the memory when considering both read and
write operations?

Average time to read is = 0.6 *(0.85*57.6 + 0.15*(288)) since an entire block is transferred so 72*4=288..

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 469 of 2244

Average time to write=0.4*72 ns

So average access time is = Average time to read+ avg time to write.. (U calculate )..

 0 votes -- Ritaban Basu ( 255 points)

5.267 Pipelining_ques top gateoverflow.in/34939

Consider 5 stage pipeline which allow all instructions except branch instruction. Program contain 30% conditional instructions
out of which 75% are branch instruction. Processor stop fetching the following instruction after the branch instruction untill
target address is available. Target address is available at the end of the pipeline stage.
All the stages are perfectly balanced with 20 GHz clock time. The processor is running with rate of ____________ (in MIPS).

Ideal CPI = 1

CPI increase due to stall [4stalls due to branching]= 0.30*0.75*4=0.9

Throughput =Clocks per second / [IdealCPI + increase due to stall]

20∗ 109
1 +0.9
= 10526.31 * 10^6 hence 10526 MIPS

 2 votes -- bahirNaik ( 2479 points)

5.268 Cache memory(made easy) top gateoverflow.in/28536

During a program execution out of 1000 memory references there are 250 and 120 misses in L1 (Level1) and L2(Level2)
caches respectively. Hit times for L1 and L2 cache are 24 and 40 cycles respectively. If there are 2.5 memory references per
instruction, how many average stall cycles per instruction? (Assume L2 to memory miss penalty is 250 cycles)?

a)50

b)100

c)150

d)200


Selected Answer

Average stall/instr. = Misses in L1/instruction * Hit time of L2 + Misses in L2/instruction * Misspenalty in L2

no of instruction = 1000/2.5 = 400.

so, Average stall/instruction = 250/400 * 40 + 120/400 * 250 = 100.

option B is answer.

 1 votes -- Sayantan Ganguly ( 5061 points)

5.268 in non pipeline processor is it necessary to consider buffer delay. top


gateoverflow.in/13426

buffer delay is called as interface delay .if in the question they have mention the buffer delay than we have to consider it.
and usually it is used between two stages to hold the intermediate result..

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 470 of 2244

 0 votes -- kunal chalotra ( 3567 points)

5.269 solve dma top gateoverflow.in/12549

Consider a system in which cycle takes 500 ns. Transfer of bus control
in either direction, from processor to I/O device or vice versa, takes 250
ns. One of the I/O device has a data transfer rate of 50 kB/s and
employees DMA. Data are transferred one byte at a time. For how long
(in ms) would the device tieup
the bus when transferring block of 128
bytes.??


Selected Answer

Device set up time 500ns..

Time to transfer 128 byte = 128/50*1024 s = 1/400 s = 2.5 Milli second

Transfer time (in milli second) >>> Setup time (in nano second) // ignore setup time

Total time = 2.5 Milli second

 1 votes -- Digvijay Pandey ( 26245 points)

5.270 co top gateoverflow.in/12090

a computer system that uses memory mapped IO configuration ,has 32 bit address space Address with 1's in the two MSB
refer to devices.WHAT is the MAximum amount of memory IO device and port address that can be referenced in such a
system respectively

1 3*2 30 and 1*2 30

2 1*2 30 and 3*2 20

3 2*2 20 and 1*2 20

4 3*2 32 and 1*2 32

i am solving in this way plzz check ...!

32 bits are there

two MSB bits

means

00

01

10

11

now they say 11 bits refer to devices option C AND D cannot be the answer ,so answer should be in between A and B

now port address is that which is connected to devices and that bits is 11 so 1* 2 30 and rest left as 00 ,01, 10 means 3*230

 1 votes -- kunal chalotra ( 3567 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 471 of 2244

5.271 dependency top gateoverflow.in/13483

co&architecture

Data dependency means READ AFTER WRITE hazard.

Here is (R1 in ADD + R1 in SUB ) + (R2 in SUB and same R2 in MUL). So two DATA dependencies.

 1 votes -- Digvijay Pandey ( 26245 points)

5.272 coa top gateoverflow.in/13484

Hit ratio of the cache memory read request is 85% and the cache memory is 5 times faster than main memory. Block size in memory
organization is 4 words. The access time of the main memory is 72 ns per word. Write through protocol (simultaneous memory
organization) is used in the system. CPU generates 60% of the read requests to read the data and the remaining for write operation.
What is the average access time (in ns) of the memory when considering both read and write operations?

co&architecture

Average Memory Access Time = 0.6 * Avg. time for read + 0.4 * Average Time for write

Main memory access time = 72 ns per word

Cache access time = Main memory access time/5 (Given in question) = 14.4 ns

Avg. time for read = 0.85 * 14.4 + 0.15(14.4+ * 72 * 4) (On a cache miss entire cache block is taken from main
memory)

= 57.6 ns

(simultaneous memory organization is given in question for writing as all writes are going to memory irrespective of
cache hit/miss. So, we can assume read is hierarchical access though it won't change the answer much)

Avg. time for write = 72 ns (No need to update the whole cache block- we are given main memory access time per word
meaning a word can be directly accessed and there is no point updating the whole block in write through cache)

So, Average memory access time = 0.6 * 57.6 + 0.4 * 72 = 63.36 ns

 0 votes -- Arjun Suresh ( 124125 points)

5.272 Give me the formula for write back and write through ( avg access
time ) in both parallel and serial top gateoverflow.in/14480

WRITE THROUGH

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 472 of 2244

On a write, memory and cache are often updated simultaneously (usually this will be specified in question) and so write
time will be memory access time for a word. On a cache miss, usually only memory is updated (no write allocate policy).

On a read, a cache block is retrieved from memory and hence the read time on cache miss will be the time to bring a block
from memory plus cache access time on hierarchical access and just the memory access time for a block, if both memory
and cache can be accessed in parallel.

So,

For hierarchical access and write-through:

Tread = H × Tcache + (1 − H) × (Tcache + Tmemory_block) = Tcache + (1 − H) × Tmemory_block

For simultaneous access and write-through:

Tread = H × Tcache + (1 − H) × (Tmemory_block)

Due to hit rates being larger and cache being much faster, the above 2 times are almost the same.

Hierarchical access and write-though case for memory write is actually not present in practical as since memory
is always accessed in case of write through, it makes sense to provide simultaneous write to cache and memory.

For simultaneous access and write-through:

Twrite = Tmemory_word

​Notice that on write, a word is being updated and on read a block is retrieved from memory.

WRITE BACK

In a write-back cache whenever a cache block is replaced, if it is dirty, then that block is written back to memory. So, this
is an overhead on all cache misses. Write Back, policy usually follows write-allocate- i.e., on a cache miss during write, the
corresponding memory block is brought from memory to cache.

For hierarchical access and write-back:

Tread = Twrite = H × Tcache + (1 − H) × (Tcache + Tmemory_block + Twrite_back) = Tcache + (1 − H) × (Tmemory_block + Twrite_back), where Twrite_back = x × Tmemory

For simultaneous access and write-back:

Tread = Twrite = H × Tcache + (1 − H) × (Tmemory_block + Twrite_back), where Twrite_back = x × Tmemory_block, where x is the fraction of dirty blocks

Ref: http://web.cs.iastate.edu/~prabhu/Tutorial/CACHE/interac.html

 4 votes -- Arjun Suresh ( 124125 points)

5.272 I1 : Load R0,3(R1) I2:Sub R3,R0,R4 I3: Mul R5,R0,R6 I4: Div R7,R0,R8
.How many cycles are needed to complete above instruction using RISC
pipeline, where all stages take 1 cycle top gateoverflow.in/14253

IF :instruction fetch

ID :instruction decode

EX : execution

MA: memory access

WB: write back

I1:Load R0,3(R1)

I2:Sub R3,R0,R4

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 473 of 2244

I3: Mul R5,R0,R6

I4: Div R7,R0,R8

1 2 3 4 5 6 7 8 9 10 (cycle)
I1 IF ID EX MA WB
I2 IF ID ----------- EX MA WB
I3 IF ID EX MA Wb
I4 IF ID EX MA WB

so 10 cycles required..

 2 votes -- kunal chalotra ( 3567 points)

5.273 Consider a system such that the number of clock cycles for a polling
operation (including transferring to the polling routine, accessing the device
and restarting the user program) is 400 cycles, and that the processor
executes with a 500 MHz clock. Determine the fraction of CPU consumed
when the mouse must be polled 30 times per second. •0.002 % •0.02 %
•0.2 % •None of these top gateoverflow.in/13606

Consider a system such that the number of clock cycles for a polling operation (including transferring to the polling routine,
accessing the device and restarting the user program) is 400 cycles,
and that the processor executes with a 500 MHz clock. Determine the fraction of CPU consumed when the mouse must be
polled 30 times per second.

•0.002 %
•0.02 %
•0.2 %
•None of these

co&architecture

Number of cycles per second required=30 times per second *400 cycles per polling operation =12000 cycles per sec

FractFraof cpu consumed=(required frequency /cpu frequency) *100=12000/500×10^6

=0.0024

Correct answer is 0.002% or 0.0024%

 0 votes -- Anurag Semwal ( 4775 points)

5.273 difference between external interrupt and i/o interrupt top gateoverflow.in/12043

I think there's no difference between the two. See http://www.cs.umd.edu/class/sum2003/cmsc311/Notes/IO/extInt.html


and search for external interrupt.

 0 votes -- lowOnATP ( 135 points)

5.274 COA top gateoverflow.in/11906

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 474 of 2244

assume that memory is BYTE addressable with word size of 32 bits.the program has been loaded in memory 300(decimal)
onwards. if an interrupt occured during the execution of HALT instruction which is stored at 328.what will be the return
address pushed on to the stack

1 332

2 328

3 324

4 none

It is mentioned during the execution of Halt instruction, so the instruction execution must be restarted and the return
address must be 328 for the interrupt.

For completed HALT instruction, the return address must be 328 + 4 assuming size of HALT instruction is one word- 4
bytes.

Ref: http://x86.renejeschke.de/html/file_module_x86_id_134.html

 0 votes -- Arjun Suresh ( 124125 points)

5.275 calculate hit... top gateoverflow.in/11214

ques..

A CPU has a 32 KB direct mapped cache with 128 byte-block size. Suppose A is two dimensional array of size 512×512 with
elements that occupy 8-bytes each. Consider the following C code segment initially the array is not in cache and i ,j ,x are
in registers than calculate the hits_____________?

for (i=0; i<512; i++)


{
for (j=0; j<512; j++)
{
x +=A[i] [j];
}
}

solution : plz check..if wrong...!

cache size is 32 kb

no of lines in cache = cache size/block size

=28

=256

each element is 8 bytes..

block size =128 bytes

no of elements in one block=128/8

=16(i.e 16 elements in one block)

for c code array is stored in main memory in row major order...

no of rows are 512..and no of elements in each row are 512 therefore no blocks needed to store 1 row elements is 32
blocks...

now these 32 blocks are going to be direct mapped from main to cache memory as there are 16 elements in one block, first
element in the block will be miss and rest 15 elements will be hits.means when one block is mapped to cache then there will
be 1 miss and 15 hits..

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 475 of 2244

for 32 block there will be 32*15 hits i.e 480 hits and there are 512 rows therefore no fo hits will be 512*480=245760 hits

http://gateoverflow.in/1854/gate2006_80-81

 0 votes -- Arjun Suresh ( 124125 points)

5.276 instruction cycle top gateoverflow.in/11193

question

A microprocessor provides an instruction capable of moving a string of bytes from one area of memory to another. The
fetching and initial decoding of the instruction takes 10 clock cycles.Thereafter, it takes 15 clock cycles to transfer each
byte.The microprocessor is clocked at a rate of 10 GHz.

a. Determine the length of the instruction cycle for the case of a string of 64 bytes.

b.What is the worst-case delay for acknowledging an interrupt if the instruction is non interruptible?

c. Repeat part (b) assuming the instruction can be interrupted at the beginning of each byte transfer.

solution.

correct me ...

fetch and decoding takes 10 cycles..

and thereafterfor each byte transfer takes 15 clock cycles..

INSTRUCTION cyle =FETCH cycle +execution cycle

=10+15*64(as in ques they said 51 for each byte)

=970 (clock cyle)

(b) as in b part they say instruction is non interruptable ...means whenever the interupt will occur during the execution oh
this instruction than it will not service it..bcoz due to non interruptable..so it will return control to interrupt when the current
instrunction will finish and it will be finished after 970 cycles

so delay wiil bo of 970 clock cycle..

(c)

in this part also it wiil be delayed for 970 clock cycle becoz control to interrupt will be given when the current instrunction
will over and i will over after 970 clock cyle

fetch and decoding takes 10 cycles..

And thereafter for each byte transfer takes 15 clock cycles..

INSTRUCTION cyle =FETCH cycle +execution cycle =10+15*64(as in ques they said 15 for each byte)

=970 (clock cyle)

(b) as in b part they say instruction is non interruptable ...means whenever the interupt will occur during the execution it
will not service it..bcoz due to non interruptable..so it will return control to interrupt when the current instrunction will
finish and it will be finished after 970 cycles so delay wiil be of 970 clock cycle..

(c) in this part max delay should be 15 cycle only.. because transfer can be interrupted at beginning of each cycle..

 1 votes -- Digvijay Pandey ( 26245 points)

5.276 A microprocessor is clocked at a rate of 5 GHz. a. How long is a clock


cycle? b. What is the duration of a particular type of machine instruction
consisting of three clock cycles? top gateoverflow.in/11192

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 476 of 2244

Frequency = 5GHz

Frequency means no of revolution per second..

In 1 second it makes 5*10^{9} rotation.

Cycle time is time to complete 1 rotation..

5*10^{9} rotation in 1 second

1 Rotation takes 1/(5*10^{9} seconds = 0.20 nano second

 0 votes -- Digvijay Pandey ( 26245 points)

5.277 bus top gateoverflow.in/11242

Assume a processor having a memory cycle time of 300 ns and an instruction processing rate of 1 MIPS. On average, each
instruction requires one bus memory cycle for instruction fetch and one for the operand it involves.

a. Calculate the utilization of the bus by the processor.


b. Suppose the processor is equipped with an instruction cache and the associated hit ratio is 0.5. Determine the impact
on bus utilization.

1
106
Clock Cycle per Instruction = = 1μs

a. Each instruction requires 2 memory cycle = 2 × 300ns = 600ns

So, total time for an instruction on average = 1μs + 600ns = 1600ns

600
1600
Bus utilization time = = 37.5%

b. Since not given, we can take instruction cache access time as negligible. Now, the memory cycle needed for an
instruction on average is 1.5 (instruction cache cannot help in operand fetch) as hit rate is 0.5. So,

average memory cycle time per instruction = 1.5 × 300 = 450ns

total time for an instruction on average = 1μs + 450ns = 1450ns

450

Bus utilization time = 1450 = 31.0%

 1 votes -- Arjun Suresh ( 124125 points)

5.278 co top gateoverflow.in/11391

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 477 of 2244

M[R1 + R2] + R3. : indexed displacement by R3..

Should be option D.

 0 votes -- Digvijay Pandey ( 26245 points)

5.279 how to solve it top gateoverflow.in/11874

Q> How much speed do we gain by using the cache,when cache is used 80% of the time? assume cache is faster than main
memory.

a)5.27

b)2.00

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 478 of 2244

c)4.16

d)6.09

Soverall=[(1-F)+F/S]-1
as F=0.8

but S is not given so we can't calculate Soverall

 0 votes -- kunal chalotra ( 3567 points)

5.280 pipeline top gateoverflow.in/11398


Selected Answer

Average instruction execution time on the nonpipelined machine is

Clock cycle × Average CPI =

10 ns × ( ( 40% + 20% ) × 4 + 40% × 5 ) = 10 ns × 4.4 = 44 ns

In the pipelined implementation, the clock must run at the speed of the slowest stage plus overhead, which

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 479 of 2244

will be 10 + 1 or 11 ns ; avg instruction execution time.

Speed up = avg time in pipe/ avg time in non pipe = 44/11 = 4 times

options (c)

 2 votes -- Pranay Datta ( 6113 points)

5.281 coa top gateoverflow.in/11392

A. True . DRAM consume more power as


compared to SRAM.

C. TRUE. Refreshing required because of


capacitors.

D. TRUE. DRAM are cheap so widely used as main


memory component.

B. FALSE. SRAM require more transistor (GATE)


per bit than DRAM.

 0 votes -- Digvijay Pandey ( 26245 points)

5.282 Finding Control memory


address register if cpi and
instruction counter is given top
gateoverflow.in/14831
Also, memory address bit is given. Control memory address register and control memory data register are to find.

co&architecture

5.283 consider a 33MHz cpu based system.what is the number of wait states
required top gateoverflow.in/16309

consider a 33MHz cpu based system.what is the number of wait states required if it is interfaced with a 60ns memory?
Assume a maximum of 10ns delay for additional circuitry like buffering and decoding.

a) 0 b) 1 c) 2 d) 3

co&architecture


Selected Answer

https://en.wikipedia.org/wiki/Wait_state

Wait state is no of cycles spent in operation of access

So it should be 33MHz implies 30.30 ns

and total memory access time will be 60+10=70ns

so no of cycles or wait states =70/30.30=2.31=3.(should be integer)

 0 votes -- sonu ( 1267 points)

5.284 How much speed do we gain by using the cache top gateoverflow.in/17674

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 480 of 2244

How much speed do we gain by using the cache,when cache is used 80% of the time ?Assume cache is faster than main
memory.

a)5.27

b)2.00

c)4.16

d)6.09


Selected Answer

The correct answer should be option C i.e. 4.16

Probably the assumption : "Cache is faster than main memory" is not sufficient to answer this question precisely.It should
be given that "Cache is how many times faster than the main memory".

However with the given information we can guarantee that speed up has to be strictly less than 5.

In general cache memory access is around ~100 times faster than the main memory access so,

ASSUMING : Cache access time is 1 ns & main memory access time is 100 ns.

So If there are total P memory accesses, then

1) Time Required Without Cache - P main memory accesses & 0 cache accesses = ( P * 100 ) + (0 * 1) = 100P
nanoseconds.

2) Time Required With Cache - (2/10) * P main memory accesses & (8/10) * P cache accesses

= ((2P/10) * 100) + ((8P/10) * 1) = (208/10)P nanoseconds.

Speed gain = Time Without Cache / Time With Cache = 100P/{(208/100)P} = 1000 / 208 = 4.8

Thus speed up will be around 4.8(less than 5 but near 5), assuming the cache is 100 times faster than main memory.

_______________________________________________________________________________

Proof for guarantee:

Suppose we are going to make 100 memory accesses.

Then suppose each main memory access takes 1 unit of time.

& all of the cache accesses(= 80 out of 100) takes total x units of time.

Then speed up will be 100 / (x + 20).

Now clearly x is strictly greater than 0 i.e. x > 0

It means (x + 20) is strictly greater than 20 i.e. (x + 20) > 20.

Hence 100/(x + 20) is strictly less than 5.

Now since generally cache is very fast than main memory (around 100 times), value of x would not be too much, so
answer should be 4 point “something”.

 1 votes -- Anurag Pandey ( 8183 points)

5.285 How much time will the processor be slowed down due to DMA
activity? top gateoverflow.in/17666

A processor is fetching instructions at the rate of 1 MIPS.A DMA module is used to transfer characters to RAM from a device
transmitting at 9600 bps.How much time will the processor be slowed down due to DMA activity?

a)9.6 ms

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 481 of 2244

b)4.8 ms

c)2.4 ms

d)1.2 ms

The
DMA
combines
(assembles)
one
word
from
one
consecutive
character
(byte)
so
we
get

I
am
assuming
1word=1
Byte
9600
chars/s
=
9600
bytes/s
=
1200
words/s
=
1200
W/s

If
we
assume
that
one
CPU
instruction
is
one
word
wide
then
1
million
instructions/s
=
1
million
words/s
=
10^6
W/s

So
we
have
1200
words
received
during
one
second
and
(10^6-1200)
words
processed
by
the
CPU
(while
DMA
is
transferring
a
word,
the
CPU
cannot
fetch
the
instruction
so
we
have
to
subtract
the
number
of
words
transferred
by
DMA)
and
we
get
(1200
w/s)
/
(10^6
w/s
-
1200
w/s)
=
1200
/
(10^6
-
1200)
=
1200
/
998800
=
0.0012014417...

So
Convert
0.0012
this
in
ms.
it
will
come
1.2
ms

 1 votes -- sonu ( 1267 points)

5.286 what are the values of overflow,carry and zero flag . cpu uses 2's
compliment top gateoverflow.in/17594

two 8 bit 1100 0011 and 0100 1100 are added. what are the values of overflow,carry and zero flag . cpu uses 2's compliment

1 1
11000011
01001100
1 00001111

zero flag=0 (final answer is non zero)


overflow flag=0(since both in carry out carry =1 and it is addition of -ve and +ve number so overflow should be equals to 0)
carry flag=1(extra bit out of msb)

 1 votes -- Umang Raman ( 10379 points)

5.287 swap space top gateoverflow.in/17835

Swap space is some space in virtual memory. but why it called as swap space?

Swap space is the space on the disk reserved for the full virtual memory space of a process.

When Operating System creates a process, it also creates (or reserves) a space on disk for all the pages of that process.

Each process contains its own swap space in the disk.

It is called swap space because it is the space(or place) in the disk from where the pages are exchanged(swapped) with
main memory, for any process.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 482 of 2244

 0 votes -- Anurag Pandey ( 8183 points)

5.288 subroutine call top gateoverflow.in/17836

I know function call is like subroutine call. But why it is differentiate from function call?

and if a processor calls a subroutine is any interrupt is possible?means what is the relationship of subroutine call and
interrupt?


Selected Answer

A related instruction is the subroutine call, which transfers execution to a


subprogram and then, after the subprogram finishes, returns to the main program where it left off relatively independent
of the remaining code.

The interrupt service routine is just like a subroutine. The difference is that when you call a
subroutine, you call it when you decide, and you understand completely what will be changed by the subroutine,

Interrupt Service Routines (ISRs) are to handle hardware interrupts.

 0 votes -- Umang Raman ( 10379 points)

5.289 Easy one but I'm not getting Approach. top gateoverflow.in/18369

A DMA controller transfers 16Bytes to memory using cycle stealing with frequency 1.2GHz. The Number of clock cycles used
for transfer of 16Bytes is 20 clock cycles. Find the throughput?

1.04 GBps

 0 votes -- akash ( 735 points)

5.290 The search concept used in associative memory is top gateoverflow.in/18093

The search concept used in associative memory is

a)Parallel search

b)Sequential search

c)Binary search

d)Selection search


Selected Answer

Search in associative memory is parallel. For k-way associativity we can have k comparators which compares the tag bits
of 'k' blocks in parallel. We can't increase 'k' beyond a limit due to hardware limitation.

 1 votes -- Pooja ( 22773 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 483 of 2244

5.291 the maximum speed-up possible approximately will be top gateoverflow.in/18090

If a microcomputer operates at 5 MHz with an 8-bit bus and a newer version operates at 20 MHz with a 32-bit bus,the
maximum speed-up possible approximately will be

a)2

b)4

c)8

d)16

It should be max(20/5, 32/8) = 4. Increasing the bandwidth aids in achieving the maximum speed up. Suppose we had a
memory intensive program then increase in bandwidth becomes critical whereas for a CPU intensive process, increase in
clock speed becomes critical.

 0 votes -- Arjun Suresh ( 124125 points)

5.292 A pipline p operation at 400Mhz has a speed up factor 6 and 70%


efficiency. how many stages are there in pipieline?? top gateoverflow.in/17587

Consider the following pseudo code. What is the total number of multiplications to be performed?

D = 2 for i = 1 to n do for j = i to n do for k = j + 1 to n do D = D * 3

(A) Half of the product of the 3 consecutive integers.

(B) One-third of the product of the 3 consecutive integers.

(C) One-sixth of the product of the 3 consecutive integers.

(D) None of the above.

efficiency =S/K

70/100=6/K

k=600/70=8.56 = 9 stages (approx)

 0 votes -- kunal chalotra ( 3567 points)

5.293 A read bit can be read - top gateoverflow.in/17690

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 484 of 2244


Selected Answer

I think answer is option D .

Every peripheral device is controlled by writing and reading its registers

 0 votes -- Umang Raman ( 10379 points)

5.294 mapping cache top gateoverflow.in/16657

Consider a cache with 64 blocks and block size 16 bits block number of byte address 1600 is

16 bit block= 2B block

Byte address 1600 is block address(1600/2)=800

which maps to cache block number (800 mod 64)=32

 1 votes -- Pranay Datta ( 6113 points)

5.295 variable instruction code top gateoverflow.in/16601

http://gateoverflow.in/?qa=blob&qa_blobid=256200031073543854

i have basic idea of this question :


here 36 bit is the total instruction size , means we 236 different patterns..
to understand the question

i assume here 1 instruction is there with two 15 bit address and one three bit register

30 *23 =2 33
so 1*2
= 1073741824

i assume here 64 instruction having with one 15 bit address and one with 3 bit registers

*218 =224
so 64


=16777216

i assume here only 2 instruction with no address or zero


so 2

if add all 1073741824 +16777216+ 2=1090149042


but we have 236 =68719476736
see here 1090149042<68719476736
here the thing is, we can design variable length opcode, with all the instruction when we have LHS which should
be less than 236. the vale(1090149042) will be changes as per according to no of instruction changes, as i
assume here no of instruction as 1 , 64, 2.if the value 1090149042 exceeds the value of 236 than surely we cant
use the concept of opcode technique to allow of the above instruction to be encode with 36 bit format.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 485 of 2244

 0 votes -- kunal chalotra ( 3567 points)

5.296 The number of logical CPUs in a computer having two physical quad-
core chips with hyper threading enabled is top gateoverflow.in/16310

The number of logical CPUs in a computer having two physical quad-core chips with hyper threading enabled is-----------.

a) 1 b) 2 c) 8 d) 16

co&architecture


Selected Answer

2 * 4 physical cores * 2 = 16 logical cores. I'm not sure if we can call this logical CPU. But Hyper Threading is vendor
specific and hence out of GATE scope.

https://en.wikipedia.org/wiki/Hyper-threading

 0 votes -- Arjun Suresh ( 124125 points)

5.297 How to calculate the address of the sector in below question ? gateoverflow.in/16737

top

A hard disk has 63 sectors/track ,10 platters each with 2 recording surfaces and 1000 cylinders ,the address
of each sector is given as
where C is cylinder no , H is surface no and S is sector no , thus the 0 th sector is addressed
as <0,0,0> , 1st sector is address as <0,0,1> and so on , so then the address <400 , 16, 29 > corresponds to
which sector no ?

Number of sectors in a track = 63

Number of track surfaces in a cylinder = 10*2

Number of sectors in a cylinder = 63*10*2

<400,16,29> , sector number = 400th cylinder + 16th surface of 400th cylinder + 29th sector of 16th surface of 400th
cylinder

Sector number of address <400,16,29> = 400*63*10*2 + 16*63 + 29 = 505037 sector .

 1 votes -- Vinay Yadav ( 1739 points)

5.298 how many number of times the instruction sequence below will loop
before coming out of the loop? top gateoverflow.in/17044

how many number of times the instruction sequence below will loop before coming out of the loop?

MOV AL,00H

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 486 of 2244

A1: INC AL

JNZ A1

a)1

b)256

c)255

d)will not come out of the loop

MOV AL,00H--- means 0000 0000(binary) is loaded into the register AL. Register AL is of 8 bits (Intel x86 architecture).

Now in each loop the value of AL is incremented by one.....this will go on till AL value becomes 1111 1111(binary) i.e
255(decimal).

After this when it is incremented i.e 1111 1111 + 0000 0001= 10000 0000. Now this is an overflow as AL is of 8 bits. The
MSB is discarded(the carry out) and hence AL becomes 0000 0000 again. Therefore, it comes out of the loop.

Totally it will loop= 255 + 1(for the last calculation) = 256

Hence B is the correct option

PS: 8085 is out of GATE syllabus now

 0 votes -- debanjan sarkar ( 775 points)

5.299 Need of TLB lookup before Cache Look up? top gateoverflow.in/17532

Why do we need to look in the TLB for a virtual address without looking into cache first?

Why we do not look for a given data directly into the cache?

TLB look up could increase hit time even if the data is in cache.

Suppose there is a TLB miss, then we have to look up in the Page Table. If data is in the page table then we are checking it
in Cache, so after all we are accessing main memory (before cache access).Is not the time required in this process
equivalent to time required in a cache miss? So how it is going to speed up the memory access?

tlb hold recent entries of page table . while cache contain recently used blocks. u should note that without getting the
frame number it is very hard to search whether a page is in cache or not. so for the same reason we have to first get the
frame number. (if u have studied cache mapping u should be knowing that frame number is required to map the block to
cache). so to get the frame number u have to o to the page table but like cache . tlb is teh cache of page table so before
visting page table i visit tlb.

yes it seems that there is a time penality but as the numerical we solve we are not given the data to be transferred, in
real scenario the data also has to transferred . so time is conversion of address + transfer time. directly access the main
memory for address takes verl less amount of time as compared to transferring a whole block. so if using the above
procedure we are spending more time in translation still it is very very less than transferr time so overall system become
more efficient . worst case can be costly .

 0 votes -- Ravi Singh ( 7303 points)

5.300 More than one word are put in one cache block to top gateoverflow.in/17264

More than one word are put in one cache block to

a)exploit the temporal locality of reference in a program

b)exploit the spatial locality of reference in a program

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 487 of 2244

c)reduce the miss penalty

d)none of these


Selected Answer

When a word is accessed, we take a block of word and put in cache expecting words in that block to be accessed in nearby
time- which is spatial locality.

 0 votes -- Arjun Suresh ( 124125 points)

5.301 pipe top gateoverflow.in/11145

Consider the following assembly language program:


I1: Move R3, R7 /R3 ← (R7)/
I2: Load R8, (R3) /R8 ← Memory (R3)/
I3: Add R3, R3, 4 /R3 ← (R3) + 4/
I4: Load R9, (R3) /R9 ← Memory (R3)/
I5: BLE R8, R9, L3 /Branch if (R9) > (R8)/
This program includes WAW,RAW, and WAR dependencies. Show these

soluton: is this correct

WAW=1(Output data dependency)

WAR=1(anti data dependency)

RAW=3(true data dependency)

WAW {I1, I3}

WAR {I2, I3}

RAW {I1, I2} {I1, I3} {I2, I5} {I3, I4} {I4, I5}

 1 votes -- Digvijay Pandey ( 26245 points)

5.302 Consider the following code: for (i=0; i <20; i​​++) for ( j= 0; j< 10;
j++​​) a[i] a[i]* j a. Give one example of the spatial locality in the code. b.
Give one example of the temporal locality in the code. top gateoverflow.in/11127

Consider the following code:


for (i=0; i <20; i++)
for ( j= 0; j< 10; j++)
a[i] = a[i]* j ;

a. Give one example of the spatial locality in the code.

b. Give one example of the temporal locality in the code.

a. a[1] is accessed after a[0] both are near memory locations and hence example of spatial locality.

b. a[0] is accessed for j = 0 and for j = 1; same memory location accessed in nearby time and hence example of temporal
locality.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 488 of 2244

 1 votes -- Arjun Suresh ( 124125 points)

5.303 No. of 1-address instructions top gateoverflow.in/5423

A computer system supports 1-address instructions and 2-address instructions and word size is 16 bits. Main memory is 64
words. If there are eight 2 -address instructions then how many 1-address instructions are used?

Address size=6 bits

For 2address instructions,

16-2*6=4 that means 2^4 opcodes

Opcodes remaining after 2 addr instructions =8

Total one addr instructions(after combining 6 address bits to instruction opcode-expand technique ) =8*2^6=512
instructions

 2 votes -- Anurag Semwal ( 4775 points)

5.303 plez tell me the correct approach and meaning of question top gateoverflow.in/5133

It is an easy one. Answered now.

http://gateoverflow.in/3692/gate2004-it_49?show=3983#a3983

 0 votes -- Arjun Suresh ( 124125 points)

5.303 what are average read cycle time and write cycle time in write through
and write back cache?Elaborate the concept please. top gateoverflow.in/4775

WRITE THROUGH POLICY:


CACHE and MAIN MEMORY is simultaneously updated.it eliminates the problem of CACHE coherence in SINGLE
PROCESSOR SYSTEM.
here updation time will be Max(Cache time,memory time) which is memory time and is feasible only for less updations.
AVERAGE READ TIME=(hit ratio of read)*cache time+(1-HIT ratio read)(cache time + memory time)
AVERAGE WRITE TIME= (hit ratio of write)*(UPDATION TIME)+(1-hit ratio write) (updation time + memory time)

WRITE BACK POLICY:


whenever a block is choosen for replacement at that time main memory is updated.
here updation time depends on dirty bit concept
if dirty bit is 1 it means block in cache is modified so here block time (for incoming block) +( block time for updating
block) + cache time
if dirty bit is 0 it means no modification is there so we dnt need to update in that case block time for (incoming block) +
cache time
this is how updation time is caclculated based on the dirty bit.

 2 votes -- Shreyans Dhankhar ( 2265 points)

5.304 Pipelining top gateoverflow.in/6697

A 5 stage pipeline with the stages taking 1, 1, 3, 1, 1 units of time has throughput of
(A) 1/3 (B) 1/7 (C) 1/5 (D) 1/6

Also please explain the answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 489 of 2244

Throughput here is the rate of instruction execution.

For pipeline execution

3 time units -1 instruction (max delay in pipeline)

throughput = 1/3 instruction per unit time

if the same question was asked for non pipeline

throughput=1/7 instruction per unit time (assuming total instruction execution time is the sum of the individual delays of
the stages)

 2 votes -- Pooja ( 22773 points)

5.305 Level 1 cache and level 2 cache top gateoverflow.in/6765

S1 is false ....but can any one plz explain about S2..?

In S1: it should be more virtual memory than its physical memory

In S2: both level minimizes cache miss

So answer should be D.

 1 votes -- Arjun Suresh ( 124125 points)

5.306 coa top gateoverflow.in/7757

A hard disk with a transfer rate of 10 M bytes/second is constantly transferring data to memory using DMA. The processor
runs at 600 MHz. and takes 300 and 900 clock cycles to initiate and complete DMA transfer respectively. If the size of the
transfer is 20 Kbytes, what is the percentage of processor time consumed for the transfer operation?

(A) 5.0%

(B) 1.0%

(C) 0.5%

(D) 0.1%


Selected Answer

Solution : D

Transfer rate =10MBps

Data to be transferred = 20KB

20×2 10
20
Duration of transfer = 10×2 = 2 × 2 −10

Frequency of the CPU = 600MHz

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 490 of 2244

Clock overhead for transfer = 300 + 900 = 1200 clock cycles.

1200
600 ×106
Time for 1200 clocks = = 2 × 10 −6 and processor is used only for this much of time. So,

2 ×10 − 6 2 ×10 − 4

Percentage of CPU time consumed = 2 ×2


− 10 −3
(
× 100% ≈ 2 ×10 = 0.1% ∵ 210 ≈ 103 )
 2 votes -- Gowthaman Arumugam ( 1079 points)

5.307 Direct Mapped Cache top gateoverflow.in/7423

A block goes to block address mod 4 cache block.

8 - miss [8 - - -]
9 - miss [8 9 --]
11 - miss [8 9 - 11]
16 - miss [16 9 - 11]
8 - miss [8 9 - 11]
9 - hit [8 9 - 11]
17 - miss [8 17 - 11]
8 - hit [8 17 - 11]
9 - miss [8 9 - 11]
11 -hit [8 9 - 11]

So, 3 hits out of 10 => 30%.

 0 votes -- Arjun Suresh ( 124125 points)

5.308 Calculate effective address? top gateoverflow.in/7281

co&architecture

In Pc relative addressing

Effective address is prog counter value +address field value

Pc will contain 302 in this case coz its a 2 byte instruction so effective address =302+500=802

 3 votes -- Anurag Semwal ( 4775 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 491 of 2244

5.309 Q 14.. PLEASE ANSWER. top gateoverflow.in/4482

If we see, 11 bits(0-10) are used to address in the instruction. So, main memory can be up to 2 11 bytes.

This assumes byte addressing and that there is no virtual memory.

If word addressing is used, we get 2 11 words = 2 * 2 11 = 2 12 bytes as each word here is 16 bits = 2 bytes.

http://www.cs.ucla.edu/classes/winter04/csM151B/l2/examples/ByteVSWordAddr.pdf

 2 votes -- Arjun Suresh ( 124125 points)

5.309 How many stall cycles are needed with the best bypassing possible for
each of the following instruction sequences in a 5-stage DLXpipeline ? ADD
R3,R6,R8 ORI R7,R3,0x67 top gateoverflow.in/3541

http://www.cs.umd.edu/class/fall2001/cmsc411/proj01/DLX/aboutDLX.html...please read this one and


Then calculate no of stalls

 0 votes -- aditya upadhyay ( 113 points)

5.309 Many microprocessors have a specified lower limit on clock


frequency(apart from the maximum clock frequency limit) because
__________. top gateoverflow.in/261

Clcok frequency becomes low means time period of clock becomes high. When this time period increses beyond the time
period in which the non-volatile memory contents must be refreshed, we loose those contents. So, clock frequence can't
go below this value.

The cache, register etc. inside CPU and RAM for primary memory are all examples of non-volatile memory and needs
refresh within the specified time period or else will loose their contents.

Non-volatile memory are being developed and computers in future should be tailor made for that.

 1 votes -- Arjun Suresh ( 124125 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 492 of 2244

5.310 Why not d? top gateoverflow.in/199

Why not option d is correct ?


Selected Answer

Because microprocessor can also have hardwired control unit. Microprogrammed control unit is just a design option for
control unit in a microprocessor. This "micro" is not related to the "micro" in microprocessor.

 1 votes -- Arjun Suresh ( 124125 points)

5.310 what is meant by cache is physically addressed and cache is virtually


addressed top gateoverflow.in/132


Selected Answer

A cache as everyone knows, stores a copy of data from memory in a fast storage near to CPU. Now, in a system with
virtual memory, CPU will be working on logical address and this logical address will be translated to physical address by
the memory unit before data is fetched from the main memory. So, if we use the cache before this translation, it will be
virtually addressed and if we use cache after this translation, it will be physically addressed.

TLB (which is like a cache for page table) is looked up on to perform virtual-physical address translation. So, in a virtually
addressed cache, TLB comes after cache and in a physically addressed cache, TLB comes before the cache.

For more reference:


http://cseweb.ucsd.edu/classes/fa10/cse240a/pdf/08/CSE240A-MBT-L18-VirtualMemory.ppt.pdf

 1 votes -- Arjun Suresh ( 124125 points)

5.311 microprogrammed cu top gateoverflow.in/363

in microprogrammed cu every computer instruction has its own microprogammed routine in control memory (mano )

Does this mean than every m/c instruction would have its own implementation of fetch routine loaded ?

5.311 an access sequence of cache block address of length N and contaons n


unique addresses. The no. of unique block address between 2 consecutive
accesses to the same block address is bound above by k. What is miss ratio
if access sequence is passed through a cache of associativity A >= k
exercising LRU replacement policy? Ans is n/N but how? top gateoverflow.in/1783

http://gateoverflow.in/1922/gate2014-1_44?show=3336#a3336

 0 votes -- Arjun Suresh ( 124125 points)

5.311 An instruction takes m bits .It suppourts 0 address(p), 1 address(q),2


address(r) , a memory reference requires n bits . Establish a relation
between p,q,r,n,m top gateoverflow.in/3540

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 493 of 2244

0 address means, during execution of the instruction, we just need to fetch the instruction- instruction fetch but no data
fetch. So, for an m-bit instruction
Number of memory reference for p = m/n

For 1-address instruction, a part of m-bit instruction will have a memory address and that memory needs to be fetched
during execution. So,
Number of memory reference for q = m/n + 1

Similarly for 2-address instruction, r = m/n + 2

(May be the question meant p is the number of 0 address instruction, it is not clear)

So, assuming a1 number of p, a2 number of q, a3 number r are executed in a time frame,

Average number of memory reference per instruction will be

a1(m/n) + a2(m/n + 1) + a3(m/n + 2)


(a1 + a2 + a3)

 2 votes -- Arjun Suresh ( 124125 points)

5.312 floating point range top gateoverflow.in/1813

Plz xplain

co&architecture

(a) Largest positive value:

This happens when all significant (mantissa) bits are 1, and the exponent bits are all 1.

= (b)p −1 − 1 × (b)X−q

Smallest positive value:

This happens when the LSB of mantissa is 1 and the exponent bits are 0 so that subtracting the bias gives the largest
negative value possible for exponent
= 1 × (b) −q

 1 votes -- Arjun Suresh ( 124125 points)

5.313 while finding true dependency, only sequential dependency will be


considered or all dependency will be taken? top gateoverflow.in/7872

co&architecture

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 494 of 2244

i2 depending on i1 because of r1 and i4 depending on i3 because of r4 so two is the answer..


 0 votes -- Anoop Sonkar ( 4167 points)

5.313 Do we need to sums on Cache Coherence problems , or just theory is


enough ? top gateoverflow.in/9036

You should practice a few. It is one of the few areas where practice is an absolute necessity.

http://gateoverflow.in/tag/cache-memory

 0 votes -- Arjun Suresh ( 124125 points)

5.314 Three state Buffer top gateoverflow.in/9678

I am just reading that Microperations from Morris mano

They have explained the concept of 3 state gate which can be used as a multiplexer which have output 1, 0 and high
Impedance. what is used of it (I am not getting )

digital-logic

This is useful for the operation of bus (shared by many components) and hence very important in computers.

http://en.wikipedia.org/wiki/Three-state_logic

 0 votes -- Arjun Suresh ( 124125 points)

5.315 co top gateoverflow.in/9632

What will be the minimum size of ROM which maintains truth table of square of 3 bit numbers(in bits) ?


Selected Answer

Truth Table will be as:

Input (Address lines) Output (Data)


I0 I1 I2 B0 B1 B2 B3 B4 B5
0 0 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 1
0 1 0 0 0 0 1 0 0
0 1 1 0 0 1 0 0 1
1 0 0 0 1 0 0 0 0
1 0 1 0 1 1 0 0 1
1 1 0 1 0 0 1 0 0
1 1 1 1 1 0 0 0 1

example for 111 (7), square will 110001 (49)

so it will have 3 address line mean 8 address [000 to 111] and 6 bits [B0 to B5] at each address = 8 X 6 = 48 bits

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 495 of 2244

but we do not need to store B4 and B5 [as B4 = 0 and B5 = I2 ]

so ROM will be of size 8 x 4 = 32bits.

 5 votes -- Praveen Saini ( 34299 points)

no is 3 bit long.. square of 3 bit no is 6 bit long..


total 8 nos (0 to 7) which truth table has to store..
total size is 8*6=48 bit

 2 votes -- Digvijay Pandey ( 26245 points)

5.316 signed Integer top gateoverflow.in/9621

Can you explain why the offset in addressing modes need to be a signed integer ?

co&architecture

Offset in addressing modes usually an unsigned integer..

 0 votes -- Digvijay Pandey ( 26245 points)

5.317 Instruction format top gateoverflow.in/10313

Consider a hypothetical 32 bit microprocessor having 32 bit instructions composed of two fields: The first 4 bits contains the opcode and the
remainder an immediate operand, an operand address, or register references.

a. What is the maximum directly addressable in bytes.


b. What is the impact on system speed if the microprocessor bus has:

1. a 32 bit local address bus and a 16 bit local data bus?


2. a 16 bit local address bus and a 16 bit local data bus?

c. Is this machine more likely to be a RISC or CISC architecture ?


Selected Answer

a. Out of 32 bit instruction, 4 bit is opcode. So, remaining 28 bits can be used as an operand address and hence up to 228
bytes can be addressed assuming byte addressing.

b.

1. 32 bit address bit means full capability of 228 addresses can be used. But 16 bit data width means each instruction
requires two memory reads.
2. With 16 bit address field we can address only 216 words of memory. So, two memory reads are required for each
address using address latching which slows down the microprocessor. Here also, two memory reads are required for
each instruction as we have only 16 bit data bus.

c. It is more likely to be a RISC machine as we are having maximum 24 = 16 instructions only.

 2 votes -- Arjun Suresh ( 124125 points)

5.317 Assume an instruction set that uses a fixed 16-bit instruction length.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 496 of 2244

Operand specifiers are 6 bits in length. There are K two-operand


instructions and L zero-operand instructions. What is the maximum number
of one-operand instructions that can be supported? top gateoverflow.in/10976


Selected Answer

We have 16 bits. So, total number of possible encodings = 216

But all these encodings are not distinct instructions as even if operands are different, we consider them as same
instruction. So, we have to find the number of each types of instructions.

We have L 0 operand instructions. Number of encodings taken by these = L as they don't have any operand part.

We have K 2 operand instructions. Number of encodings taken by these = K × 26 × 26 = K × 212 as there are 2 operands and
each being 6 bits.

All the remaining encodings can be used for 1 operand instructions, which will be equal to 216 − L − 212 × K

and number of 1 operand (of 6 bits) instructions possible will be

216 − L − 212K
26

 1 votes -- Arjun Suresh ( 124125 points)

5.318 Consider a 32-bit microprocessor that has an on-chip 16-KByte four-


way set-associative cache. Assume that the cache has a line size of four 32-
bit words. Draw a block diagram of this cache showing its organization and
how the different address fields are used to determine a cache
hit/miss.Where in the cache is the word from memory location ABCDE8F8
mapped? top gateoverflow.in/11116

i am solving in this way...plzz correct if wrong...


16 Kb cache size.

4 way set associative.

no of sets=no of lines/p(way)

no of lines=cache size /line size

no of lines=2 7
no fo sets= 27/22

therefore no of sets=32.

tag(20 bit) sets( 5 bit) block size(7 bit)

now addrees is ABCDE8F8

its binary from is :1010 1011 1100 1101 1110 1000 1111 1000

<1010 1011 1100 1101 1110 > <10001> <1111000>

it mapped to 17 th set in cache design....

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 497 of 2244


Selected Answer

Yes. You are correct. But how cache hit/miss is detected is not answered :)

 0 votes -- Arjun Suresh ( 124125 points)

5.319 CO 2001 top gateoverflow.in/11109

A processor needs software interrupt to

(a) test the interrupt system of the processor

(b) implement co routines

(c) obtain system services which need execution of priviledge instructions

(d) return from subroutine

Option C

obtain system services which need execution of priviledge instructions

 2 votes -- Bhagirathi Nayak ( 10239 points)

5.319 What is the Associativity, if we have 128 KByte cache, with 512 sets
and a block size of 64-bytes? top gateoverflow.in/11047


Selected Answer

no of lines in the cache=> cache size/Block size=> 2 17 /26=>211

no of sets=no of lines/X => X= associativity

29=211 /X=> X=22=>4 way set associative

 1 votes -- Joker ( 685 points)

512 Set 64B block size.

No of sets = 128kB/512*64

= 4

 1 votes -- Digvijay Pandey ( 26245 points)

5.319 what is the average access time for a drum rotating at 4000
revolutions per minute top gateoverflow.in/9485


Selected Answer

4000 revolution per minute means 60/4000 seconds for 1 revolution..

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 498 of 2244

average access time is time to complete 1/2 revolution i.e. . 7.5 milli second..

 2 votes -- Digvijay Pandey ( 26245 points)

5.320 10 compliment top gateoverflow.in/9416

What is 10 compliment of decimal number 2056.064 ?

I know the method 10 compliment = 9 compliment + 1

Now 9 compliment = 9999.999 - (2056.064)= 7943.935

Now 10 complimnet = 9 compliment +1

= 7943.936 or 7944.935 ?

digital-logic

see if u take 10 complement of a no x that means x + complement (x) = 10^n..


where n is no of digits in integer part of (x)..
that is one way to verify..
in case of 2056.064 complement is nothing but 10^4-2056.064 i.e. 7943.936.
correct me if i wrong.

 0 votes -- Digvijay Pandey ( 26245 points)

5.321 Bias value determination top gateoverflow.in/9309

What would be the bias value for

a. A base-2 exponent in a 6-bit field?

b. A base-8 exponent in a 7-bit field?

I assume that the exponent value is represented as 2's complement.

the bias value is a number which will be added to actual exponent to make the n-bit exponent to lie in the range (0 to 2 n
- 1).

i.e., for 8 bits, the exponent shall be from 0 to 255.

Since the actual range of 8 bit signed integers is -128 to +127, we need to add +128 to exponent to bring the range to 0
to +255. So +128 is the bias value for 8 bit exponent.

In similar way,

1) for 6 bits, the actual range is -32 to +31. so bias value is +32.

2) for 7 bits, the actual range is -64 to +63. so bias value is +64. in base-8, 080.

 0 votes -- Arulkumar ( 19 points)

5.322 Floating Arithmetic top gateoverflow.in/9300

a. Consider a fixed-point representation using decimal digits, in which the implied radix point can be in any position (e.g. to
the right of the least significant digit, to the right of the most significant digit, and so on). How many decimal digits are
needed to represent the approximations of both Planck’s constant and Avogadro’s number the implied radix point must be in
the same position for both numbers?

b. Now consider a decimal floating-point format with the exponent stored in a biased representation with a bias of 50. A
normalized representation is assumed. How many decimal digits are needed to represent these constants in this floating-
point format?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 499 of 2244

Can you please check this?

I got answer A as 53 bits

While for answer B

Since they have given Biased for decimal = 50

Then Planck Constant which is 6.63*10 -27 for this Biased Exponent Field= -27+50= 23

Similarly for Avogadro numbers which is 6.02*10 23

For this Biased Exponent Field= 23+50 = 73

Now, they asked us to find number of digit in decimal only to represent this number

For Planck Constant

Sign bit Exponent Field Significand

0 23 63

Similarly for Avogadro

Sign bit Exponent Field Significand

02
0 73

Here 6 is a hidden bit in both cases

Therefore to represent this number both we required 5 digit

Is it right?

co&architecture

a. Scaling factor needed is 10 -29 to represent Plank constant. Now Plank constant is 663 and Avogadro number is 602..0
(50 0'2). So, we need 50 + 3 = 53 decimal digits.

b. "6 is a hidden bit in both cases" Because of normalization? In binary normalized representation 1 on the left of decimal
point is taken as implied. But in decimal this "digit" can be any from 1-9. So, we can't just imply it.

Normalization just means that the leading significant digit is non-zero. 1 being taken implicitly in binary is something done
in addition to normalized representation because '1' is the only possibility there.

 1 votes -- Arjun Suresh ( 124125 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 500 of 2244

5.323 Binary Arithmetic top gateoverflow.in/9283

Under computer integer arithmetic, the quotient J/K of two integers J and K is less than or equal to the usual quotient.True
or false?

Can you support your explanation with example !

co&architecture

false..
Binary Arithmatic follow truncation rule.. that ll result greater(+ve no) equal (well normalised without truncation) or
smaller( negative no) value ..

 0 votes -- Digvijay Pandey ( 26245 points)

5.324 Floating Point Arithmetic top gateoverflow.in/9368

Consider the statements

S1: Problem of redundant expression can be avoided using normalization

S2. Ambiguity may be solved by using the concept of Biased exponent

Which of the following is true ?

a) s1

b) s2

c)both

d) none of these

5.325 floating Point Arithmetic top gateoverflow.in/9370

Consider the following Statements :

S1: Booth algorithm reduces the spaces for fixed point signed multiplication

S2: Booth algorithm increases time for fixed point signed Multiplication

Which of following is true ?

a) s1 is true

b) s2 is true

c) cant say

d)None of these

please explain the answer

co&architecture


Selected Answer

S2 is wrong as booth algorithm was invented to decrease the time of multiplication. It does mutiplication by using shift
operation which is much faster then a normal multipier where m*n multiplier cells is used.

S1 is correct as in booth algorithm we just need to keep track of bits which is flipping nd booth algorithm just uses a
shiftregister where the multiplier reside ,calcullated result is stored in the same register so it uses very few space than
any other algorithm.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 501 of 2244

 1 votes -- Saurav Kumar Gupta ( 1455 points)

5.326 FLoating Point Arithmetic top gateoverflow.in/9372

what is Nega Binary representation of (41) 10 ?

I just google first about negaBinary (-2 ) , The procedure says divide number by -2 , to get positive remainder and then read
from bottom to top

But my answer doesnt match with the answer given in book

(41) = (-2)*(-20) + 1(LSB)

-20 = (-2)*(10) + 0

(10)= (-2)*(5) + 0

(5) = (-2)*(-2) +1

(-2)= (-2)*(1) +0

1 = (-2)*(0) + 1 (MSB)

So answer what i get is 101001

But they give answer = 1111101

Can you please explain and correct me ?

co&architecture

The base expansion of a number can be found by repeated division by , recording the non-negative remainders of , and concatenating those
remainders, starting with the last. Note that if , remainder , then .

for 41 it should be like this,

41/-2 = -20, remainder 1

-20/-2 = 10, remainder 0

10/-2 = -5, remainder 0

-5/-2 = 3, remainder 1

3/-2 = -1, remainder 1

-1/-2 = 1, remainder 1

1/-2 = 0, remainder 1

so the nega binary of 41 is 1111001.

Wikipedia covers it in detail.

 0 votes -- nitin.nilesh ( 109 points)

5.327 Overflow condition top gateoverflow.in/9371

The overflow condition for unsigned 8 bit integer would be if c= a+b if c<a Or c< b

The overflow condition for signed 8 bit integer would be if c= a+b if c<a and c< b

right ??

co&architecture

For c = a + b, UNSIGNED

The overflow condition for unsigned 8 bit integer would be c < a or c < b

For c = a + b, SIGNED

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 502 of 2244

We can't say anything like that. We need to say only with respect to the sign of the input numbers. If the sign of a and b
are same but the sign of c is different, there's overflow. If a and b are of different sign, overflow cannot happen.

(When a = -3 and b = -5, c = -8 but there is no overflow and c < a and c < b)

 0 votes -- Arjun Suresh ( 124125 points)

5.328 The process of organizing the memory into two banks to allow 8 and
16 bit data operation is called top gateoverflow.in/18567

The process of organizing the memory into two banks to allow 8 and 16 bit data operation is called

a)Bank switching

b)Indexed mapping

c)Two-way memory interleaving

d)Memory segmentation


Selected Answer

Process of organizing memory in banks is called as interleaving so ans is c

u can refer this

https://en.wikipedia.org/wiki/Interleaved_memory

 0 votes -- Pooja ( 22773 points)

5.329 Compared to CISC processors,RISC processors contain top gateoverflow.in/18580

Compared to CISC processors,RISC processors contain

a)More register and smaller instruction set

b)larger instruction set

c)less registers and smaller instruction set

d)more transistor elements


Selected Answer

OPTION A MORE REGISTER AND SMALLER INSTRUCTION SET

 0 votes -- Umang Raman ( 10379 points)

5.330 pipeline top gateoverflow.in/29606

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 503 of 2244

is 2ns?(in MIPS)


Selected Answer

CPI(non-pipeline)=40%( no of cycles ALU required)+20%( no of cycles branch instruction required )+ 40% (no of cycles
memory instruction required)=0.40(4)+0.20(5)+0.40(6)=5cycles=5*10=50ns

CPI(pipeline)=one cycle time + overhead=10+2=12ns

Before pipelining, 1 instruction take 50 ns.


but after pipelining, It can execute 4.17(speed up =50/12) instructions in 50ns. So, in 1 sec, (4.17/50)*10^9
instructions can execute.Approx 83.4 MIPS

 5 votes -- Avdhesh Singh Rana ( 1509 points)

5.331 pipeline top gateoverflow.in/29604

suppose there is unpipelined processor with a cycle time of 30ns which is evenly divided into 5 pipeline stages.The total latch
latency of the pipeline will be

5.332 clock cycle top gateoverflow.in/29603

the maximum clock frequency at which the data path can operate is ??

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 504 of 2244

5.333 CO top gateoverflow.in/29673

What is the use of dirty bit and valid bit?

For reading or writing or modifing cache which one is used?


Selected Answer

Dirty bit is used to check modification in the cache block.

Dirty Bit : In a write back scheme, when a write occurs, the new value is written ONLY to the block in the cache.The
modified block is written to the lower level of the hierarchy when the block is replaced.

To avoid unnecessary writes of unmodified pages, we would like to know whether a block need to be write back or not
when we choose to replace it.

So Dirty bit tells us, whether the block has been modified(dirtied) or not from the time since it was brought into the cache.

Valid Bit : Valid bit indicates that whether the associated block in the cache contains valid data or not.

For example, when processor starts up, the cache may contain junk or invalid data & the tag fields will be meaningless.At
that time Valid bit will be 0.

 2 votes -- Anurag Pandey ( 8183 points)

5.334 number of cycles saved using operand forwarding top gateoverflow.in/29728

No of cycles without operand forwarding 14 cycles

No of cycles with operand forwarding 8 cycles

So no. of cycles saved with operand forwarding (14-8) =6 cycles

 1 votes -- srestha ( 11585 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 505 of 2244

5.335 Cache Memory top gateoverflow.in/30150

Given ans is :248

Acc to me ans sholud be like this:

cache can hold 64 blocks without replacement .

cpu fetches words from 0-4351 so no of blocks required is: 4352/64= 68 blocks

1st time 68 miss operation occured. but after this step i got stuck.

please explain how to solve such type of ques .


5.336 TEST SERIES QUESTION top gateoverflow.in/30145

Assume that memory is byte addressable with word size of 32 bits. the program has
been loaded in memory 300 (decimal) address onwards.if an interrupt is occurred
during the execution of HALT which is stored at 328. what will be return address
pushed on the stack?

Given ans is 326. but i am not getting how this ans is coming. please explain.

5.337 co top gateoverflow.in/29794

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 506 of 2244

5.338 reducing misses in cache.. top gateoverflow.in/29466

which of the following statement (if any) are generally true?

1. There is no way to reduce compulsory misses.

2. Full associative cache have no conflict misses.

3. In reducing misses, associativity is more important than capacity.

1) No, compulsory miss can be reduced. It is like all places in cache is empty and No block yet came. So to reduce
compulsory miss take some block in cache

2)No, Conflict miss is there , when there is no place empty in cache. Associativity cannot say there is no conflict misses

3) No, I think they are equally important

Associativity is for conflict misses

when Capacity is for capacity misses

http://courses.cs.washington.edu/courses/cse378/02sp/sections/section9-2.html

 0 votes -- srestha ( 11585 points)

5.339 An instruction pipeline has five stages where each stage takes 2 nano
seconds.. top gateoverflow.in/29187

An instruction pipeline has five stages where each stage takes 2 nano seconds and all instructions uses all 5 stages .There
are 20% instructions. Branch instruction are not overlapped, i.e., the instruction after the branch is not fetched till the
branch is completed under ideal conditions. If a branch instruction is a condition branch instruction , the branch is need not
be taken . If the branch is not taken the following instructions can be overlapped when 80% of all branch instruction are
conditional branch instruction , and 50% of branch conditional instruction are such that the branch is taken . What is the
average instruction execution time ?

(A) 4 milli second.

(B) 3.6 milli second.

(C) 2.96 nano second.

(D) 3.34 nano second.


Selected Answer

avg ins time=1+(0.2*(0.8(0.5*4+0.5*0))+0.2*4)*2 ns

=(1+0.48)*2 =2.96

 1 votes -- Pooja ( 22773 points)

5.340 RISC processor window size top gateoverflow.in/28503

Assume that RISC processor contains 10 global registers, 10 local registers, 6 In register and 6 Out register. It contain 4
register windows what is the size of window and register file of the processor?

a) 30 and 74

b) 32 and 74

c) 22 and 64

d) 22 and 70

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 507 of 2244


Selected Answer

G: No. of global registers.

L: No. of local registers in each window.

C: No. of registers common to two windows W: No. of windows.

Window size (S): No. of registers available for each window.

Window Size= S= L+2C+G

Register file (F): Total no. of registers needed in the processor.

Register File= F= (L+C)W+G

B should be answer.

 2 votes -- Digvijay Pandey ( 26245 points)

5.341 "TLB with physically addressed cache" plz write expression for avg
mem access time??? top gateoverflow.in/28454

Given the following information:

TLB hit rate 95%, TLB access time is 1 cycle.


Cache hit rate 90%, cache access time is 1 cycle.
When TLB and cache both get miss; page fault rate is 1%.
The TLB access and cache access are sequential.
Access to main memory require 75 cycles.
Access to hard drive require 50, 000 cycles.

The average memory access latencies when the cache is physically addressed (in cycles) (up to 2 decimal places)
is__________.

co&architecture

Average memory access time =


TLBhit (TLB time + Cache Hit (Cache time ) + Cache Miss(Main memory time + Cache Time) )+
TLBmiss(TLB time+Main Memory Time + Cache Hit (Cache time ) +
Cache Miss ( Cache Time + Page Fault(HDD time) + (1-Page fault)Main memory time))
Verify once!!

 1 votes -- Umang Raman ( 10379 points)

5.342 Speed Up in pipeline top gateoverflow.in/28285

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 508 of 2244

answer = 2.105

 2 votes -- Amar Vashishth ( 17865 points)

5.343 DMA top gateoverflow.in/28762

consider the system in which cycle time is 500 ns. transfer of bus control in either direction, from processor to I/O device or
vice versa, takes 250 ns.one of the I/O device has a data transfer rate of 50 kB/s and employees DMA. data are transferred
one byte at a time. The time(in ms) would the device tie-up the bus when transferring block of 128 bytes is _______

109ns transfers 50*10 3B

1ns " (50*10 3)/109B

500 " ( (50*103)/109)*500B =0.025B

Now, 0.025 B transfers in 1 ns

1 B " " 1000/25 ns

128B " " 1000*128/25 =5120 ns = 5.12 ms

 0 votes -- srestha ( 11585 points)

5.344 DMA Q2 top gateoverflow.in/28834

The MegaGiga hard disk rotates at 10000 rpm (6 ms/rot) with a seek time given by = 1 + 0.001tmsec, where t is the number of
tracks the arm seeks. Assume a block size of 512 bytes, 1024 sector/track, 8192 tracks, and 4 platters. The disk has a 16MB
track buffer. The disk controller can DMA read or write data between memory and the disk device at a rate of 100MB/sec.

Estimate the worst case delay to read 512 bytes from this disk.

a. 25ms

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 509 of 2244

b. 15.2ms
c. 14.9ms
d. 26.3ms


Selected Answer

best match is b . 15.2 we have to calculate the worst case time delay and worst case will happen when everything will be
maximum,.

so it will be max seektime + max rotaional latency + maximum transfer time

transfer time here include both preparation time and then dma transfer time .

maximum seek time will be when i have to cross all the tracks = 1+0.001*8192= 9.192ms

maximum rotational latency = total time to take one round only. as in gneral case we divide with 2 . that is because on an
average the disk has to move half. 2 is for the average, but here we have not to consider the average case . so it will be
time to take one round . which will be equal to 6 ms.

now the transfer will be like. first the data will be buffered in the buffer and when 512 bytes wll be ready dma will be
called to transfer it to the memory .

so disk transfer rate will be .

one round = 6 ms

512*1024 bytes = 6ms

512 bytes = 0.058 ms.

now the data is available in the buffer now time taken by the dma

512 bytes / 100MB = negligible .

total time will be 9.192+6+0.058 = 15.25 ms option b .

 2 votes -- Ravi Singh ( 7303 points)

5.345 cache miss in two way set associative .. top gateoverflow.in/29182

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 510 of 2244

in this question as said block size contains two 32 bit word, and byte addressable, so each time fetching a block from main
mem will fetch 8 byte, so my doubt is, BCD address 200 and 204 in decimal 512 and 516, fetching block at address 200 also
contains bytes at address 204 so for 200 miss and 204 will next time, bcz 204 already fetched during fetching of 200

Cache contain 8 - 32bit word =8*4B= 32 B

Each block consists of 32 bit word= 4 B

No of block in cache = 32/4= 8

It is 2 way set associative

No of sets will be 8/2 =4

Hit ratio will be 2/11 =0.18

 1 votes -- srestha ( 11585 points)

5.346 Single accumulator organisation top gateoverflow.in/29055

The size of the instruction in a single accumulator is 16 bits. In order to evaluate the expression Y = A-B+C / E+F , how
much memory space is required to store the program?

a) 18 bytes

b)24 bytes

c)22 bytes

d)20 bytes

Load C

Div E

Add F

Add A

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 511 of 2244

Sub B

Store Y

there will be 2 Bytes

Ans will be 7*2 =14 Bytes

 0 votes -- srestha ( 11585 points)

5.347 associative cache top gateoverflow.in/28901

Consider a 32 bit processor that has an on chip 16Kbyte 4 way set associative cache. assume that cache has a size of four
32 bit words. the set no in the cache to which the word from memory location FFFAE8FA is mapped_________


Selected Answer

32 bit processor means word size = 32 bit = 4 Bytes

Cache Size is 16 KB , & associativity = 4

Block size = 4 words = 4*4B = 16 B

Now Address has 3 fields Tag , Set index , Block offset

Now, Block Offset = 4 bits (16 Bytes block )

set index dependes on number of sets -

Number of sets = Cache size /(Block size * Associativity)

= 16KB / (16 * 4 )

= 256 sets

So, set offset is 8 bits..

Now memory address is FFFAE 8F A

Here FFAE is tag

8F is set index which gives 143

and A is block offset.

 2 votes -- Himanshu Agarwal ( 8861 points)

5.348 made easy test flt advance pipeline plz expliain.. top gateoverflow.in/30167


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 512 of 2244

Fst pipeline cpi=1+.20 *1*. 30 =1.06

(Branch penalty is 1 stall)

second pipelinie cpi=1+2*.20*.35=1.14(Branch penalty is 2 stall)

Cpi=1 + branch freq ( those causing stall) *branch penalty

 2 votes -- Anurag Semwal ( 4775 points)

5.349 adv flt test madeeasy pipeline, no of cycle required?? top gateoverflow.in/30196

5.350 Number of dependencies top gateoverflow.in/31879

this is made easy question . ans provided in solution is 7

Lets mark the Instructions :

1 . R1 =100

2. R1 = R2 + R4

3. R2 = R4 + 25

4 . R4 = R1 + R3

5. R1 = R1 + 30 .

RAW WAR WAW


(1,2)
(2,3)
(2,5) (3,4)
(2,4) (4,5)
(2,4)
(2,5)

I am also getting 8 dependencies .

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 513 of 2244

 2 votes -- Riya Roy ( 4767 points)

5.351 Compulsary miss top gateoverflow.in/31858

I think compulsory miss could be reduced by putting the data initially in the cache.

 0 votes -- Monanshi Jain ( 5827 points)

5.352 DMA top gateoverflow.in/31720

Consider a system in which DMA technique is used to transfer 16 MB of data from an I/O device into memory. The bandwidth
of I/O device is 128 KB/s. What percentage of time is the CPU in busy mode (approximately)?

here the time for i/o transfer is not given.

 0 votes -- sonali gupta ( 27 points)

5.353 Pipeline speedup top gateoverflow.in/32037

Suppose there are 100 instructions ad we have a 6-stage pipeline, then if 25% of the instructions have 2 stall cycles, what is
the time taken by the pipeline?

Will it be 25*3+75=150 , or

6+25*3+74=155.

Why?

This is actually related to 2014 question, where we have to compute speedup; I did this way, for 150 i get 4, for 155 i get
3.8

Speed up =4

 0 votes -- Amey ( 195 points)

5.354 Pipeline top gateoverflow.in/32508

please draw chart for this question

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 514 of 2244


Selected Answer

10 cycles are required.

 0 votes -- Amar Vashishth ( 17865 points)

5.355 Cache Replacement poicies top gateoverflow.in/33350

When we are asked to find access time for a cache having write through or write back policy.....which cache access method
to apply(hierarchial or simultaneous).

nd also

Consider the following instructions.

I1 : R1 = 100

I2 : R1 = R2 + R4

I3 : R2 = R4 + 25

I4 : R4 = R1 + R3

I5 : R1 = R1 + 30

Calculate sum of (WAR, RAW and WAW) dependencies the above instructions. (a) 10 (b) 12 (c) 6 (d) 8

Q. When we are asked to find access time for a cache having write through or write back policy.....which cache access
method to apply(hierarchial or simultaneous) ?

Ans: In all such question, you will be given directly or indirectly which method to use either hierarchical or simultaneous.

For example : take this question for reference http://gateoverflow.in/11137/coa., in this they have clearly mentioned
what to do once miss occur at cache, then it will access from main memory and load it into cache then refer it, so this is
an example of hierarchical access.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 515 of 2244

Same way if it is simultaneous it will directly access it from the memory level it has found the word.it will not load it into
the first level and then access it.

I1 : R1 = 100
I2 : R1 = R2 + R4
I3 : R2 = R4 + 25
I4 : R4 = R1 + R3
I5 : R1 = R1 + 30

RAW ( true data dependency ) 4


I1 -> I5
I1 -> I4
I2 -> I5
I2 -> I4

WAR ( Write After Read ) 4


I2 -> I3
I2 -> I4
I3 -> I4
I4 -> I5

WAW ( Write After Write ) 3


I1 -> I2
I1 -> I5
I2 -> I5

Total = 4 + 4 + 3 = 11

 0 votes -- Sandeep Singh ( 5939 points)

5.356 privileged Instructions top gateoverflow.in/32772

What are Privileged Instructions. Describe briefly.

Also give some examples.

co&architecture

To put it simply, Privileged instructions required hardware support from the system, and so they are executed by OS.
Example, reading the output from the disk buffer.

Excellent quick reference : http://www.cs.princeton.edu/courses/archive/spr01/cs217/slides/21.os.pdf

 1 votes -- Utk ( 1385 points)

5.357 ROM - Timing Diagram top gateoverflow.in/32677

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 516 of 2244

digital-logic


Selected Answer

Ans : 1000

Explanation: Initially input to register A = Bus content at time t1 = 0110 .

After rising edge of clock t1,output of register A = 0110.Hence input of ROM = 0110.Now since enable E = 1,so ROM is
enabled and output of ROM = data present in ROM at address 0110 i.e DATA[6] = 1010 (from the table given).

Hence now BUS content will be = 1010.

Next after rising edge of t2, this input 1010 will appear as output of register A.Hence it will become input for ROM.

Again since E = 1,output of ROM = data at 1010 = data at address at 10 = data[10] = 1000

Hence content of BUS after t2 = 1000.

 1 votes -- Shashank Kumar ( 2029 points)

5.358 Pipeline top gateoverflow.in/31711

Consider a 5 stage pipeline with IF, ID, EX, MEM and WB latencies 8, 6, 4, 6 and 4 respectively (in ns). If IF stage is made
50% faster, the percentage it will improve the performance CPU is __________.

Ans: 25%

 1 votes -- Amey ( 195 points)

5.359 DMA top gateoverflow.in/31691

DMA interface unit eliminates the need to use CPU registers to transfers data from

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 517 of 2244

(a) MAR to MBR (b) MBR to MAR


(c) I/O units to memory (d) Memory to I/O units

5.360 cache mem with TLB ans ?? top gateoverflow.in/30805

Common Data Questions 50 and 51

A four-way associative writeback cache has a 211 ∗ 89-bit tag store. The cache uses a custom replacement policy that requires
9 bits per set. The cache block size is 64 bytes. The cache is virtually -indexed and physically tagged. Data from a given
physical address can be present in up to eight different sets in the cache. The system uses hierarchical page tables with two
levels. Each level of the page table contains 1024 entries.A page table may be larger or smaller than one page. The TLB
contains 64 entries.

Q50).How many bits of the virtual address are sued to choose a set in the cache?

(a). 11bits

(b). 12bits

(c). 13bits

(d). 14bits

Q51). What is the size of the cache data store?

(a). 512KB

(b). 256KB

(c). 128KB

(d). 1024KB

let s is no of bits for representing sets and given no of entries in each level page table is 1024 therefore no of tag bits is
20

[(2^s)*4*20+(2^s)*9]=(2^11)*89 =>s=11bits means 2048 sets

and as k is 4 ,no of blocks in cache = 2048*4=8096

Given each block is 64 bytes therefore cache size is 8096*64=512KB

50)A 51)A

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 518 of 2244

 1 votes -- saurav04 ( 649 points)

5.361 How to calculate total size of meta data for cache ? top gateoverflow.in/30346

An 16KB 4-way set associative write-back cache is organized as multiple blocks, each of size 64-bytes. The processor
generates 32-bit addresses. The cache controller maintains the tag information for each cache block comprising with 1 Valid
bit and 1 Modified bit. As many bits as the minimum needed to identify the memory block mapped in the cache. What is the
total size of memory needed at the cache controller to store meta-data (tags) for the cache?

co&architecture

processor generates 32 bit address

Block size 64 B=2 6 B

cache size 16KB= 2 14 B

No. of blocks in cache=2 14 / 26 =28

then No. of sets = 28 / 22 =26

So TAG size (32-(6+6)) =20 bits

Now cache block comprising of 1valid , 1 modified bit

So, TAG size 20+2=22 bits

To store metadata cache controller needed 22*2 8 =5632 bits

 2 votes -- srestha ( 11585 points)

5.362 Plz clarify top gateoverflow.in/30205

Is it that,RAW or true dependency can happen only for adjacent instructions?

data dependencies can happen anywhere for any order of instructions.Plz clarify

5.363 Which of the following is most relevant addressing mode used to write
code in which reallocation done at run time? top gateoverflow.in/31559

Q.14
Which of the following is most relevant addressing mode used to write code in which reallocation done at run time?

Indexed mode
Indirect mode
Direct mode
Relative mode

Related to

http://gateoverflow.in/3578/gate2006-it_39

http://gateoverflow.in/1656/gate1998_1-19

co&architecture made-easy test-series

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 519 of 2244

5.364 Made Easy Advanced FLT 1 Q 27 top gateoverflow.in/31596

Q.27
Consider a CPU where 150 instructions take 8 clock cycles each to complete the execution. A horizontal microprogrammed
control unit has to generate 125 control signals. What is the minimum size of control word? _______

Answer given is 136 (multiple of 8 bit)
Actual No of bits required is 133. Do we always need multiple of 8 ? Here issue is that they have not specified unit (Bit or
byte) , Neither they have given that answer should be multiple of 8 , if it is in bit !

numerical-answers test-series made-easy

Horizontal Control Word Format is

Branch Control Signal


Flags CM Address
condition Field

Nothing is mention in question about Branch condition.

so number of bits for Branch Condition = 0

Same with flag, number of bits for flags = 0

Control field indicates the control signal which is 125 Control Signal.Since Horizontal control Word uses decode binary
format to represent control signal i.e. 1 bit per control signal.

So number of bits required for Control Signal Field = 125 bits

Given Number of Instruction = 150 and number of cycle/instruction = 8

So total number of cycle required in 150 instructions = 150 * 8 = 1200 cycle

In Control Unit 1 micro operation require 1 cycle so total number of micro operation = 1200 micro operation

1 micro operation require 1 Control Memory Word Storage.

So total size of control memory = 1200 Control Memory Word

number of bits required to represent Control Memory Address = Ceil( log 2 1200 ) = 11 bits

Minimum Size of Control Word = 0 + 0 + 125 + 11 =136 bits

** Control Word Size is not always mandatory to be multiple of 8. Actually there is no need of specifying bit or bytes in
this question.

 2 votes -- Sandeep Singh ( 5939 points)

5.365 Pipeline top gateoverflow.in/31681

plz explain it........

Consider a pipeline ‘x’ consist of 5 stages named as IF, ID, OF, EX and WB with the respective stage delays of 2 ns, 5 ns, 6
ns, 8 ns and 1 ns. The alternative pipeline ‘y’ contain the same number of stages but EX stage is divided into 4 sub stages,
(EX1, EX2, EX3 and EX4) with equal delay i.e. (8 ns/4) and ID stage is divided into 2 substages (ID1 and ID2) with equal
delays of (5 ns/2). In the pipeline x and y memory reference instructions are not overlapped so the penalty of memory
reference instructions in the pipeline ‘x’ is 4 cycles and in the pipeline ‘y’ is 8 cycles. If the program contains 30% of the
instructions which are memory based instructions, the speedup ratio of x is speedup ratio of y is ___________.

X = [IF] [ID] [OF] [EX] [WB]; Clock = 8ns

Y = [IF] [ID1] [ID2] [OF] [EX1] [EX2] [EX3] [EX4] [WB]; Clock = 8ns

For X:

Let number of instructions be 100.

70 inst. of CPI = 1, 30 inst. of CPI = 5

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 520 of 2244

Thus Total Execution time = 70 x 1 x 8 + 30 x 5 x 8 = 1760 ns

Total Execution Time without pipeline = 100 x 22ns = 2200 ns

Thus Speedup(x) = 2200/1760 = 1.25

For Y:

Let number of instructions be 100.

70 inst. of CPI = 1, 30 inst. of CPI = 9

Thus Total Execution time = 70 x 1 x 8 + 30 x 9 x 8 = 2720 ns

Total Execution Time without pipeline = 100 x 51ns = 5100 ns

Thus Speedup(y) = 5100/2720 = 1.875

Therefore, Speedup(x)/Speedup(y) = 0.666 or 66.66%

 0 votes -- Morphine ( 273 points)

5.366 Set associative cache top gateoverflow.in/31647

in this question how we can know set associativity.

Consider two cache organizations. The first one if 64 KB way associative with 64 byte block size. The second one is of the 64
KB direct mapped cache. The size of an address is 32 bits in both organizations. A 4 to 1 multiplexer has latency of 0.8 ns
which k bit comparator has latency of k/5 nsec. The difference between the hit latencies of both cache organizations (i.e.
associative hit latency – direct mapped hit latency) (in nsec) is ___________.


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 521 of 2244

as per given 4:1 mux,if we consider it is 4 way associative then answer is 1.2 ns.

 0 votes -- Sayantan Ganguly ( 5061 points)

There will be something n way set associative,else we can't determine set offset.The qs seems wrong..

 1 votes -- Sayantan Ganguly ( 5061 points)

5.367 Madeeasy Test Series top gateoverflow.in/28231

Suppose that in 1000 memory references there are 150 misses in first level and 100 misses in second level cache. Assume
that miss penalty from L2 cache to memory is 120 cycles. The hit time of L 2 cache is 50 cycles.

If there are 4 memory references per instruction, the average stall per instruction is


Selected Answer

Tavg stall/ints = Miss in L1/int * Hit in L2 + Miss in L2/int * Miss Penality in L2(memory access )

here 4 memory for 1 instruction


so for 1000 memory = 1000/4 = 250

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 522 of 2244

Miss in L1 = 150 Miss in L2 = 100 Hit time L2 = 50 Miss penalty L2 = 120

150 100
250
therefore Tavg stall/ints = *50 + 250 *120 = 78

 2 votes -- Umang Raman ( 10379 points)

5.368 Madeeasy test series top gateoverflow.in/28222

Suppose that a cache is 20 times faster than main memory and cache memory can be used 80% of the time. The speed up
factor that can be achieved by using the cache is


Selected Answer

Let Cache access time is X, then main memory access time will be 20X .

Speed up factor = (Time taken to get data W/O Cache)/ (Time taken to get data with Cache)

Time taken to get data W/O Cache: 20X

Time taken to get data with Cache: .8X + .2(20X) =4.8X

Then speed up will be 20X/(4.8X) = 4.166 (Answer)

 3 votes -- priyavssut ( 411 points)

Hierarchical access to main memory..


T​c : Cache Access Time, T​m : Memory Access time, Tm = 20T​c, Hit Ratio = 0.80

Effective access Time = Tc + 0.20 *Tm = Tc + 0.20*20Tc = 5*Tc


Speed Up = Memory Access Time Without Cache / Memory Access Time With Cache
= Tm/Effective Access time = 20*Tc/5*Tc

Speed up = 4

 3 votes -- Digvijay Pandey ( 26245 points)

Soverall = ((1-∑f) + ∑ s )-1



.8

= ((1-.8) + ( 20 ) -1

= 4.166

 1 votes -- Umang Raman ( 10379 points)

5.369 CA q 19 top gateoverflow.in/20305

A weather forecasting computation requires 250 billion floating point operations. The problem is processed in a super
computer that can perform 100 mega flops. How long will it take to do these calculations?(in mins)

a. 21.32 b. 31.42 c. 41.67 d. 38.67

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 523 of 2244

co&architecture

5.370 Drdo 2008 q-14 ch-3 top gateoverflow.in/21307

With reference to the return instruction. Which of the following statement is / are true?

1. The instruction can be used only to take the flow of control back to the program from which it initially jumped.

2.The instruction retrieves the address using the current stack pointer from the stack and alters the control to the program
pointed to by it.

3. The instruction works only if the registers used in the main program have been pushed and later popped before its
execution.

4.The instruction can be used only in conjunction with the call instruction.

A. 1st and 2nd

B. 2nd only

C. 1st, 2nd and 4

D. All the statement are true

co&architecture

4 certainly all are true

 0 votes -- nihit ( 11 points)

5.371 Drdo top gateoverflow.in/21184

In the NONIX operating system, the time required for various file read operations are given below:

Disk seek time: 25 msec

Disk latency time: 8 msec

Disk transfer time: 1 msec/Kbyte

Operating system overheads: 1 msec/Kbyte + 10 msec.

What is the time required to retrieve a block of 2Kbytes?

A. 45 msec B. 47 msec

C. 90 msec D. 94 msec

co&architecture operating-system

8 + 2 + 2 + 10 + 25 = 47 ms.

 0 votes -- Arjun Suresh ( 124125 points)

5.372 Find out the content of the register pair top gateoverflow.in/21082

Following is the code segment for 8085 microprocessor:

1000 LXI SP, 27FF H

1003 CALL 1006

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 524 of 2244

1006 POP H

Contents of SP and HL register pair on completion of execution of these instructions are:

a) SP=27FF, HL=1003

b) SP=27FD, HL=1003

c) SP=27FF,HL=1006

d) SP=27FD,HL=1006

co&architecture

5.373 Q34- The above circuit represents __________ stages. top gateoverflow.in/21300

A. n states

B. (n-1) states

C. 2n states

D. 2n-1 states

co&architecture

5.374 consider the floating point representation, for each part provide ans as
true or false... top gateoverflow.in/20849

TRUE/FALSE

biased
id sign mantissa
expo
1 0 00000001 00000000000000000000000 is first smallest no in IEEE 754 representationid
11111111111111111111111 is largest no represented through IEEE
2 0 11111110
754
3 0 00000000 00000000000000000000001 is smallest de-normalized no
4 0 00000000 11111111111111111111111 largest unnormalized no
11111111111111111111111111 largest no represented through
5 0 11111111
IEEE 754
6 0 00000000 10000000000000000000000000 smallest normalized no

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 525 of 2244

7 0 00000000 10000000000000000000000001 2nd smallest normalized no


1000000000000000000000000 is first smallest no in IEEE 754
8 0 00000000
representationid
1000000000000000000000000 is 2nd smallest no in IEEE 754
9 0 00000001
representationid
000000000000000000000001 is 2nd smallest no in IEEE 754
10 0 00000001
representationid
11111111111111111111111111 largest no represented through
11 0 11111111
IBM 370

For each id(row i.e exponent and mantissa) there is a corresponding red statement you hv to tell that it is true or false.

All 0 exponent and non-zero mantissa means a number is denormalized in IEEE 754 - no implied 1 before ".". Also, bias
for denormalized numbers is "-126" and that for normalized is "-127".

IEEE 754 Single precision


Exponent Sign Mantissa Value Remark
00000000 0 00...0 0 Special value 0
00000001 0 00...0 1.0 × 2 −126 Smallest positive normalized number
00000000 0 00...001 1.0 × 2 −149 Smallest positive denormalized number
When exponent is all 1's number is NAN.
100..0 Mantissa here can be any non-zero
11111111 0 ... QNAN value. If mantissa starts with 1, it is
111..1 QNaN meaning the value is
indeterminate.
Same as above but mantissa bits
000...1 starting with 0 and used to represent
11111111 0 SNaN
0111...1 Signalling NaN which are used to
represent invalid numbers.
11111111 0 000...000 +∞ Positive infinity
11111110 0 1111...1 (2 − 2 −23) × 2127 Largest normalized number

00000000 0 ( )
111...111 1 − 2 −23 × 2 −126 Largest de-normalized number

Similarly, we can see for negative numbers.

Ref: http://steve.hollasch.net/cgindex/coding/ieeefloat.html

 1 votes -- Arjun Suresh ( 124125 points)

5.375 Minimum and maximum (-ve) mantisa range in IEEE 754 32 bit gateoverflow.in/20841

top

Minimum and maximum (-ve) mantisa range in IEEE 754 32 bit floating point number representation with 1bit for sign, 8 bit
for exponent and 23 bit for mantisa.

co&architecture


Selected Answer

i think the range will be from all zeros to all once. so mantissa can be from 1.0000000....00 to 1.11111111...111 = 1 to
2 − 2 −23

 0 votes -- Ravi Singh ( 7303 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 526 of 2244

5.376 The number of bits (in binary) required to represent 25-digit decimal
number top gateoverflow.in/20746

The number of bits (in binary) required to represent 25-digit decimal number

digital-logic


Selected Answer

The concept is the maximum number of 10 digit number by 10 digit should be equal to x digit number in base 2.

so 1025-1 = 2x-1

taking log both side . take log of base 2 so that RHS can become x

25log10 base 2 = x.

x=82.5 .so to represent we will need 83 digits.

 0 votes -- Ravi Singh ( 7303 points)

5.377 page replacement top gateoverflow.in/20086

An 8 byte, 2-way set associative (using LRU replacement) with 2 byte blocks receives requests for the following addresses
(represented in binary): 0110, 0000, 0010, 0001, 0011, 0100, 1001, 0000, 1010, 1111, 0111 .

How page replacement is done?What are the types of misses occured in this case?


Selected Answer

cache size = 8 byte


Block size= 2 byte and 2 way set associative
so number of cache line 8/2=4(2bit)
number of set = 4/2 = 2(1bit)

Compulsory miss: Miss occur by the first reference to a location. (Will happen even in an infinite size cache but may be
reduced if we use a larger block size)
Conflict miss : Misses which happen due to collision. In a set associative cache of set size say 2, 2 blocks can live together
and on 3rd entry, we have a collision and one block is removed. If a miss happens due to this removal, it is counted as
conflict miss.
Capacity miss : A capacity miss occurs when a memory location is accessed once, but later because the cache fills up, that
data is discarded. And this is assuming the cache is fully associative (no conflict miss).

Word
Tag set
1bit
2bit 1bit

All the given address will use this instruction set to identify there set and line.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 527 of 2244

01 1 (set 1) compulsory miss


00 0 (set 0) compulsory miss
00 1 (set 1) compulsory miss
00 0 (set 0) hit (already there)
00 1 (set 1) hit (already there)
01 0 (set 0) compulsory miss
10 0 (set 0) compulsory miss.
00 0 (set 0) conflict miss
10 1 (set 1) compulsory miss.
11 1 (set 1) compulsory miss
01 1 (set 1) conflict miss/capacity miss

To get the capacity miss we can count the no. of unique block accesses before the access causing the miss and after that
particular block was last accessed. For example, in above case 011 is causing capacity miss as after its last access we
have unique block accesses to 000, 001, 010, 100, 101, 111 − 6 unique accesses and we have only space for 4 − 1 = 3 more unique
accesses. Thus this miss becomes a capacity miss. 000 is not a capacity miss because after the previous access to 000, we
only have 3 unique block accesses - 001, 010, 100, which means in a fully associative cache (of the given size) this would not
be causing a miss.

 6 votes -- Umang Raman ( 10379 points)

the first approach to this type of question involve conversion of binary to decimal and apply the property of set assosiative
cache.
which is surely wrong. because they have not said anywhere that binary number are page refrences they are saying these
are the address refrences. Reading the question with a little bit of patience is the key and is not as simple as it seems. i
lost one year for the same. plz practice for this a lot. otherwise u are surely going to loose a lot of marks.

coming to question. as they are addresses we have to consider as computer sees them . 8 bytes of memory with 2 per
block .

total number of cache lines . = 8/2 =4

total number of sets = 4/2( 2 way set ass.)

now every set will contain 2 cache lines 00,01 . as it is 2 way set asso.

now consider the address as cache controller handles it. every address refrence is compared with the the format the cache
controlled is programmed for . for ex here for set associative it will see it as . TAG SET OFFSET AND WORD OFFSET.

word offset will be one bit because the size of block is 2 bytes.

set offset will be 1 bit . 2 cache sets only

and remaining for tag.

so the first address which is 0110. the last bit is representing the byte which we want to get. second last the set it will go
in and remaining the tag line they will go in .

NOTE: 0110 and 0111 are refrences for same page but different bytes. so no miss .

now just apply the concept and get the answer .


 2 votes -- Ravi Singh ( 7303 points)

5.378 How many zero address instructions are there? top gateoverflow.in/19850

X=(M+N*O)/(P*Q) How many zero-address instructions are there?

I did it.Just want to check whether it is right?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 528 of 2244

PUSH P

PUSH Q

MUL

PUSH N

PUSH O

MUL

PUSH M

ADD

DIV

POP X

So total 10 instructions required.Correct?

No of instructions required will be dependent on architecture set...Say if there is no Mul instruction then we need to mul
instruction by using add instruction...so to ans que we need to know architecture or instruction set

 0 votes -- Pooja ( 22773 points)

5.379 Find out the value of PC(Program Counter)? top gateoverflow.in/18633

A computer has 24-bits instructions.A program has been loaded into main memory with starting address of
300.Which of the following is the valid value for the PC(Program counter)?

1.400

2.500

3.600

4.700

co&architecture

Here, size of instruction = 24/8 = 3 bytes. Program Counter can shift 3 bytes at a time to jump to next instruction. So the
given options must be divisible by 3. only 600 is satisfied.

 0 votes -- admin ( 1411 points)

5.380 capacity of disc pack and the number of bits required to specify a
particular sector in the disc are respectively top gateoverflow.in/18599

Consider a disk pack with 16 surfaces , 128 tracks per surface and 256 sectors per track.512 bytes of data are stores in a bit
serial manner in a sector.The capacity of the disc pack and the number of bits required to specify a particular sector in the
disc are respectively

a)256 Mbyte,19 bits

b)256 Mbyte, 28 bits

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 529 of 2244

c)512 Mbytes,20 bits

d)64 Gbytes,28 bits


Selected Answer

Capacity of disk= no of surfaces* no of tracks/surface* no of sectors/track* data / sector


=16*128*256*512=2^28B=256MB No of bits require to identify sector of particular track of partiular surface =bits to
identify surface+bits to identify track+bits to identify sector=4+7+8=19 bits So ans is a

 1 votes -- Pooja ( 22773 points)

5.381 On receiving an interrupt from an I/O device,the CPU top gateoverflow.in/18581

On receiving an interrupt from an I/O device,the CPU

a)Halts for a predetermined time

b)Branches off to the interrupt service routine after completion of the current instruction

c)Branches off to the interrupt service routine immediately

d)Hands over control of address bus and data bus to the interrupting device


Selected Answer

CPU checks the status bit of interrupt at the completion of each current instruction running when there is a interrupt it
service the interrupt using ISR.

so OPTION B)Branches off to the interrupt service routine after completion of the current instruction

 0 votes -- Umang Raman ( 10379 points)

5.382 Count the no. of clocks in a 4 stage pipeline top gateoverflow.in/18934

A 4-stage pipelined processor executed the following loop:

for(i=1;i<=100;i++)

I1; I2; I3; I4;

What is the no. of clocks to execute the above loop?

a.13 b.15 c.16 d.18

S1 S2 S3 S4
I1 1 2 1 2
I2 2 1 2 1
I3 1 1 2 1

I4 2 1 2 1

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 530 of 2244


Selected Answer

if we use without loop level parallelism than it will take 1100 clock cyles becoz loop is from i=1 to 100
as also for first i=1. it will take 11 cycles similalry for next 100 it will take 1100 cycles...

and with loop level parallelism it will take 11*1+99*7=704 cycle .

 0 votes -- kunal chalotra ( 3567 points)

5.383 ISRO 2011/5 : MOV[BX], AL is what type of addressing? top gateoverflow.in/19326

MOV [BX], AL type of data addressing is called ?


A) register

b) immediate

c) register indirect

d) register relative

isro co&architecture

MOV [BX],AL

move the contents of AL to memory location whose address is in BX

say [BX]=200

so AL contents are moved to memory location 200

it is example of register indirect..

 1 votes -- Pooja ( 22773 points)

5.384 ISRO_A 2015/34 top gateoverflow.in/19493

A hard disk system has the following parameters:

Number of track=500

Number of sectors/track=100

Number of bytes/sector=500

Time taken by the head to move from one track to adjacent track=1 ms

Rotation speed=600 rpm

What is the average time taken for transferring 250 bytes from the disc?

a)300.5 ms

b)255.5 ms

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 531 of 2244

c)255 ms

d)300 ms

Refer to this.:http://gateoverflow.in/3479/gate2007-it_44

 0 votes -- Rohan Ghosh ( 1515 points)

5.385 ISRO_A 2015/62 top gateoverflow.in/19446

The minimum time delay between the initiation of two independent memory operations is called

a)Access time

b)Cycle time

c)Rotational time

d)Latency time

(b) option..

 0 votes -- kunal chalotra ( 3567 points)

5.386 Dependency top gateoverflow.in/25085

Consider the following program segment: What types of dependencies were included in the above program?

I1 : MOV R3 , R7 ; R3  (R7 )

I2 : Load R8 , (R3 ) ; R8  Mem(R3 )

I3 : Add R3 , R3 , 4 ; R3  (R3 ) + 4

I4 : Load R9 , (R3 ) ; R9  (R3 )

I5 : BLE R8 , R9 , L3 ; Branch if (R9 ) > (R8 )

A). Write after write and read after write.

B). Write after write and write after read

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 532 of 2244

C). Read after write and write after read

D). Write after write,read after write, and write after read

Ans will be D

for eg:I1 I2-RAW(for r3)

I1 and I3-WAW (for r3)

I2 andI3-WAR(it is also for r3)

 1 votes -- srestha ( 11585 points)

5.387 Access Efficiency of a cache top gateoverflow.in/25555

Q. the access time of cache is 100 microsec, the access time of main memory is 900 microsec. and hit ratio is 95%, then
what is the access efficiency related to cache?

In this ques. what is meant by "access efficiency related to cache"?

Memory access time = 900 microsec.

Effective memory access time with cache = .95 * 100 + 0.05 * 1000 = 145 microsec.

Decrease in memory access time 755


Original memory access time
So, efficiency of cache = = 900 = 83.9%

Not sure if this is correct..

 0 votes -- Arjun Suresh ( 124125 points)

5.388 madeeasy test2015 top gateoverflow.in/27737

Here CX is not decrementing..typo in question. CX will never be zero..

 0 votes -- akash ( 735 points)

5.389 TEST SERIES question top gateoverflow.in/27688

Given Ts : Transfer time.

b: Number of bytes to be transfered.

N: Number of bytes on a track.

r: Rotational speed.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 533 of 2244

Which of the following expression gives the total avg access time?

a. Ts+(r/2)+(rb/N)

b. Ts+(1/2r)+(rb/N)

c. Ts+(1/2r)+(N/rb)

d. Ts+(1/2r)+(b/rN)


Selected Answer

Avg access time=seek time+rotational latency+ transfer

Rotational latency=1/2 rotational time

=1/2r

Transfer time =b/Nr

So ans is d

 2 votes -- Pooja ( 22773 points)

5.390 LRU policy for block replacement / top gateoverflow.in/27561

a computer system contain a main memory of 32k 16 bit words. it also has 4k word cache divided into 4 slot sets with 64
word per slot. assume that the cache is initially empty.

given data: | tag 3 bit | set 4 bit | word 6 bit | and no of cache line 2^6

The processor fetches word from locations 0,1,2,.............4531 in that order. it then repeats this fetch sequence 9 more
times. Assume a LRU policy for block replacement . how many miss operation occur in total??

5.391 no of clock cycle required for bellow figure "in case of no operand
forwarding used" ?? top gateoverflow.in/27741

In case of no operand forwarding

12 cycles are required. Id stage get operand after WB..

 3 votes -- Anirudh Pratap Singh ( 4091 points)

Nothing given, am considering risc pipelining. Data Mem accessed during MA stage only. It will take 11 cycles

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 534 of 2244

 1 votes -- Anurag Semwal ( 4775 points)

5.391 branch delay slot top gateoverflow.in/27968

5.392 effect on increasing no stages in pipeline.... top gateoverflow.in/28175

In a CPU, what is the benefit of having many pipeline stages?


Why speedup reduces with increase in number of pipeline stages?
Why increased pipeline depth does not always mean increased throughput?
why long pipeline lead to lower CPI?
what will be the effect on friquency when of of stages increased.

no advantage in having too many pipeline stages, Objective of Classic RISC pipeline is to make CPI = 1, with the purpose of reducing
average instruction execution time. Achieve that no matter how many stages.
increase in the number of pipeline stages will involve more buffer registers between stages, thereby reducing speed of overall pipeline.
frequency of what? system? if of system then it depends on the processor's clock not stages.

 0 votes -- Amar Vashishth ( 17865 points)

5.393 Bits Required top gateoverflow.in/28009

A) How many bits do you need to write 10^n in binary?

B) How many bits are required to represent the nth Fibonacci number in binary?

algorithms co&architecture normal

http://gateoverflow.in/20746/number-bits-binary-required-represent-digit-decimal-number

 0 votes -- Digvijay Pandey ( 26245 points)

5.394 Using a sequential implementation , it takes a total of 320ns for each


instruction .. top gateoverflow.in/27984

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 535 of 2244

5.395 throughput of pipeline top gateoverflow.in/26662

using a sequential implementation, it takes a total of 320 ns for each instruction, 300ns for combinational logic to complete
and 20 ns to store result. This means that a throughput will be 3.12 millions instructions/second. assuming you switch to a 3
stage pipeline by splitting the combinational logic into 3 equal parts and all reg. take 20ns to store results.Assuming pipeline
never starts, what will be the improvement in throughput?

2 instructions/sec 3 instructions/sec 4 instructions/sec

Time in pipeline=100+20+20=140

Throughput=1/140ns=7.14

So improvement=7.14-3.12=4.02

 0 votes -- Pooja ( 22773 points)

5.396 booth's multiplication algorithm top gateoverflow.in/26660

is booth's multiplication algorithm included in gate syllabus?

5.397 pipeline speed up top gateoverflow.in/25674

consider unpipelined machine with 12 ns clock cycles. It uses 4 cycles for alu operation and branches, whereas 5 cycles for
memory operations. Assume that the relative frequencies of these operations are 30% 20% 20%.Pipelining overhead is 1 ns.
The speedup of the pipeline is:
2.0 3.1 2.8 3.5


Selected Answer

.3 ∗ 4 +.2 ∗ 4 +.2 ∗ 5
.3 +.2 +.2
CPI = = 4.2
clock cycle timenon-pipeline = CPI*Clock cycle = 4.2*12 = 50.4

CPI pipeline = 1
Clock cycle time = 1*(12+1) = 13

50.4

S = 13 = 3.87

 1 votes -- Umang Raman ( 10379 points)

5.398 clash of cache block replacement and page replacement top gateoverflow.in/25673

can cache block replacement and page replacement activities clash with each other?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 536 of 2244

No.

They may/may not occur at different levels for same instruction, but their event will not affect the result of the
instruction.

The doubt is, Will there be definitely a cache miss for something in instruction if there was a page fault for the same
instruction?

 0 votes -- CrimeMasterGoGo ( 2221 points)

5.399 cost per bit of the system top gateoverflow.in/25556

What will be the average cost per bit for a system with main memory of 1024 cost, 100 units and secondary memory of 4096
cost, 10 units?

35.7 28.0 82.0 none

5.400 assembly program for c code fragment top gateoverflow.in/26176

Consider c code:

for(i=0;i<=100;i++)

A[i]=B[i]+C;

A & B are 64 bit arrays and C & i are 64 bit integers. Assume instruction size to be 4 bytes. A, B, C and i are at addresses
0,5000,1500 and 2000.Assume that the values in registers are also between iterations of the loop. Write the assembly code
for the c code fragment.

5.401 percentage of time of cpu blockage during dma transfer top gateoverflow.in/26367

Consider a disk drive with following specifications: 16 surfaces, 512 tracks/surface, 512 sectors/sector, 1KB/sector, rot.
speed 3000rpm. The disk is operated in cycle stealing mode whereby whenever one byte word is ready it is sent to memory;
similarly for writing the disk surface reads a 4 byte word from the memory in each dma cycle. Memory cycle time is 40ns.
The max. percentage of time that cpu gets blocked during dma operation:

10% 25% 40% 50%

Let x be preparation time and y be transfer time

y
Then % of time CPU Blocked = x + y ∗ 100

Total byte to be transfer =


1 byte word is ready it is sent to memory + 4 byte word for writing in each dma cycle
= 5 Byte
60
3000
X = In one rotation sec it reads 512 KB
so how much time for 5 B ?

= 195ns(approx)

Y = 5*memory cycle time


5*40 = 200ns

y 200
Therefore x + y ∗ 100 = 200 + 195 ∗ 100 = 50%

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 537 of 2244

 0 votes -- Umang Raman ( 10379 points)

5.402 number of lines in cache top gateoverflow.in/26659

the mapping function is implemented using the address. For purpose of cache access each main memory address can be
viewed as containing three fields: the least significant w bits identify a unique word or byte within a block of main memory.
the remaining s bits specify one of the 2^s blocks of main memory. The cache logic interprets these s bits as a tag of s-r bits
and a line field of r bits.The number of lines in cache equal to?

2^r 2^(r+w)

Line field of r bits means 2r cache lines (blocks).

There can be 2s−r distinct memory blocks going to each cache line and that is why we need s − r tag bits to identify which
memory block is currently present.

2r+w will be the size of cache- ignoring tag entries.

 0 votes -- Arjun Suresh ( 124125 points)

5.403 cache- main memory mapping top gateoverflow.in/26658

A CPU has cache with block size 64 bytes. The main memory has k blocks, each being c bytes wide. Consecutive c byte
chunks are mapped on consecutive blocks with warp around. All the k blocks may be accessed in parallel, but two accesses
to the same block need to be serialized. A cahe block access may involve multiple iterations of parallel block accesses
depending on the amount of data obtained by accessing all k blocks in parallel. Each iteration requires decoding the block
numbers to be accessed in parallel which takes k/2 ns. The latency of one block access is 80ns. If c=2 and k=24 then latency
of retrieving a cache block starting at address zero from main memory is

92ns 104ns 172ns 184ns

5.404 Question on constructing larger RAM from smaller RAM top gateoverflow.in/33630

Given explanation:

Please explain me the given explanation of this question (if possible with a dig),

co&architecture

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 538 of 2244

6 Operating System top


6.1 Ace Test Series: How many distinct values are possible in this parallel
program? top gateoverflow.in/35692

Anybody getting 4th value??

operating-system process-synchronization ace-test-series

ans is 4

 0 votes -- govind ( 255 points)

6.2 Address: total address space top gateoverflow.in/44298

For a computer address,if we reduce the no of bits by 2 and if we double the addressability then
total address space will be

1) Doubled 2) halved 3) Remain Same 4) None

What is meant by Addressablity???

computer-networks memory-management operating-system address

3)Remain same

Adressable means at a time how many bits or Bytes it is accessing

Byte Addressable means it is accessing 8 bit at a time

 0 votes -- srestha ( 11585 points)

6.3 Bitmap: Calculate Number Of Disk Block using bitmap method top gateoverflow.in/30585

For a Hard disk of Capacity 20 MB . Disk block address of 16 bits and disk block size of 1 KB . The number of disk blocks
required to store all the Free Blocks using Bitmap method is

1
2
3
None

bitmap operating-system file-system

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 539 of 2244


Selected Answer

1 block=1kB=2^10*8 bits

no of blocks=20*2^20/2^10=20*2^10 blocks

no of blocks to require to store bit map=ceil(20*2^10/2^10*8)

=ceil(2.5)=3

so 3 blocks required

 4 votes -- Pooja ( 22773 points)

6.4 Cache Memory: Cache + VM top gateoverflow.in/36279

Q. are all these equal?


Cache line size = Main memory block size = Virtual Memory Page size = Main memory Frame size?

please clear the confusion between both these processes, whether they occur simultaneously or not and how?

cache-memory


Selected Answer

In the discussion
https://docs.google.com/document/d/1yOhA-OFenops6oqmdAw6yBGCpLpzLxF_eSl1tOyzF6w

It has been mentioned that virtual/main memory is divided into pages/frames and cache block is a smaller division of the
same.

So i got it almost. I hope you too did!


:)

 0 votes -- Aspi R Osa ( 1305 points)

6.5 Computer Organization: Percentage Improvement top gateoverflow.in/36675

A magnetic disk has following specs:

# 0f tracks=1024

#of sectors/track=512

#of Bytes/sector =512

Disk Rotation speed=7200rpm

a)What is the percentage of improvement(approx) in average access time ,if disk speed is doubled?

a)16% b)18% c)19% d)None

computer-organization disk operating-system

6.6 Concurrency: Question on Bersteins condition top gateoverflow.in/18986

Let S1: a = x + y and S2: b = z + 1


Then R(S1) = {x, y}, R(S2) = {z}; similarly W(S1) = a and W(S2) = b.
Which of the following is true?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 540 of 2244

Bernstein's conditions are not satisfied but statements are executed concurrently.

Bernstein's conditions are not satisfied, so statements are not executed concurrently.

Bernstein's conditions are satisfied, hence statements are executed concurrently.

None of these.

operating-system concurrency


Selected Answer

Bernstein's conditions are satisfied, hence statements are executed concurrently.

Bernstein condition is satisfied in following cases

1)R(S1)∩W(S2)=∅

2)W(S1)∩R(S2)=∅

3)W(S1)∩W(S2)=∅

two statements dont have any dependency and can be executed parallely

 0 votes -- Pooja ( 22773 points)

6.6 Concurrency: Given a code snippet as question,are there any fast tricks
to Test the three neccesary conditions for the process synchonization. gateoverflow.in/3771

top

operating-system process-synchronization concurrency

First do check for mutual exclusiveness. Then do for bounded waiting and progress. Its not difficult to do- in coming week
we will take on all previous questions given below and the same technique should work in almost all of them.

http://gateoverflow.in/tag/process-synchronization

 0 votes -- Arjun Suresh ( 124125 points)

6.7 Concurrency: Concurrency top gateoverflow.in/2402

Consider the following sequential code which is executed in a multiprogramming mode by assuming that each statement can
execute independently to achieve the concurrency. If any statement dependent on other statements then those statements
will be executed in the order.

S1: a = b + c;
S2: x = y + z;
S3: y = a + c
S4: q = y + z
Which of the above statements can execute concurrently at the beginning of execution?

a)S3 and S 4

b)S2 and S 3

c)S 1 and S 2

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 541 of 2244

d)S2 and S 4

operating-system concurrency

I think the answer is d. S1 executes first then S3(which uses value of a to calculate y) and then any of S2 or S4
executes(which use value of y). What is your opinion?

 1 votes -- Keith Kr ( 5467 points)

6.8 Context Switch: Context Switch top gateoverflow.in/20094

context-switch

http://stackoverflow.com/questions/7439608/steps-in-context-switching

a. Hardware support speeds up context switching- for example saving/restoring registers.

b. Memory speed also matters- because process state is saved on stack and it is in memory.

c. Also matters as it can be attributed to special hardware

d. process size also matters as say for example, for a smaller process we require small amount of page tables (assuming
multilevel paging).

e. Matters as long as register copying doesn't work in parallel, anyway this is not in options.

 0 votes -- Arjun Suresh ( 124125 points)

6.9 Deadlock: Predict the state of this system? top gateoverflow.in/16961

Consider the following process and resource requirement of each process.

Type 1 Type 2
Process
Used Max Used Max

P1 1 2 1 3

P2 1 3 1 2

P3 2 4 1 4

Predict the state of this system ,assuming that there are a total of 5 instances of resource type 1 and 4 instances of resource
type 2.

a)Can go to safe or unsafe state based on sequence

b)Safe state

c)Unsafe state

d)Deadlock state

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 542 of 2244

deadlock

The system is in an unsafe state. In order to be sure a process can complete, it will need its request of all resource types
to be satisfied, so you need to look at the need for each process for all resource types and see if what is available can
satisfy any process’s needs. In this example we have the following needs: Process Type 1 Type 2 P1 1 2 P2 2 1 P3 2 3 As
we have only 1 unit of each resource type available, and no process has a need that can be satisfied, so the system is
unsafe.

 0 votes -- admin ( 1411 points)

6.10 Deadlock: deadlock top gateoverflow.in/29245

if system is in unsafe state then deadlock may or may not occur

but in bankers algorithm if system found in unsafe state how to check further for deadlock. explain with example

deadlock

http://www.cs.jhu.edu/~yairamir/cs418/os4/sld025.htm

reffer this then you got the algo.

 0 votes -- Anirudh Pratap Singh ( 4091 points)

6.11 Deadlock: what is the logic in calculating the minimum no of resources


to remove deadlock ?If top gateoverflow.in/19379

If I have 10 processes and each process wants 3 resources so now usually we first calculate the maximum no of resources so
that there is deadlock by assigning one resource less than the maximum need of the resource and then add 1 to it , to find
the minimum no of resources to remove deadlock ,I agree to that logic too so by using that I get the answer as 21 ,Now
what if I assign 1 resource initially to 9 processes and then assign 3 resource to 10th process or assign 2 resource to any
one of the process and 1 resource to the remaining this would account to 11 which will lead to deadlock and then add 1 to it
=12 ,this would remove deadlock , what is the mistake in this logic ?

deadlock

Total number of just enough free resources needed in a system such that Deadlock never happens is given by :

where n is the total number of processes in the system.

So, if there are 21 resources in our system then it is just the enough number that deadlock can never happen, no matter
how the distribution of resources among processes takes place.

Mistake in your logic is that you are Not considering that there is a chance of free resources(which in your
case =12) getting uniformly distributed among the requesting processes, which is sufficient to bring the
Deadlock.

 1 votes -- Amar Vashishth ( 17865 points)

6.12 Deadlock: Which of the following is not a necessary condition for a


deadlock among processes? top gateoverflow.in/38478

Which of the following is not a necessary condition for a deadlock among processes?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 543 of 2244

(a) Shared Resources


(b) No Preemption
(c) Acyclic condition among processes
(d) None of the above

deadlock operating-system

(a) Shared Resources

it is necessary condition for deadlock.since if resources are not shared then every process will get its private resources and
always executes.

(b) No Preemption

it a necessary condition.since if there is a preemption of RESOURCES then a deadlock never occurs.

(c) Acyclic condition among processes

dont know what does this mean!

so answer is maybe C or D

 1 votes -- viv696 ( 1431 points)

6.13 Deadlock: Progress guaranteed/Mutual Exclusion/Deadlock or not? top


gateoverflow.in/38391
var occupied
var blocked
Enter Region:
{
If (occupied) {
then blocked= blocked +1
sleep ( );
}
else occupied= 1;
}
Exit Region:
{
occupied= 0
If (blocked) {
then wakeup (process);
blocked= blocked – 1;
}
}

True/False
(1) Mutual Exclusion is guaranteed?
(2) Deadlock free Algorithm?
(3) Progress is guaranteed?

operating-system process-synchronization deadlock


Selected Answer

The mutual exclusion not guaranteed as it can context switch at else statement of entry section and both process can
enter the CS

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 544 of 2244

Mutual exclusion not satisfied so deadlock free.

Progress is satisfied because entry of the process is only decided by the processes willing to enter critical section. because
occupied can be made 0. as soon as process completes

 1 votes -- Sumit1311 ( 641 points)

6.14 Deadlock: what is the difference in disabling No Preemption and Hold


and wait condition of deadlock ? top gateoverflow.in/19576

In order to prevent deadlock we try to disable any one of the necessary conditions of deadlock .Now my point of confusion is
that while we have to disable Hold and wait we say that either a process must make request initially only or if before it can
request for additional resources it must be able to release all the resources that are currently allocated to it .

Now in case of disabling No Preemption also we do similar things like if a process is holding some resource and requests
another resource that cannot be immediately allocated to it ,then all the resources currently being held are preempted , so
then what is the basic difference between the two when in both of these scenarios we are trying to release the resources
from the process if it is trying to ask for some additional resources ?

deadlock

No Pre-emption : Process P1 is requesting for resource R1

1] if R1 is free then aloocated to P1

2] If R1 is not free allocated to some other process P2

a) If P2 is in the execution then the process P1 has to wait

b) If P2 is not in the execution it is in waiting for some other resource R2


then pre-empt the resource R1 and allocate it to P1

Hold and wait: 1] Allocate the resource before the start of the process

2] The process should release the existing resources before making new request
e.g. P1 request for 100 instance of R1 but allocated only 75
then P1 should release all the pre allocated resource before making another new 100 request
and keep on doing requesting and releasing untill it gets all 100 instances .

 0 votes -- Umang Raman ( 10379 points)

6.15 Deadlock: deadlock top gateoverflow.in/29218

what is meant by satisfy deadlock?

free from deadlock

OR

not free from deadlock

deadlock

not free from deadlock

 1 votes -- Anirudh Pratap Singh ( 4091 points)

6.16 Deadlock: Does Deadlock imply no Bounded waiting Or no Progress or

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 545 of 2244

BOTH of These? top gateoverflow.in/38610

Does Deadlock imply no Bounded waiting Or no Progress or BOTH of These?Also provide explanation in support

deadlock process-synchronization

Deadlock is more severe than bounded waiting problem.

Starvation is long waiting. While deadlock is infinite waiting. Deadlock surely implies no bounded waiting.

 0 votes -- Sreyas S ( 1353 points)

6.17 Deadlock: Doubt in Livelock top gateoverflow.in/26416

Consider the following situations for three process P1, P2 and P3. [Assume R1, R2 and R3 are resources]

S1: P1 is holding R1 but it is tied up in a busy wait loop repeatedly trying to access R2, which it never gets because R2 is
held by P2. P2 is also stuck in a busy wait loop repeatedly trying to access R3, which it never gets because R3 is held by P3.
P3 is also in a busy wait loop repeatedly trying to access R1.

S2: P1 is holding R1 and issued a blocking call for R2, which is held by P2. P2 issued a blocking call for R3, which is held by
P3, P3 issued a blocking call for R1. Find which of the following is correct for above situations.

A) S1 is deadlock S2 is starvation

B) S1 is livelock S2 is starvation

C) S1 is starvation S2 is deadlock

D) S1 is livelock S2 is deadlock

Here it is very easy to see that S2 is deadlock. For S1 I am not sure why it should be livelock. It is starvation for sure, but
every livelock is special case of starvation. Answer given is D)

Defination of Livelock :- A livelock is similar to a deadlock, except that the states of the processes involved in the livelock
constantly change with regard to one another, none progressing.

Here can we say S1 is livelock because Processes P1,P2 , P3 are constantly changing between running & Ready states ?
"states of the processes involved in the livelock constantly change with regard to one another, none progressing" is
Processes switching between ready & Running state.

operating-system deadlock process-synchronization


Selected Answer

D is correct. S1 is livelock and S2 is deadlock. In S1, the processes are executing instructions to get out of the lock (busy
checking) which makes it a livelock.

Ref: http://www.dcs.warwick.ac.uk/~sgm/cs237/lec/busy/

 1 votes -- Arjun Suresh ( 124125 points)

6.18 Deadlock: IPC Synchronization : Is deadlock possible here? top gateoverflow.in/35693

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 546 of 2244

operating-system deadlock ace-test-series


Selected Answer

Some times deadlock free.Lets assume process i started executing, and executed until flag1=true and preempted, now
process j is executing flag2=true and as flag1=true it will busy wait , again if its preempted process i will busy wait thus
deadlock will occur. If process i or j executes without preemption, assuming flags values are initially false then mutual
exclusion is there.

 1 votes -- Shashank Chavan ( 2439 points)

6.19 Deadlock: If the available no of resources are unable to meet the future
need of any of the processes then what is the state ? top gateoverflow.in/19708

Just wanted to know that if none of the needs of a process is met so can we directly say that it is unsafe state as well as will
lead to deadlock since none of the needs can be satisfied .Even if one need was satisfied and not other then we will declare it
to be unsafe but since it can't meet further the requirement of any process so then what can we say about it ?

deadlock

first thing is that unsafe sequence does not gurrenty deadlock

the question straties implies that it belongs to "deadlock detection and recovery"

1. in the first case the sequence will go for deadlock recovery

2.the process which satisfies the availability is safe..and the rest will lead to unsafe hence deadlock go for recovey

 0 votes -- asutosh kumar Biswal ( 215 points)

6.20 Deadlock: Deadlock top gateoverflow.in/36282

A computer has six tape drivers, with n processes competing for them. Each process may need two drivers. What is the
maximum value of n for the system to be deadlock free?

a] 6

b] 5

c] 4

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 547 of 2244

d] 3

deadlock operating-system gate1997


Selected Answer

Give each process 1 less than it requires . and then add 1 resource

So , n*1 + 1 <= 6

so , n <=5

 3 votes -- Shounak Kundu ( 3757 points)

Without any deadlock we can have 5 processes bcz we can allocate resources(2,1,1,1,1) for processes so that one process
gets finished followed by other

 1 votes -- shivanisrivarshini ( 2067 points)

6.21 Deadlock: Not a necessary condition of deadlock. top gateoverflow.in/20574

Which of the following is not a necessary condition(s) for a deadlock?

1.Mutual Exclusion
2.Hold and wait
3.No pre-emption
4.Re-entrancy

operating-system deadlock

6.22 Deadlock: Results in deadlock or not? top gateoverflow.in/14117

deadlock process-synchronization

initially FLAG is FALSE when PROCESS P1 tries to enter in CRTITICAL SECTION If condition is TURE after that making
FLAg value false... now PRREMPT the process P1 when it is present in CS . after that try the above code for P2 process
hence now FLAG value is TRUE here for p2 process If condition falis .therfore p2 will not enter the CS hencew mutual
exclusion will be satisfied.. r

therefore starvation occur For EXACTLY ONE PROCESS EITHER U FIRST START FROM process P1 or FROM P2.. HENCE NO
DEADLOCK!

 1 votes -- kunal chalotra ( 3567 points)

6.23 Deadlock: Please solve this top gateoverflow.in/11390

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 548 of 2244

operating-system deadlock resource-allocation


Selected Answer

current maximun remainig need=current-


process
allocated allocation max allocation
p 1 1 3 2
p 2 1 2 1
p 3 3 9 6
p 4 2 7 5

reamaining need= current -demand(Max allocation)

now suppose if we have only 2 available resource than we can satisfy the need of process p 1 or p 2 if we first satisfy the
need of process p 1 than according to resource allocation policy all the allocated resource will be given back hence now we
have 3 available resource , now we can we can satisfy the need of process p 2 and after that we have now 4 available
resource ,

if we look in need column than process p 3 and p 5 can't be satisfed its, therefore whole system is not safe hence,
deadlock occur option ( b) cannot be the answer.

now again repeat the above whole procedure with three(3) available resource,

therefore option (C) will be the answer..

 1 votes -- kunal chalotra ( 3567 points)

6.24 Deadlock: 'm' processes share 'n' resources of same type. The
maximum need of each process does not exceed 'n' and the sum all their
maximum needs is always less than m+n. In this setup deadlock can occur
or not? top gateoverflow.in/12228

This is a question from Operating System concepts by Silberschatz, Gagne and Galvin. On very first go I could make that in
such a situation deadlock can never occur. But doing guess work is a really bad habit and risky to.

So I did some paper work using Banker's Algorithm and somehow concluded that deadlock can never occur.But I need some
systematic approach on such question and proper explanation of the answer.

I'm curious to know how you guys would have solved this question.

Thanks in advance.

deadlock

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 549 of 2244


Selected Answer

Consider the worst case- all processes acquire maximum resources but still not able to finish. So, the resources available
must be 1 less than than the maximum need, for each of the processes (this ensures none of them can finish).

We are given maximum need is always less than m + n. As per our condition for deadlock, resources available must be 1
less than maximum need for each of 'm' processes => totally the resources available must be less than m + n - m = n.

But 'n' is the available number of resources and hence no deadlock can occur.

 0 votes -- Arjun Suresh ( 124125 points)

6.25 Deadlock: Please solve this top gateoverflow.in/11389

deadlock

in following sequence process will be in deadlock ..

p : 1| Q: 1| R:1|S:1(Block)|P:2(Block)| Q:2(block)|R: 2(block) here 1,2 are line no of process which is executed and

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 550 of 2244

vertical line is for preemption

P,Q,R execute line no 1 . but s is block becoz it request for the A which is hold by P , then if P execute lin2 req for B which
hold by R,so it will be blocked , Q executed line no 2 it block bcoz it request for the A . which not released .similar R req
for C which is hold byQ. so there is hold and wait or cycle . so there is deadlock .

there is not always deadlock . in these seq there no deadlock P:1 2 3| Q: 1 2 3| P: 4 | R 1 2| S 1 | R 3 4| S 2 3 4 .. you
can do also for other sequence .

 1 votes -- sonam vyas ( 6441 points)

6.26 Deadlock: which of the following is not a necessary condition for


deadlock? top gateoverflow.in/17042

which of the following is not a necessary condition for deadlock?

a)Mutual exclusion

b)Reentrancy

c)Hold and Wait

d)No pre-emption

deadlock

what is mean by sufficient but not necessary condition for deadlock and what are their names?

 0 votes -- Sourabh Kumar ( 287 points)

6.27 Deadlock: Deadlock top gateoverflow.in/4864

A computer system has 6 tape drives with n processes competing for them. Each process may need 3 tape drives. The
maximum value of n for which the system is guaranteed to be deadlock free is

a) 1 b) 2 c) 3 d)4

Ans given is 2....But for 4 processes also there will be no deadlock ....If we initially allocate 1 to each process 2 will be
available...and we can allocate those 2 to the first process...after its execution 3 tape drives will be free..and 2 could be
allocated to next process...so continuing in this way we can allocate resources to each process without any deadlock......

Plz explain why answer given is b)

operating-system deadlock

We have to guarantee that the system will be deadlock free in every condition. So first of all we can't invent easy ways to
allocate resources to the process, we have to see that even in worst condition, there is no deadlock (as per given
question). So in case of 2 processes there may never be possibility of deadlock. In case of 4 processes, not with your
scheme of allocation but with some other allocation- for ex, give 2 resource to P, 1 to Q, 2 to R and 1 to S-- results in
deadlock-- so it is not guaranteeing no-deadlock in 4 processes,, while in case of 2 processes , system is guaranteed to be
deadlock free.

 5 votes -- Prateeksha Keshari ( 1619 points)

Each process needs 3 tape drives to run to completion.

P1 P2 P3

2 2 2 This is a deadlock state.as each of the process is waiting for one resource at
the same time, the system has reached max of its available
resources and there are no resources available which can be taken by any process and can run to completion,.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 551 of 2244

Any number of process which is <3 ,is deadlock free scenario.

If there are 0,1,2 processes then there would be no deadlock.As in the maximum scenario of 2 processes running ,both
utilizing 4 resources we still have 2 more resources left which can be taken by either of P1 or p2,and can run to
completion,.

Ans is 2.

 1 votes -- Sourav Roy ( 2353 points)

6.28 Deadlock: what is the difference between livelock and deadlock top gateoverflow.in/3996

what is the difference between livelock and deadlock?how will you explain livelock to layman?asked at an interview @iitb

operating-system deadlock


Selected Answer

Deadlock means two or more processes are waiting for a lock without doing anything (inactive).

Livelock means processes are active but not able to progress due to interdependence. Its like two people trying to cross a
one man bridge, both backing off together and then both trying to move at the same time and doing this indefinitely.

http://www.cs.sfu.ca/CourseCentral/300/oneill/Resources/Segment7.pdf

 1 votes -- Arjun Suresh ( 124125 points)

6.29 Deadlock: DEADLOCK top gateoverflow.in/19274

in which system deadlock exists ?

deadlock


Selected Answer

in 1 syatem there is a circular wait...so that means deadlock is there ..


in 2 system r2 resources are two one allocated to P4 after work it will give back so now R2 has one resource
which is left as availableso now P3 resorce request is satisfied ,similarly u can see in diagram every process
is satisfied without any deadlock ..

so in 1 system deadlock is there and in 2 system no deadlock

 0 votes -- kunal chalotra ( 3567 points)

6.30 Deadlock: How many safe sequences possible for the given processes?
top gateoverflow.in/33348

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 552 of 2244

operating-system deadlock


Selected Answer

If we took A as a starting ,then we can take C or D,for each we can make 6 sequences(let A,C, then (B,D,E) in 3! Way..)so
total 12 seq...

If we took C as start,then we can arrange A,B,D,E in 4! Way

And same for if we start by taking D,then we can also get 4! Seq..

Total = 24+24+12 =60 sequences

 3 votes -- Sayantan Ganguly ( 5061 points)

6.31 Demandpaging: Paging top gateoverflow.in/36054

I think Answer should be (B) but its (C). Please clarify

operating-system demandpaging


Selected Answer

for first fit:

3 will be placed in paritition of size 5, 2 in 10 and 12 in 30

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 553 of 2244

so total fragmentation=(5-3)+(10-2)+(30-12)=28

for best fit:

3 will be placed in paritition of size 5, 2 in 2 and 12 in 30

so total fragmentation=(5-3)+(12-2)+(30-12)=20

so best fit is better

ans is c

 1 votes -- Pooja ( 22773 points)

6.32 Demandpaging: Virtualgate2015 os25 top gateoverflow.in/35595

operating-system virtualgate demandpaging

6.33 Disk: How to Find Data Transfer Rate? top gateoverflow.in/26231

Consider a disk pack with following specifications - 16 surfaces, 128 tracks/surface, 256 sector/track and 512Bytes/sector.
Now, the disk is rotating at 3600RPM, what is the data transfer rate.

Please be as elaborative and simplified in your approach of explaining! Thank you, all the nerds on this site!

disk


Selected Answer

There are 16 surfaces -> The following operation will be carried simultaneously on by 16 read/write heads.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 554 of 2244

We will find the number of tracks one read write head will cover in one second.

3600 rounds in 60 sec => 60 rounds in 1 sec.

=> 60 tracks have 60 x 256 x 512 Bytes.

Also 16 surfaces are simultaneously operated => 16 x 60 x 256 x 512 Bytes => 125829120 Bytes => 120 MBps

 3 votes -- CrimeMasterGoGo ( 2221 points)

6.34 Disk: PAGING top gateoverflow.in/25605

A Program of size 64MB is stored on disk which supports an average seek time of 30ms and rotation time of 20ms.Page size
is 4MB and track size is 32MB. if the pages of program are contiguosly placed on disk then what would be the total time
required to load the program from disk?

operating-system disk

Seek time = 30 ms
Rotation Time = 20 ms
20

Rotation Latency = 2

Transfer rate = 20ms---------------32MB(1 track)


1ms ?

32

= 20 = 1.6MB/ms
For one page 1ms ------------------1.6MB
? 4MB

= 1.6 = 2.5ms
Total Time for one page = 30 + 10 + 2.5 = 42.5ms

64

Total number of page = 4 = 16

Total time for 16 page = 16*42.5 = 680ms

 5 votes -- Umang Raman ( 10379 points)

6.35 Disk: explain top gateoverflow.in/12059

How much space will be required to store the bit map of a 1.3 GB disk with 512 bytes block size ?

(A) 332.8 KB (B) 83.6 KB (C) 266.2 KB (D) 256.6 KB

operating-system disk

We need a bit for each block. Number of blocks = disk size/ block size

= 1.3 GB / 512 B

This will give the size of bit map in bits. To get the byte size divide by 8 and we get 332.8 KB. For disk size, GB is taken as
1024*1024*1024 bytes and for KB it is 1024 bytes.

Ref: https://en.wikipedia.org/wiki/Gigabyte

 0 votes -- Arjun Suresh ( 124125 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 555 of 2244

6.36 Disk: confusion top gateoverflow.in/17130

I was solving few problems on secondary memory .

In my book prescribed under our university i found in many solution they had done

(2000 *69.14)/8 bytes =17.28 KB but HOW?? IT SHOULD BE 16.87 KB as 1 KB = 1024B

not only here another sum had 128 * 100kbps = 13mbps but it should be 12.5 mbps

please help me out i am very confused

operating-system disk

first of all post the question otherwise we can't understand what u are talking about.

 0 votes -- Ravi Singh ( 7303 points)

6.37 Disk: disk management top gateoverflow.in/33540

my approach
seek time 30
rotationn latency=10
tranfer time :
64 kb prog page size is 4kb so in 16 pages this prog wiil be accesed through memory since track size is given 32 kb
so in 32kb is read in one rtotaion in 20msec
so 4kb --------------------------------(20/32)*4
=2.5
for 1 page it take transfer time as 2.5msec as program is spread in pages so total acces 16 pages we need totoal time as :
(30+10+2.5)*16=680 msec
correct me !! if wrogn thanks..given ans by them is 120.

operating-system disk


Selected Answer

one track size = 32 MB

number of tracks required to store the data = 64MB/32 MB = 2 Track.

Seek time : time require to move the R/W Header to desired track

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 556 of 2244

Rotational Latency : placing the R/W from data is beginning

Now Total time taken for the first track = Seek Time + Rotation latency+ Transfer time

= 30 ms + 10 ms+ 20 ms

= 60 ms

After reading the complete one track again, there will a need to place R/W header at the track in which next 32MB data present. So for this,it will again perform seek operation and find the location from
where the next data is present.

Total time taken to transfer the second track = Seek Time + Rotation latency + Transfer time

= 30 ms + 10 ms + 20 ms

= 60 ms

Total time = 60 + 60 = 120 ms

 1 votes -- Sandeep Singh ( 5939 points)

6.38 Disk: Counting number of block accesses top gateoverflow.in/35737

Given explanation:

Please check if given solution is correct or not

operating-system disk


Selected Answer

ur solution is correct ...

 1 votes -- govind ( 255 points)

6.39 Disk: Calculating disk access time top gateoverflow.in/28495

A program of size 64MB is stored on disk which supports an average seek time of 30ms and rotation time of 20ms. Page size
is 4MB and track size is 32MB. If the pages of the program are contiguously placed on disk, then the total time required to
load the program from disk in ms is _____

Given answer: 120

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 557 of 2244

operating-system disk


Selected Answer

where:
(A) Track
(B) Geometrical sector
(C) Track sector
(D) Cluster

64MB

Total number of tracks this program takes = 32MB = 2

Program has to be loaded from the disk, it will happen in the following way:

1. Head will move at the beginning of the 1st track.


To move to that track on the disk it will take 1 Seek Time, and then to reach at the start of that track it will let the disk to rotate and this
1

on an average takes up 2 × Rotation Time. Then it will read the track and simultaneously transfer data which will take up 1 Rotation
Time(in one rotation a head can read a single track)
1

so, till now 1 Seek Time+ 2 × Rotation Time + 1 Rotation Time has passed.

2. After reading 1st track it will move to the second track and to do that same process will be followed which will take exactly the same
time as in first case.

Hence,
1

(
Time taken to load = 2 × 1 Seek Time +
2
× Rotation Time + 1 Rotation Time )
1

(
= 2 × 30ms +
2
× 20ms + 20ms )
= 120ms

 3 votes -- Amar Vashishth ( 17865 points)

seek time 30 ms

rotational latency 20/2 =10 ms

32 MB covers in 20 ms

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 558 of 2244

total transfer time(30+10+20 )=60 ms

No. of tracks in program 64/32 =2

So, for 16 pages transfer time is 60*2= 120MB

 2 votes -- srestha ( 11585 points)

6.40 Disk: Estimate the average time to read a random sector from disk top
gateoverflow.in/34338

Consider a disk with a rotational rate of 10,000 RPM, an average seek time of 8 ms, and on average of 500 sectors per track.
Estimate the average time to read a random sector from disk.

(A) 7.012 ms
(B) 11.012 ms
(C) 14.012 ms
(D) 10.012 ms

operating-system disk


Selected Answer

(seek tme+RL +Transfer time)

Rrotaion time : 10,000 r----------------------------- 60 sec


so 1 rotation-----------------------60/10000 sec=6 msec

RL will be=rotaion time /2

= 60/20000 sec

they want ans in msec so 60/20 msec=3 msec


for transfer time : in i rotation it can read whole track and here track consists of 500 sector means
in 500 sector------------------------------6 msec
in 1 sec----------------------------------------6/500

=0.012 msec
11.012 ans

 4 votes -- kunal chalotra ( 3567 points)

6.41 Disk: how many surfaces are required top gateoverflow.in/29547

pls xplain the last line of the qs,"records cannot span 2 records" and what effect does it bring to the problem

disk

Cannot span means,1 record cannot be split into two sectors.So in the above example a sector can hold 4000B and hence
it can hold only 14 records of 280B [14*280=3920] and 8 bytes will be wasted.So here the 15th record cannot be split.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 559 of 2244

Is the answer 21 surfaces?

 0 votes -- bahirNaik ( 2479 points)

6.42 Disk Scheduling: Scan cscan top gateoverflow.in/31198

plz explain scan cscan ,i have 2 books which gives 2 different implementation

operating-system disk-scheduling

SCAN: In SCAN algorithm the disk arm moves into a particular direction and services the requests coming in its path and
after reaching the end of disk, it reverses its direction and again services the request arriving in its path. So, this
algorithm works like an elevator and hence also known as elevator algorithm. As a result, the requests at the midrange
are serviced more and those arriving behind the disk arm will have to wait.

Advantages:
High throughput
Low variance of response time
Average response time

Disadvantages:
Long waiting time for requests for locations just visited by disk arm

CSCAN: In SCAN algorithm, the disk arm again scans the path that has been scanned, after reversing its direction. So, it
may be possible that too many requests are waiting at the other end or there may be zero or few requests pending at the
scanned area.
These situations are avoided in CSAN algorithm in which the disk arm instead of reversing its direction goes to the other
end of the disk and starts servicing the requests from there. So, the disk arm moves in a circular fashion and this
algorithm is also similar to SCAN algorithm and hence it is known as C-SCAN (Circular SCAN).

Advantages:
Provides more uniform wait time compared to SCAN

Reference : http://geeksquiz.com/disk-scheduling-algorithms/

** I don't know what kind of different implementation you have found. Can you please mention that also?

Any way the above explanation for both the algorithms are good and its same as in Galvin so you can follow this.

 1 votes -- Sandeep Singh ( 5939 points)

6.43 Disk Scheduling: Find the number of head movements in cylinders using
SSTF scheduling. top gateoverflow.in/41420

Consider the following disk request sequence for a disk with 100 tracks.

98, 183, 37, 122, 14, 124, 65, 67

Head pointer starting at 53 (current position of R/W heads).Find the number of head movements in cylinders using SSTF
scheduling.

operating-system disk-scheduling made-easy


Selected Answer

The current Rw head is at 53 .

it follows :53--65--67--37--14--98--122--124--183

so number of head movement is ( 65-53) + ( 67-65) + ( 67-37) +( 37-14) + (98-14) +(122-98)+(124-122)+(183-124)


=12 +2+30+23+84+24+2+59=236 movements

 2 votes -- priti ( 375 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 560 of 2244

6.44 Disk Scheduling: OS top gateoverflow.in/20519

Which of the following disk scheduling policies results in the minimum amount of head movement?

(A) FCFS
(B) Circular scan
(C) Elevator

disk-scheduling

This will depend the order of Track requested.


FCFS : complete the first cum first serve
C-scan: completes whatever it comes in its moving direction then goes back to starting point or end point & again start
from there.
Elevator(Scan):completes whatever it comes in its moving direction the reverse back and completes the left request.
Let us consider head is now at 53 and moving forward and request of track are

1. 65 75 85 89 99 in this all will give same head movement


2. 75 65 85 99 in this elevator and c-scan gives the same and FCFS will give on extra.
3.44 65 51 74 84 99 in this FCFS = 4 head movement
C-scan = 2
Elevator(scan) = 1
so we can say Elevator gives min head movement.

 0 votes -- Umang Raman ( 10379 points)

6.45 Disk Scheduling: Find the number of head movements in cylinders using
SCAN scheduling. top gateoverflow.in/41419

Consider the following disk request sequence for a disk with 100 tracks.

98, 183, 37, 122, 14, 124, 65, 65, 67

Head pointer starting at 53 (current position of R/W heads) and moving in left direction.Find the number of head movements
in cylinders using SCAN scheduling.

disk-scheduling made-easy

236 is the correct answer. Misprint in the book.

 2 votes -- Rohit Kumar ( 51 points)

In SCAN Scheduling,the disk arm starts at one end of the disk,and moves towards the other end,servicing requests until it
gets to the other end of the disk,where the head movement is reversed and servicing continues.

Here in this question,R/W head is at 53 position and moving in left direction so it will serve all the requests till 14.

Take a look.

53-->37

37-->14

Now it will reach the end of the disk 0 so this will also be a track movement.

14-->0

Again again it will start servicing the request in opposite direction.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 561 of 2244

0-->65

65-->67

67-->98

98-->122

122-->124

124-->183.

So,total head movements will be 236.

 1 votes -- Jitendra Verma ( 133 points)

6.46 Disk Scheduling: which disc access scheduling policy is used? top gateoverflow.in/16939

There are 200 tracks on a disc platter and the pending requests have come in the order - 36,69,167,76,42,51,126,12 and
199.Assume the arm is located at the 100th track and moving towards track 200.if sequence of disc access is
126,167,199,12,36,42,51,69 and 76 then which disc access scheduling policy is used?

a)Elevator

b)Shortest seek-time first

c)C-SCAN

d)First Come First Served

disk-scheduling


Selected Answer

It should be C-SCAN il as the disc access has continued towards the nearest end from initial from 100 and

serviced126,167,199 untill it has hit end the top max

and then jumped to the other end and serviced 12,36,42,51,69,76 in similar manner .

 0 votes -- ANI ( 503 points)

6.47 Disk Scheduling: Disk scheduling top gateoverflow.in/2409

Disk requests come to a disk driver for cylinders in the order 10, 22, 20, 2, 40, 6 and 38 at a given time when the given disk
drive is reading from cylinder 20. The seek time is 6ms per cylinder.

1.What is the total seek time, if the disk arm scheduling algorithm FCFS is used?

A)360 ms B)850 ms C)900 ms D)None

2.What is the total seek time, if the closest cylinder next scheduling is used?

A)360 ms B)876 ms C)850 ms D)900 ms

operating-system disk-scheduling


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 562 of 2244

1. FCFS
Total seek time
= 10*6 + 12*6 + 2*6 + 18*6+ 38 * 6 + 34*6 + 32*6
= 146*6
= 876 ms

2. Closest cylinder next:


Here the service order will be
20 22 10 6 2 38 40
So, total seek time
= (0 + 2 + 12 + 4 + 4 + 36 + 2) * 6
= 60 * 6
= 360

 3 votes -- Arjun Suresh ( 124125 points)

6.48 Dram Refreshing: DRAM refresh operation top gateoverflow.in/33541

how we will come to know that wt overhead. means here??

operating-system dram-refreshing

6.49 Effective Memory Access: Confusion in effective memory access gateoverflow.in/41917

top

Let the page fault service time be 10ms in a computer with average memory access time being 20ns. If one
page fault is generated for every 10^6 memory accesses, what is the effective access time for the memory?

We can solve the above question using the following formula

Effective memory access time = hit rate(main memory access time) + page fault rate(main memory access time +
page fault service time).

Suppose the time to service a page fault is on the average 10 milliseconds, while a memory access takes 1
microsecond. Then a 99.99% hit ratio results in average memory access time of (GATE CS 2000)

We have to solve the above question using the following formula

Average memory access time = hit rate(main memory access time) + page fault rate( page fault service time).

These two questions are asked in gate, both uses different formulae, pls explain in detail what is the difference among them,
I found them as similar.

memory-management effective-memory-access

ANS. 30 ns.

use formula: EMAT= p*s+ (1-p)*m

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 563 of 2244

where p= fault rate= 1/10 raised to 6.

s=page fault service time

m= mem access time

 3 votes -- Rohit Kumar ( 47 points)

6.50 Exponential Averaging: Virtualgate2015 os 26 top gateoverflow.in/35591

Calculate the exponential averaging for the SJF with τ 1=10, α=0.5 and previous runs as 8,7,4,16(give the answer correct to
one decimal place)

What is exponential averging??

operating-system exponential-averaging virtualgate sjf

6.51 File System: Can someone help me to find out neumericals on File
Directory Structure . top gateoverflow.in/30450

Please help me understanding the concepts of Disk Block Address


Disk Block SIze and numericals

file-system operating-system


Selected Answer

http://www.cs.utexas.edu/~lorenzo/corsi/cs372/06F/hw/11sol.html

This helped me :)

 0 votes -- Akhil Nadh PC ( 1967 points)

6.52 File System: 12 single level directory structure top gateoverflow.in/32778

a computer system uses a single level directory structure.The directory occupies 2 disk blocks.The disk block size is 2KB.
Directory entry size is 4 bytes. What is the maximum number of files in the file system?

a 512

b 256

c 1k

d 786

operating-system file-system


Selected Answer

Answer should be Option (c)

Since single level directory structure, so the directory will have the file location information stored. Maximum number of
file supported will be

(Directory size) / (One entry size)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 564 of 2244

(2 * 2 * 210 ) / (22) = 1024

 3 votes -- Utk ( 1385 points)

6.53 File System: File System top gateoverflow.in/32259

Given the disk Capacity of 30 MB has block size 512 bytes and block/cluster is 4, the number of entries require in the FAT
table is?

a) 30*2^11
b) 30*2^20
c) 30*2^31
d) 30*2^9

operating-system file-system memory-management


Selected Answer

FAT(file allocation table) contain entry for each cluster.

So 1st total #'s of block is = 30*2 20 /512= 30*2 11


4block/cluster So #'s of cluster is = 30*2 11 /4=30*29

So ans is D

 4 votes -- Jaikishan Apurva ( 787 points)

6.54 File System: Directory Structure top gateoverflow.in/36620

operating-system file-system data-structure


Selected Answer

Given Maximum of 2K files...each file in directory uses 32 bit(4byte).

so 2K Files use 8KB (in directory).

Now directory occupies 4 blocks, so 4 blocks = 8KB

1 block size= 2KB.

Each block is address with 16 bit,means there are total 2^16 blocks,

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 565 of 2244

Hence size= 2KB*2^16= 128 MB

 2 votes -- Pyuri sahu ( 1237 points)

6.55 Fork: Fork top gateoverflow.in/32413

How many times Hi printed and how many child process will created?
include<stdio.h>
int main()
{
printf("hi");
fork();
fork();
}

fork non-gate

"Hi" will be printed only once because fork() calls are after pintf("hi").

Number of Child process = 2 n - 1, where n is the number of fork() calls

So there will be 3 child processes.

 1 votes -- Sandeep Singh ( 5939 points)

6.56 Fork: System call top gateoverflow.in/19933

for (int i = 0; i<4; i++) { fork(); }</pre>


What is no of child nodes at each level ?

operating-system fork

After first fork there will be one child. After second fork, 2 new child processes (as now 2 processes are executing fork)

So at level i (starting from 0) we have 2i child processes newly created.

In the given code we have 4 levels and thus 1 + 2 + 4 + 8 = 15 child processes plus 1 parent process.

In general it will form complete binary tree when fork is executed in a loop without any further condition.
for(i=0; i<n; i++)

No. of child processes created = 2n − 1.

 0 votes -- Pooja ( 22773 points)

6.57 Fork: Fork query what will be the effect of t3= -1 here? top gateoverflow.in/34920

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 566 of 2244

fork operating-system

answer is 4. dont count c1 c2 c3 c4..the childrens are at t1=0,t2 = 0,at t3 =0 for both t2 != 0 and t2 = 0. so
total 4

 0 votes -- Sayantan Ganguly ( 5061 points)

6.58 Fork: how many process created? top gateoverflow.in/3520

Consider the following Pseudo code

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 567 of 2244

main()
{
int t1=0,t2=0,t3=0;
t1=fork();
t2=fork();
if(t1!=0)
{
t3=fork();
printf("0");
}
}

Find the total number of processes that will be created by the above program execution.

operating-system fork


Selected Answer

At the call of fork, a child process is created which executes the same code of the parent from that point. The return value
of fork is 0 for the child and is child pid (not 0) for the parent and this value is used to distinguish between child-parent
while writing code using fork.

Thus 5 child processes are created. Since the question asks for "total number of processes created" we must include
parent also making this 6 processes in total,

 12 votes -- Arjun Suresh ( 124125 points)

6.59 Fork: How many process are created by the program? top gateoverflow.in/19324

int main(){
int i;
for(i=0;i<4;i++)
fork();
return 0;
}

in my calculation i think 14 processes will be created including the the parent process. am i right ? Is there any easier
method to solve this kind of question ?? please provide the right approach to solve these kind of problems

operating-system fork


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 568 of 2244

If the program have n Fork() call then it will have 2 n-1 child processes

Here n=4 therefore child process 2 4-1 = 15


so total process by program = child process + one main process = 15+1 =16

 0 votes -- Umang Raman ( 10379 points)

6.60 Fork: Total no. of processes created? top gateoverflow.in/5943

operating-system fork

child process gets 0 as process id and parent gets child's process id as its process id. so t1 's child process won't execute
3rd fork(). therefore 4 times 0 will be printed and total process = 6.

 1 votes -- shreya ghosh ( 2801 points)

6.61 Fork: Mysterious Fork() call? top gateoverflow.in/7341

fork operating-system

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 569 of 2244

The given answer is wrong. The output may be "HiHi" or "Hi". At the time of fork, printf might not have been executed and
hence the code of printing might be copied to child as well. (printf is a non-blocking call). To avoid this behaviour, either
we have to use fflush or use the return value of printf before calling fork.

 1 votes -- Arjun Suresh ( 124125 points)

6.62 Fork: Fork top gateoverflow.in/29671

What is the output and how many child(what is the code of all other child .what they copied from parent give tree diagram)

t1=0;t2=0;

Fork();

Printf("hi");

t1=Fork();

Printf("hi");

t2=fork();

printf("hi);

fork();

printf("hi);

fork

30 Hi and 15 Child processes will be createds.

 0 votes -- mandar aundhekar ( 23 points)

6.63 Fork: Fork top gateoverflow.in/29701

what if the program like this(t1 is copied to all or printf will copied to all child)

main()

t1=0,t2=0;

t2=fork();

Fork();

Printf("Hi");

Fork();

t1=Fork();

Printf("hi");

Arjun sir , I don't know the buffer concept.please explain with tree method. How many child and how many time Hi printed.

fork


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 570 of 2244

20 "hi" will be printed and 15 child process will be created , here is an image how to visualize it. The best way is to write
value on branches, the parent is which have all the values of fork! =0;

sorry the right hand side will be the parent. i just misplaced it. well the concept is right.

 1 votes -- Ravi Singh ( 7303 points)

For the first "hi" first 2 forks will work...

Hence 4 times "hi"

For the next "hi" all 4 forks will work

So 16 times "hi"

Total 20 times....

 1 votes -- Er Lucky ( 309 points)

6.64 Fork: fork() system call top gateoverflow.in/28004

How many processes will be spawned after executing this program?

#include <stdio.h>
#include <unistd.h>
int main()
{
fork();
fork() && fork() || fork();
fork();

printf("forked\n");
return 0;
}

How to tackle the order of logical operations?

operating-system fork

In The diagram PLZ REPLACE PARENT WITH CHILD, AND CHILD WITH PARENT. the concept is right and i have edited the
theory just the diagram. as no answer is available. kindly cooperate.

what i think is answer will be 16 including the parent process. Go with the tree method other wise you will get lost in this

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 571 of 2244

Ok just keep in mind that the "and" operator is fully calculated only when first will result in one .

as if it is one then only seeing second one matters, if first is zero then definitely it will be zero, similarly for or . if first
result in one no need to calculate further.

so here we go , one more point- fork return non zero to parent i.e process id to the newly created child , and child will
have value zero

so in this image at point a first fork is called. then we got two nodes b and c. suppose c is the parent

now the line 2 . with and condition will be executed, so first fork will be executed by b , which will create two process i.e d
and e,

now we know one will be parent and one will be child. suppose d is the child then it get return value as zero and hence
condition for it will become 0 and something. as mentioned earlier it will stop execution and wait to execute line number 3,
now the point e will execute further. and will produce L and I, now here also one will be parent and one will be child . for
child the LHS for the OR will become 1 and zero which will be zero , and this will go further while for the another one it will
become 1, so it will terminate and wait to execute line number 3. and only one process will call the fork again, and then all
will execute line number 3. total it will be 16 and 1 parent will be there so 15.

 1 votes -- Ravi Singh ( 7303 points)

fork() system call spawn processes as leaves of growing binary tree. If we call fork() twice, it will spawn 2
2 = 4 processes. All these 4

processes forms the leaf children of binary tree. In general if we are level l, and fork() called unconditionally, we will have 2l processes at
level (l+1). It is equivalent to number of maximum child nodes in a binary tree at level l(+1).

As another example, assume that we have invoked fork() call 3 times unconditionally. We can represent the spawned process using a full
binary tree with 3 levels. At level 3, we will have 23 = 8 child nodes, which corresponds to number of processes running.

A note on C/C++ logical operators:

The logical operator && has more precedence than ||, and have left to right associativity. After executing left operand, the final result will be
estimated and execution of right operand depends on outcome of left operand as well as type of operation.

In case of AND (&&), after evaluation of left operand, right operand will be evaluated only if left operand evaluates tonon-zero. In case of
OR (||), after evaluation of left operand, right operand will be evaluated only if left operand evaluates to zero.

Return value of fork():

The man pages of fork() cites the following excerpt on return value,

“On success, the PID of the child process is returned in the parent, and0 is returned in the child. On failure, -1 is returned in the parent,no
child process is created, and errno is set appropriately.”

A PID is like handle of process and represented as unsigned int. We can conclude, the fork() will return a non-zero in parent and zero in
child. Let us analyse the program. For easy notation, label each fork() as shown below,

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 572 of 2244

#include <stdio.h>
int main()
{
fork(); /* A */
( fork() /* B */ &&
fork() /* C */ ) || /* B and C are grouped according to precedence */
fork(); /* D */
fork(); /* E */

printf("forked\n");
return 0;
}

The following diagram provides pictorial representation of fork-ing new processes. All newly created processes are propagated on right side
of tree, and parents are propagated on left side of tree, in consecutive levels.

The first two fork() calls are called unconditionally.


At level 0, we have only main process. The main (m in diagram) will create child C1 and both will continue execution. The children are
numbered in increasing order of their creation.

At level 1, we have m and C1 running, and ready to execute fork() – B. (Note that B, C and D named as operands of && and || operators).
The initial expression B will be executed in every children and parent process running at this level.

At level 2, due to fork() – B executed by m and C1, we have m and C1 as parents and, C2 and C3 as children.

The return value of fork() – B is non-zero in parent, and zero in child. Since the first operator is &&, because of zero return value, the
children C2 and C3 will not execute next expression (fork()- C). Parents processes m and C1 will continue with fork() – C. The children C2
and C3 will directly execute fork() – D, to evaluate value of logical OR operation.

At level 3, we have m, C1, C2, C3 as running processes and C4, C5 as children. The expression is now simplified to ((B && C) || D), and at
this point the value of (B && C) is obvious. In parents it is non-zero and in children it is zero. Hence, the parents aware of outcome of overall
B && C || D, will skip execution of fork() – D. Since, in the children (B && C) evaluated to zero, they will execute fork() – D. We should note
that children C2 and C3 created at level 2, will also run fork() – D as mentioned above.

At level 4, we will have m, C1, C2, C3, C4, C5 as running processes and C6, C7, C8 and C9 as child processes. All these processes
unconditionally execute fork() – E, and spawns one child.

At level 5, we will have 20 processes running. The program (on Ubuntu Maverick, GCC 4.4.5) printed “forked” 20 times. Once by root parent
(main) and rest by children. Overall there will be 19 processes spawned.

A note on order of evaluation:

The evaluation order of expressions in binary operators is unspecified. For details read the postEvaluation order of operands. However, the
logical operators are an exception. They are guaranteed to evaluate from left to right.

Source: http://www.geeksforgeeks.org/fork-and-binary-tree/

 1 votes -- Prasanna Ranganathan ( 2045 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 573 of 2244

6.65 Inode: Unix Inode file system top gateoverflow.in/34337

Consider a file system that uses UNIX like inodes to keep track of the sectors allocated to files. Assume that disk blocks are
1 KB in size, disk block addresses are 32 bits and the inode has space for 8 direct blocks, 1 singly indirect blocks, 1 doubly
indirect block and 1 triply indirect block. What is the largest disk drive that could be fully utilized by this system?

(A) 232 bytes


(B) 234 bytes
(C) 2 10 bytes
(D) 242 byte
Is there asked about total size of file system?
whats difference between them?

operating-system inode unix

Disk Block Address = 32-bit = 4B


Disk Block Size = 1KB
#of Disk Block Pointer that can fit in one block pointer = 1024/4 = 256
Direct pointer maximum file size = 8 * 1KB = 8KB
Due to Single Indirect Pointer maximum file size = 256 * 1KB = 256KB
Due to Double Indirect Pointer maximum file size = 256 * 256 * 1KB
Due to Triple Indirect Pointer maximum file size = 256 * 256 * 256 * 1KB
so, total file size (approx) = 2^34 Bytes.

 0 votes -- Prasanna Ranganathan ( 2045 points)

6.66 Inode: Elaborate Unix INODE top gateoverflow.in/20557

Consider a file system implemented using unix inode. The system consist of n0 direct disk block addresses, n1 single indirect
disk block addresses, n2 doubly indirect DBAs and n3 triple indirect DBAs.

The Disk Block Address = DBA bits

The Disk Block Size = DBSize Kbits

What is the total size of file system? Explain how the formula for it holds good.

What is the largest file size possible? Explain how the formula for it holds good.

What is the Maximum possible size of file system? Explain how the formula for it holds good.

This is a description of Unix INODE, from my side:

In a Unix-style file system, the inode is a data structure used to represent a file-system object; which can be one of various
things including a file or a directory .
this def. from Wikipedia; the part underlined above seems obscure.

this is how an inode looks like :

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 574 of 2244

to calculate Maximum File Size in the above given question I will use only the triple indirect and obtain
.
This is so because using one particular Triple Indirect Pointer I can point to this much data at Maximum; A Triple indirect
pointer can ultimately point to maximum number of Disk Blocks in comparison to direct/single/double.

and the Total Size of the file system (i.e. how much data we can point to + it excludes file system metadata)

saying this holds good to me coz in this formula all pointers, which INODE has been representing are taken into account.

But I investigated this, asked the GATEOverflow community and found that

If I consider this good then it is making me assume that all other metadata of inode is vanished and only a single disk block
is being used completely(something like that) to hold up pointers to other disk blocks. What about single/double/triple
indirect pointing phenomenon?

and for the Maximum possible Size of file system = total size of disk on which the file system is implemented. this
includes data we can point to + all of metadata together.

Please verify what is correct and what isn't.

operating-system inode unix

6.67 Inode: Unix INODE top gateoverflow.in/20440

Q.1) Consider the Unix inode with 12 Direct Disk Block Addresses(DBA), 1 single indirect DBA, 1 Doubly Indirect DBA and 1
triple indirect DBA. The DBA requires 32 bits and the Disk block size is 1KB. Then what is the maximum file size possible?

Vs

Q.2) A file system with 300 GByte disk uses a file descriptor with 8 direct block addresses, 1 indirect block address and 1
doubly indirect block address. The size of each disk block is 128 KBytes and the size of each disk block address is 8 Bytes.
What is the maximum possible file size in this file system?

Vs

What is the Total


Size
of
the
File
System
for both cases?

operating-system unix inode

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 575 of 2244

Q1) DBA requires 32 bits

210
22
So, number of address in one block = = 28

(
Maximum possible file size = 12 + 256 + 2562 + 2563 × 1KB = 16.0627GB )
27
23
Q2) Number of address in one block = = 16

(
Max possible file size = 8 + 16 + 162 × 128KB = 35MB )
 0 votes -- Pooja ( 22773 points)

6.68 Inter Process Communication: In message passing system how many


points of synchronization is possible?? top gateoverflow.in/5231

In message passing system how many points of synchronization is possible??

operating-system process-synchronization inter-process-communication

I think, 2 times synchronization is needed. One for connection establishment and other for connection release(If it is what
you're asking,actually i'm not getting what you mean by "synchronization points")

 0 votes -- GateMaster Prime ( 1263 points)

6.69 Inter Process Communication: Producer consumer code using


semaphore top gateoverflow.in/17367

The code for producer consumer prob​lem using semaphore is

producer's code

do { *
// produce an item in nextproduced
wait(empty) ;
wait(mutex) ;
buffer[in] = nextProduced;
in = (in + 1) % BUFFER-SIZE;
signal(mutex) ;
signal(full) ;
}
while (TRUE) ,-

consumer's code

do {
wait(full);
wait(mutex);
nextConsumed = buffer[out] ;
out = (out + 1) % BUFFEFLSIZE;
signal(mutex) ;
signal(empty) ;
}
while (TRUE) ;

My question is why do we use same mutex for both producer and consumer. Since producer does not affect 'out' and
consumer does not affect 'in', so we could have used mutex1 and mutex2.

operating-system process-synchronization inter-process-communication semaphore

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 576 of 2244

the problem are independent they are interrelated. the mutax is the variable which tells the consumer is whether a item is
present to consume . or how many item are pressent. if it is not the case. if i use mutax 1. and mutax 2. suppose mutax
one for producer. it will go on producing while mutax1 is full. then the consumer will not be able to start as mutax 2 will
be zero ( if initally taken as false.) its value has not been changed. else if u start with max value of mutax 2 cnsumer will
consume all the data of mutax 2 and the sytem will go in live lock. neither producer will produce anything nor the
consumer will be able to consume because it will not be knowing that item is present.
simple exaple. u are playing counter strike . u took another server and another team took another server. even i start
with 5 -5 player initally . suppose u killed their one player now how will second team will come to know that their one
player is dead. it is not possible till a common interface is used.

 0 votes -- Ravi Singh ( 7303 points)

6.70 Internal Fragmentation: OS adv. level q15 top gateoverflow.in/34849

The available main memory for loading processes is 128 MB which is divided into fixed number of partitions each of size 16
MB. If the processes of size 12 MB, and 6 MB are loaded into memory. The percentage of the internal fragmentation is
____________ (upto two decimal places)

operating-system made-easy internal-fragmentation

for internal fragmentation we need to consider only allocated blocks

so 4+10/32=43.75%

say it there was process of 18MB then it would cause external fragmentation..it that case we consider non allocated
blocks

so we get 6/8=3/4=75% external fragmentation

 3 votes -- Pooja ( 22773 points)

6.71 Io Handling: bit rate of video terminal unit top gateoverflow.in/18839

what is bit rate of video terminal unit with 80 character/line , 8 bits/character and horizontal sweep time of 100 micro sec?

operating-system io-handling

80
character/line
,
8
bits/character
so
total
we
have
80*8
bits=640
bits
these
are
swappd
in
horizontal
means
we
have
to
access
in
100
micro
sec,so

100
microsec---------------------640
bits

100*10-6---------------------------640
bits
1
sec---------------------------(640)/(100*10-6)

=6.4mbps
(rate)

 0 votes -- kunal chalotra ( 3567 points)

6.72 Linked Lists: Linked allocation top gateoverflow.in/37156

A program has just read the 12th disk block using linked allocation. If it next want to read the 5th disk block, then the number
of disk blocks must the program already read to reach the 5th disk block ________.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 577 of 2244

linked-lists

6.73 Madeeasy: Probability of CPU time wasted top gateoverflow.in/36302

A process spends 20% of its execution time waiting for completion of I/O operation. If there are 4 such processes in memory
at once, then the probability of CPU time wasted is _. (Assuming all I/O operations are overlapped)

Answer given is : 0.998

My answer is : 0.200

We can assume that each process takes 10ms to complete, so time waiting for I/O is 2ms. For 4 processes, we will have
total wasted time as 8ms. This is divided by total execution time 40ms.

In solution, they gave a formula, if there are 'n' processes competing with waiting time 't', then probability of CPU time
utilization is tn . How is this formula coming?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 578 of 2244

operating-system operating_system made-easy madeeasy probability

6.74 Maths: No of positive integer satisfying the inequality top gateoverflow.in/37563

Q) The number of positive integers satisfying the inequality are ________

n +1 C (n −2 ) +n +1 C (n −1 ) ≤ 90

getting n= 1 to 9

so answer should be 9

but answer given is 8 (2 to 9)

maths

6.75 Memory Allocation: Fragmentation is top gateoverflow.in/1812

Fragmentation is
a. dividing the secondary memory into equal sized fragments
b. dividing the main memory into equal size fragments
c. fragments of memory world used in a page
d. fragments of memory words unused in a page.

Please explain.

operating-system memory-allocation

(d) is the answer.

http://en.wikipedia.org/wiki/Fragmentation_(computing)

 1 votes -- Arjun Suresh ( 124125 points)

6.76 Memory Management: Virtual Memory top gateoverflow.in/19741

If i have a Reference string with S and page fault as N . then what is number of page fault when we take reverse of string
sr ?

1)FIFO

2)LRU

3)MRU

4)OPTIMAL

// i was given this question for 1 algorithm , but the i tried to find for all page replacement algorithm .

memory-management

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 579 of 2244

Arjun sir please kindly check this :)

// i can be wrong . i just tried it . it may happen that all relation ,ay be wrong and depends upon reference string only

Let us denote number of page fault with S = P1

let us denote number of page fault with S r = P2

so according to me

in case of fifo , p1 may or may not be equal to p2

in case of lru , p1= p2

in case of optimal p1=p2

in case of MFu p1 not equal to p2

Am i right sir ?

 0 votes -- priti sharma ( 637 points)

6.76 Memory Management: Does fixed partitioning suffers from external


fragmentation? top gateoverflow.in/36634

operating-system memory-management


Selected Answer

fixed partition suffers from external and internal fragmentation both if memory is not continous and variable partition
suffers from only external fragmentation

 2 votes -- govind ( 255 points)

6.77 Memory Management: FIFO belady anamoly top gateoverflow.in/19636

Is it always true that FIFO will suffer from Belady Anamoly when i increase the frame number allocate from k to k + 1 .or it
depends upon the reference string also ?

memory-management


Selected Answer

it's not always true. it depends on the string. all cases does not follow belendy anamoly.

 0 votes -- Ravi Singh ( 7303 points)

6.78 Memory Management: Memory management top gateoverflow.in/19662

On a system using fixed partition with sizes 2^8, 2^16, 2^24, 2^32 and 2 ^ 64. How many bits must the limit register
have ?

a) 16 bits

b)24 bits

c)32 bits

d) 64 bits

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 580 of 2244

memory-management

yes . limit register tell us that we always access under the limits of the process. whenever a request is made of data or
instruction in a process. the base address is added with limit register. every request must be less than this address. here i
have the largest segment of 2^64 bits so 64 bit will be required. because in worst case i have to check whether the
request is crossing the 2^64 segment.

 0 votes -- Ravi Singh ( 7303 points)

6.79 Memory Management: Memory management top gateoverflow.in/19673

If page fault service time is 50 milli second and memory access time is 100 ns, then what will be EMAT, if the probability of
page fault is p ?

a) 500000 + 100p ns

b) 100 + 500000p ns

c) 10 −7 − 5p × 10 −2 seconds

d) 10 −7 + 49.9p × 10 −3 seconds

operating-system memory-management


Selected Answer

EMAT = P (Page fault service time )+ (1-P)(Memory access time )

= p(50 × 10 −3 × 109 )ns + (1 − p)(100)ns

= p(50000000)ns +100ns−100pns

= p(500000) × 10 −7 sec +10 −7 sec−(10 −7 )p sec

which is nearly equal to ... 10 −7 sec−5p × 10 −2 sec

Hence ans :Option C)

 2 votes -- sonam vyas ( 6441 points)

Page fault service time includes memory access time too. So need to add it in case of page fault.

EMAT = (1 − p)10 −4 + p × 50 milliseconds

this gives d as ans

 2 votes -- Pooja ( 22773 points)

6.80 Memory Management: Memory managment top gateoverflow.in/19694

Consider a system in demand paged enviorment supporting a virtual address of 32bits with a page size of 4KB, physical
adddress is 29 bits . Page fault rate is 2% page fault service time is 20 ms and main memory access time is 2micro second .
Page table contain 1 valid/inavlid bit , 1 dirty bit , 1 ref bit and 3 bit for protection apart from other information .

If Page Table entry size is a multiple of 3 byte What is approx page table size of process in bytes and what is effective
memory acess time ?

a)6MB,42O MICROSEC

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 581 of 2244

B)3MB, 420 microsec

c)12MB , 419micro sec

d)3MB , 42microsec

memory-management

In this context why don't we calculate memory access twice when there is no page fault. Because in case of paging system
to read a page from memory we need two memory read, one for page table access and another for reading actual page-
frame.

 0 votes -- John Carter ( 263 points)

6.81 Memory Management: Virtual Memory top gateoverflow.in/30308

What is the maximum process size that we can have in a 32 bit operating system?How is that limit calculated.

memory-management

A 32 bit computer can address 2^32 memory so . the maximum process size will be 4GB.

The size of the virtual memory is the maximum size of the maximum size your computer can address using pointers. so a 32 bit os will have
a 32 bit address bus. so by 32 bit address bus we can address 2^32 bytes.

while 64 bit computer or os means it uses 64 bit address bus. so it can address 2^64 bytes of memory.

 0 votes -- Ravi Singh ( 7303 points)

6.82 Memory Management: Memory managemennt top gateoverflow.in/19600

A certain computer system has the physical address space as 2 16 bytes . And consists of 2byte page table entries . Assume
that each page table entry contain (beside other information ) 1 bit for valid , 3 bit for protection and 1 bit for dirty . How
many bits are available in page table entry for storing the aging information for the page ?

Assume that the page size is 512 bytes ?

a) 3 b) 4 c) 5 d) 6

memory-management


Selected Answer

Since physical address space = 2^16

page size = frame size = 512 bytes

So number of frames = 2^16/2^9= 2^7

Number of bits used to address frame = log 2(2^7)= 7 bits

since page table entry is 2 bytes = 16 bits

so now page table entry bit = no of bit used for farme number + 1 valid + 3 bit for protection + 1 dirty bit + Required
Aging information

so 16 = 7+1+3+1+x

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 582 of 2244

x=4

is it right ?

They have given answer as 3

 2 votes -- priti sharma ( 637 points)

6.83 Memory Management: External fragmentation in Best fit memory


allocation policy top gateoverflow.in/26223

Assume 140K, 260K, 60K memory is free. What is the total external fragmentation that arises for the following requests
110K, 30K, 210K, 50K using Best-fit policy, assume no compaction

A) 120K

B) 110K

C) 60K

D)30K

My ans:

But the given answer is:

Please explain.

memory-management test-series

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 583 of 2244

Selected Answer

50k request also der which occupy 260kth slot. so total external fragmentation is 30k + 30k = 60k only.

 1 votes -- Digvijay Pandey ( 26245 points)

6.84 Memory Management: Calculating total external fragmentation top gateoverflow.in/28447

Please check whether the given explanation is correct or not.

operating-system memory-management


Selected Answer

http://gateoverflow.in/26223/external-fragmentation-best-fit-memory-allocation-policy

 0 votes -- Shikhar Vashishth ( 3439 points)

6.85 Memory Management: Operating System : Memory Mangement: Test


series Basic level top gateoverflow.in/31759

A Computer system implements 8 kilobyte pages and a 32-bit physical address space. Each page table entry contains a valid bit, and the translation. If the maximum size
of the page table of a process is 20 megabytes, then what will the length of the virtual address supported by the system (in bits)?

a. 26

b. 30

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 584 of 2244


c. 36

d. 20

http://gateoverflow.in/8247/gate2015-2_47 The above question related to this gate question.But when I tried i got 33 bit
but i choose 30 bits

operating-system memory-management


Selected Answer

I will use the answer by Arjun given on the link you gave, with the relevant values modified.

8 KB pages means 13 offset bits.


For 32, bit physical address, 32 - 13 = 19 page frame bits must be there in each PTE (Page Table Entry).
We also have 1 valid bit.
So, total size of a PTE = 19 + 1 = 20 bits.
​Given in question, maximum page table size = 20 MB
Page table size = No. of PTEs * size of an entry
So, no. of PTE = ( 20 * 2020 * 23 ) / ( 20 ) = 8 M
Virtual address supported = No. of PTEs * Page size (As we need a PTE for each page)
= 8 M * 8 KB
= 64 GB = 236 Bytes
So, length of virtual address supported = 36 bits (assuming byte addressing)

 3 votes -- Utk ( 1385 points)

6.86 Memory Management: Finding maximum size of file top gateoverflow.in/36626

Given answer: 128

Please explain how to solve this problem

operating-system memory-management

Total number of addressable block are 2^16 , Total number of blocks needed for directory = 4 , so maximum file size in
blocks is 2^16 = 65536 . Total memory for storing 2k file records of 32 bits each = 2048*32/8 = 8192 bytes. Total
number of blocks need to store directory is 4 , so 4 * BlockSize = 8192 , BlockSize = 2048 bytes. Total size of largest
file in blocks(MB) = 65536*2048/2^20 = 128 MB

 0 votes -- Vikram Bhat ( 587 points)

6.87 Memory Management: Memory management top gateoverflow.in/19589

In a 32 bit machin we divide the VA into 4 segments

10bit ---8 bit ---6 bit --8 bit . We use a 3 level page such that first 10 bit are used for the first level and so on .

then what is size of a page table for a process that has a address 0 ?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 585 of 2244

a 4096 bytes

b 4274 bytes

c 4608 bytes

d 2148 bytes

memory-management

We have 3 levels of page tables. And address 0 is for start address? Where is the question taken from?

 0 votes -- Arjun Suresh ( 124125 points)

6.88 Memory Management: Memory Management top gateoverflow.in/19614

Consider a system using a sengmented paging architecture. The segment is divided into 8k pages each of size 2k words .
The segement table is divided into 256 k pages each of size 512 words. The page table entry size requires 64 bits . the frame
number requires 22 bits then calculate logical address (LA)

a) 51 bits

b) 61 bits

c) 33 bits

d) 64 bits

memory-management operating-system


Selected Answer

Segment Address : Segment No(S)+WordNo(D)

Since Segment is divided into 8K pages of 2K words each.It means Paging is done over D part of address .
Now D Part will be broken into P|D' Format.

Where P is PAge No

D'- Word No

So D=P+D'=log(8K)+log(2k)=13+11=24

Now Segment table is also divided.It means Paging is done on S part Of Logical address.

S=Log(256K)+Log(512)=18+9=27

So Logical Address=S+D=27+24=51 Bits

 0 votes -- sonu ( 1267 points)

6.89 Memory Management: Can somebody explain me internal and external


fragmentation in detail? top gateoverflow.in/26217

I always get confused between internal and external fragmentation.Is there any relation between them?pls
explain in detail

memory-management

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 586 of 2244

Fragementation:

Fragmentation occurs when memory is allocated and returned to the system. As this occurs, free memory is broken up
into small chunks, often too small to be useful.

Internal Fragmentation:

Internal fragmentation occurs when a process is assigned more memory than it has requested and the wasted memory
fragment is internal to a process.

Memory block assigned to process is bigger. Some portion of memory is left unused as it can not be used by another
process.

External
Fragmentation:

External fragmentation occurs when there is sufficient total free memory to satisfy a memory request, yet the memory is
not contiguous, so it cannot be assigned. Some contiguous allocation schemes may assign a process more memory than it
actually requested (i.e. they may assign memory in fixed-block sizes).

Total memory space is enough to satisfy a request or to reside a process in it, but it is not contiguous so it can not be
used.

http://stackoverflow.com/questions/1200694/internal-and-external-fragmentation

 0 votes -- Prasanna Ranganathan ( 2045 points)

6.90 Memory Management: Consider a system having demand paging system


top gateoverflow.in/29153

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 587 of 2244

operating-system memory-management


Selected Answer

Number of elements = 400*400 = 160000

Memory needed for all = 160000*16

160000∗ 16
128
Number of pages needed = = 20000 = 20*10^3

 4 votes -- Umang Raman ( 10379 points)

6.91 Memory Management: No. of bits in physical and logical address space
top gateoverflow.in/14684

Is it possible to have different number of pages and frames or they need to be equal in number?

memory-management


Selected Answer

Always page size=frame size for minimizing the internal fragmentation.

Here 8 pages are there. Number of entries in page table = 8.


CPU generates logical address which will be divided into 2 halves - to identify page and to identify how much deeper I
have to go in that page. So 3 (8=2^3) bits for uniquely identifying page and 10 bit for uniquely(1024=2^10) identifying
every word. Similarly the offset that is page size will be equal to frame size so here again 10 bits for uniquely identifying
each word while here 32 frames are available which can be uniquely identified by 5 bits hence answer is 13 and 15. Here
they are saying logical memory is less than physical memory. Generally main memory is less in size then physical
memory.

 2 votes -- Ravi Singh ( 7303 points)

logical address=13 bit(3 bit for page 10 bit for offset)

physical address=15 bit( 5 bit for frame 10 bit for offset)

 1 votes -- Pooja ( 22773 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 588 of 2244

6.92 Memory Management: Calculating maximum number of files possible top


gateoverflow.in/28450

Given answer: 8
Please explain

operating-system memory-management

Disk block is 8 KB

Size of each entry in block 32 bits = 4 B

So, no of entry = 2 13 / 22 =211 = 2 K

 1 votes -- srestha ( 11585 points)

6.93 Memory Management: What is the sequence of memory


access/operations when TLB, 2-level Page Table, Cache and Memory are in
picture? top gateoverflow.in/38390

My understanding and doubts are

First of all TLB is accessed.

1. If there is TLB hit, do we consider this as

Hit for 1-level PT only and search the TLB again for 2-level PT, or

Hit for 2-level PT too and are ready for searching the cache/memory for the physical address ?

2. If there is a TLB miss, do we assume that the 1-level PT is missing

But 2-level PT can be found in TLB and we search TLB again for 2-level PT, or

And so the 2-level PT will also be missing in TLB. Hence, we search the memory for 2-level PT ?

3. If there is a TLB miss i.e. the PT is not in TLB, thedata word will definitely be not in the cache and we directly search memory for this. Is this correct?

Please give your answer for all the 3 points. If possible, kindly provide a link so that I can refer it for more clarity.

memory-management

6.94 Memory Management: Finding maximum number of files possible in a


file system? top gateoverflow.in/28482

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 589 of 2244

operating-system memory-management


Selected Answer

No of blocks 4

each block size 4*1024

Total block size 4*4* 1024

entry size 32 bits = 4 B

So,no of entries=4*4* 1024/4 =4K

Each entry has 1 file

So, no of files 4K

 2 votes -- srestha ( 11585 points)

6.95 Misses: direct mapped cache - count misses top gateoverflow.in/37561

Q). Consider a cache as follows:

Direct mapped
8 words total cache data size.
2 word cache block size.
A sequence of eight memory reads is performed in the order shown from the following addresses
0, 11, 4, 14, 9, 1, 8, 0
The (number of misses + Number of compulsory misses +Number of conflict misses ) value is ____.

I tried like this - no of cache line = 8/2 =4 = 2^2

in each cache block 2 words = 2^1

tag index word offset


2 1

0- ....000 will go to block 0 -compulsory miss

11 - ...1011 will go to block 1 - compulsory

4- ....0100 block 2 compulsory

14- ... 1110 block 3 compulsory

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 590 of 2244

9- ...1001 block 0 but conflict miss ( with 0)

1-....0001 block 0 b ut conflict miss ( with 9)

8- .... 1000 block 0 but conflict miss ( with 0)

0 - 0000 block 0 but conflict miss ( with 8)

so total miss = 8

compulsory miss = 4

conflict miss = 4

so ans = 16

Where am i wrong ?

cache-memory co&architecture direct-mapping madeeasy misses

6.96 Multitasking: Multi User top gateoverflow.in/20124

http://gateoverflow.in/1488/gate1999_2-10

multitasking

6.97 Multitasking: Tasks arriving periodically top gateoverflow.in/36299

Consider a uni-processor system executing four tasks T1, T2, T3, T4 each of which is composed of 10 sequence of jobs which
arrive periodically at interval of 2, 4, 8, 16 ms resp. The priority of each task is directly proportional to its period and
available tasks are scheduled based on priority, with highest priority task scheduled first. Each instance of T1, T2, T3,
T4 requires execution time of 1, 2, 4, 6 ms resp. Given all tasks initially arrive at t=0, the 2nd instance of T3 completes its
execution at the end of ______ ms.

multitasking process-schedule made-easy

Since all arrive at time 0

Give high priority to T4 (priority directly proportional to period)

||0 T4 6 || 6 T3 10 || 10 T3 14 ||

T4 has not yet arrived so giving chance to 2nd instance of T3 which is next high proirity process.

 0 votes -- Prabhanjan R ( 747 points)

6.98 Mutex: Synchronization of two processes using Binary


Semaphore_2n_EDITION_HARRIS top gateoverflow.in/38454

Suppose we want to synchronize two concurrent processes P and Q using binary semaphores S, T and U:

Process P: Process Q:
P(S) W:
P(T) X:
P(U) Y:
Print ‘a’ Print ‘a’;
Print ‘b’ Print ‘b’;
V(S) A:
V(T) B:
V(U) C:

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 591 of 2244

Q1: What should be written at W to avoid deadlock?


(a) P(T) (b) P(U)
(c) P(S) (d) Not possible to avoid deadlock

Q2: What should be written at X and Y for the above problem?


(a) P(S), P(T) (b) P(T), P(U)
(c) P(S), P(U) (d) None

operating-system process-synchronization semaphore mutex

1. with only W it is "Not possible to avoid deadlock". but yes W = P(S) , X = P(T), Y = P(U) results deadlock free system.
So W = P(S)
2. if W = P(S) then X = P(T), Y = P(U) works fine.

 0 votes -- Digvijay Pandey ( 26245 points)

6.99 Operating_system: How do we implement synchronization algorithms


practically in operating system? top gateoverflow.in/34654

How do we implement synchronization algorithms practically in operating system?

operating-system operating_system

6.99 Operating_system: after trap,what is state of process and after trap,


process become ready? top gateoverflow.in/10431

operating_system

Trap has been set to access the kernel mode. kernel mode is required to handle the system critical signal. This mode
reside in the running mode. and require domain cross rather than context switch.

 0 votes -- Arpit Dhuriya ( 1791 points)

6.99 Operating_system: only size is sufficient for checking valid address


range of process? top gateoverflow.in/10428

operating_system

Let's talk of segmentation . Cpu generates a logical address say of n bits. Out of n bits k bits is the segment number while
rest n-k is offset. After checking the segment from segment table of process the limit register is checked with the offset if
offset<limit then it's a valid request and request is granted else a trap to os is made incase of irrelevant address.

 1 votes -- Bhagirathi Nayak ( 10239 points)

6.100 Operating_system: What will happen if Time quantum is zero in Round


Robin? top gateoverflow.in/34440

What will happen if time quantum is zero in Round Robin? Is it possible?

operating-system operating_system

6.100 Operating_system: if virtual address is not in range of valid address


what happens? top gateoverflow.in/10429

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 592 of 2244

operating_system

An invalid memory access exception will be generated and thrown to OS- segmentation fault in Linux.

 0 votes -- Arjun Suresh ( 124125 points)

6.101 Page: The total time reuired to load the program from Disk top gateoverflow.in/30488

A program of size 64 MB is stored on disk which supports an average seek time of 32ms and rotation time of 20ms . Page
size is 4MB and track size is 32MB . If the page of the program are countiguously placed on DIsk then the toatal time
required to load the program from Disk in msec is ______

file-system disk operating-system page

we need to move through two tracks

avg access time=2*(seek time+rotational latency+transfer time)

=2*(32+20+10)=124ms

 0 votes -- Pooja ( 22773 points)

6.102 Page Fault: What is the average access time to service a page fault top
gateoverflow.in/10975
In a demand paging memory system, page table is held in registers. The time taken to service a page fault is 8
m.sec. if an empty frame is available or if the replaced page is not modified, and it takes 20 m.secs., if the replaced page is
modified. What is the average access time to service a page fault assuming that the page to be replaced is modified 70% of
the time ?

page-fault

0.3 * 8 + 0.7 * 20 = 2.4 + 14 = 16.4 ms.

(but page table in register??)

 1 votes -- Arjun Suresh ( 124125 points)

6.103 Page Fault: Please help me in understanding how to solve the problem
top gateoverflow.in/14570

Consider the two-dimensional array A:


int A[][] = new int[100][100];


where A[0][0] is at location 200 in a paged memory system with pages of size 200. A small process that manipulates the
matrix resides in page 0 (locations 0 to 199). Thus, every instruction fetch will be from page 0. For three page frames, how
many page faults are generated by the following array-initialization loops, using LRU replacement and assuming that page
frame 1 contains the process and the other two are initially empty?

a.
for (int j = 0; j < 100; j++)
for (int i = 0; i < 100; i++)
A[i][j] = 0;

b.
for (int i = 0; i < 100; i++)
for (int j = 0; j < 100; j++)
A[i][j] = 0;

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 593 of 2244

operating-system page-fault


Selected Answer

First of all I am assuming some of the facts because the question does not state them.

I assume array is stored in row major order and i is used for accessing row and j is used for accessing column. As page
size is specified in number I am assuming it is going to hold 200 elements of the array.

Now it is saying memory has 3 frames and as said earlier 1 frame will be always occupied by the process so we have left
with 2 frames.

Lets analyse second loop first as it will be easy:

(b)

Total number of elements will be =100*100=10000.


So 10000 contiguous memory will be allocated to array in the form R1, R2... where R stand for row. As the page size is
200, at the start of loop 0-199 elements will come to main memory in one page after an initial page fault. After that when
we reach 200 the second page fault occurs. Thus for every 200 element 1 page fault is occurring. So 10000/200 = 50
page faults.

(a)

For 1st loop, I am drawing the image diagram.


You may guess that now blue element will be needed for which another page fault will occur and we will be accessing only
2 element per page fault. So number of page faults =10000/2=5000.

This concept can be extended if page size is given in kB and array element size is taken as 4B- just count number of array
elements in one page. I think now you have understood the concept.

 3 votes -- Ravi Singh ( 7303 points)

6.104 Page Fault: what will be the average instruction time? top gateoverflow.in/25475

If a page fault occurs on an average every 1000 instructions and average instruction time is 100ns without page fault and
100ms with page fault. what is average instruction time?

operating-system page-fault


Selected Answer

Page fault rate = 1/1000


T =Page fault rate * Page Fault Service Time + (1-Page Fault rate)*Memory access time

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 594 of 2244

1 1

= 1000 ∗ 100 ∗ 106 + (1 − 1000 ) ∗ 100


= 100099.9 ns

 1 votes -- Umang Raman ( 10379 points)

6.105 Page Fault: Need explanation on page fault handling. top gateoverflow.in/12521

Suppose a process is suspended due a page fault(page is being written back to disk or required page is being read from
disk). Now after the page IO is completed, the process becomes runnable or resumes execution ? Also will the scenario be
different ,if the process itself requested for some IO(read , write , etc) ?

If it just becomes runnable, and if it is of low priority, isn't it possible that by the time it resumes execution the page for
which it had faulted has again swapped back to disk ?

page-fault


Selected Answer

It just becomes "runnable".

Problem with low priority- I don't know how this is actually done, but after swapping in, the priority of the process can be
temporarily made quite high.

"isn't it possible that by the time it resumes execution the page for which it had faulted has again swapped back
to disk"
This is the reason for thrashing rt?

 2 votes -- Arjun Suresh ( 124125 points)

6.106 Page Fault: Average memory acces time top gateoverflow.in/14700

page-fault

given options are wrong correct ans is 0.0194

3=p[(p(300)+(1-p)100)+1]+(1-p)(1);

200p2+100p-2=0;

p=0.0194

 1 votes -- sunil kumar ( 73 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 595 of 2244

6.107 Page Replacement: Test Series Question on Second Chance page


Replacement top gateoverflow.in/31242

Demand paging uses a second chance page replacement policy (clock). It uses one use bit to give every page one more chance in FIFO replacement. Whenever a page is
referenced its use bit set to 0. Whenever it is need to replace by other page for the first time then its use bit is changed to 1 and next page will be searched for
replacement. If already given the chance then it will be replaced.
Assume that the system has 3 page frames. Consider the following page reference stream in the given order.
7, 0, 1, 2, 0, 3, 0, 4, 2, 3
The number of page faults occur using clock algorithm are ___________.

page-replacement operating-system

Considering, when new page read into a memory frame has the second chance bit set to ZERO (0) and Each time a
memory frame is referenced, set the "second chance" bit to ONE (1) - this will give the frame a second chance.

Here, PF = Page Fault, SC = Second Chance

So, Total Page Fault is 8.

 0 votes -- prathams ( 1141 points)

6.108 Page Replacement: Difference between page replacement policies top


gateoverflow.in/28329
What is the difference between first-in-first-out and last-in-first-out page replacement policies. Please provide
some illustrative examples as well.

operating-system page-replacement


Selected Answer

FIFO : जो पहले आएगा वो पहले बाहर नकलेगा, example operations in a Queue.

LIFO : जो सबसे आ खर म आएगा वो पहले बाहर नकलेगा, example operations on a Stack

 4 votes -- Amar Vashishth ( 17865 points)

6.109 Page Replacement: Page replacement top gateoverflow.in/291

A memory page containing a heavily used variable that was initialized very early and is in constant use is removed when
(a) LRU page replacement algorithm is used
(b) FIFO page replacement algorithm is used
(c) LFU page replacement algorithm is used
(d) None of the above

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 596 of 2244

page-replacement easy operating-system


Selected Answer

LRU can't be used as the page is still is in use , so it will be in most high priority.

LFU can't be used as it has been accessed several time , it's frequency value will be larger.

FIFO can do it as it only considers the time the page came in RAM. So the page can be deleted by FIFO . also from that statement
we can assume FIFO wasn't in use till now.

 5 votes -- Palash Nandi ( 1373 points)

(b) FIFO page replacement algorithm is used


Here, the first IN page is removed when pagetable is full regardless of the usage of the page.

 2 votes -- Arjun Suresh ( 124125 points)

6.110 Page Replacement: Suppose R=3,2,4,3,4,2,2,3,4,5,6,7,7,6,5,4,5,6,7,2,1


is a page reference stream.if the window size is 6 and assuming pure
demand paging.how may page faults will it cause under the working set
algorithm top gateoverflow.in/2908

suppose R=3,2,4,3,4,2,2,3,4,5,6,7,7,6,5,4,5,6,7,2,1 is a page reference stream.if the window size is 6 and assuming pure
demand paging.how may page faults will it cause under the working set algorithm

operating-system page-replacement

Working set here at any point contains the previous 6 page references (non-distinct).

3 - Working Set = [3], Page fault count = 1

2 - Working Set = [3 2], Page fault count = 2

4 - Working Set = [3 2 4], Page fault count = 3

3 - Working Set = [2 4 3], Page fault count = 3

4 - Working Set = [2 3 4], Page fault count = 3

2 - Working Set = [3 4 2], Page fault count = 3

2 - Working Set = [3 4 2], Page fault count = 3

3 - Working Set = [4 2 3], Page fault count = 3

4 - Working Set = [2 3 4], Page fault count = 3

5 - Working Set = [2 3 4 5], Page fault count = 4

6 - Working Set = [2 3 4 5 6], Page fault count = 5

7 - Working Set = [2 3 4 5 6 7], Page fault count = 6

7 - Working Set = [3 4 5 6 7], Page fault count = 6

6 - Working Set = [4 5 7 6], Page fault count = 6

5 - Working Set = [7 6 5], Page fault count = 6

4 - Working Set = [7 6 5 4], Page fault count = 7

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 597 of 2244

5 - Working Set = [7 6 4 5], Page fault count = 7

6 - Working Set = [7 4 5 6], Page fault count = 7

7 - Working Set = [4 5 6 7], Page fault count = 7

2 - Working Set = [4 5 6 7 2], Page fault count = 8

1 - Working Set = [4 5 6 7 2 1], Page fault count = 9

 3 votes -- Arjun Suresh ( 124125 points)

6.111 Page Table: Calculating size of page table top gateoverflow.in/36631

Given answer: A. Please explain

operating-system page-table memory-management


Selected Answer

Size of PAGE TABLE = (No of Pages in LOGICAL ADDRESS SPACE) * (SIZE OF PAGE TABLE entry)

No of Pages in LOGICAL ADDRESS SPACE = 2 24-k


SIZE OF PAGE TABLE entry (PTES) >= No of FRAMES in main memory
PTES >= 216-k

Size of PAGE TABLE = (224-k) *(16-k) bit = (2 24-k) *(16-k)/8 byte = (2 25-k - k*221-k)B

 5 votes -- Digvijay Pandey ( 26245 points)

6.112 Page Table: Inverted Page Table top gateoverflow.in/31967

Consider a machine with 64 MB physical memory and 34 bit virtual address space.If the page size is 4 KB ,the approximate
size of conventional and inverted page table will be??

operating-system page-table

for conventional table


no of page table enteries =232 / 4KB
=220
frame bits =14 bits taking approximate as 16 bits means 2 bytes so 220 *2= 2MB

for inverted page table


we have enteries as no of frame so no frame = PAS/ page size
=226 /4KB
=214 *(PTE)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 598 of 2244

but for calculating inverted page table size there should be size page table entry size(PTE) as in conventinal page table we know that each entry
contains the corresponding frame no !!

 0 votes -- kunal chalotra ( 3567 points)

6.113 Page Table: size of the page table top gateoverflow.in/30320

If the no of pages in a 32 bit machine is 8kB then what is the size of the page table?

a. 8kb

b. 16kB

c. 4 KB

d. Cant say

Ans: a

How is the answer a

operating-system page-table

6.114 Page Table: What is approximate size of page table top gateoverflow.in/33765

operating-system page-table memory-management


Selected Answer

no of pages in logical address space=2^24/2^k=2^(24-k)

no of entries in page table= no of pages

no of frames =2^16/2^k=2^(16-k)

so 16 -k bits required to address frame

size of page table=2^24-k(16-k)/8

=2^(21-k)(16-k)

=2^(25-k)-k 2^(21-k)

answer is option a

 2 votes -- Pooja ( 22773 points)

6.115 Page Table: page table top gateoverflow.in/34385

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 599 of 2244

operating-system page-table memory-management


Selected Answer

Since the virtual address is of 32 bits and page size is 1KB. Therefore, the total number of pages required would be 1M.
Means, these many page entries required in page table, so our page tables itself become an overhead.

So, option C is correct.

 1 votes -- Monanshi Jain ( 5827 points)

6.116 Page Table: Size of the page Table? top gateoverflow.in/33632

Problem 3
In a 32-bit machine we subdivide the virtual address into 4 pieces as follows:

8-bit 4-bit 8-bit 12-bit

We use a 3-level page table, such that the first 8 bits are for the first level and so on. Physical addresses are 44 bits and there are 4 protection bits per page.
Answer the following questions, showing all the steps you take to reach the answer. A simple number will not receive any credit.

How much memory is consumed by the page table and wasted by internal fragmentation for a process that has a code segment of 48K starting at address
0x1000000, a data segment of 600K starting at address 0x80000000 and a stack segment of 64K starting at address 0xf0000000 and growing upward (towards
higher addresses)?

operating-system page-table

6.117 Paging: What is effective memory access time top gateoverflow.in/33767

operating-system paging

avg memory access time=0.35*10+0.65*100=68.5

 0 votes -- Pooja ( 22773 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 600 of 2244

6.118 Paging: Number of memory access top gateoverflow.in/36629

Given answer is A.
I believe that B should be the answer because as the number of page tables are k. k memory access are required for each
table and finally, one for accessing the data from main memory. Please check.

operating-system paging


Selected Answer

if there is no page table then number of memory reference(s) to get date is ONE.
if K- PAGE TABLE are der (i.e. K-LEVEL PAGING) then number of memory references are (K+1)*m.

OVERHEAD = (K+1)*m - m = K*m

 3 votes -- Digvijay Pandey ( 26245 points)

6.119 Paging: Operating System top gateoverflow.in/33413

The question I answered was 4096 bytes and what the test answered is in KB and both the answers are correct . But in GATE
how do we come to know whether the answer should be given in bytes or Kb or MB or GB?

paging

They will tell you in the question itself.

 0 votes -- Morphine ( 273 points)

6.120 Paging: OS:paging Testbook Live Test Q 55 top gateoverflow.in/36588

In a two level paging environment a page table is divided in to 2^12 pages each of size 4KW. The memory is word
addressable. The physical address space is 128MW. Memory is divided into 2^14 frames.Length of the logical address is
_________

My approach:

Given #pages = 2^12

pagesize = 4KW.

PAS = 128MW

#frames = 2^14

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 601 of 2244

using the #pages and pagesize we can get VAS? how to approach.

operating-system paging

6.121 Paging: How to calculate Physical Address corresponding to Logical


Address top gateoverflow.in/37180

Represent the sentence "We are IT students" in physical memory if page size is 5 characters and the entries in page table
are-

0 6
1 5
2 7
3 10

Assume physical memory size to be 55 characters

memory-management paging

we need 18 characters and so 4 consecutive pages. Assuming we start from 0, in physical memory the locations will be 6,
5, 7 and 10. S, physical memory contents will be like (we have 11 frames for 55 characters):






e IT
We ar
stude


nts

Other frames can have any value. Actual memory content will be bits but here characters are used for representation
purpose. Say for ASCII code, we convert 'A' to 01000001 and so on.

 2 votes -- Arjun Suresh ( 124125 points)

6.122 Paging: Bits required to store logical address top gateoverflow.in/37232

suppose a paging system has 2^g+h virtual addresses & uses 2^h+k locations in primary memory for integers g,h & k.
what is the page size of the system that is implied by the virtual & physical address sizes? how many bits are required to
store a virtual address

paging

6.123 Process: What is executed by the processor? What is in ready queue?


Process or thread? top gateoverflow.in/11274

Thread is a light-weight sub-process. If so, what is executed by the processor? Process or thread? If it is thread, why do we
say that ready queue has processes? Should not we say that ready queue has threads? And if the answer is process, what is
the use of threads then? Is thread just another name of a process which is very small in size? What is actually the difference
between these two?

Thank you.

process threads operating-system

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 602 of 2244

Threads are small processes which is part of a Big Program . You can compare like divide and conquer . Splitting the big
program into small small processes .

ready queue holds the processes . threads are actually a process which is part of big process . ready queue totally
unaware of that its a thread or a process so it will treat like a normal process . And its the duty of that program (big
program ) to manipulate each of its threads and how to execute them .

 0 votes -- Pranay Datta ( 6113 points)

6.124 Process Schedule: Which of the following is correct? top gateoverflow.in/17166

Consider all the processes are arriving at large time intervals.

Let t be the time interval between two processes pi and pi +1 for any i and service time of pi is si.

If t > si for every i, then find the best strategy to schedule the processes.

(a) FCFS
(b) SJN
(c) RR
(d) SRTF

process-schedule

t>si for every i ,so before the next process enters the system first process surely completes its execution ,

and for this reason all srtf sjf and fcfs will act as same as fcfs (in case of RR it`ll be more because of context switch for
every time quantum, but order will be same if cs time is very less ) .

 0 votes -- Pranay Datta ( 6113 points)

6.125 Process Schedule: Process scheduling top gateoverflow.in/41385

Consider the following preemptive priority-scheduling algorithm based on dynamically changing priorities. Larger priority
numbers imply higher priority. When a process is waiting for the CPU (in the ready queue but not running), its priority
changes at a rate X when it is running, its priority changes at a rate Y. All processes are given a priority of 0 when they
enter the ready queue. The parameters and can be set to give many different scheduling algorithms. What is the algorithm
that results from Y>X>0?

a. LIFO

b. FCFS

c. Round Robin

d. None of the above

process-schedule operating-system


Selected Answer

It should be FCFS. Although I'[m ASSUMING that - when question says priority is changing, it implies the change is
positive - i.e. priority is increasing.

Consider that a process is running and its priority is increasing at rate of Y . Now another process arrives and waits in a
queue at time t0.

At time t1, priority of process which is running would be (t1-t0) * Y while the one which is waiting would be (t1-t0) * X.

Since Y > X, running process will always have a higher priority. SO the process in queue continues to wait .

So the best answer would be FCFS.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 603 of 2244

 4 votes -- nikhil1008 ( 243 points)

6.126 Process Schedule: Process Scheduling State top gateoverflow.in/32629

A process in which of the following state is best suited for swapping into main memory?

(A) Ready Suspended (B) Blocked Suspended

(C) Running (D) Blocked

process-schedule operating-system test-series

I think both suspend ready and suspend wait is correct as both signifies that the process is in the secondary memory and
hence from this state only its best suited to swap it back into the main memory!

 0 votes -- Rohit Mallik ( 131 points)

6.127 Process Schedule: process scheduling top gateoverflow.in/41426

Consider the progarm to be run on a computer using Round robin scheduling . The program size is 100K . hard disk transfer
rate is 1mbps .Average latency is 8ms . assuming no head seek , what could be the acceptable time quantum for cpu
utlization

1) 11oms

2) 180ms

3)210ms

d)none

process-schedule operating-system

I think it should be 110ms .. 100K/1MBPS = 100ms for transferring the program and 8 ms of latency.

The RR quantum should be sufficient to accommodate the two.

so 110ms should suffice.

But frankly I think something is missing in the question. They should have given the rate of program processing, i.e. when
the program is in the main memory, then at what rate it can be processed..

 1 votes -- nikhil1008 ( 243 points)

6.128 Process Schedule: Process Scheduling top gateoverflow.in/41413

Which one is not a valid reason for process termination ?

1) Time limit exceeded

2) memory unavailable

3) Parent termination

4) Child termination

Explain with giving an example of each

process-schedule

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 604 of 2244

Ans: 4) Child Termination

A process can terminate in one of the following basic ways:

by exiting (i.e., the process terminates itself)


by being signalled
by having no running threads (i.e., the thread count goes to 0 )

In some operating systems, if a parent process dies, then all of its child processes die too.

When a process terminates—no matter why—all of its resources are cleaned up:

Any remaining threads are terminated.


All file descriptors are closed.
All channels and side-channel connections are destroyed.
All memory mappings for the process are unmapped. This includes code, data, heap, hardware mappings, and shared
memory.

 1 votes -- vamsi2376 ( 1185 points)

6.129 Process Schedule: Question on process state transition top gateoverflow.in/28463

Answer to the above question is (C). I am unable to understand that how can a process in ready state can get blocked.
Please give an explanation.

process-schedule operating-system

there is a state called suspend ready, when system needs to free up resources, some processes are moved to that state
from ready state

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 605 of 2244

 2 votes -- Amar Vashishth ( 17865 points)

6.130 Process Schedule: Better avg turnaround time top gateoverflow.in/34683

Round robin scheduling or shortest job first scheduling,which one has better average turnaround time?

operating-system process-schedule

6.131 Process Schedule: Which of the following process scheduling algorithm


may lead to starvation? top gateoverflow.in/16448

Which of the following process scheduling algorithm may lead to starvation

(1)SJF

(2)SRTF

(3)Priority(without preemption)

(4)Priority(with preemption)

a)1,2,3 b)1,2,4

c)1,3,4 d)1,2,3,4

e)1,3 f)1,4

process-schedule


Selected Answer

All of the above algorithms can lead to starvation...

 4 votes -- Pooja ( 22773 points)

6.132 Process Schedule: Which scheduling algo has the second highest TAT?
top gateoverflow.in/16648

process-schedule

TAT(RR) =35

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 606 of 2244

TAT(FIFO)=28

TAT(SJF)= 23

i guess it should be FIFO ..DONT KNOW I MAY BE WRONG

 0 votes -- ANI ( 503 points)

6.133 Process Schedule: OS Gateforum Section test top gateoverflow.in/25021

Consider four processes with a burst time of 10, 20, 30, 40 all process arrived at time 0. Each process spends first 10% of its
execution time doing i/0, next 40% time doing CPU operations, next 20% time doing I/0 and the last 30% time doing CPU
operations. The system uses shortest remaining time next algorithm for scheduling. Calculate the completion time of P3?

operating-system test-series process-schedule


Selected Answer

p3 completes at 49

10%
ArrivalBurst 40%CPU 20%IO 30%CPU
IO
P1 0 10 1 4 2 3
P2 0 20 2 8 4 6
P3 0 30 3 12 6 9
P4 0 40 4 16 8 12

Gant chart

0--- no process--- -1--P1---5---P2---7---P1---10---P2----16----P3----20----P2----26-----P3----34----P4----40----P3----49---


-P4---59-----no process----67----P4---79

 9 votes -- Pooja ( 22773 points)

6.134 Process Schedule: ISRO_A 2015/38 top gateoverflow.in/19455

Suppose two jobs, each of which needs 10 minutes of CPU time, start simultaneously. Assume 50% I/O wait time.

How long will it take for both to complete, if they run sequentially?

a) 10
b) 20
c) 30
d) 40

process-schedule

CPU TIME = 10 min, IO Time = 50% i.e. 50% for CPU & 50% for IO. (it is not 50% of CPU time, read question again)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 607 of 2244

IO time = CPU Time = 10ms

t=0 to 10ms,
A completes its CPU Burst.

t= 10 to 20,
B completes CPU & at same time A Complete its IO burst.

t=20 to 30,
B completes its IO.

Total time is 30ms.

 3 votes -- Digvijay Pandey ( 26245 points)

6.135 Process Schedule: OS Advance Level Q-12 top gateoverflow.in/34847

Consider four processes all are arriving at time zero, with total execution time of 20, 10, 10 and 20 unit respectively. Each
process spends the first 20% of execution time doing CPU, the next 60% of doing I/O computation and the last 20% of time
doing CPU computation again. The operating system uses longest time first scheduling algorithm and schedules a new
process either when running process get blocked I/O or when the running process finishes its CPU burst.
Assume that are I/O operations can be overlapped as much as possible. The average TAT of the system given by ______
unit.
[Note: When same burst occurs for multiple process high priority given to lowest process id] (upto one decimal place)

my ans is 16.5 but ans is given 24.5

made-easy operating-system process-schedule


Selected Answer

0---P1--4---P4---8----P2---10---P3---12----no process---16---P1---20---P4---24---P2---26---P3---28

At 16 P1 finishes it IO

At 20 P4 finishes it IO

At 16 P2 finishes it IO

At 18 P3 finishes it IO

Avg turnaround time=20+24+26+28/4=24.5

 3 votes -- Pooja ( 22773 points)

6.136 Process Schedule: When ever a process is going running to blocked


state its get pre-empted right ?? top gateoverflow.in/19340

When ever a process is going running to blocked state its get pre-empted right ??

so this is also a preemptive scheduling ??

process-schedule

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 608 of 2244

Process moved to blocked state does not imply that it is preempted. Preemption is when a process is moved back to the
Ready Queue from the Running State against its will.

 2 votes -- Amar Vashishth ( 17865 points)

Among all the 5 state through which a process goes , BLOCK state is the only state where the process goes by its will .while in other it depends upon the Scheduler .. And The scheduler
we have seen are care about CPU bound process , and not for I/o bound process . So here the i/o process leave the cpu by its will . And in premptive CPu throws the process out and
take another process (Note the diff between between former and latter case ) hence its is non premptive

 1 votes -- priti sharma ( 637 points)

6.137 Process Schedule: Question on CPU scheduling algorithm top gateoverflow.in/28372

Between Round robin and shortest job first CPU scheduling algorithm which one has better average turnaround time?

process-schedule operating-system

SJF(Shortest Job First) or SRTF(Shortest Remaining Time First) has better turn around time

TAT(turn around time) = finishing time - starting time

SJF which is smallest job end first. So, finishing time is less

But in RR all jobs finishes in longest time according to time slices

http://perugini.cps.udayton.edu/teaching/courses/cps346/lecture_notes/scheduling.html

 2 votes -- srestha ( 11585 points)

6.138 Process Schedule: Process scheduling top gateoverflow.in/41411

Determine True/ False for the following statement ?

1. prefetching is a method of overlapping the I/o of a job with that jon own computation

2.With spooling scheme , where the CPU overlaps the input of one job with the computation and output of other jobs

3.Spooling is handled transparently by system

4.Spooling is much more effective way of overlapping I/O and CPu operation

process-schedule operating-system

6.139 Process Schedule: CPU utilization top gateoverflow.in/30223

If the waiting time for a process is p and there are n processes in the memory then the CPU utilization is given by,

a. p/n

b. p^n (p raised to n)

c. 1-p^n

d. n-(p^n)

operating-system process-schedule

waiting time of 1 process is p

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 609 of 2244

" " n " p n

say,if total time is 1

Utilization time will be 1- p n

Answer is (C)

 2 votes -- srestha ( 11585 points)

6.140 Process Schedule: process schdeuling top gateoverflow.in/41486

The IO wait percentage w of a process is the percentage of time the process wait for an IO to completion when executed in a
monoprogramming enviorment . on a system using round robin with n process ,all having same IO . what percentage of time
cpu will be idle in term of (w) ?

process-schedule operating-system

6.141 Process Schedule: Scheduling algorithm top gateoverflow.in/18743

Which of the following Algorithm favour CPU bound Bound process ?

1) RR 2) FCFS 3) Multilevel feedback queue

option are : a) 1 only

b) 2 only

c) 1 and 2 only

d) 1 and 3 only

process-schedule


Selected Answer

Multi level feedback queue favours IO bound process, because those process are idle for long time , their priority
increases.

and also priority of cpu bound process decreases.

RR : irrespective of CPU or IO bound it will provide 1 time quantum to each process.

remaining option

FCFS: as it is non preemptive by nature , it favours cpu bound processes

 1 votes -- pramod ( 2071 points)

6.141 Process Schedule: why pcb's of the process have links in ready queue?
top gateoverflow.in/2973

operating-system process-schedule

Each PCB has a pointer field which stored the address of the next ready process. This is how ready queue is implemented.

http://www.just.edu.jo/~basel/os/os_slides/OS%20Chp4%20Processes.pdf

 0 votes -- Arjun Suresh ( 124125 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 610 of 2244

6.142 Process Schedule: ISRO-2013-50 top gateoverflow.in/44166

Consider the following set of processes, with arrival times and the required CPU-burst times given in milliseconds.

Process Arrival Time Burst Time


P1 0 4
P2 2 2
P3 3 1

What is the sequence in which the processes are completed? Assume round robin scheduling with a time quantum of 2
milliseconds.

A. P1, P2, P3
B. P2, P1, P3
C. P3, P2, P1
D. P2, P3, P1

isro2013 process-schedule

0-2 2-4 4-6 6-7


p1 p2 p1 p3

answer B)- P2, P1, P3

 1 votes -- Dipak Barnwal ( 43 points)

6.143 Process Schedule: Time Quantum Overhead1.1 top gateoverflow.in/37078

Consider 4 processes sharing the CPU in a round robin fashion. Assuming that each process takes 5 seconds. What must be
the maximum quantum size P. Such that the overhead resulting from process switching is minimized but at same time each
process is guaranteed to gets its turn at CPU at-least every 40 seconds ________ (upto 2 decimal place).

process-schedule


Selected Answer

http://gateoverflow.in/1690/gate1998_2-17?show=1690#q1690

 0 votes -- Aspi R Osa ( 1305 points)

N*St + (N-1)*Q = 40

4*5 + 3*Q = 40

3Q = 20

Q = 6.333

 2 votes -- Vikram Bhat ( 587 points)

6.144 Process Schedule: OS Scheduling top gateoverflow.in/32619

We are given a computer system consisting of a CPU and a disk. We are told that, each user request has a compute time of 80 msec and an
average generates 10 disk requests. We are further told that, the service time at the disk is 10 msec. What is the maximum number of user

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 611 of 2244

requests that can be satisfied per second?

process-schedule operating-system

First process completes cpu at 80, cpu assigned to second and first process do io, second process completes cpu at 160,
first process completes io at 180

Similarly 9 th process completes io at 980

Process 10 to 12 cannot complete io but ll finish cpu time at 960

Coz only one disk multiple io request at same time to same disk not available, disk will have an io queue where
processes ll be lined up

Ans must be 9

 1 votes -- Anurag Semwal ( 4775 points)

Ans. 5.555 user reqest per second

Each User request requires 80 m sec of CPU Time and 10 disk request as IO Time.

total time required for a process = CPU Time + IO Time

= 80 ms + 10 disk request * ( 10 ms per disk request )

= 180 ms

Number of process per second = 1 sec / 180 ms = 1/ (180 * 10 -3 ) = 5.555

 1 votes -- Sandeep Singh ( 5939 points)

6.145 Process Schedule: CPU scheduling top gateoverflow.in/18747

Suppose a system contain n processes and system use Round Robin Scheduling , then which data structure is best suited for
ready queue of this process ?

a)Stack b ) Queue C ) Circular Queue d ) tree

process-schedule

Yes, it should be Circular Queue.

Since it is given that there are n processes in the ready queue, we do not have to worry about the overflow in the circular
queue also.

 0 votes -- Anurag Pandey ( 8183 points)

6.146 Process Schedule: CPU Scheduling top gateoverflow.in/31726

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 612 of 2244

process-schedule

The highest waiting is for SJF and second highest is present in both SJF and RR and that is 12 for process B in both.

 0 votes -- mandar aundhekar ( 23 points)

6.147 Process Schedule: Process executes systems call for top gateoverflow.in/36623

Given solution is: D, But I think that it should be C. Please check

operating-system process-schedule


Selected Answer

C. if another Process Address space is shared with Existing process then no need of system call otherwise a TRAP
generated..
yes D obviously be correct answer bcoz that (Space Allocation) is responsibility of OPERATING SYSTEM MEMORY
MANAGEMENT component which always runs in Kernel mode..

#out of given four options D is correct bt it doesn't mean option D is ONLY reason for system call :)

 1 votes -- Digvijay Pandey ( 26245 points)

6.148 Process Schedule: Problem on Round Robin scheduling with scheduling


overhead given top gateoverflow.in/33772

operating-system process-schedule

Any process will get its turn after n-1 have finished running their quantum so and there are 100 processes to be scheduled
( including the concerned process) before the concerned process starts running.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 613 of 2244

T = (n-1)*Tq + n*Ts ,

T = 1 = 99*Tq + 100*0.001/1000

99Tq = 1-0.0001 , Tq = 10.1 ms

 1 votes -- Vikram Bhat ( 587 points)

6.149 Process Schedule: Minimum possible schedule length for the


completion of three process top gateoverflow.in/33770

operating-system process-schedule

6.150 Process Schedule: Round Robin Scheduling top gateoverflow.in/30226

How round robin will work

process-schedule operating-system

6.151 Process Synchronization: Process Synchronization Gate 1994 top gateoverflow.in/15736

KINDLY SOMEONE POINT OUT MY MISTAKE. I FEEL PAREND ,PARBEGIN CONSTRUCTS CAN BE USED FOR S1 AND S2. BUT
ONE SOLUTION BOOK IS SHOWING DIFFERENT PRECEDENCE GRAPH.THERE IT IS EVEN SAID WE CANT USE PARBEG
,PAREND

HERE IS MY PRECEDENCE GRAPH

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 614 of 2244

I AM VERY CONFUSED OVER THIS.PLEASE HELP ME. I FEEL S1 AND S2 CAN BE CONCURRENT AS THEY DEAL WITH
DIFFERENT VARIABLE. THEN WE SHOULD BE ABLE TO USE PARBEG AND PAREND FOR THEM .PLZZ HELP AND RECTIFY ME

process-synchronization

i think this is the right answer . can u plz post a copy of the solution provided,. what they have told u about the answer. ??

 0 votes -- Ravi Singh ( 7303 points)

6.152 Process Synchronization: What is the output? top gateoverflow.in/14123

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 615 of 2244

a) x = 1, y = 2

b) x = 1, y = 3

c) x = 4, y = 6

Multiple options can be selected

process-synchronization


Selected Answer

B and C is possible .

For b : y=2 ;

x=x+3=3

x=1; (final write )

y=y+x = 2+1 =3

for c :

x = 4, y = 6

this is possible run x=1 after that prrempt it now run code of y=2, x=x+3 here x=1

therefore y=4.now resume from where we prreempt ie statement x=x+y executed x=4+2

giving x=4 and y=6

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 616 of 2244

 0 votes -- Pranay Datta ( 6113 points)

6.153 Process Synchronization: Synchronisation top gateoverflow.in/36121

Consider the methods used by processes P1 and P2 for accessing their critical sections whenever needed, as given below. The initial values
of shared boolean variables S1 and S2 are randomly assigned.

Method used by P1 Method used by P2

while (S1==S2); while (S1!=S2);


Critical Section Critical Section
S1=S2; S2 = not(S1)

The above two processes are both deadlock free and starvation free . Is this statement right? Because both s1 and s2 are
taking different sets of values to enter the critical section and hence no way they are getting blocked out all at once from
their critical section.So no deadlock.
Also its starvation free .

operating-system process-synchronization


Selected Answer

Yes, This sequence of statements is both Deadlock free & Starvation free. Though as you can see, Progress is not
guranteed. (If P1 does not want to enter critical section it can block P2 & so on !)

 1 votes -- Akash ( 26315 points)

6.154 Process Synchronization: synchronisation top gateoverflow.in/36130

The above synchronisation procedure satisfies

1. Mutual exclusion is guranteed


2.Progress is not guranteed
3.Bounded wait is not guranteed
4Deadlock may occur

I am getting all of the above. Is it correct?

operating-system process-synchronization

6.155 Process Synchronization: what is difference between busy waitng and

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 617 of 2244

spin lock? top gateoverflow.in/16552

http://gateoverflow.in/?qa=blob&qa_blobid=10456887729102921117

process-synchronization

ohhh i was wrong basically wht i read was just a small example of spin lock . the exact definition is here .
a spinlock is a lock which causes a thread trying to acquire it to simply wait in a loop ("
spin") while repeatedly checking if the lock is
available. Since the thread remains active but is not performing a useful task, the use of such a lock is a kind of busy waiting..

so its kind of busy waiting

 0 votes -- Ravi Singh ( 7303 points)

6.156 Process Synchronization: which of the following strategy is employed


for overcoming the priority inversion problem? top gateoverflow.in/16547

which of the following strategy is employed for overcoming the priority inversion problem?

a)Temporarily raise the priority of lower priority level process

b)Have a fixed priority level scheme

c)implement kernel pre-emption scheme

d)Allow lower priority process to complete its job

process-synchronization

The answer is 'a', as far I know.

Its also called priority inheritance, it is used to solve the priority inversion problem.

Check the example in the below wikipedia page.

https://en.wikipedia.org/wiki/Priority_inheritance

Also see http://www.allinterview.com/showanswers/100821/what-is-priority-inversion-and-what-is-the-solution.html

 0 votes -- Tehreem ( 87 points)

6.157 Process Synchronization: Determine if the given solution for critical


section problem is correct top gateoverflow.in/14016

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 618 of 2244

process-synchronization

This is a correct solution to the critical section problem.

Reason:-

satisfies mutual exclusion :-value of turn can be either i or j at the same time so any one process can be in cs.

satisfies progress-after execution of each process its flag is set to false (see in the exit section) .as this flag goes to f other
waiting process whose flag value is 1(process interested to enter cs) will enter the cs as while loop condition satisfies in
this sitiuation.

bounded waiting-after completing its execuion in cs its flag is set to false which allow other process to enter the cs .the
same process cant be executed again and again indefinetly if other process is ready and waiting.

 0 votes -- Saurav Kumar Gupta ( 1455 points)

6.158 Process Synchronization: Fill the Synchronisation Table top gateoverflow.in/30517

Synchronisation Mutal Bounded


Progress Deadlock Remarks
Mechanism Exclusion Waiting
Lock Variable
Strict Alternation
Peterson's Solution
Dekker's Algorithm
Test and Set Lock
SWAP
Fetch And Add / Test And

Add

process-synchronization operating-system

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 619 of 2244


Selected Answer

Condition for Synchronization mechanism divided into 2 Parts

1)Primary

a) Mutual Exclusion

b) Progress

2)Secondary

a)Bounded waiting time

A) Lock variable does not provide

a) ME(because many process can access the CS)

Thus as it fails primary requirement of synchronization we don't go for others.

B) Strict alteration provides

a) ME(Only two process solution)

b)BW(First have to enter the then second)

c)not progress(Other process has to enter into cs to enable the cs for other process)

d)free from dead lock (Only two process)

C) Peterson's Algorithm provides

a) ME(Two process solution)

b) Progress

c) BW

d) free from deadlock

D) Dekker's algorithm provides

a) ME

b) Progress

c)BW

d) free from Deadlock

E) Test and Set provides

a) ME

b) Progress

c) free from deadlock

 2 votes -- Saraswati Walijkar ( 193 points)

6.159 Process Synchronization: Peterson's Algorithm. top gateoverflow.in/41256

Description of Peterson's Algorithm & also for which problem it is used to solve

(1) deadlock

(2) mutual exclusion

(3) Thrashing

(4) Paging.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 620 of 2244

made-easy process-synchronization

Petersons Algorithm is a Programming Algo that allows two process to share a single -use
resource without conflict,using only shared memory for communication..

There has been many Algorithms before Petersons Like...

Lock Variable (No Mutual Exclusion)


TSL (Mutual Exclusion,Progress but not Bounded waiting)
Strict Alternation or Turn Variable (Mutual Exclusion but not Progress)
Using Interested Array (Mutual Exclusion,Progress but not Bounded waiting)

Peterson Algo Combines Turn Variable and Interested Array Concepts


and Provides All Four : Mutual Exclusion
Progress
Bounded Waiting
Architecture Neutrality

I would Go with Option 2 :)


 1 votes -- saif ahmed ( 931 points)

6.160 Process Synchronization: Can priority inversion be solved using sleep


and wake approach and avoiding busy wait? top gateoverflow.in/11244

Consider any array representation of an n element binary heap where the elements are stored from index 1 to index n of the
array. For the element stored at index i of the array (i ≤ n), the index of the parent is

(A) i − 1

(B)  2 

i
2
(C)  

(i +1 )

(D) 2

operating-system process-synchronization

NO.

Priority Inversion Problem :


Lets Consider one example: Tasks:
High Priority (H)
Medium Priority (M)
Low Priority (L)

and a lock X, may be semaphore_lock(X).(lock is required by only L and H but M does not require this lock)

Scenario:
1. L runs and acquires X
2. Then H tries to access X while L has it, because of semaphore, H sleeps.
3. M
arrives,
pre-empts
L
and
runs.
In
effect,
H
&
M
were
two
processes
waiting
to
run
but
M
ran
because
H
was
waiting
on
lock
and
couldn't
run.
4. M finishes, H can't enter because L has the lock, so L runs.
5. L finishes, relinquishes the lock. Now H gets the lock and executes.

H had the highest priority but ran after the lower priority processes had run. This is Priority Inversion.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 621 of 2244

see the story behind it:

http://research.microsoft.com/en-us/um/people/mbj/Mars_Pathfinder/Mars_Pathfinder.html

 0 votes -- ajit ( 1369 points)

6.161 Process Synchronization: What is the effect of blocking call? Why is it


not resulting in deadlock? top gateoverflow.in/16651

process-synchronization

Here in this question all processes will be blocked and no one can proceed ..so this cause deadlock...in first scenario its
busy wait, process is not blocked it's still executing but not doing any useful work so that creates livelock...

u can refer this

https://en.wikipedia.org/wiki/Deadlock

 0 votes -- Pooja ( 22773 points)

6.162 Process Synchronization: Please give an example top gateoverflow.in/11456

Is deadlock possible in Test Set Lock?

operating-system process-synchronization

Yes there is spin lock which is kind of deadlock .. it occur due to priority inversion problem .

1. TSL lock R( load lock R ,store #1 ,lock )

2. cmp R ,#0

3 critical section

4 exit section (release lock)

suppose there is 2 process p1 and p2 intial R =0 and for now line 1 is exected by process p1 and it enter into critical
section .now p2 comes which is high priority than p1 so p1 is preempted and go in ready queue and p2 execute the line 1
and 2 but lock R is not 0 . so it will be in busy waiting until it get critical section so we cant preempt it and p1 is in queue
so it could not release the lock . and fall in deadlock .

 0 votes -- sonam vyas ( 6441 points)

6.163 Process Synchronization: process sync top gateoverflow.in/12800

const int n = 5;
int count = 0;
void test(){
for i = 1 to n
count += 2;
}
main() {
Par begin
test();
test();

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 622 of 2244

test();
Par end
}

What can be the maximum and minimum value of count after completion of the program?

process-synchronization operating-system

Count += 2 treated as three instruction,

1. Read count

2. count + 2 //increment locally

3. Store // Globally

All 3 test() inside par begin par end means these function executes concurrently.

Program execution for max value.of count : run serially all Test(). Count becomes 30..

Now for minimum value :

Execute each test() for i=1 utill count +2 ..

Each test() increment count value to count +2 LOCALLY & still waiting for all test() to increment der local count by 2.

After incrementing local count let 1st test write count to 2 GLOBALLY.

Then 2nd test write count to 2 (because count +2 done locally so count value is still 2 for this test() ) . It overwrites count
value by 2.

Then 3rd test() executes in same way as 2nd test() .

For n=1 all 3 test() executed and count value is 2..

Do same same for n=2,3,4,5

Final value of count is 10.

 1 votes -- Digvijay Pandey ( 26245 points)

6.164 Process Synchronization: What are the possible values of x and y after
completion of the program top gateoverflow.in/33245

int x=0,y=0;

par begin

begin

x=1;

y=y+x;

end

begin

y=2;

x=x+3;

end

par end

what are the possible values of x and y after completion of the program?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 623 of 2244

a. x=1 ,y=2

b.x=1,y=3

c.x=4,y=6

operating-system process-synchronization

b,c are possible

There are total 6 orders possible for executing these 4 statements concurrently (like in DBMS transactions)

x=1; y=2;

y=y+x; x=x+3;

possible values for x,y :

A) 4,2

B) 4,3

C) 1,3

D) 4,6

So, b,c is the answer.

 1 votes -- Himanshu Agarwal ( 8861 points)

6.165 Process Synchronization: Which Synchronization mechanism suffers


from dissatisfaction of Bounde Waiting ? top gateoverflow.in/30478

1. Peterson's Solution
2. SWAP instruction
3. Strict Alternation
4. Both 2 and 3

process-synchronization operating-system

Peterson satishfies ME, progress using interested array and bounded waiting using turn var.

Strict alteration satisfy ME, bounded waiting using turn var but not progress.

1,3,4cannot be answer, therefore 2 must be ans

Swap instruction Doesnt satisfy bounded waiting, same instruction can get hold of cs without allowing others to use this
shared area/resource because its dependent on which instruction finds cs free at the time and no mechanism is involved
to ensure bounded waiting( such as turn var)

 0 votes -- Anurag Semwal ( 4775 points)

6.166 Process Synchronization: Starvation is possible or not? top gateoverflow.in/14018

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 624 of 2244

process-synchronization

option d

Explanation:

Semaphore X=0;

Process 1 Process 2

Repeat Repeat

1. V(X) 1. P(X)

2. Compute; 2. Compute;

3. P(X) 3. V(X)

Forever Forever

----------------------------------------------------------------------------------------------------------------------------------------------
--------------------------

The process 1 is performing up() operation in step 1, whereas process 2 is performing down() operation.

Semaphore is initialized to 0;

----------------------------------------------------------------------------------------------------------------------------------------------
---------------------------

1. Both the process keeps on rotating because of forever loop.


2. Definitely Process 2 can not enter as Down() operation at step 1;
3. Process 1 will only enter and it will perform up() making X=1;
4. As soon as X becomes 1 which is favourable for Process 2 to enter (remember it is still in continous rotaion will find
X=1), it will enter or resume.
5. Now Process 1 will Down() the semaphore and Process 2 will perform Up();

 0 votes -- Abhishek Singhal ( 209 points)

6.167 Process Synchronization: Deadlock vs. Mutual Xclusion top gateoverflow.in/37059

S1. All synchronisation mechanisms that Do not Prevent Deadlock, guarantee mutual exclusion.

S2. All synchronisation mechanisms that guarantee mutual exclusion and prevent deadlock will prevent starvation.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 625 of 2244

a) s1 is only correct statement

b) s2 is only correct statement

c) both are correct

d) none of these

process-synchronization

d.

1. Because for preventing deadlock one of the 4 conditions should not be satisfied. It should not be necessarily mutual
exclusion.

2. Because for preventing deadlock after mutual exclusion you need to have at least one of the three conditions not to be
satisfied for deadlock. But starvation is possible when that condition is not preemption. Meaning if we allow preemption
then there is the possibility of the starvation. so it doesnot necessarily prevent starvation.

Please correct me if wrong

 2 votes -- Sumit1311 ( 641 points)

6.168 Process Synchronization: binary semaphore top gateoverflow.in/37331

Let I , K, L are three processes and binary semaphores are S =1 , T=0 , Z=0 initially ;
Process I
{
while(1)
{
P(S)
printf("*");
V(T)
}
}
Process K
{
P(T)
V(Z)
}
Process L
{
P(Z)
V(S)
}

what is the minimum and maximum number of times * is printed???

process-synchronization


Selected Answer

Star will be printed 2 times.

Since the process I is waiting on S(initialized with 1), so it will print *. After some time when process K and L are done
running their code, S will gain have a value 1, process I having a while(1), it will again print *. Now there is no process
which can increment semaphor S again, so process I will keep waiting on S.

Thus answer is 2.

 3 votes -- deandamontvd ( 145 points)

6.169 Process Synchronization: Deadlock top gateoverflow.in/19194

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 626 of 2244

When a process is rolled back as a result of deadlock , the difficulty which arises is

a) Starvation

b)System Thoughput

c)Low device utilization

d) Cycle stealing

process-synchronization

1. Starvation might happen for the process but can be avoided.

2. System throughput will be affected as the whole execution of the process till the rollback is going waste.

3. Device is used in rollback - actually more than the ideal case.

4 Cycle stealing is not a related concept.

So, answer is 2- System throughput as starvation might not always be there.

 1 votes -- Arjun Suresh ( 124125 points)

6.170 Process Synchronization: In process synchonization what is true about


disabling interrupts and TSL? top gateoverflow.in/16708

In process synchronization what is true about disabling interrupts and TSL?

1)Disabling interrupt is applicable only for single processor system

2)TSL is applicable only for single processor system

3)Both could be used in multiprocessor system

4)none of the above

process-synchronization

(Test and Set Lock) that works as follows.

It reads the contents of the memory word lock into register RX and then stores a nonzero value at the memory
address lock. The operations of reading the word and storing into it are guaranteed to be indivisible—no other processor
can access the memory word until the instruction is finished. The CPU executing the TSL instruction locks the memory bus
to prohibit other CPUs from accessing memory until it is done.

It is important to note that locking the memory bus is very different from disabling interrupts. Disabling interrupts then
performing a read on a memory word followed by a write does not prevent a second processor on the bus from
accessing the word between the read and the write. In fact, disabling interrupts on processor 1 has no effect at all on
processor 2. The only way to keep processor 2 out of the memory until processor 1 is finished is to lock the bus, which
requires a special hardware facility (basically, a bus line asserting that the bus is locked and not available to processors
other than the one that locked it).

 0 votes -- ajit ( 1369 points)

6.171 Process Synchronization: In which of the following Indefinite blocking


may occur top gateoverflow.in/19658

In which of the following order indefinite blocking may occur if we add and remove process from the list associated with a
semaphore.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 627 of 2244

a)LIFO
b)FIFO

process-synchronization


Selected Answer

Indefinite blocking may occur if we add and remove processes from the list associated with a semaphore in LIFO order.

 1 votes -- Rohan Ghosh ( 1515 points)

6.172 Process Synchronization: Process Synchronisation top gateoverflow.in/19281

P0: P(S), P(Q), Print(“Hello”), V(Q), V(S)

P1: P(Q), P(S), Print(“Hi”), V(Q), V(S)

Where S & Q are two semaphores initialized to 1. In the above situation:

(a) Deadlock may occur

(b) Bounded Waiting is satisfied

(c) Deadlock never occurs

d) Both (a)&(b)

operating-system process-synchronization

Ans will be D

S=1,Q=1, if P0 takes both the value first then P(S) and P(Q) will make S=0,Q=0 and print Hello. Now V(Q),V(S) makes
S=1,Q=1 again

Now similarly P1 can takes the value and execute Hi

So when P0 takes the value of S,Q then P1 have to wait, when P1 takes the value of S and Q P0 have to wait.

So, there is a bounded waiting

Now if P0 takes S value but not Q value so for P0 S=1, Q=0, so P0 cannot proceed

and similarly P1 takes Q value but not S value , so S=0, Q=1, P1 cannot further proceed

So here is a chance of forever waiting ,i.e. Deadlock

There also have chance for starvation , as only P0 printing "Hello Hello Hello......" for a long period of time and P1 waiting

I think it is also satisfying Mutual Exclusion and Progress is not satisfied

 1 votes -- srestha ( 11585 points)

6.173 Process Synchronization: what is the difference in the execution of


below synchronization mechanisms ? top gateoverflow.in/18780

A
Pi :
flag[i]=True
turn=i

while(flag[j] && turn =i) ; // BUSY WAITING


critical section
exit section

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 628 of 2244

B
Pi :
flag[i]=True
turn=j

while(flag[j] && turn =j) ;// BUSY WAITING


critical section
exit section

I have dry run the code and It satisfies all the three properties of Mutual Exclusion , Progress and Bounded waiting but the
issue is that I am not getting the essence of these two codes i.e. in A , the process gives chance to itself while in B the
process gives chance to another process by assigning turn =j so not getting the significance of how is actually in both of the
cases the code runs correctly

process-synchronization

Hi, it should be flag[j]= true in B definition ?

 0 votes -- priti sharma ( 637 points)

6.174 Resource Allocation: why is the below state although being unsafe not
leading to deadlock ? top gateoverflow.in/19629

I got the state to be unsafe since Available is (1,1) which can't satisfy the need of any process so why is not deadlock ?

resource-allocation

it will be a deadlock as the execution of any process cannot complete in any possible way of execution. unsafe state
means the system may go to deadlock if not executed in a determined manner.

 0 votes -- Ravi Singh ( 7303 points)

6.175 Resource Allocation: Deciding system safe condition from resource


allocation graph top gateoverflow.in/28376

Please mention the algorithm(or reference link) as well.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 629 of 2244

operating-system resource-allocation


Selected Answer

Time complexity of banker's Algorithm is O(m*n 2).

http://cis-linux1.temple.edu/~giorgio/old/cis307f95/readings/deadlock.html

 2 votes -- Digvijay Pandey ( 26245 points)

6.176 Resource On: link for page table concept top gateoverflow.in/41936

Till now i have not got any exciting and detailed explanation of page tables and multi level page tables concept. if you have
any resource on this please post the link ..

resource-on page-table

Try

http://gatecse.in/wiki/Best_video_lectures_for_CSE

by P.K. Biswas

Memory management2 ,memory management 3

 0 votes -- srestha ( 11585 points)

6.177 Secondary Storage: How long does it take to load a 64-KB program
from a disk top gateoverflow.in/38416

How long does it take to load a 64-KB program from a disk whose average seek time is 10 msec., whose rotation time is 20
msecs., and whose track holds 32-KB for a 2-KB page size?(How to solve this?)

secondary-storage operating-system disk page

64 KB program will be organized into 2 tracks because of each track capacity is 32KB.

To load entire track we require 20msec. To load 2KB we require 1.25 msec.

I/O time =seek time+avg.rotation latency+transfer time

10msec+10msec+1.25msec=21.25msec

Since 64KB program is organized into 2 tracks then I/O time will be 2(21.25)=42.5 msec

 0 votes -- vali basha ( 11 points)

6.178 Segmentation: Memory Management top gateoverflow.in/32260

Which of the following problems can be overcome by virtual memory segmentation?

a) Segmentation for overlays to deal with lack of physical memory


b)Relocation of code and data address can be made segment local
c)Protection of access e.g. read , write and execute segments.
d) All of these.

operating-system memory-management segmentation

option b and c are the reason i know are resolved by virtual memory concept.No idea of overlays..:p

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 630 of 2244

for b-since in segmentation the memory is segmented so that there comes a complete function of a program in a segment.
That way there would by less chances of page faults because it is expected that the instructions in a function would be
most likely to be executed completely at a time.

for c-Since a function a segmented, no other process is allowed to use the segment block allocated to other. Thus it
provides security.

 0 votes -- Abhishekcs10 ( 1001 points)

6.179 Segmentation: Segmented paging and paged segmentation top gateoverflow.in/33954

explain similarities and dismilarities between Segmented paging and paged segmentation

operating-system segmentation memory-management

So,after vigorously searching on net for the difference or similarity between these two terms,I have come up on a final answer.First of all I would write
down the similarities:

They both (segmented paging and paged segmentation) are a type of paging/segmentation combined systems (Paging and Segmentation can be
combined by dividing each segment into pages).
In both the system the segments are divided into pages.

Now to describe the differences I will have to define and describe each term separately:

Segmented paging- Segments are divided into pages.Implementation requires STR(segment table register) and PMT(page map table).In this
scheme, each virtual address consists of asegment number, page number within that segment and an offset within that page.The segment
number indexes into segment table which yields the base address of the page table for that segment.The page number indexes into the page
table,each of which entry is a page frame.Adding the PFN(page frame number) and the offset results in the physical address.Hence addressing
can be described by the following function :

va = (s,p,w) where, va is the virtual address, |s| determines number of segments (size of ST), |p| determines number of pages per segment (size
of PT), |w| determines page size.

address_map(s, p, w)
{
pa = *(*(STR+s)+p)+w;
return pa;
}

The diagram is here:

Paged Segmentation- Sometimes segment table or page table may too large to keep in physical memory(they can even reach
MBs).Therefore,the segment table is divided into pages too and thus a page table of ST pages is created. The segment number is broken
into page no.(s1) and page offset(s2) of page table of ST pages.So,the virtual address can be described as :

va = (s1,s2,p,w)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 631 of 2244

address_map
(s1, s2, p, w)
{
pa = *(*(*(STR+s1)+s2)+p)+w;
return pa;
}

The diagram description is here:

 1 votes -- Shashank Kumar ( 2029 points)

6.180 Segmentation: segmented scheme of memory management top gateoverflow.in/26677

virtual-memory segmentation

Segment table is often too large to fit into one page. So segment table itself must have a page table in a paged segmented
scheme.
So, option (a) is correct.

 1 votes -- ayushigupta ( 89 points)

6.181 Segmentation: Memory management and Virtual memory top gateoverflow.in/37978

Which page replacement policy sometimes leads to more page faults when size of memory is increased?

A] Optimal

B] LRU

C] FIFO

D] None of these.

memory-management operating-system segmentation virtual-memory

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 632 of 2244


Selected Answer

Example for Beladay's Anomaly

 3 votes -- vamsi2376 ( 1185 points)

Bleady's Anamoly "More frames in FIFO = More page faults"

 1 votes -- Cruise Device ( 445 points)

6.182 Segmentation: what happens if the logical address requested is -


Segment Id 2 and offset 1000? top gateoverflow.in/16942

consider the following segment table in segmentation scheme:

Segment Id Base Limit

0 200 200

1 5000 1210

2 1527 498

3 2500 50

what happens if the logical address requested is -Segment Id 2 and offset 1000?

a)Fetches the entry at the physical address 2527 for segment Id 2

b)A trap is generated

c)Deadlock

d)Fetches the entry at offset 27 in Segment Id 3

segmentation

an os trap signal will be generated. as offset tell how much deeper we have to go in the segment. as we have given 1000

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 633 of 2244

as offset while the segment size is 498 . it will try to read another process memory which should not be allowed in any
case

 0 votes -- Ravi Singh ( 7303 points)

6.183 Segmentation: Segmentation top gateoverflow.in/18985

In segmented paging, is the paging applied on segment table or on segments?

virtual-memory segmentation

paging is applied on segment table, becoz due to increase in size of the segment table.and not on segment

 0 votes -- kunal chalotra ( 3567 points)

6.184 Segmentation: Memory management and Virtual memory top gateoverflow.in/37970

Match the pairs in the following question

Pair - 1

A. Virtual Memory

B. Shared Memory

C. Look-ahead buffer

D. Look-aside buffer

Pair - 2

P. Temporal locality

Q. Spatial locality

R. Address translation

S. Mutual exclusion

memory-management operating-system segmentation virtual-memory

http://cs.stackexchange.com/questions/9612/look-ahead-buffer-vs-translation-look-aside-buffer

A-R,B-S,C-Q,D-P

 0 votes -- asutosh kumar Biswal ( 215 points)

6.185 Semaphore: counting semaphore related question top gateoverflow.in/26256

A binary semaphore ensures mutual exclusion. Does a counting semaphore ensure mutual exclusion too?

Please justify your answers.

semaphore process-synchronization operating-system


Selected Answer

Yup improper use of semaphore not ensure the mutual exclusion . only proper use of semaphore ensure mutual exclusion.
ex: monitor.

 1 votes -- Anirudh Pratap Singh ( 4091 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 634 of 2244

6.186 Semaphore: semaphore application top gateoverflow.in/41916

Semaphores are used to solve the problem of


a)race condition b)process synchronization
c)mutual exclusion d)none

semaphore

http://gateoverflow.in/19489/isro_a-2015-30

**repeat question

 0 votes -- Khushboo Tak ( 1961 points)

6.187 Semaphore: How to implement the given using only 2 semaphores? top
gateoverflow.in/14121

semaphore process-synchronization

multiple ways are possible , one of the way is as follow

say 2 semaphores R=0 , S=0

P1: P2:

wait(R) USE R1

signal(R)

USE R1

USE R2

signal(S) wait(S)

USE R2

USE R3

wait(R) signal(R)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 635 of 2244

USE R3

USE R4

signal(S) wait(S)

USE R4

 0 votes -- pramod ( 2071 points)

6.188 Semaphore: ISRO_A 2015/30 top gateoverflow.in/19489

Semaphores are used to solve the problem of

I. Race Condition
II. Process Synchronization
III. Mutual Exclusion
IV. None of the above

a) I and II
b) II and III
c) All of the above
d) IV.

semaphore

Race condition is achieved by making shared data area should not be accessed by two or more processes at the same
time which can be achieved using Semaphore. so, answer should be C(all of the above)

 0 votes -- Swathi Yesu ( 15 points)

6.189 Semaphore: What is the correct implementation of UP operation in a


binary semaphore top gateoverflow.in/31466

these are the codes for down and up operations in a binary semaphore. The down operation's code seems to be correct, but
I am having some doubt in the UP's code.
Suppose a process p1 arrives and executes down. the initial value of "value" is 1. now p1 will decrement it to 0 , and then
proceed to execute CS. Suppose, during this time another process p2 arrives and executes down. now it will be forced to
sleep as value==0. Lets assume the same for another arriving process p3.
Now if P1 finishes its CS, it will execute UP, and find that L is not empty, so it will select a process from it and wake it up.
BUT, p1 has not changed the value of "value". So even if p2 wakes up and executes down, it will be forced to sleep again..
Am I missing something, or is the above implementation incorrect ?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 636 of 2244

operating-system semaphore process-synchronization

Whenever Binary Semaphores are used to synchronize the Critical Section by a Binary Semaphore Variable lets take it
"S".Generally the code structure will be like below

P(s) // Entry Section

Critical Section

V(s) // Exit Section

we do down operation to achieve mutual exclusion i.e once a process its entered into the critical section and executing it,
meanwhile no other process is allowed to execute the critical section and more on it will be suspended and it's PCB will be
kept into the suspended list of semaphore variable i.e. S.

After execution of critical section the process will perform up operation on S inside exit section and binary semaphore does
not always make S value to 1. It makes the S.value = 1 once the S.list is empty and it will simply wake up a process from
the S.list and allocate the critical section to it when S.list is not empty.

Now your confusion is, "Why UP() operation is not performing S.value = 1 when S.list is not empty ?"

Lets do it first, once we will make S.value =1 when S.list is not empty. There will be chance of process P2 may enter into
starvation.Because once the S.value is 1 any process can come and perform down operation and execute critical section.
This the process P2 may not get chance to execute the critical section.

 1 votes -- Sandeep Singh ( 5939 points)

6.190 Semaphore: Can anyone explain the below question in a detailed way?
top gateoverflow.in/37083

A Binary semaphore variable mutex is initialized to '1' and the various binary semaphore operations like 9P(), 14V(), 6P(),
8V(), 3P(), 2V() are performed, then what is the present(final) value of the binary semaphore mutex?

semaphore

6.191 Semaphore: Please explain this top gateoverflow.in/17461

semaphore

This question was asked in gate 2008 in a different way.Anyway it will clear ur doubt I hope otherwise I will try to explain
further.It is actually the implementation of a counting semaphore by 2 binary semaphores:

The P and V operations on counting semaphores, where s is a counting semaphore, are defined as follows:
P(s) : s = s - 1;
if (s < 0) then wait;
V(s) : s = s + 1;
if (s <= 0) then wakeup a process waiting on s;

Assume that Pb and Vb the wait and signal operations on binary semaphores are provided. Two binary
semaphores Xb and Yb are used to implement the semaphore operations P(s) and V(s) as follows:

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 637 of 2244

P(s) : Pb(Xb);
s = s - 1;
if (s < 0) {
Vb(Xb) ;
Pb(Yb) ;
}
else Vb(Xb);
V(s) : Pb(Xb) ;
s = s + 1;
if (s <= 0) Vb(Yb) ;
Vb(Xb) ;

The initial values of Xb and Yb are respectively


(A) 0 and 0
(B) 0 and 1
(C) 1 and 0
(D) 1 and 1

Answer (C)
Both P(s) and V(s) operations are perform Pb(xb) as first step. If Xb is 0, then all processes executing these operations
will be blocked. Therefore, Xb must be 1.
If Yb is 1, it may become possible that two processes can execute P(s) one after other (implying 2 processes in critical
section). Consider the case when s = 1, y = 1. So Yb must be 0.

 0 votes -- Rohan Ghosh ( 1515 points)

6.192 Semaphore: Question number 5.24 top gateoverflow.in/12475

Question 5.24

semaphore

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 638 of 2244

This is how P and V operations will be made by procedures. Initially all semaphores are zero. Don't confuse that T5 will be
called twice. It will be called only once by any of T1 or T3 , whosoever runs V(b) first. Also this solution forces T6 to
complete before T4 , it will never be the case that T4 has completed and you need to block T6 forever.

 0 votes -- CrimeMasterGoGo ( 2221 points)

6.193 Semaphore: How to implement the given using only 2 semaphores? top
gateoverflow.in/14120

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 639 of 2244

semaphore process-synchronization

Here P=0 S=1;

P1: P2

wait(P) wait(S)

use R1 use R1

use R2 signal(P)

signal(S) wait(S)

wait(P) use R2

use R3 use R3

use R4 signal(P)

signal(S) wait(S)

Use R4

 1 votes -- Pooja ( 22773 points)

6.194 Semaphore: How to approach this question on bounded-buffer ? gateoverflow.in/20246

top

In this empty must be 0 since producer will first produce only then it will empty

process-synchronization semaphore

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 640 of 2244

Answer is C. empty and full can be initialized any way depending on how we are going to use it. Here, empty is initialized
to n-meaning n empty slots are there. So, producer must wait on this. Similarly, consumer must wait on full as it is
initialized to 0.

A similar question:

http://gateoverflow.in/3708/gate2004-it_65

 0 votes -- Arjun Suresh ( 124125 points)

6.195 Semaphore: what is true about binary semaphore? top gateoverflow.in/16707

what is true about binary semaphore?

1)Binary semaphore has drawback called busy wait or spin lock.

2)Binary semaphore is applicable only for two processes

3)Binary semaphore has no drawback called busy wait or spin lock

4)none of the above

semaphore

i think there is no such drawback instead it uses a diffrent mechanism which was made to overcome the problem of busy
wait and spin lock . which is sleep procedure till someone is inside the critical section don't knock at the door just go to
sleep when there will be a space the process will wake u up . the process of busy waiting is a charterstic of lock variable
not of semaphonre

 0 votes -- Ravi Singh ( 7303 points)

6.196 Semaphore: What is the meaning of wake up() operation in the up()
binary operation, Definition is mentioned below. top gateoverflow.in/37088

Up(Semaphore S)
{
if (Suspended list() is empty)
S.value=1;
else
{
Select a process from the suspended list and WakeUp()
}
}

semaphore

PLEASE DON"T Downvote on this as My concept of Semaphoe is not good ....I will take up an example to explain wake up
and sleep calls..suppose there are 2 friends and one of them tells the other to wake him up now the other can do it only
once so he went to wake him up by knocking on his door and he didn't check whtr the other person was in the room or
not ..suppose he was not in the room and after that the person went to sleep and now the other person who went to wake
his friend want to sleep and he will think that his friend will wake him up but his friend also went to sleep at the same time
..now there is a DEADLOCK ..both people will think that the other would wake them up ..so there was a need of
Semaphore that is one of the reason it was invented(I think maybe I am wrong do correct me) ..so when the semaphore
value is 1 that means one process will use the value and enter into critical section ..

 0 votes -- Joker ( 685 points)

6.196 Semaphore: Do semaphores always provide mutual exclusion?? gateoverflow.in/19299

top

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 641 of 2244

semaphore

No it depends upon type of semaphore you are using .

If its binary then mutual exclusion is guarantee (Only1 process at a time in CS )

if its counting then mutual exclusion is not guarntee (multiple process be at a time in CS )

 0 votes -- priti sharma ( 637 points)

6.197 Semaphore: synchronization top gateoverflow.in/14853

the following five concurrent processes operating on counting semaphore variable (s) which is initialized to 0

P1: wait (s); cs; signal (s);

P2: wait (s); cs; signal (s);

P3: wait (s); cs; signal (s);

P4: signal s); cs; wait (s);

P5: signal (s); cs; wait (s);

what is the maximum possible value of s?

A) 1 B) 2 C) 3 D) 0

semaphore process-synchronization operating-system


Selected Answer

P4 and P5 can do signal operation without any intermediate wait and thus s can go up to value 2.

 3 votes -- Arjun Suresh ( 124125 points)

6.198 Set Associative: LRU cache top gateoverflow.in/37565

getting 7/11

made-easy co&architecture lru cache-memory set-associative

6.199 Software Testing: Reliability of the unit testing top gateoverflow.in/17318

The test suite (set of test input) used to perform unit testing on a module could cover 70 % of the code. What is the
reliability of the module if the probability of success is 0.95 during above testing

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 642 of 2244

software-testing

6.200 Testbook Test Series: Length of logical address in 2 level paging gateoverflow.in/36515

top

In a 2-level paging environment a page table is divided into 2^12 pages each of size 4 KW. The memory is word
addressable. The physical address space is 128 MW. Memory is divided into 2^14 frames. Length of logical address is
________ ?

operating-system paging testbook-test-series

The logical adress =p1+p2+d.

Here p1=12bits p2=12bits and d=12 bits. Therefore logical adress size=36 bits

 2 votes -- ROHIT CHANDRA ( 47 points)

6.201 Thrashing: Data structure for controlling thrashing top gateoverflow.in/28467

Given answer: A
Please explain.

data-structure operating-system thrashing

answer = option A

in array only the total number of processes are fixed which are available to be executed in the main memory; But in other
data structures many more elements can be added without any restriction.

 1 votes -- Amar Vashishth ( 17865 points)

6.202 Tlb: which is accessed frist TLB or cache? top gateoverflow.in/31112

I have a doubt which is accessed first TLB or cache?

I think answer should be TLB as we need it for address translation to get frame no. and then access cache

Is my approach right?

operating-system tlb cache paging

Yes you are right but only in case the Cache is Physically Addressed.

Cache memory may be Physically Addressed as well as Virtually Addressed.

If Cache is Physically Addressed then TLB will reside between CPU and Cache because CPU does a TLB lookup on every
memory operation and the resulting physical address is sent to the cache.

But in case Cache is virtually Addressed then CPU generated addresses i.e. Virtual Address will directly looked up in Cache
and In case of cache miss, we need the address translation then only TLB will be accessed.

In multi level Cache organization,TLB may reside even between two cache.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 643 of 2244

Reference - https://en.wikipedia.org/wiki/Translation_lookaside_buffer and https://en.wikipedia.org/wiki/CPU_cache

 3 votes -- Sandeep Singh ( 5939 points)

6.203 Virtual Memory: Page tables are stored in memory , which has access
time of 100 ns. top gateoverflow.in/779

Page tables are stored in memory , which has access time of 100 ns. The TLB holding 8 page table entries, has an access
time of 10 ns. Using execution of process , it is found that 85 % of the time, a required page table entry exist in TLB and
only 2 % of the total references causes page fault. Page replacement time is 2 ms . Calculate the effective memory access
time , assuming page memory access requires 2 memory accesses and TLB requires one memory access.

A) 38120 ns B) 40000 ns C) 40120 ns D) None

operating-system virtual-memory normal

0.85(10+110)+0.15(13/15(10+100+100)+2/15(10+100+2000000+100)=40125

85% time there will be a TLB hit so it will take (10+100) ns.

15% of the time two things can happen:

X% of the time page fault will occur that is it will take (10+100+2000000+100) ns.
(1-X)% of the time no page fault so it will take (10+100+100) ns.

Page fault occurs 2% of the total memory accesses so X% of 15 should be equal to 2.

i.e. 15 * X/100 = 2 X=200/15.

 0 votes -- Viral Kapoor ( 1777 points)

6.204 Virtual Memory: Calculate the number of levels of outer page required
top gateoverflow.in/30487

In a paged virtual memory organization with 32 bit virtual address and 1 KB page size PTE is 32 bits. The number of levels of
paging required to limit the outer page table fit in one page frame is ________

operating-system virtual-memory


Selected Answer

Page size is 1KB.

2 32
10
So, no. of pages = 2 = 222.

Each page entry requires 32 bits = 4 bytes as given in question.

Now, the outer page table must fit in a page frame - its size must be ≤ 1KB.

2 10
2
So, no. of entries in outer page table ≤ 2 = 256.

So, we use 8 VA bits for indexing into page table 1.

It is not mentioned in question if the second level page table must also fit in a page frame, but assuming this, we need
another 8 bits maximum for second level and only 32 - 10 - 8 - 8 = 6 bits remain for third level meaning it can easily fit in
a page frame.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 644 of 2244

 1 votes -- Arjun Suresh ( 124125 points)

Virtual address 32 bit

page size 2 10 B

No of pages (32-10)=22 bits

PTE 32 bit=4 B=2 2B

So, -ve factor i.e. 1st level page will be 2 bit less than page size

So, 1st level page will be 8 bits, 2nd level 8 bits

3rd level remaining 6 bits

So, answer will be 3

 1 votes -- srestha ( 11585 points)

6.205 Virtual Memory: Please explain this question on paging top gateoverflow.in/29409

http://www.cs.utexas.edu/~lorenzo/corsi/cs372/06F/hw/3sol.html

The question number 1 part 3 of the above link asks

1. What is the size of a page table for a process that has a code segment of 48K starting at address 0x1000000, a data segment of 600K starting at address
0x80000000 and a stack segment of 64K starting at address 0xf0000000 and growing upward (like in the PA-RISC of HP)?

And the answer starts with

First, the stack, data and code segments are at addresses that require having 3 page tables entries active in the first level page table.

What does this above line mean?


Cant we approach the problem as in calculate first the entire memory that the process requires (64+600+48) and then
advancing like a usual problem like how much memory is required to store a process of 712 k?

operating-system virtual-memory

6.206 Virtual Memory: paging top gateoverflow.in/36388

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 645 of 2244

virtual-memory

6.207 Virtual Memory: 2 level paging top gateoverflow.in/20504

consider a system using 2 level paging applicable page table is divided into 2K pages each of size 4 KB. if pas is 64 MB which
is divided into 16K frames memory is byte addressable . page tabke entry size is 2 bytes in both the levels calculate the
length of

logical and physical address.

total number of entry at second level

operating-system virtual-memory

PAS=64MB =2^26 B
so PS=26bit
Page Size=2^12 B so Page offset=12 bit
so the PS is divided as 14|12
This step does not require any paging info
-------------------------------------------------------------

inner most PT size =Number of pages * Size of each page =2^11 * 2*12 = 2^23 B
PTE size =2B
so No of PTE = 2^23/2=2^22 = Number of pages in the process
So the Virtual adress is divided as 22|12
Now outer page table size =2^23 B and page size = 2^12 B so inner page table cant fit in one page
hence paging of inner page table is required , so the number of pages possible of the inner page table each of 4K size is
2^23/2^12 =2^11 pages = number of entries for the outer page table
PTE size = 2B
so outer page table size= 2^11*2 = 2^12 B

So outer page table size is 2^12B and page size is 2^12 B so now the page table can fit in one page of the main memory
. Hence no longer paging of outer page table is required
So answer is : 14|12
22|12
2^11 entries or 2K entries
Hope this helps!

 0 votes -- Rohit Mallik ( 131 points)

6.208 Virtual Memory: Maximum size of Main Memory supported with 2 Level
Paging top gateoverflow.in/28969

Consider a 32-bit virtual address is used for paging with page size of 1024 bytes. Two-level paging is implemented with
equal number of entries in every page table of the system. If page table entry size is 2 bytes. The maximum size (in MB) of
main memory supported by the above system is ______.

-----------------------------------------------------------------------------------------------------------

Total no of entries Per page = 1024 / 2 = 512


No of entries addressible in 2 level paging = 29 * 29 = 2 18

Maximum size of Main Memory in 2 Level Paging => 2 18 * 1024 B = 2 28 Bytes = 256 MBytes.

Answer is given as 64 MB.

Just cross checking my answer here !

From Made Easy FLT 6-Practice Test 14 Q 59

virtual-memory operating-system

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 646 of 2244


Selected Answer

Conversion from virtual address to physical address .

VA = 22 +10

as page table entry is 2 bytes . which represents physical address

PA= 16 +10=26 bits

maximum possible physical memory =2^26 bytes

 5 votes -- pramod ( 2071 points)

6.209 Virtualgate: Virtualgate2015 os 7 top gateoverflow.in/35592

operating-system virtualgate

6.210 Virtualgate: Virtualgate2015 os22 top gateoverflow.in/35596

virtualgate operating-system


Selected Answer

--> Safety Algorithm requires O(m x n^2) time complexity where m is work vector and n is the finish vector
. So, option (D) is correct .

--> Lines from Galvin ( page - 288 pdf ).

 2 votes -- Vinay Yadav ( 1739 points)

6.211 Virtualgate: Virtualgate 2015 os ques 20 top gateoverflow.in/35579

Suppose that a process spends a fraction of time P performing CPU activity.With n processes in memory at once, the
probability that all n processes are perforimng I/O operation.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 647 of 2244

A P n

B 1-Pn

C (1-P) n

D 1-(1-P)n

virtualgate operating-system

6.212 Virtualgate: Virtualgate2015 os 11 top gateoverflow.in/35593

virtualgate operating-system

6.213 Virtualgate: Virtualgate 2015 os top gateoverflow.in/35576

Consider a 256k 4- way set associative cache with block size 64 Bytes. Main memory is 2Gb. The number of bits used for
tag,set and word will be respectively?

A 10,15,6

B 9,16,6

C 8,17,6

D 7,18,6

I think answer is 15,10,6 (tag,set,word)

virtualgate operating-system cache-memory

6.214 Disk scheduling top gateoverflow.in/41437

Consider following disk request sequence for a disk with 100 tracks.

44, 20,95,4,50,52,47,61,87,25

Head pointer starting at 50. Find the no. of head movements in cylinders using SCAN scheduling. Assume head moving
towards cylinder 99.

SCAN Algorithm:

When a new request arrives while the drive is idle, the initial arm/head movement will be in the direction of the cylinder where the data is stored, either in or out.
As additional requests arrive, requests are serviced only in the current direction of arm movement until the arm reaches the edge of the disk. When this
happens, the direction of the arm reverses, and the requests that were remaining in the opposite direction are serviced, and so on.

50->52 = 2
52->61 = 9
61->87 = 26

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 648 of 2244

87->95 = 8
95->99 = 4
99->47 = 52
47->44 = 3
44->25 = 19
25->20 = 5
20->4 = 16
Total = 144 head movements.

Alternate:
50->99 = 49
99->4 = 95
Total = 144 head movements

Answer) 144

 2 votes -- Abhilash Panicker ( 6527 points)

In SCAN Algorithm, the disk arm(head) starts at one end of the disk and moves toward the other end servicing requests
as it reaches each cylinder it gets to the other end of the disk. At the other end direction of the head movement is
reversed and servicing continues.

For the given problem, first the arm will move towards 99 and reverses back to Zero(0) as follows:

50->52->61->87>95->99->47->44->25->20->4.

Arm movements required to go from 50 to 52 = 2

Arm movements required to go from 52 to 61 = 9

Arm movements required to go from 61 to 87 = 26

Arm movements required to go from 87 to 95 = 8

Arm movements required to go from 95 to 99 = 4

Arm movements required to go from 95 to 47 = 52

Arm movements required to go from 47 to 44 = 3

Arm movements required to go from 44 to 25 = 19

Arm movements required to go from 25 to 20 = 5

Arm movements required to go from 20 to 4 = 16

Total head movements = 2+9+26+8+4+52+3+19+5+16 = 144

 1 votes -- vamsi2376 ( 1185 points)

6.215 Disk Scheduling top gateoverflow.in/41434

Consider an operating system capable of loading and executing a single sequential user process at a time. The disk head
scheduling algorithm used is First Come First Served (FCFS). If FCFS is replaced by shortest seek Time Fist (SSTF), claimed
by the vendor to given 50% better beachmark results, what is the expected improvement in the I/O performance of user
programs?

(A) 50%
(B) 40%
(C) 25%
(D) 0%

D) 0%

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 649 of 2244

In a single-user environment, the I/O queue usually is empty. Requests generally arrive from a single process for one
block or for a sequence of consecutive blocks. In these cases, FCFS is an economical method of disk scheduling since OS
can execute a single sequential user process at a time, the disk is accessed in FCFS manner always. The OS never has a
choice to pick an IO from multiple IOs as there is always one IO at a time.

 0 votes -- vamsi2376 ( 1185 points)

6.216 what is the relation between bounded waiting ,Progress and starvation
? top gateoverflow.in/33930

If any synchronization mechanism does not gurantee any of the conditions either progress or bounded waiting then will it
always lead to starvation ,and if both are satisfied then can deadlock occur still ?

6.216 what is cycle time?? top gateoverflow.in/37298

6.217 CPU Scheduling top gateoverflow.in/34221

A process spends 25% of its waiting time waiting for i/o to complete.If 3 processes in memory at a same time then
probability of cpu time wasted(Assume that all i/o operatio is overlapped)

25% time is for IO .

So all the 3 processes will be in IO -

.25*.25*.25= 0.015625

 0 votes -- Pranay Datta ( 6113 points)

6.218 memory management top gateoverflow.in/37204

Consider a system with a two-level paging scheme in which a regular memory access takes 150 nanoseconds, and servicing
a page fault takes 8 milliseconds. An average instruction takes 100 nanoseconds of CPU time, and two memory accesses.
The TLB hit ratio is 90%, and the page fault rate is one in every 10,000 instructions. What is the effective average instruction
execution time?
A
645 nanoseconds

B
1050 nanoseconds

C
1215 nanoseconds

D
1230 nanoseconds

6.219 Please exaplain? top gateoverflow.in/34063

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 650 of 2244

6.220 VIRTUAL_GATE top gateoverflow.in/33919

Consider a file system that uses UNIX like inodes to keep track of the sectors allocated to files. Assume that disk blocks are 1 KB in size,
disk block addresses are 32 bits and the inode has space for 8 direct blocks, 1 singly indirect blocks, 1 doubly indirect block and 1 triply
indirect block. What is the largest disk drive that could be fully utilized by this system?

(A) 232 bytes


(B) 2 34 bytes
(C) 210 bytes
(D) 242 bytes

Disk Block Size(DBS)= 1KB = 2^10

Disk Block Address(DBA) = 32bits = 4B = 2^2

Only triple indirect block will be considered because maximum file size is possible only in Triple Indirect

Therefore, ---->> (DBS/DBA)^3*DBS

---->> (2^10/2^2)^3*2^10

---->> (2^30/2^6)*2^10

---->> 2^34

 2 votes -- Saumik Sarkar ( 157 points)

Disk Block Address = 32-bit = 4B

Disk Block Size = 1KB

#of Disk Block Pointer that can fit in one block pointer = 1024/4 = 256

Direct pointer maximum file size = 8 * 1KB = 8KB

Due to Single Indirect Pointer maximum file size = 256 * 1KB = 256KB

Due to Double Indirect Pointer maximum file size = 256 * 256 * 1KB

Due to Triple Indirect Pointer maximum file size = 256 * 256 * 256 * 1KB

so, total file size (approx) = 2^34 Bytes.

 1 votes -- Prasanna Ranganathan ( 2045 points)

with 32 bit 2^32 blocks can be addressed

max disk drive size=2^32*2^10=2^42

 1 votes -- Pooja ( 22773 points)

6.221 Deadlock top gateoverflow.in/41450

Consider the following snapshot of a system running n processes. Process i is holding xi instances of a resource R, for 1≤i≤n.
Currently, all instances of R are occupied. Further, for all i, process i has placed a request for an additional y, instances while
holding the xi instances it already has, There are exactly two processes p and q such that yp = yq = 0: Which one of the
following can serve as a necessary condition to guarantee that the system is not approaching a deadlock?
(A) min(xp,xq) < maxk≠p,q yk (B) xp+xq ≤ maxk≠p,q yk (C) min(xp,xq) < 1 (D) min(xp,xq)>1

6.222 Process scheduling top gateoverflow.in/41448

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 651 of 2244

Consider three processes (process id 0,1,2, respectively) with compute time bursts 2,4, and 8 time units. All processes
arrive at time zero. Consider the longest remaining time first (LRTF) scheduling algorithm. In LRTF ties are broken by giving
priority to the process with the lowest process id. The average turn around time is
(A) 13 units (B) 14 units (C) 15 units (D) 16 units

Caption

 3 votes -- rajan ( 1287 points)

6.223 A set of processors P1, P2, ……, Pk can execute in parallel if


Bernstein’s conditions top gateoverflow.in/41871

A set of processors P1, P2, ……, Pk can execute in parallel if Bernstein’s conditions are satisfied on a pairwise basis; that is P1
|| P2 || P3 || ….. || Pk if and only if : (A) Pi || Pj for all i ≠ j (B) Pi || Pj for all i = j+1 (C) Pi || Pj for all i < j (D) Pi || Pj for
all i > j

(A) Pi || Pj ∀ i≠j

P.S. I think this should be tagged under CO and Architecture.

 1 votes -- Sourav Mishra ( 221 points)

6.224 operating System - Scheduler top gateoverflow.in/36973

Can we say Dispatcher is a sub-module of Mid Term Scheduler ?


Mid term scheduler is responsible for degree of multi-tasking .. t/f ??

6.225 ugc net 13 top gateoverflow.in/43684

Unix operating system uses i-nodes


to keep track of data blocks allocated
to a file. It supports 12 direct block
addresses, one indirect block address
and one double indirect block
address. The file system has 256
bytes block size and 2 bytes for disk
block address. The maximum
possible size of a file in this system is
(A) 16 MB (B) 16 KB
(C) 70 KB (D) 71 KB

direct block addressing will point to 12 disk blocks=12*256B

Singly Indirect block addressing will point to 1 disk block which has 256/2 disc block addresses

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 652 of 2244

=128*256B

Doubly indirect block addressing has (256/2)*(256/2) disk block addresses

=128*128*256B

Total File Size=(12+128+128*128)*256B

=4131KB

Or Alternatively you can do direct by formula

Max File size in File System=[#of Direct DBA +(DB Size/DBA)+(DB Size/DBA)^2+(DB Size/DBA)^3+........]*DB Size

Max File Size possible in file System=[ 12+ 256/2+ (256/2)^2]*256B

=4131KB

or 4MB(apx)

No option is true.

 1 votes -- Manojk ( 3365 points)

6.226 processes top gateoverflow.in/36895

6.227 Non vectored interrupts top gateoverflow.in/32835

http://superuser.com/questions/414290/when-a-non-vectored-interrupt-occurs-does-the-processor-ever-look-up-the-vector

In a non-vectored interrupt, the peripheral itself provides the address of the interrupt service routine directly to the processor. This requires more time for
an interrupt to be serviced, since the address must be retrieved from the interrupting device every time the interrupt is triggered.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 653 of 2244

S ans is B??

operating-system test-series

Correct answer : (D)

In non-vectored interrupt, it is responsibility of CPU to find the address of ISR and to find the device which caused
interrupt.Actually once CPU gets interrupt from a device, it completes its current execution phase and start servicing the
interrupt. To do so,CPU first runs a default ISR, address of it is already known to CPU. Now this default service routine is
stored somewhere in fixed memory location which CPU knows. So CPU refers to it and find the address of actual ISR from
it & also address of the device which caused the interrupt. Actually CPU uses POLLING technique to find address of
interrupt causing device.So once CPU gets address of ISR,it starts executing it and after completion it resumes its own
execution.

 0 votes -- Shashank Kumar ( 2029 points)

6.228 Find maximum number of files possible in this file system top gateoverflow.in/32832

test-series


Selected Answer

No of files=2^13/2^2=2K files

 1 votes -- Pooja ( 22773 points)

6.229 madeeasy top gateoverflow.in/37064

6.230 isi m.tech top gateoverflow.in/44249

Assume that initially 1 Megabyte of memory is available to a multiprogramming


operating system. The operating system itself occupies
250 Kilobytes of memory, and every process that is executed also requires
250 Kilobytes of memory. Assume that the processes are independent.
(i) How much additional memory is required to get more than 99%
CPU utilization if each process spends 50% of its time waiting for
the I/O operations?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 654 of 2244

Let there is n process, each process waiting time 0.5.


so CPU utilization = (1 - .5n)*100 = 99

(1/2) n = 1/100, so value of n will be 6. (2 7 =128 so we take 6)

there is 6 processes required for 99% utilization , each process utilize 250 KB , so total memory needed = 6*250
=1500KB.
now we have already 750KB(1000-250 as os occupied ) so required memory will be 1500-750 = 750 KB

 1 votes -- Dipak Barnwal ( 43 points)

6.231 Calculation of context switch overhead - ISI KOL -2014 Qstn 6(a) top
gateoverflow.in/43781

Consider three processes, P1, P2, and P3. Their start times and execution
times are given below

Let x be the amount of time taken by the kernel to complete a context


switch from any process Pi to Pj . For what values of x will the average
turnaround time for P1, P2, P3 be reduced by choosing a Shortest Remaining
Time First scheduling policy over a Shortest Job First policy?

operating-system

In case of SJF

P.No AT BT CT TAT WT
1 0 100 100 100 0
2 25 50 170 145 45
3 50 20 120 70 50

0 100 120 170

p2 p3 p2

Avg TAT =100+145+70 /3 =105

In case of SRTF

P no AT BT CT TAT WT
1 0 100 170 170 70
2 25 50 95 70 20
3 50 20 70 20 0

0 25 50 70 95 170

p1 p2 p3 p2 p1

Avg TAT =170+70+20 /3 =86.66

They asked For what values of x will the average

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 655 of 2244

turnaround time for P1, P2, P3 be reduced by choosing a SRTF over SJF But here it is already less so we can consider x=0.
(See both TAT ( SRTF TAT<SJF TAT))

 0 votes -- shekhar chauhan ( 643 points)

6.232 CPU Scheduling Algorithms top gateoverflow.in/36718

Consider three processes, all arriving at time zero, with total execution time of l0,20and 30
units, respectively. Each process spends the first 20% of the execution time doing VO, the next
70% of the execution time doing computation and the last 10% of the time doing I/O again. The
operating system uses shortest remaining time first algorithm and schedules a new process either
when the running process gets blocked on I/O or when the running process finishes its compute
burst. Assume that all I/O operations can be overlapped as much as possible. For what
percentage of the time does the CPU remain idle?

operating-system

6.233 fork question top gateoverflow.in/43453

The answer is given as 11. can anybody explain probably with a diagram?

say for loop is executing k<=3, then picture will be this. isnot it?

 0 votes -- srestha ( 11585 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 656 of 2244

6.233 Why are user level threads faster than kernel level threads? top gateoverflow.in/41646

Kernel-level threads require a context switch, which involves changing a large set of processor registers that define the current memory map and
permissions. It also evicts some or all of the processor cache.

User-level threads just require a small amount of bookkeeping within one kernel thread or process.

However, the difference isn't big if your threads are predominantly doing I/O operations, as those have to go through the kernel in any case. It's most
important if you're trying to implement some kind of simulation with a very large number of independant processes. In that case you need to pay
careful attention to what thread synchronisation mechanisms you use, as some of them also go up to the kernel and trigger a context switch.

http://www.cs.rochester.edu/u/cli/research/switch.pdf "In general, the indirect cost of context switch ranges from several microseconds to more than
one thousand microseconds for our workload."

Edit: user-level threads maintain a stack per-thread, and may or may not save the general-purpose registers depending on the architecture and the
clobber rules of its calling convention. It can be as simple as dumping the registers to the stack, jumping to a new address, and popping a few
registers, which may be in your cache if that thread was run recently.

Kernel-level context switches also change the memory map by writing to the TLB, and changing the security level (privilege level or "ring") of the
processor. See "Performance Considerations"

 2 votes -- Rude Maverick ( 3063 points)

User level threads are managed by a user level library however, they still require a kernel system call to operate. It
does not mean that the kernel knows anything about thread management. Not at all, It only takes care of the execution
part. The lack of cooperation between user level threads and the kernel is a known disadvantage. In this case, the kernel
may not favour a process that has many threads. User level threads are typically fast. Creating threads, switching
between threads and synchronizing threads only needs a procedure call. They are a good choice for non blocking tasks
otherwise the entire process will block if any of the threads blocks.

Kernel level threads are managed by the OS, therefore, thread operations (ex. Scheduling) are implemented in the
kernel code. This means kernel level threads may favour thread heavy processes. Moreover, they can also utilize
multiprocessor systems by splitting threads on different processors or cores. They are a good choice for processes that
block frequently. If one thread blocks it does not cause the entire process to block. Kernel level threads have
disadvantages as well. They are slower than user level threads due to the management overhead. Kernel level context
switch involves more steps than just saving some registers. Finally, they are not portable because the implementation is
operating system dependent.

S.No. User Level Threads Kernel Level Thread


1 User level threads are faster to create and manage. Kernel level threads are slower to create and manage.
Implementation is by a thread library at the user
2 Operating system supports creation of Kernel threads.
level.
User level thread is generic and can run on any
3 Kernel level thread is specific to the operating system.
operating system.
Multi-threaded application cannot take advantage of
4 Kernel routines themselves can be multithreaded.
multiprocessing.

 1 votes -- vamsi2376 ( 1185 points)

6.234 How much of memory would be proportionally allocated??? top gateoverflow.in/41505

If the total number of available frames is 50, and there are 2 processes one of 10 pages and the other of 5 pages. Then how much of memory would be
proportionally allocated to each of these processes?

a. Depends on the process requirements

b. 33 and 16 frames respectively

c. Memory is allocated equally for both

d. 5 and 10 respectively

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 657 of 2244

Isn't this a straightforward question ? ratio should be same right ? 2:`1..

Isn't the answer 33:16 ?

 0 votes -- nikhil1008 ( 243 points)

6.235 Virtual Addressing top gateoverflow.in/41455

A processor uses 36 bit physical addresses and 32 bit virtual addresses, with a page frame size of 4 Kbytes. Each page table
entry is of size 4 bytes. A three level page table is used for virtual-to-physical address translation, where the virtual address
is used as follows
 bits 30-31 are used to index into the first level page table,
 bits 21-29 are used to index into second level page table
 bits 12-20 are used to index into third level page table
 bits 0-11 are used as offset within the page
The number of bits required for addressing the next level page table(or page frame) in the page table entry of the first,
second and third level page table are respectively

(A) 20,20 and 20 (B)24,24 and 24 (C) 24,24 and 20 (D) 25,25 and 24

6.236 Virtual Addressing top gateoverflow.in/41416

Suppose a process has only the following pages in its virtual address space; two contiguous code pages starting at virtual
address 0x0000000, two contiguous data pages starting at virtual address 0x00400000, and a stack page starting at virtual
address 0xFFFFF000. The amount of memory required for storing the page tables of this process is
(A)8 KB (B) 12KB (C) 16 KB (D) 20KB

Some part of the question is missing. Actually it is common data question in CS gate. Answer is 16 kB. Two code pages
are present in one page Two data pages are present in one page Stack takes one page Page table takes one page total
4*4K=16K

 0 votes -- raghu iiit ( 23 points)

6.237 cpu scheduling top gateoverflow.in/42725

6.238 IIIT H PGEE 2016 top gateoverflow.in/43174

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 658 of 2244

A computer system supports 32-bit virtual addresses as well as 32-bit physical addresses. Since the virtual address space is of the same size
as the physical address space, the operating system designers decide to get rid of the virtual memory entirely. Which one of the following is
true?

(A) Efficient implementation of multi-user support is no longer possible


(B) The processor cache organization can be made more efficient now
(C) Hardware support for memory management is no longer needed
(D) CPU scheduling can be made more efficient now

This question has made created doubt every time I see this question This is previous year gate question... According to
me Answer Should be Option A) but everywhere The answer is given is option C)

 0 votes -- saif ahmed ( 931 points)

6.239 cpu scheduling top gateoverflow.in/42730

6.240 ugc net dec15 top gateoverflow.in/33805

in an operating system , indivisibility of operation means:

1)Operation is interruptable

2)Race Condition may occur

3)processor can not be prempted

4)All of the above

ANSWER: 3

EXPLANATION

An indivisible or irreducable operation is an atomic operation that is performed entirely or not performed at all.

Any operation which is indivisible requires processor until it executes entirely. If processor decides to perform some other
operation or service some other request like interrupt, the operation will be left to the current state and might never be
executed entirely, ever. However, the state of operation might be or might not be consistent, but the operation is
anyways reduced and violates the property of indivisible operation.

Race condition is an undesirable situation where two or more process attempts to modify same data at almost same time,
which is a concept of multithreading.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 659 of 2244

 1 votes -- Prateek Dwivedi ( 845 points)

6.241 CSE top gateoverflow.in/38800

Consider a cache as follows:


• Direct mapped.
• 8 words total cache data size.
• 2 word cache block size.
A sequence of eight memory reads is performed in the order shown from the following addresses.
0, 11, 4, 14, 9, 1, 8, 0
The (number of misses + Number of compulsory misses + Number of conflict misses) value is ______.

6.242 os top gateoverflow.in/38080

6.243 os top gateoverflow.in/38079

6.244 os top gateoverflow.in/38078

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 660 of 2244

6.245 Page table size top gateoverflow.in/35798

In a 32-bit machine we subdivide the virtual address into 4 segments as follows: 10-bit 8-bit 6-bit 8 bit
We use a 3-level page table, such that the first 10-bit are for the first level and so on.
1. What is the size of a page table for a process that has 256K of memory starting at address 0?

2. What is the size of a page table for a process that has a code segment of 48K starting at address
0x10000000, a data segment of 600K starting at address 0x80000000 and a stack segment of 64K
starting at address 0xf00000000 and growing upward (like in the PA-RISC of HP)?

6.246 os top gateoverflow.in/38081

6.247 Probability top gateoverflow.in/37518

A process spends 20 of its execution time waiting for completion of I/O operation. If there are 4 processes in memory at
once, then the probability of CPU time wasted is ____ (Assume all I/O operations are overlapped, upto 3 decimal places).

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 661 of 2244

6.248 Process top gateoverflow.in/35424

Suppose a new process in a system arrives at an average of six processes per minute and each such process requires an
average of 8 seconds of service time. Estimate the fraction of time (in %) the CPU is busy in a system with a single
processor?

operating-system


Selected Answer

Consider a minute. 6 process arrives and each require 8 seconds service time - totally 6*8 = 48 seconds. So, out of 60
seconds, 48 seconds, CPU will be busy -

4
5

 5 votes -- Arjun Suresh ( 124125 points)

6.249 fork() top gateoverflow.in/37472

main()

printf(" * ");

for(i=0;i<n;i++)

fork();

printf(" * ");

how many times * is printed??

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 662 of 2244

2n +1

Try drawing a tree to understand how each fork works.

http://www.csl.mtu.edu/cs4411.ck/www/NOTES/process/fork/create.html

 0 votes -- bahirNaik ( 2479 points)

6.250 FORK parent vs. child distinction top gateoverflow.in/37082

if multiple forks are given. then multiple processes will be created. Are all children created through first child are counted as
children only?

you can say they are grand child :) and this can go any depth. If on a unix shell try getting parent of a process, then its
parent and so on..

 1 votes -- Arjun Suresh ( 124125 points)

6.251 Page Table top gateoverflow.in/35800

In a 32-bit machine we subdivide the virtual address into 4 pieces as follows:


8-bit 4-bit 8-bit 12-bit.

We use a 3-level page table, such that the first 8 bits are for the first level and so on. Physical addresses are44
bits and there are 4 protection bits per page. Answer the following questions

1. How much memory is consumed by the page table and wasted by internal fragmentation for a process that
has 64K of memory starting at address 0?
2. How much memory is consumed by the page table and wasted by internal fragmentation for a process that
has a code segment of 48K starting at address 0x1000000, a data segment of 600K starting at address
0x80000000 and a stack segment of 64K starting at address 0xf0000000 and growing upward (towards
higher addresses)?

6.252 File Allocation top gateoverflow.in/36029

Please clarify the structure of blocks if possible.

operating-system

block entry=32 bit= 4byte

we have one block for directory

now number of file entries in directory =8kb/4=2K

so max 2K files possible

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 663 of 2244

 1 votes -- Pooja ( 22773 points)

6.253 cylinder number of sector?? top gateoverflow.in/36278

Consider a hard disk with 16 recording surfaces (0-15) having 16384 cylinders (0-16383) and each cylinder contains 64
sectors (0-63). Data
storage capacity in each sector is 512 bytes. Data are organized cylinder-wise and the addressing format is <cylinder no.,
surface no., sector
no.> . A file of size 42797 KB is stored in the disk and the starting disk location of the file is <1200, 9, 40>. What is the
cylinder number of the
last sector of the file, if it is stored in a contiguous manner?
(A) 1281 (B) 1282 (C) 1283 (D) 1284

6.254 Avoidance of mutual exclusion top gateoverflow.in/37774

which of the following is the guaranteed solution of avoidance of mutual exclusion?

1. Semaphore

2. Monitor

3. Bankers Algorithm

4. None

operating-system

Monitor bcoz bankers is deadlock avoidance technique and if semaphore is used in the wrong way it could violate mutual
exclusion condition so ans is monitor

 0 votes -- Amey ( 195 points)

6.255 process-schedule top gateoverflow.in/36280

Consider the 3 processes, P1, P2 and P3 shown in the table. Process Arrival time Time Units Required

(arrival time,time required)

P1 0 5

P2 1 7

P3 3 4

The completion order of the 3 processes under the policies FCFS and RR2 (round robin scheduling with CPU quantum of 2
time units) are

(A) FCFS: P1, P2, P3 RR2: P1, P2, P3

(B) FCFS: P1, P3, P2 RR2: P1, P3, P2

(C) FCFS: P1, P2, P3 RR2: P1, P3, P2

(D) FCFS: P1, P3, P2 RR2: P1, P2, P3

operating-system process-schedule normal in fcfs order of execution is P1 P2 P3 in

RR2 0-2 :p1 2-4:p2 4-6:p1 6-8:p3 8-10:p2 10-11:p1 11-13 :p3 13-15:p2 15-16:p2

p1completes at 11 P3 completes at 13 P2 at 16 so order is P1 P3 P2

can anyone give me proper explanation, i cant understand why in 4-6 part p1 is taking (not p3?).

not getting what you are asking but I hope the below work help you.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 664 of 2244

 1 votes -- bahirNaik ( 2479 points)

6.256 memory top gateoverflow.in/37804

6.256 virtual memory top gateoverflow.in/37901

6.257 Number of resource instances top gateoverflow.in/36097

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 665 of 2244

PIGEONHOLE Principle.

allocate k-1 resources to each process + 1 to avoid deadlock.


= n*(k-1) + 1
= n*k - n + 1

 0 votes -- Digvijay Pandey ( 26245 points)

6.258 virtual memory top gateoverflow.in/37902

ans is c(3)

If the size of the page table>=Page Size we go for multilevel paging , Paging is
Applied on the Pages of page table until first level page table size<==Page size.
in the question there is a misprint, INSTEAD OF PTE{page table entry} size ptr size is given.

Page Table Size=#of Pages*Page Table Entry Size

#of Pages=LAS/Page Size

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 666 of 2244

PTE=4B

--->1st time paging{last level page table}

Page table Size=(2^32/2^10)*2^2B

Still page table size ==2^24>>page size(2^10)

--->2nd time paging{second last page table}

Page Table Size=(2^24/2^10)*2^2

2^16>>2^10

--->3rd time paging

Page Table Size=(2^16/2^10)*2^2B

Now page Table Size=2^8==256Bytes <Page Size

So

3 level page table is required ,so that outer page table fit in one page frame.

 0 votes -- Ankesh Gautam ( 665 points)

6.258 what is the logic to find max and min no. of resources that are requied
to avoid deadlock top gateoverflow.in/36055

6.259 Operating System top gateoverflow.in/36061

Disk Access Question

operating-system test-series

Total number of blocks K = 64MB/4MB = 16 blocks

Block transfer rate =

32 MB - 20 ms

4MB - 2.5 ms

Total Access time = Seek + RotationalDelay + K*(transfer time for each block) [Blocks are stored sequentially, therefore
they would be in the same cylinder]

= 30 ms + 10ms + 16 *2.5 = 40 ms + 40 ms = 80 ms.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 667 of 2244

 0 votes -- bahirNaik ( 2479 points)

6.260 os top gateoverflow.in/38082

6.261 Context switching in concurrent processes top gateoverflow.in/38301

Three concurrent processes X, Y, and Z execute three different code


segments that access and update certain shared variables. Process X
executes the P operation (i.e., wait) on semaphores a, b and c; process Y
executes the P operation on semaphores b, c and d; process Z executes the
P operation on semaphores c, d, and a before entering the respective code
segments. After completing the execution of its code segment, each process
invokes the V operation (i.e., signal) on its three semaphores. All semaphores
are binary semaphores initialized to one. Which one of the following
represents a deadlockfree order of invoking the P operations by the
processes? (GATE CS 2013)

operating-system

X(c,b,a) Y(c,b,d) Z(c,d,a)-- will unsure deadlock free

 0 votes -- Deepesh Kataria ( 1207 points)

6.262 Number of bits in TLB tag top gateoverflow.in/39312

A CPU generates 32 bit virtual address. The page size is 2KB. The translation look aside buffer (TLB) can hold 256 page table
entries and is 2 way set associative mapping. The number of bits in TLB tag is ____ and total bits in single TLB entry ____?

Ans for TLB tag: 14 bits ( not sure) for first part

SOL acc to me: 11 bits are offset , table address index will be 7 bits and therefore tag will be 32 - 11 - 7 = 14

Block Size=2KB=2^11B

#f bits required for Word/Block Offset=11 bits

#Line(N)=256

Total No of Sets=N/P-Way=256/2=128=2^7

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 668 of 2244

#f Bits required for Set Offset=7bits

#f bits required for Tag=32-(11+7)=14bits

<----------------------32--------------------->

Tag Set Block


Offset Offset
14 7 11

No of Entry in TLB=LAS/Page Size


= 2^32/2^11=(2^21)B
#f bits required for tlb entry=21

 1 votes -- Ankesh Gautam ( 665 points)

6.263 virtual memory top gateoverflow.in/39129

If nothing is given in the question , then should we assume that all the page tables are page aligned ?

6.264 optimal page size top gateoverflow.in/36408

average process size is 128KB per page entry requires 8 bytes, then optimal page size?

64B 128B 7254B none

6.265 fork top gateoverflow.in/37876

how fork exeuted what is answer for this

(D) None.

My answer 2n +1 − 1 times ' * ' will be printed. Pls correct me if I'm wrong.

 0 votes -- Nirmal S ( 27 points)

6.266 memory management top gateoverflow.in/40446

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 669 of 2244

A processor uses 36 bit physical addresses and 32 bit virtual addresses, with a page frame size of 4 Kbytes. Each page table
entry is of size 4 bytes. A three level page table is used for virtual to physical address translation, where the virtual address
is used as follows
• Bits 30-31 are used to index into the first level page table
• Bits 21-29 are used to index into the second level page table
• Bits 12-20 are used to index into the third level page table, and
• Bits 0-11 are used as offset within the page
The number of bits required for addressing the next level page table (or page frame) in the page table entry of the first,
second and third level page tables are respectively

(A) 20, 20 and 20 (B) 24, 24 and 24 (C) 24, 24 and 20 (D) 25, 25 and 24

6.267 If a room have capacity of 20 persons... top gateoverflow.in/41231

If a room have capacity of 20 persons...9 persons already inside the room....then what will be the value of semaphore
integer.
A. 20
b. 9
c. 11
d. 29


Selected Answer

Depends on implementation- question is incomplete.

Assuming a counting semaphore is used to indicate the availability of a space in the room we can do as follows:

Semaphore value x- denote x person can enter the room.

So, initial value of semaphore here is 20 and when 9 person are inside, it becomes 20 − 9 = 11.

 3 votes -- Arjun Suresh ( 124125 points)

6.268 Which of the following is TRUE about the above construct ? top gateoverflow.in/41273

Two processes P 1 and P 2 need to access a critical section of code.Consider the following syncronization construct used by the
processes-

|*P1*|

while (true) {
wants1 = true;
while(wants2 == true);
[Critical Section]
wants1 = false;
}

|*P2*|

while(true) {
wants2 = true;
while(wants1 == true);
[Critical Section]
wants2 = false;
}

Here,wants1 and wants2 are shared variables which are initialized to false.Which one of the following statements is TRUE
about the above construct ?

(a) It does not ensure mutual exclusion.

(b) It does not ensure bounded waiting.

(c) It requires that processes enter the critical section in strict alteration.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 670 of 2244

(d) It does not prevent deadlocks,but ensures mutual exclusion.

gate2006-cs

It ensures Mutual Exclusion as only one process can enter Critical section at a time

But it does not prevent deadlock as if both wants1 and wants2 becomes true it enters in deadlock
state...

The Answer is D)

 3 votes -- saif ahmed ( 931 points)

6.269 PROGRESS/BOUNDED WAIT in OS top gateoverflow.in/36508

i am unable to understand the concept of progress and bounded waiting after many reads of galvin.... i knw the basic but how to say looking at a code that progress
is satisfied?

recommend any good video or write up

6.270 Does compile time binding also indicate that the compiled code is
allocated in memory at compile time ? top gateoverflow.in/34396

I have just one confusion that when we talk about compile time binding then all the symbols are resolved at compile time so
does it necessarily imply that the code will also be allocated memory at that time only , since absolute address is known at
that time ?

any binding actually means when the code is binded with the actual address. if it is compile time then the actual address
will be available at compile time. if it is run time the address will be available at run time. and if link time then it means
the code be binded at link time. and we know linker is used at link time this means the linker will be converting your
relocatable address to absolute address. in run time loader will be doing it, and compile time compiler do it . refrence
:http://www.isical.ac.in/~mandar/os/memory.pdf

Compile-time binding
Location of program in physical memory must be known at
compile time
Compiler generates absolute code
compiler binds names to actual physical addresses
Loading ​ copying executable file to appropriate location in
memory
If starting location changes, program will have to be recompiled
Example: .COM programs in MS-DOS

 0 votes -- Ravi Singh ( 7303 points)

6.271 In a 32-bit machine we subdivide the virtual address into 4 segments


top gateoverflow.in/34429

In a 32-bit machine we subdivide the virtual address into 4 segments as follows: 10-bit 8-bit 6-bit 8 bit
We use a 3-level page table, such that the first 10-bit are for the first level and so on.
1. What is the size of a page table for a process that has 256K of memory starting at address 0?
2. What is the size of a page table for a process that has a code segment of 48K starting at address
0x1000000, a data segment of 600K starting at address 0x80000000 and a stack segment of 64K
starting at address 0xf0000000 and growing upward (like in the PA-RISC of HP)?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 671 of 2244

6.272 fork top gateoverflow.in/38437

Q). Consider the following code:

Pid = fork1 ();

If (Pid !=0)

fork2 ();

fork3 ();

The number of total process created when above code is executed is________(excluding parent).

Correct answer : 5

Why 5 processes why not 4? plz someone explain..

4 Child processes & one Parent process. so 5 processes.

 0 votes -- vamsi2376 ( 1185 points)

6.273 Dirty bit Vs. Valid bit? top gateoverflow.in/36405

Please clarify the difference between the DIRTY BIT and the VALID BIT in virtual memory?

6.274 Number of child top gateoverflow.in/37450

Can Anyone Explain clearly

process

fork();

fork();

fork();

what are the number of childs?


Selected Answer

7.

First fork() will generate 1 children. Total number of process = 1 child (C1) + 1 parent (P) = 2.

Second fork() will generate 1 more process in C1 (C2) and one more process in P (C3), Total number of child processes at

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 672 of 2244

this stage = 3.

Similarly, 4 more child processes will be generated after calling third fork().

So, overall 8 processes will be there, 1 parent and 7 children. For more information, you can refer to the link provided to
you in response to your another similar question .

 0 votes -- Gaurav Sharma ( 1383 points)

6.275 Threads top gateoverflow.in/35422

Q12). Consider the following statments.

S1 : A thread running in critical section may get context switched .

S2 : Hardware access to devices is usually unavailable in user mode.

S3 : Modification to page tables are only possible in kernel mode,

Which of the above statement are correct?

a). S1, S2

b). S2, S3

c). S1, S3

d). S1, S2, S3

Is the statement S1 correct?? ans given is D but according to me it should be B

6.276 Process concept top gateoverflow.in/35423

How to approach for this type of question

Since processes start at 0 any processes that have been in the system that is it is either running or waiting have higher priority. Therefore, new processes go
to the back of the queue. When a process runs its priority keeps increasing at the rate of beta which is more of an increase than for the processes in the
ready queue. Therefore, every time the process's timer runs out, it goes to the front of the ready queue and gets dispatched again which is equivalent of
FCFS.

 0 votes -- Abhishek Kumar Singh ( 11 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 673 of 2244

6.277 OS top gateoverflow.in/34681

Consider a 32 bit virtual address is used for paging with page size 1024 B.Two level paging is implemented with equal
number of entries in every page table of the system. If page table entry size is 2 B , the maximum size of main memory
supported by the above system _______________

As the page offset is 10 bits and page table entry is 2 bytes so not considering dirty , invalid bits , the total amount of
main memory supported is 10+2*8 = 26 bits.

 0 votes -- Vikram Bhat ( 587 points)

6.278 SSTF top gateoverflow.in/34663

consider disk with 500 tracks is currently on track no 60...

FInd total head movements to satisfy request using SSTF

Request:170,37,98,122,53,14,39,28


Selected Answer

Sort the list :

14 28 37 39 53 Head at 60 98 122 170

The path followed is 60 - > 53 -> 39 -> 37 -> 28 -> 14 -> 98 -> 122 -> 170 .

The movements are : 7 + 14 + 2 + 9 + 14 + 84 + 24 + 48 = 202 movements.

 3 votes -- Riya Roy ( 4767 points)

6.279 In a 32-bit machine we subdivide the virtual address into 4 pieces as


follows: top gateoverflow.in/34452

In a 32-bit machine we subdivide the virtual address into 4 pieces as follows:


8-bit 4-bit 8-bit 12-bit

We use a 3-level page table, such that the first 8 bits are for the first level and so on. Physical addresses are44 bits and
there are 4 protection bits per page. Answer the following questions

1. How much memory is consumed by the page table and wasted by internal fragmentation for a process that has 64K of
memory starting at address 0?
2. How much memory is consumed by the page table and wasted by internal fragmentation for a processthat has a code
segment of 48K starting at address 0x1000000, a data segment of 600K starting at address 0x80000000 and a stack
segment of 64K starting at address 0xf0000000 and growing upward (towards higher addresses)?

6.280 the size of page table of process is: top gateoverflow.in/34454

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 674 of 2244

6.281 selective repeat sliding window protocol top gateoverflow.in/34458

Consider a selective repeat sliding window protocol that uses frame size of 2 kb. The capacity of the link is 2 Mbps and whose
one-way latency is of 100 msec. To achieve a link utilization of 50%. What is the minimum number of bits required to
represent the sequence number field is__________.


Selected Answer

1
2 ×106
Time for ACK to reach back for a frame = TTframe + PD + PD + TTack = (2 × 106 × + 100 + 100 + 0)ms = 201ms.

Amount of data that could be transferred in 201ms = 201 × 10 −3 × 2Mbps = 402kb = 201packets.

201

So, for at least 50% utilization the number of frames to be sent =   2


= 101 which requires 7 bits to represent.

Now, the window size in selective repeat protocol is half the sequence number space ( given in any text). So, we need
one more bit for sequence number field making it at least 8.

 1 votes -- Arjun Suresh ( 124125 points)

6.282 How to calculate Transfer Time ? top gateoverflow.in/36600

Q1)

Given a question with z Byte track size x Byte sector size and R rpm

IO time = seektime + latency time + transfer time .

How to calculate the last part ? transfer time ?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 675 of 2244

Q2 )
if no method to calculate sector size , then how do I calculate transfer time ? Given D Data Transfer Rate

Q3 )
if no method to calculate sector size , then how do I calculate transfer time ? NO Data Transfer Rate rate also given

operating-system

6.283 UGC NET December 2014 top gateoverflow.in/26897

A specific editor has 200 K of program text, 15 K of initial stack, 50 K of initialized data, and 70 K of bootstrap code. If five
editors are started simultaneously, how much physical memory is needed if shared text is used ?
(A) 1135 K (B) 335 K
(C) 1065 K (D) 320 K

5 editor works simultaneously

Each editor must have separate code in each.

But they could share initial stack, initialized data and bootstrap code

So, total memory required 200*5+15+50+70=1135 K

 0 votes -- srestha ( 11585 points)

6.284 cpu scheduling top gateoverflow.in/16402

14. Consider three processes, all arriving at time zero, with total execution time of 10, 20 and 30 units, respectively. Each
process spends the first 20% of execution time doing I/O, the next 70% of time doing computation, and the last 10% of time
doing I/O again. The operating system uses a shortest remaining compute time first scheduling algorithm and schedules a
new process either when the running process get blocked on I/O or when the running process finishes its compute burst.
Assume that all I/O operations can be overlapped as much as possible. For what percentage of time does the CPU remain
idle?
(a) 0% (b) 10.6%
(c) 30.0% (d) 89.4%

input cmputation input


p0 2 7 1
p1 4 14 2
p2 6 21 3

grant chart

spooling is done here as it provide best overlapping . it is overlapping current job computation with other job input output

 0 votes -- Ravi Singh ( 7303 points)

6.285 os top gateoverflow.in/16134

How is this stmt is false-command

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 676 of 2244

Every thread has it's own heap and data structure

Every thread has its own Program counter,register set and stack pointers ....thread of process do share code and data
segment heap

hence given statement is false

 0 votes -- Pooja ( 22773 points)

6.286 Critical section problem top gateoverflow.in/16047

repeat

flag[i]=true;

turn =j;

while(flag[j] and turn=j ) do no op;

critical section;

flag[i]= false;

remainder section;

until false;

Above algorithm is the correct soln of the critical section problem which satisfies all the three codition-1.>mutual exclusion
2.>progress 3.>bounded waiting

my question is how this algorithm satisfies bounded waiting ??let say both the process pi and pj want to enter its critical
section then they will turn flag[i] and flag[j] to 1 then pi while change the value of turn to j and and pj to i but turn can
contain only one value so any one of the process will enter its cs let say it is pi.later the process pi on completion again want
to enter its cs then is it will be executed indefinetly and pj will never be executed if this phenomenon is repeated .so,please
tell me where i m wrong .

what u got wrong here is again when the p1 come after executing it will change the turn varaible to himself and then the
older process while condition will break so after one another will go in . so aftre every 1 step second is getting a change to
enter so .

 0 votes -- Ravi Singh ( 7303 points)

6.287 memory management. top gateoverflow.in/16414

tell me if im wrong

in oder to access a page first we look in TLB if present we in look in cache( if present no need to acces main memory) if not
we go directly and accses the page with out going to see page tabels if there is a page fault we service the page

if there is a entry in TLB then there will be no page fault

cache can be virtual or physical .If its virtual one then it is placed between processor and MMU ..Mapping is done using
virtual address..In case of physical cache is placed between MMU and memory that is address translation is done first to
find location of page.. so depending on organisation we have proceed to fin date

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 677 of 2244

for more reference u can refer

https://en.wikipedia.org/wiki/CPU_cache

 0 votes -- Pooja ( 22773 points)

6.288 what is the difference between a job, task and a process ? top gateoverflow.in/16658

I have already gone through the stack-overflow posts but still could not clear with this concept , so plz clarify it with some
examples rather than explaining its definition .

The word job was used in earlier days in the batch systems. where we just collectively said that there is a job the job may
or may not be of one process suppose u have 10 process requiring to print 1 page each . u just collectively gave printer
command and may say it as a printing job. similarly we can say computation job e.t.c. task may be a job no specific
definition or boundary exist between a task and a job . u may think a task as a sub part of a job like printing a page of
process 1 is a task.

process. program under execution . u are running nfs most wanted which is of 4 gb . u have ram of 1gb still u can run this
.

suppose u r just playing stage one of that game so only that stage will be under execution and currently will be in
memory. that is called a process. process is the part of a program under execution .

 0 votes -- Ravi Singh ( 7303 points)

6.289 why is it profitable to allow internal fragmentation in a multi-


programming with variable number of tasks technique ? top gateoverflow.in/16695

When the partition size is very small then why do we say that it is sometimes profitable to allow internal fragmentation in the
partition ?

if the size of each segment of memory is small nd it is smaller than most of the processes then internel fragmentation will
never occur but some of the processes will never be able to complete its executuion because not a single segment is
large enough for that process.

but if we segment the memory in larger block then also it is nt a good idea as some memory will be wasted that why MVT
(multiprogramming with variable no of tasks) model is used.

 0 votes -- Saurav Kumar Gupta ( 1455 points)

6.290 what is the actual meaning of new state of the process ? top gateoverflow.in/16661

when I play a media file then what is actually the new state of the job since in case of a program being compiled, (hence the
executable code is actually the new state of the job) ,we say that now the program is compiled hence it is now ready for
execution and hence it is right now a new job in new state
but when we actually execute the command a.out , then it is actually executed and we say that it enters ready state and
according to the
time shared policy of CPU , the program is executed but in case of a media file or any other software start up what is the
new state of a job ?

operating-system

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 678 of 2244

When you play a media file - you don't execute it. Instead you execute the "player" which is like a "a.out" executable.
Now, the media file is provided as an input file to the player and it does the playing. So, the player (which is usually
compiled and made as an executable) would be reading the input as a file similar to reading a binary file in a C code- each
byte or set of bytes have fixed meaning defined as per the media format and after interpreting that, it does the playing.

 0 votes -- Arjun Suresh ( 124125 points)

6.291 what is the searching technique used for selecting a job from ready
queue ? top gateoverflow.in/16660

If the ready queue is such that we have all the PCB's linked up together as a linked list then whenever the CPU needs to pick
up a process for execution then does it perform linear search on it , and if it does then it would be taking large time
since there a large no of processes executing simultaneously in the memory , so then which searching technique is generally
empolyed
to pick up a process from the linked list ?

operating-system

You had told "ready queue" in question.

A queue can be implemented using a linkedlist, but always allows constant time deletion- and this is used to pick up a
process for execution. There is no need to do a search here. Whatever criteria is needed to pick up a process can be used
to design the "priority" of the queue and it can be made a priority queue.

 0 votes -- Arjun Suresh ( 124125 points)

6.292 Consider the relation R(A,B,C,D) with dependencies AB -> C, ABC -> D
and AC ->>- B. top gateoverflow.in/15062


R is not in 3NF

R is in 3NF but not in BCNF

R is in BCNF but not in 4NF

R is in 4NF

How to approach this ques ?

databases

Its in Bcnf .
Candidate keys are AB and AC .

but not is 4nf AC->>B (multi valued dependency )

so bcnf but not 4nf.

 0 votes -- Pranay Datta ( 6113 points)

6.293 How is the transfer time calculated in a disk ? top gateoverflow.in/15051

Transfer time is the time taken to read the complete sector , so how does this formula comes ?

T= 1/( no of sectors per track ) * 60/ rpm

I am unable to get that how come no of sectors per track comes , since transfer time is the time taken to read one complete
sector and on a track many sectors are present , so how come it is taking into consideration all the sectors present on the

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 679 of 2244

track ?

Well u are assuming the definition of transfer time. Its definition may vary according to context of the question . sometime
they also include the seek time, rotational latency and the actual time need to transfer it will be given in the question.
basically transfer time is included till stated by question

transfer time = seek time + rotational latency + time to read data

there will always be data present to find the number of sector present on the disk. u have not specified any of the
question so i am unable to provide the exact solution.

u can easily calculate it . i will suggest not to learn anything like the complicated formula . keep thing simple there are hell
lot of concepts to remember . u post a question instead . then i may help u more.

 0 votes -- Ravi Singh ( 7303 points)

6.294 Turnaround time top gateoverflow.in/10799

5 batch jobs A through E arrive at a computer center at almost same time. They have estimated running times of A:10, B:6,
C:2, D:4 and E:8 minutes. Their priorities are A:3,B:5,C:2,D:1 and E:8 min. Their(externally determined) priorities are
A:3,B:5,C:2,D:1 and E:4 respectively with 5 being highest priority.Ignore context switch overhead.

Q- What will be the mean process turnaround time under R-R scheduling algorithm(assuming time slice of 1 min)?

a) 22 min b) 21 min c) 18 min d) none

Ans is option D none

ct of process A=30,B=22,C=9,D=18,E=27. And at =0 for all process .

tat = ct-at so tat of A=30,B=22,C=9,D=18,E=27

mean tat = 106/5= 21.2 MIN

 0 votes -- sonam vyas ( 6441 points)

6.295 Scheduling Algorithm top gateoverflow.in/10798


Selected Answer

Why complicate this one . first of all one tip. never panic seeing a question. whenever u see such a question the answer is
very easy just rewind the concept .

so here it is asking cpu efficincy . simply cpu efficency = usefull work done by cpu/ total time .

now there are n processes which will be running and after every process context switch willl occur.

total time=n*time qunatun(q)+ n*context switch time (s)=nq+ns .


what is the usefull work done by cpu . we know context switching the wastage time . the usefull time will be only nq.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 680 of 2244

because in that time cpu was doing usefull work .

A-

cpu efficiency =nq/nq+ns=q/q+s

b- now it is giving s=q. just replace s with q then it is q/q+q=q/2q=1/2


 3 votes -- Ravi Singh ( 7303 points)

cpu efficiency = useful time of cpu / total cpu time

given r is avg running time .

q is quantum time

now we have to calculate how many time processes are switched ,so no of switched = r/q

so total time in switching is s.*r/q

total cpu time is = avg running time + swiching overhead = r +r/q*s

and usefull time is only r .

so efficiency is r/(r(q+s)/q)= q/(q+s)

2) q=s so cpu efficiency = 1/2

 1 votes -- sonam vyas ( 6441 points)

6.296 process state top gateoverflow.in/10797

When parent process executes fork system call process moves into
a) created state
b)ready state
c)running state
d)zombie state

Parent process has already begun execution and hence can not be in created (new) state

Running state is the state of a process while running. But a process just forked can't start running until the child process is
created and its pid returned to it. Till then it'll be in READY state.

Zombie state is a state of a process when the process has terminated but it's id is still in the process table (for parent to
check its exit status)

 2 votes -- Bhagirathi Nayak ( 10239 points)

6.297 Round Robin scheduling algorithm top gateoverflow.in/10800

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 681 of 2244


Selected Answer

A. is true.

In N process round robin scheduling a process will be in running state after N context switch and (N-1) CPU burst. i.e. NC
+ (N-1)Q

B. True because preempted process id puts in queue which is FIFO. So W executes before P.

C. True.

Efficiency = useful time / total time

= Q/(Q+C)

 1 votes -- Digvijay Pandey ( 26245 points)

6.298 How the "caching disabled" bit in page table entry prevent caching of
I/O registers? top gateoverflow.in/11948

I mean, how is it possible? We cant access page table before looking into cache? I think I am missing some point.

Thanks in advance.


Selected Answer

I get it. Before moving a page into cache , its cache disabled bit is checked from page table entry. If it is 1, the page is not
moved into cache.

 1 votes -- lowOnATP ( 135 points)

6.299 how much memory is needed to store each user's access data? gateoverflow.in/15029

top

consider a system where each file is associated with a 16 bit number.for each file ,each user should have the read and write
capability.how much memory is needed to store each user's access data?

A) 16KB B) 32KB C) 64KB D) 128KB

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 682 of 2244

I think answer is A .

Question is that how much memory is needed to store each user's access data so its only the memory reqd for read/write
information which is asked. For 2^16 files, there are 4 different combinations of read(R) write(W). Read, write, no read,
no write.

So bits reqd for 1 file to store access info=2

Bits reqd for 2^16 files=(2^16)×2 bits=128Kb

Converting this bits into bytes we get 128Kb/(8bits/Byte)

=16KB

 0 votes -- admin ( 1411 points)

6.299 ISRO 2011 There are 3 processes in the ready queue.,when the
currently running process requests for I/O how many process switches
takes place? a.1 b.2 c.3 d.4 top gateoverflow.in/14617


Selected Answer

One.

The currently running process will be sent in blocked state and a process from ready queue will come in.

 1 votes -- CrimeMasterGoGo ( 2221 points)

According to me now , on learning and focussing the points of vivek the answer is one . one context switch takes.

saving one process context and then loading the another process context and then running it . its all in one context switch.

now if u can understand then i may define it in the way we have read till now.

in the grant chat how many context switch does we count if we switch one process and select another process. only one .
if this question is taking two context switch then we must have to take 2 context switch between p1 and p2 . one to push
it in the wait/ suspended . and second to put p1 in running state that is not happening . so answer is one.

thanks vivek for asking again and again.

 2 votes -- Ravi Singh ( 7303 points)

I THINK

2 process switches occur .

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 683 of 2244

 2 votes -- Pranay Datta ( 6113 points)

6.300 shd d y b????/ & when cn c??? top gateoverflow.in/12127

Consider a system with five processes P0 through P4 and three resource types R1, R2 and R3. Resource type R1 has 10
instances, R2 has 5 instances and R3 has 7 instances. Suppose that at time T0, the following snapshot of the system has
been taken : Allocation R1 R2 R3 P0 0 1 0 P1 2 0 0 P2 3 0 2 P3 2 1 1 P4 0 2 2 Max R1 R2 R3 7 5 3 3 2 2 9 0 2 2 2 2 4 3 3
Available R1 R2 R3 3 3 2 Assume that now the process P1 requests one additional instance of type R1 and two instances of
resource type R3. The state resulting after this allocation will be (A) Ready state (B) Safe state (C) Blocked state (D) Unsafe
state

option (b)

alocation max
process reaminig need (R1 available(R1
(R1 R2 need(R1
no R2 R3) R2 R3)
R3) R2 R3)
p0 010 753 743 332
p1 200 424 224
p2 302 902 600
P3 211 222 011
P4 022 433 411

initially need for process is 322 but process P1 requests one additional instance of type R1 and two instances of
resource type R3. with 332 we can satisfy p3 need therefore giving all its allocated resource back resulting 5 4 3 now
available resources. with 5 4 3 we can satisfy either p1 need or p4 need here we cant satisfy p0 or p2 need becauz
remaining need resouce are more than available resource so on ..... therefore there is safe state with safe sequence as P3,
P4, P1 , P2. P0

 0 votes -- kunal chalotra ( 3567 points)

6.301 How to calculate the capacity of disk pack in the below question ? top
gateoverflow.in/16736

A disk pack has 19 surfaces and storage area on each surface has an outer diameter of 33cm and inner diameter of 22cm .The maximum recording storage density
on any track is 200 bits/cm and minimum spacing between tracks is 0.25 mm , then how to calculate the capacity of disk pack ?

Disk capacity = total number of surfaces * no. of tracks per surface * amount of data per track

Total number of tracks per surface = (outer radius - inner radius)/ inter track gap = (33cm/2 - 22cm/2 )/0.25mm = 220

perimeter of inner track = 2 * pi * inner radius = 2 * (22/7 )*11 cm

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 684 of 2244

density = 200 bits/ cm

amount of data present in single track = perimeter * density = 13829 bits (approximately)

disk capacity= 19 * 220 * 13829 bits = 6.89 MB

 0 votes -- pramod ( 2071 points)

6.302 how many entries will be there in the page table if it is inverted? top
gateoverflow.in/16972

In a 64 bit machine,with 2GB RAM and 8KB page size,how many entries will be there in the page table if it is inverted?

a)218

b)220

c)233

d)251


Selected Answer

The answer is 218 (option a) . The number of entries in page table of an inverted page table is equal to number of frames
in the main memory. which will be 2 ∗ 230 /23 ∗ 210 = 218

 1 votes -- Ravi Singh ( 7303 points)

6.303 What will be the total page faults in the following ques ? top gateoverflow.in/19975

The given ans is 9. I don't get it .


Selected Answer

answer is 9 just check once again. initally 3 page fault then on the sequence d,a,b,e,c,d = 9 page faults

 0 votes -- Ravi Singh ( 7303 points)

6.304 what is the cpu utilization? top gateoverflow.in/18069

In a system having a single processor,a new process arrives at the rate of six processes per minute and each such process
requires seven seconds of service time .what is the cpu utilization?

a)70%

b)30%

c)60%

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 685 of 2244

d)64%


Selected Answer

in 1 min 6 processes is coming and each takes 7 sec .

so in 60 sec total 42 sec time are busy .

so utilization is 42/60 *100 = 70% .

 0 votes -- Pranay Datta ( 6113 points)

6.305 The total time to prepare a disk drive mechanism for a block of data to
be read from it is top gateoverflow.in/17263

The total time to prepare a disk drive mechanism for a block of data to be read from it is

a)seek time

b)latency

c)latency plus seek time

d)transmission time


Selected Answer

option (c) .The total time to prepare a disk drive mechanism for a block of data to be read from it
is latency plus seek time.

 0 votes -- Vinay Yadav ( 1739 points)

6.306 Is it a good idea to consider the status of dirty bit in Page


Replacements? top gateoverflow.in/17657

In a LRU page replacement policy we just replace the least recently used page, without looking at its dirty bit.

However If we also look at the dirty bit of page table entries along with the LRU bits, and replace only the pages that has not
been modified(i.e. replace only pages that has dirty bit = 0) unless all the table entries have been modified ( I.e. all the
entries in the page table have their dirty bit = 1) then we can postpone the process of write back for some time.

That is we are going to apply LRU only on the pages that have not been modified untill all the pages gets modified.

Whether it will be advantageous to do so?

What could be the disadvantages of this scheme?​

co&architecture

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 686 of 2244

Selected Answer

I suppose it will be advantageous. But having a separate list of modified pages would be tricky as any page can be
modified at any time and that should be moved to the modified list. Also, some frames might be just read from but
frequently and due to this policy such pages might get replaced by less actively accessed write pages. So, depends on the
accesses this can benefit or not but I guess it is a good technique. There should be such works already done for page
replacements.

 1 votes -- Arjun Suresh ( 124125 points)

6.307 cpu scheduling top gateoverflow.in/18026

Consider a system running 10 I/O bound task and one CPU bound task.Assume that I/O bound task issue I/O operation once
every millisecond of CPU computing and each I/O operation takes 10 msec to complete.Also assume that context switching
overhead is 0.1 ms and all process are long running tasks.What is CPU utilization for round robin scheduler when

1)time quantum is 1 ms

2)time quantum is 10 ms

all task are long running task so we cannot wait to complete as no limit is given so i take one cycle in consideration.

the efficency will be same in one cycle or 100 cycles.

one cycle will be from the execution of P0 till it comes back again.

now starting with p0 context switch is taken by this symbol ]

p0 ] p1 ] p2 ]..........p10 ] total ( 11 process)

thsi will be one cycle .. not to forget the last context switch as we have not considered a context switch on before p0. so
we have to consider the last one .

now p1 will execute for 1 unit and then will go for i/o and will come back after 10 ms which is 11 ms.

well as no cpu time will be wasted as it will always have a job to execute and i/o will be overlapped like the normal day
practice it will work like normal and only wastage will be context switch time which will be 11 *0.1=1.1 ms

efficiency = (11-1.1)/11*100= 90%. well the process which is cpu bound will not have to go to i/o so he will just exit the
queue and again come in line. it will not have any effect here .

2 case.

now time quantum is 10 ms

so we know after every 1ms process goes to i/o. but a process will only be preempted when time quantum expires .

so now the cycle time will be 110 as every process is running for 10 ms. and all are long tasks not completing in one or 2
cycles

so the context switch will be the same and the wastage will also be same 1.1.

but in the time quantum every process will only do 1 ms of usefull time and all 9 ms will be wasted . except the process
which is cpu bound . he will work the whole time. so usefull time will be 1*10+10

20 unit will be only the usefull work .minus the context switch overhead = 20-1.1

18.9 is the actual useful work out of 110. so efficiency = 18.9/110*100= 17.18 %

 0 votes -- Ravi Singh ( 7303 points)

6.308 When a process is rolled back as a result of deadlock the difficulty


which arises is top gateoverflow.in/18583

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 687 of 2244

When a process is rolled back as a result of deadlock the difficulty which arises is

a)Starvation

b)System throughput

c)Low device utilization

d)Cycle stealing

We can see the example of bridge crossing, in which bridge has only one lane.

Deadlock will occur when 2 cars of opposing direction meet.

one or more cars may have to backed up if deadlock occurs.

Then starvation(indefinite waiting) is possible.

 1 votes -- ayushigupta ( 89 points)

6.309 Find out the min and max no. of page faults. top gateoverflow.in/18459

A process having access to f frames(initially all empty) makes m memory accesses to p


distinct pages.What are the max and min. no. of page faults that will occur?


Selected Answer

i think the max will be m . for every memory access if there is a page fault then it will be m. and minimum will be p as i
have to make memory access to p distinct pages.

 1 votes -- Ravi Singh ( 7303 points)

6.310 How is a process picked up from a ready queue ? top gateoverflow.in/18281

We generally say that the scheduler picks a process from the ready queue and then brings it to CPU for execution but in
general ready queue is actually a linked list of PCB's and a process is actually a different section of memory so then how
come we are able to pick up a process for execution from a queue .

Also a process has a set of executable instructions so then when CPU fetches an instruction from it , so then is it that the size
of the process in the memory changes because I saw the task manager and saw that the memory occupied by the processes
was changing nearly increasing and decreasing as the process as allocated to CPU , so I couldn't get the logic for this that
how come the memory occupied by the process changing when CPU is allocated to it ?

operating-system


Selected Answer

Ready queue is a linked list of PCBs- so the scheduler gets a PCB. Now, PCB will have all information about a process.

https://en.wikipedia.org/wiki/Process_control_block

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 688 of 2244

As part of this data will be the code location of the process. When a process is created, it is assigned memory for the code,
data, stack and heap section. Now, the CPU will start executing instructions from the code section from the PC pointed
value.

How process "memory usage" changes during execution? Because the process is using dynamic memory allocation. Write
a C code with no dynamic memory allocation- that is no function calls and simply running a nested loop a million or more
times. There won't be a change in memory usage. Memory usage changes during function calls- dynamic memory
allocation on stack (in languages like C) and on dynamic memory allocation on heap.

 0 votes -- Arjun Suresh ( 124125 points)

6.311 Dynamic address translation top gateoverflow.in/17262

Dynamic address translation

a)is part of the operating system paging algorithm

b)is useless when swapping is used

c)is the hardware necessary to implement paging

d)storage pages at a specific location on disk

Paging is a part of operating system. operating system should implement paging.

Now if here paging algorithm means page replacement algorithm then option a is incorrect.

for dynamic address translation we need MMU(Memory Management Unit) which itself is a hardware. so option c is correct.

 0 votes -- Suvam Chatterjee ( 185 points)

6.312 Feedback queues top gateoverflow.in/17261

Feedback queues

a)are very simple to implement

b)dispatch tasks according to execution characteristics

c)are used to favour real-time tasks

d)require manual intervention to implement properly

I think ans is B)dispatch tasks according to execution characteristics .

 0 votes -- Pranay Datta ( 6113 points)

6.313 which of the following is correct,please explain every point top gateoverflow.in/17095

A multiuser multi-programming O.S can't be implemented on hardware that doesn't support,

. address translation

.DMA for disk transfer

.at least two modes of cpu execution(privileged and non-priviliged)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 689 of 2244

.demand paging

Ans : <c>.at least two modes of cpu execution(privileged and non-priviliged)

Explaination :

a) We can make a system multi user and multi-programming even by not using Virtual memory. We can use static
partitions in Main memory to do our job. It's just that the degree of multi-programming will be less. But it is possible.

b) DMA has nothing to do with multi programming if we consider only processes to be CPU bound.

d) demand paging, Reason same as option a. Without VM we can make a system to ne multi programmed.

Why option c?

Because in case of multiuser system, one user will be root user for sure which will have access to privilaged instructions.

So to switch from normal user to root user you need hardware bit which is switched between two modes of uses. Also for
a system to be multi programming, we need to swap in and out the processes from memory which need hardware access
which can be only done in system mode.

 0 votes -- CrimeMasterGoGo ( 2221 points)

6.314 how many possible different schedules are there? top gateoverflow.in/16985

A CPU scheduling algorithm determines an order for the execution of its scheduled processes.Given n processes to be
scheduled on one processor , how many possible different schedules are there?

a)n

b)n2

c)n!

d)2n

answer is n! as n process have the choice to run at any place 1,2,3,4,5...n places .

 0 votes -- Ravi Singh ( 7303 points)

6.315 which of the following are the likely cause of thrashing? top gateoverflow.in/16983

which of the following are the likely cause of thrashing?

a)page size was very small

b)There are too many users connected to the system

c)Least recently used policy is used for page replacement

d)FIFO is used for page replacement

ANSWER: A

if page size is very small , locality of reference will be reduced. which increases page faults.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 690 of 2244

reference:

http://www.nptel.ac.in/courses/106108101/4

 0 votes -- pramod ( 2071 points)

6.316 which of the following is correct........... top gateoverflow.in/17100

Identify the schedular which involves only in the decision for selection of partially serviced jobs?

.S.T.S

.L.T.S

.M.T.S

.NONE

C, Mid term Schedular.

It swaps out partially serviced jobs out of running to waiting queue.

 0 votes -- CrimeMasterGoGo ( 2221 points)

6.317 cpu utilization? top gateoverflow.in/17229

Assume that there are 2 independent processes which are in memory and each process spends a fraction 2 of its time
waiting for I/O to complete. Each process requires 4 minutes of CPU time. The utilization of CPU in percentage is _____.

operating-system

I think ans is 75%.

as 1/2 of the time is for IO for both process . then 0.5*0.5 = 0.25 is for IO

and rest Cpu

so Utilization 0.75 = 75%

 1 votes -- Pranay Datta ( 6113 points)

6.318 Thrashing top gateoverflow.in/17260

Thrashing

a)always occurs on large computers

b)is a natural consequence of virtual memory systems

c)can always be avoided by swapping

d)can be caused by poor paging algorithms

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 691 of 2244

it is option d. thrashing can be caused by poor paging algorithm.

 2 votes -- Sudipta Paul ( 283 points)

6.319 in which of the following four necessary conditions for deadlock


processes claim exclusive control of the resources top gateoverflow.in/17254

in which of the following four necessary conditions for deadlock processes claim exclusive control of the resources they
require?

a)no preemption

b)mutual exclusion

c)circular wait

d)hold and wait

b. Mutual Exclusion

 1 votes -- Amar Vashishth ( 17865 points)

6.320 CPU scheduling algorithm top gateoverflow.in/10796

in which of following scheduling algorithm. any short jobs arriving after long jobs will have a longer waiting time?
A) Round Robin
B)SJF
C)FCFS
D)SRTF


Selected Answer

That is called Convoy Effect.

FCFS Scheduling.

 2 votes -- Digvijay Pandey ( 26245 points)

6.320 in which conditions,you will not allow a page to cached? top gateoverflow.in/10430

operating-system

When that page is shared with another process running on a different core of the machine. For example, in Intel 3rd
generation core architecture (Ivybridge) L1 and L2 cores are private for a core and L3 is shared. So, a shared page must
not go above L3 cache or otherwise explicit coherence mechanism must be done by the programmer.

 0 votes -- Arjun Suresh ( 124125 points)

6.321 Semaphores top gateoverflow.in/4819

Code of n processes is attached

Atmost how many process may execute in critical section at a time?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 692 of 2244

Ans is n....Please explain how..?

If initially semaphore is 1, up to 3 processes can be executing in critical section at a time as each process from 0 to P n-
1 decrements the counter on enter and increments on exit while P n increments it twice when it leaves without
decrementing.

If initial value of semaphore is 0, then up to 2 processes can enter the critical section at a time.

Similarly, if the initial value of semaphore is n-2, then up to n processes can enter the critical section at a time.

 1 votes -- Arjun Suresh ( 124125 points)

6.322 CPU Scheduling top gateoverflow.in/4810

The sequence …………… is an optimal non-preemptive scheduling sequence for the following jobs which leaves the CPU idle for ………………… unit(s) of time.
----------------------------
Job Arrival_Time Burst_Time
----------------------------
1 0.0 9
2 0.6 5
3 1.0 1
----------------------------
(a) {3,2,1),1 (b) (2,1,3},0
(c) {3,2,1),0 (d) {1,2,3},5

Ans: option (a)

please explain why answer is a)....

Assuming optimal is with respect to the total waiting time (a) is correct.

Total waiting times are

(a) 0 + 1.4 + 7 = 8.4, idle time = 1

(b) 0 + 5.6 + 14.6 = 20.1, idle time = 0.6

(c) 0 + 1.4 + 7 = 8.4, idle time = 1

(d) 0 + 9 + 14 = 23, idle time = 0

http://www.cs.uic.edu/~jbell/CourseNotes/OperatingSystems/5_CPU_Scheduling.html

 0 votes -- Arjun Suresh ( 124125 points)

6.323 please explain.. top gateoverflow.in/4734

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 693 of 2244

C needs to be checked only during a cache miss as then only there will be a main memory reference and we have to
decide whether to cache that particular page or not.

All others are not always required. If we are not caching a page, then there is no need to do virtual address to physical
address translation while looking in cache.

Also, a dirty page can be cached. Dirty bit in a page means, the page is modified and must be written back to secondary
memory during replacement. This has nothing to do with the page being cached or not.

http://6004.mit.edu/Fall13/tutprobs/vm.html

 0 votes -- Arjun Suresh ( 124125 points)

6.324 Threads top gateoverflow.in/4836

Which of the following state is private/specific to a thread?

a) Program Counter

b) Stack Pointer

c) Execution Stack

d) I/O State(File memory)

Options

A) a),b),c) only

B) only a) and b)

c) only c)

d) All

Ans is b).. Is execution stack shared among the threads as only code,data and files are shared among the threads

If execution stack is shared, suppose one thread calls a function, (that function will push the activation record on to
stack), then the current activation record in the other threads gets corrupted.

 0 votes -- Arjun Suresh ( 124125 points)

6.325 Synchronization top gateoverflow.in/4867

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 694 of 2244

Ans is B) ...but after z...y should not printed since b would become 0 then....so II should not be a possible output...

Plz explain......

When b becomes 1, the while loop in P2 breaks. Now the next instruction is printf("y"). But before this instruction gets
executed, the instructions
b=0;
printf("z");
CAN be executed by P1. (There is a possibility for that). So, B is the correct answer.

 2 votes -- Arjun Suresh ( 124125 points)

6.325 A certain moving arm disk storage, with one head, has the following
specifications. Number of tracks/recording surface = 200 Disk rotation
speed = 2400 rpm Track storage capacity = 62,500 bits The average latency
of this device is P msec and the data transfer rate is Q bits/sec. Write the
value of P and Q. top gateoverflow.in/5196


Disk rotation speed= 2400 rpm

Track storage capacity = 62,500

Average Latency = p

Data Transfer rate = q

Data transfer rate is nothing but how much data can be read in one second

WE have 2400 rotation in 1 minute

2400 rotation = 60 *10 3 ms

therefore 1 rotation = x ms, where,

x= 60 *10 3 / 2400

therefore we get x=25 ms

Hence 25 mill sec is required to read one complete track (1 rotation )

In 25 m sec, we read track capacity = 62,500 bits

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 695 of 2244

therefore in 1 sec we can read (62,500 bits )*1000/25 = 2.5 Mbits

i.e., Data transfer rate, Q = 2.5 Mbits/ sec

Now come The average Latency

Average latency is nothing but 0.5 * rotation delay

We have 2400 rotations in 1 minute

2400 rotation = 60 *10 3 ms

therefore 1 rotation = x ms, where,

x= 60 *10 3 / 2400

therefore we get x = 25 ms

And Rotation delay = (0.5)*25= 12.5 ms

Hence P =12.5 ms

and Q= 2.5 M bits / s

 3 votes -- spriti1991 ( 1127 points)

6.326 Deadlock top gateoverflow.in/4936

Consider a system consisting of n resources of same type being shared by 4 processes, 2 of which need at most 2 resources
each and other need at most 3 resources each.The min value of n so that the system is deadlock free is ___________?


Selected Answer

Total resources required = 2 * 2 + 2 * 3 = 10.

Now, with n = 10, there won't be a deadlock.

Now, assume the worst case. All processes are allotted all resources except 1. So, 2*1 + 2 * 2 = 6. Here, deadlock is
possible with n = 6.

When n = 7, at least one process must finish and we get 7 resources for 3 processes which require maximum 8 resources
between them. So, again at least one of them will finish and there won't be a deadlock.

So, n = 6 + 1 = 7 is the answer.

 3 votes -- Arjun Suresh ( 124125 points)

6.327 Critical Section top gateoverflow.in/4894

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 696 of 2244

Please explain why bounded waiting is not satisfied...?

Ans is (D)

here mutual exclusion and progress both are guranteed.

bounded waiting is also guranteed. As per Operating System Concepts by Galvin, "There exists a bound on the number
of times that other processes are allowed to enter their critical sections after a process has made a request to enter its
critical section and before that request is granted."

in option A they are talking about m/e only so A is wrong.

in option B they said m/e and b/w are guranteed only. means they indirectly saying progress is not guranteed. so B is
wrong.

in C they said progress is satisfied only. so C also wrong.

in D they said m/e and progress guranteed. Here they didnt mention anything negative about b/w so we can not think b/w
is not satisfying. therefore D is correct.

I hope you got my point.

 1 votes -- jayendra ( 5797 points)

6.328 Address Translation top gateoverflow.in/4694

A cpu generates 32- bit virtual address .The page size is 4kb .The processor has a tlb which can hold 128 entries and is 4-
way set associative .The minimum size of tlb tag is ???


Selected Answer

Answer is 11- where is that found?

Your approach is correct.

128 entries and each set has 4 entries => 32 sets

5 set bits are required. 12 offset bits for indexing a page

Now, 32-5-12 = 15 bits are there and we need all of them to be used as tag bits as otherwise we cannot identify a page
from the tag. (215 possible page can come to a set and minimum 15 bits are needed to identify the page).

 2 votes -- Arjun Suresh ( 124125 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 697 of 2244

6.329 storage space for page table top gateoverflow.in/4693

Suppose a process has only hte following pages in its virtual space : 2 contigous pages frm address 0x00000000 , 2
contiguous [ages frm 0x00400000, a stack page starting at virtual address 0xffff0000.The amount of memory for storing the
page tables is ???

8kb

12kb

16kb

20kb

16 KB, see second question here:

http://gateoverflow.in/788/gate2003_78-79?show=788#q788

 0 votes -- Arjun Suresh ( 124125 points)

6.330 Critical Section Problem top gateoverflow.in/766

Please explain with a situation where bounded waiting is satisfied but progress is not.

A livelock would be an example. Here, all the processes might get a chance to execute thus making the waiting bounded
but due to live lock no one will be able to eventually complete resulting in no progress.

 1 votes -- Arjun Suresh ( 124125 points)

6.331 Consider two processors P1 and P2 executing the same instruction set.
top gateoverflow.in/367

Consider two processors P1 and P2 executing the same instruction set. Assume that under identical conditions, for the same
input, a program running on P2 takes 25% less time but incurs 20% more CPI (clock cycles per instruction) as compared to
the program running on P1. If the clock frequency of P1 is 1GHz, then the clock frequency of P2 (in GHz) is _________.

please do explain also

operating-system normal

Total execution time, E = No. of instructions executed( #I) × CPI / clock frequency (F)
EP2 = 0.75 × EP1

 0.75 × #IP1 × CPIP1 /FP1 = #IP2 × CPIP2 /FP2

 0.75 × #IP1 × CPIP1 /FP1 = #IP1 × 1.2 × CPIP1 /FP2

 0.75 × FP1 = 1.2/FP2

 FP2 = 1.2/(0.75 × FP1 )

 FP2 = 1.2/(0.75 × 1) = 1.6 GHz

 2 votes -- gatecse ( 9515 points)

6.332 How to check for starvation top gateoverflow.in/364

Given two processes how do I check for starvation condition?Given below is a program which when executed spawns two
concurrent processes:

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 698 of 2244

Semaphore X:= 0;

/* Process now forks into concurrent processes P1 & P2 */

P1 : repeat forever V(X); Compute; P(X);

P2 : repeat forever P(X); Compute; V(X);

Consider the following statements about processes P1 and P2:

I). It is possible for process P1 to starve.

II). It is possible for process P2 to starve. Which of the following holds?

(A) Both I and II are true

(B) I is true but II is false

(C) II is true but I is false

(D) Both I and II are false

operating-system


Selected Answer

Check : What is Starvation?


Here P2 can go in infinite waiting while process P1 executes infinitely long.

Also, it can be the case that the Process P1 starves for ∞ long time on the semaphore S, after it has successfully executed
its critical section once, while P2 executes infinitely long.

Both P1 and P2 can starve for ∞ long period of time.

answer = option A

 4 votes -- Amar Vashishth ( 17865 points)

A is the answer.

Case 1:Here P1 is performing signal operation so it is first one to start...Now it may happen that after executing CS it
makes X=0 again tries to enter CS my making X=1 so it is possible that P2 can starve(just a possibility)

Case 2:If P1 executes signal operation and its execution is suspended temporarily, P2 executes wait and enter CS and
then execute signal operation making X=1 now P2 can enter critical section by executing wait operation..this may happen
for infinite amount of time..so in this P1 may starve

 2 votes -- Pooja ( 22773 points)

6.333 Which of the following are equal things when there is only one CPU in
a system. top gateoverflow.in/2335

Which of the following are equal things when there is only one CPU in a system.

A) Multiprogramming and Multitasking

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 699 of 2244

B) Multiprocessing and Multiprogramming

C) Multitasking and Multiprocessing

D) None of these

operating-system

D. None of these

These are three different concepts, they cannot be equal.



In Multi-Programming a particular program is THE BOSS. Being boss means that the process is given the highest priority to occupy the
CPU. It is the only one which claims the CPU until its completed. Although, some other process is granted the CPU for some time while the
BOSS process works with I/O devices but not the CPU. This is done to get maximum CPU utilization. When the boss process returns after
completing its I/O the running process is preempted and the boss process is again granted the CPU.

In Multi-Tasking there is no boss process, all processes are treated equal and are granted the CPU in a Round Robin fashion. This makes
multi-tasking totally different from multi-programming.

Multi-Processing means the system works with multiple CPUs.

In a sense, When we talk multi-processing we meant hardware only. But, when talking multi-programming or multi-tasking we mean
software. This makes the def. of multi-processing totally different from multi-programming or multi-tasking. They cannot be equated.

On a multi-processing system we may have implemented multi-programming or multi-tasking its a choice. e.g. a single process at a time is
using multiple CPUs to get work done faster; or single process at time is given multiple CPUs for some time then some other process is
given all CPUs at once(in a round robin fashion).

 1 votes -- Amar Vashishth ( 17865 points)

In short:

Multiprogramming is number of processes that can be in ready queue at any given instance of time. Here they can be any
number, depending on the capacity of ready queue.

Multiprocessing is the number of tasks going on simultaneously in different cores of cpu. Here number of cpu is one so at
a time one task will be going on. Notice that I am using the term task rather than process or thread because task can be
generalised to both without creating a confusion about its size. Linux uses the concept of tasks only, no processes or
threads.

Multitasking is the number of tasks CPU seems to execute simultaneously. That means we can run web browser and songs
simultaneously. They seem to run at same time but truth is at the backend, they are given CPU in time shared manner.
Its just an illusion that they are running together. In this question's case, number of tasks can be any. Browser, songs,
etc.

So answer is D.

 1 votes -- CrimeMasterGoGo ( 2221 points)

Answer should be None of these.

Multiprocessing- Happens when hardware can provide multiple processing resource- like multiple CPUs, cores etc. It is a
hardware feature.

Multi-programming- Happens, when the system has the capability to run multiple programs at the same time- when one
waits for say IO, context switch happens and next one is executed. It is to be supported by software.

Muti-tasking- Similar to multi-programming but here unit is a task which is a smaller unit than a process- a thread of
execution can be a task.

So, in a single CPU system we can say multi-processing is absent (assuming no multi-cores). Also, multi-programming and
multi-tasking don't make a difference if there is a single CPU or multiple. So, answer should be D- none of these.

R e f : http://www.8bitavenue.com/2012/10/difference-between-multiprogramming-multitasking-multithreading-and-
multiprocessing/

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 700 of 2244

 1 votes -- Arjun Suresh ( 124125 points)

6.334 the top gateoverflow.in/2961

on a system using paging and segmentation references to swapped in locations accessible through an entry in

associative table take 200ns if the main memory page table must be used ,the reference takes 400ns.References that
results in page faults require 10ms .if the page to be replaced has been modified,5ms otherwise.if the page faults rate is 5%
the associative table hit rate is 65% and 40% of replaced pages are dirty,what is the effective access time?Assume the
system is running only a single process and cpu is idle during swaps.

Average Access time = 65% * 200 + 35% * 400 + 5% * (1- 40%) * 5,000,000 + 5% * 40% * 10,000,000
= 130 + 140 + 150, 000 + 125, 000

= 275, 270 ns.

Is something wrong with the given page fault rate?

 0 votes -- Arjun Suresh ( 124125 points)

6.335 CPU Scheduling top gateoverflow.in/3890

Q1)
An OS contains 10 identical processes that were initiated at the same time. Each process contains 15 identical requests, and each request consumes 20msec of
CPU time. A request is followed by an I/O operation that consumes 10 msec. The system consumes 2 msec in CPU scheduling. For time quantum of 20 msec , the
response times of the first request of the last process is
A) 26 msec B) 220 msec C) 200 msec D) none

Ans : A

Q 2)
In the above problem , the scheduler length is
A) 3300 msec B) 3600 msec C) 6300 msec D) 6600 msec

Ans : A

Please explain.


Selected Answer

Take the last process -> it will get its first request processed after 10 schedules. Because after the first time quantum, the
first process does an I/O operation (as it would have finished its request which also takes 20ms and hence CPU given to
next process) and hence the second process gets its chance. Thus, after 9 time quantum, the final process gets its request
served (assuming a previously given process is never given CPU time again until all other processes in wait are given). So,
this means we need 10 schedules (including one at the beginning) and given in question that each scheduling takes 2ms.
So, response time for the first request of the last process

= 9 × 20ms + 10 × 2

= 180 + 20 = 200ms.

(2) The scheduling goes like this:

P1 P2 P3 ... P10 P1 P2 P3 ... P10 .... P10 P1 P2 ... P10 (P1-P10 repeated 15 times)

After every time quantum and at the beginning we need 2ms for scheduling the next process. So, total scheduling length

= (20ms + 2ms) × 10 × 15

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 701 of 2244

= 220 × 15 = 3300ms

 1 votes -- gatecse ( 9515 points)

6.335 what is the main difference between translation look aside buffer and
translation look ahead buffer . top gateoverflow.in/3304

operating-system

The below link says TLB- Translation Lookaside Buffer is used for address translation while Translation Look-ahead buffer
is used by disks to put pages in the disk cache ahead of its access (probably based on spatial locality), and that makes
sense. I have seen TLB being referred as Translation Look-ahead Buffer at some places, but that doesn't make any sense-
as looking is not done ahead here.

http://cs.stackexchange.com/questions/9612/look-ahead-buffer-vs-translation-look-aside-buffer

 0 votes -- Arjun Suresh ( 124125 points)

6.336 Deadlock top gateoverflow.in/5352

P0 is holding 3, P1 is holding 2 and P2 is holding 1. So, total number of tapes in use = 6.

Number of free tapes = 7 - 6 = 1

Now, the remaining needs of P0, P1 and P2 are 2, 2 and 2. With just 1 free tape, system is not in a safe state. Now,
deadlock may or may not occur in a non-safe state. If some process release a resource, then deadlock can be avoided.

 1 votes -- Arjun Suresh ( 124125 points)

6.336 Can anyone explain, how does Livelock occur in case of priority
inversion? top gateoverflow.in/5475


Selected Answer

Consider two processes A and B both needing an instance of X. Assume priority of A is greater than B. Initially X will be
assigned to A due to higher priority of A. But if before X completes execution, priority of B becomes greater than A, A can
be put on hold and B can start execution. Now, during execution of B, if priority of A becomes greater, the same cycle
continues- two processes trying to make progress but not able to do- livelock.
ref@ https://en.wikipedia.org/wiki/Deadlock#Livelock

 0 votes -- Arjun Suresh ( 124125 points)

6.337 where does page table resides top gateoverflow.in/9184

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 702 of 2244

where does page table resides in main memory.. os space or user space.. and i hope there is a page table in main memory
for every process.. am i right... please clarify me.thank you.. .

Page table is stored in main memory at the time of process creation and its base address is stored in process control block.
Page table is created for Each Process separately unless inverted Paging is used In which there is single Page table for all
the Processes.

 4 votes -- Anurag Semwal ( 4775 points)

6.338 which one of the following process in UNIX operating system does not
have a parent process ? (a) sh (b) dev (c) login (d) kernel top gateoverflow.in/8938

which one of the following process in UNIX operating system does not have a parent process ?

(a) sh
(b) dev
(c) login
(d) kernel

operating-system

sh does have a parent process and its parent is whoever has called sh.

arjun@armi:~$ ps -f 3985
UID PID PPID C STIME TTY STAT TIME CMD
arjun 3985 3887 0 13:17 pts/13 S+ 0:00 sh

login also has parent and its parent is the init process.

arjun@armi:~$ ps -f 498
UID PID PPID C STIME TTY STAT TIME CMD
root 498 1 0 13:11 ? Ss 0:00 /lib/systemd/systemd-logind

same for dev

arjun@armi:~$ ps -f 419
UID PID PPID C STIME TTY STAT TIME CMD
root 419 1 0 13:11 ? Ss 0:00 /lib/systemd/systemd-udevd --daemon

So, the answer is "kernel" which has process id 0 and is the parent of the "init" process.

http://unix.stackexchange.com/questions/83322/which-process-has-pid-0

 5 votes -- Arjun Suresh ( 124125 points)

6.338 consider a machine with 64Mbyte physical memory and a 32 bit virtual
address. if the page size is 4 kByte, what is the approximate size of the
page table? a)16 Mbyte b)8 Mbyte c) 2 Mbyte d) 24 Mbyte top gateoverflow.in/7465


Selected Answer

Virtual Address Space=32 Bit, Page size= 4 kb= 2 2 x 210 = 2 12

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 703 of 2244

PTE= V.A.S./ Page Size = 2 20 ....................eq. 1

Physical memory size= 64MB= 2 6 x 210 x 210 ​ = 2 26

Then No. of Frames in Physical Memory= 2 26 / 212 = 2 14

And page table needs to store the address of all these 2 14 page frames. Therefore, each page table entry will contain 14
bits address of the page frame and 1 bit for valid-invalid bit. we suppose 16 bit require it means 2 bytes (approx.)

so Size of Page table = Total PTE (from eq 1) x Size of page table entry= 2 20 x 2 = 2MB

 1 votes -- Raj Mike ( 823 points)

32 bit virtual address means 2 32 /4K = 2 20 entries in the page table as each entry points to a page (the lower 12 bits are
not used while looking up in the page table).

Each PTE must address a memory location of a page which ranges from 0 to 64M/4K = 16K. So, should need 14 bits.

So, PTE size will be 2 20 * 14 bits ≈ 2 MB

 2 votes -- Arjun Suresh ( 124125 points)

6.339 CONTEXT SWITCHING top gateoverflow.in/9274

Assume that current cpu burst of the lone process spans more than one time-slice of the round-robin algorithm.

My reasoning is as below

The steps that may take place when a timer interrupt occurs in a typical case are

1. Interrupt occurs.
2. Switch to kernel mode
3. OS saves current context into PCB(save registers, process state and memory-management info of current process)
4. Perform many architecture-specific operations, including flushing data and instruction caches and TLB's.
5. Put current process into the ready queue
6. Choose the new process to execute
7. Load context from the PCB of that process
8. Switch to user mode. Start executing the new process

I am now thinking that the OS might as well inspect the ready queue first and check if there are other processes. If there
aren't any there is no need for a context switch. Thus handling of the timer interrupt will entail switching between the user
mode and kernel mode, checking the ready Q, and switching back to the user mode to resume execution of the process.

Is this what happens? Or does a proper context switch of involving the unnecessary saving of the current state of the lone
process and the restoring the same take place?

this question arises because der is a question in ISRO exam 2007..


which of the following not necessarily saved at the time of context switching ?
a. Program Counter
b. TLB
c. General Purposes Register
d. Stack Pointer

and correct answer was given as TLB ..


reason is when context switch takes place between two threads of same process TLB and Cache are still valid because both
thread are of same process .. so dont save (dont even flush) TLB and Cache at the time of Context switching..


Selected Answer

You should see the word "NECESSARILY" in question. We don't need to save TLB or cache the ensure correct program

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 704 of 2244

resumption. They are just bonus for ensuring better performance. But PC, stack and registers MUST be saved as
otherwise program cannot resume.

Ref: http://www.linfo.org/context_switch.html

 0 votes -- Arjun Suresh ( 124125 points)

6.340 Clustered page table top gateoverflow.in/9482

Can anyone please explain what are clustered page tables?


Also why they are useful for sparse address spaces, where memory references are noncontiguous and scattered throughout
the address space?

6.341 system call top gateoverflow.in/9571

System call are usually invoked by using

a) software interrupt

b) polling

c) An indirect jump

d) A previledged instruction

Software interrupt is the answer.

Privileged instruction cannot be the answer as system call is done from user mode and privileged instruction cannot be
done from user mode.

 1 votes -- Arjun Suresh ( 124125 points)

6.342 Segmentation top gateoverflow.in/9566

Segmentation may contain

a) Internal fragmentation

b) External fragmentation

c) Both

d) None

Also please explain the answer...

Answer :B

Segmentation is similar to dynamic partitioning, only this time process can have several segments, while in dynamic
partitioning a partition is accommodating the entire process.

A different memory management approach known as dynamic partitions (also called variable partition) which creates
partitions dynamically to meet the requirements of each requesting process.

DYNAMIC PARTITIONING

Each P is allocated exactly the required space (no internal fragmentation)


Out-swapping P2 leaves a hole(External fragmentation)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 705 of 2244

 2 votes -- Anu ( 6731 points)

6.342 consider the given sequence of scheduling then what will be the
number of context switch: p1p1p2p2p3p1p4p4p4. plzzzz rply some one top
gateoverflow.in/9492

Answer is 4

P1 to P2

P2 to P3

P3 to P1

P1 to P4

Whenever CPU starts execution with Process P1(initially) we wont consider as Context switch

Context switch is one occurs when CPU changes the execution from one process to other Process

 5 votes -- supraja ( 525 points)

6.343 A certain computer system has the segmented paging architecture for
virtual memory. top gateoverflow.in/7324

A certain computer system has the segmented paging architecture for virtual
memory. The memory is byte addressable. Both virtual and physical address
spaces contain 16 2 bytes each. The virtual address space is divi8ded into 8 nonoverlapping
equal size segments. The memory management unit (MMU) has a
hardware segment table, each entry of which contains the physical address of the
page table for the segment. Page table are stored in the main memory and
consists of 2 byte page table entries.
(a) What is the minimum page size in bytes so that the page table for a segment
requires at most one page to store it? Assume that the page size can only be
a power of 2
(b) Now suppose that the pages size is 512 bytes. It is proposed to provide a
TLB (Translation look-aside buffer) for speeding up address translation. The
proposed TLB will be capable of storing page table entries for 16 recently
referenced virtual pages, in a fast cache that will use the direct mapping
scheme. What is the number o tag bits that will need to be associated with
each cache entry
(c) Assume that each page table entry contains (besides other information) 1
valid bit, 3 bits for page protection and 1 dirty bit. How many bits are
available in page table entry for storing the aging information for the page?
Assume that the page size is 512 bytes.


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 706 of 2244

So Architecture has Segmented paging

Seg No. Page no. With in the Seg. Offset

So 1 st Given Virtual Space = Physical Space = 16 bit and There are 8 Segment in the memory So for 8 segment there are 3 bit to
represent the 8 segment

Virtual Address Space


Seg No.= 3 bit Page no. With in the Seg. +Offset = 13 bit

each Page table Contains = 2 bytes = 16 bit

SO

(a) Let page Size = 2 n

We know that offset(d) = n (power of 2 in page size here n )

p+d = 13 ≫ p+n=13, so No. of page = 2 13-n

And Size Of page table = 2 13-n x 2 bytes(given in ques) = 2 14-n

And Size of page table = Page Size (Due to Statement given in Que= page table for a segment requires at most one page to store it )

214-n = 2n so n = 7

So page Size = 128 byte

(b) Actually i am not understand what the Ques. is asked

(c) each Page table Contains = 2 bytes = 16 bit

frame Size= Physical Address Space / page Size = 2 16 / 29 = 27

7 bit frame Size

frame Valid Dirty remaining = 16-7-


PP=3
bit= 7 Bit=1 bit=1 1-3-1=4 bit

So Answer is 4 Bit....

 1 votes -- Raj Mike ( 823 points)

6.344 Disk Scheduling algorithm top gateoverflow.in/7264

Which scheduling algorithm is optimum among the following disk scheduling algorithm in most of cases?

a)FCFS

b)SSTF

c)SCAN

d)LOOK

Also please give reason

ans must be D)

LOOK behaves almost identically to SSTF, but avoids the starvation problem of SSTF

 0 votes -- Laxmi ( 683 points)

6.345 fork() system call top gateoverflow.in/6109

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 707 of 2244

Also please explain how many times "PROCESS" will be printed when we don't use fflush()...?


Selected Answer

It must be fflush(stdout);

In C code by default stdout is buffered until a newline occurs. So, here if we don't use fflush, printf buffer will be active
during fork, and hence copied to the child process also. The two fork() calls create 3 child processes, and hence
"PROCESS" will be executed 4 times if we don't use fflush.

If we put a '\n' at end of printf or use fflush(stdout); only 1 printf will be done.

http://stackoverflow.com/questions/2530663/printf-anomaly-after-fork

 4 votes -- Arjun Suresh ( 124125 points)

6.346 consider the following code top gateoverflow.in/5944

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 708 of 2244

operating-system

3rd precedence graph is correct.

What I think, we can solve it by checking the flow of the execution. First, after S1 , fork is done and new process's address
S3. so two arrows from S1 (i.e S3;new process address , S2;normal execution) . Similarly proceed with other forks. At
DEF we can see S5,S4,S2 can reach. So, these processes are combined.

Please correct me if it's wrong.

 6 votes -- shreya ghosh ( 2801 points)

6.346 State True/False with explanation for the statement --> Multilevel
paging optimizes the program execution time. top gateoverflow.in/5721

True. But depends on the size of virtual address space. Multilevel paging can ensure all page tables needed for a process
can fit in physical memory and thus avoid swapping out of pages (pages of page tables) to hard disk. In this way it can
reduce execution time.

Now, if the page tables are initially itself fitting on main memory, then multi-level page table only decreases execution
time due to overhead of multi-level lookup.

 0 votes -- Arjun Suresh ( 124125 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 709 of 2244

6.346 State true or false with explanation.Larger time quantum gives more
efficiency than smaller time quantum used in RR scheduling top gateoverflow.in/6203

True.

Smaller time quantum leads to more context switch time and the time cpu spends actully executing the process is
reduced.

 1 votes -- Anurag Semwal ( 4775 points)

6.346 Can any one tell , how the formula works ? i mean why no. of process
is added ?? Sum of all process max need < No. of Process + Resource No. top
gateoverflow.in/6467

I suppose this is the formula for min. no. of processes required for deadlock. For this, we assume the worst case and this
happens when all but 1 required resources are taken by all the processes.

i.e., total allocated = total max need - n

If we have one more resource, one process can be finished and this results in more processes getting finished and there
won't be a deadlock. So, for deadlock,

max. no. of resources = total max. need - n

or

total max. need = n + no. of resources

 1 votes -- Arjun Suresh ( 124125 points)

6.347 Semaphore top gateoverflow.in/7257

What is value of binary semaphore "S" after executing 10 P (Wait) operations and 14 V (Signal) operations if the initial value
of "S" is 1 ?

It will be 1

First p operation : semaphore value 1 so make it 0 and process continue execution

Next 9 p operations : semaphore value not 1 So block all the process and place in suspended list

9 p :9 processes in asuspended list

After that for 9 v operations:

Suspended list not empty so wakeup processes one by one

After that 10 th v: suspended list empty, make semaphore value 1

After that 4 more v will also make semaphore

Value 1.

 3 votes -- Anurag Semwal ( 4775 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 710 of 2244

6.348 Semaphore top gateoverflow.in/6645

Semaphore is shared between parent and child. Since, it is initialized to 1, one of either parent or child will succeed in
wait(sem) prints Gate and then signal(sem). Now, the other process also does the same. So, "Gate Gate" will be the
output.

 0 votes -- Arjun Suresh ( 124125 points)

6.349 Is LOCK variable shared or global in the synchronization mechanism ?


top gateoverflow.in/18590

Through lock variable we try to provide synchronization


Entry section
1.while(LOCK!=0) ;
2.LOCK=1
3.CRITICAL SECTION
Exit section :

4.LOCK=0
I am unable to get that this code belongs to which process in general since P1 and P2 both execute this code and also they must be having some other code also
in addition to this one so is it that both of the processes have this piece of code present in them and if it is so then how come the value of LOCK changed by one
process is seen by the other process since LOCK is present in the entry section and not in the critical section which implies that it is not a shared variable since if it
were a shared variable it would have been inside critical section, but it is not .Also each process would make changes in its own register contents only so then how come they are actually able
to see the actual values of LOCK variable

Hi , no the above code is right . this is because both process will use same code . I will explain you LOCK is a
synchronisation variable . Let us see how . you will have LOCK=0 as initial value to get into critical section. Suppose if i
have 2 process p1 p2 . And if anyone of the process P1 come then it , it will find lock value as 0 ryt ? Now while statement
(0!=0) . false right . so it will go out of while loop and enter into critical section by making LOCK variable =1 . Now
suppose this time if p2 come , it will grab lock varaible and check (lock!=0) -->(1!=0) ;which is true , so it will loop in
while loop only (see ; after whileloop ). Hence you can get this would be exceution if any 1 process come first and then
another one (while p1 is executing ) Now imagine a scenario when both process come together and grab a lock varaible
(inital lock value is 0 ) . both will compare (0!=0) which is wrong so both of them simulatenously will enter critical section
. And the thing that here Lock is used as one of door to critical section . Its not a critical section !

 0 votes -- priti sharma ( 637 points)

6.350 Does Progress gurantee Bounded waiting ? top gateoverflow.in/18716

If a synchronization mechanism does not gurantee Progress then does it implicitly imply that it won't gurantee Bounded
waiting as well

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 711 of 2244

Selected Answer

Not really. Because "Progress" is defined for the system and "Bounded wait" per process. Even if a process is starved and
violate bounded waiting, system can progress.

On the other hand if "progress" is not guaranteed, "bounded waiting" carries no meaning. So, no progress implies no
bounded waiting- your second statement is correct.

http://csit.udc.edu/~byu/UDC3529315/Lecture6.pdf

 0 votes -- Arjun Suresh ( 124125 points)

6.351 OS top gateoverflow.in/27838

Suppose you have byte addressable computer system with a 44 bit logical address and the page size in 6.4kbytes and each page entry takes 4 bytes. you are
running a 4 Gbytes program in this system. How many page frames would you need in order to put your entire program (including its page tables) in memory?

is it 65540?

Note: page size= frame size

Total no. Of frame required = no of frame for storing the program + no. Of frame required to store the page table

=(2^32÷2^16) + (2^18÷2^16)

= 2^16 + 4

=65540

Correct me if i am wrong..Thanks..

 1 votes -- Rajesh Pradhan ( 463 points)

6.352 memory top gateoverflow.in/27670

Bounded waiting: there must exist a bound on the number of times that other processes are allowed to enter their critical sections

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 712 of 2244

after a process has made a request to enter its critical section and before that request is granted.

Lets analysis in example

Initially both process P0 and P1 make their flag= false

i.e. flag[0]= false, flag[1]= false

now p0 and p1 enter in to while loop 1

p0 make its flag[0]= true and p1 also flag[1]= true

so while p0 check for while condition and enter into 2nd while loop

and make their flag value false i.e. flag[0]=flase

at that time p1 check 2nd while loop condition since flag[0]=flase so not enter into while loop and go into critical section,

now p0 check 3rd while loop condition and enter into 3rd while loop since flag[1]=true

now p1 make its flag value false i.e. flag[1]= false

now here case arrise when p0 check 2nd while loop then flag[1]= true and when p1 check for 2nd and 3rd while loop then flag[0] =
false.

so by this p0 never getting the chance to enter in C.S. .. and p1 enter infinite number of times.

 1 votes -- Anirudh Pratap Singh ( 4091 points)

6.353 memory top gateoverflow.in/27669

Formula will be like cache is physicaly addressed so. first go to TLB then in cache.

EMAT= TLB hit [ cache hit (TLB time + Cache time) + cache miss ( TLB + Cache + memory) ] + TLB miss [ cache hit (TLB
time + Cache time) + Cache miss ( page fault [TLB + Cache + Page table+ Memory + Hard disk] + no page fault[ TLB +
Cache + Page table+ Memory]]

 1 votes -- Anirudh Pratap Singh ( 4091 points)

6.354 OS top gateoverflow.in/27839

Shared Boolean waitIn [2] = false;


Shared int turn = 1;
int myPid = 0; // For process 0. Set to 1 for process 1
int otherPid = 1 - myPid;

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 713 of 2244

wantIn [MyPid] = true;


turn = OtherPid;
while (wantIn [OtherPid] && turn == OtherPid);
// Critical section
wantIn [MyPid] = false;

How to find the necessary condition for semaphore is satisfied?

it is the same implementation of peterson algorithm , just they have changed the turn = process , to turn = others
process, the primary purpose of semaphore is to provide mutual exclusion which is definitely guaranteed.

 0 votes -- Ravi Singh ( 7303 points)

6.355 process synchronization top gateoverflow.in/28271

http://gateoverflow.in//1853/gate2006_78-79

 0 votes -- Digvijay Pandey ( 26245 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 714 of 2244

6.356 check the question top gateoverflow.in/29456

A computer system implements a 8kilobytes pages and a 36 bit physical address space.each page table entry contains a valid
bit,and the translation.if the maximum size of the page table is 96megabytes,Then what will be the length of the virtual
address supported by the system(in bits)?


Selected Answer

frame size,which is equal to page size so,2^13.

no of frames = 2^36/2^13 = 2^23.

page table entry = frame no bits + valid bit = 23+1=24 bits = 3B.

page table size= no of page * page table entry

so, 96 MB = x * 3B , so , x= 32 M = 2^25

virtual address = no of page * page size = 2^25 * 2^13 = 2^38.

so virtual address 38 bits.

 1 votes -- Sayantan Ganguly ( 5061 points)

Ideally one-level paging must be specified.

2x
2 13
Now, no. of page table entries = Virtual memory size/ Page size = = 2x−13

Each page table entry needs 23 + 1 = 24 bits (23 bits for addressing a frame and 1 valid bit). And the total size of the
page table is 96 MB. So, we get

2x−13 × 24 ≤ 96 × 223  x ≤ 96/24 × 236  x ≤ 38.

So, maximum length of virtual address possible is 38 bits.

 3 votes -- Arjun Suresh ( 124125 points)

6.357 check the quesion top gateoverflow.in/29422

consider a uniprocess system executing four tasks T1,T2,T3 and T4 each of which is composed of an 10 sequence of job(or
instances) which are arrives at periodically at interval of 2,4,8 and 16 ms respectively.the priority of each task is directly
proportional to its periods and the avaliable task are schedule in order of priority,with the highest priority task schedule
first.each instance of T1,T2,T3 and T4 requires an execution time 1,2,4 and 6 ms respectively.given that all task arrive at
beginning of the 2ms and task preempted allowed,the 2nd instance of T3 its execution at the end of_______ ms


Selected Answer

execution sequence....

1).............................

2)T4

3)T4

4)T4

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 715 of 2244

5)T4

6)T4

7)T4

8)T3

9)T3

10)T3

11)T3

12)T2

13)T2

14)T1

15)................................

16)T4

17)T4

18)T4

19)T4

20)T4

21)T4

22)T3

23)T3

24)T3

25)T3....

so ans according to me is 25 ms..

please let me know,if it is correct or not....

 0 votes -- Sayantan Ganguly ( 5061 points)

6.358 LRU plz explain top gateoverflow.in/29117

Page 1 has least last reference time(260) so LRU will replace page 1

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 716 of 2244

If it was asked for FIFO then page 2 will be replaced(least loaded time)

For most frequently used page 3 will be replaced(highest last ref time)

 1 votes -- Pooja ( 22773 points)

6.359 In particular unix OS each data block is of size 256 bytes top gateoverflow.in/27252

operating-system

Max possible size= ( Direct + Single indirect +Double indirect)* block size

so Answer is

Max possible size =[20 + (256B/ 64B)+ (256B/ 64B) 2 ]* 256B

= [20+4+(4) 2 ]*256B

= 40 *256B

= 10KB

 3 votes -- Anirudh Pratap Singh ( 4091 points)

6.360 possible vales of variables ? top gateoverflow.in/27001

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 717 of 2244

Execution sequence
1)x=1 1 1 3 1 2 2
2)y=y+x 2 4 4 3 4 3

3)y=2 3 2 1 2 1 1
4)x=x+3 4 3 2 4 3 4

x=4 y=2 x=4 y= 6 x=1 y=3 x=4 y=3 x=4 y=6 x=4 y=3

So option D

 0 votes -- Umang Raman ( 10379 points)

6.361 CPU having a single interrupt request line and a single interrupt grant
line top gateoverflow.in/26448

Which one of the following is true for a CPU having a single interrupt request line and a single interrupt grant line?
A. Neither vectored interrupt nor multiple interrupting devices are possible
B. Vectored interrupts are not possible but multiple interrupting devices are not possible
C. Vectored interrupts and multiple interrupting devices are both possible
D. Vectored interrupts are possible but multiple interrupting devices are not possible

6.362 Using a larger block size in a fixed block size file system leads to top
gateoverflow.in/26445
Using a larger block size in a fixed block size file system leads to

A. better disk throughput but poorer disk space utilization

B. better disk throughput and better disk space utilization

C. poorer disk throughput but better disk space utilization

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 718 of 2244

D. poorer disk throughput and poorer disk space utilization

If the block size is large then seek time is less (fewer blocks to seek) and disk performance is improved,
but larger block size also causes waste of disk space.

So option a is correct.

 0 votes -- ayushigupta ( 89 points)

6.363 avg SJF calculation top gateoverflow.in/25941

Calculate the exponential avg for the SJF when t1=10, alpha=0.5...previous run as 8,7,4,16

By Exponential Avg. Algo=0.5*10+0.5*0.5*4+(0.5)^2 *0.5*7+(0.5)^3 *0.5*8+(0.5)^4 *0.5*16=7.875

 0 votes -- srestha ( 11585 points)

6.364 deadlock top gateoverflow.in/26520

Using bankers algorithm time complexity is 0(n 2 m)

 2 votes -- Anirudh Pratap Singh ( 4091 points)

6.365 fork top gateoverflow.in/26657

6.366 Can anyone please help (or provide some link stated clearly) in

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 719 of 2244

Multilevel Page table and Paging with Segmentation? top gateoverflow.in/142

Need the clear concept of hierarchy of Page table.


Selected Answer

These two links are very good for paging.

https://courses.cs.washington.edu/courses/cse451/08wi/os-paging.ppt

http://www.cs.columbia.edu/~junfeng/10sp-w4118/lectures/l21-page.pdf

 2 votes -- Arjun Suresh ( 124125 points)

6.367 partitoning top gateoverflow.in/26895

Answer (C) As in First fit case Total is { (5-3) + (10-2) +(30-12) } = 28K

In Case of Best Fit Total is { (5-3) +(2-2) +(30-12)} = 20K

 1 votes -- Abhishek Kumar ( 71 points)

6.368 File system top gateoverflow.in/26678

1-->>Maximum possible no. Of file = 4KB / 4B = 1K

4KB bcz one data block used to store directory entries each of 4 Byte...So 1K max. No. Of files..

2)-->>Now max possible file size in blocks is......given below..

Now as mentioned 8-bit entry per data block means there are 2^8= 256 data blocks out of that first 2 datablocks are
overhead so 256-2=254 Blocks max file size in terms of blocks

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 720 of 2244

 1 votes -- Rajesh Pradhan ( 463 points)

6.369 dual mode operation- operating system top gateoverflow.in/29480

What is the purpose of dual-mode operation?

a. To enable the operating system to take control of the processor.


b. To save power.
c. To protect the OS and hardware from corruption.
d. To distinguish an ordinary user from a super user.

what about 3rd option???option a is correct??

operating-system

(c) To protect the OS and hardware from corruption.

Refer this page for more details : http://www.slawinski.ca/courses/new_cs30/unit2/part14.htm

 1 votes -- Sourav Mishra ( 221 points)

6.370 context switch top gateoverflow.in/30161

Let there are 4 process . P1, P2 ,P3, P4. Round Robin used for scheduling , Time quantum = q . each process burst time is
greater than q . all processs arrived at time t = 0.

now how we count the context switch.

_P1_P2_P3_P4_

to count context switched all dashes need to consider . or need to left first or last.

plz explain ?

as it is given Q> burst time so no one will end in once cycle. so again after all these q1 wil come. so definitely we have to
consider . till the last process. what i think there is no need to count the last one. whichever it is.

 0 votes -- Ravi Singh ( 7303 points)

6.371 consider a process which tries to acquire a lock top gateoverflow.in/31680

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 721 of 2244

Explain why a and b must be true.I think it should be only b because block is .. process is in wait state ie not consuming cpu
cycles whereas in busy wait cpu cycles are consumed

TSL is BUSY-Waiting approach.

So while process is in CS the the other process continuously check lock is available or not.

If lock available it gets chance to enter in CS and if not it will just wait and continuously check the LOCK variable is free or
not .

 0 votes -- Saraswati Walijkar ( 193 points)

6.372 Average access time top gateoverflow.in/31674

Assume memory access time is 10 μs and reading a page from disk takes 10 ms. If page fault occur in 0.5% of the memory
references then what is the average memory access time (in μsec)?

operating-system

Main memory access time (m) = 10 microsec

Service time (ps) = 10 milisec

Page fault rate (p)= 0.5% = 5*10^3

Thus

EMAT= m+p(ps)

= 10 microsec + 5*10-3*10*10^-3

= 10 microsec + 5 * 10^-6

= 10 microsec + 5 microsec

= 15 microsec

 0 votes -- Saraswati Walijkar ( 193 points)

6.373 cache hit quesion top gateoverflow.in/31372

Main purpose behind this question is, which access


mechanism to consider by default:Simultaneous ie on Miss directly access from main memory without transferring to cache

or Hierarchial ie First transfer to cache and then access from cache..

operating-system

6.374 multithreading top gateoverflow.in/31705

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 722 of 2244

6.375 Please explain top gateoverflow.in/31812

6.376 Plz solve top gateoverflow.in/31816

offset 10 bits

page 3 bits

7786-0111 0111 1000 0110

page=101

not in memory so cause page fault

so ans d

 0 votes -- Pooja ( 22773 points)

6.377 Please solve top gateoverflow.in/31815

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 723 of 2244

in each round one process completes

in round 1 process 1 completes then p2 and p3 run for 3 units

in round 2 p2 runs for 1 unit and p3 for 3 units

in round 3 p3 runs for 1 unit

0--p1--1--p2---4----p3---7---p2---8---p3--11--p3---12

 4 votes -- Pooja ( 22773 points)

6.378 Plz solve top gateoverflow.in/31813

6.379 Round Robin Scheduling top gateoverflow.in/31350

Execution
Process
Time
P1 3
P2 5
P3 2
P4 1
P5 3
P6 4

Assume that all process arrive at t=0 and cut off time (TQ=2 units).

One cycle includes the one occurrence of each and every remain process in system and provided that they may complete
their execution in one cycle only

Q) How many jobs will complete their execution by the end of second cycle of selection?

a) 2 c) 4

b) 3 d) 5

I am not getting from where we have to start first cycle or second cycle ?

Made Easy question.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 724 of 2244

0-P1- 2 - P2- 4 - P3 - 6 - P4 - 5 - P5 - 7 - P6 -9 (END OF ONE CYCLE ) - P1 - 10 - P2 - 12 - P5 -13 - P6 - 15 (END OF SECOND


CYCLE)

So till second cycle all P1,P3,P4,P5,P6 have completed there job.


so option D.

 0 votes -- Umang Raman ( 10379 points)

6.380 Operating system Memory Management top gateoverflow.in/31343

A computer System has 4GB of physical addressable memory with 32 bit memory addresses. It uses virtual memory with
demand paging for memory management , with a page size of 4 KB . Each page entry contains a page ID, a frame ID, and
three additional bytes of information. Q. How many bits of the virtual address are replaced by the MMU when it translates
the address into a physical address A. 12 B. 16 C. 20 D. 32

6.381 file system size top gateoverflow.in/30366

operating-system

A file size 42797 KB =42797*1024 B

Now, each sector contains 512 B

So, no of sector 42797*1024 / 512 =85594 sectors

Each cylinder contains 64 sectors

No of surface of cylinder 85594/ 64 =1337 (here remainder 26 is no of sectors filled of last cylinder)

Now, 16 recording surface to each cylinder

No of cylinder 1337/16 =83 (No of remaining surface i.e. remainder is 9 )

So, 83 cylinder is full

Now for next 9 surface and 26 sectors need 1 more cylinder

So, from starting cylinder 1200+83+1=1284 for last sector of the file

Ans will be (D)

 0 votes -- srestha ( 11585 points)

6.382 Exponential average top gateoverflow.in/30348

in this question alpha =0.25. but how we can determine that alpha

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 725 of 2244

this may clear your doubts

 1 votes -- Sayantan Ganguly ( 5061 points)

6.383 effective memory access time top gateoverflow.in/30282

Page tables are stored in memory , which has access time of 100 ns. The TLB holding 8 page table entries, has an access time of 10 ns. Using execution of process , it is found that 85 % of
the time, a required page table entry exist in TLB and only 2 % of the total references causes page fault. Page replacement time is 2 ms . Calculate the effective memory access time ,
assuming page memory access requires 2 memory accesses and TLB requires one memory access.

A) 38120 ns B) 40000 ns C) 40120 ns D) None

0.85*[100+10]+0.15[0.02{10+100+2000000+100}+0.98{10+100+100}]
= 6125.00 ns

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 726 of 2244

If there's TLB hit just refer main memory directly.

If there's TLB miss ,refer memory if page fault occurs replace page and again refer memory.

 0 votes -- Ankesh Gautam ( 665 points)

6.384 Plz solve top gateoverflow.in/30388

. Two concurrent processes P1 and P2use four shared resources R1, R2, R3 and R4 as shown below:

P1: Compute; P2: Compute;

Use R1; Use R1;

Use R2; Use R2;

Use R3; Use R3;

Use R4; Use R4;

Both processes are started at the same time, and each resource can be accessed by only one process at a time.

The following scheduling constraints exist between the accesses of resources by the processes:

P2 must complete use of R1 before P1 gets access to R1 P1 must complete use of R2 before P2 gets access to R2 P2 must
complete use of R3 before P1 gets access to R3 P1 must complete use of R4 before P2 gets access to R4 There are no other
scheduling constraints between the processes above scheduling constraints, what is the minimum no. of binary semaphores
needed?

(a) 1 (b) 2 (c) 3 (d) 4

Answer is B .

We need minimum 2 semaphores.

 2 votes -- Riya Roy ( 4767 points)

6.385 Plz solve top gateoverflow.in/30389

. Consider the program segment:

x= 0; y=0;

Cobegin

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 727 of 2244

begin

x= 1; y= y + x;

end

begin

y= 2; x= x + 3;

end

Coend;

Which of the following indicates possible values for the variables when the segment finishes execution?

(1) x= 1, y= 2 (2) x= 1, y= 3 (3) x= 4, y= 6 (a) 1 only (b) 1 & 2 only (c) 1 & 3 only (d) 2 & 3 only (e) 1, 2, 3

Option D is I think correct ans...

 0 votes -- Rajesh Pradhan ( 463 points)

6.386 Plz solve with explaination top gateoverflow.in/30392

. Consider the following program:

Const int n= 10

int Count= 0

Void A( )

{ int i; for(i= 1 to n)

Count= Count + 1;

Main ( )

{ Par begin

A( );

A( );

A( );

A( ); Par end }

What is the minimum and maximum possible value of count after the completion of the program?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 728 of 2244

(a) 1, 40

(b) 2, 40

(c) 3, 40

(d) 4, 40

Option B --2,40

Devid count=count+1 into lower lvl instruction..

​plz follow the fig...and correct me if I am wrong..Thanks..

 2 votes -- Rajesh Pradhan ( 463 points)

6.387 Plz solve with explaination. top gateoverflow.in/30391

. Consider a concurrent program with two processes P & Q, where A, B, C, D & E are arbitrary atomic statements; assume
that main program does a Par begin of the two processes:

Void P( ) Void Q( )

D;

E;

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 729 of 2244

{ A;

B;

C;

Which of the following statement is True?

(a) It is never possible to generate output ‘C’ before output ‘E’

(b) The order of Execution of statements will be same independent of the process execution

(c) The relative order among the statements of P & Q is always maintained

(d) None

6.388 PAGING: top gateoverflow.in/25474

Which is true?

a.page size increases,page fault rate also increases

b.Disk block size increases,throughput decreases.

c.page size decreases,fragmentation increases.

d.page size increases,page table size decreases.

Option D: Page Table size = number of entry * page table entry size
LAS

Page Table size = PageSize * page table entry size

so if we increase the Page size Page table size will decrease

 4 votes -- Umang Raman ( 10379 points)

6.389 OS Gateforum Section test Q2 top gateoverflow.in/25038

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 730 of 2244

test-series operating-system

I think answer is D.It is very nice qs.6 is running and its next pointer is poiniting to 0.which is poiniting to in 3 ready.In 3
ready next pointer is 12,which is pointing to 12 ready,in 12 ready next pointer 14,so pointing to 14 ready,then pointing to
6 ready,and lastly next pointer * pointing to free 8...

pls let me know if I am correct or not..and als what is the answer.

 2 votes -- Sayantan Ganguly ( 5061 points)

I think option B is the answer because in running header 6 is the current one and 0 is the pointer to next .In 0 ready,3 is
the next.In 3 ready 12 is the next.In 12 ready,14 is the next.In 14 ready 6 is the next.

Please correct me if am wrong.

 1 votes -- Prabhanjan R ( 747 points)

6.390 What is the minimum and maximum possible value of count after the
completion of the program? top gateoverflow.in/19318

Constant n= 10

int Count= 0
Void A( )
{ int i;
for(i= 1 to n)
Count= Count + 1; }
Main ( )
{ Par begin
A( );
A( );
A( );
A( );
Par end }


Selected Answer

MIN = 2

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 731 of 2244

MAX = 40

Maximum is obvious.

For Min -

Lets consider increment of count is in 3 micro instruction

step 1 Load Ri M[count]

step 2 INCR Ri

step 3 M[count] Ri

Where Ri is the local register allocated by each function called and used for temporary storage.

Lets called first A() is A1()

Second A() is A2()

Third A() is A3()

Fourth A() is A4().

Now every function from A1() to A4() will execute concurrently and each function will execute all 3 micro instruction;

1> Now consider A1() call first, it increment COUNT from 0 to 1 in 3 micro instruction but after executing 2 micro
instruction and gets preempted so at this time the value of R1(temprrary register ) = 1 but the count value will be still 0.

2> Now let A2() and A3() complete the execution so count value will be 20.

3> A4() will start it execution and let it iterate for "9" times so the count value will be 29 and preempt the A4().

4> Let A1() will start it's execution and it will execute its 3 micro instruction and overwrite count value from 29 to 1 in it's
first iteration and again preempt.

5> lets A4() start it's execution now the count value is 1 so it will iterate its 10 'th iteration and execute 2 micro
instruction and then preempt A4(). at this time R4(temporary register = 2) and count = 1.

6> Now execute remaining iteration of A1 form i=2 to 10 so it will make count value as 10 and complete it's execution.

7>In final step A4() will start it's execution and will execute 3 micro instruction for 9'th iteration and overwrite count = 1
and in the 10 iteration it will increment count from 1 to 2 and finish the execution.

So Min = 2

Max = 40.

 2 votes -- admin ( 1411 points)

6.391 Process Synchronisation top gateoverflow.in/19298

Semaphore is used to enforce Mutual Exclusion and Synchronization between processes interacting over shared data and
variables. Which of the following statements is true about semaphores in this regard?

(a) The Operations SIGNAL(S) & WAIT(S) needs to be atomic.

(b) A process exiting the CS will call SIGNAL(S)

c) ‘Busy-Wait’ solutions to the Critical Section are typically implemented using machine instructions that execute in the
Kernal mode

(d) all of the above

operating-system

Only 1 needs to be true always. But "typically" in option 3 means it is also true. Busy-Wait can be done using Though
there is no strict requirement to do a signal after CS, assuming it got a lock, the process has to release it. So, it also
becomes true. So, I think D is the best choice.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 732 of 2244

 1 votes -- Arjun Suresh ( 124125 points)

6.392 Let P0 And P1 are two processes,each accessing two binary


semaphore s and q set to value 1: top gateoverflow.in/19243

P0

wait(s); wait(q);

Signal (s); signal(q);...

P1[

wait(q);wait(s);}

signal(q);signal(s);....

whether progress is guarnteed or not ???

Progress is not guaranteed I think bcz P0 will do down operation on s and q,so when P0 is in critical section for a very long
time P1 have to wait for arbitrary time until P0 releases s and q.When a process is stopping other process from executing
then we say there is no progress.correct me if I'm wrong..

 0 votes -- Rohan Ghosh ( 1515 points)

6.393 What is the average TAT?? top gateoverflow.in/19319

Consider the processes P1, P2, P3 arrived in the sequence P2, P3, P1 and the burst time of the processes are 3, 3, 24
respectively. What is the average TAT??

where TAT(Pi) is the Turn Around Time of process Pi & n is the total number of processes participating in the scheduling
algorithm.

 0 votes -- Amar Vashishth ( 17865 points)

6.394 why is bankers algorithm less efficient than resource allocation graph
algorithm ? top gateoverflow.in/19575

I am unable to get this logic since in both of these algorithms we need to have a record of future requirement of the
processes so then why is it that resource allocation graph algorithm is more efficient ?

This line is given in galvin right ?

i think so that in A resource allocation garph , to detect a cycle we need n^2 operation (where n is no of process )

Whereas in banker Algorithm take m*n*n operation to determine whether is safe or not where m = no of resources and
n is no of process

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 733 of 2244

Hence this can be one of the reason .

 0 votes -- priti sharma ( 637 points)

6.395 Memory Management top gateoverflow.in/19722

Which of the following are true about of paging ?

1) It divide the memory into units of equal size

2)It permits implementation of virtual memory

3)It suffers from Internal Fragmentation

option a) 1 b ) 2 c) 3 d) 1,2,3

operating-system


Selected Answer

Paging divides memory in equal size pages.It suffers from internal fragmentation (on an average (page size)/2) at very
last level of page. Paging also implement virtual memory.

All are true,

 0 votes -- Digvijay Pandey ( 26245 points)

6.396 what is the relation between CPU utilization and degree of


multiprogramming ? top gateoverflow.in/19641

It is known that as we increase the degree of multiprogramming the CPU utilization tends to increase but it is not in a
uniform manner so is there any proper term which we can relate while talking about relationship between CPU utilization and
degree of multiprogramming.

Let say I have n processes and they spend p fraction of time in IO state so then CPU utilization would be 1-p^n , so then can
we derive relationship between utilization and n from this relation ?

Hi , CPU utilization mean your CPU should be always busy .

hence if take a system which is capable for running 1 process only (say p1) and now if this process p1 goes for I/o
operation then CPU would be idle right ? so cpu utilization here is low

but if i now bring more process and if any of the process goes for I/o then scheduler can take another process so that CPU
can be kept busy .Hence if you see if we increase number of process then CPU utilization automatically increases

or we can say CPU utilization is directly proportional to number of process in a system

 0 votes -- priti sharma ( 637 points)

6.397 Answer to this question is unsafe state.Why unsafe state in this


question not leading to dedlock? top gateoverflow.in/19619

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 734 of 2244

span
style="background:rgba(220,220,220,0.5);background-image:url(denied:

Yes the answer is unsafe . As far I know banker algorithm given us just the state of machine as safe and unsafe . That all . And the fact that unsafe may or may not be deadlock . So chose
unsafe as answer . They have even said state of the system . They didn't sate of system at that particular instant ( note the difference ) . It might happen that after some time with a new
request we can go to safe sate . So unsafe is safest answer yet

t we would choose deadlock as answer for state of system , then any further request won't help us to get out of situation . I hope you got it :)

 0 votes -- priti sharma ( 637 points)

6.398 Deadlock top gateoverflow.in/19190

Deadlock Prevention is not practically feasible because :

1) Applicable to only shared resources

2) It is only a therotical concept

3)Resource utilization is low

4)It is only applicable to OS Unix

operating-system


Selected Answer

3. Resource utilization is low. If we try to prevent deadlock we will be doing over conservative and thus resources might
get less used.

 0 votes -- Arjun Suresh ( 124125 points)

6.399 which address is this physical or logical? top gateoverflow.in/19156

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 735 of 2244

A address can be both . physical as well as logical. it depends whether your system has that much of ram. i.e suppose u
have a cpu of 32 bit it means it can accommodate 2^32 rows of memory . if u have that much of physical memory then
no need of any virtual or paging memory and the same address may be called as physical address. while if we don't have
such amount of memory we always reflect cpu that we have that much of memory but we manage it under virtual memory
or paging , so at that time the address generated by cpu is not the actually but need some modification after which it
becomes physical address.

 0 votes -- Ravi Singh ( 7303 points)

6.400 File system top gateoverflow.in/18819

Consider a file system where linked allocation strategy and contigous allocation strategy is used , The number of disk block
to be accessed if the k block of file to be accessed respectively is ?

a) 1,k

b)k,1,

c)klogk , k

d) k , klogk

operating-system

In Linked allocation access is sequential so k access to get kth block

Contiguous allocation support direct access so 1 access required to access kth block(starting address known)

So ans is b

 0 votes -- Pooja ( 22773 points)

6.401 File system top gateoverflow.in/18810

Which file is a sequence of bytes organized into blocks understandable by the system’s linker?
a) object file
b) source file
c) executable file
d) text file

operating-system


Selected Answer

A. object file.

A text file is a file where contents are text characters like English alphabets where each character is encoded as
bytes/multi-bytes based on some encoding like ASCII. So, supposing ASCII, to read a text file, we can read 8 bits, and
lookup the ASCII character corresponding to that 8 bits in decimal.

A source file is a text file, where the content represent some program in some programming language.

An object file can be defined as given in question.

An executable file is produced by the linker after fixing all inter module dependencies thus making the object file

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 736 of 2244

executable. For example, extern references, library linking etc are done by linker and these are absent in object file. Now,
executable file contains a sequence of bytes which will be organized into different sections (ELF format in linux) and the
code section will be composing of bytes of the form opcode-operand - or proper instructions as understood by the CPU.

PS: All these are non-standard definitions.

 0 votes -- priti sharma ( 637 points)

6.402 Will there be any starvation due to below synchronization mechanism


? top gateoverflow.in/18732

If a synchronization mechanism satisfies Bounded Waiting but no Progress and also it is a busy waiting solution so will there
be any starvation ?

Yes, there can be. Busy waiting doesn't help for starvation freedom. Bounded waiting + progress ensures no starvation,
but just bounded waiting alone doesn't ensure no starvation.

Bounded Waiting: "After a process made a request to enter its critical section and before it is granted the permission to
enter, there exists a bound on the number of turns that other processes are allowed to enter"

So, bounded waiting condition is not violated during a deadlock, but progress is not made and starvation freedom may not
be there for some process.

See below link for more such properties.

http://www.csl.mtu.edu/cs3331.ck/common/05-Sync-Basics.pdf

 0 votes -- Arjun Suresh ( 124125 points)

6.403 Max number of files top gateoverflow.in/18822

A computer system uses a single level directory structure . The directory occupies 2 disk block . the disk block size is 2KB.
directory entry size is 4 bytes . Then what is maximum number of File in File system ?

operating-system

No of entries in one block=2*1024/4=512

As two block are used for directory son no of entries=no of files=2*512=1024

 0 votes -- Pooja ( 22773 points)

6.404 process synchronizatiom top gateoverflow.in/19091

Suppose there are 2 process p and q :

P:

while (1)

wait (mutex);

print '1';

signal (mutex);

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 737 of 2244

Q:

wait (mutex);

print '0';

signal (mutex);

If process p exceute then only Q execute , then what pattern is obtained ?

a) (01)* b)(10)* c)(1/0)* d) none of these

operating-system

ans of this question is D

because there is no loop in the Q.

so Q will be executed once .

the pattrn is like this 1 *01*

 0 votes -- Pranay Datta ( 6113 points)

6.405 Process Synchronization top gateoverflow.in/19072

In a nCPU shared system , if Z is the probability that any CPU request the bus in a given cycle , the probability that only 1
CPU use teh bus is given by :

a)nZ(1-n)(n-1) b)Z(1-Z)(n-1)

c)n(1-Z)n d)(n-1)(1-Z)n

operating-system


Selected Answer

Z: probability that cpu request the bus


1-z: probability that cpu not request the bus
only one cpu request bus so: nc1 (i.e n)

so n(z)1(1-z) n-1 should be ans ??

 1 votes -- kunal chalotra ( 3567 points)

6.406 Which one of the following is allowed only in kernel mode? top gateoverflow.in/19811

Which one of the following is allowed only in kernel mode?

A) Read the time of day clock

B) Save the status of process

C) change the PC content.

D) non of these

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 738 of 2244

operating-system

context switching is done in kernel mode so acc to that b and c should occur in kernel mode

 0 votes -- Pooja ( 22773 points)

6.407 System call top gateoverflow.in/19920

main( )

{ if (fork( ) == 0)

{ /* Child */

while (1)

{ for (i=0; i<100000; i++) ;<br />


printf("\t\t\t Child executing\n ");

} }

else { /* Parent */

while (1) {

for (i=0; i<100000; i++) ;<br />


printf("Parent executing\n");

operating-system

Parent will never execute printf in this case as child executes before parent and child has a infinite loop

 0 votes -- admin ( 1411 points)

6.408 How can the architecture decide the minimum no of frames to be


allocated to the processes? top gateoverflow.in/20441

When frame allocation strategies are employed , how can the architecture set a minimum criteria for allocating frames to a
particular process since every process may have different nature ?

operating-system


Selected Answer

Each process might have different needs and might require different no. of page frames- hence the no. of page frames
allocated can be different. Now, the minimum no. of page frames allocated is determined by the ISA- which restricts it to
the maximum no. of pages a single instruction can access. You can find more info in the below GATE question.

http://gateoverflow.in/1018/gate2004_21

 0 votes -- Arjun Suresh ( 124125 points)

6.409 Why is the overhead in paging equal to average overhead caused by

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 739 of 2244

page size which is P/2, P is the size of Page ? top gateoverflow.in/20249

Why is the overhead in paging equal to average overhead caused by page size which is P/2, P is the size of Page ?

operating-system

As the page may contain few lines of instruction so the last page of a process may not be able to completely full the page
or it may be half filled or completely filled.

So we consider avg. case so it becomes p/2 . on an average half full. This is in context to internal fragmentation. external
fragmentation is zero and if the context changes and then according to the context page table overhead may or may not
be included.

 0 votes -- admin ( 1411 points)

6.410 what is the need of multi-level paging in terms of implementation of


virtual address space ? top gateoverflow.in/20200

If I say that the multi-level paging reduces the size of page table needed to implement the virtual address space of a
process, then what is the meaning of last lines in the statement :"to implement the virtual address space of a process"

Page tables are used to translate the virtual addresses seen by the application into physical addresses ( in this way page
tables are used to implement the virtual address space of a process; though the entries may not be linearly available in
the page table as demand paging does not require all pages to be present in the physical memory at the same time ).
Multilevel paging reduces the size of the page table in physical memory.

 0 votes -- ashfaque ahmed ( 11 points)

6.411 How does relocation register differ in case of load time binding and
execution time binding ? top gateoverflow.in/20818

I have gone through this link but still I am unable to get what is it actually trying to convey , when binding is done at
execution time then obviously before it we must have loaded the process so then load time binding must have been
performed as well as after it is loaded then we in the entire life time of the process it may be swapped in and out accordingly
so relocation will be done in the entire execution of the process , so will the contents of relocation register remain same or
vary since before execution load time binding will surely occur so then how do the contents of relocation register vary ?

operating-system

The concept of binding says only that when the absolute address will be available for the process. if during run time it is
available then it is run time binding or if available at load time which is necessary if absolute address is not available at
any of the above points. relocation register is set to the absolute address at that time only according to the binding you
are using. otherwise any other address in the register will be only called relocatable address only because that is not
absolute address. what should know is only that . there are only two type address. relocatable address and absolute
address. absolute address is the address at which finally after all the linking and symbol resolution program will be loaded.
so any address in the intermediate stages will only be called relocation address.

 0 votes -- Ravi Singh ( 7303 points)

6.412 How can we compare the logical address with the contents of the limit
register ? top gateoverflow.in/20819

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 740 of 2244

when the limit register contains the maximum physical address of the process so then how can we compare directly the
logical address with the limit register contents ?

operating-system

here the comparison is only to make sure that the address is less than that of the limit register any of the digital
comparator can be used for the same. And it is done so that we cannot access the address space of any other process.

 0 votes -- Ravi Singh ( 7303 points)

6.413 Amount of memory in Multilevel paging,..? top gateoverflow.in/20492

If i have a 32-bit virtual memory space with a page size of 4KB then i will have 2^20 entries in page table with let 4 byte
entry,so size=4 MB. Let it divided into <10,10,12> to implement the same using multilevel paging concept. So the upper
10-bit will be used to index page directory and number of entries in page directory = number of 2nd level page tables. My
doubt is :

1> How many entries does page directory has ?

2> How many entries does each second level page table has ?

3> What page directory entries holds ? (is it base address of each 2ndary page tables)

4> The <10,<em>10,12> marked 10-bit used to index 2nd level page table or it is added with base of each table i.e.
entries of page directory as a displacement to get exact entry ?

Hope question is not confusing you guys !

1. Easy to do, with 10 bits we get 210 = 1024 entries in page directory (first level page table).

2. This is also easy- another 1024 entries here due to 10 bits being used again.

3. Yes, exactly. Base address of each second level page table.

4. Base address is got from page directory and the second 10 bits are used for indexing- that is why no of entries become
1024.

 0 votes -- Arjun Suresh ( 124125 points)

6.414 what is the meaning of virtually addressed physically tagged cache ? top
gateoverflow.in/20415

I am confused over one point that do we look up into cache before address translation or simultaneously , In the below link it
is mentioned that it " caches are typically indexed with the virtual address, allowing the indexing to begin before address translation is
completed. "

http://superuser.com/questions/745008/whats-the-difference-between-physical-and-virtual-cache

Now the point of confusion is that how come only page offset is used to index a cache , and if hit occurs then what will
happen to the physical address generated by MMU , since the cache is indexed before address translation only .

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 741 of 2244

6.415 why is the large hole between the stack and the heap a part of virtual
address space ? top gateoverflow.in/20962

what is the meaning of the below paragraph

"The large blank space between stack and the heap is a part of virtual address space but will require actual physical pages
only if the heap or stack grows .Virtual address spaces that include holes are known as sparse address spaces.Using a sparse
address space is beneficial because the holes can be filled as the stack or heap segments grow or if we wish to dynamically
link libraries during program execution ".

My confusion is that this sparse address must be existing inside the main memory ,how come in becomes a part of virtual
address space since there may be a possibility that the stack and the heap segment are not allocated contiguously inside
the main memory then how can they simultaneously grow towards each other .

On a virtual memory system, we are accessing main memory in units of "page". So, suppose a page size is 4KB, and a
process needs 100 MB of main memory, we can allocate 25K page frames and these frames may be at any point in
physical memory- they need not be contiguous, only each 4KB needs to be contiguous.

Now, the compiler generates addresses (virtual) which are continuous. During run time memory for heap and stack are
also given and each of them is also continuous to facilitate variable addressing in programs. Now, the given paragraph
talks about the space allocated to stack and heap. We can say stack starts from memory address 0x2FFF and heap from
0x1000 and stack goes down and heap grows up. During program run both the stack and heap size can change (during
each function call, stack grows as new activation record gets created and during dynamic memory creation like malloc,
heap grows). So, in the above example, I gave after sometime stack and heap spaces might collide. To avoid this we must
leave enough gap between them and also limit the maximum memory space a process can take. In linux usually 8KB is
the default stack limit for a process.

 0 votes -- Arjun Suresh ( 124125 points)

6.416 How to calculate virtual address space in below question ? top gateoverflow.in/20176

If we are given PAGE SIZE=4KB, PAGE TABLE ENTRY SIZE=4B OUTER PAGE TABLE SIZE=4KB and levels of Paging=3 ,so
how to go about calculating the virtual address space .

No of entries in outer page table =Page size/Page table size =k (2^10Bytes)

Now these entries will point to pages in which the inner page table2 is actually divided therefore no of entries in outer
page table implies the no of pages in which we divide the inner page table2 and it is equal to K.

Now in each page of inner page table2 , we will have same 2^10 entries ,therefore in total we will have K*K entries
coming out from inner page table 2 and these many entries are actually the no of pages in which we have divided the
innermost page table 3, and therefore no of pages in which innermost page table 3 is paged is K*K , now in each page I
shall have again K entries therefore total K*K*K entries would be coming out from innermost page table 3 and it is
actually equal to no of pages in which my process would be divided therefore no of pages in virtual address space is
K*K*K and each page is of size 4KB therefore virtual address space =2^30*2^12 Bytes =2^42 Bytes hence no of bits in
virtual address =42 bits

 0 votes -- radha gogia ( 4369 points)

6.417 How many entries will be present in one page of inner page table in
below question ? top gateoverflow.in/20139

In 2 level paging say I have an inner page table which is of size 2^22 Bytes ,Now page size is of 4KB , so no we will divide this page table into pages ,so no of

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 742 of 2244

pages =2^10 ,Now in outer page table entries =2^10 , now my confusion is that how many entries will be present in 1 page out of the 2^10 pages in the inner page
table,assuming that each entry is of size 4Bytes.


Selected Answer

i think its 2^20..no need to devide into pages.

here page table size=2^22

page tables size= bytes ofr each entry * no of entry

so no of entry is 2^20

 1 votes -- akash ( 735 points)

6.418 what is the relation between internal and external fragmentation ? top
gateoverflow.in/19985

whenever we have internal fragmentation then we always have external fragmentation so but not vice-versa so is internal
fragmentation a sufficient condition for external fragmentation , I guess it won't be a necessary condition since if there is no
internal fragmentation then we can't say whether we have external fragmentation or not .

Here, It is not necessary that if there is internal fragmentation, then there is definitely external fragmentation. e.g Paging
where there is no external fragmentation but there is chance to have internal fragmentation.
Also this can be conversely also true that if there is external fragmentation then it is not necessary that there will be
internal fragmentation. Like in segmentation

 0 votes -- Avdhesh Singh Rana ( 1509 points)

6.419 What is counting method for free space management ? top gateoverflow.in/19978

How to solve the above ques ?

In counting method each entry consit of first free block n then no of contiguous block which are free after it So we have 3
free blocks here(i m assuming address start from o) Address count 1. 4 2 2. 8 0 3. 9 2

 1 votes -- Pooja ( 22773 points)

6.420 process top gateoverflow.in/19942

If a process on the system could issue an I/O request then the process will be placed on which of the following ?

a)Ready State

b) Running state

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 743 of 2244

c) ready queue

d) I/o queue

operating-system


Selected Answer

D) i/o queue ...

The process could issue an I/O request and then it would be placed in an I/O queue. after complete the request it will come in
ready queue ...

ref: http://www.tutorialspoint.com/operating_system/os_process_scheduling.htm

 0 votes -- sonam vyas ( 6441 points)

6.421 Threads top gateoverflow.in/19989

Which of the following should be allowed in kernel mode ?

1) Changing mapping from virtual address to physical address

2) mask and unmask Interrupts

3) disabling interrupts

4) reading status of a procesor

5) Reading timeof day

which one is correct ?

a) 1 2 3 b ) 1245 c) all of these d ) 235

I think its a reading of clock and reading of status of process can be done un user mode address translation is done in
kernel mode and masking unmasking disabling interrupts is done in kernel mode

 0 votes -- Pooja ( 22773 points)

6.422 disk scheduling top gateoverflow.in/19991

Consider a disk with the 100 tracks numbered from 0 to 99 rotating at 3000 rpm. The number of sectors per
track is 100 and the time to move the head between two successive tracks is 0.2 millisecond.
a. Consider a set of disk requests to read data from tracks 32, 7, 45, 5 and 10. Assuming that the elevator algorithm is
used to schedule disk requests, and the head is initially at track 25 moving up (towards larger track numbers), what is
the total seek time for servicing the requests?
b. Consider an initial set of 100 arbitrary disk requests and assume that no new disk requests arrive while servicing these
requests. If the head is initially at track 0 and the elevator algorithm is used to schedule disk requests, what is the
worse case time to complete all the requests?

Following are my answers after solving
a) I get the answer [161 ∗ .2] = 32.2ms
diskseeksusingelevator(25 → 32 → 45 → 99 → 10 → 7 → 5) = 161seeks .

b) Worst case means all disk requests are in different tracks

(0 → 1 → 2 → 2 ⋅ ⋅ ⋅ ⋅ ⋅ → 98 → 99)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 744 of 2244

worstcasetime = 100(.2 + RotationalLatency) = 100(.2 + 10) = 1020ms

IS this the correct way of solving this problem or am I missing something?

Please help


Selected Answer

a) 25-----32------45------99------10------7-------5

no of movements=168

so seek time=168*0.2=33.6 ms

B) worst case:

0--------99-------1--------98--------2.............. and so on

no of movements=99+98+97+.....1

=99*100/2

=4050

 0 votes -- Pooja ( 22773 points)

6.423 what part of memory does a bit-map take ? top gateoverflow.in/20062

If the memory is such that it is divided into various allocation unit and each allocation unit is of 32 bit and for each allocation
bit we make a bit 0 or 1 in the bit map if that allocation unit is actually a hole or is occupied by a process , so in general
space taken by bit map is 1/33 , how ?

I applied the logic that let there be x allocation units so 32*x=Total Memory size(M) , so I got x=M/32 , so if I have these
many allocation units that implies these many bits in the bit map and therefore this is the total size of bit-map , but then
why arewe including the size of allocation units as well ?

First lets calculate the memory wastage due to bitmap.

u have a allocation unit of 32 bytes. ok.

including the one bit for bitmap = (32+1)=33

now i am using 33 bits to represent one allocation as the in which one is the bit map bit.

now the total amount of memory wastage = 1/33

out of 33 bits 1 bit is wasted for bit map. so 1/33

 0 votes -- Ravi Singh ( 7303 points)

6.424 threads top gateoverflow.in/19996

is it easy to port threaded code ?

a) true

b) false

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 745 of 2244

Becoming easy. Also depends on the language. If you write in Java- it is easy as thread is supported in language itself. In
C/C++ it used to be supported with libraries but C++11 supports thread in language itself.

 0 votes -- Arjun Suresh ( 124125 points)

6.425 Suppose a system uses shortest job first scheduling and exponential
average of the top gateoverflow.in/31913

Suppose a system uses shortest job first scheduling and exponential average of the measured length of previous CPU burst
is 0.25. If the initial value of the predicted CPU burst time is 4 unit. The predicted time for 4 th CPU burst for a process with
burst time of 4 unit, 12 unit and 8 unit respectively (units) is ______.

operating-system made-easy test-series


Selected Answer

Pn+1 = alpha * T n + (1 - alpha) * P n

Given, alpha = 0.25, T 1 = 4, T 2 = 12, T3 = 8 and P 1 = 4

So, we have

P2 = 0.25 * 4 + 0.75 * 4 = 4

P3 = 0.25 * 12 + 0.75 * 4 = 6

P4 = 0.25 * 8 + 0.75 * 6 = 6.5

Answer is 6.5 units.

 1 votes -- prathams ( 1141 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 746 of 2244

7 Databases top
7.1 B: Minimum levels of B+ tree required for 5000 keys? top gateoverflow.in/39290

What is the minimum levels of B+ tree index required for 5000 keys and order of B+ tree node (P) is 10. (Assume P is the
max pointer possible to store in B+ tree node)

My answer was 3.

With: Keys <= (Internal Order)^levels * (Leaf Order)

i.e., 10^3 * 9 = 9000 >= 5000 .. So 3 levels req. But given answer is 4.

databases b b-tree indexing made-easy


Selected Answer

Mx no of keys in B+ tree of order 10 height H is :

10(H+1) - 1 = 5000
10(H+1) = 5001
H + 1= 4
H = 3
if we consider root at level 1 than level =height +1
so Number of levels = 4

other way:

order is 10 so each node can have at max 9 keys


at 1st level: key:9
2nd level: 10*9
3rd 10*10*9
4th level: 10 *10 *10*9

so Number of level = 4

 2 votes -- Pyuri sahu ( 1237 points)

7.2 B Tree: Why is there a need for Tree-based indexing mechanisms ? top
gateoverflow.in/17570

In DBMS, why is there a need for the use of tree based indexing algorithms, when we have multilevel indexes available for
use ?

databases b-tree


Selected Answer

Multilevel indexing are static . while b and b+ tree dynamic . the advantage is , databases are very much dynamic in
nature the data in the databases change a lot . so if we do multilevel indexing according to and instance and then the data
incresed the multilevel index will fail . so we need a dynamic thing like trees . they automatically grow and shrink as the
data varies.

 1 votes -- Ravi Singh ( 7303 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 747 of 2244

7.3 B Tree: In a B tree, Suppose the search Key is 9 bytes long, the disk
block size is 512 bytes... top gateoverflow.in/17567

Here, the value of p should be 24, not 23 as taken...also no reason is given for this assumption by the author (Navathe ).
Can anyone explain this ?

databases b-tree


Selected Answer

yes i think ans should be 24 , if there is any fraction then we choose the floor value (eg: 23.9 then 23 )

but i`m curious that they give the reason why 23 not 24 ("p=24 is not chosen because of the reasons given next"). please
upload that page . though to me 24 is correct .

 0 votes -- Pranay Datta ( 6113 points)

7.4 B Tree: Suppose for insertion in a b+ tree of order 3, the values are
inserted in order 73,108,100. top gateoverflow.in/17623

Suppose for insertion in a b+ tree of order 3, the values are inserted in order 73,108,100. What will be the structure of the
resulting tree? I have watched few lectures on b+ trees and in one of the lectures by a professor from IIT KGP , inserts in a
way that the resulting tree will be-

Then i watched some more lectures by some other professors and they recommended to insert in a way that will result in-

Which of the above methods should I use. I am confused as to me both seem right

b-tree databases

The basic concept is that leaf node should contain all the values . U can assign internal node to the left children or the
right children it's your choice the tranversal will be same . so such rule is there that u always have to assign it to left or
right. its like bst deletion , u may use the biggest child of left subtree or smallest child of right subtree

 0 votes -- Ravi Singh ( 7303 points)

7.5 B Tree: Minimum number of insertions to add a new level to this tree top
gateoverflow.in/32130

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 748 of 2244

b-tree

I think answer should be option A)3

1.add between 42 to 51 it will split the leaf node and internal node at second level e.g.43
2.then add one more key which split leaf node only and inserted at second level . e.g 41
3.now insert one more which will split at all level e.g. 40

 2 votes -- Umang Raman ( 10379 points)

7.6 B Tree: ISRO-2013-26 top gateoverflow.in/43933

Calculate the order of leaf (Pleaf) and non leaf (P) nodes of a B + tree based on the information given below.

Search key field = 12 field

Record pointer = 10 bytes

Block pointer = 8 bytes

Block size = 1KB

A. Pleaf = 51 & p = 46
B. Pleaf = 47 & p = 52
C. Pleaf = 46 & p = 51
D. Pleaf = 52 & p = 47

isro2013 databases b-tree

Answer c)

Pleaf

1*BP + (P leaf )*(key+Recrd Pointer) <= Block size

Pleaf<=46.18

Pnonleaf

P*Block Pointer +(P-1)*(Key) <= Block Size

Pnonleaf <=51.8

 0 votes -- srestha ( 11585 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 749 of 2244

7.7 B Tree: Why does a B tree contain only unique values , whereas a B+
tree can contain repeated values ? top gateoverflow.in/17566

I was reading the chapter on multilevel indexes , given in the Elmasi Navathe book. The following points have been given for
key values in b and b+ trees-

B trees-

and for B+ trees,

Why are values repeated in a B+ tree, but not in a B tree ? How is thing possible ? Can someone please explain this by
giving an example.

databases b-tree


Selected Answer

this is because we always maintain a copy of internal data in leafs in b+ tree. for further study. just take a book and read
first.

 0 votes -- Ravi Singh ( 7303 points)

7.8 B Tree: Max node in B+ tree top gateoverflow.in/32587

Maximum number of nodes in B+ tree possible with order 4 and height 6 is ___________.

Is the answer should be 1365 or 5461.

b-tree databases


Selected Answer

Ans. 5461

B+ Tree with Order 4 means maximum block pointer stored in a node is 4.

Bp
minimum 2
maximun 4

For Getting maximum number of node, we need to utilize maximum possible block pointer as a node in next level.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 750 of 2244

level Maximum Nodes Maximum Block Pointers


0 1 (root) 4
1 4 4*4 = 16
2 16 16*4 = 64
3 64 64*4 = 256
4 256 256*4 = 1024
5 1024 1024*4 = 4096
6 4096 4096 *4 = 16384
Total Nodes 5461

The height of a node is the number of edges on the longest path from the node to a leaf.So i have taken upto 6th level, so this way
root to leaf number of edges will be 6.

** 1365 is the maximum number of nodes up to 5th level i.e. height 5 of this type and 5461 is the maximum number of nodes up to level 6th
i.e. height 6.So both are not the correct answer.

 0 votes -- Sandeep Singh ( 5939 points)

7.8 B Tree: Can anyone please help with B+ tree multi level index structure
creation? top gateoverflow.in/127

b-tree databases


Selected Answer

This link gives good info about B+ trees:

http://courses.cs.washington.edu/courses/cse326/08sp/lectures/11-b-trees.pdf

 1 votes -- Arjun Suresh ( 124125 points)

7.9 B Tree: Space utilization of B + tree and B tree top gateoverflow.in/27140

What is the minimum and maximum space utilization of b+ tree and b tree?

databases b-tree

B+ tree min space utization=50%

B tree space utilization 66.6%

 2 votes -- Pooja ( 22773 points)

Dont know what is your quetion meaning

What i get which is get minmum utilization and which is get maximum utilization if used.

so Ans is degree of b+ tree of storing record is more so utilization is more.

degree of b tree of storing record is less than b+ tree so utilization is less.

 1 votes -- Anirudh Pratap Singh ( 4091 points)

7.10 B Tree: Minimum keys in a B-tree of order of 3 which has height = 3? top

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 751 of 2244

gateoverflow.in/9095

I think answer is 7 ,if not then pls explain .

b-tree


Selected Answer

It's 15....coz we need to go upto 4 level for getting height 3......

 3 votes -- Rupesh Kumar ( 121 points)

7.11 B Tree: B+ tree sum at height 1 top gateoverflow.in/32753

I am getting sum 22, answer given was 18.

Here is my B+ tree :

b-tree databases

7.12 B Tree: ISRO-2013-27 top gateoverflow.in/43938

The physical location of a record determined by a formula that transforms a file key into a record location is

A. Hashed file
B. B-Tree file
C. Indexed file
D. Sequential file

isro2013 databases b-tree

option a ) Hashed file is correct

For the rest you dont use any formula to determine physical location of records

 0 votes -- Dexter ( 1933 points)

7.13 B Tree: B+Tree top gateoverflow.in/32498

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 752 of 2244

1.Following key values are inserted into B+ tree where each node have 2 key values .The sum of keys present at height 1
(height is at 0) is 8,5,1,7,3,12,9,6 .

2.In a database field the search key field is 9 bytes long the block size is 512 bytes , a record pointer is 6 bytes and block
pointer is 7 bytes .The largest possible order of a non leaf node in B+ Tree implementing this file structure{order defines
max no. of keys present} is

b-tree

1st one i'm not getting it..

for 2nd :

given, search key field=9B

Record Pointer=6B ,

Block Pointer=7B

Block Size=512B

leaf node in B+tree:

Block_pointer+P*(Search_key_field+Record_Pointer) <=Block_Size "here P is order"

non-leaf node in B+tree:

P*Block_pointer + (P-1)*Search_key_field <=Block_Size

So, P*7 + (P-1)9 <= 512


16P <= 521

P<=32.5 means P=32

Order P=32 So max. number of key present in non leaf node is 32-1= 31 (Ans)

 1 votes -- Jaikishan Apurva ( 787 points)

7.14 B Tree: WHAT SHOULD BE THE ANS? top gateoverflow.in/16378

Consider a relation R (A B C) with attribute size of A as 8 bytes. Disk block size is 512 bytes and block pointer is 8 bytes. The
best choice for degree (maximum value) for B+ tree, if B+ tree was used for creating indexing on R(A B C) is__________

b-tree

8(n-1)+8n<=512

solving these u get

n=32

 1 votes -- Pooja ( 22773 points)

7.15 B Tree: If the order of a B-Tree is 20 , then the number of levels needed
to store 15 , 998 keys are? top gateoverflow.in/20443

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 753 of 2244

If the order of a B-Tree is 20, then the number of levels needed to store 15, 998 keys are ______.

databases b-tree

Level 0 19 keys

Level 1 19*20 keys

Level 2 19*20*20 keys

Level 3 19*20*20*20 keys

So 4 levels are required

 1 votes -- Pooja ( 22773 points)

7.16 Bcnf Decomposition: Bcnf decomposition proper procedure? top gateoverflow.in/36483

R(ABCDE)

{A→BC, CD→E, B→D, E→A}

How to convert it into bcnf?

I hv seen 2-3 ways to convert into bcnf.

And i dont find it possible to convert into bcnf with dependency preserving.

Is there any proper procedure works for all cases?

Lossless join for a database in bcnf is tht joining of the decomposed table or relation will give complete relation set.

Plz someone explain it

databases functional-dependencies bcnf-decomposition database-normalization

Follow any valid method but remember Dependency Preservation is not compulsorily required. Only thing compulsory is
lossless join which you know.

Therefore,conversion to BCNF will not always be Dependency Preserving but we still go for it.

If you still want to Preserve the Dependency, we arbitrarily add the attribute whose dependency was lost.

For example, say B > D was lost in BCNF, and say we have a relation(table) now which has A and D as the attributes,
then we arbitrarily add B attribute to this relation(table). NOTE: This addition doesn't violates anything. This way
now B>D is now applicable to this relation(table) and hence FD is preserved.

 0 votes -- Harsh Patil ( 31 points)

7.17 Candidate: Candidate Key top gateoverflow.in/37808

Here candidate keys are {A,BC}.

Why BC ? It has two attribute . why not only A it has only one attribute and which is minimal superkey?

Can someone explain?

R[A,B,C,D,E,F]
A->BCDEF

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 754 of 2244

BC->ADEF
D->E
D->B
B->F

databases candidate key

There can be Keys(CK) apart from A but not including A since a dding any more attributes to A(CK) would only lead to
SK. .

Therefore, though A is a CK, BC can also be a CK since BC doesn't contain A which would otherwise lead to SK.

The main point here is that there can be more than 1 CK for a relation. And since BC doesn't contain A, which is a key in
itself, BC is also a CK.

 0 votes -- Harsh Patil ( 31 points)

7.18 Canonical Cover: Decomposition top gateoverflow.in/20483

Consider following set of FDs on R(A, B, C, D, E, F)

A → BCD

BC → DE

B→D

D→A

1. Compute the canonical cover.


2. Give 3NF decomposition of R based on canonical cover.
3. Give BCNF decomposition of R based on original set of FD.
4. Can you get same decomposition of R as above using canonical cover?

databases database-normalization canonical-cover

We always decompose after getting canonical cover.

Canonical Cover :

A → B
A → C
B → E
B → D
D → A

after decomposition into 3NF:

Since, F is not functionally dependent on a key, there exists some redundancy in storing data. Hence, BCNF not possible
but 3NF is.

 2 votes -- Amar Vashishth ( 17865 points)

1.A−>BC
B−>DE
D−>A
CK{AF , BF, DF}

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 755 of 2244

2.R1(ABCDE)R2(AF)

3..R1(ABCDE)R2(AF)

4..R1(ABCDE)R2(AF)
Verify once!

 1 votes -- Umang Raman ( 10379 points)

7.19 Canonical Cover: Canonical cover of a set top gateoverflow.in/37579

Consider the following set of functional dependency on the scheme (A, B,C) A-->BC, B-->C, A--> B, AB-->C The canonical
cover for this set is:

(A) A-->BC and B--> C

B. A-->BC and AB--> C

C. A--> BC and A--> B

D. A--> B and B--> C

functional-dependencies databases canonical-cover decomposition


Selected Answer

A->BC ==> A->B A->C

B->C

A->B

A B->C [Extraneous attrib removed] ==> A->C

[A->B A->C B->C ] A->C is redundant

A->B

B->C

D is the answer.

https://www.youtube.com/watch?v=Q8j4lYeVIek​

 3 votes -- bahirNaik ( 2479 points)

7.20 Canonical Cover: Find canonical cover for the given set of functional
dependencies. top gateoverflow.in/13929

Consider the following set of functional dependency on the scheme (A, B,C)
A→BC, B→C, A→B, AB→C

The canonical cover for this set is:


A. A→BC and B→C
B. A→BC and AB→C

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 756 of 2244

C. A→BC and A→B


D. A→B and B→C

databases canonical-cover functional-dependencies


Selected Answer

In the given FDs,

1) Convert elements on LHS as singleton

Thus, A -> BC can be written as A-> B and A->C

2) Remove composite attributes from LHS

Here, AB -> C can be written as A -> C, because we have an FD {A -> B}.

3) Remove redundant attributes

We have FD = {A -> B, A -> C , B -> C}

this is a transitive depenency A -> B -> C. After remove redundancy, we get A->B, B->C.

Option D is the required answer

 3 votes -- Shefali ( 765 points)

7.21 Canonical Normal Form: F = {X -> YZ, Y -> XZ, Z -> X} How many no.
of minimal and canonical covers are possible? top gateoverflow.in/13745

Answer is 2 minimal and 2 canonical covers.

Please give full explanation of how to solve.

functional-dependencies databases canonical-normal-form

Miinimal (canonical) cover of a set of FDs is the minimal set of FDs such that all other FDs can be derived.

So, {X -> Y, Y -> Z, Z-> X}, {X->Z, Z-> Y, Y->X}

 1 votes -- Arjun Suresh ( 124125 points)

7.21 Cartesian Product: consider relation R1(A,B) and R2(C,D) ,where R1


contain 'm' tuples and R2 contain 'n' tuples and R1,R2 contain no common
attribute and attribute B have NULL values then what is the number of
tuples in cartesian product of R1 and R2? top gateoverflow.in/6664

cartesian-product

i think its mxn.. I find no reason why null make a difference

 1 votes -- Bhagirathi Nayak ( 10239 points)

7.22 Concurrency: No of operation to make schedule non serializable. gateoverflow.in/29637

top

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 757 of 2244

Consider the following schedule

S: r1(B);w2(C);????;w3(C);w1(D);w2(E)

The possible operations on S are read, write, Increment, Multiply respectively (Increment, Multiply by constant)

1. How many actions can be placed in the given schedule S such that S become non-serializable as T1→T2

a) 5 b) 7 c) 9 d)11

2. How many actions can be placed in the given schedule S such that S become non-serializable as T2→T1

a) 5 b) 7 c) 9 d)11

databases concurrency

7.23 Concurrency: Concurrency Problems top gateoverflow.in/10297

T1 T2
R(A)
R(A)
R(B)


R(B)
W(A)
COMMIT

R(A)
W(A)
COMMIT

in the above problem identify the concurrency in the following Schedule involving 2 Transaction T1 AND T2 (r: read and w :
write )

a) Dirty Read problem

b) Unrepeatable Read problem

c) Lost update Problem

d) Both a and b

concurrency

Dirty read ( uncommitted W-R ) : does not exist here.


Unrepeatable read ( R-W ) : exists. As R(A) is read in T1 and W(A) is done in T2.
Lost update ( W-W ) : does not exist here'


So , Unrepeatable read exists here.

 1 votes -- Shounak Kundu ( 3757 points)

7.24 Concurrency: Consistency preservation top gateoverflow.in/19220

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 758 of 2244

concurrency

User has to ensure consistency..atomicity ensured by transcation manager and durability to be ensured by recovery
manager and isolation to be ensured by concurrency control system

 0 votes -- Pooja ( 22773 points)

7.25 Conflict_serializable: transactions top gateoverflow.in/38887

schedule
R(A)
R(B)
R(B)
W(A)
COMMIT
R(C)
R(B)
W(C)
W(B)
R(A)
R(C)
COMMIT
COMMIT

The above scedule is -:

a)conflict serializable

b)recoverable

c)cascadeless

d)all of these

according to me a)&b)

answer given -:a)

transactions databases conflict_serializable


Selected Answer

it is Conflict Serial as T 1 ---> T3 ---> T2 or T3 ---> T1 ---> T2 .


But Schedule is Irrecoverable bcoz of Dirty Read : W3(C) and R 2(C) and T 2 commit before T3.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 759 of 2244

 5 votes -- Digvijay Pandey ( 26245 points)

7.26 Conflict_serializable: How many interleavings of these transactions are


conflict serializable? top gateoverflow.in/38077

Consider the following two transactions.

T1: R(A) W(A) R(B) W(B)

T2: R(A) W(A) R(B) W(B)

How many interleavings of these transactions are conflict serializable?

transactions conflict_serializable databases

http://gateoverflow.in/37446/number-of-conflict-serializible-schedules

 0 votes -- Digvijay Pandey ( 26245 points)

7.27 Conflict_serializable: No. of conflict Serializable Schedules? top gateoverflow.in/42373

Two Transactions T1 and T2 are given as follows:

T1: R1(A), W1(A), R1(B), W1(B)

T2: R2(A), W2(A), R2(B), W2(B)

Find the total no. of conflict serializable schedules that can be formed by t1 and t2?

transactions databases conflict_serializable concurrency

http://gateoverflow.in/37446/number-of-conflict-serializible-schedules

 0 votes -- Manojk ( 3365 points)

7.28 Conflict_serializable: Serial schedule for the given schedule top gateoverflow.in/19257

conflict_serializable


Selected Answer

Cycle exists in precedence graph so schedule is not conflict serializable

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 760 of 2244

 0 votes -- Pooja ( 22773 points)

7.29 Data: data cube top gateoverflow.in/44272

data cube

Maximum number of cells possible in the base cuboid=pn

According to question here is no concept of hierarchy associated with dimensions

So here we need to consider aggregate cell also so dimensions=p+1(for base+aggregated dimensions )

Now maximum number of cells possible=(p+1)n.

 0 votes -- Manojk ( 3365 points)

7.30 Data: data cube top gateoverflow.in/44271

data cube

7.31 Data Isolation: Final values after isolation level READ COMMITTED and
READ UNCOMMITTED top gateoverflow.in/38548

How to solve this question?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 761 of 2244

databases data-isolation

Hi , i would like to attempt

Anyone please verify this

As we are aware that there are 4 isolation defined for it

1) Repeatble uncommited

2) Repeatable Read

3)Read Committed

4)Serializable

Now in Read committed , if a transaction want to work on a data item X , it will request for shared lock it wont start
immediately , it will wait for the other transaction if it working on same data item say T2 here , As soon as T2 is done , it
will gain a control over it and start exceuting . while this is running if any other transaction want to modify it will wait for
exclusive lock ,

Now in Read Uncommitted :Doesnt required any shared lock also . It will operate on data item if any other transaction to
update is working on it or reading . It is lowest Isolation level and even forgiving one.

So now if you see in the above example

Q17)T2 is having read uncommitted isolation level

so if Ti is working on it (T1 is either reading or writing ) t2 hardly have concern so

t2 wll get set 2000 where stipened >2000 (assuming now T1 has excutted partally and t2 starts )

T1 is having READ COMMITTED : here T1 before doing operation request for shared lock on data item ,it check for any
other transaction who is updating data or working . if yes it wait .Here T2 is working so it wait . now if t1 has a lock and
other transaction want to update it , it will wait unless t1 release

So t1 may have 2200 (if it read value from t2)

t1 may have 2100 ( if t1 starts first it will acquire lock , now here at the same time if t2 starts it will set 2000 and again t1
will excute second update and set it to 2200)

t1 may get 2300 ( if t1 starts and t2 doesnt start only . it start after t1 have completed. but it says both start at approx
sam time .so no choice of 2300 )

Or if t2 has set to 2000( t2 doesnt care about other transaction processing ) and now just t1 after acquiring lock will
have 2200 and 2400.

So in all possible cases 2300 is not possible .

Q18) Now in Repeatable read : If the transaction acquires lock it will read and release only after transaction ends .So that
it get the same set of values everytime . Cant see any intermediate value of other transaction .

So suppose if T1 exceuted in Repeatable read and at the same t2 is Read commited . Incase if T1 got lock first , T2 cant
excute beacuse it always wait for other transaction who is working on same variable

So T1 update it to from 1900--2100-2300

And now t2 after t1 will set stipend to 2000 ( since 2300>2000)

now if t2 got first lock as comapred to t1

then it will have stipend set 1900 ( since 1900>2000 ) and then after t1 get a chance 1900-2100-2300

So 2200 is never possible in question no 18

Please check and let me know !

 0 votes -- Dexter ( 1933 points)

7.32 Database : Which of the following is true top gateoverflow.in/17319

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 762 of 2244

Consider the schema R (A, B, C, D) and the functional dependencies A->B and C->D. if the decomposition is made as R1(A,
B) and R2 (C, D) then which of the following is TRUE

A) preserves dependency but cannot perform lossless join

B) preserves dependency and performs lossless join

C) doesnot perform dependency and cannot perform lossless join

D) doesnot preserve dependency but perform lossless join

database- functional-dependency


Selected Answer

Decomposition is dependency preserving.

It is not lossless as there is no common attribute on which two sub relations can be joined to get original one

So ans is a

 0 votes -- Pooja ( 22773 points)

7.33 Database Constraints: y not D y A? kindly explain bcz integrity


constraints means no data should loss then how A ans here? top gateoverflow.in/12060

The student marks should not be greater than 100. This is

(A) Integrity constraint


(B) Referential constraint
(C) Over-defined constraint
(D) Feasible constraint

databases database-constraints

Integrity constraint is meant for "integrity" of data and mark <= 100 is part of it. By English meaning D option can be
right but in Database, is there something like "Feasible Constraint"?

Integrity Constraint is not meant to avoid data loss.

Ref: http://www2.amk.fi/digma.fi/www.amk.fi/opintojaksot/0303011/1146161367915/1146161783414/1146163065754/114616316796

 1 votes -- Arjun Suresh ( 124125 points)

7.34 Database Normalization: normalization top gateoverflow.in/9658

Let R(ABCDE) be a relational schema and F ={AB->CD, ABC->E,C->E} BE A SET OF FUNCTIONAL dependencies.

WHAT IS highest normal of R ?

1NF

2NF

3NF

BCNF

database-normalization


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 763 of 2244

AB is candidate key..
AB-----> CD, AB is key so BCNF
ABC ------> E , No partial dependency but E as well as C is not prime so 2NF..
C---->E, non key -----> non key so 2NF..
so overall relation is in 2NF..

 4 votes -- Digvijay Pandey ( 26245 points)

7.35 Database Normalization: Consider table R(A,B,C,D,E) with FDs as A->B,


BC->E and ED-> A. The table is in which normal form? Justify your answer.
top gateoverflow.in/1285

WHICH OF THE FOLLOWING IS FALSE ?

1)DNS IS A CLIENT SERVER APPLICATION

2) DNS TREE HAVE ONLY 64 LEVELS

3)DNS ORGANISE THE NAMESPACE IN HIERARCHICAL STRUCTURE

4) DNS USE THE UDP FOR SOME MESSAGES WHILE SOME FOR TCP .

databases database-normalization normal


Selected Answer

First step: Identify the candidate keys. Candidate keys must be able to determine all other attributes. Most of the time
they can be found by just looking at the FDs. Here,

EDC is a candidate key so are ACD and BCD.

Now, just check for the conditions of each normal form.

We can see A->B.


ACD is the candidate key and A is a partial key. But B is a prime-attribute (part of a candidate key). Hence, this is not a
partial functional dependency.

Similarly in BC->E and ED->A, E and A are prime-attributes and hence both are not partial functional dependencies.
Hence R is in 2NF.

Now 3NF states that every non-prime attribute must be dependent on the candidate key. In the given functional
dependencies, all dependent attributes are prime-attributes and hence it is trivially in 3NF.

Now BCNF requires that for every FD α − > β, α must be a super key (candidate key or its superset). This condition is
violated by all the 3 FDs given and hence R is not in BCNF.

So, 3NF is the highest normal form table can be in.

 7 votes -- gatecse ( 9515 points)

7.36 Database Normalization: normalization top gateoverflow.in/9654

Consider the relation R(ABCD) with FD's set F={ AB->CD,C->.A,D->B}

which of the following is false ?

1.C->A is a partial Dependency

2.C->A is a transitive Dependency

3.D->B IS A Partial dependency

4. All of these

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 764 of 2244

database-normalization


Selected Answer

A,B,C,D all are prime attribute so no partial as well as no transitive dependencies..

 3 votes -- Digvijay Pandey ( 26245 points)

Here AB , BC , CD , AD are candidate keys.

So , A , B , C , D all are part of prime attributes.

So , the relation is in 3NF .

So , ans is (d) : all are false

 1 votes -- Shounak Kundu ( 3757 points)

7.37 Database Normalization: normalization top gateoverflow.in/9659

Can you explain me this :

A table is in second normal form if every attribute is determined by every candidate key , but is not determined by any pure
subset of Candidate key ?

True or false

database-normalization

A relation is not in 2NF if it is suffering from partial dependency..


Partial dependency means proper or pure subset of candidate key produces non prime attribute...
non key ---> non key allowed in 2NF.
Proper Subset of candidate key -----> non prime : Partial Dependency.
A candidate key always determines each and every attribute of relation...

 2 votes -- Digvijay Pandey ( 26245 points)

7.38 Database Normalization: Determining the highest bnormal form the


table can be decomposed to top gateoverflow.in/33678

given the following relation, give the highest normal form the relation can be decomposed to.

relation R(N, S, C, Z) ;

N=>SCZ,

{S,C}=>Z,

Z=>SC

A) 1nf

B) 2nf

C) 3nf

D) BCNF

database-normalization databases

it should be in 2nf as N is the single attribute key (No partial dependency

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 765 of 2244

) and rest attributes(SCZ) can be derived from it

now since this table has transitive dependency as N->Z and Z->SC so it can't be in 3NF

 0 votes -- Sanjay Sharma ( 799 points)

7.39 Database Normalization: Normalisation top gateoverflow.in/9653

A functional dependency X->y is trivial if y⊆x right ??

database-normalization

Yes. Actually this shouldn't be a question if one understands the meaning of "trivial". Trivial basically means "the question
has no need". One example of a trivial property is:

Do human beings have brain?

There is no need to answer this question as it is trivially true- because all human beings have brain.
Now a non-trivial property would be

Do human beings have intelligence?

Now, this need not be true for all human beings and hence non-trivial.

Now, coming to functional dependency we say A- > B, when the same A element always causes the same B element. i.e.,
whenever A element repeats B element also repeats. If A is a composite set (x,y) coming from attributes X and Y and B is
the attribute Y (hence B ⊂ A), we are sure than whenever the A element repeats the B element also repeats. That is, the
functional dependency cannot be violated whatever be the elements - hence TRIVIAL.

 4 votes -- Arjun Suresh ( 124125 points)

ya.. functional dependency X->y is trivial if y⊆x..

 4 votes -- Digvijay Pandey ( 26245 points)

7.40 Database Normalization: is the following relation is in BCNF form gateoverflow.in/11354

top

r={a,b,c,d,e}

a->b

bc-> e

ed -> a

database-normalization


Selected Answer

The candidate keys are ACD, BCD and CDE.

So all attributes are prime attributes and it is in 3 NF.. but not in BCNF as any of the determinants is not super keys (even
one is sufficient to disprove BCNF Condition).

 3 votes -- Digvijay Pandey ( 26245 points)

7.41 Database Normalization: Is the following relation is in BCNF ? if not


convert it top gateoverflow.in/11526

r={A,B,C,D}

B->C

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 766 of 2244

D->A

database-normalization


Selected Answer

it`s not in bcnf because left hand sid should be a key ( super or candidate key ) .

{ bc } { da } { bd }

 2 votes -- Pranay Datta ( 6113 points)

7.42 Database Normalization: Is the following type of dependencies allowed


in 3NF- ? top gateoverflow.in/15798

Is the following type of dependencies allowed in 3NF- ?

A-->B

where A is a proper subset of CK


and B is proper subset of another CK.

databases database-normalization


Selected Answer

Yes it's in 3NF because 3NF allows those FD's X --> Y in which either :

a) X is a super key, or

b) Y is a prime attribute //(Y is prime implies X must be prime i.e. Prime ---> Prime)

So, in the given FD, B is a prime attribute. Hence, it's in 3NF

 0 votes -- Vivek sharma ( 1177 points)

7.43 Database Normalization: BCNF top gateoverflow.in/19185

A Relation R(A, B, C, D, E) with FD set F = {A → BCD, BC → D, D → B} is given. Decompose to BCNF.

database-normalization


Selected Answer

Here AE is the candidate key

The given relation is not in BCNF

So Decomposition to BCNF but we will loss the dependency preserving


R1(ABC)
R2(BD)
R3(CD)
R4(AE)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 767 of 2244

 2 votes -- Umang Raman ( 10379 points)

7.44 Database Normalization: Normalisation top gateoverflow.in/43607

Hi

I am currently refering To IIT KGP lectures for DBMS . ( Normalisation to be specific ) . here the sir has tried to give an
alternative definition of 3NF .

We know that a 3NF is one in which non key attribute of a relation must not be fully functionally dependent on other Non
key attribute of a relation . But apart from this definition he said an alternative definition ( all the 3 bullets ) . Can anyone
just verify my given below explanation ?

database-normalization

7.45 Database Normalization: What is the best way to check for 3nd, BCNF,
partial and transitive and partial dependencies ? top gateoverflow.in/31082

I am revising DBMS for the GATE exam... Often I find it confusing that which dependency should be considered as partial ,
which should be considered as transitive..due to which my deductions about the normal form turn out to be incorrect..i have
looked up many sources on the web but all of them are too subjective and also not consistent...
Can someone please give me a resource from where I can learn about this clearly and get my doubts cleared .
Thanks

databases database-normalization

7.46 Database Normalization: Which of the following decomposition is NOT


lossless? top gateoverflow.in/31661

Suppose we have a relation R(X, Y, Z, W) with the FD's:

X → Y, Y → Z, Z → W

Which one of the following decompositions is not lossless (i.e., for some instance of R, the natural join of the decomposed
relations is not equal to R?

a. R1 (X, Y), R2 (Y, Z), R3 (Z, W)


b. R1 (X, Y), R2 (X, Z), R3 (X, W)
c. R1 (X, W), R2 (Y, W), R3 (Z, W)
d. None of the above (that is they are all lossless)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 768 of 2244

databases database-normalization


Selected Answer

Answer is right .
in table R1 R2 and R3, only W is common and it is not superkey for any table. Hence, C is not lossless (is lossy).

 3 votes -- Umang Raman ( 10379 points)

7.47 Database Normalization: Determine the highest possible normal form of


the given relation? top gateoverflow.in/31171

Given R(ABCD) and

AB → C ;

ABD → C ;

ABC → D ;

AC → D

which the highest possible normal form for the above relation ?

database-normalization databases


Selected Answer

Any relation is not in 2NF iff PROPER SUBSET OF CANDIDATE KEY determines NON PRIME ATTRIBUTE..
AB is key here & there is no FD which Violate 2NF definition.
it is in 2NF but not in 3NF..

 4 votes -- Digvijay Pandey ( 26245 points)

Above relation is in 1 NF

Here (AB)+ =ABCD

So, AB is the candidate key and ABD,ABC are super key

here in,AC→D , AC is nonprime attribute partially dependent on prime attribute ABC

So, it is not even 2NF, it will be 1NF

 4 votes -- srestha ( 11585 points)

7.48 Database Normalization: decompose to 3nf top gateoverflow.in/19184

database-normalization

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 769 of 2244

I think we can decompose to BCNF but it will violate the dependency preserving.
Here AC is the candidate key
BCNF decomposition
R1(ABC) (AC is the candidate key ) R 2(BCD) (BC+ is the candidate key) R 3(DE) ( D+=DE D is the candidate key)

AC->BC BC->D D->E


Further no decomposition is possible ! I guess. So option B


 0 votes -- Umang Raman ( 10379 points)

7.49 Database Normalization: ISRO-2013-25 top gateoverflow.in/43861

Consider the following dependencies and the BOOK table in a relational database design. Determine the normal form of the
given relation.

ISBN → Title

ISBN → Publisher

Publisher → Address

A. First Normal Form


B. Second Normal Form
C. Third Normal Form
D. BCNF

isro2013 databases database-normalization

The relation is in second normal form .

We first need to find Candidate key by taking closure of attributes = ISBN

Now with ER modelling we get relation in 1 NF .

for 2nf , we shouldnt have any partial dependency ( A non key shouldnt be fully functionally dependent on a subset of Ck )

Since our Ck is 1 attribute only we wont have that partial dependency

But now for 3nf , if you see we have Address which is transitively dependent on ISBN . Hence Transitive dependency exists
.

So relation is in 2nf and not in 3nf

 2 votes -- Dexter ( 1933 points)

7.50 Database Normalization: Which normal form is considered adequate for


relational database design? top gateoverflow.in/20667

Which normal form is considered adequate for relational database design?

A. 2NF B. 3NF

C. 4NF D. BCNF

database-normalization

Answer- Option D BCNF

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 770 of 2244

 0 votes -- sdpshaw ( 99 points)

7.51 Database Normalization: Number of invalid functional dependency top


gateoverflow.in/32561

Given the following functional dependencies

{X → W, X → Y, Y → Z, Z → PQ}

Consider the FD set implied using above FD set.

Implied FD set = {X → Z, X → WY, X → WZ, X → YQ, Y → P}

The number of functional dependencies in implied FD set are invalid are ______________.

database-normalization databases


Selected Answer

All fds are valid x->y and y->z apply transitivity x->z

..x->y and x->w apply union rule x->wy

X->z and x->w union rule gives x->wz

X-y and y->pq( transitivity)

Y->p decompisition rule

So x->yq

Y -> z and Z->p so y->p using transitivity

So ans is 0

 3 votes -- Pooja ( 22773 points)

7.52 Database Normalization: Which normal form is considered adequate for


relational database design? top gateoverflow.in/15777

Which normal form is considered adequate for relational database design?


A. 2NF B. 3NF C. 4NF D. BCNF

The solution is given as 3NF, although it is known that BCNF offers 0% redundancy on FDs.

databases database-normalization

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 771 of 2244


Selected Answer

BCNF doesn't guarantee dependency preservation.

 1 votes -- Digvijay Pandey ( 26245 points)

7.53 Database Normalization: 3NF is inadequate in situations where the


relation: top gateoverflow.in/15775

3NF is inadequate in situations where the relation:


A. has multiple candidates key
B. has candidate key that are composite
C. has overlapped candidate keys
D. all the above

databases database-normalization

Its D -all the above, all three conditions can favour BCNF

 0 votes -- admin ( 1411 points)

7.54 Database Normalization: If every non-key attribute is functionally


dependent on the primary key then the relation will be in top gateoverflow.in/15778

If every non-key attribute is functionally dependent on the primary key then the relation will be in

A. 1NF B. 2NF C. 3NF D. 4NF

I think the answer should be 2NF, but in the key it is given 3NF

database-normalization databases

Should be 2NF.

A--->B, B--->C , A--->C here A is key and relation is in 2NF.

 1 votes -- Digvijay Pandey ( 26245 points)

7.55 Database Normalization: What is the highest normal form of the table T
? top gateoverflow.in/27801

Consider a database table T with attributes A,B,C,D,E and a set of functional dependencies :

FD = {AE -> BC, AC -> D, CD -> BE, D -> E}.

What is the highest normal form of the table T?

(a). 1NF.

(b). 2NF.

(c). 3NF.

(d). BCNF

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 772 of 2244

database-normalization


Selected Answer

AE -> BC BCNF As AE is CK

AC -> D BCNF as AC is CK

CD -> BE 2NF Because CD is Non Key & BE is not prime attribute.

If we break it into CD-> B -> 2NF B is not prime & CD-> E this is 3NF, E is prime

D -> E, E is prime so 3NF.

So as CD-> B is in 2NF, whole relation is in 2NF.

 1 votes -- Akash ( 26315 points)

7.56 Database Normalization: Which of the following is correct for 3nf and
bcnf? top gateoverflow.in/17006

Consider the following statements.

1. If relation R is in 3NF and every key is simple, then R is in BCNF


2. If relation R is in 3NF and R has only one key, then R is in BCNF

A. Both 1 and 2 are true


B. 1 is true but 2 is false
C. 1 is false and 2 is true
D. Both 1 and 2 are false

databases database-normalization


Selected Answer

In 3NF, for any non-trivial FD

X -> Y

either X should be a super key of Y-X must be a prime attribute (part of some candidate key).

In BCNF, for any non-trivial FD

X -> Y

X should be a super key.

So, from 3NF to BCNF we lost one condition and if a relation is in 3NF but not in BCNF then this condition must hold. i.e.,
for some non-trivial FD,

X -> Y,

X is not a super key and Y-X is a prime attribute.

Now, lets take the first condition given. It says every key is simple. So, any prime attribute is a candidate key. Thus, for
any X -> Y, we have X is not a super key, and Y-X is a candidate key. Now, if Y-X is a candidate key, Y must be a super
key and from X -> Y, X must also be a super key.

For the second case, we have only one key (implied to be candidate key). Suppose, there exist a non trivial FD

X -> Y

with X not being a super key, and Y-X being a prime attribute. Now, X must contain a prime attribute here, as
otherwise it cannot determine any prime attribute. (Since Y-X is a prime attribute, replace it with X in the corresponding
candidate key and we get another candidate key). So, the only possibility is for X and Y to be part of the same key, and
then with X -> Y, that key will be a super key and not a candidate key- to make it candidate key we have to remove Y

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 773 of 2244

from it.

So, in both given cases 3NF implies BCNF. Actually only when a 3NF relation contains overlapping candidate keys, it
cannot be in BCNF. In all other cases, 3NF implies BCNF.

 0 votes -- Arjun Suresh ( 124125 points)

7.57 Database Normalization: BCNF and 3NF top gateoverflow.in/21210

1) dependency preservation
2)lossless join

a)If a relation is in 3NF , which of the above points is guaranteed.


b)If a relation is in BCNF , which of the above points is guaranteed

[ I am confused right now, can I say , if a relation is in BCNF, then is it by default lossless/dependency preserving straight
away , or is it the fact that,if I derive BCNF decomposed relations using a particular algorithm, then only I can say that the
decomposed relations is lossless/dependency preserving same goes for 3NF].

Please help!

databases database-normalization

R[A,B,C,D,E,F]
A->BCDEF
BC->ADEF
D->E
D->B
B->F
Decompose this into 3NF and BCNF and find the diff ;)

 0 votes -- Abhinav Rana ( 489 points)

7.58 Database Normalization: What is the highest normal form the given
relation is in ? top gateoverflow.in/31158

Given a relation R (ABCD), and the following FDs-

A->BCD

BC->AD

D->B.

which is the highest normal form the table is in.


a) 1NF
b) 2NF

c)3NF

d) BCNF

database-normalization databases


Selected Answer

Here A and BC,CD are keys

Lets see if its in bcnf

A->BCD it is not violating Bcnf as lhs is key

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 774 of 2244

BC->AD not violating bcnf as lhs is key

D>B violating bcnf as D is not key

Lets see if it satisfies 3nf

B in rhs is prime attr so it satisfies 3nf

So highest normal form satisfied is 3nf

 3 votes -- Pooja ( 22773 points)

7.59 Dbms: B+ Tree top gateoverflow.in/38752

What is minimum levels of B+ tree index required for 5000 keys and order of B+ tree node (P) is 10. (Assume P is max
pointer possible to store in B+ tree node)

Answer Given : 4

b-tree dbms

Since the maximum pointer is 10 the number of keys that could be stored is 9

At level 1 => 9 keys

At level 2 =>9*10 keys =90

At level 3 =>9*10*10=900

since we still need to store the keys we move for next level

At level 4 => 9*10*10*10=9000

so we need atleast 4 levels to store 5000 keys

 4 votes -- shivanisrivarshini ( 2067 points)

[Edit]

since each internal node can point to 10 nodes,

at each level, we have 10h nodes, where h is height of tree. now since all keys are accommodated at the leaf nodes, and
each leaf node can hold 9 keys,

10h × 9 ≥ 5000

h ≥ 2.7

hence height of B+tree would be 3, and number of levels would be 0,1,2,3 = 4

Answer is 4

PS: thanks for pointing out the mistkae

 1 votes -- ryan sequeira ( 1011 points)

7.60 Dbms: B+ Tree(order of Internal node) top gateoverflow.in/33514

The order of an internal node in a B + tree index is the maximum number of children it can have. Suppose that a child
pointer takes 3 bytes, the search field value takes 17 bytes, and the block size is 1024 bytes. The order of the internal node
is_______.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 775 of 2244

dbms b-tree


Selected Answer

suppose order N of internal nodes

so N(child pointer)+(N-1)(Search key) <= block size

3N+17N-17<=1024

So, N = 52

 3 votes -- kunal chalotra ( 3567 points)

Block pointer size = 3B


Search key size = 17B
Block size = 1024B
Let the order of the internal node of the B+ tree be p.
Therefore, p*Block pointer size + (p-1)*Search key size <= Block size
=> p*3 + (p-1)*17 <=1024
=> p<=52.05
=> p=52

Order of the internal node of the given B+ tree is 52.

 2 votes -- Monanshi Jain ( 5827 points)

7.61 Dbms: Sql query top gateoverflow.in/34158

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 776 of 2244

Q). Consider STUDENT table with the following tuples.

SNAME CPI

Deepak 8.7
Dilip 9.7
Kaustav 8.5
Pallab 9.8
Sourav 8.7
Swapnil 8.5


(select *
FROM STUDENT S1
WHERE 3> (SELECT COUNT(*)
FROM STUDENT S2
WHERE S1.CPI<=S2.CPI))
UNION
(SELECT *
FROM STUDENT S1
WHERE S1.CPI > ALL (SELECT CPI
FROM STUDENT S2
WHERE 5 >=(SELECT COUNT(*)
FROM STUDENT S3
WHERE S2.CPI <= S3.CPI)))

How many numbers of tuples are there in the output of the above query?

dbms databases sql

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 777 of 2244


Selected Answer

Ans - 2

Lets divide the queries in to Q1 U Q2

Q1 Select students who have not more than 3 students with cpi '>=' theirs

Q2 Select students who have cpi > ALL(subQ2). Similar to Q1 subQ2 selects students who have not more than 5 students
with cpi '>=' theirs

Q1 outputs Dilip and Pallab


subQ2 outputs Dilip, Pallab, Deepak and Sourav. So, Q2 outputs empty as none have cpi greater than Dilip(not even
himself)

So, result = 2 rows union phi. no intersection. So, ans is 2.

This(http://sqlfiddle.com/#!9/95e5e/7) might help to understand the chunking. Try deleting part of query and running

 2 votes -- Aditya Guru ( 115 points)

7.62 Dbms: referential Integrity top gateoverflow.in/33510

dbms


Selected Answer

c is foreign key referring to A, means if ( 4,3) is deleted , 4 will not be in C(foreign key) so tuple (2,4), (3,4), (6,4) will be
deleted then , now , Primary key value 2, 3 ,6 deleted so they also will not be in C as foreign key ... so tuple (5,2) , (7,2)
are removed now in similar way 5 , 7 are deleted so (9,5) also deleted so total additional 6 tuples will be deleted

 3 votes -- sonam vyas ( 6441 points)

7.63 Dbms: 3NF True/False top gateoverflow.in/33464

A relation R is in 3NF if every non-prime attribute of R is fully functionally dependent on every key of R

True/False

dbms database-normalization

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 778 of 2244

false....not on every key on R


if statement was A relation R is in 3NF if every non-prime attribute of R is fully functionally dependent on some key of R

then its true....

 0 votes -- Pooja ( 22773 points)

7.64 Dbms: Number of super_keys top gateoverflow.in/35483

databases dbms

since ph is multivalued attribute. it will have separate table.

in the table containing attribute salary, attributes can be eno,ename, dept,ndependent along with salary.

total number of superkeys= # superkeys when eno is key + #superkeys when ename is key

- # superkeys when both eno and ename as key

= 2^3+2^3-2^2

=8+8-4=12

 2 votes -- bhawanagupta15 ( 349 points)

7.65 Dbms: Indices top gateoverflow.in/35847

Q). Assume we have a table that describes subject details taught at gateforum

Class(SubjName,FacultyName,AvgRating,remarks)

There are three indexes on this table:

I1: Clustered B+tree on <FacultyName,remarks>

I2: Unclustered hash table on <SubjName>

I3: Unclustered B+tree on <AvgRating>

For the following Query which index is the best to use?

Select * from

Class

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 779 of 2244

Where AvgRating ≤ 5 AND AvgRating ≥ 4 AND FacultyName ="Raju"

(A) I1

(B) l2

(C) l3

(D) All indices l1,l2,l3 will be equally efficient for the given query

dbms

7.66 Dbms: no of triples.. top gateoverflow.in/25252

.WHAT IS TRIPLES????

dbms

Triples is of the form (a,b,c) where a∈A,b∈B and c∈C

A has 100 enteies B has 1000 and C has 10..

in relation R participation of A is many while of B and C is one

Relation between B to C us one one so no of BC pairs=10

Now each A can combine with 10 BC pairs resulting inro 100*10 =1000 triples

 3 votes -- Pooja ( 22773 points)

7.67 Dbms: # Block accesses top gateoverflow.in/35860

dbms

7.68 Dbms: Number of records resulted by following SQL query top gateoverflow.in/37138

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 780 of 2244

Can you please provide an elaborate explanation?

databases made-easy sql dbms


Selected Answer

EXISTS return false if its input is ∅. In the given query, input to EXISTS is COUNT(*) which returns an integer value ≥ 0,
but never NULL. So, EXISTS always returns TRUE here and we get 3 rows in output.

 1 votes -- Arjun Suresh ( 124125 points)

In exists query we need to select an attribute but in above it is count(*) so no exists is taken it is executed as normal
query which doesn't contain where condition so then it results all the 3 tuples

 1 votes -- shivanisrivarshini ( 2067 points)

7.69 Dbms: Sql query 1 kt top gateoverflow.in/36886

Table stud(sid, marks, branch, gender)

Query -retrieve branches for which male student's avg marks of each branch greater than avg marks of female students of
the same branch.

I think its query should be like-


Select distinct branch
From stud s1
Where gender=male group by branch
Having avg(marks)>(select avg(marks)
from stud s2
Where gender=female and s1.branch=s2.branch
Group by branch)

Is this query correct?

databases sql dbms

Yes, your query is correct. But is the question meaning

"retrieve branches for which male student's avg marks is greater than that of female students"

 0 votes -- Arjun Suresh ( 124125 points)

7.70 Dbms: SQL top gateoverflow.in/44038

what is the difference b/w following two query:-

SELECT distinct R.*


FROM R,S
where R.a = S.a;

SELECT R.*
FROM R,(select distinct a from S) as S1
where R.a = S1.a;

a is attribute and ***duplicate*** tuples are allowed

databases sql descriptive dbms

1)SELECT distinct R.*


FROM R,S
where R.a = S.a;

it will printed all distinct value of R

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 781 of 2244

2) SELECT R.*
FROM R,(select distinct a from S) as S1
where R.a = S1.a;

here duplicate tuple of R is possible

as we are selecting distinct value for S but not for R

 1 votes -- srestha ( 11585 points)

7.71 Dbms: SQL QUERY top gateoverflow.in/44037

what is the meaning of following query:

select R.*

from R,S

where R.a = S.a and is unique R;

sql databases dbms

7.72 Ddl: Navathe-Fundamentals of Database systems-basic SQL-sixth


edition-4.8 top gateoverflow.in/42113

Write appropriate SQL DDL statements for declaring the LIBRARY relational database schema of figure below. Specify the
keys and referential triggered actions.

databases sql descriptive ddl

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 782 of 2244

7.73 Decomposition: Given a relation R(A, B, C) with functional


dependencies set {A → B, B → C, C → B} top gateoverflow.in/6309

Given a relation R(A, B, C) with functional dependencies set {A → B, B → C, C → B}


(i) lossless decomposition is always possible for R
(ii) Dependency preserving decomposition is always possible for R.
Assume decomposition includes all the attributes of R. Which of the following is correct?
A) Both (i) and (ii) true
B) (i) is true and (ii) is false
C) (i) is false and (ii) is true
D) Both (i) and (ii) are false
Please explain your answer and what does Assume decomposition includes all the attributes of R mean?

functional-dependencies decomposition

Answer is A as it will always give a lossless decomposition with dependancy preservation

 1 votes -- nivedita.soni ( 21 points)

7.74 Decomposition: how to approach this type of question top gateoverflow.in/15354

i know how to find whether the decomposition is lossless or lossy . but in this type of question they are actually not defining
how they decompose . they are only giving a set of functional depenencies . how to solve this type of question

databases decomposition


Selected Answer

Given a relation and a set of FDs, we might never be able to form a BCNF decomposition (in any way) which preserves all
the dependencies. For example, in this question we are given a relation R(A, B, C, D).

a. A → B and B → CD are the FDs. We can decompose R to AB and BCD and all dependencies are satisfied and B is a key
of second relation meaning decomposition is lossless.
b. A → B, B → C and C → D. We can decompose R to AB, BC and CD.
c. No dependency preserving BCNF decomposition possible. Because to preserve C → A dependency we need to have C
and A in same relation as we can't imply this dependency using any transitive dependency. Similarly to preserve
AB → C, we must have ABC as a relation. But then in this decomposed relation AB and BC becomes the candidate keys
and C → A violates BCNF condition as C is not a super key.
d. A → BCD. No decomposition required. R is already in BCNF.

 0 votes -- Arjun Suresh ( 124125 points)

7.75 Decomposition: For which of the following set of functional


dependencies does the relation R(A,B,C,D) has AB,CD as closed sets gateoverflow.in/32378

top

For which of the following set of functions dependencies does the relation R(A, B, C, D) has AB, CD as closed sets?

a. A → B, B → A, C → D
b. A → B, B → C, C → D, D → A
c. A → B, B → A, C → A, D → A

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 783 of 2244

d. A → B, B → A, C → D, D → C

functional-dependencies decomposition

Answer is option (B)

AB, CD are closed sets imply, does AB, CD cover all the attributes of R (attribute closure)

In option (A),

AB closure is : { A B }
CD closure is : { C D }

In option (B),

AB closure is : { A B C D }
CD closure is : { A B C D }

In option (C),

AB closure is : { A B }
CD closure is : { A B C D }

In option (D),

AB closure is : { A B }
CD closure is : { C D }

Thus, answer is option (B)

 2 votes -- shiva ( 99 points)

answer should be D)

set of attributes are closed under functional dependencies iff closure of attribute set is set itself.

(A,B)+ = {A,B}

(C,D)+ = {C,D}

and inside closed set , if C ->D then D ->C should also need to satisfy.

Only D satisfies

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 784 of 2244

example :to say { a,b,c,d } is closed set.

{a,b,c,d}+ = {a,b,c,d}

let X , Y be any subsets of {a,b,c,d}

if X -> Y then Y -> X should present (directly or indirectly which we can infer from given functional dependencies.

 1 votes -- pramod ( 2071 points)

7.76 Decomposition: Find minimal cover from given functional dependencies


top gateoverflow.in/11276

A -> BC

CD-> E

B->D

E->A

functional-dependencies decomposition

there are three step to calculate minimal cover of fds

step1:we decompose each fd with single attribute in RHS side {A->B,A->C,CD->E,B->D,E->A}

step2:now heck for each dependencies it should or shouldn't present in set , for this we hide that particular FD for which i
m cecking and try to take closure of LHS side of that FD if we r able to derive the RHS side of that fd without using that
FD then that particular fd is not required in the set

for example for FD A->B we hide A->B and find closure of A+=A cant find B so we cant remove A->B from set thus we
check for all the FDS

step3: we combined those dependncies whose LHS are common

for this question we cannot remove any dependencies so minimal set is {A->BC,CD->E,B->D,E->A}

 0 votes -- saket nandan ( 1853 points)

7.77 Dependency Preserving: Is there an easy way to check whether a given


decomposition of a relation is lossless and dependency preserving ? gateoverflow.in/37247

top

Given relation and the FDs applicable on it. How to check whether a given decomposition is lossless and dependency
preserving?

I know that for lossless we can easily check by seeing if the common attribute in the decomposed relation is a key in one of
the relations. Will this be applicable is the common attribute is a proper subset of a key in one relation. ?

I dont know how to check for dependency preserving.. can someone please explain the steps for it ?

databases dependency-preserving

Will this be applicable is the common attribute is a proper subset of a key in one relation. ?

No. Common attribute must be a KEY.


I dont know how to check for dependency preserving.. can someone please explain the steps for it ?

Proper steps you can see in DBMS text. If you practice, in GATE you can see each decomposed relation and what all
dependencies they satisfy. Then, also consider transitive dependency and see if these cover all the dependencies of
original relation.

 0 votes -- Arjun Suresh ( 124125 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 785 of 2244

7.78 Dependency Preserving: Which of the above decomposition has/ have


lossless join property? top gateoverflow.in/37576

Consider a relation R= {M, N, O,P, Q, R, S, T} with the following set of dependencies:


MN--> Q
M--> RQ
N--> R
R--> ST
Next consider the following set of decompositions for the relation schema R:
D1= {R1,R2,R3,R4}: R1={M,N,O,P}, R2={M,P,Q}, R3= {N,R}, R4={R,S,T}
D2= {R1,R2,R3,R4}: R1={M,N,O}, R2= {P,Q}, R3= {N,R}, R4= {R,S,T}
Which of the above decomposition (s) has/ have lossless join property?
A. Only D1

B. Only D2

C. Both D1 and D2

D. Neither D1 nor D2

databases functional-dependencies dependency-preserving decomposition


Selected Answer

A = {R3= {N,R} JOIN R4={R,S,T} }, R is key of R4


B = A JOIN R1={M,N,O,P}, N is Key of A
B JOIN R2={M,P,Q} , MP is key of R2
So LOSSLESS..

D2= {R1,R2,R3,R4}: R1={M,N,O}, R2= {P,Q}, R3= {N,R}, R4= {R,S,T}


NOT LOSSLESS

 2 votes -- Digvijay Pandey ( 26245 points)

7.79 Dependency Preserving: find whether given relation is dependency


preserving top gateoverflow.in/11745

R={ABCDEG}

AB->C

AC->B

AD->E

B->D

BC->A

E->G

for the following relations {AB , BC ,ABDE, EG}

dependency-preserving

All dependency are not preserved .

from relation AB we can`t determined anything only trivial dependency AB -> AB A B

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 786 of 2244

from relation BC we can`t determined anything only trivial dependency BC -> BC B C

from relation ABDE we determined dependency AB -> DE ; AD -> E ; B->D ; AND trivial dependency

from relation EG we determined dependency E -> G

so AB ->C ; AC -> B are missing .

 1 votes -- Pranay Datta ( 6113 points)

7.80 Er: Primary key top gateoverflow.in/32228

R(A,B) have tuples

1,null

Null,2

1,5

Then what is primary key

A Or B or AB

er er-model

Primary Key Constraint says that the Attributes part of Primary Key must not contain NULL values. They are Not Nullable.
This table does not have any Primary Key as both have null values.

Thus, this relation does not have any Key Constraint on it, allowing duplicate records to be inserted.

Sample of a relational instance in SQL

 2 votes -- shiva ( 99 points)

7.81 Er Diagram: Consider the following ER-Model top gateoverflow.in/34578

er-diagram databases

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 787 of 2244

Here customer to account one to many relation so for each entity one table, total 2 tables.

Next account to statements one to many relation.and here statements is weak entity.so for statements one table has been
created,where number attribute of account which is Pk,add with id of statements entity and formed candidate key of that
new table.and for for account already one table has been created previously .

Next phones and customer in many to many relation ,so we already created a table for customer previously,now one table
for relation has and one table for phones has been created. So 2 more new tables.

So total 5 tables will be needed.

 2 votes -- Sayantan Ganguly ( 5061 points)

Here we have 3 strong entity and 1 weak entity(using number as foreign key for this table) so total 4 tables needs to be
created.

 2 votes -- priyavssut ( 411 points)

7.82 Er Diagram: DBMS question on ER diagram top gateoverflow.in/18357

databases er-diagram

3 tables reqd two store entites E1 and E.2 relationship R1 can be stored in E2 table one more table is required for
Relationship R2 which is many to many so ans is 3

 1 votes -- Pooja ( 22773 points)

7.83 Er Diagram: Minimum number of tables for the given ER Diagram gateoverflow.in/27592

top

databases er-diagram

For Relation:-

1:n ->No Table

1:1 ->No Table

M:N -> A Table required

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 788 of 2244

--------------------------------------------------------------------------------------

For Strong Entity:-

A table is required

-----------------------------------------------------------------------------------------

For Weak Entity:-

A table is required

-----------------------------------------------------------------------------------------

For Multivalued Atrributes:-

A table is required

----------------------------------------------------------------------------------------

Therefore in the above ER diagra m:-

For Strong Entity-2

For M:N - 1

For Multivalued Attribute - 2

total table:2+1+2=5

 1 votes -- Sandip Shaw ( 755 points)

5 tables are required..

E1(A,B)

E1'(A,C)

E2(D,E)

E2'(D,F)

R(A,D) as R is many to many relation candidate key is AD

 1 votes -- Pooja ( 22773 points)

E1(A,B,C) with A is Candidate key and C is mltivalue attribute

R(A,D) with AD is candidate key

E2(D,E,F) with D is Candidate key and F is mltivalue attribute .

To make relation in 1nf no multivalue attribute present in relation so

E1 break in E1(AB) with Ais candidate key

E1 break in E1(AC) with AC is candidate key

E2 break in E2(DE) with D is candidate key

E2 break in E2(DF) with DF is candidate key

R(AD) will not combine with E1(AB) OR E2(DE). because\

when R(AD) will not combine with E1(AB) then E1(ABD) A->B AND AD WILL BE THEIR AD IS CANDIDAYTE KEY PARTIALY
DEPENDANCY PRESENT SO NOT COMBINE.

SAME FOR R(AD) will not combine with E2(DE).

SO 5 TABLE REQUIRED. ALL ARE KEPT ALONE

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 789 of 2244

 1 votes -- Anirudh Pratap Singh ( 4091 points)

7.84 Er Diagram: Minimum Number of tables for given ER-Diagram top gateoverflow.in/25525

er-diagram databases


Selected Answer

No of table will be 3

E1, E2,E3 we need 3 tables

but as it gives 1:n relationship , so no more tables are needed

 4 votes -- srestha ( 11585 points)

7.85 Er Diagram: Minimum number of relation for given ER diagram top gateoverflow.in/29974

Given answer is 2, but I think that for each multivalue attribute we need a relation and one for the main entity, therefore 3
should be the answer. Please correct me if I am wrong

databases er-diagram


Selected Answer

Minimum Table require

1NF = 1 table (Dno Dname Phone Office)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 790 of 2244

BCNF = 2 table (Dno Dname) (Dno Phone Office)


4Nf = 3 Table for each MVD one table (Dno Dname) (Dno Phone) (Dno Office)

 3 votes -- Umang Raman ( 10379 points)

7.86 Er Diagram: ER DIAGRAM top gateoverflow.in/18398

I think ans is A. @Arjun sir, @Pooja palod

databases er-diagram er-model

OPTION B

In many to one relation , always many side is key..

ER1 : Let's take counter example..

All records of P related to same record in Q , like -

P Q
P1 Q1
P2 Q1
P3 Q1

Now , Becoz P has total participation , so table P has 3 records for P1, P2, P3 respectively.. But Q can have any number of
records.. So, we can't say that table 'P' will have more records than table Q..

ER2 : Here Q side total participation but P side can have any number of entities besides those who are in relationship..

P Q
P1 Q1
P2 Q2
P3 Q2
P4 Q3

Here , many to one relationship and Q side total participation - means Q will have 3 entities & P has 4 enities , (P>Q)

Here we can notice that P is key so can't repeat & hence P>=Q (P can have more records as it is in partial participation
but never less)..

 1 votes -- Himanshu Agarwal ( 8861 points)

7.87 Er Model: ER MODEL top gateoverflow.in/11829

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 791 of 2244

HOW many minimum relation which satisfy BCNF.??

databases er-model


Selected Answer

5 Relations

Each for Strong Entity sets : E1 and E2, this contributes +2 (A, B, C) and (D, E, F)
One for M:N type Relationship Set : R, this contributes +1 (A, D)
One relation for each Multi Valued Attribute which preserves Multi Valued Attribute's data : C and F, this contributes
+2 (C, C') and (F, F') where C' and F' are the multiple values corresponding to each C and F respectively.

a total of 5 Relations. Here, in all relations the determinant is a super key. So, all are in BCNF and we cannot reduce the
number 5 ensuring BCNF.

Ref: http://web.cse.ohio-state.edu/~gurari/course/cse670/cse670Ch9.xht

 2 votes -- Amar Vashishth ( 17865 points)

7.88 Er Model: Let E1 and E2 be two entities in E-R diagram with simple
single valued attributes. R1 and R2 are two relationships between E1 and E2
where R1 is one-many and R2 is many - many. R1 and R2 donot have any
attributes of their own. How many minimum number of tables are required
to represent this situation in the relational model ? top gateoverflow.in/12789

A. 4
B. 3
C. 2
D. 1

databases er-model


Selected Answer

You need three tables:

For R1: Since it is one : many, you need just the tables for E1 and E2. E2 will have a foreign key referencing E1. Thus
multiple tuples in E2 will reference the same tuple in E1.

For R2: Since it is a many : many, you need the tables E1 and E2 as well as a 3rd table for the mappings as it can be
shown in neither E1 nor E2. In the third table, say E3, there will be references to both E1 and E2.

So, in all you need three tables.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 792 of 2244

Refer here also:

http://www.databaseprimer.com/pages/table-relationships/

 3 votes -- malam ( 127 points)

(b) option

3 tables required.

 1 votes -- kunal chalotra ( 3567 points)

7.89 Er Model: What exactly a weak entity ? top gateoverflow.in/4015

We know that a weak entity has no primary key .

SO , A weak entity is an entity that cannot be uniquely identified by its attributes alone . Does it mean it has duplicates and it always a multi-set ?

databases er-model


Selected Answer

Weak entity normally can be identified in connection with strong entity also . They are connected by an identifying
relation. But it does not mean that it should always have duplicates . it need not be always multi set

 3 votes -- Sankaranarayanan P.N ( 7645 points)

7.90 Er Model: how many tables will get generated for following E-R top gateoverflow.in/33284

how many tables will get generated for following E-R

I believe an answer is 3.

2 tables for 2 different multivalued attributes and one for entity "Dept.".

databases er-model

I think it should be 3.
One for the entity and 2 for multivalued attributes.

 1 votes -- Monanshi Jain ( 5827 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 793 of 2244

7.91 Er Model: Relations produced from an E-R model will always be in gateoverflow.in/1595

top

Relations produced from an E-R model will always be in

a. 1NF
b. 2NF
c. 3NF
d. 4NF

databases er-model database-normalization


Selected Answer

1 NF.

Simple atomic values non multivalued attributes.

Generally ERD is design level task and Relational model is implementation. Whenever relational model is implemented
from erd we get rid of multivalued attribute. The procedure is outlined here: http://web.cse.ohio-
state.edu/~gurari/course/cse670/cse670Ch9.xht. Multi-valued attributes are removed as M:N binary relation by repeating
the tuples and hence relation becomes 1NF. We cannot guarantee any higher normalization.

Student
SID Sname
1 Ram
2 Shyam
3 hari

SID Phone no
1 97772373733
1 97737377373
2 97873737337
2 97686373737

sid and phoneno both form the key in the new relation.

 5 votes -- Sourav Roy ( 2353 points)

7.92 File: Which is the best file organization when data is frequently added
or deleted from a file? IETE_ELAN top gateoverflow.in/37735

Which is the best file organization when data is frequently added or deleted from a file?

(A) Sequential (B) Direct

(C) Index sequential (D) None of the above

databases file-system file

7.93 File System: check the question top gateoverflow.in/29107

Given a data file with 100 records per pages and on index page capacity of 512 index entries, how deep should be the B++

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 794 of 2244

tree to index this file.

file-system databases

7.94 File System: check the question top gateoverflow.in/29088

consider a file of 8192 records .each records is 16 bytes long and its key field is pf size 6 bytes.the file is ordered on a key
field and the file organization is unspanned .the file is stored in a file system with block size 512 bytes . and the size of the
block pointer 10 bytes.if the primary index is built on the key field of the file and a multilevel index scheme i used to store
the primary index,the number of first level and second level blocks in the multilevel index are respectively_________

file-system


Selected Answer

No of records in one block=512/16=32

No of data blocks=8192/32=256

No of entries in one index block=512/16=32

No of first level index blocks=256/32=8

No of second level index block=1( 8 entries would fit in single block)

 2 votes -- Pooja ( 22773 points)

File has 8192 records

Each record size 16 B

Key field 6 B

Block pointer size 10 B

Block size 512 B

No of record in each block 512/16 = 32

No. of blocks 8192/32 =256

For primary indexing


key and pointer field size 6+10=16B

So, No. of entry in each block 512 B/16 B= 32

So, no of blocks in first level index 256/32 = 8

Second level entry will be 1 (As 32 entries fit in 1 block)

 1 votes -- srestha ( 11585 points)

7.95 Foreign: FOERIGN KEY top gateoverflow.in/39240

what is the advantage of keeping the Foreign Key null as we know if we make the Foreign Key null we cant reference it again
so thats a disadvantage ......so there must be some advantage which outweighs this disadvantage so whats that advantage

databases foreign key

suppose two table EMPLOYEE(eid,ename) and DEPARTMENT(Did,Dname) and now we make eid as a foreign key , now if
we delete any Eid from EMPLOYEE and that Eid was refrenced by foriegn key of DEPARTMENT table then to maintain
refrential integrity we hav to also delete that coressponding refrenced key from DEPARTMENT.

but if we donot want to loss data of DEPARTMENT table so instead of deleting that refrenced key of foriegn key we put null
values , by this we do not loss the data of DEPARTMENT table

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 795 of 2244

 0 votes -- saket nandan ( 1853 points)

7.96 Form: Identify a given derivation rule is in which Normal form top gateoverflow.in/7548

I need to understand how to determine a set of rules for sentence generation is in which normal form. (1NF, 2NF, 3NF,
BCNF) from productions given. I get the theory part well but identifing from the rules for deriving is tough. So if someone
gives more idea it will be appreciated.

Thank you.

database-normalization form

The question is very unclear. I don't know what you are referring to as "set of rules for sentence generation". But here is a
general procedure for identifying the normal form of a relation with respect to a set of functional dependency (Not
productions).

1. See if domains of all the attributes contain only atomic values. If so then the relation is in 1 NF(Atomicity).
2. Identify all the candidate keys.
3. If no proper sub set of a candidate key defines a non-prime attribute then the relation is in 2 NF(Partial
dependency).
4. If for all non-trivial FDs X->Y, X is a super key or Y is a prime attribute, then the relation is in 3 NF
5. If for all non-trivial FDs X->Y, X is a super key then the relation is in BCNF.

 1 votes -- Gowthaman Arumugam ( 1079 points)

7.97 Functional Dependencies: Number of candidate keys top gateoverflow.in/32681

A relation R with 5 attributes A1 , A2 , A3 , A4 , A5 . Given the following FDs

A1 → A2

A2 A3 → A5

A4 A5 → A1

the number of candidates keys that includes attribute A3 is ________________.

databases functional-dependencies

3, A3A4A1,A3A4A2,A3A4A5

 3 votes -- sonam vyas ( 6441 points)

7.98 Functional Dependencies: F1, F2, F3 are FD sets with FDs top gateoverflow.in/34577

Isn't F1 covering F3 and F3 covering F1

functional-dependencies databases

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 796 of 2244

F1: P->Q,Q->R

F2:P->Q,P->R

F3:P->Q,PQ->R

1) F1 and F3

F1 is covering F3 but F3 is not covering F1

F1: P->Q,Q->R

F3:P->Q,PQ->R

Q->R is not covered by F3

so F1 is not equivalent to F3

2)F1 and F2 are aslo not equivalent because P->R is not covered

3)F2 and F3 are equivalent

F2:P->Q,P->R

F3:P->Q,PQ->R

P->Q and P->R are covered by F3

P->Q and PQ-R are covered by F2

so option B is correct

 1 votes -- Sandip Shaw ( 755 points)

No f3 is not covering f1 because in f1 Q->R bt in f3 this FD does not implies

 1 votes -- deep_down ( 99 points)

7.99 Functional Dependencies: what would be the functional dependency for


the below schema ? top gateoverflow.in/14890

Suppliers(sid:integer, sname:string, city:string, street:string),

Assume that, in the suppliers relation above, each supplier and each street within a city has a unique name, and (sname, city) forms a candidate key.

I just want to ask that will there be only one FD here like
sname,city--> sid , street

For the stmt ,"each supplier and each street within a city has a unique name, " , what would be the FD ?

functional-dependencies

yes ,

FD are

sname city --> sid

sname,city--> street

 0 votes -- Pranay Datta ( 6113 points)

7.100 Functional Dependencies: Equivalent FDs top gateoverflow.in/32658

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 797 of 2244

what is meaning of views equal serial process-schedule

functional-dependencies

7.101 Functional Dependencies: Which do not have a lossless join,


dependency preserving BCNF decomposition? top gateoverflow.in/14891

(A) A->B, B->CD (B) A->B, B->C, C->D (C) AB->C, C->AD (D) A ->BCD

databases functional-dependencies

ans C)

 1 votes -- Pranay Datta ( 6113 points)

7.102 Functional Dependencies: The following functional dependency hold


for relations top gateoverflow.in/14806

The following functional dependency hold for relations R (A,B,C) and S(B,D,E):FD FOR BOTH THE TABLES B -> A, A -> C
The relation R contains 200 tuples and the relation s contains 100 tuples. What is the maximum 4 number of tuples possible
in natural join R|><|S?

functional-dependencies

B is the primary key. since A is functionally dependent on B and C is f.d on A so you can derive the value of A and C from
B only .

as natural join is the equijoin on the common attribute B, it will have a maximum of 100 tuples

 2 votes -- Sanjay Sharma ( 799 points)

B is primary key fro R as B->A B->C

B is foreign key for S

Max tuples in natural join of R and S will be min(200,100)=100

(As B is primary key all B values in relation R are distinct Now when we join R and S it may happen that any one of 200
value may map to all 100 values or say 100 values from 200 may map to 100 values of S These are just to cases)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 798 of 2244

 2 votes -- Pooja ( 22773 points)

7.103 Functional Dependencies: Why is it so that from a given relation


instance we can't derive the set of fds ? top gateoverflow.in/16016

why can't we say that A functionally determines B from the given relation instance when it satisfies the constraints since for
unique value of A we have unique value of B this implies that A functionally determines B , so then why can't we conclude
whether A -->B holds or not ?

databases functional-dependencies

A->B hold on this relation instance, but unless the complete relation schema is known, we cannot say for sure if A->B
holds on the entire schema. It may be the case that for some other tuples. this dependency is not satisfied. One thing that
is sure is B does not functionally determine C , whether you consider this instance or the entire schema

 0 votes -- learncp ( 627 points)

7.104 Functional Dependencies: does A-->B for the given table top gateoverflow.in/39183

Consider the table:-

A | B

a | 2

b | a

c | 4

NULL | 6

NULL | 6

determine whether F.D. holds for A-->B and/or B-->A?and How?

functional-dependencies


Selected Answer

We can only be sure whether the FD does not hold and we can never be sure whether the FD can hold as the values may
be differ after insertion(not for instance). So here in the question in this particular instance, A->B can hold as the values
in A are different and if both null values are same then also the value in the corresponding B is same(6) and if the value
turned out to be different then no issue. So A->B holds. But B->A doesn't hold cause if both the null values turned out to
be different (NULL values do not compare equal in SQL) then it will fail..

 5 votes -- Joker ( 685 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 799 of 2244

7.105 Functional Dependencies: Determine the type of functional


dependency top gateoverflow.in/20942

Consider Relation R (A, B, C, D, E, F)


{ AB->C C->B D->C E->D F->E }
C.key=AF

I have 2 questions

1) Isn't AB->C fully functionally dependent? Because the definition of full functional dependency states that no proper subset of AB can determine
C,which is the case here.

2) Does F->E exhibit partial dependency? How do I determine if its partially dependent?

functional-dependencies

Full functional dependency: if x->y then y can not determine by any of the subset of x.

let say BCD->A then A can not determined by B or C or D individually(B->A or C->A or D->A)

Partial Dependency:If AB->C then it is partial dependent if A->C or B->C

1) AB->C is fully functional dependency

2) F->E is partial dependency because AF is a candidate key and no subset of Candidate Key can determine E

http://stackoverflow.com/questions/25747802/partial-dependencydatabases

 0 votes -- sdpshaw ( 99 points)

7.106 Functional Dependencies: functional dependency top gateoverflow.in/3004

GIven a relation instance

X Y Z
2 8 4
2 10 6
2 12 6
6 4 4

which of the following FDs is satisfied by relation

A)XY → Z, Z → Y

B)YZ → X, Y → Z

C)YZ → X, X → Z

D)XZ → Y, Y → X

functional-dependencies


Selected Answer

Z-> Y is not satisfied as when Z = 4, Y has values 8 as well as 4. So, (A) is False.

YZ and Y are unique and hence FDs in (B) are trivially satisfied.

X->Z is not satisfied as when X=2, Z can have 4 as well as 6. So, (C) is false.

XZ -> Y is not satisfied as when XZ = {2,6}, Y can have 10 as well as 12. So, D is false.

 3 votes -- Arjun Suresh ( 124125 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 800 of 2244

7.107 Functional Dependencies: How to determine a partial functional


dependency when checking for second normal form ? top gateoverflow.in/21063

What is the best and the most accurate way to check if a given functional dependency is partial on the set of FDs given.
Earlier, I used to follow {part of CK -> non prime attribute} as the rule, but in several of the questions I find that this rule
alone is not sufficient. Can someone give a fully working technique to solve for such cases ?

For instance, I was reading a question on stack overflow, where in a relation r(ABCD), the following FDs hold- AB->CD, AB-
>C and A->C.

As the CK is AB,the partial FDs should be A->C . But one of thetop users has commented that the dependency Ab->C is
partial and A->C is full. ?? :/

Question link for reference (http://stackoverflow.com/questions/25747802/partial-dependencydatabases ) see answer by


'Mike Sherrill 'Cat Recall''

database-normalization functional-dependencies databases

A functional dependency X → Y is a full functional dependency if removal of any attribute A from X means that the dependency does not hold any more; that is,
for any attribute A ε X, (X – {A}) does not functionally determine Y.

A
functional
dependency
X

Y
is
a
partial
dependency
if
some
attribute
A
ε
X
can
be
removed
from
X
and
the
dependency
still
holds ;

Here if we remove B from AB→C

We get A→C (as A→C holds bcz it is in fd already)

If we remove B From there AB →C can't hold any more C fully depends on A.

So C partially depends on AB and AB→C is partial fd

Read answer of philipxy or his replies ovr the comment carefully.

 0 votes -- Khushboo Tak ( 1961 points)

7.108 Functional Dependencies: join top gateoverflow.in/11698

Consider a relation R(A, B, C) with the following functional dependencies AB → C and AC → B. A can take 20 distinct values, B
can take 10 distinct values and C can take 100 distinct values. What is the maximum possible size (in tuples) of the self join
of R on C?

A. 4,000
B. 200
C. 4,00,000
D. 20,000

databases functional-dependencies


Selected Answer

AB → C basically means whenever A,B values repeat C must also repeat. Thus this FD restrict the number of possible
tuples in R to number of possible values of A * number of possible values of B, which is 20 * 10 = 200. Now we can either
have the sane C value for all these 200 tuples or utilize all our distinct 100 values. Since we join on C, the first case would
return 200*200=40000 tuples while the second case can only return a maximum of 2*200=400 tuples when each of the
100 C value is repeated twice.

But we haven't yet considered the FD AC → B . Due to this FD, we cannot have more than 20 tuples with one C value. So
we need minimum 10 distinct C values to get our 200 tuples for R. This would mean join on C returns true for 20 tuples
(from 200 we have 10 distinct C values, meaning 20 matching ones for each C value) and we can have a maximum of
200*20 = 4000 tuples in join.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 801 of 2244

 1 votes -- Arjun Suresh ( 124125 points)

A) 4000

due to the restrictions imposed by the functional dependencies we can vary values like:
keep B and C value as constant and loop through all values of A, this gives us 20 possible combinations for the value set
to appear in the Relation R.
next on getting exhausted with the above situation we try to change the value of B, keeping C as before but FDs stops us
from doing that and the FD set asks us to change the value for C also, therefore for possible combinations of BC we get 10
different sets for which each element of set is associated with 20 values of A. 10 different because we simultaneously
change value for C as we change for B as we need maximum possible tuples in the result when performing the Self Join
on C.

On Self join we see that for such a story the same values of C are to be combined with the same values of C only Because
the join is on C.

for instance
A B C
a1 b1 c1
a2 b1 c1
a1 b2 c2
a2 b2 c2

for first row in the Relation we have with same C 20 different combinations, similarly for the second row on same value of
C there that is c1

then same is true for the third row onwards which has 20 different combinations on same value of C i.e. c2 and so on for
such 10 possible bi and ci

Hence, (20*20) * 10 = 4000

 2 votes -- Amar Vashishth ( 17865 points)

7.109 Functional Dependencies: Trivial functional dependency top gateoverflow.in/1529

Here is para from wiki, about functional dependency in relation dbms

Given a relation R, a set of attributes X in R is said to functionally determine another set of attributes Y, also in R, (written X
→ Y) if, and only if, each X value is associated with precisely one Y value; R is then said to satisfy the functional dependency
X → Y. Equivalently, the projection \pi_{X,Y}R is a function, i.e. Y is a function of X.[1][2] In simple words, if the values for
the X attributes are known (say they are x), then the values for the Y attributes corresponding to x can be determined by
looking them up in any tuple of R containing x. Customarily X is called the determinant set and Y the dependent set. A
functional dependency FD: X → Y is called trivial if Y is a subset of X.

I could not get the last point "A functional dependency FD: X → Y is called trivial if Y is a subset of X."

please give me an example and explain it

Thank you :)

databases functional-dependencies


Selected Answer

The problem here is "trivial". A native English speaker wouldn't have any doubt in this. Here is one example usage of it:

(a) An engineering student having attended high school is trivial.

More details:

http://dictionary.reference.com/browse/trivial

Now, coming to FD, we say X → Y when Y is dependent on X. That is, whenever X value changes Y value should change accordingly. Now consider X=

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 802 of 2244

{A,B,C} and Y = {A}, where Y is a subset of X. Let us consider a tuple of relation R containing X and Y (second one in the below table where x represents any
value)

A B C D
x x x x
first 456 chennai -
x x x x

Here, value of X for our tuple = {first, 456,chennai}, and value of Y = {first}. Now when "first" changes to say "second",
it will change the value in both X as well as Y, as the attribute A is the same in both X and Y. So, there is no meaning in
this FD as it is always there, and hence it becomes trivial.

 3 votes -- Arjun Suresh ( 124125 points)

For example if we consider {name, rollno} rollno. here RHS is a subset of LHS , This type of dependency are called
trivial

They are implicit.

 4 votes -- Sankaranarayanan P.N ( 7645 points)

7.110 Functional Dependencies: To calculate how many no of super keys? top


gateoverflow.in/42238
a relation R(A,B,C,D,E,F,G,H)

and set of functional dependencies are {CH->G,A->BC,B->CFH,E->A,F->EG }

then how many possible super keys are present ?

databases functional-dependencies


Selected Answer

We know, P(A ⋃ B ⋃ C ⋃ D) = P(A) + P(B) + P(C) + P(D) - P(A∩B) - P(B∩C) - P(C∩D) - P(D∩A) + P(A∩B∩C) + P(B∩C∩A) +
P(C∩D∩A) - P(A∩B∩C∩D)

Here candidate keys are (AD) , (BD) , (ED) , (FD)

No. of super keys 2 n-(size of candidate key) [n=no. of keys]

Here 28-2 =26 ⨉ 4=256 [As 4 such candidate keys available]....................i

Now use set operation to eliminate duplicate key

Now by (AD) , (BD) , (ED), (FD) duplicate keys of 3 element dulpicate keys possible 6. those are (ABD),,(ADE) , (ADF),
(EDB),(EDF), (BDF)

No more 3 element keys are possible.

So, super keys are 2 8-3 ⨉6 = 192...................................ii

Similarly 4 element keys are (ADEB) , (ADEF) , (EBDF) , (ADBF)

Now no of super keys are 2 8-4⨉4=64................................iii

Now 5 element key (ABDEF)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 803 of 2244

No. of super keys 2 8-5⨉1=8.........................iv

Now just putting it into formula of set 256 - 192 + 64 -8 =120

 3 votes -- srestha ( 11585 points)

First finding out candidate keys.

D is not present at RHS of any FD. So, it must be present in any key.

AD -> BCDEFGH, hence AB is a candidate key.

Due to E -> A, ED is another candidate key.

F->E makes FD another candidate key and similarly B->F makes BD also a candidate key.

Thus we get {AD, ED, FD, BD} as candidate keys.

Now any superset of a candidate key is a super key.

In each of the above we can add any subset of the 6 remaining elements (excluding the 2 considered for the candidate
key) and we get a superkey. No. of subsets of a 6 element set = 26 = 64. And 4 times this should be 4 × 64 = 256..

But in the above case for AD, we have considered the super key ADE and similarly for ED we have considered EDA.
Similarly for {ADF, FDA} and {ADB, BDA}. Each of these would correspond to 25 = 32 cases being repeatedly added (any
combination of remaining 5 elements). Thus 3 × 32 = 96 subtractions needed. But we have done subtraction for the cases
ADEF, ADEB, ADFB twice. So, have to add 3 × 24 = 48. Here, we again do common addition for ADEFB and this requires
subtraction of 8.

Similarly we require 2 × 32 subtractions and 16 additions for {EDF, FDE}, {EDB, BDE} and 32 subtractions for {FDB, BDF}
giving 256 - 96 + 48 - 8 - 64 +16 - 32 = 120 possible super keys.

I'll give a better way :)

The question is an application of Inclusion-Exclusion principle. Here, the 4 candidate keys correspond to 4 sets each with
64 elements. Now, the set of all super keys will be (W = AD, X = ED, Y = FD, Z = BD)

|W ∪ X ∪ Y ∪ Z| = |W| + |X | + |Y| + |Z| − |W ∩ X | − |W ∩ Y| − |W ∩ Z| − |X ∩ Y| − |X ∩ Z| − |Y ∩ Z| + |W ∩ X ∩ Y| + |W ∩ X ∩ Z| + |W ∩ Y ∩ Z| + |

Now, | W ∩ X | = | ADE | = 25 = 32

Also, | W ∩ X | = | W ∩ Y | = | W ∩ X | = | X ∩ Y | = | X ∩ Z | = | Y ∩ Z |

| W ∩ X ∩ Y | = | ADEF | = 24 = 16.

Also, | W ∩ X ∩ Y | = | W ∩ X ∩ Z | = | W ∩ Y ∩ Z | = | X ∩ Y ∩ Z |

| W ∩ X ∩ Y | = | ABDEF | = 8.

So, | W ∪ X ∪ Y ∪ Z | = 4 × 64 − 6 × 32 + 4 × 16 − 8 = 256 − 192 + 64 − 8 = 120.

 5 votes -- Arjun Suresh ( 124125 points)

here no of candidate key are 4 which is (AD), (BD), (ED), (FD)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 804 of 2244

Then no of super key due to AD is 2^n-2 where n is no of attribute so 2^6

same no for BD ,ED,FD so 4* (2^6) and due to ABD,AED,AFD,BED,BFD,EFD IS - 6(2^5)

and due to ABED,AEFD,AEFD,ABFD is+4*(2^4) and finally with ABEFD IS -(2^3) SO total super keys are

4* (2^6)- 6(2^5)+4*(2^4)-(2^3) is the answer and such type question never be asked in gate they always intrested
to find out the no of candidate key

 2 votes -- rajan ( 1287 points)

7.111 Functional Dependencies: Find the number of candidates keys that


includes attribute A3 top gateoverflow.in/3006

A relation R with 5 attributes A1, A2, A3, A4, A5. Given the following FDs
A1 → A2
A2A3 → A5
A4A5 → A1
Find the number of candidates keys that includes attribute A3

databases functional-dependencies


Selected Answer

A4 and A3 are not coming on the RHS of any FD. So, they must be in all candidate keys.

Consider A4A5, due to A4A5 -> A1 and A1-> A2, A4A5 determines {A1 A2 A4 A5}, and hence A3A4A5 is a candidate key.

Similarly, A2A3A4 and A1A3A4 are candidate keys.

So, 3 is the answer.

 3 votes -- Arjun Suresh ( 124125 points)

3 SUCH KEYS .

1. A1A3A4

2. A2A3A4

3. A3A4A5

 1 votes -- abhishek1317 ( 259 points)

7.112 Functional Dependencies: why XY-> X is always functionally


dependent(trivial ) top gateoverflow.in/42313

for attribute set D the functional dependency D->D is considerd as trival i.e. D functionally determines itself.but how for D=
{a,b,c,d,e}

i can have relation R which is subset of D1*D2.

note D1=D2=D.(to avoid confusion)

now R ={(a,b),(a,c),(b,c)(e,a)}

here D1 is not functionally determining D2.

please explain the fault in this logic

functional-dependencies databases

7.113 Functional Dependencies: A relation R(ABCDE) with FD set f = {A ->


BC, C -> DE, D -> E} and the decomposition d = { R1(ABCD), R2(DE)}. Is

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 805 of 2244

this decomposition dependency preserving? top gateoverflow.in/13838

The answer given is YES. But how is the dependency C -> DE preserved in this decomposition?

databases functional-dependencies


Selected Answer

Yes its dependency preserving ,

from R1 we get : A-> BCD and C->D

and R2 : D->E

now see , C->D amd D->E so we can say C->DE

So all dependency are preserved .

 2 votes -- Pranay Datta ( 6113 points)

7.114 Indexing: Find best choice for degree for B+ tree, top gateoverflow.in/31428

Consider a relation R(A B C) with attribute size of A as 8 bytes. Disk block size is 512 bytes and block pointer is 8 bytes. The
best choice for degree (maximum value) for B+ tree, if B + tree was used for creating indexing on R(A B C) is _________.

databases b-tree indexing


Selected Answer

Let p be degree of B+tree internal node:

(p-1) keys + p Block pointers should fit in a block ie (p-1) keys + p Block pointers size <=512

(2p-1) * 8<=512

p<=65/2

p=32

if u take p=33node size becomes 520 bytes so not possible to fit in a block hence correct ans is 32

 3 votes -- Anurag Semwal ( 4775 points)

7.115 Indexing: B-Tree / possible records top gateoverflow.in/33511

b-tree databases indexing dbms


Selected Answer

order 15

so no of pointer 15.

level 0 1 node 14 entries 15 pointers

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 806 of 2244

level 1 15 nodes 15*14=210 entries 15*15 = 225 pointers

level 2 225 nodes 225*14=3150 entries 225*15 = 3375 pointers

total entries = 3150+210+14 = 3374 entries

 4 votes -- Sayantan Ganguly ( 5061 points)

I am getting 3374 records.

Level 0 = 14
Level 1 = 14*15 = 210
Level 2 = 14*15*15 = 3150

so, 14+210+3150 = 3374

 3 votes -- Monanshi Jain ( 5827 points)

7.116 Indexing: Consider the following statement about indexes top gateoverflow.in/3003

Consider the following statement


(i) Primary index is always sparse
(ii) Secondary index may or may not be dense
Which of the above statement is/are false?

A)Only (i)

B)Only (ii)

C)Both (i) and (ii)

D)None of these

databases indexing

Ans is D

Primary is always sparse. Secondary may be dense if done on a key field and sparse if done on a non-key field.

 1 votes -- Keith Kr ( 5467 points)

7.117 Indexing: Indexing top gateoverflow.in/34682

dbms indexing databases


Selected Answer

Answer : B
A clustered index determines the order in which the rows of the table will be stored on disk – and it actually stores row level data in the leaf nodes of the
index itself. A non-clustered index has no effect on which the order of the rows will be stored.


http://www.programmerinterview.com/index.php/database-sql/clustered-vs-non-clustered-index/

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 807 of 2244

 2 votes -- bahirNaik ( 2479 points)

7.118 Indexing: Indexing (Find no. of Blocks) top gateoverflow.in/33512

dbms indexing


Selected Answer

DB size 512
record size 16

no of record possible in disk block 512/16=32 records/block


no of Disk block present in DB file 8192/32=256
so primary index is used which is called as sparse index .in this index we make entry of each disk block but
not of every record.!
so at first level we have =256/(index file size )
now wt is index file : with the help of block pointer and search we locate reocrds so index file size
=512/(6+10)

=512/16 =32 (records


per index )
so at first level we have 256/32=8 index blocks
and hence multilevel index is used so in last level we have only 1 index block
so (d ) ans.

 4 votes -- kunal chalotra ( 3567 points)

7.119 Indexing: shd b only dont know y a kindly check top gateoverflow.in/12119

A clustering index is created when _______.

(A) primary key is declared and ordered


(B) no key ordered
(C) foreign key ordered
(D) there is no key and no order

databases indexing

A clustering index = ( non key attribute + ordered )

so C is the answer

 1 votes -- Pranay Datta ( 6113 points)

7.120 Indexing: DBMS: Indexing Question top gateoverflow.in/36201

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 808 of 2244

A file is organized so that the odering of data record is same as or close to the odering of data block in some index. Then that index is called

a. Dense
b. Sparse

c. Clustered
d. Unclustered

Solution given:

(b)
• In sparse index number of entries depends on number of data block in previous level.
• In dense index number of entries depends on number of data record in previous level.

Link:

http://gateoverflow.in/8222/gate2015-1_24

databases indexing

sparse: if an index created for some search key value

dense:if an index is created for every search key value

 0 votes -- munna kumar ( 309 points)

7.121 Minimal Cover: minimal cover top gateoverflow.in/33513

dbms minimal-cover functional-dependencies

1. PQ -> R, 2. PR->Q, 3. Q->S,4. QR->P,5. PQ->T

1. Q is extraneous so P->R

2. R is extraneous so P->Q

3. Q -> S no change

4. R is extraneous Q -> P

5. PQ -> T No change

So minimal cover is P->Q, P->R, Q->S, PQ->T

So answer is 4

 0 votes -- Sumit1311 ( 641 points)

7.122 Minimal Cover: write down a minimal cover top gateoverflow.in/11565

Consider the attribute set R = ABCDEGH (where Functional Dependencies are


F= {AB·--> C,AC --> B: AD ---> E, B -----> D, BE --> A, B -> G}.

functional-dependencies minimal-cover

Minimal cover means the smallest set of FDs which can derive all other FDs. The given FDs are

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 809 of 2244

AB → C
AC → B
AD → E
B→D
BE → A
B→G

Take each FD and see if any attribute on the LHS can be avoided. There is no such reductions possible. Also, the RHS of
the FDs are unique. So, I suppose the given FDs are already a minimal cover.

The candidate keys can be found as follows. If any attribute is not on the right side of any FD, it must be in any candidate
key. So, here H must be in any candidate key.

Trial and error with AB shows it can determine, C, D, E. So, ABH must be a candidate key. Since AC → B, ACH is another
candidate key. Since BE → A, BEH is another candidate key. So, totally 3 candidate keys {ABH, ACH, BEH}.

 1 votes -- Arjun Suresh ( 124125 points)

7.122 Multivalued Dependency 4nf: Sir I am having doubt in understanding


MVD and 4NF. No books helps me easily. Please help. top gateoverflow.in/10023

multivalued-dependency-4nf

I hope this link will help you out:

http://ecomputernotes.com/database-system/rdbms/fourth-normal-form

 0 votes -- Bhagirathi Nayak ( 10239 points)

7.123 Natural Join: if natural join is done then min and max no. of tuples if
referential integrity is taken and not top gateoverflow.in/15079

R(ABC) S(BDE)

F:A->B B ->C B->D D->E

AND R HAS 100 TUPLES AND S HAS 200

natural-join referential-integrity

For R A is key and B is key for S.B is foreign key of R refering B of S.If referential integrity is taken into consideration
max and min no of tuples will be 100 and 0 (null values)if not considered max will be 100 and min will be 0(no value of B
in R matches B of S)

 3 votes -- Pooja ( 22773 points)

7.124 Natural Join: Relation between Intersection and natural inner join on
common column top gateoverflow.in/37587

When , then the cost of computing is

(A) the same as R S

(B) greater the R S

(C) less than R S

(D) cannot say anything

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 810 of 2244

natural-join referential-integrity databases

Temp1 ∩ temp2 = Empty

Temp1 × Temp 2 = 3*3 = 9

Temp ⋈ temp2 = 3*3 [cross join operations] +9[checks to match two columns]

It should be greater than R×S

 0 votes -- bahirNaik ( 2479 points)

7.125 Natural Join: dbms top gateoverflow.in/39366

Consider the relation R(XYZ) has the following tuples

X Y Z
1 2 3
1 2 4
3 2 1

_________ tuples in the result of following relational algebra expression

(πX,YR) ⋈ R,Y<S ,Y(ρS (X,Y) (πY,ZR))

dbms natural-join

Initially ∏ y,z(R) => Y Z this table is renamed as S(X,Y) = > X Y

2 3 2 3

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 811 of 2244

2 4 2 4

2 1 2 1

Finally

∏x,y(R) natural join ∏ x,y (S)

1 2 2 3

1 2 2 4

3 2 2 3

3 2 2 4

By eliminating duplicates

So the result is 4 tuples

 0 votes -- shivanisrivarshini ( 2067 points)

7.126 Natural Join: Left outer join top gateoverflow.in/35743

Given answer for this question is:

Should last row be present in the result. Please check

databases natural-join


Selected Answer

yes last row will be present for right outer join with out including last but 2

 1 votes -- Registered user 11 ( 121 points)

No, the last row should not be present

 2 votes -- Somnath Paul ( 53 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 812 of 2244

7.127 Natural Join: Maximum and minimum size of the join of two relations
top gateoverflow.in/30009

I am confused about this problem:


Relation A -> m tuples
Relation B -> n tuples

What is the maximum and minimum size of natural join?


According to this, maximum can be -> min(m,n) and minimum can be 0.
I want to know if it is asked that what is maximum and minimum size on join operation (not natural join) will the answer get
changed?

databases natural-join


Selected Answer

As the natural join take the common attribute and combines according to them lets . take a relation R(a,b,c) an a relation
S(a,p,q) such that no value of a of r is repeated in the attribute A of relation s. so natural join will take the cross product
and will search where R.a=S.a so nothing will be selected and zero tupples will be returned, while if we does not have
common attributes then it take the cross product an as it now does not which to compare as there is no common attribute
it, stops there only providing you the cartesian product.
so minimum - zero

max- R*S.

and the min max will change according to join or the constraint

 1 votes -- Ravi Singh ( 7303 points)

7.128 Query: maximum no of tuples top gateoverflow.in/41635

Consider the relation R1( P, Q, R, S ) and R2 ( R, G, T, U )


The relation R1 has 20 tuples and R2 has 10 tuples then maximum number of tuples in R1 ⟕ R2 is .......................?

relational-algebra dbms query databases natural-join

Since candidate key not define so max tupple will be 20*10 = 200.

if R1 has candidate key P and R2 has candidate key R .

then No. of max tupple will be depend on foriegn key attribute relation so here R1 ⟕ R2 = 20

 2 votes -- Anirudh Pratap Singh ( 4091 points)

7.129 Query: maximum no of touples top gateoverflow.in/41633

Consider the following relation:


R (A B C) A primary key with 100 tuples.
S (E F G) E primary key with 50 tuples.
T (AE D) AE primary key with 80 tuples.
U (D G H) H primary key with 10 tuples.
The maximum number of possible records in the result of (R JOIN S JOIN T JOIN U)

dbms query relational-algebra

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 813 of 2244

If it is Natural Join then the answer will be 10, because for all the possible conditions the relation having least number of
tuples will dominate in final result so for R JOIN S JOIN T JOIN U, as U having the least no. of tuples hence maximum number
of possible records in the result of (R JOIN S JOIN T JOIN U)=10

 3 votes -- SHIVESH KUMAR ROY ( 107 points)

7.130 Referential Integrity: Navathe-sixth edition-4.5 top gateoverflow.in/42014

Consider the database shown below ,Whose schema is also shown below .What are the referential integrity constraints that
should hold on the schema ? Write appropriate SQL DDL statements to define database

DATABASE

STUDENT
NAME Student_number Class Major
Smith 17 1 CS
Brown 8 2 CS

COURSE
Course_name Course_number Credit_hours Department
Intro to Computer
CS1310 4 CS
Science
Data Structures CS3320 4 CS
Discrete
MATH2410 3 MATH
Mathematics
Databases CS3380 3 CS

SECTIONS
Section_identifier Course_number Semester Year Instructor
85 MATH2410 Fall 07 King
92 CS1310 Fall 07 Anderson
102 CS3320 Spring 08 Knuth
112 MATH2410 Fall 08 Chang
119 CS1310 Fall 08 Anderson
135 CS3380 Fall 08 Stone

GRADE_REPORT
Student_number Section_identifier Grade
17 112 B
17 119 C
8 85 A
8 92 A
8 102 B
8 135 A

PREREQUISITE
Course_number Prerequisite_number
CS3380 CS3320
CS3380 MATH2410

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 814 of 2244

CS3320 CS1310

SCHEMA

STUDENT
Name Student_number Class Major

COURSE
Course_name Course_number Credit_hours Department

PREREQUISITE
Course_number Prerequisite_number

SECTION
Section_identifier Course_number Semester year Instructor

GRADE_REPORT
Student_number Section_identifier Grade

databases referential-integrity navathe descriptive

7.131 Referential Integrity: number of tuples top gateoverflow.in/21310

databases referential-integrity

7.132 Regular Language: CFG regular or NOT top gateoverflow.in/37110

How to identify regular CFG

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 815 of 2244

theory-of-computation context-free regular-language

7.133 Relational Algebra: relational algebra top gateoverflow.in/32061

THE DIFFERENCE BETWEEN FOLLOWING 2 EXPRESSIONS?

a. ​(selection)year≥2009(takes) NATURAL JOIN ​ student


b. ​​(selection)year≥2009(takes NATURAL JOIN​ student)

databases relational-algebra


Selected Answer

If takes and student are the relation table then query a. first selects the tuple and then performs the NATURAL JOIN

while in query b. NATURAL JOIN is done first and then from resultant the tuples are selected satisfying the condition of
selection

 2 votes -- Abhishekcs10 ( 1001 points)

7.134 Relational Algebra: Sql and relational algebra top gateoverflow.in/36946

Can anyone suggest me how to learn about sql and relational algebra and calculus for gate?

as i feel this is an important topic and one 2 marks ques will be asked. I can understand easy problems and problems with
solutions.

Anything worth regarding this topic?

databases relational-calculus relational-algebra sql

Study navathe for depth.

 0 votes -- SHIVESH KUMAR ROY ( 107 points)

7.135 Relational Algebra: validity of relational algebra query top gateoverflow.in/43785

Let R and S be two relations, and l be an attribute common to R and S.


Let c be a condition over the attributes common to R and S. Prove or
disprove the following:

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 816 of 2244

relational-algebra

i) invalid

ii) valid

 0 votes -- srestha ( 11585 points)

7.136 Relational Algebra: Practice test-2 Relational algebra query2 top gateoverflow.in/37736

Consider the following schema and relational algebra query.


Student (Sid, Sname, Sage)
Course (Cid, CourseName, Credit)
Enrolled (Sid, Cid)
π Sid (Student) – πSid (σcredit<5 (course) Enrolled)
Which of the following is correct about relational algebra Q?

Finds Sid of students who enrolled atleast one course with credit greater than 5
Finds Sid of students who enrolled all courses with credit greater than or equal to 5
Finds Sid of students who enrolled all courses with credit less than 5
None of these

first option should be correct one??


nut 2nd one is given correct plz someone tell me why Second option not first one.

databases test-series made-easy relational-algebra


Selected Answer

πSid(σcredit<5 (course) (Natural Join)Enrolled) it will project all Sid's who enrolled all course having Credit <=4

πSid(Student) =It will list Sid's

Finally,

{All Sid's-All Sid's who enrolled all courses having Credit<=4}==All Sid's but Credit not<=4==students who enrolled all courses with
credit greater than or equal to 5.

 2 votes -- Ankesh Gautam ( 665 points)

7.137 Relational Algebra: Total number of tuples top gateoverflow.in/25205

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 817 of 2244

databases relational-algebra

foreign key: set of attribute reference to primary key or alternative key of same table or other table.

1000 2000(here A value cant be different from R1(A))


R1(A(primary key) B C) R2(A(foreighn key) D E)

minimum : consider all A in R2 are different but after 1000 different A they have to repeat since R1(A) are unique then
each value of R2(A) is matched twice in R1(A).
R2(A) value can be NULL if you don't consider R1(A) as Primary key.
X= number of record = 2000 or 0

maximum : consider all A in R2 are same then matched to only value of R1(A)
Y=number of record in join = 2000

X+Y = 4000.or 2000

 1 votes -- Umang Raman ( 10379 points)

7.138 Relational Algebra: division in relational algebra confirm plz top gateoverflow.in/31089

Suppose that cardinalities of relations A and B are m and n respectively, then the maximum cardinality of the resultant
relation A ÷ B is (A divides B)

m m

(A) m (B) m − n (C)  


n
(D)  
n

databases relational-algebra


Selected Answer

Ans is (d) floor(m/n)

Ref - https://en.wikipedia.org/wiki/Relational_algebra#Division

 4 votes -- Sandeep Singh ( 5939 points)

7.139 Relational Algebra: Relational Algebra top gateoverflow.in/37109

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 818 of 2244

Whats wrong with option A.

databases relational-algebra


Selected Answer

A. Returns all A values except the largest.

B. Returns the lowest value of A.

C. Returns the largest value of A.

 1 votes -- Arjun Suresh ( 124125 points)

7.140 Relational Algebra: Practice test-2 Relational algebra query top gateoverflow.in/37731

Consider the relations R(A, B) and S(B,C). Which one of the following can evaluate differently than the others?

a) π A(R) - ( π A (R - πA,B (R⋈S)))

b) πA(R∩ (πA(R) x π B(S)))

c) πA( (R x πc(S)) ∩ (πA(R) x S))

d) πA(R⋈S)

here I guess query is :- select attribute A where table R and S has same values of their common attribute.

option c and d represent same query

i am not sure about a and b

i think option a is same query

what are both options representing ??

test-series made-easy databases relational-algebra

Option (a) should be the answer

Option a : π A(R) - ( π A (R - πA,B (R⋈S)))

πA,B (R⋈S) will project tuples with a common value of B in R(A,B) and S(A,B)

πA (R - πA,B (R⋈S)) will project A from the set difference of R and π A,B (R⋈S) which ultimately will give tuples having
uncommon value of B BUT CAN HAVE SAME VALUE FOR ATTRIBUTE A.

πA(R) - ( π A (R - πA,B (R⋈S))) will again project A from the set difference of R and π A (R - πA,B (R⋈S)) which seems to give
attributes with the common value of B , which MIGHT ALSO GIVE AN EMPTY SET as the projection.

which is not a natural join of R and S.

see for example

R(A,B) = { (a,1), (a,2), (a,3)}

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 819 of 2244

S(B,C) = { (1,x), (2,x)}

 0 votes -- Naman Om ( 53 points)

7.141 Relational Algebra: Given two R union compatible relation R1 (A, B)


and R2 (C, D) what is the result of the operation top gateoverflow.in/32227

Given two R union compatible relation R 1 (A, B) and R 2 (C, D) what is the result of the operation

R1 A= C AB = D R 2?

a) R1⋃R 2 b) R 1 ⨯ R2 c) R 1 – R2 d) R1 ∩R2

How to solve these kind of questions

relational-algebra

7.142 Relational Algebra: True or False: Relational algebra cannot perform


aggregate function top gateoverflow.in/7669

True or False: Relational algebra cannot perform aggregate function

relational-algebra normal


Selected Answer

False. Average, count, max, min are all in relational algebra.

 6 votes -- anshu ( 2155 points)

7.143 Relational Algebra: Why is the maximum number of tuples in full outer
join equal to m*n ? top gateoverflow.in/16082

Why is the maximum number of tuples in full outer join equal to m*n, where m is the number of attributes in one relation
and n is the attribute count in other ?

Can someone give an example to illustrate this ?

databases relational-algebra


Selected Answer

Max no of tuple returned by Full outer join is same as no of tuples in Cartesian Product i.e. m*n.

 0 votes -- Digvijay Pandey ( 26245 points)

7.144 Relational Calculus: Relational Calculus basic top gateoverflow.in/43409

Hi , i have just written the question and answer for the below schema . I have written this according to lectures of IIT KGP .

I would request all the experts please look to my solution and point out my mistakes (if any ) :)

page 1

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 820 of 2244

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 821 of 2244

Page 2 :

page 3 :

page 4 :

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 822 of 2244

databases relational-calculus

ohh sure sir . I will do that

 0 votes -- Dexter ( 1933 points)

7.145 Relational Calculus: relational calculus top gateoverflow.in/42908

BOOK(ACC_NO, TITLE, YR_PUB)

USER(CARD_NO, B_NAME, B_ADD)

B_BY(ACC_NO , CARD_NO , DOI)

SUPPLIER(S_NAME,S_ADD)

S_BY(S_NAME,S_NAME,PRICE,,DOS)

Query :- find the names of those supplier who have supplied titles corresponding to all book issused by 'VIJAY'.

using relational calculus solve the query (if possible give proper explation)

databases relational-calculus

This query is quite simple in terms that its very logical... let's see this step wise

Step 1: B_name =" Vijay" present in User relation having Card_no. as the key

Step 2: Card_no is an attribute of B_by relation having Acc_no as an attribute which will be referencing to the Book
relation

Step 3: Book relation contains Title which will give titles for a particular Acc_no....we have to find Acc_no of such other
similar Titles too...

Step 4: after we successfully found out the possible Acc_no of "Titles" issued by Vijay we join S_by and Book relations to
find and display the S_name for the projected Acc_no.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 823 of 2244

hence the query becomes :

z = { t | ∀ a ∈ User ( a [B_name] = "VIJAY" ==> /* selecting tuples with B_name = "VIJAY"*/

∃ b ∈ B_by( a[Card_no] = b[Card_no] ∧ /* natural join of B_by(b) and User(a) for Card_no of "Vijay"*/

∃ c ∈ Book( c[Acc_no] = b[Acc_no]) ∧ /* natural join of Book(c) and B_by(b) for Acc_no of books issued to the Card_no of "VIJAY" */

∃ d ∈ Book( c[Title] = d[Title]) ∧ /* cartesian product of Book(c) with Book(d) to find Titles same as Titles issued by "VIJAY"*/

∃ e ∈ S_by( d[Acc_no] = e[Acc_no] ∧ t[S_name] = e[S_name] ) /* natural join of S_by(e) and relation d to find S_name for the all Titles issued by Vijay*/

I hope this is the correct solution. Still, any suggestion is Welcome. I face issues with brackets. Any help regarding that.

 0 votes -- Naman Om ( 53 points)

7.146 Relational Calculus: give answer for relational algebra , tuple calculas ,
and SQL top gateoverflow.in/14757

BOOK(acc_no.,year,title)

USER(card_no.,names,address)

SUPPLIER(s_name,address)

BORROWED BY (acc_no.card_no,date of issue)

SUPPLIED BY(acc_no,date of supply,price ,s_name)

in above given relation find out the acc_no of all the book which are present in the library

in

(a)relational algebra form

(b) in sql form

(c)in tuple calculas form

databases relational-calculus

Books will be in library which are not issued by anyone. So

(b) Sql query

Select b.acc_no

From book b

Where b.acc_no NOT IN ( select c.acc_no

From borrowed_by c)

(a) πacc_no( book ) - πacc_no​( borrowed_by)

(c) {t| ∃t∈(book)∧∃b∈(book) (∃c∈(borrowed_by) ( b[acc_no]≠c[acc_no] ∧ t[acc_no]=b[acc_no]))}

That's what I know.hoping its correct.

 0 votes -- Khushboo Tak ( 1961 points)

7.147 Relational Calculus: relation calculus 'for every' type top gateoverflow.in/2485

Example Relational Scheme

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 824 of 2244

student (rollNo, name, degree, year, sex, deptNo, advisor)


department (deptId, name, hod, phone)
professor (empId, name, sex, startYear, deptNo, phone)
course (courseId, cname, credits, deptNo)
enrollment (rollNo, courseId, sem, year, grade)
teaching (empId, courseId, sem, year, classRoom)
preRequisite (preReqCourse, courseID)

Question:

Determine the students who are enrolled for every


course taught by Prof Ramanujam. Assume that Prof
Ramanujam teaches at least one course.

Answer:

1. {s.rollNo | student (s) ^


2. (∀c)(course (c) ^
3. ((∃t),(∃p)( teaching(t) ^ professor(p) ^
4. t.courseId = c.courseId ^
5. p.name = “Ramanujam” ^
6. p.empId = t.empId )) →
7. (∃e) (enrollment(e) ^
8. e.courseId = c.courseId ^
9. e.rollNo = s.rollNo)
10. )
11. }

Please explain the answer, i am little bit confused with how relation calculus express divide operator.

(My belief if that ∀ is similar to the quotient operator. ) TIA !

relational-calculus

As you have mentioned in the question, this is a relational calculus expression and not a relational algebra one. Relational
algebra contains only algebraic operations and proportional logic. But relational calculus can contain free and bound
variables as seen here.

∀ means FORALL ∃ means EXISTS as in Mathematical logic

1. {s.rollNo | student (s) ^


2. (∀c)(course (c) ^
3. ((∃t),(∃p)( teaching(t) ^ professor(p) ^
4. t.courseId = c.courseId ^
5. p.name = “Ramanujam” ^
6. p.empId = t.empId )) →
7. (∃e) (enrollment(e) ^
8. e.courseId = c.courseId ^
9. e.rollNo = s.rollNo)
10. )
11. }
This says that for all courses taught by Ramanugan if there exists a student who has enrolled for it, then return his id. If you go through each line carefully you
can get this.

Relational Algebra and relational calculus:


http://www.cs.virginia.edu/~son/cs662.s06/ch4m.ppt

 0 votes -- Arjun Suresh ( 124125 points)

7.148 Relational Calculus: Find out all the books which are either issued, or
have been supplied by a supplier. top gateoverflow.in/14758

BOOK
(acc_no, year, title)
USER

(card_no, name, address)


SUPPLIER

(s_name, address)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 825 of 2244

BORROWED_BY
(acc_no, card_no, date of issue)
SUPPLIED_BY
(acc_no, date of supply, price, s_name)

In the above relation, find out all the books which are either issued, or have been supplied by a supplier.

Give your answer in the following forms:


(a) Relational Algebra
(b) SQL
(c) Tuple Calculus

databases relational-calculus

SQL Form:
select *
from book
where book.acc_no IN (select acc_no
from borrowed_by)
OR book.acc_no IN (select acc_no
from supplied_by
where s_name LIKE "%%");

 0 votes -- Pratyush Varshney ( 27 points)

7.149 Relational Calculus: query top gateoverflow.in/25254

Consider the following instance R.

A 1 2 3 4
B Null 1 2 2

The number of tuples returned by the following SQL query is

> select * from R as R1

where not exists (select * from R where B = R1.A)

databases sql relational-calculus


Selected Answer

The relation is put in landscape mode :)

R = {(1, NULL), (2, 1), (3, 2), (4, 2)}

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 826 of 2244

Now, a tuple is output if where condition is TRUE. Here the where condition is NOT EXISTS which returns true iff we give
empty set to it. So, the condition for output here is that the inner query should not return any tuple.

Based on query, the inner query returns a tuple if the 'A' value being considered exist in any of the tuple as a 'B' value.
This happens for A values, 1 and 2 and hence NOT EXISTS is FALSE for these two as the inner query returns {(2, 1)} and
{(3, 2), (4, 2)} respectively. For the tuples (3, 2) and (4, 2), the inner query returns {} and hence they are output. So, the
output is {(3, 2), (4, 2)} and answer is 2.

 7 votes -- Arjun Suresh ( 124125 points)

7.150 Relational Calculus: Tuple Relational Calculus top gateoverflow.in/37224

I believe since the variable 't' is a free variable, so option three should also be right. Second option is also correct?

relational-calculus databases

I think 3rd option is wrong because

professor(t[ID]=t[id] ^ t[salary]>10000) , here t[ID]=t[id] ^ t[salary]>10000 is acting on argument which is is not


ranging over entire table professor

BUT, in tuple crelation calculas says that we have to make variable t which is to be range over entire table

like, professor(t)^condition applied on t

or

t ϵprofessor ^ condition on t

so option 2 is carrect which satisfy the formate of TRC

 1 votes -- saket nandan ( 1853 points)

7.151 Relational Calculus: write down Domain Relational Calculas query? top
gateoverflow.in/12670

employee(person-name,street,city)

works(person-name,company-name,salary)

company(company-name,city)

manages(person-name,manager-name)

Find all employees who earn more than every employee of small bank co-operation

databases relational-calculus

i am not sure , i just give a try on this :

{ p | (∃q)(∃r) works(p q r) and ( ( ∀y) (works(x y z )^( y = small bank co-operation)) -> (∃z) (z<r) )}

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 827 of 2244

 1 votes -- Pranay Datta ( 6113 points)

7.152 Relations: is b option correct ryt?? top gateoverflow.in/11982

If D1,D2, .. ..Dn are domains in a relational model, then the relation is a table, which is a subset of

(A) D1+D2+ … +Dn


(B) D1×D2× … ×Dn
(C) D1∪D2∪ … ∪Dn
(D) D1–D2– … –Dn

databases relations

yes option B is correct .because a relation can be utmost D 1XD2X....XDn

 2 votes -- Bhagirathi Nayak ( 10239 points)

7.153 Sql: Sql top gateoverflow.in/31969

In sql, these all are right or wrong

Exist{}=true

Not exist{}=true

All{}=true

Not all{}=true

Any{}=false

Not any{}=false

In{}=false

Not in{}=false

sql

7.154 Sql: SQL top gateoverflow.in/37948

Can Foreign key value can be null??

sql databases


Selected Answer

Yes it may be null or duplicate also.

 1 votes -- Shashank Chavan ( 2439 points)

7.155 Sql: Output of given sql query top gateoverflow.in/30061

Use the following tables for the below queries wherever table 1 and table 2 are used:

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 828 of 2244

Select *

From Table 1

Where not exists (Select T2 B From Table 2 where T2 B <> T1 B)

How many number of rows will be there in the output ?

a. 1
b. 2
c. 3
d. 0

sql databases


Selected Answer

0 will be the right answer.

Select T2B from T2 where T2B <> T1B

This inner sub query is returning column T2B of all the tuples from the table formed by cross product T1 x T2 where
columns T1B & T2B are not equal.

Table T1 has 3 tuples, & T2 has 2 tuples so T1xT2 will have 2x3 = 6 tupes.

In these 6 tuples values of attributes (T1B, T2B) will be as follows:

(aa, aa)

(aa, bb)

(bb, aa)

(bb, bb)

(cc, aa)

(cc, bb).

Out of these 6 (T1B, T2B) pairs 4 will be returned where T1B & T2B are not equal.

Since the sub query is has 4 tuples in it, the Not Exists construct will return the value false for each of the 3 tuples in T1.

So 0 tuples will be there in output.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 829 of 2244

 2 votes -- Anurag Pandey ( 8183 points)

WRONG ANSWER : Miscomputed the sub query.

Since every element in column T2B of table T2 is also present in the Column T1B of table T1, the sub query in the
"Where" clause is going to return NULL. //This is incorrect.

The condition "Where Not Exists NULL" is a tautology,

that is this condition will always be true for every tuple in Table 1, so all the 3 tuples of table T1 will be shown in output.

Hence 3 should be the correct answer.

Why the condition "Where Not Exists NULL" is a tautology?

Not Exists basically checks if the sub query returns any tuples or not & since the sub query is returning NULL, Where Not
Exists NULL will always be evaluated to true.

 1 votes -- Anurag Pandey ( 8183 points)

7.156 Sql: Question on SQL like operator top gateoverflow.in/30005

Given answer: D
Please explain

databases sql


Selected Answer

Don't know whether my approach is correct or not.

You have to select all the 'name' from relation 'students' where name are ending in 'A' and could have anything (or nothing) at the
starting.

Statement D is "select * from students where name >='A' and name <'B';"

name >='A' and name <'B' means:-


name >='A' means name could begin with A or greater than A i.e., B,C...,Z but name <'B' means name should end with alphabet less
than B which is A. (Don't know may be ASCII code comparison)

So, statement D is equivalent to the given statement.


 2 votes -- Monanshi Jain ( 5827 points)

It is also asked before and it depends on how the charter are compared, , and they are different fr different for different
dbms software

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 830 of 2244

so it may never be asked in gate.

 1 votes -- Ravi Singh ( 7303 points)

7.157 Sql: Output of sql query with group by clause top gateoverflow.in/29986

A B C
5 2 1
10 NULL 2
15 2 3

In the above relation T the output of query:


select * from T group by B;

A B C
10 NULL 2
5 2 1

Can anyone explain why this is the output?

databases sql


Selected Answer

The group by command just return each row for unique combination of group by attributes. And every null is calculated as
a unique group . i.e. if u have one more row then with NULL u will gate 3 rows. because the both the null will be
calculated as a different group.
and it is not always the case it will return the first row. i think it is dependent on the database software . like on mysql i
got first row, while on the online sql ide . http://www.w3schools.com/sql/trysql.asp?filename=trysql_select_all
this will produce the last row,

 2 votes -- Ravi Singh ( 7303 points)

Remember one thing when you do group by clause then it will select the first row of each group so you are getting this
answer

 1 votes -- Abbas Gabru ( 49 points)

7.158 Sql: give statement in english for SQL top gateoverflow.in/13318

databases sql

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 831 of 2244


Selected Answer

Students who have enrolled for a course in CS department but not in ME department.

 1 votes -- Arjun Suresh ( 124125 points)

7.159 Sql: ISRO-2013-24 top gateoverflow.in/43857

Consider the following relational schema:

Suppliers (sid:integer, sname:string, saddress:string)


Parts (pid:integer, pname:string, pcolor:string)
Catalog (sid:integer, pid:integer, pcost:real)

What is the result of the following query?


(SELECT Catalog.pid from suppliers, Catalog
WHERE Suppliers.sid = Catalog.pid)
MINUS
(SELECT Catalog.pid from suppliers, Catalog
WHERE Suppliers.sname <> 'Sachin' and Suppliers.sid = Catalog.sid)

A. Pid of parts supplied by all except Sachin


B. Pid of parts supplied only by Sachin
C. Pid of parts available in catalog supplied by Sachin
D. Pid of parts available in catalog supplied by all except Sachin

isro2013 sql databases

Answer is (C)

Here in 1st query we are joining Catalog and Supplier and getting those supplier and parts which are available in Catalog

In 2nd query we are doing same as 1st query but just removing those rows where Supplier name sachin

So, resulting table has only those rows where catalog.sname is sachin

 0 votes -- srestha ( 11585 points)

7.160 Sql: DBMS question on SQL query (2) top gateoverflow.in/18355

The answer given is (b)

But , according to given query , isn't it d) ?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 832 of 2244

databases sql


Selected Answer

the answer is b .

because We cannot compare NULL in sql with " =" sign. In SQL's three-valued logic. neither NULL equals NULL nor NULL
not-equals NULL is true. Testing whether a value is NULL requires an expression such as IS NULL or IS NOT NULL.

so all the other becomes invalid. option b will be the answer

 0 votes -- Ravi Singh ( 7303 points)

7.161 Sql: DBMS SQL query (3) top gateoverflow.in/18356

databases sql

option a) is correct ..

like operator is used for comparisons ...and % is used to match 0 or more character matching

ref : http://www.csee.umbc.edu/portal/help/oracle8/server.815/a67779/operator.htm

 0 votes -- sonam vyas ( 6441 points)

7.162 Sql: Finding output of given SQL query top gateoverflow.in/29980

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 833 of 2244

Given answer: B
I don't know how to deal with NULL in such query operations. Please explain.

sql databases

NULL = unknown
unknown AND True = unknown
unknown AND False = False
unknown AND unknown = unknown

unknown OR True = True


unknown OR False = unknown
unknown OR unknown = unknown

So according to me answer is
option B) A and C are selected.

 2 votes -- Umang Raman ( 10379 points)

7.163 Sql: DBMS question on SQL query top gateoverflow.in/18354

Hi , I tried to solve it in this way -- inner query returning zero tuples.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 834 of 2244

So , outer query becomes select * from table1 where not exists null ( i mean no tuple ).

basically , it should give me all the tuples , right ?

I know , i am wrong , please clarify.

databases sql

as this a dependent query as u can see one attribute of outer query is used in the condition in inner query. the approach
to this type query is.run then like nested loop of i and j.

take the first row of table specified in outer query and app the inner condition on all the rows of table specified by inner
query.

so here on first taking aa from t1. and comparing it it aa ( first row of table t2) match so nothing will come.

now compare with second row of t2. bb will come.

so at the end u will have aa,bb,bb,aa in the inner query selection. as there is no distinct keyword , duplicates will not be
removed.

now just remove these tupples from the outer quesry. u will get one tupple i.e c cc

option a it is

 0 votes -- Ravi Singh ( 7303 points)

7.164 Sql: SQL top gateoverflow.in/10606

Consider the Following Collection of relational schema

Professor( profname , deptname)


Department (deptname, building)
Committee(commname, Profname)

Which of following query finds all the professors who have not offices in any of those buildings that professor Piper has
offices in

A.
Select distinct P.profname
from professor P
Where not exists ((
Select building
from department d
where P.deptname= D.deptname )
Union (
Select building
from department D1, professor P1
Where P1.profname=’Piper’ and P1.deptname= D1.deptname ))

B.
Select distinct P.profname Prom professor P
Where not exists
(( Select building from department d where P.deptname= D.deptname )
Intersect
(Select building from department D 1., professor P1
Where P1.profname=’Piper’ and P1.deptname= D1.deptname))

C)

Select distinct P.profname


From professor P
Where not exists(
Select Building from Department d1, professor p1
Where P1.Profname=’Piper’ and p1.deptname=D1.deptname )

D) None of these

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 835 of 2244

sql


Selected Answer

Option B is correct, even though it has NOT EXISTS, it checks whether set of the building(s) belonging to the "current" professor (in the outer query) has any intersection
with the set of building(s) belonging to Prof. Piper, and if they intersect, we shouldn't take the current professor, otherwise yes. This is ensured by the NOT EXISTS clause
that is dependent on the outer query this time.

 3 votes -- spriti1991 ( 1127 points)

7.165 Sql: MOCK_GATEFORUM_SAT6 SQL top gateoverflow.in/29712

sql


Selected Answer

The answer should be C


In Sql, duplicate rows are allowed, if no primary key is set.

also, all the null values are considered as null and we cannot diffrentiate between the different null values obtained.

 1 votes -- learncp ( 627 points)

i think a should be the answer. because .

1- sql does not treat every null same . sql treat null as unknown and we cannot compare two Null value by a equality and
the group by command also count every null as unique group,

2- the asnwer may be yes , u can create a table with no primary key which will be useless because join operation will not
be sucessful and that table will not be in 1nf.

 2 votes -- Ravi Singh ( 7303 points)

Ans is C.

Multisets are allowed. Refer : http://waelchatila.com/2005/05/18/1116485743467.html

 1 votes -- CrimeMasterGoGo ( 2221 points)

7.166 Sql: Null values while aggrigate function in query top gateoverflow.in/33301

How aggrigate functions in query will behave in data contains NULL values.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 836 of 2244

I think answer should be D as all aggrigatre functions EXCEPT count will ignore NULL values.

so, AVG will be 300 and count will be 4

databases sql


Selected Answer

300 , 3 /. how avg works

avg = sum( marks) / count(marks) . = count ignore null values . so count marks gives 3

so 300

and count ( mobile number) = 3

 1 votes -- Ravi Singh ( 7303 points)

7.167 Sql: Navathe-Fundamentals of Database systems-basic SQL-sixth


edition-4.11 top gateoverflow.in/42182

Specify the updates of Exercise 3.11 using the SQL update commands.

EXERCISE 3.11 : Suppose that each of the following Update operations is applied directly to the database state shown in
Figure 3.6. Discuss all integrity constraints violated by each operation, if any, and the different ways of enforcing these
constraints.

a. Insert <‘Robert’, ‘F’, ‘Scott’, ‘943775543’, ‘1972-06-21’, ‘2365 Newcastle Rd,

Bellaire, TX’, M, 58000, ‘888665555’, 1> into EMPLOYEE.

b. Insert <‘ProductA’, 4, ‘Bellaire’, 2> into PROJECT.

c. Insert <‘Production’, 4, ‘943775543’, ‘2007-10-01’> into DEPARTMENT.

d. Insert <‘677678989’,NULL, ‘40.0’> into WORKS_ON.

e. Insert <‘453453453’, ‘John’, ‘M’, ‘1990-12-12’, ‘spouse’> into DEPENDENT.

f. Delete the WORKS_ON tuples with Essn= ‘333445555’.

g. Delete the EMPLOYEE tuple with Ssn= ‘987654321’.

h. Delete the PROJECTtuple with Pname= ‘ProductX’.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 837 of 2244

i. Modify the Mgr_ssn and Mgr_start_dateof the DEPARTMENT tuple with

Dnumber= 5 to ‘123456789’ and ‘2007-10-01’, respectively.

j. Modify the Super_ssnattribute of the EMPLOYEE tuple with Ssn=

‘999887777’ to ‘943775543’.

k. Modify the Hoursattribute of the WORKS_ON tuple with Essn=

‘999887777’ and Pno= 10 to ‘5.0’

_____________________________________________________________________________________

FIGURE 3.6

_____________________________________________________________________________________

EMPLOYEE

Fname Minit Lname Ssn Bdate Address Sex Salary Super_ssn Dno

1985- 731 Fondren


John B Smith 123456789 M 30000 333445555 5
01-09 ,Houston,TX

1955- 638
Franklin T Wong 333445555 M 40000 888665555 5
12-08 Vose,Houston,TX

1968- 3321
Alicia J Zelaya 999887777 F 25000 987654321 4
01-19 Castle,Spring,TX

1941- 291
Jennifer S Wallace 987654321 F 43000 888665555 4
06-20 Berry,Bellaire,TX

1962- 975 Fire


Ramesh K Narayan 666884444 M 38000 333445555 5
09-15 Oak,Humble,TX

1972- 5631
Joyce A English 453453453 F 25000 333445555 5
07-31 Rice,Houston,TX

1969- 980
Ahmad V Jabbar 987987987 M 25000 987654321 4
03-29 Dallas,Houston,TX

James E Borg 888665555 1937- 450 M 55000 NULL 1


11-10 Stone,Houston,TX

DEPARTMENT

Dname Dnumber Mgr_ssn Mgr_start_date

Research 5 333445555 1988-05-22

Administration 4 987654321 1995-01-01

Headquarters 1 888665555 1981-06-19

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 838 of 2244

DEPT_LOCATIONS

Dnumber Dlocation

1 Houston

4 Stafford

5 Bellaire

5 Sugarland

5 Houston

WORKS_ON

Essn Pno Hours

123456789 1 32.5

123456789 2 7.5

666884444 3 40.0

453453453 1 20.0

453453453 2 20.0

333445555 2 10.0

333445555 3 10.0

333445555 10 10.0

333445555 20 10.0

999887777 30 30.0

999887777 10 10.0

987987987 10 35.0

987987987 30 5.0

987654321 30 20.0

987654321 20 15.0

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 839 of 2244

888665555 20 NULL
WORKS_ON

PROJECT

Pname Pnumber Plocation Dnum

ProductX 1 Bellaire 5

ProductY 2 Sugarland 5

ProductZ 3 Houston 5

Computerization 10 Stafford 4

Reorganization 20 Houston 1

Newbenefits 30 Stafford 4

DEPENDENT

Essn Dependent_name Sex Bdate Relationship

333445555 Alice F 1988-04-05 Daughter

333445555 Theodore M 1983-10-25 Son

333445555 Joy F 1958-05-03 Spouse

987654321 Abner M 1942-02-28 Spouse

123456789 Michael M 1988-01-04 Son

123456789 Alice F 1988-12-30 Daughter

123456789 Elizabeth F 1967-05-05 Spouse

databases descriptive sql navathe

7.168 Sql: Having clause top gateoverflow.in/33155

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 840 of 2244

sql

D is correct. http://gateoverflow.in/47/gate2012_15

 0 votes -- Digvijay Pandey ( 26245 points)

7.169 Sql: Navathe-Fundamentals of Database systems-basic SQL-sixth


edition-4.14 top gateoverflow.in/42178

Design a relational database schema for a database application of your choice.

a. Declare your relations,using the SQL DDL.


b. Specify a number of queries in SQL that are needed by your database application.
c. Based on your expected use of database , choose some attributes that should have indexes specified on them
d. Implement your database , if you have a DBMS that supports SQL.

databases descriptive sql navathe

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 841 of 2244

7.170 Sql: Navathe-Fundamentals of Database systems-basic SQL-sixth


edition-4.2 top gateoverflow.in/42039

List the data types that are allowed for SQL attributes.

databases sql descriptive

SQL - Data Types: http://www.tutorialspoint.com/sql/sql-data-types.htm

For complete information: http://tunweb.teradata.ws/tunstudent/TeradataUserManuals/SQL_Reference_--


_Data_Types_And_Literals.pdf

 0 votes -- vamsi2376 ( 1185 points)

7.171 Sql: Can you please explain the second query top gateoverflow.in/34579

sql databases

7.172 Sql: What will COUNT(*) returns if all the collection has only null
values? top gateoverflow.in/42010

What will COUNT(*) returns if all the collection has only null values???

databases sql

In SQL,when we use the count function over an attribute of the relation and that attribute contains null values for some/all
tuples of that relation than the null values will not be considered during the calculation.But if we use count(*) over some
relation than it will consider the null values as well.So count(*) will return count of all the tuples in that relation.

 4 votes -- Aditya Sharma ( 687 points)

Aggregate function (like Count(), Sum(), Avg()) ignore null values.


Now what about count(*) ?

In case of Count (Marks) it count number of NON NULL rows. Count(Marks) discards those rows in which Null is present. Here
Domain is Marks Column.

Same Analogy with Count(*) also. It counts every non null rows.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 842 of 2244

let there is Student table S and with attributes : Name, DOB, Subject & Marks.

Now Count(*) count no of row in which atleast one column is Non NULL otherwise discard that row. If every column of a particular
row is filled with NULL (which really not a good database) then count(*) also ignore that row. For Count(*) domain is all column so
it will check null value in every column unlike Count(Marks) see NULL values only in Marks Column.

Count(), Count(*) both excludes those rows in which every column is NULL.

 4 votes -- Digvijay Pandey ( 26245 points)

count(*) will return count of all the non-null tuples in the relation & ignore the count for tuples with all null values.

 1 votes -- Vivek Srivastava ( 283 points)

7.173 Sql: Sql group by clause? top gateoverflow.in/29380

How does group by works. ya it make groups of the data . and what i know it will group the data. what what i found on
running on the online tutorials is that , the group by only shows me one entry for every distinct entry, can someone plz
explain the way this group by works??

sql

The group by clause will gather all of the rows together that contain data in the specified column(s) and will allow aggregate functions to be
performed on the one or more columns.

 0 votes -- Tarani Behera ( 47 points)

7.174 Sql: Question on calculating the number of tuples in result of a


database query top gateoverflow.in/34022

I couldn't understand its solution. Please explain

databases sql

7.175 Sql: Which of the following SQL queries find the managers of the

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 843 of 2244

Branches with total asset over 10000? top gateoverflow.in/5895

Consider the following relations:

Customer (cid, name, city)


Branch (bid, manager, city)
Account (accid, bid, cid, balance)

bid is foreign key of Account referencing Branch, cid is the foreign key of Account referencing Customer.

Which of the following SQL queries find the managers of the Branches with total asset over 10000?
a.
SELECT b.manager
From Branch b
WHERE (SELECT SUM (balance)
FROM Account a
WHERE a.bid = b.bid) > 10000

b.
SELECT b.manager From Branch b, Account a WHERE a.bid = b.bid
GROUP BY b.bid HAVING SUM (a.balance) > 10000

c. Both (a) and (b)


d. None of these

databases sql

i think only A is correct but not B because manager attribute shuld be in group by clause.

 2 votes -- Aryan ( 223 points)

7.176 Sql: What is the result of the given query? top gateoverflow.in/16813

SELECT Lname, Fname


FROM EMPLOYEE
WHERE NOT EXISTS (
SELECT *
FROM WORKS_ON B
WHERE ( B.Pno IN (
SELECT Pnumber
FROM PROJECT
WHERE Dnum=5 )
AND NOT EXISTS (
SELECT *
FROM WORKS_ON C
WHERE C.Essn=Ssn
AND C.Pno=B.Pno )));

Works_On table has details of projects the employee works on and project contains details of various projects running in
various department.

What details does the above query fetches? Please explain the steps to solve this query.

sql

Gives details of employees who either don't work on a project in department no. 5 OR works on a project with essn=ssn
(social security number?)

 0 votes -- Arjun Suresh ( 124125 points)

7.177 Sql: sql query top gateoverflow.in/36919

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 844 of 2244

sql

Option c is correct

 0 votes -- Shefali ( 765 points)

7.178 Sql: Navathe-Fundamentals of Database systems-basic SQL-sixth


edition-4.12 top gateoverflow.in/42256

Specify the following queries in SQL on the database schema of Figure 1.2.

Figure 1.2:
A database that stores
student and course
information.Caption

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 845 of 2244

a. Retrieve the names of all senior students majoring in ‘CS’ (computer science).
b. Retrieve the names of all courses taught by Professor King in 2007 and
2008.
c. For each section taught by Professor King, retrieve the course number,
semester, year, and number of students who took the section.
d. Retrieve the name and transcript of each senior student (Class = 4)
majoring in CS. A transcript includes course name, course number, credit
hours, semester, year, and grade for each course completed by the student.

descriptive databases sql navathe

1. Select Name from STUDENT where Major = "CS".

 0 votes -- Anirudh Pratap Singh ( 4091 points)

7.179 Sql: SQL query top gateoverflow.in/10602

Consider the relation Emp ( SS#, name , age , salary, dno )

Dept(dno, dname, floor , mgrSS#)

Retrieve the social security number of those employees who work in both the show and toy department

A) Select distinct e.SS#

from Emp e , Dept d

where e.dno = d.dno and dname= 'toy'

intersect

(select distinct e.SS# from emp e , dept d

where e.dno= d.dno and d.name='shoe '

B)

Select distinct e.SS#

from emp e , dept d

where e.dno= d.dno and d.dname='toy' and d.dname='shoe'

c) Both a and b

sql


Selected Answer

A only. B is false as for a single tuple, dname cannot be both 'shoe' as well as 'toy' and hence this query returns {}.

 3 votes -- Arjun Suresh ( 124125 points)

7.180 Sql: SQl query top gateoverflow.in/10601

Consider the relation Customers (custid, name , address , city , state , introducer)

List all the customers who have introduced at least one other customer

1) Select distinct e.name from Customer e, Customer F where f.introducer =e.ename

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 846 of 2244

2) Select distinct e.name from Customer e, Customer F where f.introducer <>e.name

sql


Selected Answer

1 should work.

 2 votes -- Arjun Suresh ( 124125 points)

7.181 Sql: Navathe-Fundamentals of Database systems-basic SQL-sixth


edition-4.10 top gateoverflow.in/42206

Specify the following queries in SQL on the COMPANY relational database schema shown in figure 3.5 .Show the result of
each query if it is applied to the COMPANY database in Figure 3.6

a. Retrieve the names of all employees in department 5 who work more than 10 hours per week on the ProductX project.
b. List the names of all employees who have a dependent with the same first name as themselves
c. Find the names of all employees who are directly supervised by "Franklin Wong".

FIGURE 3.5: Schema diagram for the COMPANY relational database schema.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 847 of 2244

FIGURE 3.6:One possible database state for the COMPANY relational database schema

databases descriptive sql navathe

7.182 Sql: A relational table employee. top gateoverflow.in/5914

A relational table Employee (ENo, EName, Dept) has 88 number of tuples. What will be the result of following SQL statement?

SELECT COUNT (ENo) FROM Employee WHERE ENo NOT IN (NULL);

a. 88
b. 44
c. 0
d. 87

sql databases

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 848 of 2244


Selected Answer

Where E_no not in NULL - the predicate evaluates to unknown. so no rows will be printed.

 8 votes -- shreya ghosh ( 2801 points)

7.183 Sql: What is the result of a condition when a subquery returns zero
tuples ? top gateoverflow.in/16869

I was reading an article regarding the use of ALL, SOME, ANY operators https://oracle-base.com/articles/misc/all-any-some-
comparison-conditions-in-sql . In the ALL section, it was mentioned that " If a subquery returns zero rows, the
condition evaluates to TRUE" . In the ANY section, however, it was mentioned that " If a subquery returns zero rows,
the condition evaluates to FALSE." . Why are the results of the same subquery different for two operators ? It should
evaluate to false for both the cases. What am I missing here ?

databases sql


Selected Answer

ALL ( {} ) = TRUE

ANY ( {} ) = FALSE

This is just the semantic of ALL and ANY. ALL means the condition must be true for ALL tuples and hence this becomes
trivially TRUE for {}. ANY means there must exist at least one tuple for which the condition is TRUE and hence this
becomes trivially false for {}.

 2 votes -- gatecse ( 9515 points)

7.184 Sql: Finding output of given SQL query top gateoverflow.in/29981

Given answer: B
I don't know how to deal with NULL in such query operations. Please explain.

sql databases

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 849 of 2244

given answer is wrong...null is not arithmatic comparable ..only last tuple will be qualified.

 1 votes -- sultan ( 35 points)

7.185 Testbook: TestBook Live Test Q No 29 top gateoverflow.in/36137

I think here even with Ph is removed from table we still get 12 Super keys. Because Salary & One of CK must be there.

test-series testbook databases

24 should be ans

 1 votes -- Pooja ( 22773 points)

7.186 Testbook: TestBook Live Test Q N0 47 top gateoverflow.in/36129

Consider STUDENT table with following tuples:


SName CPI
Deepak 8.7
Dilip 9.7
Kaustav 8.5
Pallab 9.8
Sourav 8.7
Swapnil 8.5
(SELECT *
FROM STUDENT S1
WHERE 3 >= (SELECT COUNT(*)
FROM STUDENT S2
WHERE S1.CPI <= S2.CPI) )
UNION
(SELECT *
FROM STUDENT S1
WHERE S1.CPI > ALL (SELECT CPI
FROM STUDENT S2
WHERE 5 >= (SELECT COUNT(*)
FROM STUDENT S3
WHERE S2.CPI <= S3.CPI)) )

How many number of tuples are there in the output ?

I'm getting 2 as the answer, while the given answer is 4.

test-series databases testbook

Answer is 2 :)

http://sqlfiddle.com/#!9/52ba3d/1

Thanks To @Pragy for this link !

 0 votes -- Akash ( 26315 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 850 of 2244

7.187 Transactions: How many conflict serializable schedules are possible ?


top gateoverflow.in/20582

The transactions T1 and T2 are given as follows:

T1: R1(A) W1(A) R1(B) W1(B)

T2 : R2(B) W2(B) R2(C) W2(C)

The total number of conflicts serializable that can be formed by T1 and T2 are

Answer :20 (incorrect)

The correct answer is 14

transactions

7.188 Transactions: In 2 Phase locking protocol, how does a deadlock


happen ? top gateoverflow.in/17872

According to 2-phase locking protocol, if a transaction acquires an exclusive lock on any object, another transaction cannot
obtain any kind of lock on it till the first transaction unlocks it.

Is the reverse also true, i.,e., if a transaction acquires a shared lock on any item, then any other interleaving transaction
cannot acquire any kind of lock on it..? or it cannot acquire exclusive lock, but can acquire shared lock. ?

databases transactions


Selected Answer

let there be two transaction T1 and T2

T1 T2

s(A)r1(A)

x(B) w2(B)

x(A) w2(A) here it is denied T2 waits for T1

s(B)r1(B) here it is denied T1 waits for T2

so its a deadlock situation.

 2 votes -- Umang Raman ( 10379 points)

If a transaction is holding a shared lock on a data item then only shared lock is possible by any other

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 851 of 2244

transaction on the same item.

or

If a transaction is holding a xclusive lock on a data item then neither shared nor xclusive is possible by any
other transaction on the same item

 2 votes -- Vivek sharma ( 1177 points)

7.189 Transactions: What is the difference between a Strict schedule and a


Cascadeless schedule ? top gateoverflow.in/17082

I am unable to differentiate between a strict schedule and a cascadeless schedule...although what I have understood is that
in strict schedule, we cannot perform read/write till the other transaction commits..but isnt this condition also valid for
cascadeless schedules ?
Can someone please explain by giving an example.

databases transactions

Strict schedules

---> A schedule is strict if: " A value written by a transaction T is not read or overwritten by other transactions until T
either aborts or commits.

---> Strict schedules are recoverable and cascadeless.

Cascadeless schedules

---> Even if schedule is recoverable, several transactions may need to be rolled back to recover correctly.

---> Cascading Rollback: a single transaction failure leading to a series of rollbacks

T1 T2 T3
R(A)
R(B)
W(B)
R(A)
W(A)
R(A)
Abort

---> Cascadeless schedule: For any transactions Ti and Tj: if Tj reads data written by Ti, then Ti commits before read
operation of Tj.

--> On a cascadeless schedule a transaction T2 cannot read a value a if a transaction T1


wrote a
before that and didn't commit.

---> On a strict schedule T2 also wouldn't be able to write a after T1


wrote it (even if it read a before T1 wrote it).

If you read carefully, the definition of strict says "not read or


overwritten". That's the difference.

from the Wikipedia page on the subject:

Another
Solution

CASCADING ROLLBACK
An uncommitted transaction has to be rolled back because it read an item from a transaction that failed. This is the case for Se.

This form of rollback is undesirable, since it can lead to undoing a significant amount of work. It is desirable to restrict the schedules to
those where cascading rollbacks cannot occur.

A schedule is said to avoid cascading rollback if every transaction in the schedule reads only items that were written by committed
transactions. This guarantees that read items will not be discarded.

STRICT SCHEDULE

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 852 of 2244

Transactions can neither read nor write an item X until the last transaction that wrote X has committed or aborted.

Strict schedules simplify the recovery process.

The process of undoing a write (X) operation of an aborted transaction is simply to restore the before image, the old-value for X.

Though this always works correctly for strict schedules, it may not work for recoverable or cascadeless schedules.

EXAMPLE:

Sf: w1(X, 5); w2(X, 8); a1;

Hope this will help.

 2 votes -- Mukesh Sharma ( 37 points)

7.190 Transactions: Number of Cascadeless Schedules top gateoverflow.in/32150

Consider the following Two Transactions.

How many Cascadeless schedules are possible over T1 & T2 ?

a. 32
b. 42
c. 51
d. 52

databases transactions

This question is from a previous question.

http://gateoverflow.in/31867/how-many-recoverable-schedules-are-possible-from-t1-and-t2

nilamd answered the question correctly, i.e. 42

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 853 of 2244

I am trying to explain the answer. As shown on the previous question, there are 51 recoverable schedules. All Cascadeless
schedules are also Recoverable schedules. Thus, we need to find the Cascading Recoverable schedules and we can remove
them from the Recoverable Schedules to get the possible number of cascadeless schedules.

Two cases arise again.

Case 1

T1 T2
r(x)
r(y)

w(x)
r(x)
w(x)
w(y)
commit
commit

Here, we can have the two last operations from T1 either before r2(x), between r2(x) and w2(x) or after w2(x). Also keep
in mind that if you count the case where both w1(y) and commit1 come before r2(x) then it will become cascadeless
schedule. We need to keep the schedule cascading but Recoverable. Number of possible ways of placing w1(y) and
commit1 in different places is 5.

Case 2

T1 T2
r(x)
w(x)
r(x)
r(y)
w(x)
w(y) commit
commit

Here also, we can have commit2 not before r1(x) since then it will also become cascadeless schedule and also commit2
cannot come after commit1 since then it will be Irrecoverable schedule. Number of possible places to have commit2 in
different places is 4.

Thus, total number of cascading schedules is 5 + 4 = 9

Number of cascadeless schedules is 51 - 9 = 42

 3 votes -- Utk ( 1385 points)

7.191 Transactions: Consider 3 transactions T1, T2 and T3 having 2, 3 and 4


operations respectively. top gateoverflow.in/7514

Consider 3 transactions T1 , T2 and T3 having 2, 3 and 4 operations respectively. Find the number of concurrent schedules?

transactions databases


Selected Answer

Total operations = 2+3+4=9


Total no. of concurrent schedules : 9C2 * 7C3 = 1260

1. We need to maintain order of operations of an individual transaction [or it won't be a schedule] in the final interleaved
schedule.
2. Out of the 9 possible positions we choose 2 places for T1 and place it operations sequentially , then we choose 3 places
for T2 and place its operation sequentially , The remaining 4 places are used for T3 .

 4 votes -- done ( 509 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 854 of 2244

7.192 Transactions: how many view equivalent serial schedules are possible
top gateoverflow.in/36024

how many view equivalent serial schedules are possible for the given schedule s: w1(a) r2(a) w3(a) r4(a) w5(a) r6(a)

a) 2

b) 3

c) 6

d) 8

transactions

7.193 Transactions: Conservative 2 phase locking. top gateoverflow.in/34945

Is it Conservative 2 Phase locking (C2PL) ?

T1

LOCK-X (A)
LOCK-S (B)
R(A)
R(B)
W(A)
UNLOCK (A)
COMMIT
UNLOCK (B)

databases transactions


Selected Answer

yeah it is conservative cause in conservative u have to acquire all lock before transaction starts,but u acn release it at any
time.but it is not strict or rigorous.in strict u can only release shared lock before commit operation,but u cannot release
xclusive lock before commit,and in rigorous u cant relaese any lock before comit.

 4 votes -- Sayantan Ganguly ( 5061 points)

7.194 Transactions: ISRO-2013-23 top gateoverflow.in/43854

Which of the following is the highest isolation level in transaction management?

A. Serializable
B. Repeated Read
C. Committed Read
D. Uncommitted Read

isro2013 databases transactions

Option A is correct here.

Serializable is the highest isolation level in transaction management.

Source:https://en.wikipedia.org/wiki/Isolation_%28database_systems%29

 0 votes -- Manojk ( 3365 points)

7.195 Transactions: How many recoverable schedules are possible from T1


and T2? top gateoverflow.in/31867

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 855 of 2244

Common data for Q.32 & Q.33

Consider the following Two Transactions.

How many recoverable schedules can be formed over T1 & T2 ?

a. 51
b. 52
c. 55
d. 56

transactions databases


Selected Answer

Ans is (a) 51

∵ Number of Recoverable Schedule = All Concurrent Schedule - Number of Irrecoverable Schedule

All Concurrent Schedule :

If There are two transaction Ti and Tj with x and y operation respectively then

number of concurrent schedule possible = x+yCx or x+yCy

In our case, x = 5 and y =3

So All possible Concurrent Schedule = 8C3 = 56

Irrecoverable Schedule :

A schedule with two transaction T i and T j becomes Irrecoverable, if

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 856 of 2244

Transaction Tj reads a data item updated by Transaction T i and Tj Commit before T i

Ref : https://en.wikipedia.org/wiki/Schedule_(computer_science)#Unrecoverable

So to make Irrecoverable schedule in our case here there are two possibilities

Case 1: T2 reads data item X, updated by T 1 and T2 commit before T 1

To Satisfy this condition, we need to schedule w 1(x) before r 2(x) and Commit T 2 before T1.

This way our Transaction schedule of T 1 and T 2 may look like below

T1 T2
r(X)
r(Y)
w(X)

r(X)

w(Y) w(X)

Commit

Commit

All Bold Red colored and operation can be perform any order by keeping operations of each transactions in same order as
they were given, still the schedule will be Irrecoverable.

So Number of ways to arrange there bold red colored operations to make schedule = 4C1 = 4

Total Number of Irrecoverable schedule possible in this case = 4

Case 2 : T1 reads data item X, updated by T 2 and T1 commit before T 2

To satisfy this condition, there only one possible way because you have to perform w 2(X) before r1(x) and Commit T 2
after commit of T 1.

T1 T2
r(X)
w(X)
r(X)
r(Y)
w(X)
w(Y)
Commit
Commit

Number of Irrecoverable Schedule in Case 2 = 1

So Number of Irrecoverable Schedule = 4 + 1 = 5

∵ Number of Recoverable Schedule = All Concurrent Schedule - Number of Irrecoverable Schedule

= 56 - 5 = 51

 9 votes -- Sandeep Singh ( 5939 points)

7.196 Transactions: time stamp ordering top gateoverflow.in/3007

Consider the following sequence of actions.


r1(A) r2(B) w1(C) r3(B) r3(C) w2(B) w3(A)
Which of the following time stamp ordering allowed to execute the schedule using basic time stamp protocol?

A) (T1, T2, T3) = (10, 30, 20)


B) (T1, T2, T3) = (20, 30, 10)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 857 of 2244

C) (T1, T2, T3) = (30, 20, 10)


D) (T1, T2, T3) = (10, 20, 30)

databases transactions


Selected Answer

Consider A-> T1 is reading it and then T3 is writing to it. While reading, R-ts(A) is set to max( R-ts(A), TS (1)). So, if R-
ts(A) is So, T3 > T1

Consider B-> T2 is reading it and then T3 is again reading it and T2 is then writing to it. So, T2 > T3 (Reading only
updates R-ts and and checks only W-ts)

Consider C -> T1 is writing to it and T3 is reading from it. So, T3 > T1

Thus, T1 < T3 < T2- option (A).

http://courses.cs.vt.edu/~cs5204/fall00/distributedSys/bto.html

 2 votes -- Arjun Suresh ( 124125 points)

7.197 Transactions: Unrepeatable read problem top gateoverflow.in/19258

transactions


Selected Answer

Unreapeatable problem.means we get different values in different reads.For eg in S1 say T2 read intially x=5 then T1
updated x=1 so now T2 will read x=1 here T2 has read two different values during consecutive reads This shouldnt have
been allowed as T1 has nit committed..do ans is a ie S1

 0 votes -- Pooja ( 22773 points)

7.197 Transactions: please explain with the help of example WW problem


and lost update problem and what is the difference between them? top gateoverflow.in/3862

databases transactions


Selected Answer

Lost update problem is really simple.

Deposit (10)
A = A+10;

View Balance:
print A

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 858 of 2244

Now, suppose initial balance A is 100 someone deposits 20 by calling Deposit(10) two times and then called View Balance
to view the updated balance. If they are called sequentially no problem here. But suppose they are called concurrently:

Suppose in first call to Deposit,


A = A + 10;

Here, A is read, 10 is added to it and A+10 is stored back to A.

Similarly happens in next call to Deposit. But if the read of A in second happens before the final store to A in first call, the
first call of Deposit has no effect. The update done by first Deposit is lost (when the second Deposit stores the value it will
be 110 and not 120 as it has read 100 instead of 110)- and this is called Lost update problem.

WW problem

 1 votes -- Arjun Suresh ( 124125 points)

7.198 Transactions: How is this schedule not allowed in Strict 2PL, but
allowed in 2PL ? top gateoverflow.in/18915

[ ]
T1 T2
R(A)
W(A)
R(A)
W(A)
R(B)
W(B)
Commit
Abort

How is this schedule allowed in 2PL ? In 2PL , there must be a growing phase in , which is not present in T2 ..?

This example is given in the book by Raghu Ramkrishnan on page 529 and 552 (for reference)

databases transactions

T1 T2
Lock(A)
R(A)
W(A)
Unlock(A) // Assuming that T1
does not need any more locks or
those locks before unlocking it
Lock(A)
Lock(B)
R(A)
W(A)
R(B)
W(B)
Unlock (A)
Unlock(B)
Commit

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 859 of 2244

Abort
T1
T2
This is how it is possible to implement 2 Phase locking. I think you can see growing & shrinking phase. Issue is that 2
Phase locking in itself does not maintain good property like Deadlock or say recoverable schedule, just like Semaphore are
used for synchronizing but we need to use them wisely, or they can cause deadlocks ! It is possible to follow 2 Phase
locking , even when resulting schedule is not recoverable.

 0 votes -- Akash ( 26315 points)

7.199 Transactions: ISRO-2013-23 top gateoverflow.in/43855

Which of the following is the highest isolation level in transaction management?

A. Serializable
B. Repeated Read
C. Committed Read
D. Uncommitted Read

isro2013 transactions

Answer is Serializable ---Highest isolation level and Lowest one is Read Uncommitted

The Isolation level are defined for transaction :

We will see what violation can happen with each isolation level : violation are Dirty read , Non repeatable read, Phantom .

The first one is Read Uncommitted : So here Dirty read , Non repeatable read, Phantom . all are possible

The second One is Read Committed : It reads the data after the another transaction is committed But it doesnt guarantee
That the next time it will read the same data value then it will get same old value .. Dirty read--Not possible , Non
repeatable read--Possible , Phantom-- Possible .

Third one : Repeated Read : : It reads the data after the another transaction is committed But it guarantee That the next
time it will read the same data value then it will get same old value .. Dirty read--Not possible , Non repeatable read--not
possible, Phantom-- Possible .

Fourth One is : Serializable : It is highest and toughest isolation level . It will give always Consistent result . It would have
schedules equivalent to Serial Schedules .Dirty read--Not possible , Non repeatable read--Possible , Phantom-- Not
Possible .

 0 votes -- Dexter ( 1933 points)

7.200 Tree: madeeasy testseries DB b+ tree top gateoverflow.in/37743

The maximum number of records that can be indexed for a B+ tree of 4 levels with order 10 and root at level 1 are
_________.

made-easy_test-series databases b tree


Selected Answer

order 10 means here block pointer so means every node has 9 Record pointer but take care that record pointer is present
only at leaf level ,not in in internal nodes of tree becoz its B+ TREE..

first level 1 nodes


2 nd level 10 nodes
3 rd level 100 nodes
4 th level 1000 nodes
now every node has 9 Record pointer so each node has 9 Record Pointer with KEYS as pairs so for 1000 nodes we have
9000 record pointers means it can index 9000 records

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 860 of 2244

 1 votes -- kunal chalotra ( 3567 points)

7.201 Update: Navathe-Fundamentals of Database systems-basic SQL-sixth


edition-4.7 top gateoverflow.in/42038

Consider the LIBRARY relational database schema shown in the figure below .Choose the appropriate action (reject, cascade,
set to NULL, set to default) for each referential integrity constraint, both for the deletion of a referenced tuple and for the
update of primary key attribute value in a referenced tuple.Justify your choices

databases referential-integrity navathe descriptive update delete

7.202 View_serializable: TestBook Live Test Q No 46 top gateoverflow.in/36132

view_serializable databases test-series testbook

answer is non serilizable.i just can write a table to show dependency,but this question's answer is correct

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 861 of 2244

 0 votes -- viv696 ( 1431 points)

7.202 View_serializable: From where should I study view serializability? top


gateoverflow.in/38927

view_serializable databases


Selected Answer

i think this will help you

https://www.youtube.com/watch?v=0uhCfZ-ePy8

 1 votes -- Shah Himadri Satishbhai ( 171 points)

7.203 View_serializable: View serializable top gateoverflow.in/39011

S: T1(A)R2(B)W2(B)R2(A)W2(B)W1(A)R3(B)W3(B)

Given schedule is view serializable ?

view_serializable databases transactions

yes of course it is a VS

now as we know VS have some steps

1>every TA should STARTs with READ operation.

2>every TA should have READ-WRITE conflict.

3>TA should ENDS with WRITE operation.

Here,this schedule is fulfilling all the terms so this is a VS.

 0 votes -- Shah Himadri Satishbhai ( 171 points)

7.204 View_serializable: DBMS: Consider the following schedule top gateoverflow.in/39309

Consider the following schedule


S : r 1 (A) w2 (A) commit2, w1 (A) w3 (A) commit3, commit1
Which of the following is true?

a. Schedule is view serializable schedule and strict recoverable schedule


b. Schedule is non serializable schedule and strict recoverable schedule
c. Schedule is non serializable schedule and not strict recoverable schedule

d. Schedule is serializable schedule and not strict recoverable schedule

dbms view_serializable

Yes!. The answer id option D.

It is not strict recoverable schedule and doesn't statisfy the conflict serializable, but we have blind write so checking for
view serializable and it statisfies view serializable.

 1 votes -- Prasanna Ranganathan ( 2045 points)

7.205 View_serializable: View serializable top gateoverflow.in/38902

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 862 of 2244

With the help of blind write how we know that given schedule is view serializable

view_serializable

It is not necessary for a schedule to have blind write in order to be view serializable , only if u find a schedule which is not
conflict serializable u go for checking whether it is view serializable or not ,Now if blind writes are there then there may be
a possibility that the schedule is view-serializable and if blind writes are not present then the schedule is not even view
serializable , So now if the schedule is view-serializable , if You are able to get a sequence of transactions so that they
follow all the constraints which are necessary for a schedule to be view-serializable then u r done .

You need to make sure that the transaction which makes last update should also make last update in the view-equivalent
schedule and the transaction which reads the initial data item should also read the initial data item in the view-equivalent
schedule , since it is a NPC problem so you can't do it in polynomial time but if u r given 2 to 3 transactions u can easily
verify if u can design a view-equivalent schedule or not .

 0 votes -- radha gogia ( 4369 points)

7.206 View_serializable: View serializable top gateoverflow.in/37733

S: r1(x),r2(x),w1(x),w2(x) it is view serializable or not

view_serializable

The given schedule is not conflict serializable so now check for blind writes , if u get blind writes then the schedule may or
may not be view serializable but if there are no blind writes then the schedule cannot be view serializable .And here we
don't have any blind writes so the schedule is not view -equivalent to any serial schedule .

 1 votes -- radha gogia ( 4369 points)

7.207 View_serializable: Seriaizability top gateoverflow.in/34138

dbms transactions view_serializable

There is a cycle formation between T3 to T4 due to W(B) and T4 to T3 due to R4(A) and W3(A) . Hence the schedule is
non serializable . We cannot say anything about about view serializibility here becoz for that we need atleast 2 schedules.
Therefore ans should be D.

 1 votes -- Riya Roy ( 4767 points)

7.208 View_serializable: View and conflict Serializability top gateoverflow.in/37201

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 863 of 2244

I want to confirm my answers..

For 19.2.1

a) VIEW equal serial order T1 T2T3 or T2T1T3

b) VIEW equal serial order 6 possible orders

c) 2 VIEW equal serial orders

d) 2 VIEW equal serial orders

For 19.2.2

A) 2 VIEW equal serial orders and one conflict equal one

b) 1 VIEW equal serial orders and 1 conflict equal..

{ all schedules have 1 conflict equal serial order}

Plz point out my mistakes.

view_serializable transactions databases

7.209 View_serializable: Method for checking view serializability top gateoverflow.in/29700

I know one method of checking view serializability in which we consider all the possible permutation of occurrences of
transactions and check for three conditions:
(1) Initial reads (2) W-R conflict (3) Final writes

I want to know is there any faster way to check view serializability?

view_serializable databases

7.210 View_serializable: view serializability top gateoverflow.in/26378

t1 t2

w(x)

r(x)

w(x)

commit

commit

Why is this not view serializable?

databases transactions view_serializable

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 864 of 2244


Selected Answer

if given schedule is equivalent to anyone of the serial schedule then given schedule is View Serial. for this we are checking
3 conditions as :

1. Initial read : No intital read in any Transaction. so T2 -----> T1 not possible.

2. Final Write : Final write should be done by T1. No write operation is T2 so it is allowed to execute eother T1----->T2 or
T2 -----> T1 bit T2 ----->T1 not possible as condition of Initial Read. now only option left is T1 ----->T1

3. Write Read sequence : if T1 --->T2 then T2 reads value of x after second update done by T1. so T1 -----> T2 also not
possible.

finally not View Serial.

 2 votes -- Digvijay Pandey ( 26245 points)

7.211 View_serializable: PROBLEM ON VIEW SERIALIZABILITY top gateoverflow.in/9429

check whether it is view serializable or not?

schedule S:R1(X),W2(X),W1(X)

view_serializable


Selected Answer

no it is not view serializable..


reason is there may b 2 schedule possible :
1. T1--->T2
2. T2----->T1z
in case 1 final write of x is done by T2, but in given question final write of x is done by T1. so it violates condition of view
serializability.
in case 2 initial read of T1 is updated value by T2 but in original question it is directly reads database.. again condition of
view serialization failed..

so not serializable schedule..

 4 votes -- Digvijay Pandey ( 26245 points)

The ans can be viewed here

 1 votes -- Sourav Roy ( 2353 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 865 of 2244

7.212 View_serializable: View serializable schedules top gateoverflow.in/19259

What are the view serializable schedules possible for this?

view_serializable

7.213 View_serializable: How to check the view serializability of a given


schedule ? top gateoverflow.in/17135

Suppose we have a schedule containing two transactions as shown-

[]
T1 T2
R(A)
W(A)
R(A)
W(A)
R(B)
W(B)
R(B)
W(B)

We will proceed to create the polygraph for the above schedule..my doubt is that do we need to create the polygraph for
both the items A, B or just a single polygraph for the entire schedule. If we create separate polygraphs, for A we will get t1-
>t2, and for B we will get t1->t2.. Same graph will be obtained if we draw a single polygraph

databases transactions view_serializable


Selected Answer

you should draw a single graph.else you will not succeed to figure out the cycle,alltime,which is an important thing for
deciding conflict or non conflict serialization

 3 votes -- Sayantan Ganguly ( 5061 points)

7.214 Virtual: Virtual gate -SQL top gateoverflow.in/38579

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 866 of 2244

Q). Consider the table employee(empid, name, department, salary) and the two queries Q1,Q2 below .Assuming that department 5 has
more than one employee, and we want to find the employees who get higher salary than anyone in the department 5 , which
one of the statements is TRUE for any arbitrary employee table?

Q1): SELECT e.empid FROM employee e WHERE NOT EXISTS (SELECT * FROM employee WHERE s.department = "5" and
s.salary ≥ e.salary)

Q2): SELECT e.empid FROM employee e WHERE e.salary > ANY (SELECT distinct salary FROM employee WHERE
s.department ="5")

(A). Q1 is the correct query

(B). Q2 is the correct query

(C) Both Q1 and Q2 produce the same answer

(D) Neither Q1 nor Q2 is the correct query

The correct answer is A

Is query1 correlated query?

sql query virtual gate

7.215 Virtualgate: VIRTUALGATE II Q.25 Which of the following is not true ?


top gateoverflow.in/37976

Which of the following is not true?

a. Generalization is the result of taking the union of two or more disjoint entity sets to produce a higher level entity set.
b. Specialization is an abstraction in which relationship sets are treated as higher-level entity sets.
c. Canonical covers are used to decompose a relation into 3NF, which is a small relaxation of the BCNF condition.
d. The concurrency control management component of the database is responsible for handling the concurrency control
policies.

virtualgate databases

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 867 of 2244

7.216 Virtualgate: Query interpretation Virtual Gate top gateoverflow.in/38765

The inner query in Q1 will select the employee having max salary from all other employees in all departments(this will return
the max salaried employee in the entire company which belongs to dept 5), and outer query will select all employees not in
the inner query. Is this interpretation right?

In Q2, inner query gives a list of all salaries of employees in dept 5, and outer query selects those employees from entire
company who have salary greater than anyone in dept 5.

Why is the answer Q1 and not Q2?

virtualgate sql databases

7.217 Where: SQL-DBMS top gateoverflow.in/36336

Hello,

What is the result for the given scenario:

Select * from table1 where (cond) ANY/IN/ALL/EXISTS/etc (sub query result empty)

If this is the question given and asked how many rows does it return then the answer would be ??

I know when we use > ALL for the above scenario it gives all the rows of table1.

Please add your points.

databases sql where

7.218 sql top gateoverflow.in/12594

In SQL we can use aggregate function without using GROUP by


clause. (TRUE /FALSE)

Yes it is possible .

eg : SELECT AVG(Price) AS PriceAverage FROM Products;

now see this

SELECT NAME , AVG(Price) AS PriceAverage FROM Products;

this is not possible . in that you have to place GROUP BY NAME . peace

 1 votes -- Pranay Datta ( 6113 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 868 of 2244

7.219 comment top gateoverflow.in/12548

Consider the following schedule:


S : r2(z), r2(y), w2(y), r3(y), w3(z), r1(x), w1(x), w3(y), w3(z), r2(x), r1(y),
w1(y), w2(x)

is this sechedule serializable ??


Selected Answer

Schedule is not Serial, not even Conflict Serial..

Cheking Vew Serial :

X initially read data from database so X should execute before Y & Z bcoz Y & Z both update x value..

X ----> {Y,Z} .............(1)

Final write of y done by transaction X. That means X should execute after Y & Z because both write y.

{Y,Z } ----> X. ..............(2)

(1) & (2) contradict each other ..

So schedule is not View Serial..

Non serialisable schedule..

 1 votes -- Digvijay Pandey ( 26245 points)

Its not a conflict nor view serializable .

 1 votes -- Pranay Datta ( 6113 points)

7.220 Is there any condition in which we can say that dense index is sparse
index?? top gateoverflow.in/12442

Is there any condition in which we can say that dense index is sparse index?

databases


Selected Answer

If each block contain only one record , then dense index will act like sparse index .

 4 votes -- Pranay Datta ( 6113 points)

7.221 number of tuples top gateoverflow.in/12600

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 869 of 2244

It will return 2 tuple ..

2 and NULL ..

Distict keyword treat all null vaues as same and select a common tuple for all NULL value..

 2 votes -- Digvijay Pandey ( 26245 points)

2 Tuples

for verification purposes : SQL_Fiddle

 1 votes -- Amar Vashishth ( 17865 points)

7.222 Made Easy top gateoverflow.in/37686

plz explain ..is natural join commutative and associative.

made-easy test-series databases

Yes, Natural join is both associative and commutative.

As per intuition, natural join filters the rows based on the criteria. So, it does not really matter in what sequence we do
this filtering because the invalid rows are going to be discarded sooner or later.

This gives you more information.

 1 votes -- Gaurav Sharma ( 1383 points)

7.223 Number of conflict serializible schedules top gateoverflow.in/37446

Number of conflict serializible schedules in

T1 : R(A) W(A) R(B) W(B)

T2: R(A) W(A) R(B) W(B)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 870 of 2244

do same for T2----->T1


and two more Serial Schedule T----->T2, T2----->T1

Two interleaving and two Serial Total four Conflict Serialisable Schedule Possible..

 2 votes -- Digvijay Pandey ( 26245 points)

7.224 explain top gateoverflow.in/13323

If R and S are two relation in BCNF the natural join of R and S is also
in BCNF.

above statement true or false.??

databases

False. It is logical, while converting a 3NF relation to BCNF we decompose a 3NF relation into two BCNF relation, and in
some cases we get lossless decomposition , so joining 2 BCNF relation is not a BCNF relation

 0 votes -- Shohra Afaque ( 17 points)

7.225 Minimum no. Of table top gateoverflow.in/37158

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 871 of 2244

3 Tables.

1) E2

2) E3

3) E1 which depends on E2 for its existence.

 0 votes -- Harsh Patil ( 31 points)

7.226 madeeasy test series top gateoverflow.in/37211

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 872 of 2244

why table for phones is not considered here..? :)

Has table represents phone only i.e. which customer is having which phone.

 0 votes -- Shefali ( 765 points)

7.227 Transactions top gateoverflow.in/12678

If schedule is not clear in image

Schedule is W 1(A),R2(A),W3(C),W1(B),W2(C),R3(B),R2(B)

i think it`s allowed under TWR (so, it will allow under MVTS )

the order is T1 > T2 > T3

the answer is A

 1 votes -- Pranay Datta ( 6113 points)

7.228 explain? top gateoverflow.in/12606

R is relationship with 1 : 1 cardinality, 30% participation at E1 end 70%


participation at E2 end which is the best possible design?
a. E1 and E2 kept separate with foreign key at E1 end
b. E1 and E2 kept separate with foreign key at E2 end
c. E1 and E2 kept separate with foreign key at E1 as well as E2
d. E1 and E2 merges into a single table with no foreign key

To me I think now

Because of 1 to 1 mapping it can merges into a single table . No need for FK .If we do then we have a problem to select
primary key . So , E1 and E2 kept separate , and we will foreign key at E2 because 70% participation at E2 ,because of

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 873 of 2244

that null value at E2 will be less .

In case of E2 if i choose foreign key at E1 then participation at E1 30% , so the Null values will be increased .

Option B is correct .

I might be wrong but to me i think I`m right :P .

 0 votes -- Pranay Datta ( 6113 points)

7.229 comment top gateoverflow.in/12418

T1:W(X), T2:R(Y), T1:R(Y), T2:R(X)

• Is it conflict serializable, view serializable, serializable, recoverable, avoids cascading aborts, strict?

It is surely Conflict serializable => View Serializable => Serializable

Commit information is not given so its not possible to conclude anything about Recoverability

 2 votes -- Amar Vashishth ( 17865 points)

its clearly conflict serializable so it must be view serializable also .

Recoverable says that the which transaction is write 1st must be commit 1st , and there is no commit statement so its
recoverable but its not cascade less its cascading because T2 is reading a R(x) which is written by T1 and T1 did not
commit after writting .

 1 votes -- Pranay Datta ( 6113 points)

7.230 serializability top gateoverflow.in/12362

option (A) is correct

precedence graph contain cycle so it is not conflict serializable

but the same schedule is view serializable because due to presence of BLIND WRITE IN transaction T2 ,T3.!! :)

 0 votes -- kunal chalotra ( 3567 points)

7.231 y not a? many time confuse in this kind of questions top gateoverflow.in/12117

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 874 of 2244

Manager’s salary details are hidden from the employee. This is called as

(A) Conceptual level data hiding (B) Physical level data hiding (C) External level data hiding (D) Local level data hiding

databases

answer will be conceptual level.physical implementation is same.It is the logical structure of the entire database as seen
by DBA. It Supports each external view: any data available to a user must be contained in, or derivable from the
conceptual level.

 0 votes -- Rohan Ghosh ( 1515 points)

7.232 ME_Test_Series - Database top gateoverflow.in/37982

Consider the following statement


(i) Primary index is always sparse
(ii) Secondary index may or may not be dense
Which of the above statement is/are false?

a) Only (i)
b) Only (ii)
c) Both (i) and (ii)
d) None of these

made-easy test-series databases

7.233 projection top gateoverflow.in/38106

The Project operation (∏ ) in relational algebra:

(i) Is used for eliminating duplicate rows automatically from the output.

(ii). Is used to filter columns.

(iii). Is a unary operator.

(iv). has degree of output relation same as input relation.

(A). (i). and (iii)

(B). (ii) and (v)

(C). (i) and (ii)

(D). (iv) only

project operation corresponds to select operation in sql except the fact that in sql select doesnt remove duplicates cause it
is expensive but project does remove duplicate so Option A is true..

It also filter out columns ..example ->consider a realtion with attribute A ,B,C ..project can be used to o/p the column

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 875 of 2244

A..so Option B is also true

Unary operator are those that takes only one realtion as i/p ..project,select and rename are unary operator so option C is
true

Degree of a relation means no of attributes but project can be used to o/p less number of columns as well .. so D is false

 0 votes -- Joker ( 685 points)

7.234 made easy top gateoverflow.in/38137

Consider a Table T with a key field K. A B tree of order P where P denotes the maximum number of record pointers in a B
tree. Assume K is 12 bytes long, disk block size is 1024 Bytes, record pointer is 6 bytes and block pointer size is 2 bytes
long. In order for each B tree node to fit in a single disk block the maximum value of P. Is answer correct?

made-easy test-series databases


Selected Answer

key field K = 12B, Record pointer R = 6B, Block pointer B = 2B


Disk block size is 1024B

n*B + (n-1)*(K+R) <= Disk block size


n*2 + (n-1)*(12+6) <= 1024
20n -18 <= 1024
20n <= 1042
n <= 52

 0 votes -- Digvijay Pandey ( 26245 points)

7.235 Index top gateoverflow.in/12077

(10)

for 10,000 records we require 100 blocks as question said only one block should present at a time in a
memory with access time of 10 MS than to access the block from memory is should require atleast 980
MSEC because our word is present in 98th block so first block access is (10+reamining access of 97 blocks

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 876 of 2244

will be 970 MSEC )but those 97 blocks should be replaced from secondary storage to memory and that time
should be added to 980 MSEC so i think answer should be 980 MSEC.

(11)

as primary index is built and index block contain 100 enteries ,there are 100 blocks of data file present and
each FIRST RECORD(ANCHOR RECORD) should BE MADE AS INDEX ENTRY so NO OF ANCHOR RECORDS
ARE 100 (i,e 100 BLOCKS) therefore 100 index entry in primary index

so to search index block need 10 MSEC AND AFTER THAT ACCCESING OF DATA FILE FURTHER REQUIRES
ONE BLOCK ACEESS

total 2 BLOCK ACCES =20 MSEC.

 0 votes -- kunal chalotra ( 3567 points)

7.235 Consider table R(A,B,C,D,E) with FDs as A->B, BC->E and ED-> A. The
table is in which normal form? Justify your answer. top gateoverflow.in/2896

Question is already answered:


http://gateoverflow.in/1285/consider-table-with-table-which-normal-form-justify-answer?show=1285#q1285

 2 votes -- Arjun Suresh ( 124125 points)

7.236 B+ Tree top gateoverflow.in/12122

In a B+ tree index file if there are K search keys and each leaf node contains n records then number of records to be
accessed in the worst case is

a)log2nk

b) lognk

c)logceil(k)n

d)logceil(n/2)k

Here ceil is ceiling function

Ans will be D) logceil(n/2)k

but dont know the explanation for this :D .

 0 votes -- Pranay Datta ( 6113 points)

7.237 expalin top gateoverflow.in/12356

if we use 3 key ,4 pointer nodes. how many different B tree are there when the data file has 6 records.

First, the six data records can be divided among the B-tree leaves in the following ways: 2-2-2 or 3-3. There are no other ways to divide size records, with
2 or 3 for each leaf.

In each of these two cases, there can be only one other node, the root, and it must point to each of the two or three
leaves. Again, there are no other ways to structure 2 or 3 leaves, with each interior node having 2 or 3 children. Our
conclusion is that there are only two different B-trees for 6 data records.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 877 of 2244

http://infolab.stanford.edu/~ullman/dbsisols/sol4.html#sol43

 1 votes -- sonam vyas ( 6441 points)

7.238 b + TREE explain..?? top gateoverflow.in/12350

with respect to the B+ TREE index method .select the true statements?

1 records are physically stored in primary key order

2 B+ tree use a hashing algo.

3 the index tree may become unbalanced as a result of updates

4 none of the above

A is false..Clustering index on non key .

B is false (obviously B+ tree need not follow hashing function)..

C. true.

Take a B+ tree with 3 keys {1,2,3} and 2 is root.. now update root value to 10.. tree will be unbalanced..

 1 votes -- Digvijay Pandey ( 26245 points)

7.238 Is decomposition upto 5NF required for gate? top gateoverflow.in/12323

there is no question on 5nf still..... but no one knows when a question on it will pop up.. so be ready

 1 votes -- Bhagirathi Nayak ( 10239 points)

4NF had been asked in past. Till now I haven't seen a question on 5NF.

 1 votes -- Arjun Suresh ( 124125 points)

7.239 The order of leaf node in b + tree ia the top gateoverflow.in/37873

What is the order of leaf node in the b+ tree

Let order be P_leaf. Then, P_leaf ( K+pr ) + P <= Block Size. This is the formula.

Where K is size of search key, pr is record ptr size ,P is block ptr or tree ptr size.

 0 votes -- Sreyas S ( 1353 points)

7.240 database explain top gateoverflow.in/13341

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 878 of 2244

databases

7.241 explain! top gateoverflow.in/13345

Suppose a phone book contain 500 pages and each page can contain
upto 500 records. Suppose we want to search for a particular name in a
phone book. Give a worst case bound on number of pages that must be
looked to perform a search using an index for the name of the first entry
of each page??

databases

2 (the index has 500 pages, so the entire index ​ts in one page; so
1 access to the index and 1 to the data).

 1 votes -- Rohan Ghosh ( 1515 points)

7.242 intersection operation top gateoverflow.in/36013

max no of rows=min(n1,n2)

min =0

ans a

 2 votes -- Pooja ( 22773 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 879 of 2244

7.243 serializibility top gateoverflow.in/36011

My Answer is option c im i wrong if so plz correct me

c is correct

 0 votes -- Shefali ( 765 points)

7.244 why is the below statement regrading weak entity correct ? top gateoverflow.in/14597

Weak entity set avoids the data duplication and consequent possible inconsistencies caused by duplicating the key of the strong entity..

plz clarify this........

databases

clearification of above statement is in two ways

(a) weak entity is totally participated in strong entity i.e. each element of weak entity is must have some element in
strong entity

but weak entity have not its own primary key it is identified by primary key of strong entity

(b) suppose if we duplicate the weak entity set then we have to duplicate the primary key as we know that primary key
must contain unique value which is not possible so there will be contradiction here

 0 votes -- saket nandan ( 1853 points)

7.245 ER DIAGRAM top gateoverflow.in/14517

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 880 of 2244


Selected Answer

I think C) is correct

one for phone ( phone , dno )

one for office ( office , dno )

and one for dept ( dno ,dname )

 4 votes -- Pranay Datta ( 6113 points)

I think it can be two

first table (dno,dname)

second table (dno,phone,office) with don,phone,office as key

 1 votes -- Pooja ( 22773 points)

(B) option with two tables table u can satisfy this... Dno ------>Dname Dno------>phone office as see obove
decomposition is in BCNF..

 1 votes -- kunal chalotra ( 3567 points)

7.246 How to draw E-R model for the below scenario ? top gateoverflow.in/14378

Each employee is assigned to a project work at only one location for that project, but can be at a different location for a different
project. At a given location, an employee works on only one project. At a particular location, there can be many employees assigned
to a given project.

databases

basically this can be broken down as .

employee works at on project . so always we make noun and object as entity so here project and employee can be entity
where as verb is the relationship . which is works at . so i think this can be the er diagram .

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 881 of 2244

 0 votes -- Ravi Singh ( 7303 points)

7.247 Non serial schedule top gateoverflow.in/36005


Selected Answer

total number of schedules = 8!/3!2!3!=560

no of serial schedules=3!=6

no of non serial schedules = 560-6=554

 2 votes -- Abhilash Panicker ( 6527 points)

7.248 How should the relation be decomposed so that it is in BCNF ? top gateoverflow.in/35910

In the relation R(ABCD) , AB-->C , C-->AD


How should the table be decomposed so that it is in BCNF , One decomposed relation will be ACD ,what should be other should it be BC , but if it is then there is no functional dependency

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 882 of 2244

corresponding to it and if I do ABC , then I have C-->A but C is not a superkey in ABC , so how should the decomposition be done ?

databases

Here , in this example , BCNF & Dependency preservation is not simultaneously possible .

This type of problem occurs when we have AB -> C , C -> A type of Dependency.

R1 (A C D) , R2 (B C) - If we decompose like this we are having BCNF , but AB -> C dependency is lost.

 2 votes -- Himanshu Agarwal ( 8861 points)

R(ABCD)

AB-->C C-AD

we can see candidate key here is{AB,BC}

For BCNF the FD Set:

X-->Y

where x should be super key

but we can see that C-->AD failed to satisfy bcnf.

Decompose into

R1(ABC) R2(CD) R3(AC)

AB-->C. C-->D. C-->A

Key{AB} Key{C} Key{C}

Minimum 3 table required ,2 Foreign key required.

BCNF not satisfied ,dp decomposition satisfied. If you want to satisfy BCNF You will definitely loose dp decomposition.

 1 votes -- Ankesh Gautam ( 665 points)

7.249 Consider a relational table r with sufficient number of records, having


attributes A1, A2,…, An and let 1 <= p <= n. top gateoverflow.in/15000

The database can be configured to do ordered indexing on Ap or hashing on Ap. Which of the following statements is TRUE?
(A) Ordered indexing will always outperform hashing for both queries
(B) Hashing will always outperform ordered indexing for both queries
(C) Hashing will outperform ordered indexing on Q1, but not on Q2
(D) Hashing will outperform ordered indexing on Q2, but not on Q1.

databases

Ap = C -Hashing would mean constant time to get the tuple from the index.

C1 ≤ Ap ≤ C2 - We need to scan a range of values in index to determined the matching tuples.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 883 of 2244

So, C should be the answer.

 0 votes -- Arjun Suresh ( 124125 points)

7.250 3nf Dependency top gateoverflow.in/14925

B and D should be the answer. If a prime attribute comes on the right side of a FD, then the left side will also become a
prime attribute due to this dependency. So, B and D options are the same.

A is avoided in 3NF.
C is the desired FD and is there in BCNF also.

 2 votes -- Arjun Suresh ( 124125 points)

7.251 how to solve below question of ER model ? top gateoverflow.in/14881

Consider an Entity-Relationship (ER) model in which entity sets E1 and E2 are connected by an m : n relationship R12, E1 and E3 are
connected by a 1 : n (1 on the side of E1 and n on the side of E3) relationship R13.

E1 has two single-valued attributes a11 and a12 of which a11 is the key attribute. E2 has two single-valued attributes a21 and a22 is the key
attribute. E3 has two single-valued attributes a31 and a32 of which a31 is the key attribute. The relationships do not have any attributes.
If a relational model is derived from the above ER model, then the minimum number of relations that would be generated if all the relations are
in 3NF is ___________.

How to approach this question ?

databases

Three tables would be required for three entities E1 ,E2,E3 now R12 is many to many relationship so new table will be
created with(a11,a21) as key.R13 is one to many relationship so need of extra table

E1(a11,a12)

E2(a21,a22)

E3(a31,a32,a11') a11' is foreign key

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 884 of 2244

R(a11,a21)

 1 votes -- Pooja ( 22773 points)

7.252 Number of SuperKeys top gateoverflow.in/35907

Q3). Consider the Relation R(A, B, C, D, E) and F. D ′ s are AB → CD, CD → E, E → AB then the total number of super key are:-

(A). 10

(B). 12

(C). 18

(D). None

The answer given is :

18 Superkeys.

{AB} + is key → superkey {ABC, ABD, ABE, ABCD, ABCE, ABDE, ABCDE}

{E} ∗ is key → superkey {EA, EB, EC, , ED, EAC, EAD, EBC, EBD, ECD, EACD, EBCD}

databases


Selected Answer

AB, CD and E are the candidate keys.

Take AB- pair it with any subset of {C, D, E} - 8 super keys. (4 including E)

Take CD- same as above- 8 super keys. But ABCD and ABCDE are counted twice. So, 6 more. (3 of them including E)

Take E- with {A, B, C, D} we get 16 super keys. But 4+3 = 7 are already counted. So, 9 more.

So, totally 8 + 6 + 9 = 23.

 3 votes -- Arjun Suresh ( 124125 points)

7.253 If there are mapping constraints in the E-R diagram , can we reduce
the size of the table ? top gateoverflow.in/14344

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 885 of 2244

I am not getting that how many attributes must be there in the Borrowed by table which actually represents a table since we
have the constraint that one user can borrow only one book .

databases

in above given e-r diagram one is to one relation is given since it hav both two arrows facing towards entity it means that
one user can take only one user and also conversly says that one book is borrowed by one user so in both entity book and
user one primary key that must be present in borrowed table i.e. accesetion no and card no. and one attribute is DOI of
borrowed relation so minimum attribute will be 3

 0 votes -- saket nandan ( 1853 points)

7.254 what do we mean by saying that A candidate key is a super key for
which no proper subset is also a super key ? top gateoverflow.in/14305

Since candidate key is a minimal key and it is a proper subset of a super-key , then how is it that for a candidate key ,its
proper subset is not a super key ?


Selected Answer

A candidate key is the minimal superkey. That means if we try to remove some attributes from the candidate key
(minimal super key) we will no more get a superkey as it was the minimal. Hence, any proper subset of the candidate key
is not a superkey.

 5 votes -- debanjan sarkar ( 775 points)

7.255 Relational algebra top gateoverflow.in/13939

Suppose I have 2 relations


R(stud_no,name,sex,course) and S(stud_no,course).Can someone says what the following operations returns?

∏ R − S(r) and ∏ R − S, S(r)

Sir ,I am not able to figure what these ∏ R − S(r) and ∏ R − S, S(r) expressions returns.Can u pls explain with an example?
Please do help...Thanks in advanvce..

This is the division operator. When we say (r / s)- first of all, the attribute set of r must be a super set of that of s. Now,

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 886 of 2244

(r/s) will select all tuples from r, which doesn't have any missing corresponding tuple in s- i.e., it works like a quotient.

Example:

R(stud_no,name,sex,course) and S(stud_no,course)

Let r = { < 10, Rahul, M, CS > , < 10, Rahul, M, Che > , < 11, Ben, M, CS > }, s = { < CS > , < Che > }

∏R −S(r) − ( ∏R −S ( ∏R −S(r) × (s) ) − ∏R −S,S(r) )


∏R−S (r) - Select all attributes of R but not S from r.
{ < 10, Rahul, M > , < 11, Ben, M > }
∏R−S ,S (r) - Select all attributes of R but not S union all attributes of S from r, which is same as selecting all attributes
from r, but with attributes of S at end so that we can subtract correctly.
{ < 10, Rahul, M, CS > , < 10, Rahul, M, Che > , < 11, Ben, M, CS > }

( ∏R−S ( ∏R−S(r) × (s) ) − ∏R−S ,S(r) ) - Take the cross product of r (after removing attributes of s) and s and subtract all
tuples in r. So, this returns the tuples in r × s for which r doesn't have a tuple.
∏R−S { < Rahul, M, 10, CS > , < Rahul, M, 10, Che > , < Ben, M, 11, CS > , < Ben, M, 11, Che > } − { < 10, Rahul, M, CS > , < 10, Rahul, M, Che > , < 11
= ∏R−S { < Ben, M, 11, Che > }
= { < 11, Ben, M > }

( ( ) )
So, ∏R−S (r) − ∏R−S ∏R−S (r) × (s) − ∏R−S ,S (r) = { < 10, Rahul, M > , < 11, Ben, M > } − { < 11, Ben, M > } = { < 10, Rahul, M > }

That is using division operator we are selecting the students who have selected ALL the courses.

 1 votes -- Arjun Suresh ( 124125 points)

7.256 database top gateoverflow.in/13926

decompose relation into 2NF ,3NF,BCNF

R(ABCDE) {AB--->C, DE----->C , B------->D}

R(ABCD) {AB----->C,C-------->D,D-------->A}

databases

For R(ABCDE) :
Decomposition into 3NF = [{ABC}, {BD}, {DEC}, {ABE} ]
Decomposition into BCNF = [{ABC}, {BD}, {ABE}] or [{ABE}, {BD}, {DEC}]

For R(ABCD) :
Decomposition into 3NF = [{ABC}, {CD}, {AD} ]
Decomposition into BCNF = [{ABC}, {CD}]

 1 votes -- Amar Vashishth ( 17865 points)

7.257 Candidate keys top gateoverflow.in/37028

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 887 of 2244

Q18). Consider the table R , with attributes A, B, C, D and E. What is the largest number of candidate keys at the same time?

a. 1
b. 5
c. 10
d. 31

As we know number of candidate keys with n number of attributes is 2n − 1.Then how to solve this question?

databases

10 is incorrect answer.

 0 votes -- Shefali ( 765 points)

7.258 solve top gateoverflow.in/13348

How many view equal serial schedules possible for the following
schedule?
S : w1(A) r2(A) w3(A) r4(A) w5(A) r6(A) w7(A) r8(A

databases


Selected Answer

according to view equivalence definition

1) any write by Ti followed by read by Tj , the same condition should be followed

2) last operation on some item should be same in view equivalence schedule.

all writes are blind writes in the given question.

last write on A is W7(A) . and it should be followed by R8(A). this sequence should be always appear at the end in any
euivalence schedule.

remaining 1. W1(A) should be follwed by R2(A)

2. W3(A) should be followed by R4(A)

3. W5(A) should be follwed by R6(A)

these 3 sequences can appear any order so = 3! = 6

please correct me if any mistake.

 2 votes -- pramod ( 2071 points)

7.259 what is the relationship between weak and strong entity ? top gateoverflow.in/14043

1:1

1:M

M:1

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 888 of 2244

M:N

A weak entity it self doesn't have a primary key and depends on the strong entity to form a primary key. For example
EMPLOYEE can be a strong entity and DEPENDENT a weak entity. An employee can have multiple dependents and a
dependent can have multiple concerned employees. So, the relationship is M:N, with the participation of weak entity being
TOTAL- there is no dependent without a concerned employee.

 0 votes -- Arjun Suresh ( 124125 points)

7.260 DBMS top gateoverflow.in/36701

databases


Selected Answer

It will print all the tuples of the table. So, answer will be 3.

Here EXISTS is not taking into consideration the result of COUNT(*) ,

Instead of this , if query would have been

SELECT * FROM T WHERE EXISTS ( SELECT B FROM T WHERE B = 2) , that would result in 0 tuples.

http://sqlblog.com/blogs/andrew_kelly/archive/2007/12/15/exists-vs-count-the-battle-never-ends.aspx

 0 votes -- Shounak Kundu ( 3757 points)

7.261 Does a relation actually exists in comparison to a table ? top gateoverflow.in/14217

I just read the difference between a table and a relation which actually states that a relation is a n-ary tupleof records which
cannot be duplicate while in a table we may have duplicate records so I am a bit confused that we actually represent a
relation using table only so then is it that a table without duplicate records is called a relation , plz clarify this that how do we
actually represent this relational schema in a database ?

A table is just a representation of a relation. You can say relation is a theoretical model and table is its practical
representation. A table can have duplicate entries unless it has a unique key constraint on some attribute while a relation
being a set cannot have duplicates.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 889 of 2244

Ref: http://www.quora.com/Is-there-a-difference-between-a-relation-and-a-table

 1 votes -- Arjun Suresh ( 124125 points)

7.262 Number of Superkeys [Test-Series] top gateoverflow.in/36553

Consider a relation R with 2n attributes. Assume any 2n/2 of the attributes constitutes key. Total number of super keys
possible are:
n− 1
a. 2n C2 n − 1 × (2)2
n− 1
b. 2n C2 n − 1 + (2)2
n− 1
c. 2n C2 n − 1 − (2)2
n− 1
d. 2n C2 n − 1 ÷ (2)2

databases made-easy

Well I think there is a typo in question ....

as per the given answer..:p

the question should be

There are 2^n attributes in a relation R,... Any combination (2^n)/2 (i.e 2^(n-1)) keys forms a candidate key then

2n
2n − 1
number of candidate keys---> ( )

remaining attributes --> 2n − 2n −1 = 2n −1

any of the subset could be taken for a superkey


n− 1
therefore number of subsets 22

2n
2 (n − 1 ) n− 1
therefore total number of superkeys ( ) ∗ 22
 2 votes -- Abhishekcs10 ( 1001 points)

7.263 DBMS top gateoverflow.in/36698

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 890 of 2244

databases


Selected Answer

E No Ename DeptNo
E001 A 10
E002 B 10
E003 B 5
E004 C 10
E005 D 20
E001 A 20
E003 B 10

So , if I do the first query

it will give

ENo
E001
E002
E004
E003

Union

ENo
E005
E002

so, Union will remove duplicate entries.(i,e E002)

ENo
E005
E002
E001
E004
E003

But if we do the second query , we will get the duplicate tuples.

So, option (b) is true , Q1 is subset of Q2

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 891 of 2244

 1 votes -- Shounak Kundu ( 3757 points)

7.264 DBMS top gateoverflow.in/36699

databases

This is a correlation query .

It works as a nested for loop.

The above query can be visualised as---

For every entry in R1

check if (∃ tuple in R such that R1.A=R.B)

{ do not select the tuple

else

{print the tuple in output

In above statements R1.A is outer loop variable and R.B is inner loop variable.

Now while executing--->

For R1.A=1 ∃ R.B such that R1.A = R.B => not selected

For R1.A =2 ∃ R.B such that R1.A= R.B => not selected

For R1.A = 3 ∄ R.B such that R1.A = R.B => selected

For R1.A = 4 ∄ R.B such that R1.A = R.B => selected

..thus 2 tuples would be in output

 1 votes -- Abhishekcs10 ( 1001 points)

7.264 Explain system recovery procedure with check point record. top gateoverflow.in/4047

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 892 of 2244

http://codex.cs.yale.edu/avi/db-book/db6/practice-exer-dir/16s.pdf

 1 votes -- Arjun Suresh ( 124125 points)

7.264 schedule serializable top gateoverflow.in/38594

7.265 is canonical cover and minimal cover is same thing? top gateoverflow.in/6346

Is canonical cover and minimal cover is same thing?

The only difference is that in canonical cover,the LHS should be unique.

eg.Minimal cover is A->B ,A-C

but Cannonical cover has to be A->BC.

 0 votes -- Sourav Roy ( 2353 points)

7.266 How to merge weak entities with other entities in order to get
minimum number of tables? top gateoverflow.in/6618

How to merge weak entities with other entities.I'm asking it in reference to this question-->>

http://gateoverflow.in/390/gate2008_82-83?show=390#q390

Actually i'm interseted in knowing the behaviour of weak entity with other entities in order to merge them to get the
minimized number of tables. Is it equivalent to merging of two normal entites..?If not, then what is the difference.How to
proceed in case of weak entites.?

Plz answer..

7.267 Conflict serializable and 2pl schedule top gateoverflow.in/42378

Can someone write one example of a schedule which is conflict serializable but is not allowed by 2pl protocol. I have read
that 2pl-> css, but css-> 2pl is not necessary?

T1 T2 T3
W(A)
W(A)
W(A)
W(B)
W(B)
W(B)

 0 votes -- Manojk ( 3365 points)

7.268 DBMS question practice. top gateoverflow.in/42871

Where should i practice questions of DBMS other than GATE previous year papers?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 893 of 2244


Selected Answer

If you have read the concepts properly from standard resources then no need of anything other than previous year
questions. (Otherwise any number of practice won't be enough).

 2 votes -- Arjun Suresh ( 124125 points)

7.269 Lossless and dependency preserving decomposition top gateoverflow.in/6180

Consider relation R(A,B,C,D) and F={A->B, B->C, C->D, D->A}

The decomposition of R into R1(AB), R2(BC) and R3(CD) is

a) Lossless and dependency preserving

b) Lossy but dependency preserving

c) Lossy but dependencies are not preserved.

d) Lossless but dependencies are not preserved.

I am getting Lossless by applying algorithm but is this decomposition dependency preserving...?Plz explain


Selected Answer

R1,R2 has common attribute B. B is key in R2.

so R1(AB) R2(BC) composed into R12(ABC)

Between R12(ABC) and R3(CD) common attribute is C and C is key in R3. Hence the decomposition is lossless.

Checking dependency preservation.

R1(AB) R2(BC) R3(CD)

A->B B->C C->D

We can straightaway see that these dependencies are preserved in the decomposed relations.

But we have a doubt with D->A,as it cannot be directly said to be preserved.

For these lets check the additional FD s that can be implied from the above three FDS.

R1(AB) R2(BC) R3(CD)

B+={BCDA} C+={CBDA} D+={DCBA}

B->A C->B D->C

Union of all the FDS

we get

G={A->B C->B C->D

B->A B->C D->C}

lets check if D->A is covered by G

D+={DA}

D+ in G ={DCBA}

hence D->A is also preserved.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 894 of 2244

Hence loss-less as well as dependency preserving.

 3 votes -- Sourav Roy ( 2353 points)

7.269 is tuple calculus is important for gate or not? top gateoverflow.in/42284


Selected Answer

Yes, it was in syllabus of 2016 and most probably 2017 too - should come in 2-3 months. Actually this is an easy portion
(nothing more to study) if you have covered Mathematical logic and set theory.

 1 votes -- Arjun Suresh ( 124125 points)

7.270 Maximum internal nodes in B+ tree. top gateoverflow.in/6625

A B+ tree of order 'd' is a tree in which each internal node has between 'd' and '2d' keys values. The root has between 1 and '2d' values. What is the maximum
number of internal nodes in a B+ tree of order 4 with 52 leaves.
A. 8 B.13
C.17 D.19

C 17..

 0 votes -- akash ( 735 points)

7.271 Find the number of minimal candidate keys of R? top gateoverflow.in/7518

databases

C and D only out of AB,AF,AE,C,D

 0 votes -- P2 ( 17 points)

7.272 Index top gateoverflow.in/7440

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 895 of 2244

S1 is true and S3 is False as secondary index is dense...Please explain whether S2 is true or false

Dense Index are faster in general as they point to contiguous memory location. Each Dense Index points to a certain
Record therefore there only single access is required.

In Sparse Index the Index points to the Record having the highest Key. All other records are traversed by pointer from the
record having highest value. In short First the Record with highest Value is selected (1 Disk Access). This record has
further records attached to it by linked List.This List is iterated to get the desired block.(Multiple Disk Access)

 1 votes -- Pratyush Varshney ( 27 points)

7.273 Thomas Write Rule top gateoverflow.in/7273


Selected Answer

Ans: A

http://en.wikipedia.org/wiki/Thomas_write_rule

 1 votes -- Keith Kr ( 5467 points)

7.274 Transactions top gateoverflow.in/7185

To check whether a given schedule is serializable or not , do we need to check only for conflict serializability or both conflict
serializability and view serializability ..?

If you are able to proof that it is conflict serializable, through precedence graph or any other algo

It will be conflict serializable and view serializable also.

No need to check further.

But suppose it fails conflict serializability test

Then you have to test for view serializability (initial read, updated read and final write)

Because conflict serializable schedules are subset of view serializable schedule(concurrent schedules view equal to some
serial schedule i. e serializable schedules) .

We test generally first for conflict serializabilty coz its easier to test (p problem

Topological sort complexity O(n^2)

Whereas View serializability is a np complete problem and hence difficult to test.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 896 of 2244

 1 votes -- Anurag Semwal ( 4775 points)

7.275 Use of DDL top gateoverflow.in/42995

I am currently studying database . In the Raghu Rmakhrishnan it has been written that "the DDL languages is used in both
external level and Conceptual level ". Please elaborate on this :)

databases

7.276 Database top gateoverflow.in/43005

Consider the given below 2 statements

s1 : Every ternary relationship can be expresses as combination of 2 or more binary relationship .

s2: Evert ternary relationship can be expressed with the help of aggreation concept .

1) both are true

2) both are false

3) s1 is true s2 is false

4) s1 is false s2 is true

databases


Selected Answer

Ans 2)

1) Ternary relationship may or maynot be expressed with 2 binary relationship.

In the below link it is given "ternary relationships may sometimes be replaced by two binary relationships (see book
Figures 3.5 and 3.13). Semantic equivalence between ternary relationships and two binary ones are not necessarily true."

http://jcsites.juniata.edu/faculty/rhodes/dbms/ermodel

2) ternary relationship cannot always expressed with aggregation concept. If there are redundant relation then , to
overcome it we use aggregation. So it is false

http://www.cs.sfu.ca/CourseCentral/354/zaiane/material/notes/Chapter2/node15.html

 0 votes -- srestha ( 11585 points)

7.276 If R is in BCNF and it has atleast one simple Candidate Key then R is
always in 4NF. Any explanation for this Arjun ? top gateoverflow.in/5336


Selected Answer

If R is in BCNF and no redundancy due to Multi valued attributes then it will be in 4NF.
In question they said R is already in BCNF and atleast one simple key.. one Simple key implies NO MULTI VALUED
dependency.. so relation will be in 4NF.

 3 votes -- Digvijay Pandey ( 26245 points)

7.277 consider the following schedule: top gateoverflow.in/5461

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 897 of 2244

S: R1(x), W 2(x), R 2(x), R 3(x), W 3(x)

If the above schedule S is conflict equal to S' then find S' ?

a) R1(x), R 3(x), W2(x), R 2(x), W3(x)

b) R1(x), R 2(x), R 3(x), W 2(x), W3(x)

c) R1(x), R 2(x), W2(x), W3(x), R 3(x)

d) none

databases

The answer is described here.

 0 votes -- Sourav Roy ( 2353 points)

7.277 If a file consists of 5 attributes, than what is the number of secondary


indices that can be constructed on the file?? plz answer n explain the anwer
also.. :) top gateoverflow.in/5248

A secondary index provides a secondary means of accessing a data file for which
some primary access already exists. The data file records could be ordered,
unordered, or hashed. The secondary index may be created on a field that is a candidate key and has a unique value in every record, or on a nonkey field with
duplicate values.
From -> Navathe DBMS !

So we need to have primary index too. Assuming we used 1 column for that, we have 4 columns remaining, using which
we can have max 4 secondary indexes !

 0 votes -- Akash ( 26315 points)

7.278 please answer... top gateoverflow.in/4812

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 898 of 2244


Selected Answer

Let

X
P Q R S T
1 2 3 4 5
2 3 4 5 6

Y
P Q U V
1 2 3 4
2 4 5 6

3 4 5 6

X ⋈ Y
P Q R S T U V
1 2 3 4 5 3 4

So,

(i) will give {1}

(ii) will give {1, 2}

(iii) P{{<1, 2>, <2, 3> } - { {<1, 2>, <2, 3> } - {<1, 2>, <2, 4>, <3, 4> }}}

= P{1,2} = {1}

(iv) {1, 2} - {1, 2, 3} = {}

So, (i) and (iii) are the only possibility to be same. They are actually same because both are selecting tuples from the
relation with same values for (P, Q) and then projecting the value for P.

(Note: Projection avoids duplicates unlike select in SQL)

 2 votes -- Arjun Suresh ( 124125 points)

7.279 the answer says.. natural join bu i think it should be join with
equality.please clear the doubt. top gateoverflow.in/4811

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 899 of 2244


Selected Answer

Natural join is a special type of equi join, where the


attributes for equality are not specified in the query. Here,
the attribute for join is specified in the query. So, (C) should be the answer.

http://en.wikipedia.org/wiki/Join_%28SQL%29#Equi-join

 2 votes -- Arjun Suresh ( 124125 points)

7.280 Explain top gateoverflow.in/5468

databases


Selected Answer

Ans is B:

here, inner query will retrive all students who have enrolled for the course with less than 5 credits. after join operation we
are retriving SID of all those students.

now, difference operator will return all SID which are in student relation but not in the result that we can from inner
query. therefore it will return all the SID of students who have enrolled for courses with credit greater than 5.

A is not correct because;

while performing set difference operator if any student has enrolled for any subject with less than 5 credit will be
removed.

 3 votes -- jayendra ( 5797 points)

Student
Sid Sname Sage
1 a 14
2 b 23
3 c 44
4 d 22
5 e 24
Course
cid coursename credit
1 x 4
2 y 7

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 900 of 2244

3 z 5
4 q 2
5 m 8
Enrolled
sid cid
1 1
2 4
2 1
3 2
4 5
5 5

Now the inner sub query does on a natural join on the relations course and enrolled followed by selection of tuples where
credit <5

So the result of natural join is

N.B only attributes which are necessary for the question are taken rest are ignored.

cid sid credit


1 1 4
1 2 4
2 3 7
4 2 2
5 4 8
5 5 8

after the selection where credit <5 ,tuples selected are

cid sid credit


1 1 4
1 2 4
4 2 2

projection of SID on above gives {1 ,2}

projection of SID on student -{1,2}

={3,4,5}.

Now a look into enrolled relation would depict that sid 3,4,5 are mapped to cid s 2,5,5.

and cid 2,5 in course shows that they have credit 7,8 which is >5.

hence ans b is true.

 1 votes -- Sourav Roy ( 2353 points)

7.281 Explain top gateoverflow.in/5469

databases

http://en.wikipedia.org/wiki/Blind_write

 4 votes -- Manali ( 2229 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 901 of 2244

7.282 Tuple Calculus Difference between 'for all' and 'such that' top gateoverflow.in/43310

Book(year_of_publication, Title, Acc_no(primary key))

then what does the following expression mean? (does it even mean anything)

s={ t | ∀ u∈Book(t[year_of_publication] = u[year_of_publication] ∧ t[title] = u[title] )}

7.283 Number of candidate keys top gateoverflow.in/6170

Let R(ABCDE) be a relational schema and F={AB->CD, ABC->E,C->A}. The number of candidate keys are

a) 1

b) 2

c) 3

d) 4

Is there some standard way to solve such problem.. or we have to consider each Functional Dependency...?Please explain...

by lookin at the RHS side u willcome to know B is nowhere so B has to be a part of CK so u vil get two CK AB and BC

 1 votes -- Shreyans Dhankhar ( 2265 points)

7.284 Tell whether the following set of decomposition of functional


dependency is Lossy or not and dependency preserved or not? See the
screenshot top gateoverflow.in/5917

databases

I think you have marked correct it is dependency preserving and lossless.

 2 votes -- Arpit Dhuriya ( 1791 points)

7.285 No. of tables? top gateoverflow.in/5470

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 902 of 2244

databases

According to me , It's 5 table

CUSTOMER ( Ssn )

ACCOUNT (Number , SSn)

PHONES (Number )

STATEMENT ( Date ,id ,Number )

HAS( Ssn ,Number )

 1 votes -- Manali ( 2229 points)

7.286 File Organization top gateoverflow.in/7992

Implementation of an inverted list to maintain the record list for each value for a given attribute can be done by-

1) Sequential File

2) Direct File

3) Indexed File

4) Indexed Sequential File

Please explain..

2, 3 and 4 are possible for implementing inverted list. Basically we need an indexed access to the file (as in hashing) but
this might not be there in a simple sequential file.

http://orion.lcg.ufrj.br/Dr.Dobbs/books/book5/chap03.htm

 0 votes -- Arjun Suresh ( 124125 points)

7.287 DDL and DML in Database top gateoverflow.in/8023

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 903 of 2244

Is there any SQL command which belongs to both DDL and DML?

AFAIK nothing is there.

 1 votes -- Arjun Suresh ( 124125 points)

7.288 Relational Algebra top gateoverflow.in/10997

in a) projection has subscript hid and first select has hCity="Vancouver" and second select has year =2005 as subscript

in b) projection has subscript hid and select has hCity="Vancouver" ^ year is not equal to 2005 as subscript

In second question first projection operator has subscript s_name, title and second projection operaor has title as its
subscript

Schema for second-

book(acc_no,yr_pub,title)

user(card_no,b_name,b_address)

supplier(s_name, s_adder)

borrow(acc_no, card_no,doi)

supp(acc_no, s_name, price,dos)

in second question sigma card_no=753(borrow(natural join)book) gives table containing


attributes(yr_pub,title,cc_no,card_no,doi) after applying pie title it gives table containing only title atttribute under card no
=753 (second algebra)

now pie s_name,title(supply(natural join)book) gives table with attribute(s_name,title) containing all the supplier name and
title (first algebra)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 904 of 2244

now we divide first by second then it will give only those supplier name where title name of second matches with title
name first thus it will provide name of all the suppliers who supplied all the copies of book under card-no =753

 0 votes -- saket nandan ( 1853 points)

7.288 What Happens when Cartesian Product is applied to Relations with


same attribute name? top gateoverflow.in/11022

if we apply cartesian product on same relation then we cannot identify the attributes so first we apply rename operation
then we will apply carteian product on same relation

 0 votes -- saket nandan ( 1853 points)

7.289 no. of splits top gateoverflow.in/39208

Q).Consider the following B + tree

Which of the following is true, after inserting 80. (If rotation allowed)

(A).No node splitted

(B).Only Root node splitted

(C). Only leaf node splitted

(D).Both Root & leaf node splitted

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 905 of 2244

The answer must be A.As no node splitting is done.As rotation is allowed,80 will be placed on 85 position and 85 will be
placed before 90 and 95.

 0 votes -- Harsh1992 ( 71 points)

7.290 Find no of Tuples top gateoverflow.in/39237

consider the selection of the form s a<=200(r) where r is a relation with 1000 tuples . Asume attribute values of A among the
tuples are uniformly distributed in interval [1,500]. The number of tuples return by given query are ___ .

BY UNIFORM PROBABILITY DISTRIBUTION

THE AREA OF INTEREST WILL BE 1 TO 200

(200-1)/(500-1) x1000=400 APPROX

 2 votes -- Deepesh Kataria ( 1207 points)

7.291 Relational Algebra top gateoverflow.in/10993

Please answer the following questions

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 906 of 2244

for question no 31 ats answer will be cartesian product is superset of natural join if nd if only if we havnot applied natural
join same relation

but in question 32 here we r applying natural join on same relation teacher then we hav applied rename option then
attributes are different so caretesian product nd naturaljoin will be same for both so answer will be (c) option

 0 votes -- saket nandan ( 1853 points)

7.292 ugc net paper 2 computer science code 87 top gateoverflow.in/11842

http://ugcnetonline.in/question_papers_december2012.php

Q50 y not ans b y shd c???

It should be p1.skill = p2.skill AND p1.posting no <> p2.posting no..

 0 votes -- Digvijay Pandey ( 26245 points)

7.293 INDEXING DATABASE top gateoverflow.in/11887

Clustering index is always sparse?? comment with explanation...??

clustering index is the index which has a record for every search key value and the index appears in the order of records in
the database..

sparse index is the index whose index is a subset of the search key value.and the index appears in the order of records in
the database..

now there is case where in sparse index the subset of index=all search key values so you can say clustering index is
sparse index but the reverse cant be said...

 0 votes -- Bhagirathi Nayak ( 10239 points)

7.294 File Processing top gateoverflow.in/44229

Can anyone give me an example of fixed length records and variable length records with respect to any Relational table .?

I dont want definition of these terms .

databases


Selected Answer

In database system, a field can have a fixed or a variable length. A variable length field is one whose length
can be different in each record, depending on what data is stored in the field.

Variable length fields are useful because they save space. Suppose, for example, that you want to define a
NAME field. The length of each NAME field will vary according to the data placed in it.

For example, Dexter is 6 character long, but Dexter Ji is 9 characters long

A Fixed length record is one in which every field has a fixed length.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 907 of 2244

With Fixed-length fields, you would need to define each field to be long enough to hold the longest name.
This would be a waste of space for records that had short names

 0 votes -- Manojk ( 3365 points)

7.295 B-Trees and B+ Trees top gateoverflow.in/12076

for 5 question:

i think;

(A) true

(B) false

(C) true

as fann out of B+tree is greater than B tree so that why it contain less no of levels and due to less no of level it covers
less space and therefore search time is less as comapred to B TREE..

 0 votes -- kunal chalotra ( 3567 points)

7.296 DBMS, Blind Writes top gateoverflow.in/35703

My doubt is, T3 and T4 have blind writes, can these be conflict serializable?

databases

7.297 INDEXING top gateoverflow.in/11891

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 908 of 2244


Selected Answer

A record size is (30+9+9+40+9+8+1+4+4)=114 and 1 B for deletion marker 1 so 115 B record size . No. of record
30000.

block size =512 B , blocking factor floor (512/115) =4 so no. of block required celin (30000/4 ) = 7500 .

SSN= key = 6 B

KEY+block pointer = 9+ 6 = 15 B

No.of index per record = (512/15) = 34.13 = 34

1st level :

7500/34=220.58=221 block required for 1st level

2nd level:

221/34=6.5=7 block required for 2nd level

3rd level

1 block required (its straightforward )

and avg block access is 4 (1+1+1+1).

 2 votes -- Pranay Datta ( 6113 points)

7.298 The process of assigning similar objects/entities to object/entity type


known as top gateoverflow.in/10992

The process of assigning similar objects/entities to object/entity type known as

a)Classification

b)Instantiation

c)Specialization

d)Generalization

classification is answer .

 2 votes -- sonam vyas ( 6441 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 909 of 2244

7.299 Data model top gateoverflow.in/10982

In a database , the specification of data where individual data item of same type can have different sets of attribute

a) True

b) false

databases

i think the statement is true .

in a database its possible to have 2 attributes of same domain (same type eg. int ) .

student - (roll - int , name -char , phone - int ..... )

 0 votes -- Pranay Datta ( 6113 points)

7.300 Conflict Equivalent top gateoverflow.in/10299

Consider the following ordering S of transaction

T1:R(X),W(Y), T2:R(X),W(Y);T3:R(X),W(Y). how many schedules if any are conflict equivalent to S?

1) 3

2) 5

c) 15

d) 30

databases

total schedule = 6!/2!*2!*2! = 90


and every schedule is conflict equal schedule because no cycle in any precedence graph ..
by symmetry each serial schedule must have equal no of conflict schedule..
der are 90 schedule and 3! serial schedule..
T1 ----> T2 ----> T3 is one out of 6 serial schedule.
so no ofconflict equal schedule which is equal to T1 ----> T2 ----> T3
= 90/6 = 15

 4 votes -- Digvijay Pandey ( 26245 points)

C) 15

here we are asked that how many schedules are conflict equivalent to only S: T1 →T2 →T3

total number of concurrent schedules = (2+2+2)! / (2! * 2! * 2!) = 90 ( ref )

but here in these set of transactions it can be seen clearly that on executing them concurrently in any order they are
always going to result in a Serializable Schedule. Hence there are 90 serializable schedules.

but we also know that only in 3! ways we can arrange T1 , T2 and T3 . There are 6(=3!) possible combinations of serial
schedules. But we are getting 90 serializable schedules. It means that some schedules are conflict equivalent to each
other and simultaneously to a serial schedule out of those 6 serial schedules.

Then 90 is divided into packets of schedules each group(packet) being Conflict Equivalent to one among those 6 serial
schedules.

Therefore, 90/6 = 15 schedules exists in a packet. One such packet of schedules is Conflict Equivalent to serial
schedule S: T1 →T2 →T3

 3 votes -- Amar Vashishth ( 17865 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 910 of 2244

7.301 Associativity of Set difference oprator top gateoverflow.in/41844

Is set difference operator (-) used in relational algebra associative?


Selected Answer

No it is not associtive.

suppose we have three relations A,B and C

take A as

s.no name
1 abc
2 xyz

take B as

s.no name
1 abc
3 mno

take C as

s.no name
1 abc
4 stu

The result of set difference is tuples which are present in one relation but not in another.

the result of

(A-B)-C =

s.no name

2 xyz

and the result of

A-(B-C) =

s.no name
1 abc
2 xyz

Both are different. Therefore, it is not associative.

 1 votes -- Nishu ( 433 points)

I Guess "No" It is not Associative

 2 votes -- saif ahmed ( 931 points)

7.302 Transaction processing top gateoverflow.in/44137

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 911 of 2244

W1(X)R2(Y)R1(Y)R2(X) ?

Is it view Serializable or Conflict or both ?

databases

Here as no cycle is form in dependency graph,so it is conflict serializable...

 0 votes -- Uddipto ( 535 points)

7.303 ACID PROPERTIES top gateoverflow.in/10294

ATOMICITY IS MANAGED BY

a) Programmer

b) Recovery Management Component

c) Concurrency Control Component

d) None of it

databases

It is the
responsibility of the transaction recovery subsystem of a DBMS to ensure atomicity
As per Database Systems Navathe !

 0 votes -- Akash ( 26315 points)

7.304 Transaction top gateoverflow.in/44088

HI ,

I am currently studying DBMS . I am having a doubt , We know that When schedules are conflict serializable it will always
give consistent result and more important concurrency too .

For the Conflict serializable we have an algorithm which says if precedence graph contain no cycle then it is serializable else
not .

I recently came across debit credit transaction :

T1:R1(X); X= X-10,W1(X);R1(Y);Y=Y+10;W1(Y);

T2:R2(Y);Y=Y-20;W2(Y);R2(X);X=X+20;W2(X);

And a non serial schedule is given

S:R1(X);W1(X);R2(Y);W2(Y)R1(Y)W1(Y)R2(X);W2(X)

if you run this schedule by considering any initial value of X and Y , you will get consistent results . But if you draw a
precedence graph for this you will get a cycle , which meant it not serializable ..

So caan i say a cycle in such kind of transaction wont give correct results . we need to consider the semantics of all
operation which we usually ignore ?

databases

7.305 If S is a superkey such that S top gateoverflow.in/10395

If S is a superkey such that S ∩ UID is NULL then S ∪ UID is also a superkey

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 912 of 2244

From statement "If S is a superkey such that {S ∩ UID} is NULL then {S ∪ UID} is also a superkey". If i delete "{S ∩ UID}
is NULL" then also statement is true. Anyway Superkey ∪ anything = Superkey only. What is d use of "{S ∩ UID} is NULL"
??

 1 votes -- Digvijay Pandey ( 26245 points)

7.306 DBMS general top gateoverflow.in/10403

Decompose a relation into 3NF , BCNF, 2NF , How to get it?

Into 2nf: try to remove the partial dependencies by decomposing the table.
Into 3nf: now remove the transitive dependency by decomposition

Into bcnf: now remove the overlapping candidate key by decomposition from the 3nf table if any

If you say how to decompose then it's a long process in that case follow a standard book you will get the algorithms

 0 votes -- Bhagirathi Nayak ( 10239 points)

7.307 serializability top gateoverflow.in/39351

any one reply pls fast

T3-->T1-->T2

I guess answer C should have matched. Can be done by precedence graph.

 0 votes -- Tehreem Ansari ( 1327 points)

7.308 b+ tree order top gateoverflow.in/10708

Assume block size 4096 bytes,size of key is 4 bytes,size of pointer is 8 bytes.How many keys are possible per blocks for b+
tree organisation?

(a) 155

(b) 154

(c) 341

(d) 340

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 913 of 2244

# of key =lower bound of ( block size/ (key + pointer))=lower bount of ( 4096/(4+8)= lower bound of (341.33)= 341

 1 votes -- Anirudh Pratap Singh ( 4091 points)

7.309 Functional Dependency top gateoverflow.in/40502

Lets say their is R(A,B,C) and FD : AB, ABC and A is key. Is it in 3NF? Explain


Selected Answer

For a relation to be in 3NF , we must have X-->Y , so either X should be a key or Y should be a prime attribute , Now with
the given FD , u can re-write them as A-->B and A-->C as (A) +=(ABC) , so you can remove B from the functional
dependency AB-->C , so that it becomes A-->C , therefore now you are left with A-->BC only and since A is a key so
clearly the FD is in 3NF .

Point : whenever You have PQ-->R and (P)+=(PQR) , then remove Q from the FD ,since P alone can determine
R so Q is redundant here , so your FD reduces to P-->R

 1 votes -- radha gogia ( 4369 points)

3NF defination->

for every non -trivial FD x->y either->1. X is a key

2. Y is a prime attribute

so here R(A,B,C) :A->B and AB->c.. A is a key (given) ..for AB->finding closure ->AB +=ABC ..it contains all the attributes
so it is also a key. both FD satify 1st condition so this is in 3NF

 1 votes -- Joker ( 685 points)

7.310 Extraneous Attribute top gateoverflow.in/40504

Let FD: AB-->C , A-->C .Is B extraneous ?if yes, then how can we determine B.


Selected Answer

B is useless here , it could even have been ABDFRGTYUILOP-->C , then BDFRGTYUILOP ,all these attributes are useless
since A alone can determine C , so u r left only with the functional dependency A-->C , as far as determining B is
concerned , it is a prime attribute , since AB is a candidate key here . so in the given relation schema R(ABC) , you have
only 1 functional dependency A-->C and AB is candidate key .

 2 votes -- radha gogia ( 4369 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 914 of 2244

AB-->C

A-->C

2ND FUNCTIONAL DEPENDENCY SHOWS THAT 'A' ALONE CAN DERIVE C. SO IN 1ST FD B IS EXTRANEOUS . BECAUSE
HERE A AND B TOGETHER DERIVING C. THIS IMPLIES THAT B IS NOT REQUIRED TO DERIVE C.A ALONE CAN DERIVE
IT.AND IF WE REMOVE B, A CLOSURE WILL REMAINS THE SAME.

 1 votes -- kajal392 ( 21 points)

7.311 To decompose the give relation into 3nf and BCNF top gateoverflow.in/4348

consider a relation R(a,b,c,d,e,f,g,h,,i,j)

following fd's hold-

AB->C

A->DE

B->F

F->GH

D->IJ

decompose the relation into 3nf and BCNF.


Selected Answer

First of all find the keys.

This is what I do for it, find all attributes not appearing on RHS of FDs. These attributes must be prime attributes- must
be in present in some candidate key. Now, find their minimal cover and add other attributes so that the minimal cover
covers the entire attributes.

Here, A and B are not on RHS, so must be in candidate key. AB determines {A,B,C,D,E,F,G,H,I,J} and hence becomes the
candidate key as well.

Now, A-> D, A->E B ->F are partial FDs. So, the relation is not in 2NF.

To make it in 2NF, we decompose in to 3 relations

A->DEIJ giving ADEIJ, B->F and F->GH giving BFGH and AB -> C giving ABC.

These 3 relations are in 2NF. and ABC is in BCNF. In ADEIJ, we have transitive dependencies

A-> D and D -> IJ

and in BFGH we have transitive dependency B -> F and F-> GH

So, to make the table into 3NF, we make a separate relation for DIJ and FGH. So, now we get 5 relations

ABC, ADE, DIJ, BF and FGH which is in 3NF. None of the prime-attribute comes on right hand side of any FD => so as
soon as the relation is in 3NF, it is in BCNF as well. Or you can see for each non-trivial FD α → β, whether α is a candidate
key. (non-trivial means β ⊄ α)

 1 votes -- Arjun Suresh ( 124125 points)

7.312 What do the SQL query return ? top gateoverflow.in/35624

Bank(bname, city)
Travel(pname, city)
SELECT T1.pname
FROM Travel T1
WHERE NOT EXISTS (SELECT B.city
From Bank B

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 915 of 2244

WHERE B.bname = ‘SBI’


EXCEPT
SELECT T2.city
FROM Travel T2
WHERE T1.pname = T2.pname)

Solution
I am getting as Who have travelled in any city where SBI is located
Answer given as Who have travelled in all city where SBI is located

Please tell the correct ans and reason


Selected Answer

The second part of EXCEPT wil give all the cities which a person has travelled to

Say B has travelled to {Pune ,Kolkata,MP,TN}

Now the first part of EXCEPT will give all the cities where SBI is located. say {Kolkata,TN,UP}

Now if you do EXCEPT between these two states. you will get a tuple or UP . So B has not travelled to all the states
conntaining SBI.Now the NOT EXISTS part will be FALSE (as something is being returned,in this case UP). As a result we
will not take B from the original query.
So only if a person have travelled to all the cities where SBI is present then only the EXCEPT will give NULL and the NOT
EXISTS part is TRUE, and we will return that person from the query.
Hope its clear . Its better you take tables and find out.

 1 votes -- chat28 ( 495 points)

7.313 What command is used top gateoverflow.in/18587

What command is used to change contents of one database using the


contents of another database by linking them on a common key field?
a)Replace

b)join

c)change

d)update

I guess the answer is b)join .

But join does not change the contents of the database

 0 votes -- David ( 107 points)

7.314 A locked database file can be top gateoverflow.in/19157

a) accessed by only one user


b)modified by users with the correct password
c)used to hide sensitive information
d)updated by more than one user

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 916 of 2244

Option A) accessed by only one user.

 0 votes -- Umang Raman ( 10379 points)

7.315 related to BCNF Decomposition top gateoverflow.in/18513

quest: consider the Rn R(C,S,Z) with FDs CS->Z and Z->C


then their BCNF decomposition will be lossless join or Dependency preserving or both of them?

CS and ZS are candidate keys

Fd Z->C violates Bcnf

So bcnf decomposition is

R1(S,Z) and R2(Z,C) is lossless as Z is common attr in both reln but not dependency preserving as CS->Z not preserved

 0 votes -- Pooja ( 22773 points)

7.316 Related to closure and FDS top gateoverflow.in/18512

ques: F is a set of functional dependencies on realtion R(ABCDE) with F={A->ABCD,B->C,B->D} which of the following is in the closure of F?
a.) CD->B b.) C->D c).B->CD d.) BCD->A

databases

B->C

B->D

So using union rule we get

B->CD

so ans is c

 0 votes -- Pooja ( 22773 points)

7.317 superkeys possible top gateoverflow.in/31670

15,

for AB ->AB, ABC ABD ABE ABCD ABCE ABDE ABCDE

FOR BC ->BC BCD BCE BCDE

FOR CD ->CD CDE ACDE

 0 votes -- Ganesh Patel ( 41 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 917 of 2244

7.318 serializability top gateoverflow.in/19260

the precedence of graph of this schedule contain cycle.. so this schedule is not conflict serializable...
so (d) option..

 0 votes -- kunal chalotra ( 3567 points)

7.319 Question on dense index top gateoverflow.in/30109

________ index is dense

A) Primary index
B) clustered index
C) secondary index on candidate key
D) all

databases


Selected Answer

AND : C

primary and clustered indexes are sparse.

secondary index is dense

 4 votes -- pramod ( 2071 points)

7.320 query top gateoverflow.in/20585

consider following queries over R(AB) ans S(BC)

Q1:select distinct A,C from R,S where R.B=S.B

Q2:{A,C|∃B(A,B)|∊R ∧(B,C)∊S)}

Q3:∏A,C(R⨝S)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 918 of 2244

which of following queries are equivalent??

1 and 3 are equivalent.

2 is not equivalent because join condition is not given.

 0 votes -- Aditya Gaurav ( 1831 points)

7.321 candidate key top gateoverflow.in/20589

Given relation R(A,B,C,,DE,F) with FDs

C->A

DE->F

B->D

ADD C->B to following FD.. How many different FD are there which make C as candidate key...(For simplicity assume FD
have only one attribute on LHS and RHS)

can add A->E,

to make c as c.k,so no. of f.d reqd=5

 0 votes -- sourav anand ( 1585 points)

7.322 3nf decomposition top gateoverflow.in/20491

Consider R(ABCDEF) with following fd

AB->CDEF

C->A

D->B

C->D

E->F

B->E

Decompose it into 3NF

R1(ABCD) AB->CD, C->A, C->D and D->B will imply in this decomposition

R2(BE) B->E will imply in this decomposition

R3(EF) E->F will imply in this decomposition.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 919 of 2244

 0 votes -- Aditya Gaurav ( 1831 points)

7.323 normal forms top gateoverflow.in/20605

Q)Which of the following is false??

1)Relation R in BCNF with atleast one simple candidate key is also in 4NF

2)Relation R in BCNF with all candidate key simple is also in 4NF

3)Relation R in 3NF with only one compound candidate key is also in BCNF

4)Relation R in 3NF with atleast one simple candidate key is also in 4NF

Explain with example....

1)Relation R in BCNF with atleast one simple candidate key is also in 4NF
if multivalue attribute exist in the table then every candidate key will be compound key
so here there is one simple candidate key no multivalue attribute present so surely its in 4NF also.
2)Relation R in BCNF with all candidate key simple is also in 4NF
same reason as above.
3)Relation R in 3NF with only one compound candidate key is also in BCNF

if relation R is in 3NF and atmost one compound CK then it is also in BCNF


if more than one compound Ckey will present then prime to prime will be possible which will violate the BCNF property
but with one compound CK there will be no such possiblity

e.g. R(ABCDE) {AB->C C->D D->E E>A}


CK{AB EB DB CB} Here C->D D->E E>A violates the BCNF
4)Relation R in 3NF with atleast one simple candidate key is also in 4NF

There is no MVD in the relation


But there can be possiblity of two compound candidate key then it will not be in BCNF

R(ABCDE) {AB->C C->BD D->E E>A}


CK{AB C EB DB } Here D->E E>A violates the BCNF so 4NF will also not satisfied.

option 4 is false.

 1 votes -- Umang Raman ( 10379 points)

7.324 ISRO_A 2015/18 top gateoverflow.in/19400

Given a block can hold either 3 records or 10 key pointers.A database contains n records , then how many blocks do we need
to hold the data file and the dense index

a)13n/30

b)n/3

c)n/10

d)n/30


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 920 of 2244

total number of block required by data file = n/3

total number of records needed by pointer = n/10. ( key pointer = no of keys)

total blocks = n/3+n/10 =13n / 30

 0 votes -- Ravi Singh ( 7303 points)

7.325 sql top gateoverflow.in/31673

is the answer option B

 2 votes -- Rabia Singh ( 43 points)

7.326 cardinality top gateoverflow.in/31777

7.327 which normal form is based on the concept of 'full functional


dependency' is top gateoverflow.in/18117

which normal form is based on the concept of 'full functional dependency' is

a)First Normal Form

b)Second Normal Form

c)Third Normal Form

d)Fourth Normal Form

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 921 of 2244


Selected Answer

Functional dependency X --> Y is a full functional dependency if removal of any attribute A from X means that the
dependency does not hold any more i.e. for any attribute A ϵ X, (X - {A}) does not functionally determine Y.

It is related to 2nd NORMAL FORM.

 0 votes -- Digvijay Pandey ( 26245 points)

7.328 Serializable top gateoverflow.in/32154

http://gateoverflow.in/?qa=blob&qa_blobid=10158621331044967374

7.329 which of the following are the candidate keys? top gateoverflow.in/17425

Let x,y,z,a,b,c be the attributes of an entity set E.if {x} ,{x,y}, {a,b} ,{a,b,c}, {x,y,z} are superkeys then which of the
following are the candidate keys?

a){x,y} and {a,b}

b){x} and {a,b}

c){x,y,z} and {a,b,c}

d){z} and {c}


Selected Answer

Minimal superkey is candidate key

{x} and {ab } are candidate keys....

 0 votes -- Pooja ( 22773 points)

7.330 FIND THE NO OF KEYS top gateoverflow.in/32281

Consider relation r(P, Q, R, S) with functional dependencies

PQ → R

PQ → S

R→P

S→Q

Find the number of keys in the relation R.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 922 of 2244


Selected Answer

4 keys , PQ ,RS, PS ,RQ.

 3 votes -- Sayantan Ganguly ( 5061 points)

7.331 An aggregation association is drawn using which symbol? top gateoverflow.in/17417

An aggregation association is drawn using which symbol?

a)A line which loops back on to the same table

b)A small open diamond at the end of a line connecting two tables

c)A small closed diamond at the end of a line connecting two tables

d)A small closed triangle at the end of a line connecting two tables

Option B) A small open diamond at the end of a line connecting two tables.

In UML, aggregation is shown by an open diamond on the end of the association line that points to the parent
(aggregated) class.

 0 votes -- Sunit Acharya ( 17 points)

7.332 B+ tree database top gateoverflow.in/18230

The minimum number of keys in a B + tree is 3. The maximum number of keys in any non-root node is


Selected Answer

Min No of child pointer (x) = 4

Max no ofchild pointer = 2x = 8

Max no of key = 8 - 1 = 7

 1 votes -- Digvijay Pandey ( 26245 points)

7.333 Foriegn key top gateoverflow.in/32139

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 923 of 2244

databases

Unique and Not NULL.

 1 votes -- Monanshi Jain ( 5827 points)

7.334 Does a relation which is many to one from P to Q signify that P


contains more number of entities than Q ? top gateoverflow.in/18284

According to me both ER1 and ER2 have a many to one relation from P To Q , so does it imply that P has more no of entities
than Q or we can simply say that through an ER diagram we can't tell anything about no of entities .

databases

7.335 which of the following statements are true regarding the below ER
diagram ? top gateoverflow.in/18282

The answer to Q14 is 4 because table Y indicated by total participation every entity is participated in relationship and also
given 1:M ratio implies Table x can participate in zero or many entities.so it depends on the input we give.

Correct me If I m wrong

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 924 of 2244

 0 votes -- Prabhanjan R ( 747 points)

7.336 grouping when attribute have some null entry.. top gateoverflow.in/18280

select state, companyname, count(*) from abovetable group by state, companyname../

Null will cause one group reords 1 10 11 12 will form one group

 0 votes -- Pooja ( 22773 points)

7.337 group by SQL top gateoverflow.in/18278

Output return by the following query???


SELECT
(SELECT state
FROM Employees e
where e.EmployeeID = e2.EmployeeID),
count ()
FROM Employees e2 Group By (SELECT State From Employees e
WHERE EmployeeID=e2.EmployeeID)

7.338 explain the no of table in ER Model ,i get 4 table .. top gateoverflow.in/21295

7.339 How to approach this question on database? top gateoverflow.in/29978

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 925 of 2244

Given answer: B
I don't know what are closed set in databases. Please give some references for explaining it.

databases

7.340 db top gateoverflow.in/26221

databases

Let n be degree

8n+8(n-1)<=512

16n<=520

n<=32.5

n=32

 1 votes -- Pooja ( 22773 points)

For indexing used internal node structure.Because leaf node pointing to original data only.

P-1(key size)+ P(Block pointer)<=512

P-1(8) + P(8)<=512

8P -8 + 8P <= 512

16P <= 512+8

p <= 520/16

p <=32.5

P = 33 take ceeling

 1 votes -- Anirudh Pratap Singh ( 4091 points)

7.341 db top gateoverflow.in/27323

how many b tree are possible with 6 record if there are 3 key.???how to solve?

databases

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 926 of 2244

7.342 N-ary tree top gateoverflow.in/25896


Selected Answer

Sum of degrees = (I-1) * 5 + 4 + L (Each internal node except root has degree 5 and root has degree 1) = 5I + 37

So, no. of edges = (5I + 37)/2

No. of nodes = no. of edges + 1

So, L + I - 1 = (5I + 37)/2

3/2I = 37/2

I = 37/3 = 12.33.

So, for 38 leaf nodes we need more than 12 internal nodes, so it must be 13 internal nodes and last level not being fully
filled.

 0 votes -- Arjun Suresh ( 124125 points)

relationship in any n-ary tree

I(n-1) + 1 = L I : intenal node n:n-ary tree L:leaf node

I(4-1)+1=38
I =12.33 = 13 nodes

 1 votes -- Umang Raman ( 10379 points)

7.343 check the question top gateoverflow.in/28210

consider unspanned blocking with 20 byte blocks. A file contains records of sizes 2,5,3,7,4,20 bytes.

the percentage of space wasted if blocks are allocated for file is?

my answer is 47.5.but they are given 31.66.please explain it.


Selected Answer

1​​s​t 20 byte block 2,5,3,7 -> 3B wastage

2nd block 4, -> 16B wastage

3rd block 20 -> 0B wastage

total byte = 60B

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 927 of 2244

So %Space waste = (19/60)*100= 0.316631*100 = 31.66%

 1 votes -- Anirudh Pratap Singh ( 4091 points)

7.344 Number of rows top gateoverflow.in/28660

they do somthing which make it very simple.

1=2 which make inner query always false i.e. null

then anythng > any ( null)

always true...

so all row comes as ouput

 1 votes -- Anirudh Pratap Singh ( 4091 points)

7.345 db top gateoverflow.in/27312

How many view eloquent serial schedule are possible?

S:w1(a)r2(a)w3(a)r4(a)w5(a)r6(a)

databases

I think one T1->T2->T3->T4->T5->T6

 1 votes -- Anirudh Pratap Singh ( 4091 points)

7.346 db explain. top gateoverflow.in/26224

databases

database block factor= 100/10

here 100 no. of record and 10 is record size.

one block contain 10 record.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 928 of 2244

In Index file block fector= key +pointer= 90% of record size +10% of record size= 100% of record size= 10

so in index file one block contain 10 record=

Block factor= 100/10=10

 1 votes -- Anirudh Pratap Singh ( 4091 points)

7.347 DBMS query2 top gateoverflow.in/26780

Answer will be A,C

Here dbms_marks>seminar marks and seminar marks>75--------------this query fetches tuple C

dbms_marks>90 OR dbms_marks<50-----------------------this query fetches A,C

 0 votes -- srestha ( 11585 points)

7.348 DBMS query1 top gateoverflow.in/26779

No. of tuples result of following query will be 2

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 929 of 2244

NULL will not participate in any grouping

 1 votes -- srestha ( 11585 points)

7.349 Find the title of all the books which is not yet issued? top gateoverflow.in/26862

Book_schema(Acc.no,yr_pub,title)

B.by_schema(Acc.no,Doi,Card.no)

Where, Acc.no is accession number

yr_pub is the year of publication

B.by_schema is the borrowed by schema

and Doi is the date of issue.

Select title from Book_schema b,B.by_schema s where s.Acc.no=b.Acc.no and Doi>CURDATE()

Here CURDATE() function gives the current date.So this query will return you the titles of those books which issue date is
greater than current date means the books which are not issued yet.(This query syntax is according to SQL Server 2008)

 0 votes -- gate rk ( 71 points)

7.350 number of conflict serializable schedules top gateoverflow.in/26891

Two transaction T1, T2 are given as follows

T1 : R1(A) W(A) R1(B) W1(B)

T2 : R2(B) W2(B) R2(C) W2(C)

total number of conflict serializable schedules ?

ans given is 54

how to solve it

T1 : R1(A) W(A) R1(B) W1(B)


1 2 3 4

T2 : R2(B) W2(B) R2(C) W2(C)
5 6 7 8
Conflict condition RW WR WW
There are total 5 conflict operation
1. T(1) & T(2) operations should execute in given ordered sequence
1-2-3-4 and 5-6-7-8
2.NO operation should come between any two conflict schedule operation e.g. between 5 and 6 no other operation can
come otherwise it will violate the condition.

Let us count how many combination can be made from given condition-:

1) Execute all T(1) first then T(2)


i.e. 1-2-3-4-5-6-7-8 ----------------- 1 way
2)Since there is conflict between 3 and 6 so we can say that 6 should execute before 3 to avoid violation.
6<3

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 930 of 2244

To count this first let us count how many total concurrent process can be possible .

__5__6__7__8__
so we have 5 empty space out which we have to fill with 4 operation (1,2,3,4) with repetition.
At each empty space any number of operation can come.
It is similar problem to chocolate problem.

Total Number of concurrent process = (5+4-1)C4 = 70


(n=5(empty space) r=4(total operation) therefore (n+r-1Cr) )

But this also include in which our condition are violating. 6

1) 1 2 3 4 occur before 6
here n= 2 r =4
therefore (2+4-1)C4 = 5

2) 1 2 3 occur before 6
here n= 2 r= 3
therefore (2+3-1)C3 = 4 but here d can be at 3 place so total 4 *3 = 12 arrangement

so total 12 +5 = 17 arrangement are violating our condition out 0f 70 concurrent arrangement


So total arrangement = 70 -17 = 53

So total arrangement = serial arrangement + concurrent arrangement


= 53 + 1 = 54

 2 votes -- Umang Raman ( 10379 points)

7.351 DBMS top gateoverflow.in/27116

prime attribute appears in some candidate key???pls explain how??

databases

R(ABCDE)

AB-> CD

C->B

D->E

candidate key are AB and AC.

then A, B, C are prime attribute.. here B come in one candidate key not in both But also a prime attribute.

SO any attribute which are in any candidate key are prime attribute.

 3 votes -- Anirudh Pratap Singh ( 4091 points)

7.352 No of rows top gateoverflow.in/28694

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 931 of 2244

Here ans will be (c)1

inner query first executed i.e. select manager from emp ; and this fetches 2,3,4

Now, outer query will be executed and the rows of eno.=2 or 3 or 4 will not be prined

So, it only prints

eno ename manager

1 a 2

 1 votes -- srestha ( 11585 points)

7.353 check the question top gateoverflow.in/29032

databases

7.353 Can two entity sets in a relation have the same primary key? top gateoverflow.in/25201

yes, it can possible in recursive relationship.In recursive relationship the two keys(primary key and foreign
key) are the same but represent two entities of different roles to relate relationship.

Ex:-

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 932 of 2244

 2 votes -- Leen Sharma ( 2935 points)

7.354 Check the following TRC top gateoverflow.in/25295

Given,

Suppliers(sid,sname,rating)

Parts(pid,pname,color)

Catalog(sid,pid,cost)

1.Retrieve sid of the suppliers who supplied some red or some green part.

I did it this way- {t | ∃c∊Catalog ∃p∊ Parts(c.pid=p.pid ∧ p.color="Red" ∨ p.color="Green" ∧ t.sid=c.sid)}

1 more way to do-- {t | ∃c∊Catalog (∃p∊ Parts( p.color="Red" ∨ p.color="Green"∧ c.pid=p.pid) ∧ t.sid=c.sid)}

I want to verify whether these TRC queries are correct or not.Also correct me if i am wrong.

Suggest some other ways if possible.

Also,

2. Retrieve sid of suppliers who supplied at least two parts.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 933 of 2244

1.{t.sid
|∃t∊Supplier,
∃c∊Catalog
,∃p∊
Parts(
p.color="Red"

p.color="Green"
∧c.pid=p.pid
^t.sid=c.sid)}

2.{t.sid
|∃t∊Supplier,
∃c∊Catalog,∃p1,p2∊
Parts(
p1.pid
!=
p2.pid
∧c.pid=p.pid^
t.sid=c.sid)}

 2 votes -- srestha ( 11585 points)

7.355 Time stamp ordering top gateoverflow.in/25086

As the transaction order is T!--->T2--->T3--->T4

so there is a conflict W3A----->r2A

It is a write read conflict which is not allowed in BTS and TWR

r2A roll back in transaction T2

so ans will be C

 1 votes -- srestha ( 11585 points)

7.356 True/False top gateoverflow.in/25083


Selected Answer

S1: False count doesn't include null values.(if allowed NULL + Anything = NULL )
S2: False average add all non null values (if allowed NULL + Anything = NULL )
S3:False projection of relational algebra is not equal to SQL select since SQL allow duplicate but relational algebra doesnt
allow i.e why we use Select distinct in SQL.
So option A

 1 votes -- Umang Raman ( 10379 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 934 of 2244

7.357 how to find minimum and maximum size ?? top gateoverflow.in/25003

R1(p,q,r) and R2(r,s,t) with the primary key P and R respectively.the relation R1 contain 200 tuple and R2 contain 250 tuple then minimum and
maximum size find right outer join is........

It will have few conditions:

For : R1 right_outer R2

Case-1: If each rows of R1 get only one matched row of R2 then result will be :250( bcz of right outer join)

Case-2: If rows of R1 doesn't get any matched row in R2 then result will be :250( bcz of right outer join)

For : R2 right_outer R1

Case-1: 200

Case-2: 200

 1 votes -- Bishnu Agrawal ( 96 points)

Right outer join says that atleast all the tupples of right table should come. i think the minimum and max here will be 250
only. because first we will perform the natural join and take all right table tupples . R is the primary key of relation so
natural join on both the table will result in 200 tupples but we have to take all the remaining right into consideration so it
should be 250.

 1 votes -- Ravi Singh ( 7303 points)

7.358 er diagram top gateoverflow.in/29161

Q) Consider the following diagram:

If A has 100 entities,B has 1000 entities , and C has 10 entities. What is the maximum number of triples of entities that could
be in the relationship set for R?

Max no of triples will be 1000

As, here A to B many to one relationship

So, each B will form 1 triples,So max 1000 triple

Now A to C also many to one relation, C will also form 10 triples

But max.no of triples of entities will be 1000

 1 votes -- srestha ( 11585 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 935 of 2244

7.359 Mulivalued Dependency top gateoverflow.in/29151

In Laymann terms, what is Multivalued Dependency?

X-->Y means for one value of X we can have more than one value of Y

Example::deptname-->phone no

 0 votes -- Pooja ( 22773 points)

7.360 Dense index top gateoverflow.in/25895

A block can hold either 12 records or 42 key pointers .A database contains 96 records , then how many blocks are required to
hold the data file and the dense Index?

a). 10

b). 12

c). 11

d). 13

databases

No of blocks for record=96/12 = 8

No of block for index=96/24 = 4

So total no of blocks= 12

 1 votes -- Pooja ( 22773 points)

7.360 Can anyone please help me with that UNDO and REDO concept in
recovery of transaction with commit and checkpoint? top gateoverflow.in/25576


Selected Answer

Checkpoint: Checkpoint is a mechanism where all the previous logs are removed from the system and
stored permanently in a storage disk. Checkpoint declares a point before which the DBMS was in consistent
state, and all the transactions were committed.

Recovery:When a system with concurrent transactions crashes and recovers, it behaves in the following
manner −

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 936 of 2244

The recovery system reads the logs backwards from the end to the last checkpoint.

It maintains two lists, an undo-list and a redo-list.

If the recovery system sees a log with <tn,


start=""> and <tn,
commit=""> or just <tn,
commit="">, it puts the
transaction in the redo-list.

If the recovery system sees a log with <tn,


start=""> but no commit or abort log found, it puts the transaction in undo-
list.

All the transactions in the undo-list are then undone and their logs are removed. All the transactions in the redo-list and
their previous logs are removed and then redone before saving their logs

 1 votes -- Leen Sharma ( 2935 points)

7.361 database indexing, "what is binary search on data"...not getting what


he want to ask top gateoverflow.in/29135

52) No. of binary search log 23000 =12

53)No of records =3000

Block size=1024B

Unspanned record length=100B

No of records in each block (B.F.)= floor(1024/100)=10

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 937 of 2244

No of blocks in each record= ceil(3000/10)=300

B.F. in primary indexing =floor(1024/15)=68.26= 68

No of blocks in primary indexing ceil(300/68)=44.11=45

No of accesses in first level=300 entries

No of entries in second level = 45

So, block access in secondary index =1+ceil(log 45) =1+6=7

Ans 7

http://nptel.ac.in/courses/IIT-MADRAS/Intro_to_Database_Systems_Design/pdf/5_Data_Storage_and_Indexing.pdf

 0 votes -- srestha ( 11585 points)

7.362 multivalued dependency top gateoverflow.in/29150

find multivalued dependency in this table?



Selected Answer

There are two multi value attribute

course ->-> Book and course ->-> Lecturer

Since if we add a book to the course we have to add for each lecturer in that course

e.g Korth is added AAH then in table

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 938 of 2244

AAH KORTH JOHN


AAH KORTH WILLIAM M
AAH KORTH CHRISTIAN G
Should be added in the table

or if we add any lecturer for any course we have to add book for it .

 1 votes -- Umang Raman ( 10379 points)

7.363 DATABASE top gateoverflow.in/32434

7.364 dbms top gateoverflow.in/17143

Bank(bname,city)

Travel(pname,city)

select T1.pname from Travel T1 where not exists(select B.city from Bank B where B.bname='SBI' except select T2.city from
Travel T2 where T1.pname=T2.pname);

My question is what T1 and T2 doing here? Can anybody give an example and explain?

Here T1 and T2 refer to two copies of same table travel..basically they are alias to same table travel...this query is trying
to find pname who has visited sbi branches in all city

 0 votes -- Pooja ( 22773 points)

7.365 When the system is restarted, which one statement is true of the
recovery procedure? top gateoverflow.in/15098

Consider the following log sequence of two transactions on a bank account,initial balance 12000, that transfer 2000 to a mortgage payment and
then apply a 5% interest.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 939 of 2244

1. T1 start
2. T1 B old=12000 new=10000
3. T1 M old=0 new=2000
4. T1 commit
5. T2 start
6. T2 B old=10000 new=10500
7. T2 commit

(A) We must redo log record 6 to set B to 10500


(B) We must undo log record 6 to set B to 10000 and then redo log records 2 and 3.
(C) We need not redo log records 2 and 3 because transaction T1 has committed.
(D) We can apply redo and undo operations in arbitrary order because they are idempotent

According to me answ must be option B since after failure the transaction T1 was commited partially hence now it needs to redo both the write
operations as it does in case of deffered databse modification , although here we have immediate data base modification but still redo operation
must work similarly only that it redoes all the write operations .

databases

http://gateoverflow.in/981/gateoverflow.in

 1 votes -- Tehreem Ansari ( 1327 points)

7.366 How can in the below schedule write write operation can be swapped ?
top gateoverflow.in/15147

I am nt getting how this write operation in the first case can be converted into a serial schedule in both the two cases , i.e we
are given the first set as the complete schedule now how can we convert it into serializable schedule i.e. since READ(X) of transaction T1 cannot be swapped with the WRITE(X) of T2 , hence
while drawing the graph , there must be an arrow from T1 to T2 .

Also WRITE(X) of T1 cannot be swapped with WRITE(X) of T2 hence there must be an arrow from T2 to T1 , now there comes a cycle in the graph , hence it must be not be conflict
serializable so then how can we convert that schedule into a serial schedule ?

databases

7.367 ER model top gateoverflow.in/34709

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 940 of 2244

Q). Relations produced from an E − R model will always be in

a). 1 NF

b). 2 NF

c). 3 NF

d). BCNF

7.368 consistency in database top gateoverflow.in/34723


Selected Answer

Yes, Programmer ensures consistency.

Imagine a scenario for programming a transfer of amount Rs.1000 from account A to B.A has 1500 B has 1500 initially
A+B=3000

A= A-1000 and B=B+1000

A=500 B=2500

After transaction if A+B=500 then we can say that there is some problem in the coding as for database to be consistent
A+B should be 3000.

If there is no proper coding the database can enter into an inconsistent state.

 1 votes -- bahirNaik ( 2479 points)

7.369 B+ tree order top gateoverflow.in/34727

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 941 of 2244

lets have order as p=degree

b+tree

Internal nodes have form <[bp][k][bp] [k][bp] [k][bp] > order p max (p-1) keys , p are actually number of block
pointers.

To find max how many keys can fit in formula would be

blocksize*(p)+keysize(p-1)<= 512

8(p-1)+8p<=512

8p-8+8p<=512

16p<=520

p<=32.5

hence p can be max 32

your are correct it should be 32 don't know why they have given 33.

 3 votes -- bahirNaik ( 2479 points)

7.370 How is the below schedule conflict serializable ? top gateoverflow.in/15198

I am not getting that due to Write(A) in T1 and Read(A) in T2 , I will have an edge from T1 to T2 , and then due to Write(B)
in T1 and then Read(B) in T1 , we will have an arrow from T2 to T1 , hence a cycle is formed so it should be non-conflict
serializable , so why is it conflict serializable , plz correct me where am I wrong ?

databases

Conflict serializable in given problem like belows ways::

T1----->T2

In first half:

In second half also T1---->T2:

Explanation(For variable A)::

In T1(1st) and T2(sec)::

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 942 of 2244

READ(A) conflict only WRITE(A) but not READ(A)

WRITE(A) conflict READ(A) first then WRITE(A) therefore order is T1--->T2

Explanation(For variable B)::

In T1(First) and T2(sec)::

READ(B) only conflict with WRITE(B) in T2 not READ(B) in T2

WRITE(B) conflict both READ(A) and WRITE(B) in T2

Therefore T1---->T2.

 0 votes -- admin ( 1411 points)

7.371 How many minimal candidate eys are there? top gateoverflow.in/15356

On the relation R(a,b,c,d,e) if candidate keys are c, d, ab, be

then how many minimum candidate keys are there?

minimum does not exist here minimum stand for only one. but c and d may be taken as minimum but this assumption is
wrong . just to match the answer of a wrong study material i am saying that .

 0 votes -- Ravi Singh ( 7303 points)

7.372 why are both SIX and SIX not compatible to each other ? top gateoverflow.in/15411

If a node is already in SIX mode then why can't another transaction lock it again in SIX mode ?since this implies that some
another transaction is trying to apply exclusive lock on some node below this current node , so then what 's the issue ?

databases

7.373 Full outer join top gateoverflow.in/34042

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 943 of 2244

databases

ANSWER: Q 1 , Q 2 and Q 3

EXPLANATION

Natural Join is a type of cartesian product whose selection of tuples is based on common columns of two
table.

Outer Join considers all the tuples from both the table and join them with specified attribute. Null in case of no
join of tuples possible.

SQL COMMANDS

CREATE TABLE PSNGR(


Pass_No varchar(2),
Pass_Name varchar(10),
TNo varchar(2)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 944 of 2244

);

CREATE TABLE TRN(


TNo varchar(2),
Type varchar(3)
);

INSERT INTO PSNGR VALUES


('P1','Mallesham','T4'),
('P2','Suresh','T3'),
('P3','Anirudh','T3'),
('P4','Shiva','T1');

INSERT INTO TRN VALUES
('T1','SFA'),
('T2','EXP'),
('T3','SHA'),
('T4','RAJ');

SELECT PSNGR.Pass_Name,PSNGR.TNo, Type


FROM PSNGR CROSS JOIN TRN
WHERE PSNGR.TNo = TRN.TNo
AND TRN.Type = 'SHA';

SELECT PSNGR.Pass_Name,PSNGR.TNo, Type


FROM PSNGR NATURAL JOIN TRN
WHERE TRN.Type = 'SHA';

SELECT PSNGR.Pass_Name,PSNGR.TNo, Type


FROM PSNGR JOIN TRN
ON PSNGR.TNo = TRN.TNo
WHERE Type = 'SHA';

Output of the three select statement -

EDIT:

Result of Q 3 becomes clearer with the following query

SELECT PSNGR.Pass_Name,PSNGR.TNo, Type


FROM PSNGR JOIN TRN
ON PSNGR.TNo = TRN.TNo;

 2 votes -- Prateek Dwivedi ( 845 points)

7.374 why are IS and S locks compatible ? top gateoverflow.in/15410

if a node R1 is in IS mode then it may be a possibility that some node below it is in exclusive
lock then how can we lock R1 in S mode since if I apply S on it that means I am
trying to lock every node below R1 in S mode but since some node below it is already
in exclusive lock so then how can I apply S lock on it .

since may be initially R1 was in IX mode but some other transaction came and applied
IS to it that means some node below R1 can be both in exclusive mode and in shared mode if R1 is
in IS mode so than how can a transaction come and lock R1 in shared mode i.e. why are IS and S locks
compatible ?

databases

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 945 of 2244

7.375 TestBook Test Series Database top gateoverflow.in/34329

Q 40). Which of the following is/are TRUE?

I). Strict schedule is a cascade-less schedule and recoverable schedule.

II). Every cascade-less schedule is recoverable schedule.

III). Every conflict serializable schedule is recoverable.

I and II only

II and III only

I and III only

Please answer with reference why III is false.

I see venn diagram ->


https://en.wikipedia.org/wiki/Schedule_%28computer_science%29#Hierarchical_relationship_between_serializability_classes

Here. (Same is used in ans key, but no reference for it !)

test-series databases

7.376 Division Operator top gateoverflow.in/34547

databases

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 946 of 2244


Selected Answer

In simple terms, the division operation, π AB (R) / πB (S) means 'A' values for which there should be 'B' value in R for every
'B' value occurring in S.

Now, we see that the combination of every row of R 2 not occurring in R 1 and so the correct option is (d).

 1 votes -- Utk ( 1385 points)

None of these , ultimately getting no distinct values .so empty set. Apply usual rules of division and find out

 1 votes -- chat28 ( 495 points)

7.377 Outer join top gateoverflow.in/34730

All will output the same result set!

"All" should be the correct answer.

 0 votes -- bahirNaik ( 2479 points)

7.378 cardinality top gateoverflow.in/34731

databases

A B

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 947 of 2244

a1 b
a2 b
a3 b
a4 b

Relation will be look like this...because cardinalities of R1 is m and of R2 is 1 So cartesian product will give the result like
above table

 0 votes -- Rahul Rai ( 41 points)

7.379 B+ Tree Find Order top gateoverflow.in/35594

In a database file, the search key field is 9 bytes long the block size is 512 bytes, a record pointer is 6 bytes and block
pointer is 7 bytes. The largest possible order of a non leaf node in B+ tree implementing this file structure {order defines
maximum number of keys present} is ______.

Solution

Asked Order of Internal Node:

Equation : order *( Block Ptr Size ) + ( order -1) Record Ptr Size < = Block Size

n(7)+ ( n-1) * 6 <= 512

13n <= 518

n <= 39.84

order = 39

Answer given as 31 .
How is this possible . Correct me if i am wrong


Selected Answer

My Answer is

Block Size =(n-1)key size +(n-1) record size + n* block pointer size
n is the order of b+ tree
512=(n-1)*9+(n-1) *6+n* 7

512=15n-8

n=520/15 =34.66

floor(n) =34

 1 votes -- shivanisrivarshini ( 2067 points)

7.380 ER model top gateoverflow.in/35578

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 948 of 2244


Selected Answer

its maain to many relation

in case of many to many relation a new table is created for relation

so 3 tables are

employee(eno,ename);

dept(dno,dname)

works(eno,dno,since)

so b is ans

 0 votes -- Pooja ( 22773 points)

7.381 maximum number of keys in any non-root node top gateoverflow.in/35620

The minimum number of keys in a B + tree is 3. The maximum number of keys in any non-root node is ____.

Solution:

min no of keys = ceil ( n/2 ) -1

3 = ceil (n/2) -1

n = 8

the keys in non-root will be n-1 = 7 ( Where n is order of b+ tree )

answer given as 8

What is wrong with my answer ?


7.382 State True or False top gateoverflow.in/35622

F = {AB → C, A → B, B → A}. Canonical cover of F is unique.

Solution

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 949 of 2244

If B closure contains A i can eliminate A


SO
A ---> B is in canonical FD

Similarly B---> A

I can find 2 different types of Canonical FD for the given set hence it is unique and true

it is given that the the statement is False . How is it possible ?



7.383 Explain top gateoverflow.in/26227

databases


Selected Answer

level 1 : one node ( root node ) contains 10 block pointers as B+ tree is of order 10

level 2: contains 10 nodes each with 10 block pointers

level 3: contains 100 nodes each with 10 block pointers

level 4: contains 1000 nodes ( assuming order of leaf nodes is 10 as they didn't mention separately)

each node contains 9 (key , record pointer) pairs

so maximum number of records that can be indexed is 9*1000 = 9000

 2 votes -- pramod ( 2071 points)

7.384 DBMS B+tree top gateoverflow.in/35554

Consider a relation R(A B C) with attribute size of A as 8 bytes. Disk block size is 512 bytes and block pointer is 8 bytes. The
best choice for degree (maximum value) for B+ tree, if B + tree was used for creating indexing on R(A B C) is ______

My Calculation

16n<= 520

n<=32.5

So order will be 32 ?
Answer given as 33.
Which is correct ?

7.385 Number of Superkeys top gateoverflow.in/35518

Relational scheme R with N attributes A 1, A2 …. A n. If every attribute is the Candidate Key, then how many superkeys are
possible?

databases

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 950 of 2244


Selected Answer

No of super keys will be 2^n-1

There will be no overlapping( all subsets except phi will be super key)

There will be n candidate keys

For eg R(a,b,c) a b c are candidate keys

a b c ab ac bc abc are super keys

 4 votes -- Pooja ( 22773 points)

7.386 blind writes top gateoverflow.in/34741

Consider the following schedule S1.

S1 : R1 (C)R2 (C)W1 (A)W2 (A)W1 (C)R1 (B)R2 (B)W1 (B)W1 (D)W2 (B)W2 (D)R1 (F)W3 (E)R3 (F)

Let ′ X ′ be the number of 'blind-write' operations in the given schedule and ′ z ′ be the number of conflict equivalent serial
schedules to S1 . The value of X ∗ Z is_________.


Selected Answer

The Schedule is not conflict serializable.This can be checked by the precedence graph,it contains a cycle.It has 5 blind
writes that are the writes without any prior read of that data item.

Z+X= 0+5=5

 5 votes -- bahirNaik ( 2479 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 951 of 2244

7.387 Advantage of B+ tree over B tree top gateoverflow.in/15063

I am unable to get that what advantage do we get when we store only records consisting of primary attributes in case of B+
tree i.e. we do not store record pointers corresponding to those key attributes , we do it only at the leaf level , doesn't it
increase the overhead since we have to come upto the leaf level and then access the data where as in case of B tree with
each node we have a record pointer associated so I guess that's more advantageous , so then why database designers prefer
B+ trees over B trees ?

databases


Selected Answer

first of all u need to understand this. we do not use AVL trees or red black trees as they grow depth wise rather than
breath wise. we prefer breath growth as the number of levels will be less and the time search time will be less due to less
number of levels.

now we prffer b+ over b because . b+ grows more breath wise than b tree. what it means is it can holds more data in
internal nodes.

to explain i m taking an informal example

suppose u have a seat which is of 6 meter. now each person requires 1m space . so total number of person that can sit =6
(b+ tree case)

now in second case everyone is carrying an extra luggage of 1 meter. so total number of person that can sit =3 (b tree
case)

the same case happens in b tree. every internal node should contain key with record pointer . which is a type of extra
field.which is not present in b +tree . due to which the number of keys a block can accumulate becomes less. and the b+
tree for the same reason can accumulate more number of keys. as more number of keys can be stored in the internal
nodes . the height of tree decreases due to which the search efficiency increases.

2ndly page fault decreases . as in one page more number of keys are stores the page fault rate decreases as there is
more probability of a hit.

now i think u can understand this rather than mugging up.

 0 votes -- Ravi Singh ( 7303 points)

7.388 dbms top gateoverflow.in/35222

what is output and explain

7.389 Canonical cover is in which normal form ? top gateoverflow.in/15007

I am just having one confusion that if we have a canonical cover so it doesn't have any extraneous attributes or redundancy ,

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 952 of 2244

so is it always in normal form, or not always true ,i.e it may depend on whether it satisfies all the conditions for being in
normal form .

databases


Selected Answer

basically when we have a canonical cover that mens we have the non redundant functional dependecy . it will be in first
normal form only . the actuall use of canonical cover in the process of normalization is to remove the reduent and and
repeating functional dependency which make our problem easy now. There is a way how our teacher taught us all about
normalization. a live example .

according to him normalization is a war . now i am training u to be a commando of normalization. before going to war u
have to choose guns . if there are 2 set of functional dependency which mens 2 guns . u definitely will choose more
powerful else if there is only one gun u have to make it lighter so that u can fight easily. here canonical cover help us. if u
have 2 set of functional dependecy chose that is more powerful mens whic is driving more attributes, else just remove all
the redudant terms other wise u have to deal with them aterwards. now after choosing gun u have to choose bullets . so
find candidate keys . they are the bulets now u are ready to fiht the battle of normalization . now u can easily understand
that these steps are required before normalization.

 0 votes -- Ravi Singh ( 7303 points)

7.390 2pl top gateoverflow.in/34034

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 953 of 2244

Yes. its possible to execute the schedule in 2PL.

T1 T2 T3

X(A)

W(A)

X(B)

U(A)

X(A)

W(A)

W(B)

U(B)

X(B)

U(A)

X(A)

W(A)

W(B)

U(B)

X(B)

W(B)

U(A)

U(B)

Since schedule is allowed to execute in 2PL then schedule is conflict serializable schedule & conflict serial schedule is the
lock point order(lock point is red colored).this way, Equivalent conflict serial schedule is T2 -> T1 -> T3

 0 votes -- Sandeep Singh ( 5939 points)

7.391 Why does Read operation conflicts with write operation ? top gateoverflow.in/15422

I am having one confusion in this concept , say T1 reads a data item A and then T1 writes on it , so we say that while
converting into a serial schedule we can't swap these two , but what's the reason behind this since whatever T1 does in its
doing with its own memory variable , hence no issue of conflict and even after T2 issues write then whatever T1 would write
would be written back into the disk so then why do we not allow read to swap with write operation .

databases


Selected Answer

imagine you are about to write on a piece of paper anything

you will do two things first read what is there if any and then write after that or even overwrite it.

now imagine you write and then read.. it seems both would be same i guess ..remember when you write and read you are
overwriting whatever the paper had even without knowing what it had..this time you are nt reading what was there but
you read what you wrote now or we may say you are bothered to write and then see what you wrote..

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 954 of 2244

here you will always read the recent change you made

But if you read and then write you will read the previous change that could have been done by anyone else NOT ONLY
YOU ..

hence this is y they cant be swapped or we say they are differnt even in ones own transaction ..

else you would nt read what your friend wrote 2 sec ago and but read what you wrote 1 second ago.and who knows you
might need the information your friend tried to convey you but since you tot to write and then read you lost them.. ur
decission may be fatal as you ddnt listen or read what ur friend wrote and missed them

 0 votes -- admin ( 1411 points)

7.392 Query equivalence top gateoverflow.in/33150

Let R and S be relational schemes such that R={a,b,c} and S={c}. Now consider
the following queries on the database:

I. ΠR − S(r) − ΠR − S(ΠR − S(r)×s − ΠR − S,S(r))


II. { t | t ∈ ΠR − S(r) ∧ ∀u ∈ s ( ∃v ∈ r ( u = v[s] ∧ t = v[R − S]))}
III. { t | t ∈ ΠR − S(r) ∧ ∀v ∈ r ( ∃u ∈ s ( u = v[s] ∧ t = v[R − S]))}
IV. SELECT R.a, R.b
FROM R,S
WHERE R.c=S.c

Which of the above queries are equivalent?

http://gateoverflow.in/1331/gate2009_45

 0 votes -- Monanshi Jain ( 5827 points)

7.393 ugc net dec 2015 top gateoverflow.in/33100

consider the table create table test( one integer , two integer , primary key( one) ,unique (two) ,check (one>=1 and <=10),check (two>=1 and <=5)); how many
records atmost can this table contain
1) 5 2) 10 3) 15 4) 50 ans is given 5 as they said two is unique so max 5 record but in my opinion it should be 10 as unique key can contain null also

7.394 SOLVE THIS ONE top gateoverflow.in/16380

Consider the following schedule S1:

S1: R1(C) R2(C) W1(A) W2(A) W1(C) R1(B) R2(B) W1(B) W1(D) W2(B) W2(D) R1(F) W3(E) R3(F)

let 'X' be the number of bilnd writes and 'Z' be the number of conflict equivalent serial schedules to S1. the value of X*Z
is=______

I think here no of blind writes =5 and no of conflict equivalent serial schedules=0 . because there is a loop betwwen T1 and
T2. so 5*0=0

number of blind write is equal to 5 , means value of X=5.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 955 of 2244

and transactions in given schedule forming a circle so the given schedule is not conflict serializable.

so the numer of conflict equivalent serial schedules=0;

means value of z=0;

so X*Y=5*0=0;

so final answer is 0;

 0 votes -- rohit37s ( 195 points)

7.395 Sparse dense top gateoverflow.in/33157

databases

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 956 of 2244

Ans will be (C)

 0 votes -- srestha ( 11585 points)

7.396 Uniform distribution top gateoverflow.in/33161

Uniformly distributed,means the tuples are distributed 1 to 100,101 to 200,..in this way,401 to 500,total 5 division,each
having 200 tuples total 1000 tuples,so now relation r less than equal to 200 means ,total 200 +200 =400 tuples

 0 votes -- Sayantan Ganguly ( 5061 points)

7.397 Finding minimum number of tables top gateoverflow.in/16917

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 957 of 2244

Find the minimum no of tables requires for representing the above relational model?

3 tables will be required

Department ( dno,dname)

phone number(dno,phone)

office(dno,office).
the key is we always make a new table for multivalued attribute and place the attribute with the primary key of the table.

 0 votes -- Ravi Singh ( 7303 points)

7.398 Which evaluate differently top gateoverflow.in/32685

databases

7.399 Identical Queries top gateoverflow.in/32566

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 958 of 2244

databases

7.400 The physical location of a record determined by a formula that


transforms a file key into a record location is top gateoverflow.in/16991

The physical location of a record determined by a formula that transforms a file key into a record location is

a)Hashed file

b)B-Tree file

c)Indexed file

d)Sequential file

In hashed file physical location of record is computed using hash function so ans is a

 0 votes -- Pooja ( 22773 points)

7.401 Find no. of records in highest level of multi-level index top gateoverflow.in/16941

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 959 of 2244

http://gateoverflow.in/259/gate2008_70

Basically i think i m wrong but i am going to try.

The answer to question 1 is 256 to 4 .

now the blocking factor of database=1024/32=32 record/ block

blocking factor of index file will be= 1024/(4+10) ( 4bytes ssn and 10 bytes block pointer. )= 73.14=73

total number of blocks database need = 16384/32= 512 blocks.

now in primary index we know that every block has a entry in the index. so index file will need

512/73 = 7.01 = 8 blocks wil be needed if we do one level of indexing.

indexing is done till all file comes in one block.

so still 8 blocks are needed one more level will be required.

which will contain 8 entries as each block will be having a pointer in 2 level index.( which is not an option )

now they are using clustred indexing.

clustred index file contains entry for every distinct entry , as every distinct entry in this question is taking a block . total
number of entry will be number of block . as it is stated they are evenly distributed.

512 blocks how 1000 entry all starting with a new block can exist.

3 possiility are there

i am wrong .

question is wrong or ambiguous

far beyond that i have studied..

plz post the solution as provide then i think we may help .

 0 votes -- Ravi Singh ( 7303 points)

7.402 which of the expressions are equivalent ? top gateoverflow.in/16935

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 960 of 2244

7.403 PLEASE SOLVE THIS top gateoverflow.in/16379

The maximum number of nodes in a B+ tree with order 4 and height 6 are ____________

I think it should be 1+4+4^2+4^3+4^4+4^5+4^6= >(4^7-1)/(4-1)=>5461

yes ans should be order is 4 so each node will have 4 pointers


1+4+4^2+4^3+4^4+4^5+4^6= >(4^7-1)/(4-1)=>5461

 1 votes -- Pooja ( 22773 points)

7.404 HOW TO SOLVE THIS ONE? top gateoverflow.in/16377

Consider unspanned blocking with 20 byte blocks. A file contains records of sizes 2,5,3,7,4,20 bytes.

The percentage of space wasted if blocks are allocated for file is __________

Answer should be 31.66% wastage=60-41/60*100

 0 votes -- Pooja ( 22773 points)

7.405 seralizibilty top gateoverflow.in/33661

is blind writes and write after reading a data item same or not

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 961 of 2244

no they are not same . blind wite is . writing without reading the data item without reading it. .

 1 votes -- Ravi Singh ( 7303 points)

7.406 serializibility top gateoverflow.in/33659

R1(a),w2(a),w1(a),w3(a) is view serializibility or not explain?

It is view serializable..

Intial read is done by t1 and finite write by t3

So t1 t2 t3 is sequence as initial read condition and final write condition satisfied

 2 votes -- Pooja ( 22773 points)

7.407 what is the actual meaning of rollback in a transaction ? top gateoverflow.in/15491

we say that when any transaction is rolled-back that means it would be re-started again , so lets say if T2 reads a data item
from T1 , perform some computation on it and then writes it back onto disk and after some T1 fails , so its a dirty read
problem and we say that this schedule is not recoverable , so then if T1 is rolled back i.e. it is restarted again so then will T1
execute in a serial fashion from start till end or whether there would be still some concurrent execution between T1 and T2 .

After roll-back will the value of data item be set to its initial value or since T1 is restarted again it would be set to the value
as computed by T1 again ?

databases

It is a signal means that the transaction has ended unsuccessfully, so that any changes or effects that the
transaction may have applied to the database must be undone.

 0 votes -- sudhanshu kumar ( 31 points)

7.408 How many tuples appear in this following relational algebra top gateoverflow.in/33679

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 962 of 2244

databases


Selected Answer

ANSWER: 2

EXPLANATION

For the sake of explanation, I would prefer to make a minor modification to the given relation algebra as follows -

ρP(A,B) (πA,B(R)) ⋈R.B<S .BρS (A,B) (πB,c(R))

I just renamed the relation to the left of join operation as P. Now let us see the state of two relations before the join
operation.

P S

=========== ==============

A B A B

-------------------- -------------------------

1 2 2 3

1 3 3 2

3 2 2 1

Join operation is simply a cartesian product with a condition. So before join operation, let's see what will be result of PXS

P + S

=========================

A B + A B

---------------------------------------------

1 2 2 3

1 2 3 2

1 2 2 1

1 3 2 3

1 3 3 2

1 3 2 1

3 2 2 3

3 2 3 2

3 2 2 1

Now if put a contraint on above resultant relation to select only those tuples whose P. B < S. B we get;

P + S

=========================

A B + A B

---------------------------------------------

1 2 2 3

3 2 2 3

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 963 of 2244

SQL QUERIES

CREATE TABLE sample(


A numeric(1),
B numeric(1),
C numeric(1)
);

INSERT INTO sample values


(1,2,3),
(1,3,2),
(3,2,1);

SELECT P.A,P.B FROM


(SELECT A,B FROM sample) AS P
INNER JOIN (SELECT B AS A,C AS B FROM sample) AS S
ON P.B<S.B;

 2 votes -- Prateek Dwivedi ( 845 points)

ρS(A,B) (πB,C (R)) -> it will project B and C coloum from table R and rename it as Table S with coloum A,B
i.e. A=B and B=C

πA,B (R) it will project A and B coloum from table R


now according to given condition R.B < S.B only one row satisfy i.e first one

 1 votes -- Umang Raman ( 10379 points)

7.409 what top gateoverflow.in/33715

what is intention shared and exclusive locks

7.410 what is the meaning of the data item actually when we write the
statement READ(A) ? top gateoverflow.in/15648

I am having some confusion in understanding the meaning of the term data item .

when we write

READ(A)

A=A-10

WRITE(A)

Now I am unable to get one point here that when we have a file consisting of various blocks and those blocks consisting of
various record and when we say that we are accessing a particular data item for reading then is this data item is a record or
some particular field inside that record .

And major confusion is that how can we simply read a field from a record during disk access , since disk access is expensive
hence we must be able to fetch the entire block from the disk , but we write only this statement like :

READ(A) , is this block or only a single attribute ?

databases

when we have READ(A), the entire block containing A is fetched from secondary to the buffer. Then from that block the
particular field is read

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 964 of 2244

 0 votes -- Sankaranarayanan P.N ( 7645 points)

7.411 What is the difference between the following two expressions,


conceptually and in terms of relational algebra ? top gateoverflow.in/16110

What is the difference between the following two expressions, conceptually and in terms of relational algebra ?

1. names of girl students with more marks than some boy student
2. names of girl students with marks not less than some boy students

Can someone please give an example to illustrate the difference.

databases

Just resolve the sentence using discrete maths...

x: Girl student

y: Boy student

f(z): marks of student z

then 1- {x|∃y(f(x)>f(y)}

2- {x|∄y(f(x)<f(y)}

thus the first query means select the girl whose mark is greater than any one of the the boy student( it has to be greater
than minimum of the marks of boy students)

and second query means to select the girl whose marks are not less than any boy student (i.e. on negation it becomes
that girls marks are greater than every boy student) thus the marks of girl should be greater than maximum marks of the
boy students.

 1 votes -- Abhishekcs10 ( 1001 points)

7.412 WHAT SHOULD BE THE ANSWER? top gateoverflow.in/16376

I think conservative 2PL prevents deadlock also. What should be the answer?

in two phase locking deadlock is possible...conservative protocol is just a way to ensure that deadlock does not
happen..Impestamp protocol ensures serializability and prevents deadlocks but suffers from starvation

 1 votes -- Pooja ( 22773 points)

7.413 What is the minimum no of candidate keys for the given FD's ? gateoverflow.in/16350

top

AB->C
C->D
D->EA

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 965 of 2244

E->F
F->B

I am getting the answer as 5 but answ given is 2

databases

The answer must be AB and C...Hence only two candidate keys are present.

 0 votes -- Harsh1992 ( 71 points)

7.414 what is the significance of checkpoint in a transaction ? top gateoverflow.in/16338

I am confused regrading the significance of checkpoint i.e. is it that whenever we place checkpoint does that mean that all
the data items before it have been written onto the data base , if not then why do we place it below the transactions which
have simply written the data item but not yet committed ?

databases

checkpoints are inserted in order to make the recovery process more simpler. instead of writing everything to the stable
storage at the end, we issue checkpoint in different occassion. Once a check point is encountered all the dirty pages of all
transaction ( committed and non committed ) is flushed to the stable storage. Also the transaction log is flushed to
storage

Now if there is any need of any recovery, if we need to do a redo , then we need to do it only after the checkpoing

if it is an undo also we need to do it for before the check point (for transaction which were not committed at the time of
checkpoint)
those transactions which were committed before checkpoint, there is no need to do anything.

please note in reality some transaction/ schecules may take a very long time to complete. so it is always better to use
checkpoints

 0 votes -- Sankaranarayanan P.N ( 7645 points)

7.415 which of the following is true? top gateoverflow.in/16128

Every time the attribute A appears , it is matched with the same value of attribute B but not the same value of attribute C.
which of the following is true?

a) A->(B,C) b) A->B, A->>C c) A->B,C->>A d) A->>B, B->C


Selected Answer

the option b is correct . there is just a small definition of multivalue dependencies which . if a->> c is a dependency it
means for a ,c has more than one value.

here it is saying whenever a appears b has same value which is true in case of functional dependency . if a->b exist for
every a if repeats there should be same b . so a-.b exist here and it is clearly saying c is not same which means for same
a it contains multipule value of c. so answer is b .
why not c ??

just consider the case


a is 1

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 966 of 2244

and for c

A C

1 3

1 4

now u can see that for a we have multipule value of c but c does not have multiple values for a . so we cannot say c->>a .
but we can say a->>c. and question is saying c can take different value not a .

 0 votes -- Ravi Singh ( 7303 points)

7.416 DBMS Conflicts top gateoverflow.in/35688

databases

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 967 of 2244

8 Theory of Computation top


8.1 Automata: ugc net dec12 top gateoverflow.in/43894

ans with explanation

automata

Given FA represent all strings containing ba as substring.

And Equivalent minimal DFA is

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 968 of 2244

So No of state =3

 0 votes -- Manojk ( 3365 points)

8.2 Cbt 1: ME cbt-1 q-11 top gateoverflow.in/37037

Consider the following languages over the alphabet Σ = { 0, b, a}:

Which of these languages are deterministic context free language?

Only L1
Both L1 and L2
Both L1 and L3
All of the above

made-easy cbt-1 theory-of-computation


Selected Answer

L2 is not CFL because a PDA cannot check for prime numbers. L3 is not CFL because we cannot check repetitive words in a
PDA (we can check only if words are repeating in reverse order). So, they both cannot be DCFL also. Only L1 is DCFL.

 2 votes -- Arjun Suresh ( 124125 points)

8.3 Chomsky Normal Form: ugc net top gateoverflow.in/44004

53. If the parse tree of a word w generated


by a Chomsky normal form grammar
has no path of length greater than i,
then the word w is of length
(A) no greater than 2^i+1
(B) no greater than 2^i
(C) no greater than 2^i–1
(D) no greater than i

chomsky-normal-form

Option b is correct .

You can see this :)

It is proved my Induction and recurrence relation

http://nptel.ac.in/courses/106106049/downloads/Properties%20of%20CFL.pdf

 0 votes -- Dexter ( 1933 points)

8.4 Closure Property: The recursive sets are not closed under : top gateoverflow.in/25465

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 969 of 2244

closure-property

8.5 Closure Property: toc top gateoverflow.in/29102

L1 is a Context free language (CFL), L2 is a Deterministic Context free language (DCFL)

¯
and , L = L1 ∩ L2

then L is

a) Need not be CFL

b) not CFL

c)DCFL

context-free closure-property


Selected Answer

L2 = DCFL , which is closed under complement so L2' = DCFL

L1 = CFL ,

L = CFL ∩ (DCFL )' = CFL ∩ DCFL BUT ,DCFL AND CFL both are not closed in intersection ...so it may or may not be CFL.

so answer is A)

http://gatecse.in/wiki/Closure_Property_of_Language_Families

 1 votes -- sonam vyas ( 6441 points)

8.6 Closure Property: True or False: DCFL is closed under set difference top
gateoverflow.in/6471
True or False: DCFL is closed under set difference

closure-property theory-of-computation


Selected Answer

Let L1 and L2 be two DCFLs.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 970 of 2244

Now u want to find whether L1 − L2 is dcfl or not? (if DCFL is closed under set-difference, this must be TRUE for ANY such
L1 and L2 ).

To prove this we make use of the fact that DCFL is not closed under intersection. (For example take L1 = {a b c
∗ n n ∣n≥0 }
and L2 = { an b ∗ cn }
∣ n ≥ 0 which gives L1 ∩ L2 = {
an bn cn }
∣ n ≥ 0 , which is not even a CFL.)

¯
L2
Now we can L1 ∩ L2 = L1 −

DCFL is closed under complement (If we complement the accept states of DPDA for L we get DPDA for the complement of
¯
L, but this is not true for a general PDA.) So, L2 is a DCFL, let it be R. So,

L1 ∩ L2 = L1 − R, where L1 , L2 and R are DCFLs. Now, if DCFL is closed under set difference it must also be closed under
complement. But we already showed that it is not. So, DCFL is not closed under set difference.

 5 votes -- Shreyans Dhankhar ( 2265 points)

8.7 Closure Property: Closure Properties Table top gateoverflow.in/43773

http://gateoverflow.in/?qa=blob&qa_blobid=8929616163903734815

closure-property theory-of-computation

8.8 Combinations: Hopcroft Ullman - Automata Theory, Need Help top gateoverflow.in/43342

I am Reading Automata Theory from Ullman(2nd Edition).

I stuck on a point of (Page No. - 65) Example 2.13 (line No. - 4) .

that Line is "Since any of 2n Subsets of the last n symbol"

I think it should be 2n Combination not 2n Subsets

I am highly confused.......*****NEED HELP******

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 971 of 2244

theory-of-computation set-theory&algebra combinations

8.9 Combinations: How to construct an automata with even number of a's


and odd number of b's? top gateoverflow.in/41374

The alphabets are a and b.


Construct a DFA

minimal-state-automata theory-of-computation finite-automata combinations


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 972 of 2244

The above DFA is the required one..

More info:
State 1: even number of a's and even number of b's
State 2: odd number of a's and even number of b's
State 3: even number of a's and odd number of b's
State 4: odd number of a's and odd number of b's

 4 votes -- Abhilash Panicker ( 6527 points)

8.10 Compound Automata: Minimal FA top gateoverflow.in/36422

What is the number of states in a minimal FA which accepts all strings over (0,1)* where every string starts with 100 and
the length of the string is congruent to 1(mod4)

I am getting 11 states. Ans given is 8. While doing the cross product , is it ensured that , I will get the minimal DFA ? or do I
have to minimise after the cross product ?

theory-of-computation compound-automata

there are 8 states inclusive of dead state , sorry for the small size but I tried resizing it but it is not getting uploaded then
,But I hope its clear , u can open the image in new link tab.

And after cross-product you might need to minimize.

 1 votes -- radha gogia ( 4369 points)

8.11 Compound Automata: Two languages reducible to each other in


polynomial time. Which is false option for them? top gateoverflow.in/33889

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 973 of 2244

If Language L1 is reducible to L2 and L2 reducible to L1, then shouldn't they both be Recursively Enumerable Languages? I
am really confused with the option given.

Source : testbook.com live test on 3rd January, 2016

recursive-recursively-enumerable normal compound-automata

as both are polynomial time reducible ie both decidable

Solution also says both are decidable

 0 votes -- Parimal Andhalkar ( 1311 points)

8.12 Compound Automata: How to construct compound Automata ? and find


the no of states in minimal FA ? top gateoverflow.in/33507

Construct Minimal FA that accept all binary strings ends with 01 AND length of string is EVEN .
Also find no of states in its minimal FA

compound-automata minimal-state-automata

The above problem is Intersection of Two problems

1. All binary strings ending with 01, having regular expressoin (0 + 1) ∗ 01, having DFA M1

2. All binary strings of even length , having regular expression ((0 + 1)(0 + 1)) ∗ , having DFA M2

Take Intersection of M1 and M2 , using cross product, having x0 y0 as start state and x2 y0 as final states( where we have both
finals together)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 974 of 2244

Q\ Σ 0 1
→ x0 y0 x1 y1 x0 y1
x1 y1 x1 y0 x2 y0
x0 y1 x1 y0 x0 y0
x1 y0 x1 y1 x2 y1
x2 y0∗ x1 y1 x0 y1
x2 y1 x1 y0 x0 y0

Minimized DFA will be


Q\ Σ 0 1
→ x0 y0 x1 y1 x0 y1
x1 y1 x0 y0 x2 y0
x0 y1 x0 y0 x0 y0
x2 y0∗ x1 y1 x0 y1

 3 votes -- Praveen Saini ( 34299 points)

8.13 Context Free: toc top gateoverflow.in/27122

how to approach

L = {ambn cp dq | m + n = p + q}

give grammar for it???

theory-of-computation context-free

Surely it is a CFL.We can draw a PDA for it

It also can be done by a single stack. Like Push a^m and b^n, and then Pop c^p and d^q

 2 votes -- srestha ( 11585 points)

For L = {a mbncpdq | m+n = p+q , m,n,p,q ≥ 0 }

S → aSd | X | Y | Z
X → aXc | Z
Y → bYd | Z

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 975 of 2244

Z → bZc | ∊

For L = {a mbncpdq | m+n = p+q , m,n,p,q ≥ 1 }

S → aSd | aXd | aYd | aZd


X → aXc | Z
Y → bYd | Z

Z → bZc | bc

 2 votes -- Praveen Saini ( 34299 points)

8.14 Context Free: is it context free? top gateoverflow.in/4689

is it cfl L = { a^n b^n c^m | n>=1 , m=2n } ?

i did like for stack push and pop " a & b " are coverd and later we are having stack empty? can we write this language as

a^n b^n c^2n ?

theory-of-computation context-free

I think a pda cannot be drawn for this language,a stack can be used to check dependency between a and b ( push for a
&pop for b ) but for implementing dependency with c a tm will be needed thus it's nt a cfl

And the language is same as a^nb^nc^2n

 2 votes -- Monisha ( 127 points)

8.15 Context Free: #Toc top gateoverflow.in/26952

I read some where that if thier is one comparision at any time then only CFL otherwise CSL?
plz give proof.

context-free


Selected Answer

That is utter, absolute bullshit. The number of comparisons is ambiguous and ill-defined, so you should avoid using it to
determine where a language lies in the Chomsky hierarchy. If one could distinguish between CFL and CSL just based on
the number of comparisons, Bar-Hillel wouldn't have invented the Pumping Lemma for CFLs.

{ }
How many comparisons do you need to make in ap ∣ p ∈ Primes ? No comparisons, still CSL.

How about this?

{ | }
w ≅ 0 (mod 4)

x ≥ 10, y>z
δ aw bx β γ cy dz ρ
β= γR

δ ∈ Palindromes

So many comparisons, but still CFL.

And the following is regular:

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 976 of 2244

{ | }
α ∈ Palindromes

binary(γ) ∈ Primes OR γ = ϵ
Kolmogorov
α β γ δ complexity
δ∈ of
this answer

β ∈ Σ∗

 4 votes -- Pragy Agarwal ( 13675 points)

8.16 Context Free: CFL production top gateoverflow.in/35499

Are grammars with S → SS productions always ambiguous?

Also, how can the production be represented in form of a formula? For example, S → aSb ∣ ε can be written as S = an bn

What would be the formula for S → aSb ∣ SS ∣ ε?

context-free


Selected Answer

I think this grammar is unambiguous (Note: proving unambiguity for an arbitrary CFG is undecidable!):

S → SS ∣ aA ∣ bB

A → aA ∣ α

B → bB ∣ β

About converting a grammar to a formula, the grammar is a formula! If you want a formula of the type axbycz, it is neither
always obvious nor always possible!

For example, the S → aSb ∣ SS ∣ ε can't be put into a nice looking formula. It describes balanced parenthesis, where a is the
opening paren, and b is the closing paren.

 2 votes -- Pragy Agarwal ( 13675 points)

8.17 Context Free: Which of the following is true ?? top gateoverflow.in/36767

test-series theory-of-computation context-free

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 977 of 2244


Selected Answer

For L1 we count xy using stack and if after y another y comes, it marks the start of yz and then we start popping the count
from stack. So, this is DCFL. (changing xy to yx would make it non-DCFL).

For l2 we need to see if #a ≠ #b, so we push a on stack and pop b. So, DCFL.

D choice. (All other choices are also correct).

 2 votes -- Arjun Suresh ( 124125 points)

8.18 Context Free: Which of the language accepted by the following PDA ??
top gateoverflow.in/25178

theory-of-computation context-free

Assuming that the last state( in the transition order ) is the final state ...

The given PDA will accept the language {a xbycz : x,y,z >=0}

Please verify..

 0 votes -- abby murali ( 431 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 978 of 2244

8.19 Context Free: Is the grammar S → ϵ empty? top gateoverflow.in/20875

Is the grammar
S → ϵ empty?

theory-of-computation grammar context-free


Selected Answer

The only string accepted by the grammar is ε.

L = {ε}

Therefore it cannot be empty.

Here is an example of a grammar that produces an empty language: S → S

Since there are no non-terminals in this grammar, it will never generate any strings. So, its language will be empty L2 = ∅

{ }
S→A
Another example would be: A→S . This grammar has a non-terminal, but it cannot be reached.
B → xyz

 3 votes -- Riya Roy ( 4767 points)

8.20 Context Free: give explanation..??? top gateoverflow.in/18428

context-free


Selected Answer

Only L2 and L4 are CFL because there is only one comparison at one time and CFL can do one comparison.

L2 = i ≤ j or j ≤ i. So, there is no relation between i and j, and they can be anything. (The condition becomes trivial as any i
and j satisfies it). Thus, we can read all the a's without pushing into stack. To ensure that j = k, push all bs into stack.
When we encounter c's pop all b's one by one. Thus, it is a DCFL.

L4 : i = j can be checked by pushing for a's and popping for b's. If at the end of popping for b's, we end up with an empty
stack, we need to check that c's are even, which can be accomplished by a D-PDA. If we end up on a non-empty stack, we
accept. Thus, L4 is also a DCFL.

 1 votes -- Umang Raman ( 10379 points)

8.21 Context Free: Find the grammar that generates inherently ambiguous
context free language. top gateoverflow.in/7428

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 979 of 2244

context-free theory-of-computation

IF a language is Ambiguous and that cannot be written in any other simplified way ( into unambiguous language) , then
language is Inherently ambiguous.

A Language is ambiguous if a string of language can be derived by more than one way and having different derivation
tree.

Such as L = aibjck i=j or j= k , i,j,k>=0

= aibick ⋃ aibjcj

S → S1 | S2

S1 → XC S2 → AY

X → aXb|ϵ Y → bYc |ϵ

C → cC|ϵ A → aA|ϵ

There is no other way to define this language , and there are strings abc, aabbcc, etc which can be derived from both S
→ S1 or S → s2 . So this language is inherent ambiguous.

In case of problem given

a. L = { a nbndm n,m>=0 ⋃ a ibjdj i,j>=0 } which is inherently ambiguous . and strings abd,aabbdd, etc can be derived
by 2 ways

b. L = { a nbm m>=n m,n>=0 ⋃ wb i , w ϵ (a,b)* ,i>=0 }

which can be simplified as

L = w , w ϵ(a,b)* into an unambiguous language

 3 votes -- Praveen Saini ( 34299 points)

8.22 Context Free: Which of the following languages are CFL? top gateoverflow.in/471

Which of the following languages are CFL?

L1 = {0 1
n m
}
∣ n ≤ m ≤ 2n L2 = {a b c
i j k ∣ i = 2j or j = 2k }
theory-of-computation context-free normal

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 980 of 2244


Selected Answer

Both are CFL.

CFG for L1 : {S → 0S1 ∣ 0S11 ∣ ε

{
S→X∣Y

X → Xc ∣ P
CFG for L2 : P → aaPb ∣ ε

Y → aY ∣ Q
Q → bbPc ∣ ε

 7 votes -- Pragy Agarwal ( 13675 points)

8.23 Context Free: Which of these languages are NOT context free? top gateoverflow.in/41233

Let

l1 = {0n +m1n 0m ∣ n, m >= 0},


l2 = {0n +m1n +m0m ∣ n, m >= 0} ,
l3 = {0n +m1n +m0n +m ∣ n, m >= 0}

Which of these languages are NOT context free? Solve this question with explanation Thank you

theory-of-computation context-free


Selected Answer

l1 : This language is context free as we can push all the zeros on the stack and when 1 comes we can pop a 1, after that
when 0 comes we can again pop the zeros from the stack. If stack is empty the string is accepted else can't.
l2 : This is not context free language as if we push all the initial zeros on the stack and start to pop for each 1, we can't
compare the m number of zeros at the last.
l3 : This is not context free language. (same reason as for l2).

 5 votes -- Monanshi Jain ( 5827 points)

8.24 Context Free: toc top gateoverflow.in/7425

Let L1 = {an bmcn ∣ m, n ≥ 0} and L2 = {an cn ∣ n ≥ 0}. Both L1 and L2 are context free languages. if L = (L1 − L2 ) then L is ____.

a. Finite Language

b. Regular language

c. DCFL

d. Not DCFL

theory-of-computation context-free

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 981 of 2244

Selected Answer

L1 = {ϵ, ac, abc, abbc, aacc, aabcc, aabbcc, …}.

L2 = {ϵ, ac, aacc, aaaccc, …, }.

So,

L1 − L2 = {a b c
n m n ∣ m > 0, n ≥ 0 }
DCFL.

 8 votes -- Arjun Suresh ( 124125 points)

8.25 Context Free: Regular - CFG top gateoverflow.in/33999

Consider the language L 1 = { a pbqcr / p,q,r >= 0} and L 2 = { a pbqcr ​/ p,q,r >= 0 and p=r}

Then L 1 - L2 is regular of CFL ?

theory-of-computation context-free


Selected Answer

L1 = {ap bq cr | p, q, r ≥ 0}

L2 = {ap bq cr | p, q, r ≥ 0, p = r}

L1 − L2 = strings in L1 those are not in L2

= {ap bq cr | p, q, r ≥ 0, p ≠ r} , will be CFL

 4 votes -- Praveen Saini ( 34299 points)

8.26 Context Free: Context free grammar top gateoverflow.in/27863

Write a CFG for language L= {a m b n c p d q | m +n = p + q }

context-free

8.27 Context Free: TOC question from virtual gate top gateoverflow.in/28039

Given answer: A
Please explain

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 982 of 2244

theory-of-computation finite-automata context-free

Language is regular and regular expression is : bb*cb*b Complement of L = L(G') = (a+b)* - bb*cb*b

 0 votes -- Digvijay Pandey ( 26245 points)

8.28 Context Sensitive: plz answer... top gateoverflow.in/4958

theory-of-computation grammar context-sensitive


Selected Answer

Lets see the strings generated by G and G'.

For G,
S -> bAcAb -> bcAb ->bcb

S -> bbSbb -> bbAcAbb -> bbcbb

S -> bbSbb -> bbAcAbb -> bbcAb -> bbcb

So, G is generating all strings where number of b's to the left of 'c' in the input string is greater than or equal to the
number of b's to the right. So, L(G) is context-free but not regular.

For G' we have an extra production bA -> A which can condense any number of b's. So, G' will generate all strings over b
and c containing at least one b before and after a c. This language is hence regular.

So, (B) is correct.

 2 votes -- Arjun Suresh ( 124125 points)

8.29 Context Sensitive: Context Sensitive Grammar - ISRO 2008/7 top gateoverflow.in/18478

Consider the grammar

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 983 of 2244

S → ABCc ∣ bc
BA → AB
Bb → bb
Ab → ab
Aa → aa

Which of the following sentences can be derived by this grammar?

A. abc
B. aab
C. abcc
D. abbc

isro theory-of-computation context-sensitive


Selected Answer

C is a useless symbol, since it cannot derive any terminal. Hence, the production S → ABCc becomes obsolete. This causes
all other symbols to become unreachable from S, they are also identified as obsolete!

Therefore we can only derive bc from this grammar.

 3 votes -- Amar Vashishth ( 17865 points)

C is useless nd there is no way to remove it so cnt produce any given output

 1 votes -- admin ( 1411 points)

nothing will be generated question is wrong according to me.

 1 votes -- Ravi Singh ( 7303 points)

8.30 Context Sensitive: How is the complement of Language L is Context free


?? top gateoverflow.in/25180

The complement of the language L containing an equal number of a ′ s,b ′ s and c ′ s is


(a) regular
(b) context free
(c) context sensitive but not context free
(d) recursive and not a cfl.

theory-of-computation context-free context-sensitive


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 984 of 2244

Complement will include all strings which are not in the given language like {a, b, c, ab, ac, ba, bc, cba, aaabbc, …}

(an bn cn )c = Σ ∗ − (an bn cn )

= {a b c ∣ p ≠ q or q ≠ r }
p q r CFL { }
∪ (a + b + c) ∗ (ba + ca + cb + cba)(a + b + c) ∗ Regular

Therefore It is a CFL as CFLs are closed under union (when we do union operation over two CFLs, we always get a CFL).

 5 votes -- Umang Raman ( 10379 points)

Equal No of a's ,b's and c's is not context-free, but it's complement is Context-free.

That is ,

L = {w |noa (w) ≠ nob (w),w ∈ (a + b + c) ∗ }

{ w |nob (w) ≠ noc(w),w ∈ (a + b + c) ∗ }

{ w |noc(w) ≠ noa (w),w ∈ (a + b + c) ∗ }

Note: I hope it can be implemented by NPDA

 4 votes -- Praveen Saini ( 34299 points)

8.31 Context Sensitive: Answer given as (C). Can't understand why ?? gateoverflow.in/36768

top

context-free context-sensitive theory-of-computation

We can reduce this to

L = {0n 1n 0m ∣ n ≥ 0, m ≤ n}.

We cannot make a PDA for this as we need to do 2 infinite counts. But we can do this with an LBA and so L is CSL. Answer
should be B choice.

 2 votes -- Arjun Suresh ( 124125 points)

8.32 Context Sensitive: Grammar - Language top gateoverflow.in/29609

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 985 of 2244

Consider the following context-sensitive productions

S → bSb | AcAAb → A, Ab → bbA → b, bA → A

Let G be grammar given by all the rules except the last, and let G ′ be the grammar given by all the
rules mending the last. Which of the following is true?

​(A) L(G) is regular and L(G ′ ) is context-free but no regular


(B) L(G) is context-free but no regular and L(G ′ ) is regular
(C) Both L(G) and L(G ′ ) are regular
(D) None of L(G) and L(G ′ ) are regular

context-sensitive grammar identify-class-language


Selected Answer

G: S → bSb | AcAAb → A, Ab → bbA → b

lets try to derive some string

S ⇒ bSb ⇒ bbSbb ⇒ bbbSbbb. . (till any no of b ′ s) ⇒ bbbAcAbbb

Now on the left of c be have only one choice bA → b, on right we have two choice Ab → A or Ab → b

So ,we will get

S ⇒ bbbcAbb or bbbcbbbfurtherS ⇒ bbbcAb or bbbcbbfurtherS ⇒ bbbcb


No of b's on the right may be less.

so hereL(G) = {b cb | m ≥ n, m, n ≥ 1 }
m n

L(G) is Context Free

G ′ : S → bSb | AcAAb → A, Ab → bbA → b, bA → A

S ⇒ bSb ⇒ bbSbb ⇒ bbbSbbb. . (till any no of b ′ s) ⇒ bbbAcAbbb

Now on the left of c be have two choice bA → b or bA → A ,on right we have two choice Ab → A or Ab → b

No of b's can vary on either side.


so hereL(G ′ ) = {b cb | m, n ≥ 1 }
m n

L(G ′ ) is Regular,b + cb + .

 2 votes -- Praveen Saini ( 34299 points)

8.33 Context Sensitive: What should be answers of Question 14, 15 and 16


and Why ?? top gateoverflow.in/25181

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 986 of 2244

Common Data for Q14,15 &16 is given below: Ram takes two context-free languages L1 and L2

a). He concatenates L1 and L2 to obtain a new set L3 .

b). He takes the complement of L3 to obtain a set L4

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 987 of 2244

c). He forms a new language L5 by taking the first half of each string in L4 .

d). He obtains a new language L6 by taking the second half of each string in L4 .

e). He concatenates L5 and L6 to obtain a new language L7 .

f). He takes the intersection of L7 and L1 to obtain a new language L8 .

Q14). The language L5 is

a) finite

b).cfl but not regular

c).r.e. but not recursive

d).recursive set

Q15).The language L7 is

a). cfl but not regular

b). csl

c). recursive but not a csl

d). r.e. set that is not recursive.

Q16). The language L8 is

a). recursive

b). csl that is not finite

c). cfl that may regular

d). r.e. set that is never finite.

theory-of-computation regular-language context-free context-sensitive

8.34 Context Sensitive: Complement of CSL top gateoverflow.in/33183

Please some one explain. why complement of this language is CFL.

theory-of-computation context-free context-sensitive


Selected Answer

L= {a b a n n n |n≥1 }

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 988 of 2244

Complement of L, will consist of strings as

{
1. aibjak | i ≠ j or j ≠ k ork ≠ i }
2. All strings starts with b.

3. a ∗ b ∗ or b ∗ a ∗ .

4. All strings contains bab as substring.

5. May be something left, but regular

it will be CFL.

 3 votes -- Praveen Saini ( 34299 points)

8.35 Counting: Let L = {a, bb} How many strings of length 10 are present in
L* ? top gateoverflow.in/15026

Let L = {a, bb}


How many strings of length 10 are present in L* ?

theory-of-computation counting


Selected Answer

Length 1: only one string - "a"

Length 2: "aa", "bb" - 2 strings

Length 3: "aaa", "bba", "abb"

Length (n) = Length (n-1) + Length(n-2),

as we get a string of length n, by appending "a" to a string of length n − 1 as well as by appending "bb" to a string of
length n − 2. (This works only because 'a' and 'bb' doesn't have a common character).

So,

n No. of strings
1 1
2 2
3 3
4 5
5 8
6 13
7 21
8 34
9 55
10 89

We get no. of strings = 89 (10th Fibonacci number)

 7 votes -- Arjun Suresh ( 124125 points)

8.36 Csl: Does CSL Contains Empty String ? top gateoverflow.in/28056

Does CSL contains empty string ? I've got contradictory statements from various sources.
Can someone for sure say whether empty string is CSL or not ! Please give the reference.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 989 of 2244

My source -> Page no 292, Chapter 11 A Hierarchy of Formal Languages & LBA, Peter linz -An Introduction To Finite
Automata, 5th Edition

"A language L is said to be CSL if there exists context sensite grammar G such that L = L(G) or L = L(G) U { }" So
Language contains empty string & Grammar does not ! as per Peter Linz "

Here

means empty string.

Example ->

a^nb^nc^n , n >=0, where this is CSL or Not ? This language contains empty string too !

theory-of-computation csl

Yes, it is CSL. Because empty string must be a regular language. When a string is regular and also finite, it also satisfies
higher properties like CFL, CSL and also recursive

∊⊂ finite ⊂ regular ⊂ CFL ⊂ CSL.

 2 votes -- srestha ( 11585 points)

Yes, CSL do contain empty string.


But with restriction that only the production of the form S->e are valid and S should not occur on the right hand side of
any production (in this case). Just to include, empty string in the grammar, this production is used.

 1 votes -- Monanshi Jain ( 5827 points)

8.37 Csl: Choose the false statement and give proper explanation to each top
gateoverflow.in/26855

Consider the language

L1 = {a n b 2n | n>=1 },

the homomorphism h(p)=a , h(q)=aa Let

L2= h-1 (L1) & R= p*q *

1. L2 intersection R = {a mbm | m>=1}


2. L2 and L1 are both CFL(context free Language) and are not regular
3. L2 is not CFL but is a CSL(context Senstive Language

Choose the false statement and give proper explanation to each

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 990 of 2244

theory-of-computation dcfl csl


Selected Answer

I hope h(p) = a and h(q) =bb

L1= {a nb2n, n>=1} = {abb, aabbbb, aaabbbbbb,...}

L2 = h −1 (L1)

h −1 (L1) ={w | h(w) belong to L1}

L2= {pq, ppqq, pppqqq,....}

[example : h(pq) = abb, h(ppqq) = aabbbb]

L2 = {p mqm, m>=1}

R= p*q*

L2 ∩R = {p mqm, m>=1}

[ note: as far as I think there are some serious typing error in this as h(q) =bb and by option a they mean same result as
I got.]

L1 and L2 are cfls but not regular.

​Option c is false.

 2 votes -- Praveen Saini ( 34299 points)

8.38 Csl: CFL or CSL ? top gateoverflow.in/29925

Is the language given by wwRwwR, where w is any string over the binary alphabet, Context Free or Context Sensitive?

theory-of-computation context-free csl

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 991 of 2244


Selected Answer

L = {wwRwwR ∣ w ∈ (0 + 1) ∗ } is CSL.

Push w into stack, pop w with wR, (here stack become empty) then push w into stack , then pop w with wR, But we are not
sure (or we can't ensure) first w is same as second w, so it is not context-free.

R R
[here is another language as, L = {w1 w1 w2 w2 ∣ w1 , w2 ∈ (0 + 1) ∗ } , that is CFL.]

 4 votes -- Praveen Saini ( 34299 points)

It willbe CSL , not CFL.

Because two w need to be equal

 1 votes -- srestha ( 11585 points)

8.39 Dcfl: DCFL top gateoverflow.in/31639

Is DFCL closed under complement ? If so can you provide any text for the same.

theory-of-computation dcfl identify-class-language


Selected Answer

DCFL are closed under compliment.

Firstly, what do we mean by deterministic CFL?


It means we can make a Deterministic Push Down Machine which accepts this language.

Now, What do we mean by a Deterministic PDA?


It means at any state, we won't have a choice. This is because in a deterministic machine, there are no epsilon moves
possible and there will only be unique moves possible for a given symbol. In a nutshell, for a given state and symbol, we
can "determine" the next state of the machine without any ambiguity.

Now, to get the complement of DPDA, all you have to do is to toggle the final and non-final states of the PDA. If you do
so, your PDA will still stay deterministic. Hence, DCFL are closed under compliment.

 3 votes -- Sudesh Prakash Singh ( 127 points)

8.40 Dcfl: Unambiguous CFL which is not DCFL top gateoverflow.in/25162

Give an example of Unambiguous CFL which is not DCFL .

theory-of-computation context-free dcfl

The set of all of EVEN PALINDROMES over ∑ = {0. 1} is an unambiguous language & it is not a DCFL.

An unambiguous grammar for this language will be:

S --> 0S0 | 1S1 | ∈

 4 votes -- Anurag Pandey ( 8183 points)

8.41 Dcfl: DCFL not closed under top gateoverflow.in/34719

DCFLs are not closed under ________

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 992 of 2244

a. Complement operation

b. Inverse homomorphism operation

c. Reversal operation

d. Prefix operation

theory-of-computation dcfl

REVERSAL

 1 votes -- Monanshi Jain ( 5827 points)

8.42 Dcfl: whether the following languages are DCFL or not??? top gateoverflow.in/32304

L1 = {an c bn } ∪ {a2n d bn }

L2 = {a3k b3k ∣ k ≥ 0 }
theory-of-computation dcfl


Selected Answer

Both are dcfl, we have dpda for them

1. Read 2 a ′ s and push 1 a, we have have of a ′ s on stack

Now If we get c, it means we have double count of b ′ s than those of a ′ s on stack. So on reading two b pop one a ( means
do nothing for one b, pop one a with one b)

​Or, if we get d, it means we have same number of b ′ s, those of a ′ s. So pop one a on reading one b.

​Given c or d, make clear what to do, it is deterministic.

2. is also dcfl, push one a on reading 3 a, pop one a on reading 3 b ′ s.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 993 of 2244

 5 votes -- Praveen Saini ( 34299 points)

8.43 Dcfl: DPDA (Empty Stack vs Final State) top gateoverflow.in/33620

" DPDA acceptance with empty stack" & " DPDA acceptance with Final State" are not equivalent.

Comment on their dissimilarities & why they are not equivalent ?

theory-of-computation dcfl

8.44 Decidability: Are the below two problems decidable ? top gateoverflow.in/27291

1. A turing machine prints a specific letter .

2.If L is CFL then L' is also CFL .

For the second one ,it is known that L' will not be CFL but then why can't we design any algorithm for it ,since it is true that
complement of CFL will never be true so then what is the essence here with respect to talking about decidable and
undecidable ?

decidability


Selected Answer

. A turing machine prints a specific letter .

This problem is redusable to state entry problem. i.e. TM print specific letter if it enter on perticular state since state entry
problem is undecidable so it is also.

 3 votes -- Anirudh Pratap Singh ( 4091 points)

8.45 Decidability: English Terminology top gateoverflow.in/33691

Do we reduce PCP problem to our problem X to show that X is undecidable OR we reduce the problem X to PCP to show X's
undecidability ?. A question has confused me in the terminology.

theory-of-computation decidability


Selected Answer

PCP is undecidable.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 994 of 2244

We have to reduce PCP to X to show that X is undecidable.

If A is reducible to B we can use a solution to B to solve A.

For example :

P : Ram can lift 5 KG dumble.

Q : Ram can lift 2 KG dumble.

Here Q is reducible to P, that is if we know Ram can lift 5 KG dumble, it means Ram can lift any dumble of weight less
than or equal to 5 KG as lifting lighter dumble is an easier task than lifting a heavy dumble.

So we can say that Ram can lift 2 KG Dumble given he can lift 5 KG Dumble.

P is a harder task than Q.

But note that P is not reducible to Q as the capability of lifting 2 KGs does not implies the capability of lifting 5 KGs.

Now consider another case,

M : Ram can not lift 5 KG Dumble.

N : Ram can not lift 2 KG Dumble.

Here M is reducible to N, that is if we know that Ram can not lift 2 KG Dumble then we can guarantee that he can not lift
5KG Dumble and his lifting threshold must be less than 2 KG.

Also, N is not reducible to M as if given Ram can not lift 5KGs we can not say anything about whether he would be able to
lift 2 KGs or not.

Similarly in terms of Decidability of problems, we can say that

Decidability = Ram can lift ___ KG Dumble

Undecidability = Ram can not lift ___ KG Dumble

For convenience you may make following assumptions:

1) A is reducible to B is like saying problem A is easier than problem B.

2) Decidability of a Problem is directly proportional to its easiness: So easy problems are more likely to be decidable then
the harder ones.

3) If a problem X is known to be decidable then every problem easier than X will also be decidable.

4) If a problem X is known to be undecidable then every problem harder than X will also be undecidable.

Now consider the following four cases:

(i) If A is reducible to B and B is decidable then A must also be decidable: we know that B is decidable so we can say that
A is also decidable as A is easier than B.

(ii) If A is reducible to B and B is undecidable then A may or may not be decidable: B is undecidable but A is easier than B
so we can not say that A is undecidable.

(iii) If A is reducible to B and A is decidable than B may or may not be decidable: A is known to be decidable but since B is
harder than A we can not say anything about its decidability.

(iv)If A is reducible to B and A is undecidable then for sure B is also undecidable: A is known to be undecidable, and it is
easier than B so every problem harder than A will also be undecidable.

Your question is similar to case (iv) here.

You can also check a previous GATE question based on the same concept
here: http://gateoverflow.in/1375/gateoverflow.in

 2 votes -- Anurag Pandey ( 8183 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 995 of 2244

8.46 Decidability: S1: L ≤ m {0n1n | n ≥ 0} then L is decidable. top gateoverflow.in/15024

Answer True/False for the statements:

S1: L ≤m{0n 1n ∣ n ≥ 0} then L is decidable.

S2: if L is R.E. and L ′ ⊆ L then L ′ is recursively enumerable because enumerator for L also enumerates L ′ .

theory-of-computation decidability


Selected Answer

S1 is true. L is reduced to a decidable problem and hence L also becomes decidable.

S2 is false. Enumerator for L also enumerates strings in L ′ , but it might also enumerate strings not in L ′ . For example,
take L as Σ ∗ and take L ′ as a non recursively enumerable language over Σ. Now, L ′ ⊆ L

 2 votes -- Arjun Suresh ( 124125 points)

8.47 Decidability: Partially Decideable 1,1 top gateoverflow.in/37470

Some explanation?

decidability

8.48 Decidability: Consider L and L , each over the alphabet Σ. Let f: Σ → Σ be


1 2
top gateoverflow.in/17142

Consider two languages L1 and L2 , each over the alphabet Σ.

Let f: Σ → Σ be a polynomial time, computable bijection, such that:

(
∀x: x ∈ L1  f(x) ∈ L2 )
Further, let f −1 also be polynomial time computable.

Which of the following canNOT be true?

(A) L1 ∈ P and L2 is finite


(B) L1 ∈ NP and L2 ∈ P
(C) L1 is Undecidable and L2 is Decidable
(D) L1 is Recursively Enumerable and L2 is Recursive

decidability theory-of-computation

Give F and F inverse are polynomial time computable functions.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 996 of 2244

=>we can reduce L1 to L2 in polynomial time and L2 to L1 in polynomial time.

ANS (C)

if L1 is Undecidable then L2 should also be undecidable .

if L2 is decidable then L1 should also be decidable .

It is possible to convert L1 to L2 and L2 to L1 , iff both are decidable are , both are undecidable.

 1 votes -- pramod ( 2071 points)

8.49 Decidability: Whether given CFL is Regular is Decidable? top gateoverflow.in/6942

Which of the following are True?

S1: Every NFA can be converted to equivalent PDA

S2: Whether a given CFL is Regular is decidable.

1. S1 2. S2

3. Both 4. None

theory-of-computation context-free decidability


Selected Answer

How can a CFL be given? If it is given as the language generated by a CFG, then the problem is undecidable.

The question here is ambiguous.

 2 votes -- Arjun Suresh ( 124125 points)

Only S1 is decidable.

Checking Regularity for CFLs is UNDECIDABLE problem

 5 votes -- Sandeep_Uniyal ( 5063 points)

8.50 Decidability: How to remember decidability? top gateoverflow.in/26354

I want to know how to remember which language is decidable for which property. Should I go through the proofs or should I
remember everything?

theory-of-computation decidability

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 997 of 2244


Selected Answer

Using my MeFinE Rule:

 5 votes -- Amar Vashishth ( 17865 points)

8.51 Decidability: Choose the decidable algorithm. top gateoverflow.in/25462

Please explain the decidablities of options A, C & D.

decidability

8.52 Decidability: Decidability top gateoverflow.in/26269

L = {⟨M⟩ ∣ M is a TM and | L(M) | ≤ 3}.

Is it decidable or undecidable?

Give the approach ?

decidability


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 998 of 2244

Given an encoding of a TM, we have to accept it if the encoded TM accepts no more than 3 words.

This is the statement of the given problem. I guess many people will have guessed the solution by now- it is undecidable
and more over not even semi-decidable because this is intuitively harder than the complement of halting problem.

We can use reduction to prove this, but it is long. So, just using Rice's theorem. We can get instances of Tyes and Tno as
follows: (any other would also do)

L(Tyes) = {0}
L(Tno ) = {0, 00, 000, 0000}

So, here L(Tyes) ⊂ L(Tno ), which means the given property (of language of Turing machines) is non-monotonic and hence as
per Rice's second theorem, the given problem is not even semi-decidable.

http://www.gatecse.in/803-2/

 6 votes -- Arjun Suresh ( 124125 points)

8.53 Decidability: IF L IS DECIDABLE THEN.. top gateoverflow.in/18897

IF L IS DECIDABLE THEN

1)L&L' BE TURING RECOGNIZABLE

2)L MUST BE TURING RECOGNIZABLE BUT L' NEED NOT BE

3)EXACTLY ONE OF L AND L' BE TURING RECOGNIZABLE

4)L' IS TURING RECOGNIZABLE BUT L NEED NOT BE

theory-of-computation decidability


Selected Answer

L is decidable means it is Recursive language and Recursive language are closed under Complement.So Both L and L' are
REC

And Recursive language are Turing recognizable .

So both L and L' are Turing recognizable Option A

 2 votes -- Umang Raman ( 10379 points)

8.54 Dfa: Dfa identify the language accepted by the following dfa top gateoverflow.in/35081

Accepting language is1- [(1 *0)*01*]*0*

Or 2- (1*0)*0]*0* any of these is correct??

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 999 of 2244

theory-of-computation dfa

8.55 Dfa: Dfa top gateoverflow.in/35114

Construct the minimal dfa that accept all binary numbers which have congruent to 2mod4

Can't we eliminate state q3?

as q1 and q3 hav same inputs and output transition.

I think it is same as a language having strings ending with 10. Right na?

theory-of-computation minimal-state-automata dfa

8.56 Finite Automata: toc top gateoverflow.in/25538

There exist algorithms to decide if a finite automata

A. accepts the empty set.


B. accepts a finite number of strings.
C. accepts an infinite number of strings.
D. all of the above.

theory-of-computation finite-automata

DFA accept all language with finite strings.

Pumping Lemma used to decide/test whether the the given infinite language will be accept by DFA or Not.

Answer : D

 0 votes -- Yash Gupta ( 133 points)

8.57 Finite Automata: Relation between given regular Expression (Finite


Automata) top gateoverflow.in/15109

Let A= (a + b)* ab (a + b)*,

B= a*b* and

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1000 of 2244

C= (a + b)*.

Then the relation between A, B and C:

A. A+B= C

B. A+Reverse(B)= C

C. Reverse(A)+B= C

D. None

finite-automata


Selected Answer

A:all strings containing 'ab' as substring

B:any no. of a's followed by any no. of b's or all strings not containing 'ba' as substring

C:all strings over a,b

Reverse(A):all strings containing 'ba' as substring

Reverse(B):any no of b's followed by any no. of a's or all strings not containing 'ab' as substring

option a:A+B=a^+b^+ which is proper subset of (a+b)* so False

option b: A+Reverse(B)={ all strings containing 'ab' as substring } Union {all strings not containing 'ab' as substring} =
(a+b)* True

option c: Reverse(A)+B= {all strings containing 'ba' as substring }

Union {all strings not containing 'ba' as substring }=(a+b)* True

 4 votes -- Anurag Semwal ( 4775 points)

8.58 Finite Automata: For a length of string n,how many transactions will be
there for acceptance of the string? top gateoverflow.in/32286

For a length of string n,how many transactions will be there for acceptance of the string?

1. O(n)
2. O(n^2)
3. O(nlogn)
4. O(n^3)

theory-of-computation finite-automata

8.59 Finite Automata: Build an FA that accepts the language of all strings of
a's and b's such that next-to-last letter is an a top gateoverflow.in/10695

Build an FA that accepts the language of all strings of a's and b's such that next-to-last letter is an a.

theory-of-computation finite-automata


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1001 of 2244

if you mean to say second last symbol is always a

regular expression = anything secondlast last = (a+b)* a (a+b) [ second last is a , last is either a or b ]

Corresponding NFA will be

convert the above NFA into DFA

resulting DFA will be

 7 votes -- Praveen Saini ( 34299 points)

8.60 Finite Automata: DFA over alphabet {a,b} top gateoverflow.in/11279

Let M be a DFA over the alphabet ∑ = {a,b} with exactly 2 states. Suppose further that M accepts a finite number 'n' of
distinct words. what is the maximum value of 'n' .

A) 1

B) 2

C) 3

D) 4

truly speaking i didn't get the question very clear.

<answer given is A>

theory-of-computation finite-automata

M accepts only finite number of words. So, we should have a dead state and one out of two states must be a dead state
and this must be reachable from the start state. Further there shouldn't be a loop in the path from the start state to any
final state. So, the only option is for the transition on both a and b from start state to go to the dead state. This would
make the DFA accept only "empty" string by making the start state final. So, I suppose n = 0.

 4 votes -- Arjun Suresh ( 124125 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1002 of 2244

a machine will give you finite no. of output . means

eg . a machine contains 2 length string ∑ = {a,b} ....... so the machine will accept finite number of elements( aa, ab
ba bb ).

but in case of infinite length line a machine starts with "a" ... then (a,ab,abb,aab,ababababba, .........so on ) .

and if a dfa contains any cycle then it will produce infinitely many sting , so for finite number of elements the dfa must not
contain any cycle . and it has only 2 states . so according to the condition if you draw this machine you will find out that
1st state must be final state and the 2nd one is used as dead state and this machine will only accept £ . If you
considered £ as word then answer will be 1 otherwise 0 . peace

 2 votes -- Pranay Datta ( 6113 points)

8.60 Finite Automata: How to calculate number of DFA's possible with


designated initial state ? top gateoverflow.in/15855

finite-automata


Selected Answer

if we have n states and k input symbols and assuming that the no of final state may be any subset of these n
states.

no of ways to choose initial state = 1 (as the intial state is fixed)

no of final state = 2^n (as we have two possibility -->1> choose a state and keep in our subset of final state
or 2>do not choose it)

no of different dfa assuming no final state and no initial state is n^(n*k) because

input alphabate a b

dfa can go to any of dfa can go to any of


state1
the 3 staes the 3 staes
dfa can go to any of dfa can go to any of
state 2
the 3 staes the 3 staes
dfa can go to any of dfa can go to any of
state3
the 3 staes the 3 staes

so,total no of state= (no of way to select initial state)(no of way to select final state)(no of way to select
different dfa with is not designated by a final state or initial state)

= 1*2^n*n^(k*n)

 1 votes -- Saurav Kumar Gupta ( 1455 points)

8.61 Finite Automata: How many DFA with 4 state can be constructed over
alphabet a and b with desiginated intial state? top gateoverflow.in/14667

Please tell the approach , I am not getting that when initial state is designated then won't we consider it as like 4C1 since
any of the four states could be initial state since we don't know which of the states would be designated ?

finite-automata


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1003 of 2244

Initial state is fixed. Now from initial state, transitions for symbols a and b can be to any of the 4 states, so there are
4 ∗ 4 = 24 possibilities. Similarly, from 2nd, 3rd and 4th state, there are 24 possible transitions for each state i.e. we have
24 ∗ 24 ∗ 24 ∗ 24 = 216 possible transitions.

Each state also has 2 possibilities of being final state or not, so there are 24 possibilities for choosing final states.

So total number of DFAs = 216 ∗ 24 = 220.

 6 votes -- Happy Mittal ( 9253 points)

8.62 Finite Automata: toc top gateoverflow.in/25539

Consider dfa, nfa & ε -nfa accepting the same language.

Choose the correct statement?

A. All three models always have the same number of states.


B. The minimal dfa for all three machines is unique
C. The nfa model always has more number of states than the dfa
D. The ε- nfa always has the maximum number of states

theory-of-computation finite-automata


Selected Answer

B Statement is Correct.

Different DFA possible for a Language but Minimal DFA for a language is unique and here every model accepting same
language.

Hope this Help you. :)

 2 votes -- Yash Gupta ( 133 points)

8.63 Finite Automata: FSM top gateoverflow.in/17815

Choose the correct one -


A) a FSM with 1 stack is more powerful than a FSM without stack
B) a FSM with 3 stack is more powerful than a FSM with 2 stack
C) a FSM with 2 stack is more powerful than a FSM with 1 stack
D) both A and C

finite-automata theory-of-computation

FSM+1 stack= PDA

FSM+2 stacks or 1 Queue= TM

now power(TM)>power(PDA)
power (PDA)power(FSM)
so A and C both are correct.
FSM+3stacks doesn't produce any benefit over FSM +2 stacks as both are TM only.

 0 votes -- Suvam Chatterjee ( 185 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1004 of 2244

8.64 Finite Automata: Which statement is true? top gateoverflow.in/18035

Consider dfa , nfa & ∈-nfa accepting the same language,

choose the correct statement?

a) All three models always have the same number of states.

b) The minimal dfa for all three machines is unique.

c) The nfa model always has more number of states than the dfa.

d) The ∈-nfa always has the maximum number of states.

finite-automata theory-of-computation

Minimal DFA always unique.

Rest of three option may or may not true. No relation between no of states in DFA,NFA and epsilon NFA. (Max no of states
in DFA of n state NFA is 2^n. But that is maximum)

 1 votes -- Digvijay Pandey ( 26245 points)

8.65 Finite Automata: What is the relation between S and S , where top
1 2 gateoverflow.in/17360

Let S1 be the size of the smallest DFA that accepts all strings, that when interpreted as an integer are multiples of 5.

Let S2 be the size of the smallest DFA that accepts all strings beginning with 1, that when interpreted as a binary integer are
multiples of 5.

What is relation between S1 and S2 ?

theory-of-computation finite-automata


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1005 of 2244

S1 will have 5 states and S2 should have 7.

Suppose L = {w ∣ w ∈ {0, 1} ∗ , w ( viewed as a


binary integer )is divisible by 5 }.
The DFA for L can be drawn by keeping in mind, the following points:

DFA will have 5 states, named Q 0 , Q 1 , Q 2 , Q 3 , Q 4 .


These 5 states corresponds to the 5 remainders of an integer divided by 5.
The start state is Q 0 .
The only final state is Q 0 .

Transitions of the DFA can be defined inductively as follows:

If string w represents integer i, from start state Q 0 ,then assume on input string w we will go to state that corresponds
to Q (i mod 5 ) state.

( )
That is, δ Q 0 , w = Q (i mod 5 )

For example,
If w = ‘‘100 " , then i = 4.
( )
Thus δ Q 0 , ‘‘100 " = Q (4 mod 5 ) = Q 4 .

Since w represents the integer i, ‘‘w0 " will represent (2 × i) (left shifted w).
So, the transition from any state Q (i mod 5 ) on ‘‘0 " will be to the state Q (2i mod 5 ) .

(
That is, δ Q (i mod 5 ) , ‘‘0 " ) = Q (2i mod 5 ).
For example,
If w = ‘‘100 " then i = 4.
(
Thus δ Q 4 , ‘‘0 " ) = Q (2 ×4 mod 5 ) = Q3.

Similarly, ‘‘w1 " represents (2i + 1).
So, transition from state any state Q (i mod 5 ) on ‘‘1 " will lead us to the state Q (2i +1 mod 5 ) .

(
That is, δ Q (i mod 5 ) , ‘‘1 " ) = Q (2i +1 mod 5 ).
For example,
If w = ‘‘100 " , then i = 4.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1006 of 2244

(
Thus δ Q 4 , ‘‘1 " ) = Q (2 ×4 +1 mod 5 ) = Q4.

Suppose L ′ = {w ∣ w ∈ {0, 1} ∗ , w begins with 1, w ( viewed as a


binary integer )is divisible by 5 }.
The DFA for L ′ will be very similar to the DFA for L.

Other than the states {Q 0 , Q 1 , Q 2 , Q 3 , Q 4 }, it will also contain 2 additional states namely Q Start , Q dead to incorporate the
mechanism of rejecting strings starting with ‘‘0 " .

Transitions for the state Q Start will be as follows:

(
δ Q Start , ‘‘0 " ) = QDead
δ (Q Start , ‘‘1 " ) = Q 1 .

Thus DFA for L will contain 5 states, while the DFA for L ′ will contain 7 states.

I don't think further minimization is possible in S2 .

 1 votes -- Anurag Pandey ( 8183 points)

8.66 Finite Automata: No of string accepted by a finite automata top gateoverflow.in/17320

finite-automata theory-of-computation


Selected Answer

The possible ways to create an acceptable string of length k are:

Start with an acceptable string of length k − 3, and take the D → ACD path.
Start with an acceptable string of length k − 3, and take the D → ABD path.
Start with an acceptable string of length k − 2, and take the D → BD path.

Thus, we achieve the recurrence relation given below:


D→ABD
(
N k−3 )  (
N k−2 )
N(k) = D→ACD +

(
N k−3 )+ D→BD


© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1007 of 2244

( )
N(k) = 2N k − 3 + N k − 2( )

The sequence for N(k) thus generated is

0, 0, 2, 0, 2, 4, 2, 8, 10, 12, 26, 32, 50, 84, 114, 184, 282, 412, 650, 976, 1474, …

http://ideone.com/JtmMW1

So, N(11) = 32 is the correct answer.

 2 votes -- Pragy Agarwal ( 13675 points)

Answer: N(11) = 32

I could not find the recurrence relation, but I solved it in this way.

The regular expression for this DFA is (01 + 01)((11)* + (010)* + (001)*)* .

Our problem now reduces to basic counting.

Suppose the string is of the form “##&&&&&&&&&”

In how many ways we can make a string of length 11 from the RE (01 + 01)((11)* + (010)* + (001)*)*

From the (10 + 01) part of the RE, we will always have only 2 possible choices for the 2 most significant bits of the string
i.e. for “##” .

Now for the remaining 9 least significant bits i.e. for “&&&&&&&&&” we have to dwell into the

((11)* + (010)* + (001)*)*part of our RE.

This part can have only strings whose length is a linear combination of 2 & 3 since it is the kleene closure of strings of
length 2 and 3 only.

All possible linear combinations of 2 & 3, which will produce exactly 9 will be,

2 + 2 + 2 + 3, or 3 + 3 + 3.

We have only one choice for length 2(i.e. the string 11) and two choices for length 3(i.e. strings 010 or 001).

For the part 2 + 2 + 2 + 3 => here since the order matters and 3 has two choices, the all possible strings of this type will
be à 4C1(to choose a position for the string of length 3) x 2( to choose among 010 and 001) which gives 4 x 2 = 8.

For the part 3 + 3 + 3 => order does not matters here since all strings are of same length, but each string of lenth 3 has
two choices so it will give 2^3 = 8.

So Total possible ways of forming strings of length 9 for “&&&&&&&&&” = 8 + 8 = 16.

& Total possible ways of forming strings of length 2 for “##” = 2 (10 or 01).

So all possible ways of forming strings of length 11 for “##&&&&&&&&&” = 2 x 16 = 32.

 1 votes -- Anurag Pandey ( 8183 points)

8.66 Finite Automata: 1) How many two state FA can be drawn over an
alphabet {0,1} which accepts the empty language? top gateoverflow.in/16808

finite-automata theory-of-computation

Answer should be 20 if the Finite Automata is Deterministic, and 320 if the Finite Automata is Non Deterministic, under
the ASSUMPTION that THE START STATE IS FIXED.

Points worth mentioning in order to answer this question:

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1008 of 2244

1. If the FA accepts the empty set, either it has no accepting states, or it has one accepting state that you cannot reach
from the other state (which must be the start state).

2. You should decide whether two automata are the same if they differ only in the names of the states. Suppose you call
the states p and q. If I design one DFA with these states, changing the name of p to q and the name of q to p gives me a
different automaton. Are these really different? What this really asks is whether your design of the DFA includes selecting
which state is the start state, or will you simply agree that all 2-state DFA's have "the start state" and "the other state"?

3. Whether the finite automata is a DFA or an NFA?

Now, If the automata is a DFA whose two states are A & B, start state is FIXED to be A, and each transition is defined,
then there would be total 4 transitions possible (delta(A, 0), delta(A, 1), delta(B, 0), delta(B, 1)).

If B is not a final state then each of these transition can have 2 choices (either A or B) so it will give 2^4 = 16 DFAs.

With B as the final state (which will be not accessible from A of course), delta(A, 0), delta(A, 1) will have only one
choice(i.e. A itself) and delta(B, 0), delta(B, 1) will still have 2 choices(either A or B) so it will give 2^2 = 4 DFAs.

So under these conditions, the number of DFAs that accept empty language is 16+4=20.

In case of non – determinism, it is NOT NECESSARY TO DEFINE EACH TRANSITION so any transition can have 4 possible
choices (not defined, A, B, both A&B).

Thus using the same reasoning as used for DFA, the number of NFAs that accept the empty language will be 4^4{if B is
not a final state} + ((2^2) * (4^2)){if B is the final state} = 256 + 64 = 320.

P.S. If you are NOT ASSUMING the start state to be fixed then both of the answers will be simply multiplied by 2 (since
once A can be the the start state and once B).So there will be 40 DFAs and 640 NFAs.

 2 votes -- Anurag Pandey ( 8183 points)

8.67 Finite Automata: toc top gateoverflow.in/25967

The number of states in a minimal finite automata accepting the empty set is_________.

theory-of-computation finite-automata


Selected Answer

1. All strings go to one state- the reject state - there is only 1 class as per Myhill-Nerode theorem and DFA also has just 1
state and no final state.

 1 votes -- Arjun Suresh ( 124125 points)

8.68 Finite Automata: FSM for Adding two integers top gateoverflow.in/16462

Draw a Finite State Machine that adds two integers.

finite-automata


Selected Answer

Finite Automata (FA) or Finite State Machine to add two integers can be constructed using two states:

·q0: Start state to represent carry bit is 0


q1: State to represent carry bit is 1


The inputs to FA will be pair of bits i.e. 00, 01, 10, and 11

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1009 of 2244




The FA starts in state 1 (since carry is 0) and inputs a pair of bits. If the pair is 11, the FA outputs a 0 and switches to
state 2 (since the carry is 1), where the next pair of bits is input and is added to a carry bit of 1.

Example: Consider the addition of 52 and 21
110100 - (binary representation of 52)
010101 - (binary representation of 21)

Since adding numbers is done from right to left, The first input symbol is 01, representing a 0 in the rightmost (binary)
digit of 52 and a 1 in the rightmost digit of 21. The machine enters state q0 (since there is no carry) and outputs a 1. The
next input is 00 because both numbers have zero as the second rightmost digit. The machine enters state q0 and outputs
0. The next input is 11. The machine enters state q1 (since the carry is 1) and outputs 0. Being in state q1 means that
there is a carry from this position into the next. And the remaining bits can be worked out to get 1001001 (i.e. 73).

 1 votes -- Saurav Kumar Gupta ( 1455 points)

8.69 Finite Automata: Minimization of dfa top gateoverflow.in/37589

Do we have any shortcut for minimization of dfa

theory-of-computation finite-automata

8.70 Finite Automata: Model this toy by a Finite Automata top gateoverflow.in/42863

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1010 of 2244

theory-of-computation finite-automata


Selected Answer

a.

Let (XXX = L, R) denote the position of the three levers x2 , x2 and x3 respectively.

Each of the three levers has 2 states and thus we get 2 × 2 × 2 = 8 possible states. But we also need to know if we are in an
accept state or not (i.e., where the ball exited). So, this requires 16 states. Let (XXX)A denote the accept state and (XXX)R
denote the reject state. For simplicity we can avoid the accept/reject part of the state on the left side of transition as the
transition is independent of that part.

1. δ(LLL, A) = (RLL)R
2. δ(LLL, B) = (LRR)R
3. δ(RLL, A) = (LRL)R
4. δ(RLL, B) = (RLR)R
5. δ(LRR, A) = (RRR)R
6. δ(LRR, B) = (LRL)A
7. δ(LRL, A) = (RRL)R
8. δ(LRL, B) = (LLR)A
9. δ(RLR, A) = (LRR)R
10. δ(RLR, B) = (RLL)A
11. δ(RRR, A) = (LLR)A
12. δ(RRR, B) = (RRL)A
13. δ(RRL, A) = (LLL)A
14. δ(RRL, B) = (RLR)A
15. δ(LLR, A) = (RLR)R
16. δ(LLR, B) = (LLL)A

b. We reach final state when

"B" comes at end and there are even number of "B"s (right most path)
"B" comes at end or there are even number of "A"s (centre path) and string length is a multiple of 4 or multiple of 4
+ 3

 2 votes -- Arjun Suresh ( 124125 points)

8.71 Finite Automata: The no. of states of the FSM, required to simulate the
behavior of a computer with a memory capable fo storing 'm' words, each of
length 'n' bits is?? top gateoverflow.in/3411

a) m x 2n

b) 2mn

c) 2m+n

d) None of these

theory-of-computation finite-automata


Selected Answer

We need to find the number of different configurations possible for memory and each of these will be a state in FSM. (At
any time memory will be in one configuration and in next instance it either remains same or goes to a different

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1011 of 2244

configuration)

A word is of n bits. And we have m such words. So, total number of bits = m*n.

We need a separate state for each bit combination. So, no. of states = 2 mn.

 6 votes -- Arjun Suresh ( 124125 points)

8.72 Finite Automata: Problem in Understanding the DFA, Need Help gateoverflow.in/43609

top

I am reading Hopcroft Ullman - Automata Theory(2nd Edition).

In page Number 65 (Red Underline part in the given Ima ge); I understand when i=1 but unable to understand when i>1 then
how the Accepting and Non-accepting State are same.

My Point is "if i > 1 then a1 or b1 may be 1. So, then How it must be both Accepting and Non-Accepting; it may be
Accepting and Non-Accepting ".

Please help me............

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1012 of 2244

Thanks

theory-of-computation finite-automata

8.73 Finite Automata: No. of states in the minimal finite automata which
accepts the binary strings whose equivalent is divisible by 32 is ________?
top gateoverflow.in/7703

No. of states in the minimal finite automata which accepts the binary strings whose equivalent is divisible by 32 is
________?

A. 5

B. 6

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1013 of 2244

C 31

D 32

theory-of-computation finite-automata


Selected Answer

Answer is 6.

For binary strings divisible by 2 we check if the last char from right is a 0.

For binary strings divisible by 2 2 we check if the last char from right is a 00.

...

For binary strings divisible by 2 5 we check if the last char from right is a 00000

So, we need 6 states for counting the number of 0's on right, from 0 to 5.

 8 votes -- Arjun Suresh ( 124125 points)

8.74 Finite Automata: Find n(K) where K is the size of string that a DFA
accepts. top gateoverflow.in/368

Subject: Finite Automata


Topic: DFA

Q) Can anyone explain me how i can find the no of strings of length k words that is accepted by a given DFA.

Do post the resources which can be helpful to understand this concept.

theory-of-computation finite-automata

This should be specific to a given DFA.

 0 votes -- gatecse ( 9515 points)

8.75 Finite Automata: DFA to accept a binary number divisible by 2 top gateoverflow.in/10366

Sorry for the bad quality picture. Which of these is correct? (1 or 2)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1014 of 2244

finite-automata

Ist one is correct

binary no ,i.e, symbols are {0,1} [base =2]

divisible by 2 i.e states are 0,1 representing remainder on dividing 2.

[base x state + input symbol ] mod 2 → state

for example state is 1 and input symbol is 0 , that is(10) represent [1 x 2 + 0 ] = 2 and on dividing by 2 it gives
remainder 0

so[1 x 2 + 0 ] mod 2 = 0

similarly for state 0 transitions are

[ 0 x2 + 0] mod 2 → 0

[ 0 x2 + 1] mod 2 → 1

for state 1

[ 1 x2 + 0] mod 2 → 0

[ 1 x2 + 1] mod 2 → 1

resulting in following DFA

 3 votes -- Praveen Saini ( 34299 points)

8.75 Finite Automata: NFA for the language, L= (ab, ba)* would have how
many states? top gateoverflow.in/10056

theory-of-computation finite-automata


Selected Answer

NFA for (ab+ba)*

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1015 of 2244

Having 3 states

and DFA for same

have 4 states

 6 votes -- Praveen Saini ( 34299 points)

4 states.

 1 votes -- aayushranjan01 ( 325 points)

8.76 Flip Flop: number of states of the FSM required to top gateoverflow.in/28047

number of states of the FSM required to simulate behaviour of a computer with a memory capable of storing 'm' words ,
each of length 'n' bits is ?

finite-automata flip-flop

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1016 of 2244


Selected Answer

Total m words. Each of size n bit.

Total m*n bits .

Number of states in FSM are 2m*n


[ 1 bit need 1 flip-flop , represent 2 states, 0 or 1.]

 1 votes -- Digvijay Pandey ( 26245 points)

8.77 Grammar: Question on deciding type of language top gateoverflow.in/28760

Given answer: A
Please explain

theory-of-computation grammar


Selected Answer

D option is correct. L1 and L2 are DCFL and so are CSL also. (DCFL and CFL are not closed under intersection but CSL is).
So, their intersection is CSL- context sensitive. CSL being a subset of recursive, answer here is D.

Why option A is FALSE- because L is recursive (decidable).

 3 votes -- Arjun Suresh ( 124125 points)

8.78 Grammar: ugc net top gateoverflow.in/43901

grammar

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1017 of 2244


Selected Answer

A “handle” of a string is a substring that matches the RHS of a production and whose reduction to the non-terminal (on
the LHS of the production) represents one step along the reverse of a rightmost derivation toward reducing to the start
symbol.

Here production A->aSb reduced.

So option d is correct.

 1 votes -- Manojk ( 3365 points)

8.79 Grammar: Uniquely derivable strings from grammar top gateoverflow.in/28759

The given answer to the problem is 1 ('a'). But I think that strings 'a+a' & 'a*a' can also be derived from the grammar.
Please correct me if I am wrong.

theory-of-computation grammar

E-> E+E->a+E-> a+a

E->E+E-> E+a->a+a

So, not unique derivation for a+a

Similarly not unique derivation for a*a

Only unique derivation for 'a'

 1 votes -- srestha ( 11585 points)

8.80 Grammar: Recognising type of language top gateoverflow.in/7546

HI,

I would like someone to give clarification on how to identify a string is which grammar. I am not able to understand the
concept well. So if someone explains ii, it will be highly appreciated. Please give examples.

for eg: { a^n } is CFG or not.

Thank you.

grammar

1. If you can express the language as a regular expression then the language is Regular

eg: an , n ≥ 0 is a regular language.

2. If you can recognize the language with a stack machine (Push Down automata), then it is a context free language.

eg an bn , n ≥ 0 is a context free language.

3. If you can recognize the language with a Linear bound automaton (Turing machine with a finite tape), then its a context
sensitive language.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1018 of 2244

4. If you cannot construct any of the above , then it belong to Phase structured language.

Turing machine can be constructed for recognizing any recursively enumerable language.

 4 votes -- Gowthaman Arumugam ( 1079 points)

8.81 Identify Class Language: Which language is regular? top gateoverflow.in/37671

Which of the following grammars generate regular language?

a. S → aSa | bSb | a

b. S → aS | bS | aA | bA
A → bAc | ϵ

c. S → aA | ϵ
A → Sb

d. None of these

Why (A) is not regular? as {WCW^r | W,C belongs to (a,b)} is regular}

theory-of-computation identify-class-language made-easy


Selected Answer

if we look carefully at Grammars given, Languages corresponding to them are

a). L1 = {wawR ∣ w ∈ {a, b} ∗ }

b). L2 = {wbn cn ∣ w ∈ {a, b} + , n ≥ 0}

c). L3 = {an bn ∣ n ≥ 0}

None of these are regular.

 0 votes -- Praveen Saini ( 34299 points)

8.82 Identify Class Language: regular or context free ? top gateoverflow.in/36426

(a+b)^* a^n b^n n>=1

theory-of-computation identify-class-language

This is CFL , since u have to keep track of no of a's with no of b's , which can't be done by a finite automaton therefore u
need to design a PDA for it. Changing n >= 1 to n >= 0 can make it regular as then the given language will be reduced to
(a + b) ∗ .

 2 votes -- radha gogia ( 4369 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1019 of 2244

8.83 Identify Class Language: Regular/ Non Regular. Language is regular or


not? top gateoverflow.in/25504

Is the following two languages regular?

I. L = { w | the number of occurrences of ′ 01 ′ in w is equal to the number of occurrences of ′ 10 ′ }


II. Late(L) = {x ∈ Σ ∗ : for some a ∈ Σ, string ax ∈ L where L is regular}

(A) Only I (B) Only II (C) Both I & II (D) Neither I nor II

theory-of-computation identify-class-language


Selected Answer

I. is regular , all strings over {0,1} that start and ends with same symbol.

II. is also regular. we need to remove first symbol from stings accepted by L

Design DFA for L, Move with one transition from start state, and the states we reach, say some Q,mark them as new start
state, it seems we have more than one start states, then add a new state as start state and connect it with these Q with
null move.

Example

L = { all strings over {0,1} those start with 00 }, having regular expression 00(0+1)*

DFA for L

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1020 of 2244

on giving symbols { 0,1} at start state we reach to q1 and q3, add new start state and connect it with q1 and q3 with ∊
moves.

After removing Null moves (∊-moves) , we have new DFA for Late(L)

having language Late(L) = { all strings over {0,1} those starts with 0 } having regular expression 0(0+1)*

 3 votes -- Praveen Saini ( 34299 points)

8.84 Identify Class Language: plz answer top gateoverflow.in/9718

Let L1 and L2 be languages over Σ and assume that L1 ∩ L2 = ϕ. if L1 is finite language and L1 ∪ L2 is regular then L2 is ____ ?

a. Regular language and finite

b. Regular language and infinite

c. Need not be regular

d. None of these

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1021 of 2244

identify-class-language


Selected Answer

Let L2 = compl(L1). Now, L1 intersect L1 is empty and L1 union L2 is ∑* and hence regular. And L2 here is regular and
infinite - so A option is eliminated.

Now, we have L1 union L2 as regular and hence we have a DFA (say D) for it. We also have DFA for L1 (say D1). Now, we
can make a DFA for L2 (say D2) by doing D intersect compl(D1), as complement of a regular language is regular and
regular set is closed under intersect. So, L2 must be regular.

Now, consider L2 = {}. Now, L1 intersect L2 is empty and L1 union L2 is L1 which is regular. But here, L2 is regular and
finite.

Hence option D- none of these.

 5 votes -- Arjun Suresh ( 124125 points)

8.85 Identify Class Language: type of language top gateoverflow.in/38125

let L=(a,b,c)* | the length of x is square then L is -

a)Regular

b)recursive but not context free

c)context free but not regular

d)none of these.

identify-class-language

Yes It will be Recursive and can't be CFL bcz if the length is in square i.e power is non-linear and whenever the length is
non linear like factorial, underoot etc then it can't be CFL

 0 votes -- Akshay Bhatia ( 81 points)

8.86 Identify Class Language: Dcfl or not top gateoverflow.in/37698

L={w0w ∣ w ∈ (0+a+b)*}

identify-class-language

yes it is definetly CSL

 0 votes -- Akshay Bhatia ( 81 points)

8.87 Identify Class Language: Identify the class of the language top gateoverflow.in/17460

Identify the class of the language L = {anbm ∣ n ≤ m ≤ 2n }.


a) CFL but not DCFL
b) DCFL but not regular
c) not CFL

theory-of-computation identify-class-language


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1022 of 2244

The condition to be checked here is no. of b's following a's should be more than the no. of a's but less than twice the no.
of b's. This cannot be done using a DPDA. But for each a we can non-deterministically guess that it can generate either
one b or two bs and this way we can make a PDA. The context-free grammar would be

S → aSb ∣ aSbb ∣ ϵ

 2 votes -- Arjun Suresh ( 124125 points)

8.88 Identify Class Language: Automata1.1 top gateoverflow.in/37498

Let L1 and L2 be languages over Σ and assume that L1 ∩ L2 = ϕ. if L1 is finite language and L1 ∪ L2 is regular then L2 is ____ ?

a. Regular language and finite

b. Regular language and infinite

c. Need not be regular

d. None of these.

identify-class-language

As L1 is regular and L1⋃L2 is regular then L2 must be regular as RL are closed under Union. But we can't say whether L2
is finite or infinite bcz it may be or may not be finite... Correct me if I am wrong

 1 votes -- Akshay Bhatia ( 81 points)

8.89 Identify Class Language: Identify the class of the language top gateoverflow.in/20798

L= {w ∈ (a + b) ∗ ∣ w has at least as many occurrences of (bba)'s as (abb)'s }


Identify the class of the language.

theory-of-computation identify-class-language


Selected Answer

let us consider the string abbabbabbabb


In this string, number of occurrences of abb are 4 but when we see here bba is also occurred and the number of
occurrence of bba is 3.
Note that if i add a 'a' at the last of string we can have same number of occurrences of abb and bba so this string
is accepted. We can say if the string is ending with abb so by appending a 'a' we can make bba also.
Now string2: bbabbabbabba in this number of occurrences of bba is 4 and abb is 3 which already satisfy the
condition.
So we can observe here that whenever bba will be there string will be accepted
So with this idea we can build an automata for this.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1023 of 2244

Hence, it is regular.

 2 votes -- Leen Sharma ( 2935 points)

Regular. The key observation here is that successive occurrences of abb and of bba in any string over {a, b} must alternate
along the string. To see this, one can show that in any string w, between any two occurrences of abb there is an
occurrence of bba and vice versa. Consider an arbitrary substring of w delimited by two occurrences of abb. This string has
the form abbuabb, where u is a possibly empty string. If u contains no a symbols, then the string bbua ends in bba.
Otherwise, suppose that the first a in u occurs at position i; then the string bbu1 . . . ui ends in bba. For the other direction,
again consider an arbitrary substring of w delimited by two occurrences of bba. Then the reversal wR of w has the form
abbuabb for some string u. By the above argument, wR must contain bba as a substring, so w itself contains an occurrence
of abb. For a string w, let D(w) denote the difference between the number of occurrences of abb and of bba in w. By the
above argument, for anyw, ∣ D(w) ∣≤ 1. At this point it is not difficult to see what a DFA for our language should look like.
The states should keep track of the last two symbols seen, as well as the sign of the quantity D(w). (See diagram; the
start state is qst, and the accept states are marked in thicker lines.)

 1 votes -- admin ( 1411 points)

8.90 Identify Class Language: Choose correct option top gateoverflow.in/11363

Choose the correct statement

(a) There exists a cfg generating the language {ww ∣ w ∈ (a + b) + }


2
(b) There exists a cfg generating the language L = {an ∣ n ≥ 1}

(c) There exists a cfg generating the language {an bn cn ∣ n ≥ 1}

(d) There exists a cfg generating the complement of the language {ww ∣ w ∈ (a + b) + }

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1024 of 2244

The answer given is (d) .

But , in my opinion answer should be (a) . Am I wrong ? Please correct me.

CFLs are not closed under complement. So , how can the answer be (d) ?

theory-of-computation identify-class-language


Selected Answer

A. is clearly CSL. // CFL can do string matching in reverse order like WW r but not as WW
B. Power is quadratic . So it cant simulated by PDA .. LBA needed..
C. Again CSL. two infinite comparison on same variable 'n' simultaneously.. PDA cant simulate.
D. Yes complement of WW IS CFL.. How complement of CSL will be CFL ??

LET A be CFL & its complement is B which is CSL.. now some one asking what is complement of CSL 'B' ?? Obviously
answer will be A which is CFL only..
CFG for complement of WW :
Every odd length string will be in complement of WW.

S(odd) ----> 0A | 1A | 0 | 1
A ----> OS(odd) | 1S(odd)

Now for even length string :

S(even) ----> BC | CB
B ----> DBD | 0
C ----> DCD | 1
D ----> 0 | 1

 5 votes -- Digvijay Pandey ( 26245 points)

8.91 Identify Class Language: TOC top gateoverflow.in/32761

Consider the complements of the languages

L1 = {ww ∣ w ∈ (a + b) } +

L2 = {a b c
n n n ∣n≥1 }
L3 = {a b a b ∣ i, j ≥ 10 }
i j i j

L4 = {a b ∣ i, j ∈ (a + b) }
i j +

Represented by the sets K1 , K2 , K3 & K4 respectively.

a. K1 , K2 , K3 & K4 are all CFLs.


b. K1 , K2 are CFLs & K3 , K4 are regular.
c. K1 , K3 are CFLs & K2 , K4 are regular.
d. K1 , K2 & K3 are not CFLs but K4 is regular.

theory-of-computation identify-class-language


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1025 of 2244

K1 , that is complement of L1 is CFL.

K2 , complement of L2 is CFL.

As it includes

1. {aibjck, i ≠ j or j ≠ k or k ≠ i}

2. All strings included cb or ca or ba.

3. a ∗ ,b ∗ , c ∗ , may be something more.

K3 , complement of L3 , is also cfl

As It includes

1. {aibjakbl, i ≠ k, or j ≠ l}

2. All string having length < 40.

3. All odd length strings.

4. All strings start with b, all string start with a and end with a , a ∗ b ∗ ,b ∗ a ∗ may be something more.

K4 , complement of L4 is regular, so CFL too.

It seems typo there as i, j ∈ (a + b) + should be something as i, j ≥ 0 or i, j ≥ 1 or something similar, but any ways L4 is
regular, so its complement too.

 3 votes -- Praveen Saini ( 34299 points)

8.92 Identify Class Language: Regular/ Non Regular . Why is L2 not regular
? top gateoverflow.in/30000

L1 = {a mbn | m+n = Even} L2 = {a mbn | m-n = 4}

(a) L1 is Regular, L2 is Not Regular

(b) Both are Regular

(c) Both are Non- Regular

(d) L2 is Regular, L1 is Not Regular

theory-of-computation identify-class-language


Selected Answer

L1 is regular, having regular expression (aa) ∗ (bb) ∗ + a(aa) ∗ b(bb) ∗ , either both m and n are even or both are odd then m + n will

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1026 of 2244

be even

in case of L2

L2 = {ambn | m − n = 4}

= {ambn | m = n + 4}

= {an +4 bn }

= {aaaaan bn }

L2 is CFL.

 12 votes -- Praveen Saini ( 34299 points)

8.93 Identify Class Language: how to identify whether a language is Context


free or Context sensitive top gateoverflow.in/30669

Which of the following language is CFL?

a. {ambn cn | m! = n}

b. {ambn ck | if (m = n) then (n! = k)}

c. {ambn ck | m > n or n < k}

d. None of these

theory-of-computation identify-class-language


Selected Answer

for cfl if there is one comparison at one time then its a CFL.

a) ambn cn | m!=n
here two comparison first b= c and a !=b & c so not a cfl

b) ambn ck | if(m=n) then n!=k


here first we have to compare a=b if it is yes then n!=k
we can't do it using one stack since we have already popped a using b to match m=n so we cant match the n to k.

c) ambn ck | m>n or n<k


here at one time only one compare if m>n then we dont have to check for n<K or vice versa and it can be done by NPDA.

so option c

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1027 of 2244

 3 votes -- Umang Raman ( 10379 points)

8.94 Identify Class Language: please give proper explanation top gateoverflow.in/30762

To prove that language L is not regular, we may show that

1. L is the intersection of two regular languages.

2. L is the intersection of two non-regular languages.

3. the union of L with some regular language is regular.

4. the union of L with some regular language is non-regular.

5. the complement of L is regular.

theory-of-computation identify-class-language


Selected Answer

Regular language is closed under union. So, if we take union of 2 regular languages, we must get a regular language.
Thus, 4 is the correct answer here.

1 is false because intersection of 2 regular languages is always regular.


n n
2 is false because intersection of 2 non-regular languages can be regular - e.g., {02 ∣ n > 0} ∩ {03 ∣ n > 0} = ∅ which is
regular.

3 also won't prove L non-regular as regular union regular is regular (non-regular union regular can also be regular).

5 is false as regular complement is regular.

 2 votes -- Arjun Suresh ( 124125 points)

8.95 Identify Class Language: c is which type of language and why top gateoverflow.in/44238

The ‘C’ language is


(A) Context free language
(B) Context sensitive language
(C) Regular language
(D) None of the above

identify-class-language


Selected Answer

C is almost Context Free language

Source:http://poj.org/problem?id=3220

But C has some additional feature eg. * is used as multiplication and pointer ,& is used with address and bitwise operator
etc

which can,t be handled by CFG. For handling such kind of information a Context Sensitive Grammar is required.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1028 of 2244

SO Option B is Correct.

PS: C language is not context free means using just a PDA we cannot determine if an input C program is valid (obeying C
syntax) or not.

 3 votes -- Manojk ( 3365 points)

8.96 Identify Class Language: If L2 is DCFL ,how to draw its DPDA? top gateoverflow.in/30897

L1 = {(xy)m(yz)m , m ≥ 1}

L2 = {ambn ck | m > n or m < n}

Which of the following is True?

(a) L1 is CFL, L2 are DCFL (b) L1 is DCFL, L2 is CFL

(c) Both L1 , L2 are CFLs (d) Both L1 , L2 are DCFLS

theory-of-computation identify-class-language


Selected Answer

Yes L2 = {ambn ck | m > n or m < n} is DCFL

having DPDA

L1 = {(xy)m(yz)m , m ≥ 1} is also DCFL

having DPDA

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1029 of 2244

 3 votes -- Praveen Saini ( 34299 points)

8.97 Identify Class Language: which of these are regular sets ? top gateoverflow.in/35915

L1 = {a bp q ∣ p + q ≥ 106 }
L2 = {a bm n ∣ m − n ≥ 106 }
In both of these there is a comparison between no of a's and b's so I guess both of them should be non-regular sets but why

only L2 is non-regular ?

regular-set identify-class-language


Selected Answer

First of all here , We try to simplify it

suppose we have some another number 4 instead of 106 , It is just to understand what is the meaning of conditions in L1
and L2 .

So here, we have new languages

LA = {ap bq ∣ p + q ≥ 4}

Here it means each string must have length ≥ 4 and it must be in "no of a ′ s followed by no of b ′ s"

This is regular, having regular expression , a4 a ∗ b ∗ + a3 a ∗ bb ∗ + a2 a ∗ bbb ∗ + aa ∗ bbbb ∗ + a ∗ b4 b ∗

So What we need to do , need to ensure length of strings must be at least 4.(and I hope, it can be easily done by FA.)

Similarly, in L1 , we need to make sure length of strings is ≥ 106 , and is regular.

LB = {ambn ∣ m − n ≥ 4}

= {a4 aibj ∣ i ≥ j} is CFL

No of a ′ s are atleast 4 more than No of b ′ s.

We need stack for it

Push a ′ s into stack , on reading b ′ s , pop a ′ s. At the end of b ′ s, check there are at least 4a ′ s left on stack (as, pop these a's
one by one with state change with ϵ )

Similarly, in L2 , we need to check No of a ′ s are atleast 106 more than No of b ′ s , we need stack for it, So it is non-
regular.

 0 votes -- Praveen Saini ( 34299 points)

L1:

It's regular because only thing we have to satisfy here is length of string.we are not required to count occurrences of a&b.

A finite automaton is possible to construct whose final state will be there only on/after 10^6 length strings have already
been processed by dfa.

L2:

In language 2 there is comparison involved ,the difference between the occurrences of a and occurrences of b should be
atleast 10^6.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1030 of 2244

There are infinite strings composing of alphabet a & b whose differences would yield 10^6. So here we can't draw finite
automaton.

 5 votes -- Ankesh Gautam ( 665 points)

8.98 Identify Class Language: Class of language top gateoverflow.in/33095

Identify the class of this language -

L = { w 1w2 | w1 != w2 & | w1| = |w2|}

A) Regular

B) CFL

C) CSL

D) Rec

theory-of-computation identify-class-language


Selected Answer

Language is CFL

string in first half is distinct from string in second half.

S → XY | YX

X → ZXZ | 0

Y → ZYZ | 1

Z → 0|1

 1 votes -- Praveen Saini ( 34299 points)

8.99 Identify Class Language: what is L3 top gateoverflow.in/38789

Q). Given a regular set L1 & a language L2 we form

L3 = L1 ∪ L2 or L3 = L1 ∩ L2

Which of the following is true.

(A).The emptiness problem of L3 is decidable

(B). It is decidable is L3 is empty, finite or infinite

(C). L3 is necessary regular

(D). It is undecidable if L3 is a r.e set

identify-class-language

If L1 = ϕ, L3 = L1 ∪ L2 = L2. Now, if L2 is r.e. but not recursive, options A, B and C are false. Not sure of option D.

 0 votes -- Arjun Suresh ( 124125 points)

8.100 Identify Class Language: Identify the class of L top gateoverflow.in/44053

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1031 of 2244

Consider

L1 = {a b c d
n n m m ∣ m, n ≥ 1 }
L2 = {a bn n ∣n≥1 }
L3 = {(a + b) }∗

L1 - L3 is

(A) Regular (B) CFL but not regular (C) CSL but not CFL (D) None of these

theory-of-computation identify-class-language


Selected Answer

CFL

L1 − L3 = L1 , hence CFL
Proof,
L1 − L3 = {abcd, aabbcd, aaabbbccdd, …} − {ϵ, a, b, ab, aab, …}
= {abcd, aabbcd, aaabbbccdd, …}
= L1

 5 votes -- Arjun Suresh ( 124125 points)

8.101 Identify Class Language: Regular/Non-regular Language top gateoverflow.in/29608

Given a set A ⊆ {0, 1} ∗ , let

A ′ = {xy | x1y ∈ A}. That is, A ′ consistes of all the strings obtained from a string in A by deleting in A by

deleting exactly one 1. if A is regular, then A ′ is

(A) Regular

(B) Context free but not regular

(C) Recursive but not context free

(D) None of the above.

identify-class-language regular-set


Selected Answer

A is regular

Design a DFA M1 for language A.

Design a DFA M2 for (0 + 1) ∗ 1(0 + 1) ∗

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1032 of 2244

Do the Intersection, using M1 × M2

Now,We will have DFA M that accepts all strings x1y ∈ A

There will be at least one transition in M such as q × 1 → q ′ ,where q ≠ q ′ ,while moving from start state to final state, and
not in closure (not is closed loop, x1y guaranteed for such transition), replace 1 by ϵ in that one transition as q × ϵ → q ′
so , after converting ϵ − NFA to DFA, that will be DFA of A ′

A ′ will be Regular

 4 votes -- Praveen Saini ( 34299 points)

8.102 Identify Class Language: Regular or not ? top gateoverflow.in/3175

{ wxw | w belongs to {0,1}* , x belongs to {0,1} + }

theory-of-computation regular-set identify-class-language


Selected Answer

Lets see the strings in L


= { 0, 1, 00, 01, 10, 11, 000, ..... } (When w is ϵ, wxw generates all these strings and hence we don't need to consider
any other case for w)
= Σ* - {ϵ}

Hence, regular.

More examples: http://gatecse.in/wiki/Identify_the_class_of_the_language

 5 votes -- Arjun Suresh ( 124125 points)

8.103 Inherently Ambiguous: Inherently ambiguous grammar top gateoverflow.in/10736

Q- Which one of following languages is inherently ambiguous?

(A) The set of all strings of the form an bn , n > 0 { }


{
(B) an bn cmdm, n, m > 0 }
{
(C) an bn cmdm, n, m > 0 } ∪ {a b c d , n, m > 0 }
n m m n

(D) Both (B) and (C)

Plz explain..

..........Is there any criteria on the basis of which we could identify inherently ambiguous grammar

theory-of-computation inherently-ambiguous

Answer is C

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1033 of 2244

Yes, there is some criteria to check inherent ambiguity

First of all , Inherent ambiguity term is used for language, not for grammar.

A language for which every grammar (you can design ) is ambiguous.

There may be many grammar for one language

say L is an , n > 0 mean a + , L = {a, aa, aaa, aaaa, . . }

There is a CFG S → aS | Sa | a , which is ambiguous as we can derive one word say , aa, using different ways and having
different tree also. This CFG is ambiguous but language is not inherent ambiguous.

because we have a CFG S → aS | a for same language that is unambiguous.

So you can say, for a language for which no unambiguous grammar is possible is inherent ambiguous
language

As in option C , language is two different language for which CFG cannot be designed without using

S → S1 | S2

where S1 → XY

X → aXb | ab

Y → cYd | cd

and S2 → aSd | aZd

Z → bZc | bc

This is only and only way to design CFG for Language.

and This language is ambiguous also

you can derive word abcd using S → S1 and also Using S → S2

So Language is Inherent Ambiguous .

[other words you can check aabbccdd or aaabbbcccddd ..i,e common in both parts of language]

 3 votes -- Praveen Saini ( 34299 points)

8.104 Ldentify Language: Identify language top gateoverflow.in/35419

Explanation is given as S1, S2, S3 dont satisfy prefix property. But, why cant they be accepted by dfa (where we dont check
prefix property satisfaction). If pda was given then they would have been right, I guess.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1034 of 2244

identify-class-language dfa theory-of-computation ldentify-language


Selected Answer

I do not know what is DFA with empty stack. So, assuming PDA with empty stack.

S1 and S2 are finite languages and hence regular and hence CFL. S3 and S4 are CFLs. PDA with empty stack can accept
the whole CFL without any exception and the language accepted by this and the PDA with acceptance by final state is one
and the same. So, the answer should be 4 as only S5 is not a CFL.

Now, consider PDA as DPDA. Now, the language accepted by a DPDA with empty stack is a proper subset of the language
accepted by a DPDA with final state. This set (accepted by DPDA with empty stack) must obey the prefix property - if w is
in L, no prefix of w must be in L, and is exactly the same as the language generated by a LR(0) grammar.

From the given sets the first 4 do not obey prefix property:

1. a prefix of ab
2. b prefix of ba
3. aab prefix of aabbbb (not DCFL also)
4. a prefix of aa (not DCFL also)

The last one is not even a CFL. So, none of these languages can be accepted by a DPDA with empty stack. A DPDA with
final state can accept the first 2 sets but not the other two.

 0 votes -- Arjun Suresh ( 124125 points)

8.105 Ldentify Language: Language and its compliment top gateoverflow.in/33925

Given $(L')^* = (L^*)' where ' is complement operation.

L is ?

ϕ, {ϵ} and Σ ∗

{ϵ} and Σ ∗

ϕ and {ϵ}

L is not any of ϕ, {ϵ} and Σ ∗

Please someone explain the meaning of ∅ and comp(∅) also. This question got me confused over the meaning of ∈ also.

ldentify-language finite-automata regular-expressions


Selected Answer

Let L = ϕ.

Then L ′ = Σ ∗ , (L ′ ) ∗ = (Σ ∗ ) ∗ = Σ ∗ , L ∗ = ϵ, (L ∗ ) ′ = (ϵ) ′ = Σ +

Let L = ϵ.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1035 of 2244

Then L ′ = Σ + , (L ′ ) ∗ = (Σ + ) ∗ = Σ ∗ , L ∗ = ϵ, (L ∗ ) ′ = (ϵ) ′ = Σ +

Let L = Σ ∗

Then L ′ = ϕ, (L ′ ) ∗ = (ϕ) ∗ = ϵ, L ∗ = Σ ∗ , (L ∗ ) ′ = (Σ ∗ ) ′ = ϕ

Option D must be correct.

 5 votes -- Monanshi Jain ( 5827 points)

8.106 Ldentify Language: Identify language generated by CFG top gateoverflow.in/20590

Consider the following grammar,

S → aSa | bSb | A
A → aBb
B → aB | bB | ϵ

Identify the language generated by above CFG

a. L = {ww | w ∈ (a + b) }
R ∗

b. L = {xwabbw | w, x ∈ (a + b) }
R ∗

c. L = {waxbw | w, x ∈ (a + b) }
R ∗

d. None of these

theory-of-computation ldentify-language

Look at CFG

S → aSa | bSb this is used to generate w on left and wR on right


as S ⇒ aSa ⇒ abSba ⇒ abaSaba ⇒ so on till putting A at center

So S ⇒ wAwR or it could be simple S → A [as w can be ϵ also, as w ∈ (a + b) ∗ ]

now putting A → aBb

S ⇒ waBbwR

now B → aB | bB | ϵ mean we can get (a + b) ∗ from B as we can get {^,a,b,aa,ab,ba,bb,....} [try]

we can say B used for generating some sting x where x could be anything i,e x ∈ (a + b) ∗

so S ⇒ waxbwR where w, x ∈ (a + b) ∗

 2 votes -- Praveen Saini ( 34299 points)

8.107 Made: Dfa top gateoverflow.in/43445

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1036 of 2244

made eady test

b should be ans

{toc,os}, {cd}, {prog} {ds} {algo} {co} {cn} {swt}

 1 votes -- Manojk ( 3365 points)

8.108 Madeeasy: Identify languages as partially decidable or decidable? top


gateoverflow.in/36743
Consider the following languages

A={<M>|M is a TM and |L(M)| >= 3}

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1037 of 2244

B={<M>|M is a TM that accepts some string}

Which of the following is correct?

(a.) A is decidable, B is partially decidable

(b.) A is partially decidable, B is decidable

(c.) Both A and B are decidable

(d.) Both A and B are partially decidable

Answer given : (d.)

But how?

theory-of-computation decidability made-easy madeeasy made-easy_test-series


Selected Answer

A. Language of Turing machine contains at least 3 strings.

B. Language of Turing machine contains at least 1 string.

Both are non-trivial property of r.e. languages and hence undecidable as per Rice's theorem. Now, for semi decidability
(answering for yes cases) of A, we can feed the Turing machine strings from L one by one (using dovetailing technique to
avoid any infinite loop for some string) and as long as the language is sure to contain at least 3 strings, it will eventually
accept 3 distinct strings and we can stop. (If there are no such 3 strings, this technique goes to infinite loop and that is
why we cannot completely decide this). For B also do the same technique using replacing 3 with 1.

So, D choice.

 3 votes -- Arjun Suresh ( 124125 points)

8.109 Madeeasy Testseries: madeeasy test series pracice test 5 toc q-13 top
gateoverflow.in/37096
Let L = {(aP)*⎜P is a prime number} and Σ={a}. The minimum number of states in NFA that accepts the
language L are ________.

i don't think it is even a regular language. then how can NFA be generated?

theory-of-computation madeeasy-testseries


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1038 of 2244

Ans is 3 states

 2 votes -- Sayantan Ganguly ( 5061 points)

8.110 Madeeasy Testseries: TOC CFL Difference top gateoverflow.in/38568

Let L1 = {an bmcn ∣ m, n ≥ 0} and L2 = {an cn ∣ n ≥ 0}. Both L1 and L2 are context free languages.

If L = L1 – L2 then L is ________

Finite language
Regular language
DCFL
Not DCFL

theory-of-computation madeeasy-testseries


Selected Answer

L = L1 − L2 = {an bmcn ∣ n ≥ 0, m > 0}.

Hence DCFL.

 4 votes -- Arjun Suresh ( 124125 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1039 of 2244

8.111 Madeeasy Testseries: madeeasy practice test 5 TOC q-20 top gateoverflow.in/37105

Assume R 1, R 2 and R 3 are three regular expressions.


Given, R1+R2R3 = (R1+R2) (R1+R3) for any R2 and R 3.
Which of the following could be the correct condition which always satisfies the above equation.
(i) R1 = R 2 (ii) R 1 = R 3
(iii) R1 = φ

given answer is all three are correct.

but i am not sure about (iii)

how to answer such kind of questions?

theory-of-computation madeeasy-testseries

8.112 Minimal State Automata: Number of final state require to accept Φ in


minimal finite automata. top gateoverflow.in/38244

Number of final state require to accept Φ in minimal finite automata.


a) 1
b) 2
c) 3
d) None of the mentioned

theory-of-computation minimal-state-automata


Selected Answer

Number of finfinal state(s) require to accept Φ in minimal finite automata is ZERO.


Number of state(s) require to accept Φ in finite automata is ONE.

 1 votes -- Digvijay Pandey ( 26245 points)

8.113 Minimal State Automata: the possible no of dfa with three states top
gateoverflow.in/11767

The possible no of dfa with three states X,Y and Z, where X being always initial state for the DFA over the alphabet
{0,1}

a)5830

b)5831

c)5832

d)5932

correct answer is option C,but what is the systematic way to get it??

theory-of-computation finite-automata minimal-state-automata

N * N^(N*M)* 2^N (N is number of states , M is number of alphabet )

the first N is for no. of way to select initial state . Here N will be 1 because they told us X is only initial state .

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1040 of 2244

N^(N*M) is for no. of transition functions from a set of N*M elements to a set of N elements. .

2^N No. of final state we can choose .

so , 1 * 3^(3*2)* 2^3 =5832

 7 votes -- Pranay Datta ( 6113 points)

No. of possibilities for start state = 1 as it is fixed here.

No. of possibilities for final state = 2 3 = 8 as any subset of the set of states can be the final state.

No. of possible transition functions = Number of possible functions from a set of 6 elements (Q×Σ) to a set of 3 elements
(Q)

=36 = 729

So, number of possible DFA's= 729 * 8 = 5832

 4 votes -- Aditya Gaurav ( 1831 points)

8.114 Minimal State Automata: dfa min states top gateoverflow.in/37795

find min no of states in dfa that accepts string begining or ending with 00 or 11

theory-of-computation minimal-state-automata


Selected Answer

DFA M1 over {0, 1}, that begins with 00 or 11 having regular expression (00 + 11)(0 + 1) ∗

DFA M2 over {0, 1} that ends with 00 or 11 having regular expression (0 + 1) ∗ (00 + 11)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1041 of 2244

DFA M using cross product of M1 × M2 having start state as { x0 , y0 } and mark final state as any state contain x3 or y3 ( and
do minimization)

 2 votes -- Praveen Saini ( 34299 points)

8.115 Minimal State Automata: find minimal dfa for L top gateoverflow.in/1105

L = {an b: n ≥ 0} ∪ {bn a: n ≥ 1}

theory-of-computation minimal-state-automata


Selected Answer

6 states are required.

 3 votes -- gatecse ( 9515 points)

8.116 Minimal State Automata: TOC: DFA Minimization top gateoverflow.in/37468

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1042 of 2244

Clear Image URL: http://postimg.org/image/ljcst3k0t/

minimal-state-automata theory-of-computation

8.117 Minimal State Automata: Finding minimum states in FA. top gateoverflow.in/38084

If it is asked for minimum states required in FA for some language, we can have both NFA and DFA, and NFA has lesser
number of states but many books write that consider DFA as default. What to take into consideration in such case?NFA or
DFA?

theory-of-computation minimal-state-automata finite-automata

As per previous year solution of questions based on Minimal FA they always considers DFA if nothing is specified.

 0 votes -- Akshay Bhatia ( 81 points)

8.118 Minimal State Automata: What is the number of states in the minimal
DFA with input symbols {0,1,2} where 2nd last symbol is 1? top gateoverflow.in/7373

What is the number of states in the minimal DFA with input symbols {0,1,2} where 2nd last symbol is 1?

A. 8

B. 9

C. 6

D. None

theory-of-computation minimal-state-automata


Selected Answer

Second last symbol is 1 over {0,1, 2 }

regular expression = (0+1+2)*1(0+1+2). Anything Second last Last

For this regular expression NFA is

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1043 of 2244

Convert NFA to DFA

 6 votes -- Praveen Saini ( 34299 points)

B.
Whenever the question says the nth symbol from the right side is fixed and the input language has m symbols the answer
for minimal dfa is mn . So 3 2 = 9

 1 votes -- Chintan Jariwala ( 23 points)

D. None of these

 1 votes -- Anurag Semwal ( 4775 points)

8.119 Minimal State Automata: no of states in minimal dfa top gateoverflow.in/11768

no. of states in minimal DFA built for:

accepts all strings over the alphabet {0,1} interpreted as a binary number is congruent to zero modulo n has

a)n states

b)n-1 states

c)n+1 states

d)None of the above

basically, i didn't get what they are trying to say in this question?( correct answer is option A )

theory-of-computation minimal-state-automata finite-automata

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1044 of 2244


Selected Answer

States in Modulo n are {0,1,2,3,........ upto n-1}

Total number of states are n ..

 3 votes -- Digvijay Pandey ( 26245 points)

8.120 Minimal State Automata: Let Σ= {a}, assume language, L= {


a^(2012.K) / K> 0}, what is minimum number of states needed in a DFA to
recognize L top gateoverflow.in/15009

Let Σ= {a}, assume language, L= { a^(2012.K) / K> 0}, what is minimum number of states needed in a DFA to recognize
L

theory-of-computation minimal-state-automata


Selected Answer

States are 2013..

from S0 to S2012.. S2012 is final state, S0 is starting..

transition from S0--->S1--->......S2012 ---> S1..

 6 votes -- Digvijay Pandey ( 26245 points)

8.121 Minimal State Automata: draw DFA in 3 states top gateoverflow.in/11766

well, according to a question for matching minimal state dfa to regular expression,following match is given to be correct,but i
don't find that correct.can you guys please try to prove it's correctness or wrongness??

(a+b)*ab*ab* ---- can be drawn in 3 states (given correct)

but how???

theory-of-computation minimal-state-automata finite-automata


Selected Answer

It`s nothing but a language containing string atleast 2 a's .

anything a anything a anything = (a+b)*a(a+b)*a(a+b)*= (a+b)*ab*ab* = b*a(a+b)*ab* = b*ab*a(a+b)*


[ all are equivalents by converting NFA to DFA]
Draw FA for b*ab*a(a+b)* as it result in DFA and easy.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1045 of 2244

 5 votes -- Pranay Datta ( 6113 points)

8.122 Minimal State Automata: Non-deterministic Finite Machine top gateoverflow.in/17784

Let M be a Non-deterministic Finite Machine. Let G be the Regular Grammar obtained from M. Which is True?

(a) G will always be unambiguous

(b) G will always be ambiguous

(c) G may be ambiguous

(d) None of the above

finite-automata regular-expressions minimal-state-automata


Selected Answer

I think ans is C)

Regular language can be Ambiguous .

 0 votes -- Pranay Datta ( 6113 points)

8.123 Minimal State Automata: Please post the DFA for the language. gateoverflow.in/14284

top

What are the number of final states in minimal DFA, where Σ = {a, b}, if every string starts with "aa" and length of string is
not congruent to 0 mod 4?

A. 7
B. 6
C. 3
D. 5

minimal-state-automata


Selected Answer

Final states would be only those in which remainder is not 0 mod 4 i.e. remainder is either 1,2, or 3. So there will be 3

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1046 of 2244

final states.

Here is the DFA : Here number on a state shows length of string mod 4.

 4 votes -- Happy Mittal ( 9253 points)

8.124 Minimal State Automata: Toc DFA top gateoverflow.in/32032

no of states for accepting €?

minimal-state-automata


Selected Answer

For L = {ϵ}

In DFA, minimum no. of states required = 2

In NFA, minimum no. of states required = 1

 5 votes -- Praveen Saini ( 34299 points)

8.125 Minimal State Automata: TOC FLT Test Made Easy top gateoverflow.in/31554

Q.51

Consider the finite automaton is the following figure.

What is the number of state to accept same language by DFA for above NFA (need not minimum)?

7
9
11
16

I think here minimum state required is 8. So 9 is correct answer !

made-easy minimal-state-automata theory-of-computation

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1047 of 2244


Selected Answer

answer is 7

 5 votes -- Sandip Shaw ( 755 points)

8.126 Minimal State Automata: confusion in finding states in minimal DFA top
gateoverflow.in/37564
number of states in the dfa which accepts the binary strings whose decimal equivalent is divisible by 5 ?

since ∊ is not accepted as it doesn't have any decimal equivalent so


initial state cannot be accepting state so to accept 0 (zero) there should be some other state than the initial state .

so what will be the answer 5 or 6

minimal-state-automata theory-of-computation

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1048 of 2244

5 states required for it .

state 0: num mod 5=0 or you can say all the numbers divisible by 5 falls here this is the final state indeed

state 1: num mod 5=1 falls here

state 2: num mod 5=2 falls here

state 3: num mod 5=3 falls here

state 4: num mod 5=4 falls here

your query:0 is divisible by 5 so no need to take extra care of it... it falls in the state 0

 1 votes -- Bhagirathi Nayak ( 10239 points)

8.127 Minimal State Automata: Binary Number when interpreted as decimal


mod 12 top gateoverflow.in/25189

What are the Number of states in minimum DFA that accepts Binary strings when interpreted as decimal mod 12 give 0 as
remainder.Also give DFA.

minimal-state-automata theory-of-computation


Selected Answer

I m getting 5 states

0 1

-> q0 (F) q 0 q 1

q1 q2 q3

q2 q1 q2

q3 q4 q1

q4 q0 q1

 1 votes -- Himanshu Agarwal ( 8861 points)

8.128 Minimal State Automata: Minimum number of states in the DFA gateoverflow.in/35606

top

What is the minimum number of states in the DFA for accepting the strings (a + b) ∗ a(a + b)(a + b)

I draw the following DFA

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1049 of 2244

The minimum number of states is 4. The answer given is 8. How is it possible?

Please explain.

minimal-state-automata finite-automata theory-of-computation


Selected Answer

The given RE represents a language which contains strings which can start with anything but must end with a substring
which is all strings of length 3 starting with a.

Here is the NFA and the state transition table.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1050 of 2244

 4 votes -- chat28 ( 495 points)

8.129 Minimal State Automata: number of states required to construct dfa


accepting language L = (ab+aba)* top gateoverflow.in/26753

number of states required to construct dfa accepting languages L = (ab union aba)* alphabet = {a,b} is atleast??

my view:

for intersection of 2 reg langs we take cartesian product construct dfa then we mininise it ... for union of lang containing
same symbols like (111+11)*we can enumerate and produce least no.for required states but for above question like
(ab+aba)* what should i do to solve ?

minimal-state-automata theory-of-computation


Selected Answer

Instead of any confusion, it is better to design NFA for given regular expression and convert it to DFA.

[ note : any one can design DFA directly depending on practice/aptitude]

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1051 of 2244

 2 votes -- Praveen Saini ( 34299 points)

Can you make a NFA for it? Something like this:

If you can do that, you can simply convert it to DFA and minimize the DFA to get this:

And thus get the answer: minimal states = 5

 2 votes -- Pragy Agarwal ( 13675 points)

8.130 Minimal State Automata: minimal DFA top gateoverflow.in/11769

The minimal state DFA, accepting all strings over the alphabet {0,1} where the n th symbol in every string from the right end
is a 1, has

a) 2n states b) 2n-1 states c) 2 n+1 states d) None of the above

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1052 of 2244

theory-of-computation minimal-state-automata finite-automata

Answer is 2^n.

Check DFA construction on following question solved for N = 3.

http://gateoverflow.in/544/gate1991_17-b

 1 votes -- Akash ( 26315 points)

Answer should be 2^n states i.e. option A.

Generalized Regular Expression for such a DFA will be: (0 + 1)*1 concatenated with a string of (n – 1) 0’s

Steps involved in drawing the DFA.

1. Draw the corresponding NFA – It can be drawn easily. THE NFA WILL ALWAYS CONTAIN “n + 1” STATES. (Why n + 1
states always? ? : because you have to COUNT from 1 to N+1, & each state will remember a count).
NOTE – On drawing the NFA you will notice that on the whole NFA there is ONLY A SINGLE NON DETERMINISTIC
TRANSITION. That non deterministic transition will be from the start state, on input 1.
2. Change the NFA to the minimal DFA – Subset Construction can be used in this step, to convert the NFA into a
MINIMAL DFA (Subset Construction will give a minimal DFA for any value of n, you can check it by set partitioning
etc.) Since it is known that there is only one Non Deterministic Transition for any value of n, we can guarantee that if
the number of states in the NFA is x then number of states in the corresponding DFA HAVE TO BE 2^(x – 1).(Why ? ?
: refer to CAUTION)

Summarizing:

For any value of n,

The number of states in the NFA have to be n+1.

In this question, if the NFA contains n + 1 states then the minimal DFA will have 2^((n + 1) – 1) = 2^n states.

Moreover The number of final states in the DFA will be 2^(n – 1).

Example: for n = 3,

The number of states in the NFA = 3 + 1 = 4, (say A (Initial state), B, C, D (Final State)).

The only non deterministic transition in this NFA will be delta(A, 1) = {A, B}.

The number of states in the minimal DFA = 2^((3 + 1) – 1) = 2^3 = 8.

The number of final states in the minimal DFA = 2^(3 – 1) = 4.

States in the minimal DFA: {A}(start state), {A, B}, {A, C}, {A, B, C}, {A, D}, {A, B, D}, {A, C, D}, {A, B, C, D}.

Final States in the minimal DFA: {A, D}, {A, B, D}, {A, C, D}, {A, B, C, D}.

CAUTION: I have NO PROOFS for the argument & implication I made in Step 2 (i.e."Subset Construction will always lead
to a MINIMAL DFA in this case" & "Since it is known that there is only one Non Deterministic Transition for any value of n,
we can guarantee that if the number of states in the NFA is x then number of states in the corresponding DFA HAVE TO
BE 2^(x – 1)").I concluded them by drawing DFAs for n = 1, 2, 3 and analyzing them, but my intuition says they must be
true.

 1 votes -- Anurag Pandey ( 8183 points)

ans a)2^n

 1 votes -- Pooja ( 22773 points)

8.131 Minimal State Automata: Minimization of FA top gateoverflow.in/10739

We define a removable state as a state such that if we erase the state itself & the edges that come out of it, what results is a

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1053 of 2244

perfectly good looking FA.


(i) Give an example of an FA that contains a removable state.
(ii) Show that if we erase a removable state the language defined by the reduced FA is exactly the same as the language
defined by the old FA.

theory-of-computation minimal-state-automata

1. Unreachable state

L is all inputs start with a over {a,b} having regular expression a(a+b)*

in above DFA q2 is unreachable state as we start from start state to final state it can be removed

resulting DFA is

having same language and regular expression a(a+b)*

2. Equivalent states

L is a 2n n>=1 mean L = {aa,aaaa,aaaaaa.....}

if we look at DFA q1 and q3 are equivalent [ q1 x a -> q2 and q3 x a -> q2] so we can remove any of them say q3 , so
state and outgoing edge will be removed but what about incoming edge [q2 x a ->q3 ] so q2 x a-> q3 will be replaced by
q2 x a -> q1 [as q1 is equivalent of q3]

Resulting DFA will be

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1054 of 2244

having same languageL={aa,aaaa,aaaaaa,....}

 3 votes -- Praveen Saini ( 34299 points)

8.132 Minimal State Automata: states required for L* using Thompson's


Construction? top gateoverflow.in/17041

Q. If machine M is recognizing L with n states. Then M' recognizing L* construed using Thompson's Construction will have
___ states.

a) n

b) n+1

c) n+2

d) n-1

I know that we use Thompson's construction while converting from e-NFA. I thought if some RE is accepted with n states,
then (RE)* should also be acceptable by n states. But my book says the answer as b) n+1 states.

I am not even getting their explaination as "We need one extra state to eliminate the e-moves" . How can this be done? Can
somebody plz explain.

Thanks.

theory-of-computation minimal-state-automata finite-automata

8.133 Minimal State Automata: How to approach this type of question gateoverflow.in/30667

top

The number of states in DFA which accepts a language such that each block of 4 consecutive symbols of every string contain
at least two a ′ s for Σ = {a, b} is ___________. [if String length is less that 4 then it must be accepted]

minimal-state-automata theory-of-computation


Selected Answer

No of state for accepting length 0 input = 1

No of state for accepting length 1 input = 2

No of state for accepting length 2 input = 4

No of state for accepting length 3 input = 8

All inputs up to length 3 will be accepted.

No of states for accepting length 4 (or more) input in each block of 4, having 2 a ′ s = 4C2 = 6

No of states for accepting length 4 (or more) input in each block of 4, having 3 a ′ s = 4C3 = 4

No of states for accepting length 4 (or more) input in each block of 4, having 4 a ′ s = 4C4 = 1

No of states for rejecting length 4 (or more) input in any block of 4, having 1 a = 1 (dead state).

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1055 of 2244

Total No of states in DFA = 1 + 2 + 4 + 8 + 6 + 4 + 1 + 1 = 27 states

Rough DFA ( bcoz of complexity of it but correct) is given below, Name of state representing a block of 4.

state {aaba} × a → {abaa} , {aaba} × b → {abab} , {abba} × a → {bbaa}, {abba} × b → {dead state}, and so on

No of state for accepting length 0 input = 1 , that is {ϵ}

No of state for accepting length 1 input = 2 , that is {a}, {b}

No of state for accepting length 2 input = 4, that is {aa}, {ab}, {ba}, {bb}

No of state for accepting length 3 input = 8, that is {aaa}, {aab}, {aba}, {abb}, {baa}, {bab}, {bba}, {bbb}

All inputs up to length 3 will be accepted.

No of states for accepting length 4 (or more) input in each block of 4, having 2 a ′ s = 4C2 = 6, that is {aabb}, {abab}, {abba}, {baab}, {baba}, {bbaa}

No of states for accepting length 4 (or more) input in each block of 4, having 3 a ′ s = 4C3 = 4, that is {aaab}, {aaba}, {abaa}, {baaa}

No of states for accepting length 4 (or more) input in each block of 4, having 4 a ′ s = 4C4 = 1, that is {aaaa}

No of states for rejecting length 4 (or more) input in any block of 4, having 1 a = 1 , that is {dead state}

Total No of states in DFA = 1 + 2 + 4 + 8 + 6 + 4 + 1 + 1 = 27 states .

 5 votes -- Praveen Saini ( 34299 points)

8.134 Minimal State Automata: minimum no of states and final states gateoverflow.in/30731

top

I solved both of these qs in a traditional way,by drawing nfa and then convert them to dfa..by tthis process ans shoulbe 4
and 2..but both of them are wrong..pls check..

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1056 of 2244

theory-of-computation minimal-state-automata


Selected Answer

I. (0 + 1) ∗ 1, all strings ending with 1, need only 2 states

II. 0 + 1) ∗ 10(0 + 1) ∗ , all strings contain substring 10, need 3 states, and they are asking about final state, that is only 1.

[Note:
1. all strings ending with n length string or all string contain n length substring, will always n + 1 states in minimal DFA.
2. After conversion from NFA to DFA, there are maximum probability of minimization, always look after it.]

 3 votes -- Praveen Saini ( 34299 points)

8.135 Minimal State Automata: what is the minimum no of DFA states


required to recognise below language? top gateoverflow.in/26869

L={a^nk , k>0 and n is an integer constant }

In this question which constant should be changed , n or k while considering the DFA since then it can be either n+1 or k+1 ?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1057 of 2244

theory-of-computation minimal-state-automata


Selected Answer

for n=3 and k=1,2,3,4,.............

it a^3,a^6.........so

n+1 state

since n is constant and k is changing but logic is k>0

so n+1 required.

 6 votes -- Manojk ( 3365 points)

8.136 Minimal State Automata: dfa top gateoverflow.in/32098

Find minimal finitte automata for

L1:L1 contains set of strings starting with 1010 and length of string is divisible by 4.

L2:L2 contains set of strings starting woth 1010 and its equivalent decimal value divisible by 4

theory-of-computation minimal-state-automata


Selected Answer

For L2 the decimal equivalent of binary number is divisible by 4 only when last 2 digits of binary number will have
ATLEAST 2 zeros. qR is the reject state .

According to me this should be the minimal DFA .

 5 votes -- Riya Roy ( 4767 points)

8.137 Myhill Nerode: Equivalence classes of a Language top gateoverflow.in/15127

Find all the equivalence classes of Regular Language

011 (0+1)* 011

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1058 of 2244

regular-set myhill-nerode


Selected Answer

First of all we should specify which "equivalence relation". Since not specified, I assume based on Myhill-Nerode relation.

http://courses.cs.washington.edu/courses/cse322/05wi/handouts/MyhillNerode.pdf

Class
Strings
No.
1 ϵ
2 0
3 01
4 011
0110, 01100, 01110, ...- all strings starting with 011
5
and ending in 0
01101, 011001, 011011, ... -all strings starting with
6
011 and ending with 01
011011, 0110011, 0111011, ... -all strings starting
7
with 011 and ending with another 011.
8 All strings not starting with 011

Totally 8 equivalent classes- the last one for a dead set of strings (can never be in language after appending any string).
So, the min-DFA for L will have 8 states with one being a dead state.

 2 votes -- Arjun Suresh ( 124125 points)

8.138 Myhill Nerode: TOC -Number of Equivalence Classes top gateoverflow.in/29550

The number of equivalence classes which exist for the following regular expression R are ______.
R = (a + b) ∗ b(a + b + ϵ)

what is the meaning of equivalence classes here...

theory-of-computation equivalence-classes myhill-nerode


Selected Answer

No of equivalence classes as per Myhill Nerode equivalence relation = No of States in Minimal DFA

So Draw the NFA and convert into Minimal DFA.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1059 of 2244

Strings reaching at each state in Minimal DFA, are distinguish from strings reaching at other states, that is what equivalence class mean
here.

Other things about equivalence class is that, if x and y are two strings of same class( here reaching same state), and we append some
strings z to then i.e, xz and yz, that will also reach to same equivalence class (either same or any other). Minimal DFA serve our purpose.

if we analyse the regular expression, we can see

first state, all rejecting strings, doesn't belong to L or given regular expression.

second state, all strings ending with b or bb, means ending with b, and accepts, (a+b)*b(∊+b)

Third state, all strings ending with ba, and accepts,(a+b)*ba.

 4 votes -- Praveen Saini ( 34299 points)

8.139 Nfa: NFA to DFA Conversion top gateoverflow.in/16456

If NFA has n states, then its DFA can have______states in worst case.

theory-of-computation finite-automata nfa minimal-state-automata

2^N

Reason;

The next state of nfa coud be any subset of state .

no of subset of states=2^n(as we have 2 choices for each state either we can keep it or not in our subset )

 0 votes -- Saurav Kumar Gupta ( 1455 points)

8.140 Nfa: Consider 2 scenarios: C1: For DFA (ϕ, Ʃ, δ, qo, F), if F = ϕ, then L
= Ʃ* C2: For NFA (ϕ, Ʃ, δ, qo, F) top gateoverflow.in/15010

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1060 of 2244

Consider 2 scenarios:
C1: For DFA (ϕ, Ʃ, δ, qo, F),
if F = ϕ, then L = Ʃ*
C2: For NFA (ϕ, Ʃ, δ, qo, F),
if F = ϕ, then L = Ʃ*
Where F = Final states set
ϕ = Total states set
(a) Both are true (b) Both are False
(c) C1 is true, C2 is false (d) C1 is false, C2 is true

theory-of-computation nfa finite-automata


Selected Answer

C1 is true.

C2 is not True but that doesn't mean it always false. C2 sometimes true some time false.

"C2: For NFA (ϕ, Ʃ, δ, qo, F), if F = ϕ, then L = Ʃ* . Where F = Final states set, ϕ = Total states set" is neither always
TRUE nor always FALSE.

but even one case contradict then it considered as false. so answer is Option C.

 4 votes -- Digvijay Pandey ( 26245 points)

C1 is true and C2 is false.

 1 votes -- Vivek sharma ( 1177 points)

8.141 Nfa: Draw NFA. top gateoverflow.in/21212

1) Design an NFA with no more than 5 states for:

{ } {
L1 = ababn ∣ n ≥ 0 ∪ aban ∣ n ≥ 0 }

2) Design an NFA with 3 states for:

{ } {
L2 = an ∣ n ≥ 1 ∪ bmak ∣ m, k ≥ 0 }

3) Design an NFA with 4 states for:

{ } {
L3 = an ∣ n ≥ 0 ∪ bna ∣ n ≥ 1 }
theory-of-computation nfa


Selected Answer

The NFA's for the given languages :

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1061 of 2244

 2 votes -- Riya Roy ( 4767 points)

8.142 Nfa: NFA intersection top gateoverflow.in/36261

How do I construct the intersection of two NFAs? Do I need to follow the same cross product method like the DFAs? If so,
then how do I handle the epsilon transitions?

Please support your answer with an example

Thanks in advance!

theory-of-computation nfa finite-automata

You can use the cross-product construction on NFAs just as you would DFAs. The only changes are how you'd handle ε-transitions. Specifically, for
each state (q i, rj) in the cross-product automaton, add an ε-transition from that state to each pair of states (qk, rj) where there's an ε-transition in the
first machine from q i to qk and to each pair of states (qi, rk) where there's an ε-transition in the second machine from rj to rk.

Alternatively, you can always convert the NFAs into DFAs and then compute the cross product of those DFAs.

 1 votes -- Gabbar ( 469 points)

8.143 Nfa: ∈-NFA TO NFA top gateoverflow.in/35244

Construct an eqv. NFA for the given ∈-NFA

Is this eqv. Nfa correct??

Or this one

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1062 of 2244

Why is thr transition between q0 to q1 of 0,1 ?

theory-of-computation nfa finite-automata


Selected Answer

ϵ- closure (q0 ) = (q0 , q1 , q2 )

ϵ-closure(q1 ) = (q1 , q2 )

ϵ-closure(q2 ) = (q2 )

We can design DFA directly by taking ϵ- closure (q0 ) , i,e, (q0 , q1 , q2 ) as start state

Q\ Σ 0 1 2
->(q0 , q1 , q2 )∗ (q0 , q1 , q2 ) (q1 , q2 ) (q2 )
(q1 , q2 ) ∗ - (q1 , q2 ) (q2 )

(q2 ) ∗ - - (q2 )
- - - -

or NFA with q0 as start state and having states q0 , q1 and q2 where q2 is final state

Q\ Σ 0 1 2
->q0 q0 , q1 , q2 q1 , q2 q2
q1 - q1 , q2 q2
q2∗ - - q2

And from NFA we can convert to DFA also

 1 votes -- Praveen Saini ( 34299 points)

8.144 Non Regular: If L1 is Regular, and L1UL2 is regular, then L2 is? gateoverflow.in/38228

top

Consider L1, L2 ⊆ Ʃ* such that L1 and L1 ∪ L2 are regular.


(a) L2 is definitely regular

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1063 of 2244

(b) L2 may not be regular

(c) L2 is context free

(d) None of above

Is it option B or C? How?

theory-of-computation identify-class-language regular-language non-regular context-free


Selected Answer

B.

let L1=(a+b)*

L1 contains all posible strings over A and B.

and L2= any language.

L1 union L2 =L1 =regular

 3 votes -- viv696 ( 1431 points)

8.145 Non Regular: madeeasy test series pracice test 5 toc q-19 top gateoverflow.in/37098

Which of the following is a non-regular language?

L = {wxwy | x,y,w∈(a+b)+}
L = {xwyw | x,y,w∈(a+b)+}
L = {wxyw | x,y,w∈(a+b) +}
All of these

theory-of-computation madeeasy-testseries non-regular


Selected Answer

http://gatecse.in/wiki/Identify_the_class_of_the_language#Some Twisted Examples

wxyw is csl

 2 votes -- Sayantan Ganguly ( 5061 points)

8.146 Normal Pda: How to draw NPDA for language L = { a^i b^j c^m | m
>= min( i,j) } top gateoverflow.in/3903

L1 = { a^i b^j c^m | m ≥ min(i,j) }

L2 = { a^i b^j c^m | m ≥ max(i,j) }

Which language is CFL ?

ANS : L1 is CFL but L2 is NOT.

My understanding :

For Language L1 :

( Here I am interested in checking Whether language is DCFL or not , also. )

Checking DCFL or not :

By looking at language , it is not possible to construct PDA as it contains 2 conditions ( i > j or i < j And m ≥ min (i,j) )

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1064 of 2244

But there is a way of checking language is DCFL or not. ( By Prefix Property )

No Proper Prefix ⇢ Prefix property ⇢ DCFL

But there is No Proper Prefix getting for this language , So, Prefix property , and so L1 is DCFL ( but there is no DPDA for
L1 as per my 1st conclusion ( i.e. 2 conditions -> No PDA )

It means somewhere I am wrong. Please correct me.

Checking CFL or not :

We will have to check whether it is accepted by NPDA or not.

I dont know correct way to construct NPDA but I tried in following way.
1) At some point PDA will assume that i < j or i > j
condition 1st : i < j
We are interested in min , so consider only i,≥ means accept "a" and skip all "b" and for each "c" , pop each "a"
Condition 2nd: i > j
We are interested in min , so consider only j means skip all "a" and accept "b" and for each "c" , pop each "b" So it is CFL.
Please correct me if it is wrong.
If above NPDA is right , then we can construct NPDA for L2 also.
But Answer part saying L2 is not CFL.

So above NPDA is right or wrong ??

theory-of-computation finite-automata pda normal-pda


Selected Answer

Prefix property is not obeyed by all DCFLs. It is obeyed only by those languages accepted by a deterministic PDA which
accepts by empty stack- if a prefix of the string is in L, stack should have been empty before and deterministic means, this
cannot happen.

Now, a language obeys prefix property doesn't mean it is DCFL. {a nbncn | n ≥ 1} obeys prefix property but not even CFL.

L1 = { a i bj cm | m ≥ min(i,j) }

Here number of c's is greater than minimum of number of a's and number of b's. So, we can say that if number of c's is
greater than number of a's or if number of c's is greater than number of b's, we accept. i.e.,

L1 = { a ibjcm | m ≥ i OR m ≥ j) }

The OR condition here means even though we need to do two checks, we can accept in either case and hence using non-
determinism we just need a PDA to accept L1 (we non-deterministically check if m ≥ j and if m ≥ i). So, L1 is a CFL but
not DCFL.

L2 = { a i bj cm | m ≥ max(i,j) }

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1065 of 2244

This can be rewritten as

L2 = { a ibjcm | m ≥ i AND m ≥ j) }

The AND condition here means we need to do two checks and even non-determinism cannot help us here. This is because
if we non-deterministically guess i ≥ j, and accept if m ≥ i, suppose if the guess is wrong, then we would have accepted a
word not in L2. (In short non-determinism can help only when we have OR condition). So, L2 is not even CFL- it is a CSL.

 8 votes -- Arjun Suresh ( 124125 points)

Before answering I'll give you two points to see:

Σ* is a language which doesn't satisfy prefix property- (if w is in L, prefix of w can also be in L). Now, is this language not
DCFL?

Your PDA for L1 is right. But suppose you use the same PDA (suitably changed) for L2. It will accept aaabcc rt? And
aaabcc is not in L2.

 1 votes -- Arjun Suresh ( 124125 points)

8.147 Number Of Dfa: Number of DFA ? top gateoverflow.in/27730

Let q0 and q1 be two states, with q0 always being the initial state. Let the alphabet be {a, b}.

Then, the possible number of DFA's with only these two states q0 and q1 is?

A. 32
B. 64
C. 80
D. 120

theory-of-computation number-of-dfa


Selected Answer

answer is 64,

every alphabet has two choices on every state . as on state q1 ,0 can either go to q0 or remain on q1, so at every state 4
choices are there, ans such 2 states are there so 4*4=16 is the total number of transition possible, now for final state we
have 4 possibility, while for inital state we have just one possibility. so it will be 1*4*4*4=64. if no boundation on initial
state it will be 128. (2*4*4*4)

 1 votes -- Ravi Singh ( 7303 points)

for a state, on an input symbol we have two choices, which are

1. end up in the same state


2. end up in the other state

There are two input symbols available.


So, total number of ways transition is possible from a state = Choices for an input symbol × Number of Input Symbols = 2 × 2 = 4

Total number of ways in which transition can happen in a DFA with two states = Choices at state q0 × Choices at state q1 = 4 × 4 = 16

In a DFA any state can be a final state or an initial state. Here, Input state is fixed, so we need not worry about it.
total number of possibilities for the set of final states = 4

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1066 of 2244

Hence, total states in this DFA = 4 × 16 = 64


 1 votes -- Amar Vashishth ( 17865 points)

8.148 Number Of Dfa: How many DFA's exist with three states over the input
alphabet {0,1} top gateoverflow.in/10853

Is there any procedure to generalize these types of problems ?

Thanks in advance

theory-of-computation permutation combinations finite-automata number-of-dfa


Selected Answer

Input set is given. So, we have 3 parts of DFA which we can change:

1. Start state
2. Transition Function
3. Final state

Start state can be chosen as any one among 3 in 3 ways.

Transition function is from Q ⨯ Z to Q, where Q is the set of states and Z is the alphabet state. |Q| = 3, |Z| = 2. So,
number of possible transition functions = 3(3 * 2) = 3 6

Final state can be any subset of the set of states including empty set. With 3 states, we can have 2 3 = 8 possible sub
states.

Thus total number of DFAs possible

= 3 × 36 × 23 = 17496

For n states and m input alphabets we can have the formula

n × nnm × 2n = nmn +1 × 2n

In a DFA there might not be a difference if start state changes- as states are unlabeled usually. In such a case, we can
divide the above by number of states giving nmn × 2n possible DFAs.

 16 votes -- Arjun Suresh ( 124125 points)

. State ↓ input → 0 1
2 X 3 3
2 Y 3 3
2 Z 3 3
Total no of DFA = 3*3*3*3*3*3*2*2*2
= 5832
No of DFA with x is starting state = 5832
No of DFA with y is starting state = 5832
No of DFA with z is starting state = 5832
Total DFA = 3*5832 = 17496

 3 votes -- Digvijay Pandey ( 26245 points)

8.149 Pda: how to construct pda for a^i b^j where j!=2i+1, i>=0 top gateoverflow.in/17021

how to construct pda for a^i b^j where j!=2i+1, i>=0 ?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1067 of 2244

i have constructed for j=2i+1 but by complementing the states do we get actual n pda of our requirement?

whether it is decidable?

pda

Yes, but works for only deterministic PDAs and has problems and won't work straight away- see below link.

http://drona.csa.iisc.ernet.in/~deepakd/atc-2011/DPDA.pdf

For NPDA, a complement PDA may not even exist.

 0 votes -- Arjun Suresh ( 124125 points)

8.150 Pda: Push down automata top gateoverflow.in/35754

Which solution is correct one?

I wish I solved it correctly (sol1)

pda theory-of-computation

8.151 Pda: design DPDA for the given language top gateoverflow.in/20654

design DPDA for the given language.

pda


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1068 of 2244

Although it looks there are 2 conditions but there is only one condition which is m ≠ n and hence the deterministic PDA is
shown above .

 0 votes -- Riya Roy ( 4767 points)

8.152 Pda: plz answer top gateoverflow.in/9925

the minimum number of states in the PDA accepting the language

L= {a bn m ∣ n > m; m, n > 0 }
a) 2

b) 3

c) 4

d) 5

theory-of-computation pda


Selected Answer

if we use stack symbols as {z0,A} where initial stack symbol is {z0} and final state is {q2} than if the transition
functions are-

(q0, a, z0) --> (q0, Az0)

(q0, a, A) --> (q0, AA)

(q0, b, A) --> (q1, ϵ)

(q1, b, A) --> (q1, ϵ)

(q1, ϵ, A) --> (q2, ϵ)

q2 is final state..

Minimum no. of states = 3, with NPDA.

 3 votes -- shreshtha5 ( 1227 points)

Assuming only DPDA:

We cannot accept this language using empty stack. Because aaab is in L and aaabb also in L, thus violating prefix
property. So, this language must be accepted using final state as long as PDA is deterministic.

State 1- counting A using stack

State 2- counting B using stack

State 3 - accept

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1069 of 2244

State 4 - reject

 2 votes -- Arjun Suresh ( 124125 points)

8.153 Pda: Language accepted by PDA is __________? top gateoverflow.in/7422

pda theory-of-computation


Selected Answer

L = a(a + b) + b

In q0 when stack is empty and an a comes, a is pushed on stack. After this for either a or b, we reach q1 without modifying
the stack. In q1 we can ignore all a's and b's without modifying the stack. Finally, we can move to q2 on a b and this pops
the a on stack (there is non-determinism here for the given PDA). And now stack is empty and PDA reached final state.
So, L is regular but infinite.

 3 votes -- Arjun Suresh ( 124125 points)

8.154 Pda: PDA top gateoverflow.in/29548

Consider the following push down automata.

The language accepted by above PDA is_______.

a. Regular but infinite.


b. DCFL but not regular.
c. CFL but not DCFL
d. Finite language.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1070 of 2244

theory-of-computation context-free pda


Selected Answer

Regular but infinite. that is a(a + b)(a + b) ∗ b$


Initially Z0 is stack initial symbol, at state q0 read a and push a into stack, we have aZ0 in stack, now read a or b, do
nothing at stack, that is still aZ0 , and reach to q1 , can read any no of a's or b's at q1 and do nothing at stack, that is still
aZ0 , and still at q1 , read b and pop a from stack, we have Z0 at stack and reach to q3 , read $ and do nothing reach to qf.

 4 votes -- Praveen Saini ( 34299 points)

Yes it will be (A)

the language will be a(a+b) +b

Because, First in empty stack it is taking one 'a' at the top of stack.

Now, whatever a or b it takes but it doesnot change the stack value. The stack contain only that 'a'. But it should have to
take atleast one more a or b in the string. That is why it goes to state q0 to q1. Now, at last it got one 'b' for going to next
state q3 which proceeds to final state qf.

So, here we can form regular expression and also can draw dfa for a(a+b) +b . So, it will be infinite regular language.

 1 votes -- srestha ( 11585 points)

b) Its clearly not DCFL because on input a there are more than two transition.

d) There is a loop at state q 1 so it not finite. So its is wrong.

Now option (c) and (a) are the remaining , both are correct but option (a) is more correct with more precise description
about the language.

Because given language can be represented using Regular Expression and Its is the language accepting all the strings
of length at least 3 which starts with 'a' and ends with 'b'.

Regular Expression = a (a+b) (a+b)* b

So option (a) is correct here.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1071 of 2244

 1 votes -- Sandeep Singh ( 5939 points)

8.155 Pda: Output Of PDA. top gateoverflow.in/33576

pda theory-of-computation

8.156 Pumping Lemma: Pumping Lemma top gateoverflow.in/29347

Prove or Disprove below language is regular or not

L1={w|w∈∑* where w visit all state of M atleast once where M is machine accepting L1

L2={w|w∈∑* where w visit all state of M equal no of times where M is machine accepting L2

pumping-lemma

8.157 Pumping Lemma: Pumping lemma top gateoverflow.in/6350

To check L={02i |i is an integer} is regular or not ....i applied pumping lemma as below...Can anyone please
explain why i am not getting it as regular ?

Let Z=02n= 0n-1 0n 01

Take u= 0n-1 , v=0 n, w=01

So, u (v)i w can be written as 0 n-1 (0n)i 0 ...Take i=0, we get 0 n-1.0=0n but 0n dont belong to language as n may be odd.So i
am not getting it as regular...

theory-of-computation pumping-lemma

Pumping lemma says that "there exists an n, u, v and w". Here you took them fixed.

Let Z = 0 2n
Now, u = 0, v = 02(n-1), w = 0.

http://www.cse.msu.edu/~torng/Classes/Archives/cse460.03spring/Lectures/Module26.pdf

 2 votes -- Arjun Suresh ( 124125 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1072 of 2244

8.158 Pumping Lemma: Pumping Lemma RL CFL & Pumping Length top gateoverflow.in/38445

What is the basic Conditions for Pumping Lemma of RL and CFL


I found different ans in different sources

Also Tell me what is a pumping length ?

IS there any minimum pumping length or something ?

pumping-lemma theory-of-computation

Pumping Lemma for RL is explained here

Now, someone should explain it for CFL

Also pls show xwwR is not CFL

 0 votes -- Akhil Nadh PC ( 1967 points)

8.159 Pumping Lemma: Pumping Lemma Confusion top gateoverflow.in/30351

consider a language {0^2n | n>=1}


I am using pumping lemma to show that the above language is not regular.
taking m=3
w=0000
x=0
y=0
z=00
now xy^0z = 000 which is not in w.
hence the language is not regular.
what is the mistake I have done in pumping lemma, because the language is actually regular.

pumping-lemma theory-of-computation

refer to this answer

http://gateoverflow.in/6350/pumping-lemma

 1 votes -- Tameem Salman ( 21 points)

8.160 Pumping Lemma: Whether w wr x where w,x belongs to {a,b}*


Regular? top gateoverflow.in/38670

L = {wwrx where w,x belongs to {a,b}*} is Regular definitely as w can always be considered to be Epislon. So, this just becomes (a+b)* language.

What about this one:


Whether L={wwrx where w,x belongs to {a,b}+} Regular ?

theory-of-computation regular-language pumping-lemma

no not at all..

 1 votes -- Tauhin Gangwar ( 509 points)

8.161 Pumping Lemma: What is the minimum pumping length of the


following languages top gateoverflow.in/27476

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1073 of 2244

This is from the first chapter questions of Sipser's book on TOC. I am stuck in some of the questions where we are asked to
find the pumping length of the following languages.

Find the minimum pumping length of the following regular languages:-

1. L=0 ∗ 1 + 0 + 1 ∗ ∪ 10 ∗ 1

2. L=001 U 0*1*

3. L=0*1*
4. L=10 (11* 0)* 0
5. L= ∊

theory-of-computation pumping-lemma


Selected Answer

(Definition) If L is a regular language, then there is a number p (the pumping length) such that s is any string in L of
length p or more can be written as s = xyz, satisfying the following conditions :

1. for each i ≥ 0 , xy iz ∈L,

2. |y|>0, and

3. |xy| ≤ p.

So we need to find the minimum length string s = xyz ∈ L such that xy iz should also be L.
Remember:

i) y ≠ ∊ , point 2 of definition |y|>0 means only that.

ii) y should be in closure (loop) that repeats ,so that we get xyiz∈L
iii) Don't Worry about Unions, only we need to find s = xyz ∈L that satisfying i) and ii) above said.

Now

Q1. 0*1 +0+1* U 10*1

s= xyz =101 , where x=1 , y=0 and z=1 such that xyiz∈L ( that is 10*1, look i >=0)

Minimum Pumping length = 3


( if you are confused that 11 in L and have minimum length, then remember point2 of definition y ≠ ∊ and secondly when
you will put i=0 in xyiz you will get 11 ∈L )

Q2. L = 001 U 0*1*

s= xyz = 0 , where x=∊,y=0 and z=∊ such that xy iz∈L (that is 0*∊)

Minimum Pumping length = 1

Q3. L = 0*1*

Minimum Pumping Length = 1 (refer Q2)

Q4. L = 10(11*0)*0

s = xyz = 10100 where x=10,y=10 and z=0 such that xy iz∈L (that is 10(1∊0)*0 )

Well it looks Minimum Pumping length is 5 , But it is not, We can repeat y any time (or it should be) and y ≠ ∊ that mean
we cannot use 3 or less length string from L for pumping , So y can be 10 (minimum) so minimum string S we using for
pumping is 10100 of length 5, but length 4 string can not generated from the given language (that's not our fault). So we
can say we use 4 or more length string s for pumping that belongs to L.

So Minimum Pumping length = 4.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1074 of 2244

Q5. L= ∊

Ideally its length 0 only s = xyz = ∊, where x = ∊ , y = ∊ and z = ∊ But y ≠ ∊

So we say, Minimum pumping length = 1 .

 7 votes -- Praveen Saini ( 34299 points)

8.162 Pushdown Automata: Theory of computation question top gateoverflow.in/26539

http://geeksquiz.com/gate-gate-cs-2015-set-1-question-60/

please give explanation to this question.

theory-of-computation pushdown-automata


Selected Answer

Given string is 101100 now u have to find which string added to this so whole string is accepted .

so take 101100 + option a(10110)= 101100 10110..now run on stack

push 1 push 0 push 1 push 1 push 0 push skip 0 ...then start popping on next input so .. one 0 -> 1 come pop 0... then on 0 -> 0 come cant
pop and push also so sting not accepted.

take 101100 + option a(10010)= 101100 10010..now run on stack

Now m doing for option 2

push 1 push 0 push 1 push 1 push 0 push skip 0 ...then start popping on next input so .. one 0 -> 1 come pop 0... then on 1 -> 0 come pop 1
then on 1-> 0 come pop 0.... then on 0->1 come pop 0 ...then on 1-> 0 come pop q.. noe stack is empty on null aceept the string

 2 votes -- Anirudh Pratap Singh ( 4091 points)

8.163 Pushdown Automata: Context free or not ? top gateoverflow.in/15327

L = {aibjckdl ∣ i + k = j + l}
Is L context free?
If yes, then draw PDA. If no, why?

context-free pushdown-automata pda


Selected Answer

Consider for the case i >= j

Push A for each a


Pop A for each b
Push C for each c
Pop C first and then A for each d.

Accept if stack is empty when input finishes.

For the case i < j

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1075 of 2244

Push A for each a


Pop A for each b until stack becomes empty
Push B for each b after that
Pop B for each c until stack becomes empty
Push C for each c after that
Pop C first and then B for each d.

Accept if stack is empty when input finishes.

So, clearly L is CFL. But we can combine the two cases and there is no guess needed making L a DCFL.

 2 votes -- Arjun Suresh ( 124125 points)

The language can be like a^n b^m c^n d^m. and cannot put in one stack. So it is not CFL

 3 votes -- srestha ( 11585 points)

8.164 Pushdown Automata: ugc net top gateoverflow.in/44095

pushdown-automata

(a) a^nb^n is Dcfl but not regular

(b) The complement of a^nb^na^n is CFL but not DCFL.

(C)a^nb^na^n is CSL but not CFL .

(D) text mismatch

 0 votes -- Manojk ( 3365 points)

8.165 Rank Of Nonterminal: What is the rank of the non-terminal B in the


following context free grammar? top gateoverflow.in/20040

Consider the following CFG


S → AB
A → aBc ∣ aB ∣ a
B → bDe ∣ f ∣ CD
C → Dg ∣ h
D→g

The rank of the non-terminal B is __________

context-free rank-of-nonterminal

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1076 of 2244

S -> AB

->ACD ( B-> CD )

Therefore the maximum number of non terminals from the start state is 3 .

Rank of the given grammar is 3.

 0 votes -- Riya Roy ( 4767 points)

8.166 Recurrence: How to calculate This recurrence ? top gateoverflow.in/32213

. The finite automaton below:

accepts no word of length zero, no word of length one, and only two words of length two (01 and 10). There is a
fairly simple recurrence equation for the number N(k) of words of length k that this automaton accepts. Discover
this recurrence and demonstrate your understanding by identifying the correct value of N(k) for some particular k.
Note: the recurrence does not have an easy-to-use closed form, so you will have to compute the first few values by
hand. You do not have to compute N(k) for any k greater than 14.

a) N(14) = 280
b) N(11) = 76
c) N(13) = 2730
d) N(11) = 32

recurrence theory-of-computation algorithms

8.167 Recursive Recursively Enumerable: turing machine plzz xplain top gateoverflow.in/29737

Let A = {⟨M⟩ ∣ M is turing machine that halts on all inputs and L(M) = L ′ for some undecidable language L ′ }. Then A is ____

a. Regular language
b. Recursive language but not regular
c. Recursively enumerable language but not recursive language
d. Non-recursively enumerable language

theory-of-computation recursive-recursively-enumerable


Selected Answer

M is a Turing machine that halts on all inputs implies L(M) is recursive.

Now, L(M) = L' for some undecidable language L' (I suppose this is a typo or else they could have said L' is some
undecidable language and the final L' should be just L).

So, this means L(M) = complement of an undecidable language. But complement of undecidable is again undecidable. But
L(M) must be decidable. So, there cannot be any such M making A = ∅ which is a regular language.

 2 votes -- Arjun Suresh ( 124125 points)

8.168 Recursive Recursively Enumerable: Please explain? top gateoverflow.in/30890

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1077 of 2244

Consider the following Languages:

Lne = {⟨M⟩ ∣ L(M) ≠ ϕ}

Le = {⟨M⟩ ∣ L(M) = ϕ}

where ⟨M⟩ denotes encoding of a Turing Machine M


Then which of the following is true?

(a) Lne is r.e. but not recursive and Le is not r.e.


(b) Both are not r.e.
(c) Both are recursive
(d) Le is r.e. but not recursive and Lne is not r.e.

theory-of-computation recursive-recursively-enumerable


Selected Answer

Answer should be A according to me.

Lne says the input encoded TM M should not accept an string - which means M accepts ϕ . That means if we get an string
which is accepted by M then our work is done - we get an answer for the yes part. But in case we do not get a string we
have to check all infinite strings to know finally whether it will be not equal to ϕ . Therefore we do not have answer for no
part . Hence it is RE but not recursive.

Le is not even re because we do not have answer for yes part . We have to check all the infinite strings to answer whether
it finally accepts ϕ .

We can also apply Rice's theorem here. Both Lne and Le describes non-trivial properties of r.e. languages. So, as per Rice's
theorem both are undecidable. Now, Le is a non-monotonic property ( L(Tyes) ⊂ L(Tno possible for empty set and any non-
empty set respectively). So, Le is not even r.e. as per Rice's theorem part 2. Rice's theorem part 2 cannot be used for Lne
since it is not a non-monotonic property (we cannot get any Tyes, Tno such that L(Tyes ⊂ L(Tno ). So, we cannot say if it is not
r.e. using Rice's theorem and we have to use the first method for this part.

http://www.gatecse.in/rices-theorem/

 3 votes -- Riya Roy ( 4767 points)

8.168 Recursive Recursively Enumerable: is the set of recursively


enumerable languages countable? top gateoverflow.in/13227

theory-of-computation recursive-recursively-enumerable

Yes, it is. Because we can count the set of TMs.

https://books.google.fr/books?
id=hsxDiWvVdBcC&pg=PA281&lpg=PA281&dq=is+the+set+of+recursively+enumerable+languages+is+countable&source=bl&ots=rdGw
DM5-zIluIIH3F-
R7ilFk&hl=en&sa=X&ved=0CCcQ6AEwAWoVChMIjMidg9vcxgIVBJQeCh2GhQvO#v=onepage&q=is%20the%20set%20of%20recursively%

 0 votes -- Arjun Suresh ( 124125 points)

8.169 Recursive Recursively Enumerable: Let A and B be disjoint, R.E.


languages. Let A' U B' also be recursive enumerable. What can you say

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1078 of 2244

about A and B? top gateoverflow.in/15155

ˉ ˉ
Let A and B be disjoint, R.E. languages. Let A ∪ B also be recursive enumerable. What can you say about A and B?

(a) Neither A nor B is decidable is possible (b) At least one among A and B is decidable (c) Both A and B are decidable (d)
None of above

theory-of-computation recursive-recursively-enumerable


Selected Answer

The question has some redundant data.

It is given A and B are disjoint. So, A ∩ B = ∅  A ′ ∪ B ′ = Σ ∗ which is regular (and hence r.e. also). So, " Let A ′ ∪ B ′ also be
recursive enumerable" is not necessary in question.

Now, I say option A is true which implies options B and C are false as option A says both A and B can be non r.e. Example
for such an A and B is given below..

A = L1 = {⟨M, w, 0⟩ ∣ M halts on w}

B = L2 = {⟨M, w, 1⟩ ∣ M halts on w}

Here L1 and L2 (variants of halting problem) are r.e. and neither is recursive. The last bit is added to ensure L1 ∩ L2 = ∅.

 2 votes -- Arjun Suresh ( 124125 points)

8.170 Recursive Recursively Enumerable: Given Language is REC or Non RE top


gateoverflow.in/4196

Which of the following is true for the given language?

L = {<TM> | TM halts on every input}

<TM> is encoding of the Turing machine


¯
(A) L is Recursive and L is also Recursive
¯
(B) L is Recursive Enumerable and L is also Recursive Enumerable
¯
(C) L is Non Recursive Enumerable and L is Recursive Enumerable
¯
(D) L is Non Recursive Enumerable and L is Non Recursive Enumerable

theory-of-computation difficult recursive-recursively-enumerable decidability


Selected Answer

Well, there is an easy solution to this- thanks to @Sonu.

L here describes the encoding of TM which halts for all inputs. In other words, L describes the encoding of TMs whose
language is recursive. Now, this problem can be solved easily using Rice's theorem. (part 2).

L(TM) is recursive? is a non-monotonic property, because we have a TM for which L(TM) is recursive - TM yes, and we can
have another TM for which L(TM) is non-recursive- Mno and L(TM yes) subset of L(M) no. (For example L(TM yes) is ∅ and
L(TM no) is any non-recursive language). Now, all non-monotonic property of language of TM are not-even semi decidable-
their language is not recursively enumerable. So, L is not recursively enumerable.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1079 of 2244

L' can be stated as is L(M) non-recursive? This is again a non-monotonic property as we can have L(TM yes) = a non
recursive language and L(TMno) = Σ*, so that the subset condition holds. So, L' is also non-recursively enumerable.

http://gatecse.in/wiki/Rice%27s_Theorem_with_Examples

 2 votes -- Arjun Suresh ( 124125 points)

The question describes a language which has the encoding of the TMs that halts for every input. Now, to say this language
is recursive, we have to make another TM (this new TM is different from the encoding of TMs in L) which accept all strings
in L (which are encoding of all halting TMs). If this new TM halts for all input, then the given language is recursive. If it
halts for strings in L (may or may not halt for strings not in L), then the given language is recursively enumerable.

(The given property is of TM and not its language. So, we can't use Rice's theorem )

So, only way is reduction. If we reduce halting problem to this problem (solve halting problem assuming solution to given
problem), then we prove that L is not recursive as language of halting problem is proved to be non recursive.

First we try to solve halting problem. We assume we have a TM M for accepting L, that is given an encoding of a TM,
our TM will say "yes" if the encoded TM halts for all inputs and "no" otherwise. Now, we want to solve halting problem
using this. Halting problem is to decide if a given TM halts for a given word w. We proceed as follows:

Given an instance of halting problem (an encoding of a TM H and a word w), we make another TM N which will take any
input but simply erases that input from the input tape and simulates the moves of H on w. If H halts on w, N halts on all
inputs. If H doesn't halt on w, N won't halt on any input - reduction is perfect. Now, we simply give the encoding of N to
our assumed TM for L- M. If L says "yes"- we can say H halts on w, if L says "no"- we can say H does not halt on w - we
have solved halting problem, which can never be done. Thus, our assumption is wrong and such an M can't exist. So, L is
not recursive.

To prove L is not RE is bit more tricky. One proof is given here:

http://www.inf.ed.ac.uk/teaching/courses/ci/documents/note09.pdf

To prove L' is not recursively enumerable: (It's easier as we can directly reduce from complement of halting problem)

L ′ = { < TM >∣ TM does not halt on some input }

We can try reduction from complement of halting problem. Complement of halting problem is given a TM H and a
word w, we have to say if H does not halt on w. We proceed as follows: (same reduction as done for halting problem).

We assume we have a TM M' which semi-decides L'- that is it says "yes" if we give encoding of a TM that does not halt on
some input. (It may say "no" or loops, if the encoded TM halts on all inputs)

Given an instance of complement of halting problem (an encoding of a TM H and a word w), we make another TM N which
will take any input but simply erases that input from the input tape and simulates the moves of H on w. If H halts on w, N
halts on all inputs. If H doesn't halt on w, N won't halt on any input - reduction is perfect. Now, we give the encoding of N
to our assumed TM for L'- M', and if M' says "yes", it means N does not halt on some input- possible only if H does not halt
on w - we solved complement of halting problem using M' which is not possible. So, M' cannot possibly exist meaning L' is
not recursively enumerable.

So, L is not recursive and L' is not recursively enumerable. The only matching option is (D) - we need not prove L is not
RE.

 4 votes -- Arjun Suresh ( 124125 points)

8.171 Recursive Recursively Enumerable: Complement of a recursive


language top gateoverflow.in/34807

Given a TM M, complement of L(M) is context-free. True/False?

recursive-recursively-enumerable context-free

"There exists a Non-Context-Free Recursive Language whose complement is Context Free."

We know that CFLs are not closed under Complement.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1080 of 2244

This implies that there exists a CFL, L such that L̃ is not Context Free.

Since every Context Free Language is also a Recursive Language, L must be a Recursive Language.

Since Recursive Languages are closed under Complement, L̃ must be a Recursive Language.

So L̃ is a Non-Context-Free Recursive Language whose complement is a Context Free Language.

"There exists a Non-Context-Free Recursive language whose complement is not is also not Context Free."

Consider the following language A,

A= {a p ∣ p is a prime number . }
It is known that A is a Non-Context-Free Recursive language.

but checking

1) If a number is prime &

2)If it is a non-prime,

both requires division.

So I guess here both A and à are Non-Context-Free Recursive Languages.

So this part should also be true.

Hence, I guess the statement

"Complement of a Recursive but not Context Free Language is Context Free. "

should neither be a Tautology nor a Contradiction, it should be a Contingency.

 0 votes -- Anurag Pandey ( 8183 points)

8.172 Recursive Recursively Enumerable: Turing Recognizable L top gateoverflow.in/33909

If L is Turing-recongnizable. Then

ˉ
(A) L and L must be decidable.

ˉ
(B) L must be decidable but L need not be.

ˉ
(C) Either L is decidable or L is not Turing recognizable.

(D) None of above.

theory-of-computation recursive-recursively-enumerable


Selected Answer

L is r. e.,

L ′ may or may not be r. e.

If L ′ is r. e. , then it means L is decidable.

​If L ′ is not r. e. , then it means L ′ is not Turing Recognizable.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1081 of 2244

​Option C.

 5 votes -- Praveen Saini ( 34299 points)

8.173 Recursive Recursively Enumerable: Which of the following is not a


recursive Language? Please explain the reason for each top gateoverflow.in/16587

Which of the following is not a recursive language?

a. Regular language

b. {⟨M, w⟩ | M is a DFA that accepts w}

c. {⟨M⟩ | M is a TM and there exists an input which halts within 100 steps}

d. {⟨M⟩ | M is a TM and L(M) is regular }

theory-of-computation recursive-recursively-enumerable decidability


Selected Answer

Option A) Every Regular Language is decidable.

Option B) We are given a DFA and asked to determine if a word w belongs to it. Simulate and see if the word w goes to a
final state- always decidable. (Same works for PDA, LBA and even always halting TMs)

Option C) Give an input to TM and if the input is accepted by TM in 100 steps then it will say "yes" else "no". But there is a
catch here- we are not given the input and there are infinite possible inputs. But, in 100 steps a TM cannot process more
than 100 length of the input. So, we can simulate the given TM for 100 steps for all possible strings of length 100 (this
number is finite) and decide our problem.

Option D) L(Tyes) = Σ ∗ and L(Tno ) = {an bn ∣ n > 0}. So, this is a non-trivial property of LANGUAGE OF TM, and hence according
to Rice's First Theorem, it is undecidable. Source : http://gatecse.in/wiki/Rice%27s_Theorem_with_Examples

Option D is actually non-even semi decidable and for this we can take L(Tyes) = ϕ and L(Tno ) = {an bn ∣ n > 0}, making
L(Tyes) ⊂ L(Tno ).

More problems: http://www.cs.rice.edu/~nakhleh/COMP481/final_review_sp06_sol.pdf

 4 votes -- Aditya Gaurav ( 1831 points)

8.174 Recursive Recursively Enumerable: How can we say that this language
is regular? top gateoverflow.in/16588

Let A = { < M > | M is a turing machine that halts on all inputs and L(M) = L ′ for some undecidable language L ′ }. Then A is ___

a. Regular language

b. Recursive language but not regular

c. Recursively enumerable language but not recursive language

d. Non-recursively enumerable language

theory-of-computation decidability recursive-recursively-enumerable

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1082 of 2244


Selected Answer

First of all we have to find the set of strings in A.

A is having the encoding of TMs which has certain properties. So, lets look at the property.

The property of the TM being encoded is that it halts on all inputs (which means its language is recursive) and also that its
language is the complement of an undecidable language L (in question it must be L and not L ′ ).

Some issue with the given property? Yes, there is no undecidable language whose complement is recursive(decidable) as
if L is decidable its complement must also be. So, the given property is unsatisfiable and there is no TM which satisfies this
(trivially false). This makes A = {} which is nothing but a regular language.

 1 votes -- Arjun Suresh ( 124125 points)

8.175 Recursive Recursively Enumerable: Union/Intersection of Recursive


languages top gateoverflow.in/33733

Which of the following is false ?

a. Union of two recursive languages is recursive

b. Intersection of regular and recursive language is recursive

c. Union of regular language and recursive language is recursive

d. None of these.

please give examples of each option..

and also describe intersection of regular and recursive is recursive..

theory-of-computation made-easy recursive-recursively-enumerable

If a language is regular, then it is recursive too.

Recursive languages are closed under Union and Intersection.

1. Union of two recursive language is recursive

2. Intersection of two recursive language is recursive

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1083 of 2244

http://gatecse.in/wiki/Closure_Property_of_Language_Families

 0 votes -- Praveen Saini ( 34299 points)

8.176 Recursive Recursively Enumerable: Which is true? top gateoverflow.in/4305

Let M range over Turing machine descriptions, Consider the set REG = { M | L(M) is a regular set } and let the complement of
REG be Co-REG.

Which of the following is true?

A. REG is r.e. but Co-REG is not


B. REG is not r.e. but Co-REG is
C. Both are r.e.
D. None of the above

theory-of-computation recursive-recursively-enumerable decidability


Selected Answer

REG contains the set of all strings which are encodings of TM whose language is regular. So, REG is deciding a property of
TM- we are lucky and can make use of Rice's theorem.

Here we want to prove whether RE or not. (Rice's theorem part 1 won't help)

So, lets see if the property is non-monotonic so that we can apply Rice's theorem part 2.

For non-monotonicity, language of TM satisfying the property must be a subset of language of TM not satisfying the
property. So, if we take L(TMyes) = ∅ and T(TM no) = any non regular language, this proves the property is non-monotonic.
So, as per Rice's theorem part 2, REG is not RE.

Using the same technique we can prove Co-Reg is also not RE. Just take L(TM yes) = any non regular language and
L(TM no) = Σ*.

http://gatecse.in/wiki/Rice%27s_Theorem_with_Examples

 6 votes -- Arjun Suresh ( 124125 points)

L(M) is a regular set is a non-monotonic property of r.e. languages and deciding any such property is not even semi-
decidable making REG non r.e.

For Co-Reg, L(M) is a non regular set, which is also a non-monotonic property of r.e. languages and hence Co-Reg is also
non r.e.

So, D option.

http://www.gatecse.in/rices-theorem/

PS: To show monotonicity of a property, we need a r.e. language which has the property and another r.e. language which
does not have the property and the first one a proper subset of second. For REG these languages respectively can be the
empty language and any non-regular language (just one possibility) while for C-REG these respectively can be any non-
regular language and Σ ∗ .

 3 votes -- Arjun Suresh ( 124125 points)

8.177 Reduction: Question on reducibility top gateoverflow.in/34020

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1084 of 2244

Please check if the given answer is correct or not.

theory-of-computation reduction


Selected Answer

2 can be TRUE. Both can be recursive as recursive set is a proper subset of r.e. set. But 1 can never be TRUE. So, given
answer is correct. But does the "polynomial" word in question carry any significance?

 2 votes -- Arjun Suresh ( 124125 points)

8.178 Reduction: To say P=NP top gateoverflow.in/139

To say P=NP which one of the following is sufficient? (All reductions in polynomial time)

A. Reduction of a NP problem to a P problem

B. Reduction of a NP-complete problem to a P problem

C. Reduction of a P problem to an NP problem

D. Reduction of a P problem to an NP-complete problem

reduction theory-of-computation normal


Selected Answer

Option B is the most correct answer. (To know why it is not THE correct answer read the tail section of this answer)

The reasons are as follows.

A problem p in NP is NP-complete if every other problem in NP can be transformed into p in polynomial time. They have
another property that given a problem in NP and a solution, we can verify deterministically in polynomial time that the
solution is indeed a valid solution or not.

P represents the class of all problems whose solution can be found in polynomial time.

Reduction of an NPC problem to a P problem would imply 2 things:


1) All problems in NP are reducible to this problem in P because all NP problems are reducible to NPC problems.
2) We can solve the NPC problem in polynomial time as well because we ca solve ther problem in P in polynomial time by
definition of class P.

This implies that all problems in NP are solvable in polynomial time. (1)

A problem which can be solved in polynoimial time is essential in P

Which implies P=NP (QED)

Tail

The statement of option B is incomplete. It is not enought to say that that reduction of NPC problem to a problem in P, but
the reduction should be polynomial reduction or karp reduction.
The statement which implies P=NP would be There exist a polynomial time reduction of a problem in NPC to a
problem in P. The answer is partially correct because when we say reduction, we usually mean polynomial time

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1085 of 2244

reduction, but neverthless it doesnt hurt to be precise.

 6 votes -- NitHish Divakar ( 151 points)

8.179 Regular Expressions: equality of regular expressions top gateoverflow.in/11763

which of the following pair of regular expressions are equal

a)a* & ((aa)* + (aa0)*)*

b)(r+s)* & (rs)*

c)(rr)* & r*r*

d)(r1(r1+r2)*)* & r 1(r1+r2)

answer given is option D but it think option D should be modified to (r1 (r 1 +r2 )*)* & r1 * (r 1 +r2 )* for being it correct.

theory-of-computation regular-expressions

Yes you are right . your modified version of option D will give the right option .

 3 votes -- Pranay Datta ( 6113 points)

8.180 Regular Expressions: is a*b* is a regular expression ? top gateoverflow.in/43411

if yes then what is the difference b/w a*b* and a^n b^n ?if yes what is that ? if nothing then why a^n b^n is not a regular
Language ?

Forgive me if this is a stupid question .But as a non cs student i don't know what is going on in TOC .

theory-of-computation regular-expressions finite-automata


Selected Answer

Yes a*b* -- Regular one ( It can take any number of a and b )

anbn ---- An equal no of a and equal no of b

The regular lang is accepted By a Finite state Automata . It doesnt have any memory with it .

So for the first one it doesnt have any restriction to keep track how much a and how much b it has read . it wouldnt have
restriction of a, b, aaabbbbbb, abbbb,bbbbb , aabb etc

While for the second , if it has read 3 a then it should read 3 b also , but FA doesnt have memory only , it read 3 a and
then when it start reading b , it doesnt have any idea about how much a it read .

Hence the second one is non regular :)

I hope it help you !

 3 votes -- Dexter ( 1933 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1086 of 2244

a*b* = write any no. of a and any no. of b without any condition. ( so we can design finite automata for this which take 2
state , when we able to make FA then these language are Regular)

ex: am bn here m and n are diffrent variable so we have no restriction of no. of a and no. of b are equal , less than , greater
than etc.

an bn = always as no. of a equal to no. of b.. so we cannot create FA for it. B/C comparision is present b/w a and b. ( when
comparission present then not regular ) ex. an bn c n here comparision present among a,b,c. always equal no. of a,b,c.

 1 votes -- Anirudh Pratap Singh ( 4091 points)

8.181 Regular Expressions: What language does this FA represent ? And


what is the regular expression for this FA ? top gateoverflow.in/43353

regular-expressions theory-of-computation finite-automata


Selected Answer

First state and last state in your DFA are equivalents.

it will be look like :

DFA over {a,b} that accepts all strings that doesn't contain "aa" as substring.

 4 votes -- Praveen Saini ( 34299 points)

8.182 Regular Expressions: right left quotient top gateoverflow.in/43900

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1087 of 2244

explain with proper procedure is diagram must for such type of questions

regular-expressions

HERE L1={ba, aba, baa,abaa, aaba, baaa.........}

and L2={a, ab, abb, abbb,..............}

Supose

L1={pax,jax}

L2={x,ax}

then L1/L2={pa,ja,p,j}

So here

L3=L1/L2

={b, ab, ba,aba, aab, baa.....................}

So option C is correct.

 0 votes -- Manojk ( 3365 points)

8.183 Regular Expressions: toc top gateoverflow.in/25540

Consider a regular expression over the alphabet set {r, s}. The following regular expressions are to be considered

1. (r ∗ s ∗ ) ∗ + (r + s + ) ∗
2. (r + s + r + ) + + (ε + r) ∗
3. (rs ∗ + sr ∗ ) ∗ + (ε + s)
4. ((rs ∗ ) ∗ r) ∗ + ((sr ∗ ) ∗ r) ∗

Choose the correct answer?

A. all are equivalent to (r + s) ∗


B. all are equivalent to (r + s) +
C. all denote an infinite number of strings but not equivalent to (r + s) ∗
D. all denotes a finite number of strings

theory-of-computation regular-expressions

Please correct me if I am wrong.

In option (1) (r ∗ s ∗ ) ∗ + (r + s + ) ∗ , so we can generate ((r ∗ s ∗ )(r ∗ s ∗ ). . . . . (r ∗ s ∗ )) + ((r + s + )(r + s + ). . . . . . . . . . . . (r + s + )).

So , if we put r as null , we would be able to get s , if we put s as null ., we will able to get all r.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1088 of 2244

Also , we can get any combination of s and r.

 0 votes -- Shounak Kundu ( 3757 points)

8.184 Regular Expressions: equality of regular expressions top gateoverflow.in/11761

Q)

which of the following pair of regular expressions are equal

a)(0+1)* & 0* + 1*

b)∅* & ∅*

c)0(120)*12 & 01(201)*2

d)None of the above

answer given is option C which i got why.The problem is what is wrong with option B deemed to be true?? .also is 010
present in

0* +1*??

theory-of-computation regular-expressions

option B is right and also C .

option A is wrong .

0* +1 * produced this type of string (0,00,000,000,000000,1,111,11111,11111111) either no. of 0 or 1`s .

 2 votes -- Pranay Datta ( 6113 points)

8.185 Regular Expressions: equality of regular expressions top gateoverflow.in/11762

which of the following pair of regular expressions are not equal

a)∅* & ∈*

b)(01+0)*0 & 0(10+0)*

c)r1*(r1+r2)* & (r1 + r2)*

d)None of the above

in my view option A should be the correct option but answer given is option D

theory-of-computation regular-expressions

The answer is option D .

Because

∅* = ∈ & ∈* = ∈ so both are equal .

 4 votes -- Pranay Datta ( 6113 points)

8.186 Regular Expressions: #Regular Expression top gateoverflow.in/42618

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1089 of 2244

The regular expression 0*(10*)* denotes the same set as

(A) (1*0)*1*

(B) 0 + (0 + 10)*

(C) (0 + 1)* 10(0 + 1)*

(D) none of these

theory-of-computation regular-expressions


Selected Answer

it should be option (A).

0*(10*)* = (1*0)*1*

 6 votes -- Digvijay Pandey ( 26245 points)

The best method to solve this kind of problem is that to solve it by taking string as example. You just check that what is
the string which can be generated by one RE, which can not be generated by other. And for this don't take a long string
as example. Take most basic string, that will give you answer most of the time. For example lets solve the above problem.

The smallest string can be generated from the given RE ( 0*(10*)*) is "epsilon".

For this only option (C) is incorrect. Because option C ((0 + 1)* 10(0 + 1)* ) can never generate "epsilon" string.

Given RE can generate "1", but option B, can not generate "1" hence option B is wrong.

Now come to option A ((1*0)*1*). This can generate the " epsilon" string and "1" too but It can not generate a string
like "00010001000", which can be generated by our given Regular expression.

Hence Answer will be None Of these i.e. Option (D).

 4 votes -- Rude Maverick ( 3063 points)

it should be opt (a).

0*(10*)* =∈,0,1,10,010,0010,100...........

a. (1*0)*1*= ∊,1,0,10,110,101,1011,110.......it is generating same set of strings by using shifting property

b. 0 + (0 + 10)* = 0,10,010 .......... it is not generating ∈

c. (0 + 1)* 10(0 + 1)* = 10,010........... it is not generating ∈

 2 votes -- kvkumar ( 59 points)

(a+b)*=a*(b.a*)*=b*(a.b*)*

1*(0.1*)*

p(q.p)*=(p.q)*p

(1*.0)*.1*

option A)

 1 votes -- sanketg186 ( 97 points)

8.187 Regular Expressions: true or false? top gateoverflow.in/4645

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1090 of 2244

abcd belongs to (b*a*)*(d*c*)*

theory-of-computation regular-expressions


Selected Answer

yes.

(b*a*) -> a

(b*a*)2 -> b

(d*c*) -> c

(d*c*)2 -> d

 6 votes -- Arjun Suresh ( 124125 points)

8.188 Regular Expressions: which one is correct ? top gateoverflow.in/16735

Consider R1 and R2 are two regular expression then equality of two regular expression compute in

A) polynomial time B) Exponential time

C) logarithmic Polynomial time D) Constant Time

regular-expressions

www.win.tue.nl/mdseminar/pres/ploeger-19-10-06.pdf
Polynomial Time.

 0 votes -- Abhinav Rana ( 489 points)

8.189 Regular Expressions: TOC: Regular Expression How to apprach gateoverflow.in/33551

top

Consider the regular expression R = (a + b) ∗ (aa + bb)(a + b) ∗ . Which one of the following regular expressions describes the same
language as described by R?

R1 = (a(ba) ∗ (a + bb) + b(ab) ∗ (b + aa))(a + b) +

R2 = (a(ba) ∗ (a + bb) + b(ab) ∗ (b + aa))(a + b) ∗

R3 = (a(ba) ∗ + b(ab) ∗ ) + (a + b) ∗

R4 = (a(ba) ∗ + b(ab) ∗ )(a + b) +

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1091 of 2244

How to approach this ?

theory-of-computation regular-expressions


Selected Answer

Regular expression given is (a + b) ∗ (aa + bb)(a + b) ∗ , means all strings having double letter

DFA

Option B,

{ }
a (ba) ∗ (a + bb) b (ab) ∗ (b + aa)
     
reach to q 1still at q 1reach to q 3
+ reach to q 2still at q 2reach to q 3 (a + b) ∗
 
we are at state q 3 at q 3 with anything including ϵ
R2 =

is correct as per DFA .

Another way is to do is using state elimination

Remove Edges in between q1 and q2 and then states, we will get the exact option

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1092 of 2244

Note :

1. In option A, it is wrong because of (a + b) + , once we are at state q3 , then we need minimum ϵ to reach q3 , that is missing in option A

2. In option C, R 3 can generate ϵ, a and b, but we need minimum aa or bb to reach final and as per given regular expression.

3. In option D, R 4 can generate ab or ba, that should not be .

 1 votes -- Praveen Saini ( 34299 points)

8.190 Regular Expressions: Question of regular expression top gateoverflow.in/10855

Consider the following regular expressions :

(i) ((a/b) ∗ (ii) (a ∗ /b ∗ ) ∗ (iii) ((ϵ/a)b ∗ ) ∗

Which of the following statements are correct ?

(a) (i) ,(ii) are equal and (ii) , (iii) are not .

(b) (i) ,(ii) are equal and (i) , (iii) are not .

(c) (ii) ,(ii) are equal and (i) , (ii) are not .

(d) All are equal

Answer is given as (d) . .

But , my question is :

from (ii) (a ∗ /b ∗ ) ∗ : I can derive (a/ϵ) ∗ , which can give me (a)* . Isn't it so ?

From (i) ((a/b) ∗ : I can not separate a and b .

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1093 of 2244

So , how can they all be equal ?

theory-of-computation regular-expressions


Selected Answer

1. (a + b)*
2. (a* + b*)* =(a+b) *
3. ((null + a)b*)* = (b* + ab*)*
= ((null + b + bb + bbb + .....) + a(null + b + bb + bbb + .....))*
= (b + a + a(all string of b) + null + (all string of b except ))* //rearranging b*
= (a +b + rest) *

= (a + b)* as anything of rest or their combination is already included in (a+b) *


So all are equal.

 6 votes -- Digvijay Pandey ( 26245 points)

As of my knowledge a/b means either a or b,so we can select any one of them.

 1 votes -- admin ( 1411 points)

8.191 Regular Expressions: Which of the following are not equivalent to


expression (a + b + c)* ? top gateoverflow.in/15086

Which of the following are not equivalent to expression (a + b + c) ∗ ?

(A) (a ∗ + b ∗ + c ∗ ) ∗

(
(B) (ab) ∗ + c ∗ ∗ )
(C) (a ∗ b ∗ c ∗ ) ∗

(D) (a ∗ b ∗ + c ∗ ) ∗

theory-of-computation regular-expressions


Selected Answer

Clearly b is the answer as we can see that every one is generating aaaaabbb while the second option is not generating it .
The approach to this question is see in option b every a is has to be followed by b because it has (ab)*, and such
restriction is not in the question.

 5 votes -- Ravi Singh ( 7303 points)

8.192 Regular Expressions: Which one of the following doesn’t generate


same language as rest? top gateoverflow.in/15386

1. (a+b)*a(a+b)*(a+b)*
2. b * a b * a (a + b)*
3. (a + b)* a b* a b*
4. b * a (a + b)* a b*
5. All are generating same language.

theory-of-computation regular-expressions

Look at R.E. 1 & 2,3,4 In R.E. 2 ,it cannot produce 'a'.

So Regular expression 1 will never generate same language as of others

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1094 of 2244

 1 votes -- Rohti Bhange ( 125 points)

this the very simple . start with the minimum strings that can be made . starting with first string every language with a as
a substring will be accepted. and minimum string will be a .but every other language minimum string will be aa. hence 1 is
not like other.

 1 votes -- Ravi Singh ( 7303 points)

8.193 Regular Expressions: Regular expression for all strings starts with ab
and ends with bba is. top gateoverflow.in/38246

Regular expression for all strings starts with ab and ends with bba is.
a) aba*b*bba
b) ab(ab)*bba
c) ab(a+b)*bba
d) All of the mentioned

Doubt: starting with 'ab' and ending with 'bba', so 'abba' should also be accepted right?

regular-expressions theory-of-computation finite-automata


Selected Answer

right answer is : ab(a+b)*bba + abba

 4 votes -- Digvijay Pandey ( 26245 points)

8.194 Regular Expressions: Which of the following regular expressions are


equivalent? top gateoverflow.in/14657

1. (a ∗ + b ∗ ) ∗
2. (a ∗ b ∗ ) ∗
3. (a + b) ∗
4. (a + b ∗ ) ∗
5. (a ∗ + b) ∗
6. (b ∗ a + a ∗ b) ∗
7. (a + ab) ∗
8. (ba + ab) ∗

regular-expressions theory-of-computation


Selected Answer

1. (a ∗ + b ∗ ) ∗
≡ (a + a ∗ + b + b ∗ ) ∗
≡ (a + b) ∗

2. (a ∗ b ∗ ) ∗

(
≡ (ϵ + a ∗ )(ϵ + b ∗ ) ∗)
≡ (ϵ + a ∗ + a∗ b∗ + b∗ ∗)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1095 of 2244

≡ (a + b) ∗

3. (a + b) ∗

4. (a + b ∗ ) ∗

(
≡ a + (b + b ∗ ) ∗ )
≡ (a + b) ∗

5. (a ∗ + b) ∗

(
≡ (a + a ∗ ) + b ∗ )
≡ (a + b) ∗
Note: Symmetric to 4

6. (b ∗ a + a ∗ b) ∗

(
≡ (a + b ∗ a) + (b + a ∗ b) ∗ )
≡ (a + b) ∗

7. (a + ab) ∗
Not equivalent to any other of these eight RegEx-es.

8. (ba + ab) ∗
Not equivalent to any other of these eight RegEx-es. Not even to 7!

 6 votes -- Pragy Agarwal ( 13675 points)

8.195 Regular Expressions: Let A = (a + b) ∗ ab (a + b) ∗ , B = a ∗ b ∗ and C = (a + b) ∗ .


Then the relation between A, B, C is? top gateoverflow.in/13162

a. A + B = C

b. AR + BR = C

c. AR + B = C

d. None

theory-of-computation regular-expressions


Selected Answer

AR is all stings over {a,b} that contain "ba" as substring.i.e, (a+b)*ba(a+b)*

B is all strings over {a,b} that doesn't contain "ba" as substring ,i.e, a*b*

so A R + B = (a+b)* = C

Option C is correct.

NFA for A and its equivalent DFA.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1096 of 2244

Reversal of A , that is resulting in NFA

Equivalent DFA for AR is

 11 votes -- Praveen Saini ( 34299 points)

8.196 Regular Expressions: DFA for the given regular expressions top gateoverflow.in/13189

1. (aa*)b
2. (abab)+(aaa+b)*

regular-expressions


Selected Answer

DFA for L((aa*)b) is

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1097 of 2244

DFA for L((abab+(aaa+b)*) is

 5 votes -- Praveen Saini ( 34299 points)

8.197 Regular Expressions: Regular Expression top gateoverflow.in/31229

can anyone help me with regular expression for-

a)set of all strings with equal number of 0s and 1s such that no prefix has 2 more than 0s than 1s nor 2 more than 1's than
0's.

b) set of all strings of 0s and 1s whose number of 0s is divisible by 5 and whose number of 1's is even.

theory-of-computation regular-expressions

8.198 Regular Expressions: Toc theorem proof top gateoverflow.in/2426

How ϕ ∗ = ϵ?

theory-of-computation regular-expressions proof


Selected Answer

ϕ = {}, which is empty set. Now by definition of *, it repeats the content of a set ZERO or more times. And anything
repeated zero time is ϵ. And nothing repeated 1 or more times is nothing.

So, ϕ ∗ generates the language {ϵ} whose regular expression is ϵ. Hence,

ϕ∗ = ϵ

It can be also shown as:

a ∗ generates {ϵ, a, aa, aaa, . . . . }


ϕ ∗ generates {ϵ}

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1098 of 2244

 6 votes -- Arjun Suresh ( 124125 points)

8.199 Regular Expressions: regular exp[ression top gateoverflow.in/42665

Which of the following regular expression identities are true ?

(A) (r + s)* = r* s*

(B) (r + s)* = r* + s*

(C) (r + s)* = (r*s*)*

(D) r* s* = r* + s*

regular-expressions


Selected Answer

C (r + s)* = (r*s*)*

 2 votes -- Manojk ( 3365 points)

8.200 Regular Expressions: Regular expression top gateoverflow.in/35276

Which of the following regular expr. Generate set of all strings not containing 100 as substring.

a. 0*(1+0)*

b 0*1010*

c. 0*1*01

d. 0 *(0+1)*

I think none of them is correct one

Ans should be 0 *(1+01)*

theory-of-computation regular-expressions


Selected Answer

None of them is correct

a) can generate strings having 100 bcoz of (0 + 1) ∗

d) same reason as above

b) can generate strings having 100 bcoz of 10 ∗

c) cannot generate strings ending with 0 but doesn't contain 100.

Here is correct regular expression for it. (there may be another regular expression equivalent to it)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1099 of 2244

 4 votes -- Praveen Saini ( 34299 points)

8.201 Regular Expressions: What is the Regular Expression for top gateoverflow.in/26894

The regular expression for the language recognized by the following Finite State Automaton is?

A. 0 ∗ ∣ 0 ∗ 1 +
B. 0 ∗ ∣ 11 ∗
C. 0 ∗ ∣ 0 ∗ 1 + ∣ 0 ∗ 1 + (0 + 1) ∗
D. None of these.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1100 of 2244

regular-expressions finite-automata


Selected Answer

Using Arden's Theorem

A= ∈ + A0 - - - - I

B = A1 + B1--------II

C = B0+ C0+ C1 -- - - III

Apply Arden's Theorem in I

​A= ∈0* = 0* - - - IV

​Put IV in II

​B = 0*1 + B1

apply arden's theorem

​B = 0*11* =0*1 + - - - - V

both A and B are final states

​Regular expression = A + B

= 0* +0*1 +

Option a.

[ Note:Arden's Theorem : if R = Q+RP then R=QP*

No need to find C as it is dead state]

 2 votes -- Praveen Saini ( 34299 points)

8.202 Regular Expressions: Which one is ambiguous? top gateoverflow.in/17930

regular-expressions theory-of-computation


Selected Answer

non of these since all grammar are left linear! (grammar is ambiguous only if it is left and right linear both).

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1101 of 2244

there is only one derivation tree for each production.

 0 votes -- Umang Raman ( 10379 points)

8.203 Regular Expressions: equivalent regular expression? top gateoverflow.in/7424

Assume R1 , R2 , and R3 are three regular expressions.

Given R1 + R2 ⋅ R3 = (R1 + R2 ) ⋅ (R1 + R3 ) for any R2 and R3 . Which of the following could be correct condition which always satisfies
the above equation.

1. R1 = R2

2. R1 = R3

3. R1 = ∅

A) only 1 and 2 are correct

B) only 1 and 3 are correct

C) only 2 and 3 are correct

D) 1,2, and 3 are correct

Answer is given as D

regular-expressions theory-of-computation


Selected Answer

(R1+R2) (R1+R3) = R1R1 + R1R3 + R2R1 + R2R3

Now, R1 = R2 => LHS = R1 + R2R3 = R1 + R1R3


RHS = R1R1 + R1R3 + R1R1 + R1R1

So, they are not equal. For example consider R1 = R2 = a, R3 = b. LHS = a + ab, RHS = aa + ab

When R1 = R3, LHS = R1 + R2R1


RHS = R1R1 + R1R1 + R2R1 + R2R1, again not equal. For example, R1 = R3 = a, R2 = b, LHS = a + ba, RHS = aa + ba

When R1 = ϕ,

LHS = ϕ + R2.R3 = R2.R3


RHS = (ϕ + R2).(ϕ + R3) = R2.R3, hence equal.

 4 votes -- Arjun Suresh ( 124125 points)

8.204 Regular Expressions: regular expression top gateoverflow.in/16976

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1102 of 2244

regular-expressions

Alphabet: {0, 1}

There could be more than one Regular Expressions expressing the same Language.

I came up with the following:

a) All strings ending with 01:

(0 + 1)*01

b) All strings not ending with 01 :

(0 + 1)*(00 + 10 + 11) + (epsilon + 1 + 0) OR

(1 + 0( 0 + 10)*11)* + (1 + 0( 0 + 10)*11)*0(0 + 10)*

c) All strings with even 0’s

(1 + 01*0)*

d) All strings containing 00 at least twice:

(1 + 01)*00(0 + 1(1 + 01)*00)(0 + 1)*

e) All strings containing 00 at most twice:

(1 + 01)* + (1 + 01)*0 + (1 + 01)*00 + (1 + 01)*001 + (1 + 01)*0010 + (1 + 01)*00(0 + 1(1 + 01)*00)

f) All strings not containing 101:

(11*00 + 0)* + (11*00 + 0)*(11* + 11*0)

 0 votes -- Anurag Pandey ( 8183 points)

8.204 Regular Expressions: What Language Does this expression represents


( (0 + 1) (0 + 1)*)* 00 (0 + 1)* top gateoverflow.in/43165

theory-of-computation regular-expressions

it same as writing (0+1)*00(0+1)*

L contains strings with atleast 2 zeroes

 1 votes -- sanketg186 ( 97 points)

8.205 Regular Expressions: regular expresstion matching top gateoverflow.in/11280

The regular expression 0*(10)* denotes the same set as:

A) (1*0)*1*

B) 0+(0+10)+

C) (0+1)*10(0+1)*

D) none of the above

well according to me in option A we can get 111111...(many no of one's) without the need of 0, but same is not the case
with the original R.E posted above, where in i have to get 0's in order to get 1's in my strings. <answer given is option A>

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1103 of 2244

what do you say guys??

theory-of-computation regular-expressions


Selected Answer

A can generate "11" but given RE can't

B can generate "100" but given RE can't

C can generate "100" but given RE can't

So, answer must be D- none of these.

 9 votes -- Arjun Suresh ( 124125 points)

yup , you are right . wrong ans given . peace

 2 votes -- Pranay Datta ( 6113 points)

8.206 Regular Language: Determine the type of language top gateoverflow.in/39498

theory-of-computation regular-language

Ans is b

 0 votes -- Sibarpit ( 149 points)

8.207 Regular Language: Homomorphishm operation top gateoverflow.in/35488

If ∑={0,1} ∆={a,b} and h(0)=aa h(1)=bb

And L={ab+ba} *

then what is h(h -1(L)) ?

I knw here h-1(L) is ∅(phi).

theory-of-computation regular-language

8.208 Regular Language: Why this is not a regular language? top gateoverflow.in/32989

Consider following languages :

L1 = { wxwy | x,w,y ∈ (a + b) + } ,

L2 = { xwyw | x,w,y ∈ (a + b) + } ,

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1104 of 2244

L3 = { wxyw | x, y, w ∈ (a+b)+ }

How can we say that L 1 , L 2 are regular but not L 3 ? Please explain.

theory-of-computation regular-language identify-class-language


Selected Answer

{
L1 = wxwy | x, w, y ∈ (a + b) + }
here x, y ∈ (a + b) + means any string having length ≥ 1 ,( and not a big problem).

w must be same at both place having length ≥ 1 , start with a or b


w w
 
w (something) w (something)
   
a(something) x amust be same as earlier y + b(something) x bmust be same as earlier y

Remember x and y can be anything having length ≥ 1 , i.e, belong to (a + b) + , we are flexible with the length of x and y ,
except 0 length .

∈ (a +b ) + ∈ (a +b ) + ∈ (a +b ) + ∈ (a +b ) +
   
(something)x (something)y (something)x (something)y
a a + b b

here if something is not same, we can say that something is part of x and y respectively and w is simple a or b, rest is x
and y.

a(a + b) + a(a + b) + + b(a + b) + b(a + b) +

In simple words , here x and y can absorb rest of the strings

L1 is Regular.

{
L2 = xwyw | x, w, y ∈ (a + b) + }
w must be same at both place having length ≥ 1 , end with a or b


w w
 
w (something) w (something)
   
must be same as earliera must be same as earlierb
x (something)a y + x (something)b y

∈ (a +b ) + ∈ (a +b ) + ∈ (a +b ) + ∈ (a +b ) +
   
x(something) a y(something) a + x(something) b y(something) b

here if something is not same, we can say that something is part of x and y respectively and w is simple a or b, rest is x
and y.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1105 of 2244

(a + b) + a(a + b) + a + (a + b) + b(a + b) + b

In simple words , here x and y can absorb rest of the strings

L2 is Regular.

{
L3 = wxyw | x, w, y ∈ (a + b) + }
w must be same at both place having length ≥ 1 , start with a or b


w w
 
w (something) w (something)
   
a(something) amust be same as earlier b(something) bmust be same as earlier
xy + xy


Problem Problem
 
∈ (a +b ) + (something) ∈ (a +b ) + (something)
   
must be same as earlier must be same as earlier
a (something)x y a + b (something)x y b

Problem is that, there is x in right of first something , if both did not same we can say ,that can be part of x, but there is
no x or y in left/right of second something, to absorb that. ( and there is a or b , that must be remain unchanged.)

L3 is not regular.

 10 votes -- Praveen Saini ( 34299 points)

8.209 Regular Language: Why is (a + b)* a regular language? top gateoverflow.in/42932

The language (a+b)* is regular as there is a regular expression for it.But this language contains all possible strings. So it
should imply that regular language is the super-set of all languages, but clearly it isn't!

Subsets like an bn are not regular. Can someone tell me what am I missing?

regular-language theory-of-computation


Selected Answer

Let D be a regular set. So, D contains a set of strings which all can be accepted by a FA.

Now, CFL ⊃ RL.

This means set of all context-free languages (not set of strings, rather set of set of strings), is a super set of set of all
regular languages. No need to prove this as every regular language is a CFL and there are CFLs which are not regular.

Individually there may or may not be any subset/superset relation between a regular language and a CFL. (The relation is
between set of all regular languages (RL) and set of all context-free languages (CFL)). For example the regular set {} is a
subset of any CFL and the regular set Σ ∗ is a super set of any CFL.

(Consider Indians (set of people born in India) as a subset of Asians. Now can we say an Indian - say "Mohan" a subset of
an Asian "Lee"?)

 3 votes -- Arjun Suresh ( 124125 points)

Every subset of regular language is may or may not be Regular.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1106 of 2244

e.g: a*b* is a Regular Language than an bn ⊆ a ∗ b ∗ ; n ≥ 0 and its not Regular.


(or)

Let take ambn than its subset 'aabb' string is not Regular . (i.e anbn ⊆ ambn)

Similarly,

Every superset of Regular language is may or may not be regular.


e.g: If Empty language \o is Regular than its superset an bn need not be Regular, where n ≥ 0.

Therefore, according to the properties of regular languages, it is not closed under subset or superset.

 1 votes -- Gate Aspirant Mkr ( 79 points)

8.210 Regular Language: transition diagram for the given regular language top
gateoverflow.in/35466

L={wxwr ∣ w,x∈(a,b) *}

Is this language regular language?

Plz give transition diagram or table?

theory-of-computation regular-language


Selected Answer

L = {wxwR ∣ w, x ∈ {a, b} ∗ }

Language is regular , we can get all string over {a, b} from x by putting w = ϵ.

Regular expression is (a + b) ∗

 4 votes -- Praveen Saini ( 34299 points)

8.211 Regular Language: Identify the language accepted by the following


NFA with ∈ -moves. top gateoverflow.in/28993

Identify the language accepted by the following NFA with ∈ -moves.

All strings over a's and b's


All strings which do not contain aa

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1107 of 2244

All strings which do not contain bb


None of these

----------------------------------------------------------------------------------------------------

Made Easy Q 11, FLT 6- Practice Test 14

Here issue is that this language accepts (a+b) +

So my question is that ->

Do we include empty string in "All strings over a's and b's", to be honest I feel that answer given is incorrect, & IT should
have been "All strings over a's and b's". Because empty string is not really a string which we should count over any alphabet.
If they have said (a+b)* as first option , it was easy & Clear. But using words instead of precise notation , makes this
question confusing. Please answer this question, what should be correct answer.

theory-of-computation regular-language


Selected Answer

Above FA is accepting all strings over a and b excluding empty string so ans should be D.

[option A, all strings over {a, b}, means all strings starting from length 0, if something not explicitly given]

 4 votes -- Pooja ( 22773 points)

8.212 Regular Language: Regular/Non-regular Language top gateoverflow.in/29610

Consider the following subsets of {a, b, $} ∗


A= {xy | x, y ∈ {a, b} , #a(x) = #b(y) },

B = {x$y | x, y ∈ {a, b} , #a(x) = #b(y) }


Which of the following statements are true?


(A) A and B both are regular
(B) A is regular but B is not
(C) A is not regular but B is regular
(D) Both are non-regular

regular-language theory-of-computation


Selected Answer

A= {xy | x, y ∈ {a, b} , #a(x) = #b(y) } is regular and is (a + b)


∗ ∗

As any string can be break in to x and y where no of a ′ s in x = no of b ′ s in y, here we are flexible in choosing length of x and
y as per our choice.

example 1: xy = aaaaa, x = ϵ ,y = aaaaa

example 2:xy = bbbabbbbaa, x = bbbabbb, y = baa

And try any other string. remember we are flexible with length of x and y.

B= {x$y | x, y ∈ {a, b} , #a(x) = #b(y) } is non-regular.


As we need to push a ′ s of x into stack and need to pop them with b ′ s of y.

whatever is there before $ is x and after $ is y . we can't choose them .

 10 votes -- Praveen Saini ( 34299 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1108 of 2244

8.212 Regular Language: if w ∈ (a + b) ∗ satisfies abw = wab, then length(w) is ? top


gateoverflow.in/28044

regular-expressions regular-language theory-of-computation


Selected Answer

abw = wab

one of solution is, w = (ab)*

[w can be any string ∈ (ab)* ]

So length of W must be even for sure.


(But all even length string ∈{a,b}* may not satisfy ab W = Wab)

 2 votes -- Digvijay Pandey ( 26245 points)

8.213 Regular Language: Choose the regular set. top gateoverflow.in/25463

Choose the regular set

{
A. wwRwwRww ∣ w ∈ {a, b} + }
B. { n
a2 an ! apq ∣ p prime, q not prime, n ≥ 1 }
{
C. wXwR ∣ w, X ∈ {a, b} + }
D. {a b a b a b ∣ i, j ≥ 1 }
i j i j i j

regular-language identify-class-language


Selected Answer

for any string in the language represented by option C

we can have a X such that first and last symbol of the string are same.

so, due to the presence of that X language is reduced to the language definition where the first and the last symbol are
same

Hence, that can be accepted by a DFA. Therefore, the option C is Regular

 3 votes -- Amar Vashishth ( 17865 points)

8.213 Regular Language: find all strings in ((a+b)*b(a+ab)*) of length less


then 4. top gateoverflow.in/43164

theory-of-computation regular-expressions regular-language

ba

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1109 of 2244

bb

ab

baa

bab

bbb

bba

abb

aab

aba

 1 votes -- srestha ( 11585 points)

8.214 Regular Language: Is this language regular? top gateoverflow.in/16816

Is L={0, 011, 011000, 0110001111, ....} a regular language?

I know that the language should follow some regular pattern and we should be able to construct a regex for it in order to say
it a RL. Morever it shouldnt require any kind of extra memory to store the counts.

BUT, in this given language, I can see a regular pattern, but I am not able to construct a regex. And I think that prevois
count should be remembered by the m/c.. So it should be NRL. But my book says its a RL. I am not getting how??

P.S. I wud be thankful if somebody suggests a quick method to identify given set to be RL or NRL based on pattern.

Thanks in advance :)

regular-language theory-of-computation regular-expressions regular-set

Did NOT looks like a regular language. Instead of analysing the exact pattern and positions of 1's and 0's in the strings of
the language, try to count the number of 0's and 1's. You will notice that, if the number of 0's in any string of this
language is i^2, then the number of 1's have to be either (i^2 + i) or (i^2 - i). I don't think that this dependency can be
preserved by any regular language. Even it does not seems like a Context Free Language to me.

 1 votes -- Anurag Pandey ( 8183 points)

8.215 Regular Language: Is the language regular top gateoverflow.in/18030

L={s belongs to (0+1)*| for every prefix s' of s|n0(s')-n1(s')<=2} where n0 is number of 0s and n1 is number of 1s.Is this
regular?If yes then why

theory-of-computation regular-language

http://gateoverflow.in/992/gate2006_29

 0 votes -- Arjun Suresh ( 124125 points)

8.216 Regular Language: Why is a nb n ∪ a ∗ b ∗ regular ? top gateoverflow.in/17829

Why is an bn ∪ a ∗ b ∗ regular ?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1110 of 2244

Does this imply that a subset of non regular language can be regular ?

theory-of-computation finite-automata regular-expressions regular-language


Selected Answer

It is necessary to understand the set of strings that are accepted by both the languages.

a^n b^n = {∈, ab,aabb, aaabbb, aaaabbbb, aaaaabbbbb,...........}

a*b*= {∈, a, b, aa, ab, aab, aabb, abbb, aabbbb,aaabbb,aaabb, aaaabbbb,........}

Clearly former one is the subset of later one.

So when union is done on the two languages, the resultant language is the later one i.e. a*b*, which is a regular language.
Hence the union of the two is a regular language.

The empty language is a regular subset of any language at all.

More generally, every finite subset of any language is regular.

be the language .

Let be the subset of consisting just of {aa, aaaaa,aaaaaaaaaaa}.

Then L is not regular but R is.

 4 votes -- admin ( 1411 points)

a*b* U a^nb^n = a*b*. That's why it is regular.

No it does not imply that a subset of non regular language can be regular.

It implies that subset of regular language can be non regular !

In fact every non regular language is subset of regular Language Σ* !

 1 votes -- Akash ( 26315 points)

8.217 Regular Language: regular language top gateoverflow.in/39224

Let L1,L2 be two arbitarily language then state true or false-:

please give proper explanation...

1)if L1.L2 is regular then is L1,L2 regular too?

2) if L1.L2 is regular then is L2.L1 is regular too?

theory-of-computation regular-language regular-set


Selected Answer

Let

L1 = {ap ∣ p is prime}, and L2 = {an bm ∣ m, n ≥ 0}

then L1 . L2 = {aibj ∣ i ≥ 2, j ≥ 0} is Regular.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1111 of 2244

and L2 . L1 = {aibjap ∣ i, j ≥ 0, p is prime} is Non-regular.

So both statement are false.

 14 votes -- Praveen Saini ( 34299 points)

8.218 Regular Language: Regular Language top gateoverflow.in/17912

Is {xww ∣ w, x ∈ (a + b) + } regular because there is no restriction on the max length of x ?

As mush as I know, if there is no restriction on the maximum value of x, then it can expand as much as to cover ww, making
the language regular. Please correct me if I am wrong.

theory-of-computation regular-set regular-expressions regular-language

hodor it's nor regular as there always have to some x . which does not matter . but what matter is there always should be
a "w".

and if there is aways a W string no way to check.

if it was xww where x,w belongs to (a+b)* then it was regular as what ever u give as w i will always consider it as zero.
and will consider whole string in x . so if i put w = null . then

language will become x which will be (a+b)* as x belong to (a+b)*.

i think it will be little bit tough to understand but i prefer to visit gate cse regular language page
http://gatecse.in/wiki/Identify_the_class_of_the_language

 1 votes -- Ravi Singh ( 7303 points)

8.219 Regular Language: Which of these is/are CFGs top gateoverflow.in/17932

regular-language theory-of-computation regular-expressions

i) is cfl,but not dcfl,since there is non determinism (by seeing b,when top of stack is a, you can either pop it or dont do
anything and wait for c and pop one a for every c and if by the end all a's are popped for every c u can accept it or if all
a's are pooped and sill c's remain.

ii)clearly csl.

iii)cfl but again not dcfl, as u can match either a's and b's or you can see whether no of a's <> no of c's(for each c pop
one a, if at the end atleast one a remain on tos and i/p string in empty or all a's are popped off still at least one c remain
on tos u can accept it.)

iv) regular language (a*b*c*)


so option i,iii) & iv)

 0 votes -- Suvam Chatterjee ( 185 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1112 of 2244

8.220 Regular Language: Which of the following statements is/are True? top
gateoverflow.in/14984
(a) If R is regular and N is non-regular, then there exists R + N, which is regular.

(b) If R is regular and N is non-regular, then there exists R + N, which is non-regular.

regular-language


Selected Answer

dont know what is + sign here because R and N used as SET.

if it is Union then ,

1. R= (a+b)*, N = a^nb^n , n>=0

R U N = (a+b)* which is regular.

2.R = phi, N = a^nb^n, n>=0

R U N = a^nb^n, n>=0

both are true (bcoz in options they said THERE EXIST )

(in general both are true but for a particular case where L and N is precisely given it may not holds true).

 3 votes -- Digvijay Pandey ( 26245 points)

8.221 Regular Set: Is this language regular? top gateoverflow.in/14985

L = {an bm ∣ (n + m) is even}

regular-set

Yes.

(aa) ∗ (bb) ∗ + a(aa) ∗ b(bb) ∗ will be the regular expression.

 8 votes -- Arjun Suresh ( 124125 points)

8.222 Regular Set: proof regarding infinite union/intesection top gateoverflow.in/3078

Q1:Prove that Regular Sets are NOT closed under infinite union. (A counterexample suffices).

Ans1: Consider the sets {0}, {01}, {0011}, etc. Each one is regular because it only contains one string. But the infinite
union is the set {0i1i | i>=0} which we know is not regular. So the infinite union cannot be closed for regular languages.

Q2: What about infinite intersection?

Ans2: We know that

{0i1i | i>=0} = {0} U {01} U {0011} U ...,

Taking complements and applying DeMorgan's law gives us

{0i1i | i>=0} c = {0}c ^ {01} c ^ {0011} c ^ ...,

Where we are using U to deonte union and ^ to denote intersection. Recall the complement of a regular language is regular,
and hence the complement of a not-regular language is not regular. So we can conclude that the left hand side of the
equation is not-regular, and each term in the intersection is regular. Therefore infinite intersection does not preserve
regularity.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1113 of 2244

Please explain what is infinite union/ infinite intersection and also explain the answer

This question is from aduni.org

theory-of-computation regular-set

Infinite union means we do union operation infinite (uncountably many) times, same with infinite intersection.

 1 votes -- Arjun Suresh ( 124125 points)

8.223 Regular Set: REGULAR EXPRESSION - Inverse homomorphism top gateoverflow.in/33920

Let r = (10 + 0) * 11(0 + 1) * be a regular expression for the regular language L and let h(0) = ab and h(1) = ba a
homomorphism. What is a regular expression for h(L)? How about h −1 (L′) if L′ is given by the regular expression r ′ = (ab
+ a) * bb(a + b) *?

theory-of-computation regular-expressions regular-set

8.224 Regular Set: equal number of sequence, is language regular ? top gateoverflow.in/15130

L1= Set of all strings having equal number of 00 and 11.


L2= Set of all strings having equal number of 01 and 10.
(a) Both are Regular (b) Both are Context-Free
(c) L1 is regular, L2 is Context Free (d) L1 is CF, L2 is Regular

theory-of-computation regular-set


Selected Answer

L1 is well known Non Regular i.e. (00)^n(11)^n. (Since there is no common character in "00" and "11" we need to keep
count of both which is not possible with a finite automata as count can be infinite).

L2 is regular and its regular Expression like 0(0+1)*0 + 1(1+0)*1 + 1 + 0 +epsilon.

 4 votes -- Digvijay Pandey ( 26245 points)

8.225 Regular Set: Let L be a regular language top gateoverflow.in/173

Let L be a regular language and w be a string in L. If w can be split into x, y and z such that | xy | ≤ number of states in the
minimal DFA for L, and | y | > 0 then,

(A) ∀i ∈ N, xyiz ∉ L

(B) ∃i ∈ N, xyiz ∈ L

(C) ∀i ∈ N, xyiz ∈ L

(D) ∃i ∈ N, xyiz ∉ L

theory-of-computation easy regular-set


Selected Answer

(C) ∀i ∈ N, xyiz ∈ L

This is the result of Pumping Lemma for regular language

 6 votes -- Keith Kr ( 5467 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1114 of 2244

8.226 Regular Set: Which of the following are useful in proving a language to
be regular? top gateoverflow.in/174

Which of the following are useful in proving a language to be regular?

1. Myhill-Nerode theorem
2. Pumping lemma
3. Drawing an NFA
4. Forming a regular expression

(A) All of these

(B) 1, 3 and 4 only

(C) 2, 3 and 4 only

(D) 3 and 4 only

theory-of-computation regular-set normal


Selected Answer

(B)1, 3 and 4 only

As from the given options, Myhill-Nerode theorem is useful by providing necessary and sufficient condition for proving that
a language regular. Pumping lemma is often used to prove that a language is non-regular. Drawing an NFA can be useful
to prove a language is regular. Forming a regular expression can also help us prove if it is a regular language

 6 votes -- Keith Kr ( 5467 points)

8.227 Regular Set: Subset of a Regular Expression top gateoverflow.in/30668

Consider the regular expression R = (a + b) ∗ a(ab) ∗ + ϵ.


Which of the following are possible as subset of R?

(i) (aa) ∗ (ii) (ba) ∗ (iii) (aa) ∗ (ba) ∗

a. (i) and (ii) only

b. (ii) and (iii) only

c. (i),(ii) and (iii)

d. None of these.

theory-of-computation regular-expressions regular-set

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1115 of 2244


Selected Answer

see what the regular expression given is doing. it will generate all string having atleast one a and it will also generate null.
now all option are either generating null or the minimum instance is containing an a. so the condition atleast on a will get
satisfied so all are subsets.

 2 votes -- Ravi Singh ( 7303 points)

The given regular expression can generate empty string or a string containing a.
(aa)* - This can be generated by the given regular expression.
(ba)* - This could also be generated by the given regular expression.
(aa)*(ba)* - This could also be generated by the given regular expression.

Therefore, all are possible. So. option C is correct.

 1 votes -- Monanshi Jain ( 5827 points)

8.228 Regular Set: L is regular or not?? top gateoverflow.in/4300

Let ∑ = {a, b} and Let L = { w | w contains an equal no of occurrences of substring 'ab' and 'ba' }. Thus aba ∈ L since
'aba' contains one occurrence of 'ab' and one occurence of 'ba' but abab ∉ L.

Then which of the following is TRUE?

Select one:

A. L is regular.

B. L is DCFL but not regular.

C. L is CFL but not regular.

D. L is recursive but not a CFL.

theory-of-computation regular-set normal

There can be no direct step-wise procedure to solve such questions.In the above question, we need to check option wise.

A language is said to be regular if you can construct a finite automaton for it. Here is the DFA for required language.

 4 votes -- Shridhar ( 383 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1116 of 2244

L is regular. Because we cannot have two ab in a string without having a ba or vice-verse. So, there are only 3 states
possible- one where number of "ab" and "ba" are same, one where number of "ab" is 1 more than number of "ba" and the
final one where number of "ba" is 1 more than number of "ab". So, we just need a finite state automata to represent this.

 2 votes -- Arjun Suresh ( 124125 points)

8.229 Regular Set: Given that a language LA = L1 U L2, top gateoverflow.in/3876

Given that a language LA = L1 ∪ L2 , where L1 and L2 are two other languages. If LA is known to be a regular language, then
which of the following statements is necessarily TRUE?

A. If L1 is regular then L2 will also be regular


B. If L1 is regular and finite then L2 will be regular
C. If L1 is regular and finite then L2 will also be regular and finite
D. None of these

theory-of-computation regular-set normal


Selected Answer

(b) is the answer because we cannot make an irregular set S regular, by adding a finite number of elements to it. This can
be proved as follows:

Let R ∪ F = T be regular, where F is a finite set.

R ∪ (F − R) = T (both the sets are now disjoint)

 R = T − (F − R)  R = T ∩ (F − R) ′

Now T is regular set and F is a finite set and so F-R must also be finite and hence regular also. Regular set is closed under
complement and intersection which makes R also regular.

We can prove (a) false be taking L1 = Σ ∗ and L2 = {a b n n


}
∣ n > 0 . Now, union of these is Σ ∗ which is regular but L2 is not
regular.

(c) can be proved false by taking L1 = {a} and L2 = {a n


}
∣ n > 0 . Now L1 ∪ L2 is regular and L1 finite but L2 is not finite.

 8 votes -- Arjun Suresh ( 124125 points)

8.230 Regular Set: which of the following is always regular top gateoverflow.in/5068

Let P be a regular language and Q be a context free language such that Q ⊂ P.

Which of the following is always regular ?

(A) P ∩ Q

(B) P-Q

(C) Σ* - P

(D) Σ* - Q

theory-of-computation regular-set


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1117 of 2244

Option C. As Regular languages are closed under complement

A. P ∩ Q won't be regular, if P = Σ ∗ and Q is a CFL but not regular.

ˉ
B. P − Q won't be regular when P = Σ ∗ and Q is a CFL as this will be Q and CFL complement need not even be CFL.

D. This is CFL complement and this need not even be CFL.

 5 votes -- shreya ghosh ( 2801 points)

8.231 Rel: madeeasy test series pracice test 5 toc q-26 top gateoverflow.in/37102

Which of the following language is recursively enumerable language?

{< M > | M is a TM and there exist an input whose length is less than 100, on which M halts}
{< M > | M is a TM and L(M) = {00, 11}}
{M1, M2, M3 | L(M 1) = L(M 2) ∪ L(M3)}
All of these

Ans:- 1st language is REL

why not 2nd language ??

theory-of-computation madeeasy-testseries rel

8.232 Testbook: TestBook Live Test 1 Q No 9 top gateoverflow.in/36119

Only way NFA of 6 states can be reduced to DFA of one state if all remaining 5 states of NFA are useless (Unreachable etc) &
THere are no Dead State. In any normal NFA without useless states, I think we need at least same no of states in DFA (Think
about NFA which is just DFA with minimal states. !) I do not agree to 1 , as it means that all states other than start state in
NFA was useless.

test-series theory-of-computation testbook


Selected Answer

Consider an NFA for Σ ∗ , one which has 6 states. Every state is an accepting state, and every state is reachable. The
organisation of the transitions is irrelevant.

Now, there are 5 redundant (but reachable) states in this NFA.

The corresponding DFA will have just 1 state.

Regarding "Why would someone have an NFA with 5 redundant states?", that is a different question, the answer to which
doesn't affect the fact that there can be a DFA of 1 state for an NFA of 6 states.

Consider a person who is trying to convert a complicated regex into an NFA. It might not be obvious from the regex that it
is reducible to Σ ∗ , and it might not be obvious from the NFA either. So, that makes a valid usecase for an NFA with 6
states with majority of them being redundant.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1118 of 2244

 3 votes -- Pragy Agarwal ( 13675 points)

8.233 Time Complexity: running time of NFA to DFA top gateoverflow.in/28051

running time of NFA to DFA conversion including the case where NFA has ϵ-transition is ?

theory-of-computation time-complexity


Selected Answer

For a given NFA of n state, number of states in equivalent DFA is atmost 2 n.

Worst case complexity is O(2n).

 5 votes -- Digvijay Pandey ( 26245 points)

8.234 Turing Machine: L(M) = Σ* top gateoverflow.in/79

L = {⟨M⟩ ∣ L(M) = Σ ∗ }

A. L is RE but L ′ is not RE

B. Both L and L ′ are RE

C. L is not RE but L ′ is RE

D. Both L and L ′ are not RE

theory-of-computation turing-machine decidability difficult


Selected Answer

Yes. Both L and L' are not RE. We can have the same reduction as done for L(M) is infinite.

Lets assume L is RE. So, we have a TM N which will say "yes" if given an encoding of a TM whose language is Σ ∗ . Now
using N we try to solve non-halting problem as follows:

A non halting problem is given as follows: Given an encoding of TM <H> and a word w, whether H does not halt on w.
That is, we have to decide if H does not halt on w. This problem is proved to be not RE and so no TM can not even say
"yes" for "yes" case of the problem.

Now, given a halting problem (<H>, w), we proceed as follows: We make a new TM say A, which on input x, just
simulates H on w for |x| steps. If H halts on w, A goes to reject state. Otherwise it accepts. So, L(A) = Σ ∗ if H does not
halt on w and L(A) = a finite set if H halts on w. (If H halts in |x| steps for w, any string with length greater than |w|,
would certainly be not in L, making L a finite set and hence can never equal Σ ∗ ).

Now, we just give the encoding of A to our assumed TM N. If N says "accept", we have that L(A) is Σ ∗ => H does not halt
on w => we solved "yes" case of not halting problem, which is not possible. Hence, our initial assumption of L is RE is
false. L is not RE.

Proving L' is not RE is easy.

L' = {<M> | L(M) is not equal to Σ ∗ }

L(M) is not equal to Σ ∗ is a non-monotonic property of TM. Because we can take TM Tyes with L(Tyes) = ϕ and Tno with
L(Tno ) = Σ ∗ . Here, Tyes satisfies the property (of being not being equal to Σ ∗ ) and Tno does not satisfy that property and
L(Tyes) ⊂ L(Tno ), making this a non-monotonic property of TM. And hence this becomes not RE as per Rice's theorem second
part.

So, both L and L' are not RE making (D) the correct answer.

http://gatecse.in/wiki/Rice%27s_Theorem_with_Examples

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1119 of 2244

 3 votes -- gatecse ( 9515 points)

Answer is D

Both the lanuages are not RE

 1 votes -- gauravsachan9188 ( 75 points)

8.235 Turing Machine: L(M) is infinite top gateoverflow.in/78

L = {⟨M⟩ ∣ L(M) is infinite}

A. L is RE but L ′ is not RE

B. Both L and L ′ are RE

C. L is not RE but L ′ is RE

D. Both L and L ′ are not RE

theory-of-computation turing-machine decidability difficult


Selected Answer

Lets assume L is RE. So, we have a TM N which will say "yes" if given an encoding of a TM whose language is infinite. Now
using N we try to solve non-halting problem as follows:

A non halting problem is given as follows: Given an encoding of TM <H> and a word w, whether H does not halt on w.
That is, we have to decide if H does not halt on w. This problem is proved to be not RE and so no TM can not even say
"yes" for "yes" cases of the problem.

Now, given a halting problem (<H>, w), we proceed as follows: We make a new TM say A, which on input x, just
simulates H on w for |x| steps. If H halts on w, A goes to reject state. Otherwise it accepts. So, L(A) = Σ ∗ if H does not
halt on w and L(A) = a finite set if H halts on w. (If H halts in |x| steps for w, any string with length greater than |w|,
would certainly be not in L, making L a finite set).

Now, we just give the encoding of A to our assumed TM N. If N says "accept", we have that L(A) is infinite => H does not
halt on w => we solved "yes" case of not halting problem, which is not possible. Hence, our initial assumption of L is RE is
false. L is not RE.

Proving L' is not RE is easy.


L' = {<M> | L(M) is finite}

L(M) is finite is a non-monotonic property of TM. Because we can take TM Tyes with L(Tyes) = ϕ and Tno with L(Tno ) = Σ ∗ . Here,
Tyes satisfies the property (of being finite) and Tno does not satisfy the property and L(Tyes) ⊂ L(Tno ), making this a non-
monotonic property of TM. And hence this becomes not RE as per Rice's theorem second part.

So, both L and L' are not RE making (D) the correct answer.

http://gatecse.in/wiki/Rice%27s_Theorem_with_Examples

 3 votes -- gatecse ( 9515 points)

8.236 Turing Machine: Equivalence of Turing Machines. top gateoverflow.in/34370

Consider the following two arguments:

"For every non deterministic TM M1 there exists an equivalent deterministic TM M2 recognizing the same
language."

"Equivalence of two Turing Machines is undecidable"

These two arguments seem a bit contradicting.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1120 of 2244

What can be concluded from these two arguments?

turing-machine theory-of-computation


Selected Answer

"For every non deterministic TM M1 there exists an equivalent deterministic TM M2 recognizing the same language."

This statement talks about the trivial property of Turing machines. The power of Turing machines remains unaltered in
deterministic and non deterministic states. We can build a Deterministic machine for every Non Deterministic Turing
machine.

"Equivalence of two Turing Machines is undecidable"

This statement is about the non trivial properties of Turing machines, that is, if you are given two Deterministic Turing
machines, it is undecidable if they both accept the same language. You can not iterate over the ∑ ∗ to check if they are
the same.

In the first statement case we don't need to iterate over the ∑ ∗ set to prove the equivalence whereas in the second case
we need to which makes it undecidable.

 2 votes -- CrimeMasterGoGo ( 2221 points)

8.237 Turing Machine: Consider the following languages top gateoverflow.in/66

Consider the following languages

A = {⟨M⟩ ∣ TM M accepts at most 2 distinct inputs}

B = {⟨M⟩ ∣ TM M accepts more than 2 distinct inputs}

Identify the correct statement from the following:

(A) A is Turing recognizable B is not Turing recognizable

(B) B is Turing recognizable A is not Turing recognizable

(C) Both A and B are Turing recognizable

(D) Neither A nor B is Turing recognizable

turing-machine theory-of-computation normal


Selected Answer

B is the answer- A is not Turing recognizable while B is Turing recognizable.

A is Turing recognizable if TM for A, say TA outputs "yes" for "yes" cases of A- i.e.; when M accepts at most 2 distinct
inputs. But M can loop forever without accepting more than 2 distinct inputs and we can never be sure if it will or will not
accept any more input. Thus, TA may not output "yes" for "yes" cases of the language and hence A is not Turing
recognizable.

Similarly, B is Turing recognizable if TM for B, say TB outputs "yes" for "yes" cases of B- i.e.; when M accepts more than 2
distinct inputs. If M is accepting more than 2 distinct inputs, it's possible to enumerate all strings from the language
(strings of length 1 followed by strings of length 2 and so on ) and feed to M. (We should use [ dovetailing][1] technique
so that even if some string causes TM to loop forever, we can continue progress). If M is accepting more than 2 distinct
inputs we are sure that we'll encounter those strings after some finite moves of the TM. Thus TB can always output "yes"
for "yes" cases of the language and hence B is Turing recognizable.

(It's easier to see that A and B are complement to each other. TM can say "yes" for "yes" cases of B means it can say
"no" for "no" cases of A. But to make A Turing recognizable we need the output "yes" for "yes" cases of A, which is not
the case here. )

(Once we prove that B is Turing recognizable but not Turing acceptable (recursive), there is no need to check for A. The
complement of a Turing recognizable but not Turing acceptable language is always not Turing recognizable.)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1121 of 2244

[1]: http://www.xamuel.com/dovetailing/

 5 votes -- Arjun Suresh ( 124125 points)

8.238 Turing Machine: Relationship between Problems and Languages gateoverflow.in/14964

top

Is there a one to one correspondence between problems and languages? we interchangeably use these while discussing
decidabilility and turing machines

turing-machine decidability

no atleast now i can say they don't have one to one correspondance . same language can define more than one problem.
one problem can be a subset of another problem so more than one problem can map to more than language for example.
all number divisible by 9 will be divisible by 3 also if n>9. so language defining one problem can also define another
problem so no one to one correspondance possible

 0 votes -- Ravi Singh ( 7303 points)

8.239 Turing Machine: Which of the folowing are R.E top gateoverflow.in/19947

Which of the following problem(s) is/are Recursively enumerable or its complement is recursively enumerable?

I. The language of all Turing machines that accept nothing.

II. The language of all Turing machines that accept everything.

III. The language of all CFG’s that are ambiguous.

turing-machine recursive-recursively-enumerable


Selected Answer

1. L1 = {⟨M⟩ ∣ L(M) = ϕ}

2. L2 = {⟨M⟩ ∣ L(M) = Σ } ∗

3. L3 = {⟨G⟩ ∣ G is ambiguous }

All 3 languages are not recursive.

L1 and L2 are not even recursively enumerable.

L1 not being recursively enumerable can be proved by Rice's theorem part 2 using Tyes and Tno such that L(Tyes) = ϕ and
L(Tno ) = {a} (any non-empty set) thus L(Tyes) ⊂ L(Tno ).

Proof for L2 being not recursively enumerable is shown here.

L1 ′ is recursively enumerable as here we can fed the TM all strings from the language and as long as it is accepting a
string, we are guaranteed to stop at some point.

L2 ′ is not even recursively enumerable. Again we can use Rice's second theorem for this using Tyes and Tno such that
L(Tyes = ϕ (any set other than Σ ∗ would do) and L(Tno ) = Σ ∗ thus L(Tyes) ⊂ L(Tno ).

Proof for L3 being undecidable can be done by reduction from Post Correspondence Problem . But L3 must be recursively
enumerable as here we have to check if a given grammar is ambiguous- we can take each word from L and see if multiple
parse tree exists- as long as grammar is ambiguous, we will eventually get a word for which there are multiple parse
trees. L3 being recursively enumerable but not recursive would mean L3 ′ is not recursively enumerable.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1122 of 2244

 2 votes -- Arjun Suresh ( 124125 points)

8.240 Turing Machine: Turing machine top gateoverflow.in/36037

Construct TM tht accept al string of a's and b's where each string is even length palindrome.(here qf is final state, q0 initial
state and B blank symbol)

Right now this TM accepting all palindrome string.

If pink arrow term is replaced with halt then this TM will accept even length palindrome only and if green arrow terms are
replaced with halt thn this TM will accept odd length palindrome only.

I am not sure if I m doing it right. Plz let me know my mistakes

turing-machine theory-of-computation


Selected Answer

Here we have TM for Palindrome

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1123 of 2244

Here we have marked 3 transitions as (1), (2) and (3)

if we removed (2) and (3) from it, It will be only for Even Palindrome

if we removed (1) from it, it will be for Odd palindrome

else it is for General Palindrome.

 1 votes -- Praveen Saini ( 34299 points)

8.241 Turing Machine: Number of symbols necessary to simulate a TM gateoverflow.in/25157

top

The number of symbols necessary to simulate a TM with m symbols and n states is ?

A. m + n
B. 8mn + 4m
C. mn
D. 4mn + m

turing-machine

answer = option D

How 4mn + m is the answer? don't know. A teacher who has been teaching TOC for GATE for many year told that he
couldn't find the solution to this question, but that's the answer for it.

Solution:
We are required to simulate this turing machine. This means that we need an alternative turing machine(coz it asks how
many symbols do we need) that can function like this turing machine but have symbols which are among one of the options
below.

Now to see how option D 4mn + m works,

Consider an alternative turing machine B such that it has only 2 internal states and atmost 4mn + m symbols, can simulate
this turing machine A.

The internal states of B are α and β.

Machine B acts like machine A, by carrying the information of internal state of A via symbols present on its own tape under
the reading head and in the cell of the tape that the reading head of A will visit next(machine B also has a copy of the
input tape which is given to A).

Machine B uses a back and forth bouncing process to keep track of which state A is in and also what elementary symbol is
needed to be put back on the tape, so that its own output matches the output of machine A.
During the bouncing process the symbol printed in the new cell works like a counter that ends on the current state of A
also, retaining information as to the symbol that was printed previously in this cell.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1124 of 2244

The symbol on the tape of machine B should be either m elementary symbols or 4mn more symbols.

We need 4mn more symbols have a generic form :

Bi ,j ,x,y

where, i = {1, 2, 3, 4, …m} corresonds to m symbols


j = {1, 2, 3, 4, …n} corresonds to n internal states of A machine
x = to represent if our bouncing process the cell is transmitting information or receiving it; i.e. what is the machine doing
there Read/Write
y = R or L next move of read pointer of machine B should be towards left or right, this is for that bouncing process

Here, we see that by combination of i, j, x, y we have total number of such symbols present on the tape = m × n × 2 × 2 = 4mn
as earlier defined we need to have elementary symbols on the tape too which are to be same as those in machine A, they
are m in number

so we have a total of 4mn + m symbols for machine B which it can put on the tape.

The operation table of machine B is defined as:

if input tape of machine A contains the symbol A13 then at the corresponding place in input tape of machine B the symbol
present will be B13

One instance of bouncing operation in this method to result in the simulation of machine A is given in the first image
posted in this answer it is in accordance with the given operation table. Using this information we can do a walkthrough
and see that the simulation is possible.

Machine A can be a UTM.

 0 votes -- Amar Vashishth ( 17865 points)

8.242 Turing Machine: what is number of states in following Turing m/c? top
gateoverflow.in/4637

What are the min number of states in Turing machine L={0^n 1^n}

As per below link we need 4 states including final state ....

But cant we do in 3 states....?

For identifying 1st 0 convert it to X(change state from q0 to q1), then bypass all 0 , on reaching 1st 1 convert to Y(change
state from q1 to q2) and move left ....by pass all 0 to reach last X in leftmost end...change state to q0 ...so that we can
again follow same process....but why a change of state is required when all 0s have been converted to X....?Why do we need
q3.....?

http://www.eecs.wsu.edu/~ananth/CptS317/Lectures/TuringMachines.pdf

Please explain..................

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1125 of 2244

theory-of-computation turing-machine


Selected Answer

As per your explanation, first 0 is converted into X, and then reach to first 1 that is converted in Y and so on [ 0 to X, 1 to
Y]

using 3 states, q0,q1 and q2 . [000111BBB.. to XXXYYYBBB..]

Then why we need q3, To ensure all 0's is converted into X, we need to check there is a Y in right of X

[what if we reach q2 to q0, and there is no more 0's at q0]

for example 000111BBB... lead to X00Y11BBB.. leads to XX0YY1BBB.. leads to XXXYYYBBB... using q0,q1,q3.

B is blank symbol.

Then why we need q4, suppose we have input 0001111BBB..

that will lead to XXXYYY1BBB.. that should not be accept in TM.

so q3 ensure there is Y in right of X(all 0's is converted to X ) , q4 to ensure after all Y there is B (Blank symbol)

[ what if 1's are more than 0's]

so 5 states are required.

Our purpose is not only to convert all 0's to X and 1's to Y, but to ensure input of language ( w ∊L) is accepted and else
(w∉ L) is to rejected

 2 votes -- Praveen Saini ( 34299 points)

8.243 Turing Machine: TM top gateoverflow.in/29549

Consider the following turning machine (where,, $ is represent accept the string).

If the string is 01010 then what will be the output?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1126 of 2244

a. 10100
b. 10101
c. 10110
d. 10011

turing-machine


Selected Answer

First

Initially tape has b01010


input tape
current state
and current R/W head position is in red, transition is used as given in TM .


b 01010b b0 1010b b01010b b010 10b b01010b b01010 b b01010b b010 10b b01010b b0 1110b b 00110b b10110b b10110b
q0 q0 q0 q0 q0 q0 q1 q1 q2 q2 q2 q2 q3
→ → → → → → → → → → → → (Accepts)

10110 is the answer.

Second
The above TM is performing 2's complement of the given binary string.

say , b01010b is binary string on input tape, having b as blank symbol.

When we reach at q1, it mean we reach at right end of string.

Now find the first one from the right end, then after that change 0 to 1 and 1 to 0 , reach to left end and accept,halt.

Let's see

01010

1st complement of 01010 = 10101

2's complement = 1'st complement + 1 = 10101+1 = 10110

so reach the right end , find the first 1, that is 010 10 , the move left and change 1 to 0 and 0 to 1, 101 10, that is 2's
complement.

C is the answer.

 2 votes -- Praveen Saini ( 34299 points)

8.244 Turing Machine: Which of the following languages are Recursively


Enumerable language? top gateoverflow.in/7427

Which of the following languages are Recursively Enumerable language?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1127 of 2244

A. {⟨M⟩ ∣ M is a TM and there exist an input whose length is less than 100, on which M halts}
B. {⟨M⟩ ∣ Mis a TM and L(M) = {00, 11}}
C. {⟨M1, M2, M3⟩ ∣ L(M1) = L(M2) ∪ L(M3)}
D. All of these

turing-machine recursive-recursively-enumerable theory-of-computation


Selected Answer

a) is recursively enumerable but not recursive. If there is such an input, then we can say "yes". But for the no case we
cannot decide as we can never be sure that such an input does not exist.

b) is not RE. We can use Rice's 2nd theorem which will be most straightforward. Here we are given the encoding of a TM
and asked if the language of that machine is {00, 11}. (This is different from asking if that machine accepts 00 and 11,
which would be RE). So, now to apply Rice's 2nd theorem, we need to make 2 TMs, TMyes and TM no, with L(TM yes) =
{00,11} and L(TMno) != {00,11} and L(TM yes) subset of L(TM no). (The last condition is for non-monotonicity).
Here, we can easily get a TM no as L(TM no) can be {00, 11, 011} or any subset of sigma star containing {00, 11} except
{00, 11}. Since we get TMyes, and TM no, the given language is not RE.

c) Checking the equivalence of language of 2 TMs itself is not even semi-decidable. So, this is a double non-recursively
enumerable language. We can use Rice's 2'nd theorem here also, by taking L(TMno) = sigma star.

 7 votes -- Arjun Suresh ( 124125 points)

8.245 Virtualgate: virtual gate 2 top gateoverflow.in/39193

Let L1 and L2 be two arbitrary languages, choose incorrect statement(s)

i. if L1 . L2 is regular then L2 . L1 is also regular.


ii. L1 = L2 iff L1 ∖L2 = ϕ and L2 ∖L1 = ϕ.
iii. if L ⊆ Σ ∗ and L is finite, then Σ ∗ ∖L is regular (\ denotes set difference)

A. Only (i)
B. (i) and (ii)
C. (ii) and (iii)
D. All

virtualgate theory-of-computation identify-class-language


Selected Answer

L1 and L2 are two arbitrary languages

Option 1. if L1 . L2 is regular then L2 . L1 is also regular

Let L1 = {ap ∣ p is prime}, and L2 = {an bm ∣ m, n ≥ 0}

then L1 . L2 = {aibj ∣ i ≥ 2, j ≥ 0} is Regular.

and L2 . L1 = {aibjap ∣ i, j ≥ 0, p is prime} is Non-regular.


Option 2. L1 = L2 iff L1 ∖L2 = ϕ and L2 ∖L1 = ϕ

L1 ∖L2 = ϕ means all strings of L1 are present in L2 , and

L2 ∖L1 = ϕ means all strings of L2 are present in L1

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1128 of 2244

option3. if L ⊆ Σ ∗ and L is finite, then Σ ∗ ∖L is regular

L is finite, means L is regular , so Σ ∗ ∖L = Σ ∗ − L is also regular

Only i) is incorrect

 8 votes -- Praveen Saini ( 34299 points)

8.246 Virtualgate: VIRTUALGATE II Q.29 L is surely decidable if - top gateoverflow.in/37977

L is surely decidable if

(A) both L and its complement are not recognizable

(B) L ⊆ {0} ∗

(C) L ≤m{0n 1n ∣ n ≥ 0}

(D) LR is decidable

virtualgate decidability theory-of-computation


Selected Answer

both B and D are true , If L R is decidable then we can easily construct a turing machine which reverses the input and
feeds it to turing machine for LR to get turing machine for L, so L is also decidable . Similarly if L is reducible to L1 = 0 n
1n then as L1 is decidable so L is also decidable.

 1 votes -- Vikram Bhat ( 587 points)

8.247 Virtualgate: virtual gate 2 top gateoverflow.in/39188

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1129 of 2244

virtualgate


Selected Answer

the answer cis right .


4th statement if a->b in polynomial time means that b complexity can't be higher than a . so if b is undecidable a will be
anything lower than undecidable , so it may be decidable .

and for 2 take example . a^p where p is prime and sigma * which is regular , and now pull out intersection .

 1 votes -- Ravi Singh ( 7303 points)

8.248 Virtualgate: VIRTUAL_GATE top gateoverflow.in/37297

Here My explanation is :

I. We run TM for 1,2,3,4,5....n if it stops in any of these then yes otherwise no

II. We run TM for n steps if it stops yes otherwise no

III. We run TM for n, n+1, n+2.....infinity so if it halts we can say yes but if do not halt we can't say anything because we
have to run it infinite number of times

Is my explanation correct?

decidability theory-of-computation virtualgate

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1130 of 2244

Your explaination for third one is not correct. You can not run it for infinity since there should be some limit( memory
limiation) since you are not sure it will halt or not it might be possible it may keep running forever and you are waiting for
halting because you condition atleast one is still satisfied. So, third one is not decidable.

 0 votes -- Vishnu ( 13 points)

8.249 TOC : Complement of RE top gateoverflow.in/33517

Let L be the language over the alphabet Σ={0,1} defined by the regular expression (0 + 1) ∗ 00(0 + 1) ∗ . Which one of the
following regular expressions defines the complement of L?

a) 1 ∗ 01 ∗ 01 ∗

b) (10) ∗ 11(10) ∗

c) (0 + 10) ∗ (1 + ϵ)

d) (1 + 01) ∗ (0 + ϵ)

Why Option 2 is wrong ?

theory-of-computation


Selected Answer

Regular expression given is (0 + 1) ∗ 00(0 + 1) ∗

Language is all strings over {0,1} that contain substring 00

having DFA

complement of DFA

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1131 of 2244

Regular expression is (1 + 01) ∗ (ϵ + 0)

[ it will take 2 mins by state elimination or by arden's theorem to get regular expression, or even without that , check
closures at final 1 that is one of 1 and other is 01, so at final one (1 + 01) ∗ , now concentrate on final 2 , to reach final 2, we
need final 1 followed by 0, that is (1 + 01) ∗ 0 , so regular expression (add both) is (1 + 01) ∗ (ϵ + 0).]

Another way .

a) can generate 00, False

b) can't not generate ϵ, 0, 1 , that cannot contain 00 as substring , as minimum length string generating from regular
expression is 11 False.

c) can generate 00, False

 4 votes -- Praveen Saini ( 34299 points)

8.250 Dead state top gateoverflow.in/33609

If we are asked the number of states in minimum DFA, then we have to count dead state , right ?

theory-of-computation


Selected Answer

If its DFA then we have to count Dead State.

 2 votes -- Sandeep Singh ( 5939 points)

8.251 doubt regarding pda top gateoverflow.in/44115

Why is the answer c??

For any PDA, make a new state and do an epsilon transition to the start state and change the start state to the new state.

Similarly make a new state and make an epsilon transition from all accept states to this new state. Now, make another
new state and make an epsilon transition from the new state to this one and make this final new state the only accept
state.

Thus we get a simple PDA for any given PDA (thanks to epsilon transitions). Now, is this possible without epsilon
transition?

 0 votes -- Arjun Suresh ( 124125 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1132 of 2244

8.252 Which of the following is true? top gateoverflow.in/39125

Consider the following subsets of {a, b, $}*


A = {xy | x, y ∈ {a, b}*, #a(x) = #b(y)},
B = {x$y | x, y ∈ {a, b}*, #a(x) = #b(y)}
Which of the following statements are true?

(A) A and B both are regular


(B) A is regular but B is not
(C) A is not regular but B is regular
(D) Both are non-regular

test-series theory-of-computation

A = {xy | x, y ∈ {a, b}*, #a(x) = #b(y)},


this Language is always regular. Actually it will accept every string from (a+b)*.

B = {x$y | x, y ∈ {a, b}*, #a(x) = #b(y)}


This one is NON REGULAR. we cant find middle element from DFA.

 0 votes -- Digvijay Pandey ( 26245 points)

8.253 ugc net dec12 top gateoverflow.in/43112

Assume, L is regular language. Let


statements S1 and S2 be defined as :
S1 : SQRT(L) = { x| for some y
with |y| = |x|2, xy ∈L}.
S2 : LOG(L) = { x| for some y with
|y| = 2|x|, xy ∈ L}.
Which of the following is true ?
(A) S1 is correct and S2 is not
correct.
(B) Both S1 and S2 are correct.
(C) Both S1 and S2 are not correct.
(D) S1 is not correct and S2 is
correct.


Selected Answer

Both are correct. MAX, MIN, ROOT, HALF, CYCLE, LOG Regular languages are closed under these operations.

 2 votes -- Digvijay Pandey ( 26245 points)

8.254 Regular Expression and strings top gateoverflow.in/38134

Let L 1 = 0*1*, L 2 = 1*0*, L 3 = (0+1)* and L 4 = 0*1*0*. Then the number of strings in the following language L are ________.

L = (L 1 ∩ L2 ) – (L 3 ∩ L4 )

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1133 of 2244


Selected Answer

L 1 = 0*1*, L 2 = 1*0*, L 3 = (0+1)* and L 4 = 0*1*0*

L 1 ∩ L 2 = 0* + 1*
L 3 ∩ L 4 = 0*1*0*

L = (L1 ∩ L 2 ) – (L 3 ∩ L 4 ) = (0* + 1*) - (0*1*0*) = ∅


 1 votes -- Digvijay Pandey ( 26245 points)

8.255 Decidable and Undecidable problems of automata top gateoverflow.in/38929

Please list down all the decidable and undecidable problems for FA, PDA, TM.

Since there isnt a single place where all are listed.


Selected Answer

please check out the link

http://gatecse.in/wiki/Grammar:_Decidable_and_Undecidable_Problems

 0 votes -- ramamurthi kumar ( 99 points)

8.256 Which of the following is false? top gateoverflow.in/33575

Which of the following statement is false?

(A) Whether one DPDA is equal to other.

(B) Whether a CFG accepts the language of all strings.

(C) If a CFG has an equivalent DPDA.

(D) Two CFG generates the common words.

(i) Only D (ii) B,C,D (iii) A,D (iv) only A

theory-of-computation test-series

since B C D are undecidable hence false

answer is (ii)

correct me if wrong

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1134 of 2244

 1 votes -- artiagrahari ( 113 points)

8.256 How to propose a recurrence equation for a given DFA over a set of q
states? top gateoverflow.in/41867

8.257 recursively enumerable top gateoverflow.in/44224

I am not able to understand the concept of recursively enumerable.Can somebody explain in easy language what is the
difference between recursively enumerable and recursive?

8.258 FSA top gateoverflow.in/32578

//Pls tell me the difference between option A and B its very confusing to me

Consider the context free grammar G with start symbol S and productions
S -> aAB | aBA | bAA | e
A -> aS | bAAA
B -> aABB | aBAB | aBBA | bS
The language generated by this grammar is
(A) The set of all strings that have exactly twice as many a's as b's
(B) The set of all strings that have exactly twice as many b's as a's
(C) The set of all strings with same number of a's and b's
(D) None of the above


Selected Answer

Option A says: Number of a =2 * Number of b.


Option B says: Number of b =2 * Number of a.

Try to derive any string from the above grammar. You will only be able to derive the strings in which all strings that
have exactly twice as many a's as b's., which is option A.

 2 votes -- Monanshi Jain ( 5827 points)

8.259 language top gateoverflow.in/38685

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1135 of 2244


Selected Answer

Integer factorization is in NP but not proved to be in NP-Hard or P. So, it can go either way in future. We have 3 choices
for L depending on this, but all the 3 choices are CFLs. So, we need not worry anything and just say L is a CFL though we
do not know exactly which CFL it is.

 0 votes -- Arjun Suresh ( 124125 points)

https://en.wikipedia.org/wiki/Integer_factorization
Prime Factorisation is One of the Undecidable problem..

So given Language is L = { w⊄wr | w∊ (a+b)*}


Actually Given Problem is set of all Palindrome i.e. L = {WWr | w∊ (a+b)*}

 1 votes -- Digvijay Pandey ( 26245 points)

i think it will be d .
It is still not know . so either it will be true or false. and definitely it is decidable it is NPc wich is a part of NP. which means
it can be solved in polynomial time .

 1 votes -- Ravi Singh ( 7303 points)

8.260 Closure property top gateoverflow.in/38676

A CFL ∩ a DCFL (i.e what is the intersection of a CFL with a DCFL??)


Selected Answer

Surely CSL , it may not be CFL..


L1 = {a b c , n, m ≥ 0 }
n n m

L = {a b c , n, m ≥ 0 }
2
m n n

L = L ∩ L = {a b c , n, m ≥ 0 } ∩ {a b c , n, m ≥ 0 } = {a b c , n ≥ 0} is CSL and not CFL.


1 2
n n m m n n n n n

 4 votes -- Digvijay Pandey ( 26245 points)

8.260 how to implement quick sort with turing machine top gateoverflow.in/42449

TM is a Super Computer. Now question redused to "Implement QUICK SORT on Computer System"
Apply Divide & Conquer

 0 votes -- Digvijay Pandey ( 26245 points)

8.261 which type of language(regular,CFL,CSL,REC,RE) is generated by this?


top gateoverflow.in/38863

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1136 of 2244

L={ a mbn|m <=2n+5}

theory-of-computation


Selected Answer

Language is DCFL but not Regular.


It is DCFL so it must be NCFL, CSL, REC, RE too .

 6 votes -- Digvijay Pandey ( 26245 points)

8.261 Language identification top gateoverflow.in/38817

8.262 DECIDABILITY top gateoverflow.in/32253

I an not getting the meaning of turing recognizable language..can someone please help..


Selected Answer

If some TM can accept all strings in a language (not accept any string not in language) then the language is Turing
recognizable (recursively enumerable).

This differs from Turing decidable (recursive) in the sense that the TM need not reject an string not in L (it may instead
loop forever). So, Turing decidable proper subset of Turing recognizable.

r. e. ⊃ rec. ⊃ csl ⊃ cfl ⊃ dcfl ⊃ reg ⊃ finite

 3 votes -- Arjun Suresh ( 124125 points)

8.263 regular language top gateoverflow.in/44254

given 2 languages :

L1 = {a^n b^l a^k | n + l +k>5 }

L2 = {a^n b^l c^ k|n>5, l >3, k≤ l } Which of the following is true ?

(A) L1 is regular language and L2 is not regular language.

(B) Both L1 and L2 are regular languages.

(C) Both L1 and L2 are not regular languages.

(D) L1 is not regular language and L2 is regular language.

is there any short cut method


Selected Answer

L1 is regular

Regular expression is :

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1137 of 2244

aaaaaaa*b*a*+ aaaaabb*a* + aaaabbb*a* + aaaabaa* + aaabbbb*a* + aaabbaa* + aaabaaa *+

aabbbbb*a* + aabbbaa* + aabbaaa* + aabaaaa* + abbbbbb*a*+ abbbbaa*+ abbbaaa*+ abbaaaa*+

abaaaaa* + bbbbbbb*a* + bbbbbaa* + bbbbaaa* + bbbaaaa* + bbaaaaa* + baaaaaa*

Source:http://gateoverflow.in/?qa=blob&qa_blobid=3726082460590158103

L2 is not regular clearly bcz there is one comparision k<=l.

Option A.

 1 votes -- Manojk ( 3365 points)

To solve this kind of problem, think that how many stack would you need to solve the problem.

FA + 0 stack = Regular Languages

FA + 1 stack = Context Free languages

FA + 2 stack = Turing Machines

We can implement (FA + n stack with FA + 2 stack). Hence By Turing Machine, we can solve any problem.

Now look at L1, To implement this we need at least one stack, hence this is not a regular grammar, by using one stack we
can implement this language hence its is Context free languages.

L2, also can not be implemented without using stack. We need One stack to implement this. Hence this is also CFL.

So answer would be C.

 2 votes -- Rude Maverick ( 3063 points)

8.264 what it means top gateoverflow.in/38818

Which of the following languages enforces rule that a definition should occur before the use of a variables.

(A) {an bn cn ∣ n ≥ 1} (B) {ww ∣ w ∈ (a, b) ∗ }


2 3
(C) {ap ∣ p prime} (D) {an bn cn ∣ n ≥ 1}

Please explain me the question first


Selected Answer

I hope it will help to understand the problem

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1138 of 2244

Option b) is correct

 5 votes -- Praveen Saini ( 34299 points)

8.265 ugc net dec 2012 top gateoverflow.in/42660

Suppose there are logn sorted lists of n logn elements each. The time complexity of producing a sorted list of all these
elements is (use heap data structure) (A) O (n log logn) (B) theta (n logn) (C) omega (n logn) (D) omega (n^3/2)

Since total elements are logn * n logn = n(logn)^2 . heapify procedure take O(n (logn)^2) . not in option so Omega
(nlogn)

 0 votes -- Anirudh Pratap Singh ( 4091 points)

8.266 made easy TOC top gateoverflow.in/38633

Consider the following language L = {w∈(a + b)* w has atleast as many occurrences of (bba)’s as (abb)’s}.
Which of the following statements is/are true?
S1. Language L is regular. S2. Complement of L is CFL.
S3. Complement of L is CSL. S4. Reversal of L is CFL.

Only S1
Only S2 and S4
Only S1 and S3
All of these

Answer KEY
all of these .

I really doubt how this language is regular . could someone solve this ?

made-easy theory-of-computation test-series

8.267 convert the regular expression top gateoverflow.in/32592

convert the regular expression (0+1)*1(0+1) to an NFA without null move

theory-of-computation

NFA for (0+1) * 1 (0+1)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1139 of 2244

 2 votes -- Sandeep Singh ( 5939 points)

8.268 Type of Grammar top gateoverflow.in/41821

What type of grammar is this most accurately described as?


S-> b/ aD
D-> a/ aDD
A. A regular grammar B. CFG C. CSG D. Type-0


Selected Answer

option B

s->b/aD right linear grammar

D->a/aDD context free grammar

so altogether its CFG

 5 votes -- Bhagirathi Nayak ( 10239 points)

8.269 Left linear grammar top gateoverflow.in/38462

Consider the following right linear grammar.

S->aA/abc

A->aA/bB/a

B->bB/cC/b

C->cC/c

Find left linear grammar is equivalent to the above right


linear grammar?

theory-of-computation

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1140 of 2244

IS it,

S->Aa

A->Aa/Bb

B->Bb/Cc

C->Cc

 0 votes -- Dibyo jyoti Koleh ( 11 points)

8.270 REGULAR OR NOT top gateoverflow.in/38924

WHICH ONE REGULAR

1.{a^m b^n} m=4-n

2{a^m b^n} m=n-4

3.{a^m b^n} m-n=4


Selected Answer

L1 = {ambn ∣ m = 4 − n}

L1 can be written as

L1 = {ambn ∣ m + n = 4} is regular, having regular expression a4 + a3 b + a2 b2 + ab3 + b4

L2 = {ambn ∣ m = n − 4}

L2 can be written as

L2 = {ambn ∣ n = m + 4}

or, L2 = {ambm+4 } = {ambmb4 } is CFL

L3 = {ambn ∣ m − n = 4}

L3 can be written as

L3 = {ambn ∣ m = n + 4}

or, L3 = {an +4 bn } = {a4 an bn } is CFL

 3 votes -- Praveen Saini ( 34299 points)

8.271 ugc net dec2015 top gateoverflow.in/33103

the solution of the recurrence relation T(n)<={ theta(1) if n<=80

T(n/s) +T(7n/10)+O(n) if n>80

1)O(lg n) 2)O(n) 3)O(nlgn) 4)none

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1141 of 2244

it seems there is error as it should be T(n/5)

8.272 TOC: FA to RE top gateoverflow.in/33368

theory-of-computation

I strongly believe u really want to use state elimination method for this . if u want to learn u can google it out and apply .

the best and efficient way is the option elimination method . it works , fast.

1- take option 1 and 4 and make the start term null. as we can take it any number of time . i will take it zero time .

now only 01 remains . and 01 is not accepted,

now check for 2 and 3 u will get 2 as answer

 1 votes -- Ravi Singh ( 7303 points)

8.273 Is phi a regular language or not top gateoverflow.in/38475

phi is regular language or not

theory-of-computation

phi,null both are regular languages

 0 votes -- Tauhin Gangwar ( 509 points)

8.274 dfa top gateoverflow.in/38543

dfa for a*b* + b*a* ?

DFA M1 for a ∗ b ∗

DFA M2 for b ∗ a ∗

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1142 of 2244

DFA M for a ∗ b ∗ + b ∗ a ∗ for M1 ∪ M2 as {x0 y0 } as start state, and any state having any final will be final state

Q /Σ a b
→ x0 y0∗ x0 y1 x1 y0

x0 y1∗ x0 y1 x1 y2

x1 y0∗ x2 y1 x1 y0

x1 y2∗ x2 y2 x1 y2

x2 y1∗ x2 y1 x2 y2
x2 y2 x2 y2 x2 y2

 2 votes -- Praveen Saini ( 34299 points)

8.274 difference between derivation tree and parse tree in automata theory?
top gateoverflow.in/42364

both are same

 1 votes -- Manojk ( 3365 points)

8.275 How to identify REL top gateoverflow.in/38619

Which of the following language is recursively enumerable language?

{< M > M is a TM and there exist an input whose length is less than 100, on which M halts}
{< M > M is a TM and L(M) = {00, 11}}
{M1, M2, M3 L(M 1) = L(M 2) ∪ L(M3)}
All of these

How to identify REL ? and REC ?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1143 of 2244

theory-of-computation

8.276 automata top gateoverflow.in/42095

what is the use of automata in computer science?

Automata are used in various ways..


In computer science:-
1. DFA/NFA - used for Lexical Analysis in Compilers
2. Moore/Mealy - concept is used in Digital CIrcuits, precisely Sequential Logic.
3. CFG and CSG - used in Parsing and Other compiler constructs such as type checking, etc.
4. LBA - The whole real world computer model can be seen as an LBA (i.e. TM with restricted input tape)
5. TM - concepts are used in theoretical computer science extensively.

Other applications:-
https://cs.stanford.edu/people/eroberts/courses/soco/projects/2004-05/automata-theory/apps.html

 2 votes -- Abhilash Panicker ( 6527 points)

8.277 Find Language top gateoverflow.in/38598

If L1 is HALTING problem of TM and L2 is Complement of L1.


both L1,L2 are not Recursive.
but L = L1 U L2 = Turing Decidable i.e. Recursive.

yes Option C is true..

 1 votes -- Digvijay Pandey ( 26245 points)

8.278 TOC: No of states in Equvalent NFA top gateoverflow.in/33480

Consider the following language.


+
L = {wxwy | x,y,w∈(a+b) }
How many states are there in equivalent NFA for above L?

theory-of-computation


Selected Answer

Regular expression for the language is a(a + b) + a(a + b) + + b(a + b) + b(a + b) +

NFA will be as

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1144 of 2244

Or

For Reference :

http://gateoverflow.in/32989/why-this-is-not-a-regular-language

 4 votes -- Praveen Saini ( 34299 points)

NFA doesnt exist.

its not even context free.

the NFA given is wrong .since it will accept string that are not in the language.

remeber,if string is not in langugae then NFA will reject it.

but if its in languga atleast one path will be present to final state

 1 votes -- viv696 ( 1431 points)

8.279 simulate one tape turing machine with k-tape TM top gateoverflow.in/41309

Time taken by one tape TM to simulate n moves of k-tape TM is

a) O(n)

b) O(n^k)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1145 of 2244

c) O(n^2)

d) none of these

C) O(n^2)

 0 votes -- icecool ( 99 points)

8.280 NFA/DFA top gateoverflow.in/37052

Pls draw the corresponding NFA/DFA for the given Grammar which are regular here .


Selected Answer

Here it is important to identify the language.

As

I) is generating (a + b) ∗

II) is generating a(a + b) ∗

III) is generating ambn , m ≥ n.

 2 votes -- Praveen Saini ( 34299 points)

8.281 Is |L1. L2| = |L1| x |L2|? top gateoverflow.in/36970

The answer given is NO .

I have a doubt. When concatenating two languages, we take the strings of the first language and concatenate it with each string of the second
language. So if I go by the definition only, the above statement is correct.

But by taking a few examples, it seems that when we concatenate two languages, some of the strings comes out to be the same. The final
concatenated language will contain strings less than |L1| * |L2|.

Therefore, the correct relation should have been |L1. L2| <= |L1| x |L2|.

Is this the right logic to answer this question? Or did I miss out on any conceptual reasons?

theory-of-computation

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1146 of 2244

Yes that's correct. For eg. for ∑ as {0,1}

take L1 = {0,01} and L2 = {∈,1}

then L1.L2= {0,01,011}

so |L1.L2| = 3 and |L1|*|L2| = 2*2 =4

 0 votes -- Abhishekcs10 ( 1001 points)

8.282 ugc net top gateoverflow.in/43909

Option D is the right answer. First option is incorrect because b is coming after c but according to language its not
possible. Same problem occurred in option 2 and 3 also

 0 votes -- Rahul Rai ( 41 points)

8.283 construct the dfa top gateoverflow.in/35763

Give minimal DFA that performs as a MOD-3 1's counter,i.e outputs a '1' each time the number of 1's in the input sequence
is a multiple of 3.

Design a (normal) DFA that accepts strings, over { 0, 1}, that ends with 111.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1147 of 2244

Now Look at DFA, q3 is a state where we get a sequence in which no of 1 ′ s is multiple of 3. so whenever we reach q3 we get
output 1.

We can design Mealy machine for it , by getting output 1 on the incoming edges on state q3 , and output 0 at all others.

Or, We can design Moore machine, by putting output 1 on the state q3 and output 0 on others.

 2 votes -- Praveen Saini ( 34299 points)

8.284 MOORE AND MEALY MACHINES top gateoverflow.in/35723

MOORE AND MEALY MACHINES PROBLEMS WILL COMES UNDER THE GATE CS 2017 SYLLABUS OR NOT?

8.285 Cfg top gateoverflow.in/43443

Every cfg may not have equivalent pda

T/F

made-easy

For every CFG there is an equivalent PDA.

For any CFG there exists a PDA. L(M)=L(G).

For any PDA there exists a CFG L(G) = L(M).

 2 votes -- Manojk ( 3365 points)

8.286 Finite Automata top gateoverflow.in/40678

There are exactly ................ different finite automata with three states x, y and z over the alphabet {a, b} where x is

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1148 of 2244

always the start state.

at input 'a' of x, transition can be to any of the 3 states x or y or z= 3 choices

at input 'b' of x , transition can be to any of the 3 states x or y or z= 3 choices

similarly for y= 3 choices for 'a' and 3 choices for 'b'

and for z= 3 choices for 'a' and 3 choices for 'b'

total state transition choices=3^6

x can be accepting or non- accepting state=2choice

y can be accepting or non- accepting state=2choice

z can be accepting or non- accepting state=2choice

total type of state choices=2^3

total Automata=2^3*3^6

 0 votes -- sanketg186 ( 97 points)

8.287 Automata Gate 2016 top gateoverflow.in/40165

8.288 The following machine is designed with PDA acceptence by final state
to accept odd length palindromes top gateoverflow.in/37108

my question is as it is odd length palindrome , so it can be ababa , right ?

Now , in the given diagram , they have not mentioned the scenario :

1) when a is the stack top element and input symbol is b ( b , a / ? )

2) when b is the stack top element and input symbol is a ( a, b / ? )

Now , my question is - without these two transitions can we design this pda ? ( as it is done in the given ans )

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1149 of 2244

theory-of-computation

According to me this question is unclear but if we thinks that ∊ represents that at the top of the stack there can be
anything then only we can say option c is correct ..

But in gate they will not ask such unclear and confusing question...

at state B

there should be following transitions specified..

∱(B,b,Zo)=(B,bZ0) , ∱(B,a,Zo)=(B,aZ0) , ∱(B,b,b)=(B,bb), ∱(B,b,a)=(B,ba),

∱(B,a,a)=(B,aa) , ∱ (B,a,b)=(B,ab)

Hope this will clear your doubt...

 0 votes -- Akshay Bhatia ( 81 points)

8.289 what is the class of Min(R) for a given regular language ? top gateoverflow.in/37107

Let R be any regular set .Let Min(R) is a set of all strings 'w' in R , where every proper prefix of 'w' is not in R, then to which
class of language does this Min(R) belong ?


Selected Answer

We have a regular set and we want to remove all strings such that in our set for any string, we should not have its prefix.
Now consider the DFA for L. Take all of its final states and see if there is a path to any other final state. (This is a graph
search problem). If so, then mark that final state as non-final because this path we found is essentially adding a "suffix"
to an already accepted string in L and making another string in L. Doing like this for all final states give us the DFA for
MIN(L). So, it must also be regular.

 2 votes -- Arjun Suresh ( 124125 points)

8.290 Which of the following represent the minimum no. of states in DFA
which accept all string of length atmost 5 ‘a’? top gateoverflow.in/35797

Which of the following represent the minimum no. of states in DFA which accept all string of length atmost 5 ‘ a’?

6
4
5
7

Answer given in 5 , how possible ?

atmost 5 a means , on seeing 6th a , we should send it to a dead state right ?

so , won't it be 7 states ?

theory-of-computation


Selected Answer

7 is the correct answer 6 final states + 1 dead state

 2 votes -- priyavssut ( 411 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1150 of 2244

8.291 How to design PDA for given language ? top gateoverflow.in/36940

L={anbn :n>=0 ,n!=100} how to take care of the condition that n !=100 ?

Draw a DFA for n ≠ 100. Take intersection with PDA for L with n ≥ 0.

 1 votes -- Arjun Suresh ( 124125 points)

8.292 ugc net top gateoverflow.in/43710

18. Given the following expressions of a

grammar

E -> E * F / F + E / F

F -> F – F / id

Which of the following is true ?

(A) * has higher precedence than +

(B) – has higher precedence than *

(C) + and – have same precedence

(D) + has higher precedence than *


Selected Answer

* and + both have same precedence .- has greater precedence than + and *.

Option B is Correct.

 2 votes -- Manojk ( 3365 points)

8.293 ugc net top gateoverflow.in/43897

compiler-design

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1151 of 2244

Option a

First α is incorrect it shouldnt be for some string β. It has already seen t as terminal . It doeesnt have to look for β

But Follow X has nothing to do with α

So statement 1 and 2 are false

 0 votes -- Dexter ( 1933 points)

8.294 which length string has to be removed top gateoverflow.in/38821

8.295 Which of the following is the most powerful parring method top gateoverflow.in/43711

Which of the following is the most

powerful parring method ?

(A) LL(I)

(B) Canonical LR

(C) SLR

(D) LALR

CLR is most powerful parser among all the parser which parse more no of grammar than other.So option B.

 1 votes -- Manojk ( 3365 points)

8.296 ugc net 13 top gateoverflow.in/43692

Option c is right . Regular langauges are not capable of doing the above Mathematics operation !

 0 votes -- Dexter ( 1933 points)

8.297 What sub-topics do I need to study to cover Turing machines and


Undecidability ? top gateoverflow.in/36547

Do I need to study basic concepts of complexity classes (P, NP , NP-Hard...reduction etc.) ?

Yes,

Basic concepts of complexity classes – P, NP, NP-hard, NP-complete removed from Algorithms but Reduction is there in Theory of Computati

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1152 of 2244

 1 votes -- Víkky Mathur ( 21 points)

8.298 Epsilon top gateoverflow.in/36177

Is Epsilon a terminal ? If yes, then why not we consider it as a separate column while making the LL(1) parsing table ?

8.299 Csl or cfl top gateoverflow.in/43452

ww^r complement is CSL

Is this right or wrong

If right please how can we prove

made-easy

Correct

ww r is CFL . CFl not closed under complement so move up to chomsky hirarchy . since every CFL is CSL and Compliment of
CSL is CSL.

 1 votes -- Anirudh Pratap Singh ( 4091 points)

8.300 TOC top gateoverflow.in/43562

Consider the language given below .Find the complement of these language and Explain Complementary
language?

1. wwr | w ∈ (a , b)*

2.wx wr| x,w ∈ (a , b)+

3.ww ∣ w ∈ (a, b)+

4.wxw∣ x,w ∈ (a , b)+

theory-of-computation

1. ∑* - ( wwr)

wwr ={ ∊,aa,bb,abba,abbbba..............}

then ∑* - ( wwr) = {a,b,aba,ab,ba,................}

wwr is Regular. Complement of regular is regular

2.∑* - ( wxwr)

wxwr=(aaa,aba,abba..........)

then ∑* - ( wxwr) = {a,b,aa,bb...................}

wxwr is DCFL . DCFL closed under complement. ∑* - ( wxwr) is DCFL

3.∑* - ( ww)

ww=(aa,bb,abab............)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1153 of 2244

∑* - ( ww)=(a,b,abba,abaa.............)

ww is CSL. Complement of CSL can be CSL

4.∑* - ( wxw)

wxw=(aaa,aba,abaab............)

∑* - ( wxw)=(a,b,aa,ab......................)

wxw is CSL. Complement of CSL is also CSL,

 0 votes -- srestha ( 11585 points)

8.301 Solve these automata questions top gateoverflow.in/37112

1. The number of symbols necessary to simulate a TM with 'm' symbols and 'n' states is-

a) m+n b)8mn+4m c)mn d)4mn+m

2. Any TM with m symbols and n states can be simulated by another TM with just 2 symbols and less than

a) 8mn states b)4mn+8 states c)8mn+4 states d)mn states

3. The number of states of the FSM,required to simulate the behaviour of a computer,with a memory capable of storing 'm'
words,each of length 'n' bits is-

a)m⨯2n b)2mn c)2 m+n d)none

8.302 Find the number of productions top gateoverflow.in/35160

Consider the grammar

S ---> PQ | SQ | PS

P --->x

Q--->y

To get a string of n terminals the number of productions to be used is

n2
n+1
2n
2n-1


Selected Answer

Any CNF takes 2n − 1 steps to get a strings of n length,

n − 1 steps to get n Nonterminals, then one step to get one terminal from each Nonterminals , so n more steps so 2n − 1
steps

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1154 of 2244

In case of GNF, n length string take n steps only, bcoz each production have one terminal in it.

 2 votes -- Praveen Saini ( 34299 points)

8.303 TOC top gateoverflow.in/41575

Every 0 is followed immediately by 11. It means 110 or 011??

I think it should 011. is it ?


Selected Answer

A follow B = B first then A

A followed by B = A first then B.

So, 011

 5 votes -- Anirudh Pratap Singh ( 4091 points)

I think it should be 011 because it says " every 0 is followed immediately by 11".

 1 votes -- s_ddwl ( 147 points)

8.304 why is the given property of language non-trivial ? top gateoverflow.in/37750

L={<M>|L(M) is regular } ,isn't it a trivial property because every TM accepts regular language.


Selected Answer

Every Turing Machine accepts regular language? Whether yes or no does not matter (I guess you meant for every regular
language we have a TM) because the property asked in question is the language of a Turing machine regular- this is true
for some and false for some and hence is non-trivial.

Is the language of Turing machine r.e.? This is true for all TM, and hence is trivial.

 3 votes -- Arjun Suresh ( 124125 points)

FIRST OF ALL ITS UNDECIDABLE ....here the explanation

its similar to asking . does every program accepts the given input and rejects all thats not in input ...

and how u said that every TM accepts regular language ....u cant prove for all turing machine ...it will loop forever .

 1 votes -- Deepesh Kataria ( 1207 points)

8.305 What does this question mean? top gateoverflow.in/39130

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1155 of 2244

Is the answer regular because the set is a finite set? Or is it because of some other reason?

theory-of-computation

Regular Languages are closed under Prefix, Half, Root, Cycle, min, max operations.

 0 votes -- Digvijay Pandey ( 26245 points)

8.306 Regular language top gateoverflow.in/44114

The answer given is a),I think it should be b


Selected Answer

Here, we have some n, and this comes inside a set definition so it basically means we have to consider all possible values
of n. (Assuming n means a natural number). So, if n = 1, we have

L1 = {a, aa, aaa, …}.

When n = 2 we have

L2 = {aa, aab, aaa, aaab, …}.

Like this we get

L = L1 ∪ L2 ∪ ….

Here, L1 , L2 are not regular. So, we cannot use closure property (even regular languages are not closed under infinite
union). So, we have to do some deduction. I see that

L = {aibj ∣ i > j}.

which is not regular but DCFL.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1156 of 2244

 1 votes -- Arjun Suresh ( 124125 points)

8.307 DFA States Question top gateoverflow.in/41820

Let Σ= {0, 1} What will be the number of states in minimal DFA, if the Binary number string is congruent to (mod 8). A. 8 B.
9 C. 7 D. 4

One Straight Answer can be derived from this..


x mod m , if m can be written in the form of 2^n then the number of states equals to n+1
Second is what is mentioned in @Praveen Comment,
4 of these states will get minimized. it is just as all strings ending with 000

Thus Answer is Option D)


 1 votes -- saif ahmed ( 931 points)

8.308 Is this language DCFL top gateoverflow.in/33904

Hi , my question is : is this language D ( w x w R ) DCFL or Non deterministic CFL ?

theory-of-computation


Selected Answer

A is non linear power of a so csl

B is regular (aaa)*aaaaa

C is DCFL .

D is CFL because x belongs to 0 and 1.so we don't know exactly where is actually x, so we need to explicitly guess the 0
or 1 so that we can say after that w^R starts.

(if x is not of 0 or 1, say 2 then we know exact after that we have w^R ,then it will be DCFL)

 3 votes -- Sayantan Ganguly ( 5061 points)

language D ( w x wR ) is DCFL
after x pop all wR with all w whichis present in stack so dcfl

 1 votes -- kunal chalotra ( 3567 points)

8.309 ugc net dec 2015 top gateoverflow.in/33808

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1157 of 2244

given the following 2 languages

L1={a^n b a^n |n>0}

L2={a^n b a^n b^n+1 |n>0

which of the following is correct

1)L1 is context free and L2 is not context free language

2)L1 is not context free and L2 is context free language

3)Both L1 and L2 are context free languages

4)Both L1 and L2 are not context free languages


Selected Answer

L1 = {an ban | n > 0} is CFL

push a ′ s in stack ,do nothing with b , then pop a ′ s from stack on reading a ′ s

L2 = {an ban bn +1 | n > 0} is CSL.

Push a ′ s in stack, donothing on b , pop a ′ s from stack on reading a ′ s, then we left with b ′ s with empty stack, then we can't
ensure these b ′ s are one more that earlier a ′ s.

Option A, L1 is context free and L2 is not context free language.

 0 votes -- Praveen Saini ( 34299 points)

8.310 Dfa top gateoverflow.in/37838

Dfa to accept strings with 0's and 1's so that no of 0's should be even and no of 1's is divisible by 3

theory-of-computation


Selected Answer

DFA M1 over {0, 1} having even no of 0 ′ s (or divisible by 2)

DFA M2 over {0, 1} having no of 1 ′ s divisible by 3

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1158 of 2244

DFA M using cross product M1 × M2 , having {x0 , y0 } as start state, and mark final state where we have both finals together,
i.e.{x0y0} as final state.

Q∖Σ 0 1
→ x0 y0∗ x1 y0 x0 y1
x1 y0 x0 y0 x1 y1
x0 y1 x1 y1 x0 y2
x1 y1 x0 y1 x1 y2
x0 y2 x1 y2 x0 y0
x1 y2 x0 y2 x1 y0

 1 votes -- Praveen Saini ( 34299 points)

8.311 Let M range over Turing machine descriptions. Consider the set REG
and let the complement of REG be Co-REG. top gateoverflow.in/39127

Let M range over Turing machine descriptions. Consider the set REG= {M | L(M) is a regular set} and let the complement of REG be Co-REG.
Which of the following is true?

(A) REG is r.e. but Co-REG is not


(B) REG is not r.e. but Co-REG is
(C) Both are r.e.
(D) None of them are r.e.

theory-of-computation

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1159 of 2244

d) sorry d. is correct...when l&l complement both are r.e...then l is recursive

 0 votes -- Tauhin Gangwar ( 509 points)

8.312 DCFL,CFL,NonDCFL,Non CFl top gateoverflow.in/36442

how to we identify them...

if a lang is not cfl then it is DCFL??

what is differenc between all of them

8.313 TOC top gateoverflow.in/37670

/
Let L = {madeeasy2016} over Σ = {m, a, d, e, s, y, 2, 0, 1, 6}, L1 = prefix(L) and L2 = L1 Σ ∗ . The number of strings in L2 (assume L1 and L2
do not include empty string) are ______.

theory-of-computation


Selected Answer

L = {madeeasy2016}

L1 = prefix(L), excluding empty string

L1 = {m, ma, mad, made, madee, madeea, madeeas, madeeasy, madeeasy2, madeeasy20, madeeasy201, madeeasy2016}

/
In general Right Quotient of L1 with L2 means L1 L2 = {x : xy ∈ L1 for some y ∈ L2 }

so In our problem

/
L2 = L1 Σ ∗ = {x : xy ∈ L1 for some y ∈ Σ ∗ }

/
for y = ϵ, L2 = L1 Σ ∗ = L1

Number of strings in L2 = Number of strings in L1 = 12

 2 votes -- Praveen Saini ( 34299 points)

Lets explore the quotient operator:

L1/L2 = ?

? is every 'x' that satisfies x.y ∈ L1 where y ∈ L2

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1160 of 2244

Now, consider any arbitrary language L. What is L/∑* ?

So, take... x.y ∈ L as 'y' can range from epsilon to every string possible, you will find that x is actually a prefix for L. How? Say y='b', and L
contains some string like aabbb. So x becomes 'aabb'. So, if you consider all possible x (which is nothing but the quotient) , you will get prefix(L).

Now, coming to your question, L1/∑ * is nothing but prefix(L1). Thus, L2=Prefix(L1) which inturn is prefix for given string. So, just calculate
prefixes, that's it :)

 2 votes -- Tushar Shinde ( 1523 points)

8.314 Regular Language top gateoverflow.in/34913

A Language is said to be regular iff

a. There exists a Right Linear Regular Grammar for L

b. There exists a Left Linear Regular Grammar for L

c. There exists a NFA with a single final state

d. There exists a DFA with a single final state

e. There exists a NFA without  - move.


Selected Answer

A, B, C, E are TRUE. C choice.

For D consider the regular language {0, 00}. We cannot make a DFA with a single final state. But for any NFA, we can
reduce it to an equivalent NFA with a single final state- just make a new final state, mark all final states as non-final and
add an epsilon-transition from those final states to the new one.

 2 votes -- Arjun Suresh ( 124125 points)

8.315 PDA top gateoverflow.in/34981

I m student of MCA.

(PDA) plz tell me difference b/w -

a^n b^n | n >=0

or

a^n b^n | n>=1

in my view :-

L={1,11,111,........} is >=1 condition and

L={€, 1,11,111,.........} is >=0 condition. this is rght or wrong.

plz tell me difference with pda transition

(a^n b​^n | n>=1)

transition :

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1161 of 2244

(q0,a,Z0)=(q1,XZ0)

(q1, a, X) =(q1,XX)

(q1,b,X)=(q2,€)

(q2,b,X)=(q2,€)

(q2, €, Z0)=(q3,€)

accepted by the final state.

(a^n b^n | n >=0)

transition :

(q0,€,Z0)=(q3,€)

(q0,a,Z0)=(q1,XZ0)

(q1,a,X)=(q1,XX)

(q1,b,X)=(q2,€)

(q2,b,X)=(q2,€)

(q2,€,Z0)=(q3,€)

accepted by the final state.

 0 votes -- rakeshkr49 ( 17 points)

8.316 Which of the following language is decidable top gateoverflow.in/35060

Consider the following languages


L1 = {< M, q > | M is a turing machine that visits state q on some input within 10 steps}
L2 = {< M > | M is a turing machine, |M| < 100 where |M| is number of states in machine}
Which of the following is correct?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1162 of 2244

L1 is decidable but L 2 is not decidable

L2 is decidable but L 1 is not decidable

Both L1 and L 2 is decidable

Neither L 1 nor L 2 is decidable

According to Rice theorem's first part , any non-trivial property of TM is undecidable , so L1 should be undecidable , right ?
Because , we can not tell whether it will not visit q on some input within 10 steps.

But , L2 is trivial property , right ?

Please correct me.

theory-of-computation


Selected Answer

Both are non-trivial properties. But Rice's theorem does not say anything about properties of TM. It says about properties
of language of TM or about properties of r.e. set. So, it is not applicable to given question as here it talks about TM and
not its language.

L2 is easily decidable. We can just count the no. of states in the TM description. This is similar to counting the no. of lines
in a given C code.

L1 looks semi-decidable. But it is also decidable. With one move (step) a TM can read only 1 input letter. So, in 10 steps
the maximum input a TM can read is 10 letters. So, to decide the problem just simulate the given TM on all inputs of
length 10 for up to 10 steps. If the TM visits state q on any of them we have answer "yes" and otherwise we have answer
"no". No chance of an infinite lop here.

 2 votes -- Arjun Suresh ( 124125 points)

8.317 can we remove null?? top gateoverflow.in/44077

See here . every grammar symbol must yield a terminal ( directly or indirectly )

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1163 of 2244

If you See A , B , C , D, F . we will think they are not yielding terminals .

But if you See E -->bc ( This is only production which directly yields terminals, but this production is indirectly helping
other symbol to yield production )

Let us See

E-->bc

1.C-->Ec = bcc

2.B-->bCC= bbccbcc

3.A->SbB-->Sbbbccbcc/ bbbbccbcc (on applying s as null )

4- S-->AaS/∈= Aa= bbbbccbcca

5.D-->abAA=ab bbbbccbcc bbbbccbcc

6.C--->cD= cab bbbbccbcc bbbbccbcc .

Even F can generate Terminals

But we would see our Useless symbol Definition : These are the symbols which cant be reached by Start Symbol .

So if You See F is the only symbol which cant be reached by start symbol directly or indirectly

So number of useless symbol =1

and For second part , The number of production in G after removing null production is

S-->AaS/∈= Aa/AaS

A->SbB= SbB/bB

B->bCC

C-->cD/Ec

D-->abAA

E->bc

F-->bBC

So number of null production is 10

 0 votes -- Dexter ( 1933 points)

8.318 under which language does the following set fall and why top gateoverflow.in/37441

8.319 FIND INHERENTLY AMBIGUOUS GRAMMAR- top gateoverflow.in/32223

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1164 of 2244


Selected Answer

A language is a inherently ambiguous there is not exist any unambiguous grammer.

Ref : https://en.wikipedia.org/wiki/Ambiguous_grammar#Inherently_ambiguous_languages

Now in option (a) , the language generated by this grammer is

L = { a m b n dl | m = n} U { a m b n dl | n=l}

let L1 = { a m b n dl | m = n} & L2 = { a m b n dl | n=l}

So here the language itself there is a conflict requirement for its string. L1 is the set of strings where number of a 's and b 's
are same while L2 is the set of string where number of b's and d 's are same. Strings of type a n bn d n will have two parse
tree.

There is no unambiguous grammar for it.

Option (b) language generated by this is

L = { a mbn | n>m } U { (a+b) * } = (a+b) *

So for this language you can definitely give unambiguous grammer and even this language is regular and regular
language do not posses unambiguity.

S->aS|bS|^ is unambiguous grammar for it.

Only Grammer given in Option (a) generates inherently ambiguous language

 3 votes -- Sandeep Singh ( 5939 points)

8.319 can we find out minimum numbers of states in DFA if NFA has n states
top gateoverflow.in/34006


Selected Answer

if NFA has n states , then states in DFA will be determined by set of subsets of the states of the NFA.

1 ≤ Number of states in equivalent DFA ≤ 2n , where n is number of states in NFA.

say NFA has two states , q0 and q1 , then DFA may have ,any to all, of {{}, {q0 }, {q1 }, {q0 , q1 }}

 7 votes -- Praveen Saini ( 34299 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1165 of 2244

8.320 TOC - What is quotient operation ? top gateoverflow.in/34611

Let A = {(a*b*)} and B = {bb, ba, bbb}. Then A/B represents of the following language when / is quotient operation.

a) ∅

b) {b* }

c) {a*b* }

d) None

What is the quotient operation here, and how to operate it on given languages.

theory-of-computation


Selected Answer

Definition :

L1 /L2 = {x : xy ∈ L1 for some y ∈ L2 }

Here we need to find Prefix ( x) from strings (xy) of language L1 those have some suffix ( y) and these suffix belong to L2 .

In other words, string in L1 /L2 is the prefix of xy where string xy is in L1 and y is in L

There are many ways to do it .

One of them is,

L1 (a ∗ b ∗ ) = {a ∗ , a ∗ b, a ∗ bb, a ∗ bbb, a ∗ bbbb, a ∗ bbbbb, . . . . . }

for y = bb ∈ L2

xy∈L1 xy∈L1 xy∈L1 xy∈L1


   
a ∗ bb a ∗ b bb a ∗ bb bb a ∗ bbb bb
      
x y∈L2 x y∈L2 x y∈L2 x y∈L2
L1 (a ∗ b ∗ ) = {a ∗ , a ∗ b , , , , ,.....}

so these x are actually strings in L1 /L2

So One of subset of L1 /L2 is {a ∗ , a ∗ b, a ∗ bb, a ∗ bbb, . . . . } = a ∗ b ∗

for y = bbb ∈ L2

xy∈L1 xy∈L1 xy∈L1 xy∈L1


   
a ∗ bbb a ∗ b bbb a ∗ bb bbb a ∗ bbb bbb
      
x y∈L2 x y∈L2 x y∈L2 x y∈L2
L1 (a ∗ b ∗ ) = {a ∗ , a ∗ b, a ∗ bb , , , , ,.....}

So another subset of L1 /L2 is {a ∗ , a ∗ b, a ∗ bb, a ∗ bbb, . . . . } = a ∗ b ∗ it is same as earlier

No need to check y = ba ∈ L2 bcoz there is no string in L1 that ends with ba


so, L1 /L2 = a ∗ b ∗

Similarly , there is Left Quotient

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1166 of 2244

L1 ∖L2 = {y : xy ∈ L1 for some x ∈ L2 }

Once we get the exact meaning of Left or Right Quotient and done with 3-4 problem, then there is no problem

 2 votes -- Praveen Saini ( 34299 points)

8.321 NDPA top gateoverflow.in/34657

Consider the NPDA < Q = {q0, q1, q2}, ∑ = {0, 1}, τ = {0, 1, ⊥ }, δ, q0, ⊥ , F = {q2} >, where (as per usual convention) Q is the set of states, ? is the
input alphabet, ? is stack alphabet, ? is the state transition function, q0 is the initial state, ⊥ is the initial stack symbol, and F is the set of accepting
states, The state transition is as follows Which one of the following sequences must follow the string 101100 so that the overall string is accepted by
the automaton?

8.322 regular exxpression top gateoverflow.in/37869

QUESTION 26 : Consider below the regular expressions over alphabet {0, 1, 2}


(i) (0 + 01 + 012))*
(ii) 0*(0 + 1)*(0+1+2)*
(iii) 0*(ε + 01)*(Φ + 01)*
(iv) 0 * + (01)* + (012)*
Which of the above regular expressions represent same language as 0(01)
* *(012)*

(A) i, ii and iii


(B) ii and iv
(C) iii
(D) iv


Selected Answer

None of these for the given options

0 ∗ (01) ∗ (012) ∗

i) 012 01 can be derived from option i) but cannot derived from given regular expression

ii) 2 can be derived from option ii) but cannot derived from given regular expression.

iii) 012 cannot be derived from option iii) but can derived from given regular expression

iv)01 012 cannot be derived from option iv) but can derived from given regular expression.

if we do some correction in option iii) as 0 ∗ (ϵ + 01) ∗ (ϕ + 012) ∗ , then it will be correct


∗ ∗
*Note (ϵ + R1) ∗ = R1 and (ϕ + R2) ∗ = R2

 3 votes -- Praveen Saini ( 34299 points)

8.323 How to make a DFA given a regular grammar ? top gateoverflow.in/26813

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1167 of 2244

A-->aB/bA/b , B-->aC/bB , C-->aA/bC/a

what is the approach ?

here A is initial and final state of the dfa

 1 votes -- srestha ( 11585 points)

8.323 under all mod conditions the language is always is regular or not if not
please explain with some examples top gateoverflow.in/12767

L= { w1w2 | w 1, w2 = (0+1)* // Non Regular

L = { w| No of a mod 3 = 0} // Regular

In general it can be anything.. mod need not to be regular in every case..

 0 votes -- Digvijay Pandey ( 26245 points)

8.324 which of the following statements is correct regarding Regular


language? top gateoverflow.in/12745

1.Every Ragular Language have an equivalent LR(0)grammer.


2. Every DCFL have an equivalent LR(0) grammer

I think first statement is correct.


1. Every regular language do have an equivalent LR(0) grammar.
2. Every DCFL do not have equivalent LR(0) grammar because DCFL are basically LR(1) and some of LR(1) cannot be
converted to LR(0).

So, first statement is correct.

 0 votes -- Monanshi Jain ( 5827 points)

8.324 difference between phi and epsilon? top gateoverflow.in/12645

there is no way you can reach the final state then the language contains only ø .

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1168 of 2244

and when you can reach the final state by giving nothing in input ( initial state = final state ) then the language
contains € .

 3 votes -- Pranay Datta ( 6113 points)

phi means nothing not even epsilon i.e nothing not even null is accepted epsilon atleast contains epsilon i.e null string is
accepted

 1 votes -- Bhagirathi Nayak ( 10239 points)

8.324 difference between phi and epsilon? top gateoverflow.in/12644

Phi means empty set.

Epsilon means der is some element in a set whose cardinality(cardinality of that element not set cardinality) is 0.

In case of TOC theory (NFA) :

Phi means no string accepted i.e. no final state.

Epsilon means der is a string of length 0 & it is accepted i.e. der is a final state.

 0 votes -- Digvijay Pandey ( 26245 points)

8.324 What is the difference between ambiguous and inherently ambiguous


for context free languages? top gateoverflow.in/12886

A context free grammar G is said to be ambiguous ,if there exists some w belongs to L(G) that has at least 2 distinct
derivation trees.

I f every grammar that generate L is ambiguous then language is called inherently ambiguous ...eg for inherently
grammar is L= {a^nb^nc^m}∪{a^nb^mc^m}

http://infolab.stanford.edu/~ullman/ialc/slides/slides7.pdf

 3 votes -- sonam vyas ( 6441 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1169 of 2244

8.324 number of states of minimal nfa accepting strings of length n top gateoverflow.in/12942

Minimal states for Nfa for n length string is n+1 .

 0 votes -- Pranay Datta ( 6113 points)

8.325 Elimination of epsilon top gateoverflow.in/13275

Question : (Here e=epsilon) S->A|B, A->e, B->aBb, B->b

My answer is :

S->B, B->aBb , B->b

or

S->B|e , B->aBb , B->b

Want to know which one is correct ? please explain...

theory-of-computation


Selected Answer

second one is correct , if S---> e we could not eliminate it bcoz language generate e ,and if language does not generate e
then it can be eliminate ...

s-->AB

A--->aAA/e

B--->bBB/e after elimination of e

S-->AB/A/B/e

A-->aAA/aA/a

B-->bBB/bB/b

 6 votes -- sonam vyas ( 6441 points)

8.325 intersection of CFL and RL will always be regular or CFL top gateoverflow.in/13233

Always be CFL but not necessarily regular. As an example take regular language = Σ ∗ and its intersection with any CFL
gives that CFL.

 1 votes -- Arjun Suresh ( 124125 points)

8.326 plz answer .. top gateoverflow.in/13038

let q0 and q1 are two states and q0 is always initial state over the alphabet {a,b}, the possible number of dfa's with two
states q0 and q1 are

16,32,64,80

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1170 of 2244


Selected Answer

No. of possibilities for start state = 1 as it is fixed here.

No. of possibilities for final state = 22 = 4 as any subset of the set of states can be the final state.

No. of possible transition functions = Number of possible functions from a set of 4 elements (Q × Σ) to a set of 2 elements
(Q)

= 24 = 16.

So, number of possible DFA's = 4 × 16 = 64

 2 votes -- Arjun Suresh ( 124125 points)

8.326 it necessary for a dfa to have to have atleast one final state? top gateoverflow.in/12487

No its not necessary . If a dfs does not has a final state then for that dfa L= { Ø } .

 7 votes -- Pranay Datta ( 6113 points)

Final state not necessary but Starting state must be der..

 2 votes -- Digvijay Pandey ( 26245 points)

Refer to this http://stackoverflow.com/questions/21731715/dfa-without-final-state

 1 votes -- Rohan Ghosh ( 1515 points)

8.327 Is the language WXW^R is a regular ? top gateoverflow.in/12374

is the language WXW R is regular? can any one provide the proof?

WXW R is regular on {a,b} . X can be anything .

so we can rewrite this language as " starting bit and ending bit are same " which is a regular language .

see this : http://stackoverflow.com/questions/14521300/why-l-wxwr-w-x-belongs-to-a-b-is-a-regular-language

 5 votes -- Pranay Datta ( 6113 points)

i assume W,X belongs to {a,b}* i will always intentionally put W=null and X=string you provide me now X belongs to
{a,b}* so the whole language is regular..

 3 votes -- Bhagirathi Nayak ( 10239 points)

8.327 Consider following Regular Expression (i) a*b*b (a+ (ab)*)* b*(ii) a*
(ab + ba)* b*What is length of shortest string which is in both (i) & (ii)? A.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1171 of 2244

2 B. 3 C. 4 D. None top gateoverflow.in/11401

(i) a*b*b (a+ (ab)*)* b* = a*b*b (a+ ab)* b*

(ii) a*(ab + ba)* b*

Shortest string will be "b" only..

Length will be 1.

Option D.

 4 votes -- Digvijay Pandey ( 26245 points)

8.328 which of the following is true top gateoverflow.in/11310

Let L denote the languages generated by the grammar S → S0S0 | 00.


Which of the following is TRUE?

A. L = 0 +
B. L is regular but not 0 +
C. L is context free but not regular
D. L is not context free

C is the given answer but I got B

L={00(2),000000(6),0000000000(10)...}

number of zeros inside the bracket

Is it correct?

Yes. It is correct.

 1 votes -- Arjun Suresh ( 124125 points)

8.329 proper non empty substrings top gateoverflow.in/11278

The maximum no of proper non empty sub-strings for the given 'n' length string is:

A) n*(n+1)/2 - 1

B) n*(n+1)/2

C) n*(n+1)/2 + 1

D) none of the above

I basically want a good explanation here for whatever option you choose???thanks in advance .

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1172 of 2244

<answer given as per coaching book is B>

theory-of-computation


Selected Answer

take "abc" string. Sub strings are

1. a
2. b
3. c
4. ab
5. bc
6. abc

For a string of length n, we can have 1 sub-string of length n, 2 sub-strings of length n-1, 3 sub-strings of length n-2, ... n
substrings of length 1. So, total no. of sub-strings = 1 + 2 + ... + n = n (n+1)/2

But the question asks for "proper" sub-strings. Proper sub-string means the given string (of length n) must not be
counted. So, the answer must be n(n+1)/2 - 1.

Ref: http://www.personal.kent.edu/~rmuhamma/Algorithms/MyAlgorithms/StringMatch/stringMatchIntro.htm

 2 votes -- Arjun Suresh ( 124125 points)

8.330 plz answer ! top gateoverflow.in/11421

i think

Here Qo is initial state as well as final state . so ans is B.

 3 votes -- Pranay Datta ( 6113 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1173 of 2244

8.331 choosing incorrect identity top gateoverflow.in/11765

choose incorrect identity from the following

a) (a+b)* = (a+b)*(a+b)*

b) (a+b)* = a(a+b)*b(a+b)* + ∈

c)(a+b)* = (a+b)*ab(a+b)* + b*a*

d)None of the above

correct answer given is option D but obviously option B and option C both are wrong too.


Selected Answer

Yes option B is wrong .

We can not produced string ba from option B. [Even a,b cannot be derived]

But

option C is right . [all string over {a,b} contain sub string "ab" + all string doesn't contain "ab" as sub-string = all strings
over {a,b}]

 2 votes -- Pranay Datta ( 6113 points)

8.332 Can DPDA accept ambiguous grammars? top gateoverflow.in/12231

Option D is correct. But G is ambiguous. Can DPDA accept G?


Selected Answer

Yes. It is not depend on Grammar that is ambiguous or unambiguous, that is depend on language (generated by
Grammar) accepted by DPDA or NPDA.

above Grammar is for language , Balanced parenthesis for which we can design DeterministicPDA
[ push "(" into stack and pop with ")" ]

so 3 is True.
2 is True, i guess valid parenthesis mean balanced parenthesis.

1 is True , as S=>() S=>(S) =>()

 2 votes -- Praveen Saini ( 34299 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1174 of 2244

1>If a language is accepted by a DPDA then this language should have an unambiguous grammar.

2>This does not mean that all languages that have an unambiguous grammar is accepted by a DPDA (for e.g ww^r).This
language has an unambiguous grammar i.e S-->aSa | bSb | epsilon

3>If a grammar is inherently ambiguous then it is surely not accepted by a DPDA.

In your question the language of valid parenthesis has an unambiguous grammar i.e S-->(S)S | epsilon..Thus there can
be a DPDA though we are not sure because of point 2.

Now we try to make a DPDA that can accept it, to be sure..we get is as...say Q1 is initial state and Q2 is final state..then
the transitions will be..

( Q1,(,Z )---->( Q1,(Z )

( Q1,(,( )----->( Q1,(( )

( Q1,),( )------> (Q1 ,epsilon)

( Q1,epsilon,Z)-----> ( Q2,Z)

therefore, this language is accepted by a DPDA

 5 votes -- debanjan sarkar ( 775 points)

8.332 are all regular languages accepted by a nfa is generated by ambiguous


grammar? top gateoverflow.in/11864

A language accepted by nfa is a regular language . And a regular language is left recursive or right recursive . So regular
language maybe ambiguous or unambiguous depend upon implementation . So All languages accepted by a nfa is
ambiguous or unambiguous grammar .

 1 votes -- Pranay Datta ( 6113 points)

8.333 how to find whether a language is regular or not top gateoverflow.in/11770

my question is whether we have a shortcut an idea which can help us in recognizing any language to be regular or not,in GATE .and
also what is the best way to get it properly done when you want to do it the old school way?

theory-of-computation


Selected Answer

Check following thing .

1. Is DFA/NFA or regular expressions possible or not (especially in case of WW, WWr, W1W2.....)

2. String matching ---> non regular

3. Counting comparison ---> non regular

4. Power is non linear ---> non regular

5. If finite then regular.. it doesn't matter comparison or string matching or power is non linear if language is finite it must
be regular.. even finite subset of non regular is regular..

Still some more but questions base on these 5 points frequently asked in GATE..

referhrefer : http://gatecse.in/wiki/Identify_the_class_of_the_language

 4 votes -- Digvijay Pandey ( 26245 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1175 of 2244

8.333 L = { a^n b^m, n>=4, m<=3}, What will be the regular expression for
the complement of L? top gateoverflow.in/13365

n>=4 , then {aaaa,aaaaa,aaaaaa,aaaaaaa,.....} = aaaa{ ^,a,aa,aaa,.....} =aaaaa*


b<=3, then {^,b,bb,bbb}

L= anbm ,n>=4,m<=3

Regular expression will be aaaaa*(^+b+bb+bbb)


DFA for above regular expression will be

DFA for complement of L , i.e, L' will be

will have regular expression


(^+a+aa+aaa)(^+b(a+b)*) +aaaaa*(b+bb)a(a+b)*+aaaaa*bbb(a+b)(a+b)*
or
(^+a+aa+aaa)(^+b(a+b)*) +aaaaa*(b+bb+bbb)a(a+b)*+aaaaa*bbbb(a+b)*

 4 votes -- Praveen Saini ( 34299 points)

8.334 Please solve Q.80 and Q.81 top gateoverflow.in/13422

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1176 of 2244

theory-of-computation

80 . LR(1) item B---> a.B,a is valid for " aaa ".

A---> a'.ß, a'' is valid for viable prefix let y if there is derivation S-rm*-->ØAw---> Øa'ßa''w

here y=Øa' here a'' is lookahead , which is first symbol of w so for given question

S--> BB---> BaB--->--> Bab---> aBab-*-->aaaBab(rightmost derivation) so here a''=a , w=ab ,Ø=aa,

viable prefix = aaa

81. similar here S--> BB --> BaB--> BaaB

so w=∊ ,a''=$ ,a'=a , Ø=Ba so

y= Baa..

reference http://www.cs.clemson.edu/course/cpsc827/material/LRk/LR1.pdf

http://tinman.cs.gsu.edu/~raj/4340/sp12/LR1.pdf

 0 votes -- sonam vyas ( 6441 points)

8.335 Consider this grammar: S → SS | a How many derivation trees are


possible for a^4 ? (a) 3 (b) 4 (c) 5 (d) 6 top gateoverflow.in/15208

Consider this grammar: S → SS | a How many derivation trees are possible for a^4 ? (a) 3 (b) 4 (c) 5 (d) 6

Is there any formulae to solve this kind of problem?

theory-of-computation

i think 5 is possible . i don't think one can derive a trick for that as the production can change and there are lot of
productions . so u should make all the possible combinations . it take hardly 30 second to get to the answer. u may derive
a formula but what i prefer never learn anything till it is really required. there are hell lot of formulas to remember and
really when i went for gate paper this year i hardly think there was a question based on formula,.

 1 votes -- Ravi Singh ( 7303 points)

8.336 L1 = {ca^nb^n} ∪ {da^nb^2n} L2 = {a^nb^n c} ∪ {a^nb^2n d} top


gateoverflow.in/15153

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1177 of 2244

L1 = {ca b } ∪ {da b }
n n n 2n

L2 = {a b c } ∪ {a b d }
n n n 2n

a. Both are DCFL’s


b. Both are NCFL’s
c. L1 is DCFL, L2 is NCFL
d. L1 is NCFL, L2 is DCFL

theory-of-computation


Selected Answer

L1 is DCFL because der is one to one comparison between no of a and b and c & d are used to identify which {ca^nb^n}
∪ {da^nb^2n} sub language execute first.

i think L2 is NCFL because union of two DCFL always be an CFL but der is no CLUE to identify which sub language
executes first thats why it is not DCFL..

 5 votes -- Digvijay Pandey ( 26245 points)

8.337 How to find the complement of a language ? top gateoverflow.in/15106

I am having problem in finding the complement in the sense that I am unable to complement the relation defined between
the powers of the variables ,say I have a language like

L={a^m b^n , m > n>100}

Now what should be the procedure in order to find the complement of this relation and then proceed in calculating the
complement of the language ?

theory-of-computation

complement of a language is all the possible strings with sigma* - language strings. frame a gramer that only not accept
your language and accept everything else.

for example every string starting with b. and accept every possible case below 100 as no condition is there for that and all
strings where m<n and n>100 . i thing we included everything . this is the complement of the language

 1 votes -- Ravi Singh ( 7303 points)

8.338 The language of primes in unary is top gateoverflow.in/15070

The language of primes in unary is:


A. Regular B. CFL C. DCFL D. Context Sensitive

theory-of-computation

D.Context sensitive

it will be l={1^p where p is prime} ..it cant be regular as there is no pattern in the strings generated that we can
remember, also we cant generate primes using FA+ one stack ie pda.

 6 votes -- Anurag Semwal ( 4775 points)

8.339 toc top gateoverflow.in/15304

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1178 of 2244

for DCFL there exists LL(k) or not?

No, LL(k) form subset of DCFLs.

https://en.wikipedia.org/wiki/LL_grammar

 0 votes -- Himanshu Agarwal ( 8861 points)

8.340 How is the below language regular ? top gateoverflow.in/15363

If L={a^n w a^n , w={a,b}* }

how come this is a regular language , although I can write like

a(a+b)*a +aa (a+b)*aa but still how are we able to make sure that the power of a from the beginning is the same as the
power of from end , plz draw a finite automaton for it , I am stucked up in this .

theory-of-computation


Selected Answer

If L = {an wan , w ∈ {a, b} ∗ }

When a set definition is given, we must consider all possible cases as per the definition- i.e., for a language we must
include all possible strings satisfied by the given definition. In this question when we put n = 0, we get L = Σ ∗ and that is
the maximal set and so we don't need to consider any other value for n. And this set is regular.

 2 votes -- Digvijay Pandey ( 26245 points)

8.341 The language L is ? top gateoverflow.in/15876

let L = { Φ
ϵ
if Recursiveset(RS) = RES
if RS ≠ RES

then L is:

a) Regular B) CFL but not regular

c)Regular but not CSL D)none

theory-of-computation

Answer is A, regular.

There are two choices for L but both are regular sets. Now, RS != RES, and this is a known fact. So, L = ϕ which is a
regular set.

Now, even if RE = RES? is not a proven fact, still L is a regular set. Just that we don't know which regular set it is.

 0 votes -- Arjun Suresh ( 124125 points)

8.342 which of the following is a non-regular language?? top gateoverflow.in/15743

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1179 of 2244

a. L={ WXWY | X,YE(a+b)+}

b. L={ XWYW| X,YE(a+b)+}

c. { WXYW | X,YE(a+b)+}

d. All of these


Selected Answer

Only C is non-regular.

http://gatecse.in/wiki/Identify_the_class_of_the_language

 0 votes -- Arjun Suresh ( 124125 points)

8.342 What are the number of states needed in minimal DFA, that accepts
(1+1111)* A. 5 B. 4 C. 1 D. None top gateoverflow.in/15628

(1+1111)* is same as 1*. Single state DFA with same starting and final state.

 1 votes -- Anurag Pandey ( 8183 points)

8.343 Is this Language regular? top gateoverflow.in/14950

L= {Σ ∗ }
theory-of-computation

Definition- language is a set of strings, here it is a set of set of strings.

But even Σ is not defined here and if I take ∑=a, a character and not an alphabet set, then we get a language.

eg: Let ∑={a,b},Then, ∑∗={ϵ,a,b,aa,ab,ba,bb,…}. However, { ∑*} = {{ϵ,a,b,aa,ab,ba,bb,…}}

So, its like this L={ ∑∗}

L = { language }

so, L is not even a language .

 1 votes -- Pranay Datta ( 6113 points)

8.344 regular expression top gateoverflow.in/14663

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1180 of 2244

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1181 of 2244

A 4

B 3

C 2

D 1

E 6

F 5

 2 votes -- Pranay Datta ( 6113 points)

8.345 Type of language ? top gateoverflow.in/13818

it will be accepted by NPDA. Right ??

without any doubt this language is CFL and there exists a npda which recognises it.......

 1 votes -- Bhagirathi Nayak ( 10239 points)

NPDA will create copies of itself while checking for palindrome on its way (of scanning the Input string), where it finds a
possibility that an alphabet maybe the middle of the palindrome string.

 1 votes -- Amar Vashishth ( 17865 points)

8.346 minimum no. of states top gateoverflow.in/13754

only one state in both the cases NFA OR DFA . and by the way it is asking about minimal FA (NFA) so ans should be 1 only
.

ref : http://www.cs.odu.edu/~toida/nerzic/390teched/regular/fa/acceptor.html

 2 votes -- sonam vyas ( 6441 points)

8.347 change finite automata into regular expression using state elimination
method top gateoverflow.in/13510

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1182 of 2244

create the DFA of the above NFA and start eliminating the state for getting the RE

(aa+bb)(a+b)*

 0 votes -- rajesh srivastava ( 77 points)

8.348 Rice Theorem top gateoverflow.in/13848


Selected Answer

The decision problem here is given a TM M, does there exist an equivalent TM H, which runs in polynomial time and
accepts/rejects same as H and if M doesn't halt, H is free to do anything.

Here we need H to behave as M for all inputs on which M halts- so this is indeed a property of language of TM making
Rice's theorem applicable.

Is this property trivial? - No, because for some M, we can have an equivalent H as given (all NP problems), but for many
we don't have (problems outside NP). So, non-trivial property of language of TM make this problem undecidable as per
Rice's first theorem.

 1 votes -- Arjun Suresh ( 124125 points)

8.349 If L1 & L3 are regular & L3 = L1 . L2 top gateoverflow.in/13859

If L1 and L3 are regular & L 3 = L 1 . L2 then:

1. L2 has to be regular
2. L2 need not be regular

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1183 of 2244

3. L2 has to be context free


4. None of these

I came across this question and according to me the answer should have been option 1. But the workbook I picked up this
question from has option 2 as the answer. My reasoning was that when a regular language is concatenated with another
language, for the result to stay regular the second language has to be regular, or else the language thus obtained may
contain strings that cannot be derived through a FA.

Please advise as to what is the correct answer.

theory-of-computation


Selected Answer

I`m not sure , in my view option 2 is right .

see if L1 ={a+b)* any number of a and b can occurs

L2= {a,b} same number of a and same number of b (eg . ∊,ababba,ababba like that )

now L3 = L1.L2

L3 is regular where l3 (a+b)*

 3 votes -- Pranay Datta ( 6113 points)

regular language is concatenated with another language, for the result to stay regular the second language has
to be regular

This is wrong. Take regular language {} and concatenate with even a non r.e. language. We get {} it self which is
regular.

 4 votes -- Arjun Suresh ( 124125 points)

8.350 what is the total number of strings that can be generated from the
below FA ? top gateoverflow.in/14427

The FA above recognizes a set of stings of length 6, what is the total number of strings that can be generated from the FA?

a. 18
b. 20
c. 130
d. None

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1184 of 2244


Selected Answer

In above FA, at each transition, we can either go 1 step right, or 1 step up, and to reach accepting state, we have to take
exactly 3 steps right, and 3 steps up. So basically we have to find all distinct paths from initial to final state.

There are 6 steps total to be taken, out of which we can choose 3 right steps in ( 3 ) = 20 ways. Other 3 steps will be up-
steps so we don't have a choice there.

So there are 20 strings recognized by this FA.

 6 votes -- Happy Mittal ( 9253 points)

1 4 10 20

1 3 6 10

1 2 3 4

1 1 1 1

each number represents number of paths/number of strings possible

for leftmost row vertices and last row vertices each vertex ,only one path possible, for other vertices fill in bottom up
manner, no. of strings generated or no. of diff paths to a vertex is sum of distinct paths from its left vertex and down
vertex from where arrow is coming.

 3 votes -- Anurag Semwal ( 4775 points)

8.351 how to deal with TOC top gateoverflow.in/14318

Having trouble while doing TOC, specially with languages.

Please suggest somebook / notes / lectures.

Very frustrated with it.

theory-of-computation


Selected Answer

ways to deal with TOC

1.buy peter linz

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1185 of 2244

2.follow shai simonson lectures

3.follow Harry potter lectures from PORTLAND university

you can choose any one of it but always practice when you just finished a topic.

 2 votes -- Bhagirathi Nayak ( 10239 points)

Follow these materials- if you are having trouble watch the videos given

http://www.gatecse.in/theory-of-computation/

 2 votes -- Arjun Suresh ( 124125 points)

8.352 What does R represent here ? top gateoverflow.in/14283

Q). Let A = (a + b) ∗ ab(a + b) ∗ , B = a ∗ b ∗ and C = (a + b) ∗ .Then the relation between A, B and C is:

A). A + B = C

B). AR + BR = C

C). AR + B = C

D). None

http://gateoverflow.in//13162/plz-answer

 3 votes -- Pranay Datta ( 6113 points)

R means reverse of a string.

 1 votes -- Happy Mittal ( 9253 points)

8.352 If a Finite state machine that accepts a set, has no loop...eg: accepts
only 101. Is it the set regular? does it have the PUMPING LEMMA property?
(If it is regular but has no loops) top gateoverflow.in/11094

Yes its a regular language . if there is a loop in the state diagram then we can say that it produce infinitely many strings
(with some pattern) .

Pumping lemma can not used to prove the regularity of a language . if a language fails the pumping lemma test then we
can say its not a regular language but if it pass the test then the language may be regular or may not be .

 2 votes -- Pranay Datta ( 6113 points)

Concept :
If pumping lemma fails then language is not regular..
Contrapositive of this statement :
If language is regular then pumping lemma satisfied..

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1186 of 2244

So every regular set satisfy Pumping Lemma property trivially.. but reverse (i.e . If Pumping Lemma satisfy then regular)
may not be true..

 2 votes -- Digvijay Pandey ( 26245 points)

Ok see ,if it accept 101 and having no loop then this language becomes finite language that means its surely regular
language , coming back to your second question it may not satisfy Pumping Lema property because Pumping Lema use for
proving non regularity always use in negative sense , means if some language satisfy its property then language is not
regular but if not satisfy its property we can't say anything about language .

 1 votes -- kaushal ( 41 points)

8.352 Is it possible to build a Regular grammar for ( a^m a^n b^m c^n ) ? top
gateoverflow.in/10928

theory-of-computation


Selected Answer

Language is CFL but not regular..

L = a ^m a^n b^m c^n

= a ^n a^m b^m c^n. // inside outside comparison

It is CFL.

CFG for this language :

S ----> aSc| A

A ----> aAb| null

 4 votes -- Digvijay Pandey ( 26245 points)

8.353 answer this... top gateoverflow.in/4956

I Think L1/L2 can be written as L1-L2 so it should be B.

 0 votes -- Arpit Dhuriya ( 1791 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1187 of 2244

8.354 plz answer.. top gateoverflow.in/4955

Let A = {aaa, aaaaaaa, aaaaaaaaaaa, ..... } (length is a multiple of 4 plus 3)

Now, L1 = {a, aaa, aaaaa, aaaaaaa, aaaaaaaaa, ...} (all odd length strings in a)

L2 = {aaa, aaaaaaaaa, aaaaaaa, aaa...a (49 a's) .... }

Here L1 is regular and L2 is irregular.

But just because 1 example gave regular doesn't mean L1 is always regular. But 1 example gave irregular means L2 is not
regular.

I gave this example for better understanding. To prove L2 is irregular just take A = {aa}. Now, L1 = {aa, aaaa,
aaaaaaaa, ...} which is calculating the power of 2's which cannot be done using a regular language.

Now, to prove L1 is regular we must move more formally. It is not a trivial proof and two proofs are given in the link
below for sqrt and the same logic can be extended to other roots also (just by changing the final states).

http://math.stackexchange.com/questions/332720/if-l-is-regular-prove-that-sqrtl-left-w-ww-in-l-right-is-regular

 0 votes -- Arjun Suresh ( 124125 points)

8.355 please answer this.. top gateoverflow.in/4952

L is regular because there cannot be two "ab" in a string without a "ba" or vice versa. So, at any stage of processing the
input string, count of "ab" difference "ba" will be either 0, 1 or -1 and hence we just need a finite automaton to recognize
it.

 1 votes -- Arjun Suresh ( 124125 points)

8.356 I think the answer should be 32 but its not in options? Help me in this
question.. top gateoverflow.in/4838

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1188 of 2244


Selected Answer

First of all I would like to clear that empty language is ϕ and not λ and there is only one way to have final state in finite
automata then - By not having any final state at all . Now 16 is total number of transitions possible in DFA of two states
and two inputs. So possible number of DFA's with no final state= 16 , now there are 4 more possibilities when q1 is final
state and it is not reachable from initial state.. ( courtesy @Arjun sir ) Therefore ans is 16+4=20

 5 votes -- Prateeksha Keshari ( 1619 points)

8.357 plz answer this.. top gateoverflow.in/4957

(D). None of the above.

Both are not r.e.

L(M) is a regular set is a non-monotonic property of L(TM) as we can have a TM, T yes with this property (L(TM) = ∅) and a
TM Tno which does not have this property (TM for any non-regular language) and T yes ⊂ T no. Now, all non-monotonic
properties of language of TMs are unrecognizable or their language is not recursively enumerable.

For Co-REG also, the same proof holds. We just need to change T yes to a non-regular language and T no to Σ*.

http://gatecse.in/wiki/Rice%27s_Theorem_with_Examples

 1 votes -- Arjun Suresh ( 124125 points)

8.358 plz answer... top gateoverflow.in/4959

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1189 of 2244


Selected Answer

A is the answer.

Counting a finite number of steps in a TMs is always decidable. Whenever TM takes a step, increment a counter. Doing this
for 481 steps is always possible. If TM halts in between output "no", otherwise "yes".

Whether the Turing machine accepts empty string is undecidable. Easiest proof is using Rice's theorem. This is a non-
trivial property of L(TM) as there is a Turing machine accepting ϵ and is another TM which does not accept ϵ. And all non-
trivial properties of language of TMs are undecidable. (This problem is semi-decidable as if the TM accepts ϵ we can say
"yes". Only for the case when TM does not accept ϵ we cannot decide)

 3 votes -- Arjun Suresh ( 124125 points)

I think A is the answer.

 1 votes -- Arpit Dhuriya ( 1791 points)

8.359 Regular Languages top gateoverflow.in/5373

Hi @Arjun sir ,

Regular languages are closed under Symmetric difference and Right quotient operation.

So , in S 1 , the statement that "Regular languages are not closed under symmetric difference and quotient operation" is false .

So , S2 is only correct.

 1 votes -- Shounak Kundu ( 3757 points)

8.360 which of the following is false? top gateoverflow.in/5140

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1190 of 2244

for an arbitrary CFG G, there exist an algorithm

a) to check if L(G) contain infinite strings

b) to check which variable appear in some sentential form

c) to check which variable are nullable

d) to check which variable are useless

e) none of these

a is true. I don't understand the meaning of b, c, or d. Where is this question from?

 0 votes -- Arjun Suresh ( 124125 points)

8.361 Minimum no of states top gateoverflow.in/4984

Minimal finite automata that accepts all strings of a and b where the nth input symbol from right hand side is 'a'

a) 2n b)2n c) n d) n+2

A. As all the symbols upto nth input from the right must be checked. and there are 2 symbols a and b. So there must be
2n states.

 2 votes -- shreya ghosh ( 2801 points)

8.362 Let L1 is regular and L2 is CFG. Then what is L1-L2? top gateoverflow.in/4555

(A) Regular (B)CFG

(C)Deterministic CFG (D) Context Sensitive


Selected Answer

L1 - L2 = L1 ⋂ L2'

Now CFL complement need not be CFL (as CFL's are not closed under complement). But any CFL is also a CSL and CSLs
are closed under complement. So, any CFL complement is guaranteed to be a CSL. Now, CSL intersection CSL (regular is
also a CSL) is CSL, and so L1-L2 is always Context Sensitive.

(It can also be regular or CFL but we can say always only with respect to CSL)

http://gatecse.in/wiki/Closure_Property_of_Language_Families

 9 votes -- Arjun Suresh ( 124125 points)

8.363 Closure properties of Regular language. top gateoverflow.in/4206

Two Regular sets L1 and L2.

a) L3 = concatenation of L1 and L2

b) L4 = complement of L3

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1191 of 2244

c) L5 = first half of each string in L4

d) L6 = second half of each string in L4

e) L7 = concatenation of L5 and L6

f) L8 = intersection of L7 and L1

Q1) Language L5 is ( Ans : Recursive set)

Q2) Language L7 is ( Ans : CSL)

Q3) language L8 is ( Ans : CFl that may be regular)

Please Explain.

Regular set is closed under concatenation, complement and intersection.

http://infolab.stanford.edu/~ullman/ialc/spr10/slides/rs2.pdf

So, L3 and L4 are regular.

L5 = first half of each string in L4 which is a regular set. Now, first half of a regular set is regular. So, L5 is regular.

http://www-bcf.usc.edu/~breichar/teaching/2011cs360/half(L)example.pdf

Second half of a regular set must also be regular (I don't have a proof now). So, L6 is regular.

L7 and L8 are also regular as regular set is closed under concatenation and intersection.

 2 votes -- Arjun Suresh ( 124125 points)

8.364 Appropriate option for L top gateoverflow.in/74

Consider the following languages

L1 = {an bn ∣ n ≥ 0}
L2 = Complement(L1 )

Chose the appropriate option regarding the languages L1 and L2

(A) L1 and L2 are context free


(B) L1 is context free but L2 is regular
(C) L1 is context free and L2 is context sensitive
(D) None of the above

theory-of-computation normal


Selected Answer

L1 is clearly a DCFL and DCFL is closed under complement. Hence, L2 is also DCFL.
We can make a PDA for L2 , using the same PDA for {aⁿbⁿ} as follows:

Start by pushing each 'a' on to stack. When b comes start popping. If 'a' comes after a 'b' or 'b' comes when the stack is
empty, go to a final state from where the PDA accepts any string. Otherwise, at the end of the string, if stack is non-
empty, accept the string and if stack is empty, reject the string.

 2 votes -- Arjun Suresh ( 124125 points)

8.365 Let Σ = {a, b, c}. Which of the following statements is true ? top gateoverflow.in/69

Let Σ = {a, b, c}. Which of the following statements is true ?

a)For any A ⊆ Σ ∗ , if A is regular, then so is {xx ∣ x ∊ A}

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1192 of 2244

b)For any A ⊆ Σ ∗ , if A is regular, then so is {x ∣ xx ∊ A}

c)For any A ⊆ Σ ∗ , if A is context-free, then so is {xx ∣ x ∊ A}

d)For any A ⊆ Σ ∗ , if A is context-free, then so is {x ∣ xx ∊ A}

theory-of-computation difficult


Selected Answer

We can get a DFA for L = {x ∣ xx ∊ A} as follows:


Take DFA for A (Q, δ, Σ, S, F) with everything same except initially making F = ϕ.
Now for each state D ∈ Q, consider 2 separate DFAs, one with S as the start state and D as the final state and another
with D as the start state and set of final states ⊆ F. If both these DFAs accept same language make D as final state.

This procedure works as checking the equivalence of 2 DFAs is decidable.

Contradictions for other choices

a) Consider A = Σ ∗ . Now for w ∈ A, L = {xx ∣ x ∈ A} = {ww ∣ w ∈ Σ ∗ } which is context sensitive

c) Same example as for (a)

d) Consider A = {an bn c ∗ a ∗ bmcm ∣ n, m ≥ 0}


This is CFL. But if we make L from A as per (d), it'll be
L = {an bn cn ∣ n ≥ 0} which is not context free..

 5 votes -- Arjun Suresh ( 124125 points)

8.366 Identify the class of L top gateoverflow.in/67

Consider

L1 = {a b c d ∣ m, n ≥ 1 }
n n m m

L2 = {a b ∣ n ≥ 1 }
n n

L3 = {(a + b) } ∗

Intersection of L1 and L2 is

(A) Regular (B) CFL but not regular (C) CSL but not CFL (D) None of these

theory-of-computation normal


Selected Answer

Regular.
L1 ∩ L2
= {abcd, aabbcd, aaabbbccdd, …} ∩ {ab, aabb, aaabbb, …}
= ∅.

 3 votes -- Arjun Suresh ( 124125 points)

8.367 If anybody have some note or link to the topic like NP related
questions, Please provide. I have never been successful in answering these

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1193 of 2244

type of question. Any help will be really appreciated. top gateoverflow.in/109

If anybody have some note or link to the topic like NP related questions, Please provide. I have never been successful in
answering these type of question. Any help will be really appreciated.

check dis

http://gatecse.in/wiki/NP,_NP_Complete,_NP_Hard

 2 votes -- Shreyans Dhankhar ( 2265 points)

8.367 is Palindrone string a NCFL ? top gateoverflow.in/1133

yes. It is CFL and not DCFL. Only if some separating character like 'c' is at the middle it will be DCFL.

 2 votes -- gatecse ( 9515 points)

Palindrome mean that can be even palindrome or that can be odd palindrome

In even palindrome say L = w w r where we need to give a transition (in between with the help of ∊) after which we know
reverse get started.

L= w ∊ w r [eq: ababbaba as abab∊baba ]

before ∊ we need to push symbols in stack , after∊we need to pop symbol from stack

PUSH operation

δ(q,a,Z) =δ(q, aZ)


δ(q,b,Z) =δ(q, bZ)
δ(q,a,a) =δ(q, aa)
δ(q,b,b) =δ(q, bb)
δ(q,a,b) =δ(q, ab)
δ(q,b,a) =δ(q, ba)

then DONOTHING

δ(q,∊,a )= (q1,a)

δ(q,∊,b )= (q1,b) [State change with ∊ , a Mark now we will get w r, so we need to do POP]

then POP operations

δ(q1,a,a) = (q1, ∊)

δ(q1,b,b)= (q1,∊)

Then acceptance
δ(q1,∊,Z) = (qf ,∊)

So Palindrome is NCFL

Note: we talk about L= { wcw r | w∊ (a,b)* } that is DCFL ,

 1 votes -- Praveen Saini ( 34299 points)

8.368 Language accepted by TM top gateoverflow.in/4205

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1194 of 2244

Above TM
accepts language 0^+.

Q 26. Ans is ( given ) csl.

My Understanding :

Above TM halts only on 0^+ input.

For combination of 0's and 1's it will not halt. Will run forever. It means it is Recursive Enumerable language. ( undecidable
/ Semidecidable )

So 0^+ is RE ??? ( I m confused here)

A language is nothing but a set of strings. So, a TM can accept multiple languages (if a TM accepts a language any subset
of that language is also accepted by the TM).

So, the 26 questions seems wrong- it should be language "decided by" or "recognized by" and not "accepted by". For
accepted by, we can give any language whose strings take the TM to final state. {00}, {000, 0000} etc are examples.
"Decided by" forces the TM to reject any string not in L while "recognized by" forces the TM to accept all strings in L and
not accept (reject or loop forever) any string not in L.

http://theory.stanford.edu/~trevisan/cs154-12/turing-machines-1.pdf

 1 votes -- Arjun Suresh ( 124125 points)

8.368 What is the type of the language I,where L=


{a^nb^n|0gateoverflow.in/3582
top


Selected Answer

L contains aabb, aaabbb, aaaaabbbbb, ... a kbk where k is the largest prime below 327. Now there are only a finite set of
strings in L making it a finite language. L can be accepted by a finite automaton.

 4 votes -- Arjun Suresh ( 124125 points)

8.369 FSM top gateoverflow.in/1867

Suppose we have an encoding of a fsm ... 1.is it regular? 2.does the fsm accepts its own encoding ?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1195 of 2244

I guess what you mean is weather the set of encodings of all fsms is regular.

That depends on the encoding you choose, and yes we can create an ecoding such the the set of all encodings is regular.

A fsm which accepts the set of all encodings will then accept its own encoding.

 1 votes -- Omesh Pandita ( 2209 points)

8.369 what closure properties DCFL holds? top gateoverflow.in/5390

http://gatecse.in/wiki/Closure_Property_of_Language_Families

 0 votes -- Arjun Suresh ( 124125 points)

8.370 Does PDA accepts L={a^n b^n | n>=0 , n!=13}??? top gateoverflow.in/5480

If it does, how??

theory-of-computation easy

L= {a b
n n ∣ n ≥ 0, n ≠ 13 }
Consider the following Languages:

L1 = {a b
n n ∣n≥0 }
L2 = Σ ∗ − a13b13

We can see that

L1 is a Deterministic Context Free Language ( DCFL)


L2 is a Regular Language ( RL)
L = L1 ∩ L2

Since DCFL ∩ RL = DCFL, we can conclude that L is DCFL.

To draw the DPDA for L:

Draw a DPDA for L1


Draw a DFA for L2
Take the product of the two machines. It is simple. The procedure for doing that is listed in this pdf(Click to view)

 3 votes -- Pragy Agarwal ( 13675 points)

8.371 Regular Languages and Homorphism top gateoverflow.in/10700

Q-1 Why Half(L) = x | for some y such that | x | = | y | , xy is in L i.e first half of strings in L is regular? Here L is a regular language

Q-2 If h(a)=01 , h(b)=0 Find h -1(L) where L={w|w contain equal no of 1's and 0's}

Q-3 If L is regular then L1={uv:u ∈L, v∈L R} is regular? Plz explain this too..

Q-4 L1 = xy | x ∈ L and y ∉ L, L is regular is regular ?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1196 of 2244

theory-of-computation

FIRST NOTICE FOR ALL QUESTIONS it is said L is regular. hence it would have a DFA and finite number of states.

in QUESTION 1 now string are in two parts x and y. and it is said |x| = |y| .. as L is regular it would need finite steps to
generate ITS strings. and so if it takes finite steps to generate xy.. IT WOULD SURELY TAKE finite steps to generate x and
y ..the two halves .. HENCE HALF(L) IS REGULAR as x and y can be done in finite steps wich is apropert of FINITE
AUTOMATA

in QUESTION 2 it is said about homomorphic inverse ..and we know given a string homomorphic inverse is how using
alphabets we can derive a string.HERE eg 0101 can be by aa as no of 0 and 1 is equal.hence if we want n sequences it
would be of the form a n. REGULAR EXPRESSIONS ARE CLOSED UNDER HOMOMORPHIC INVERSE

in Question 3 it is said that NOTICE L1 IS made up of concatination of L and L R. . we know L has dfa and that dfa can be
reversed (by interchanging final and start start). hence L1 is nothing but a concatenation of two REgular languages and L1
IS REGULAR

NOW watch the 4 question, L1 is made up of x and y .. where x ∈ L hence REGULAR . now y ∉ L THAT MEANS IT IS
COMPLEMENT OF L . we again know we can complement DFA .. hence again it is reduced to a case of CONCATENATION
OF TWO REGULAR LANGUAGES. HENCE IT IS REGULAR

 1 votes -- ANI ( 503 points)

8.372 DFA for 00+11+(01+10)(00+11)*(01+10) top gateoverflow.in/10672

Below DFA is accepting above regular language but it is accepting null also....can anyone please give correct DFA


Selected Answer

DFA : 6 states

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1197 of 2244

 1 votes -- aayushranjan01 ( 325 points)

8.372 If any FA has three states & only one +, must it reject some inputs?
(alphabet set {a,b}) top gateoverflow.in/10670

theory-of-computation

8.373 Min DFA and Homomorphism top gateoverflow.in/10660

Q- Give the min DFA corresponding to 01[((10)*+111)*+0]*1

Q-2 Consider the homomorphism , h(0)=aba, h(1)=abb

Given L2=(a+bb)*ba find h -1(L2)

a) 0* b)100* c)1*0 d)11*0

8.374 CNF grammar top gateoverflow.in/10731

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1198 of 2244

in B) production is S->AB(if in image it is not clear)

S → AB

A → SSA|aA|∊

B → bA|a

In CNF , grammar should in form

N → NN (Nonterminal → Two Nonterminals only)

N → t (Nonterminal → terminal only)

N represent a Nonterminal , t represent a terminal

So null production should be removed

After removing null production (A → ∊)

S → AB | B

A → SSA|aA|SS|a

B → bA|a|b

Now we get a unit production (S → B ) it should be removed

after removing unit production

S → AB | bA|a|b

A → SSA|aA|SS|a

B → bA|a|b

Now as per format we cannot have nonterminal and terminal together (as S → bA is not allowed)

let A' → a and B' → b

now grammar is

S → AB | B'A|a|b

A → SSA|A'A|SS|a

B → B'A|a|b

A' → a

B' → b

Now as only two nonterminal is allowed (A → SSA is not allowed)

break it into two parts

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1199 of 2244

now grammar is

S → AB | B'A|a|b

A → SA''|A'A|SS|a

B → B'A|a|b

A' → a

B' → b

A'' → SA

is final answer

it seems none is correct in options

 2 votes -- Praveen Saini ( 34299 points)

8.375 ambiguity in grammar top gateoverflow.in/10732

Which of the following describes the minimum condition for ambiguity in a grammar?
a) Every derived word must have atleast 2 rightmost derivation
b) some word must have more than 1 leftmost derivation
c)A derived word has one rightmost and another leftmost derivation
d)each derived word has 2 leftmost and 2 rightmost derivation


Selected Answer

If a word (atleast one), that grammar generates, can be derived has two (or more) derivation that corresponds into
different derivation (parse) tree. That Grammar is ambiguous.

Ans. B is correct

a) Every derived word must have atleast 2 rightmost derivation

wrong as one word is sufficient.

c)A derived word has one rightmost and another leftmost derivation

wrong bcoz parse tree for left most derivation and rightmost derivation of a word can be same.

d) each derived word has 2 leftmost and 2 rightmost derivation

wrong , as no need to check each derived word, only one word having two derivation with different tree is sufficient.

b) some word must have more than 1 leftmost derivation

right , atleast one word that can be derived by two derivation ( left, right or mix) have different tree .

Tree will be different if one word has two leftmost (or right most ) derivation .

 4 votes -- Praveen Saini ( 34299 points)

8.376 Which of the the languages are CFL ( and not ) top gateoverflow.in/10874

Q 1.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1200 of 2244

My answer is (c) all are CFL ,

as in case of L1 , we can break it as a n am c2m c2n : so we can compare using a stack

in case of L2 , we can compare either of them , so it is CFL

In case of L3 , it can also be resolved using a single stack . So , this is also CFL.

Q2.

Here in the question , S->aS | bS | a | b , my answer is (a+b) + (b).

Am I correct in solving these questions ?

theory-of-computation


Selected Answer

Q1.

L1 = {a pc2p | p ≥ 0} is DCFL

L2 is CFL but not DCFL as we cannot deterministically check two unbounded conditions using a single check but the
conditions being OR we can do this non-deterministically.

L3 again is CFL but not DCFL. At every point we have two options- to equal the number of 0's or to double the number of
0's.

Q2.

Options b, c and d aren't same?

Q3. X-> aX|bX|a means anything ending with a that is (a+b)*a


Y -> Ya|Yb|a means anything start with a that is a(a+b)*

S->XY that is (a+b)*aa(a+b)*

in the given options , (d is fit. even though it is not same )

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1201 of 2244

 2 votes -- Arjun Suresh ( 124125 points)

8.377 Question on Regular expression - 2 top gateoverflow.in/10866

Answer given as : e

But , my question is (P*Q*) * = {null string , any number of P , any number of Q , P followed by Q , }

whereas (P*+Q*)* = { null string , any number of P , any number of Q , P followed by Q , Q followed by P }

So , in the (P*Q*)* , Q followed by P is not possible . So , how they can be equal ?

theory-of-computation


Selected Answer

(P*Q*)* = null + (P*Q*) + (P*Q*)(P*Q*) + (P*Q*)(P*Q*)(P*Q*) + .....


Now lets take (P*Q*)(P*Q*);
((NULL + P + PP ...)Q*)(P*(NULL + Q + QQ + QQQ ...)
// combine Q* and null from 1st bracket and P* and null from 2nd
= (Q*P*)

rearrange P*, Q* for other combination..

 3 votes -- Digvijay Pandey ( 26245 points)

8.378 CFG top gateoverflow.in/10742

Plz answer above 2 questions

well the answer is here . but it's far beyond my understanding . anybody plz explain .

https://courses.engr.illinois.edu/cs498374/fa2014/notes/02bis-context-free.pdf

 0 votes -- Ravi Singh ( 7303 points)

8.379 Regular Languages top gateoverflow.in/10636

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1202 of 2244

8.380 Language represented by Regular Expression top gateoverflow.in/10625

L={w|the number of consecutive 1's in w is 0 or multiple of 4}

L is represented by which of following regular expression?

a)[(1111+1)*0*]*

b)(1111+10+0)*

c)(111*+10*)*

d)0*(111+1)*0*

8.381 cyk algorithm is used for CFG'S to test which class of problem??? top
gateoverflow.in/6425
cyk algorithm is used for CFG'S to test which class of problem???

CYK algorithm is a dynamic programming method of order O(n^3) to find the membership property of CFG.

 3 votes -- ansaritk ( 83 points)

8.381 complement of every contet free language is recursive ? or recursive


enumerable? or both? top gateoverflow.in/6370


Selected Answer

Both. Also, context-sensitive.

CFL is a strict subset of CSL. CSL is closed under complement. So, CFL complement is CSL.

And CSL is a strict subset of recursive which in turn is a strict subset of recursively enumerable.

 2 votes -- Arjun Suresh ( 124125 points)

8.382 An NFA has 7 states of which 3 are final states. The maximum number
of final states in converted DFA would be ______? top gateoverflow.in/5916

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1203 of 2244

theory-of-computation

We have four state which is not finale so all these state which come together to form a state in dfa are not have any finale
state in dfa.
so possible dfa state with only these 4 states is 24 = 16 and total number of state is 2 7 = 128 so total number of state
which contain final state is 128 -16 =112.

 6 votes -- Arpit Dhuriya ( 1791 points)

8.382 in op C : L1: a^n + b^m L2=R(L1)=a^m + b^n . So L1 U L2= a^(m+n)


+ b^(m=n) ----> How it is becoming Σ∗ top gateoverflow.in/6534

Compl(L1) is not L2 here. Complement of L1 means all strings not in L1 which means Σ* - L1

 0 votes -- Arjun Suresh ( 124125 points)

8.383 DFA top gateoverflow.in/6732

Please explain..


Selected Answer

The answer is C) Both S1 and S2 , since δ(q0,a) = δ(qf,a) for all a ∈ ∑ we know that which ever state q0 goes on any string
s, qf also goes to same state on string s, so S1 is true. S2 is also true since q0 goes to final state on x, so qf will also go
to final state on x, so any xk string will lead to final state.

 0 votes -- Omesh Pandita ( 2209 points)

8.384 Minimum No of states in Finite Automata top gateoverflow.in/10055

Minimum state Finite Automata recognizing the language corresponding to following Regular Expression

(0*10+1*0)(01)*

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1204 of 2244

a)3 b)4 c)2 d)5

Also please show Finite Automata for it.


Selected Answer

atleast 6 states are required in FA construction for this language, as shown below:

 2 votes -- nitishsandhu ( 125 points)

dfa for the same

 1 votes -- aayushranjan01 ( 325 points)

8.385 Finding the rank of variable for CFG top gateoverflow.in/7149

Consider the following CFG

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1205 of 2244

S->AB, A->BC|a , B->CC|b , C->AB|a ,

What will be the rank of the variable of B?

In order to find RANK grammar must be in CNF form.

From that grammar consider only rules involving variables like A-> BC

Construct a directed graph from every rule of the form v ariable -> variable variable. If A-> BC then A, B and C are
nodes. There is an edge from A to B and edge from A to C.

Rank of Variable is the longest path(no of edges) starting from that node.

In this example ther is a cycle involving B so Rank of B will be infinity

 0 votes -- Balaraju Anthony ( 11 points)

8.386 The number of states in a DFA accepting all the strings over {0,1} in
which 5th symbol from right hand side is always '1' is? top gateoverflow.in/7050

Will the answer be 4 or 25 ?


Selected Answer

It will be 2 5 as 2 5 possible combinations of characters are possible with the 5th last character being 1. We need to
remember each of them as any of them can be the 5th last character as we continue processing further characters.

 5 votes -- Arjun Suresh ( 124125 points)

8.387 L=set of all bit strings with even number of 1's ...Regular Expression
will be . top gateoverflow.in/15991

Options are

a) (0*10*1)*

b) 0*(10*10*)

c) 0*(10*1)*0*

d) 0*(10*1)*10*

I have doubt in b and c.which one is correct and why.?

clearly none of the answers actually match .try 110011 as already mentioned. .. I dont think ambiguous questions will be
given in GATE.

 0 votes -- admin ( 1411 points)

8.388 The number of different languages over any alphabet of more than one
symbol is not countable. T/F ? top gateoverflow.in/16065

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1206 of 2244

it is True ,but not getting how give me proof for his . above statement from a book by hopcroft and ullman.

theory-of-computation

can give a informal proof to remember. the set of all string of a language is countable where as the set of all languages is
uncountable because we can put all the string is proper odering and then they can be enumerated . while suppose you
yake set of all languages now even first language will be having infinite strings. like the case of real number . so u will
never reach the language 2 . this he informal proof formal proof is diagonalization method.

 0 votes -- Ravi Singh ( 7303 points)

8.389 if w ϵ (a,b)* satisfy abw = wab then length (w) is ? top gateoverflow.in/28045

8.389 what is the diff between (a+b)* and (a*b*)* ? top gateoverflow.in/28041


Selected Answer

No difference. Both are same.

(a b )
∗ ∗ ∗
= (( ) (
ε + a + aa + … ⋅ ε + b + bb + … )) ∗

(
= a + b + some other strings ) ∗

= (a + b) ∗

 4 votes -- Digvijay Pandey ( 26245 points)

8.390 Let A= (a + b)* ab (a + b)*, B= a*b* and C= (a + b)*. Then the


relation between A, B and C: top gateoverflow.in/27869

Let A= (a + b)* ab (a + b)*, B= a*b* and C= (a + b)*. Then the relation between A, B and C:
A. A+B= C

B. AR+BR= C

C. AR+B= C

D. None

theory-of-computation


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1207 of 2244

A = (a + b) ∗ ab (a + b) ∗ Strings containing substring ‘‘ab "

AR = (a + b) ∗ ba (a + b) ∗ Strings containing substring ‘‘ba "

B = a∗ b∗ All a's should come before any b's

BR = b∗ a∗ All b's should come before any a's

C = (a + b) ∗ All strings

Now,

A + B doesn't give us all the strings. For example, A + B doesn't contain the string ‘‘ba " .

Thus, A + B ≠ C

AR + BR doesn't give us all the strings. For example, AR + BR doesn't contain the string ‘‘ab " .

Thus, AR + BR ≠ C

AR + B does give us all the strings!

First, lets look at which strings don't come in B. They are the ones that contain atleast one such ‘‘a " that occurs after
some ‘‘b " . For example, B doesn't contain the string ‘‘aba "

Now, we observe that all the strings that do not come in B, satisfy the property for AR, and hence come in AR.

Thus, if we union AR and B, we will get all strings.

Hence, AR + B = C

Another way to verify it is by constructing an NFA for AR + B, converting it to DFA and minimizing it.

 4 votes -- Pragy Agarwal ( 13675 points)

8.391 Number of Substrings top gateoverflow.in/27816

Total number of sub strings present in "GATE" is

A)7 B) 10 C) 11 D) 8


Selected Answer

0 length = 1 ( null)

1 length = 4 (G,A,T,E)

2 length=3 ( GA, AT , TE)

3 length= 2 ( GAT, ATE)

4 length = 1( GATE)

total= 1+2+3+4+1= 11

 5 votes -- Anirudh Pratap Singh ( 4091 points)

8.392 How to tell which of the languages are regular ? top gateoverflow.in/28207

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1208 of 2244

theory-of-computation

Here y is a regular set

As y∊ A and A is a regular set

Here y=x n

So, here xn have to be regular

But in x= y n

y is regular but y n may not be regular

say y = a *b*

but yn=anbn

So, here x=yn is not regular

 0 votes -- srestha ( 11585 points)

8.393 what is the left quotient of a CFL with a regular language ? top gateoverflow.in/28698

If I take L=a^n b^n and R=(a+b)* so I am getting the value of L/R to be regular ,Am I correct ?

theory-of-computation

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1209 of 2244

I think ans will be (B )

B is a part of xy , as y∊B

xy∊ A ,

now L/R (or A/B or xy/y)

=CFL / regular

let CFL =a nbn

regular= b4

So, L/R= anbn-4

which is also CFL

 1 votes -- srestha ( 11585 points)

8.394 TOC top gateoverflow.in/28823

Why Min(L) ≠ Complement((Prefix(L))?

Min(L) is set of all strings w in L where every proper prefix of w is not in L

Prefix(L) is set of all prefix of w ∈L

Min(L) is set of all strings w in L where every proper prefix of w is not in L

MIN (L) is subset of L. [as it defines] ----------------------- (I)

Example : Let us take L={1,11,000,1100}

Min(L)= {000,1} is subset of L.

Prefix(L) is set of all prefix of w ∈L

Prefix(L) is superset of L

Prefix(L) contains all strings of L [as every strings is prefix of itself] ---------- (||)

Example(continued) : Prefix(L)={0,00,000,1,11,110,1100} , all strings of L are contain in Prefix(L)

Using II, we can say

Complement of Prefix(L) = Prefix(L) ′ , doesn't contain any string of L ------------------------- (III)

Example(continued) : complement(Prefix(L))=(0+1)* - {0,00,000,1,11,110,1100}

Using (I) and (III),

Min(L) ≠ Prefix(L) ′ , and it holds for any language L .

 3 votes -- srestha ( 11585 points)

8.395 The vernacular English ,if considered a formal language is a top gateoverflow.in/28785

The vernacular English ,if considered a formal language is a _______________________________

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1210 of 2244

a) Regular

b) CFL

c) CSL

8.396 Regular/Non Regular. Is the below language context free ? top gateoverflow.in/28701

For a set of string A, define the set FirstHalves A = {x | ∃y, | y | = | x | and xy ∈ A}


For example, FirstHalves {a, ab, bab, bbab} = {a, bb}
if A is regular, then FirstHalves is
(A) Regular
(B) Context-free but not-regular
(C) Recursive but not context-free
(D) None of the above

theory-of-computation


Selected Answer

A is regular , then FirstHalves or Half(A) is also regular.

1. Design DFA, M of language A

2. Find the reversal of DFA M , say N.

3. Traverse M for one transition (for given Σ ) and N for one transition (for given Σ ) , and repeat the process.

4. if We reach at common states, Mark them as New finals in DFA M (remove old final and do minimization )

5. Result is DFA of Half(L) or FirstHalve(L)

[Note: in Short, design DFA for A , traverse from both directions (start and final),if reach at common states with same no of transitions, make them as new finals, result will be
DFA for Half(L) ]

 4 votes -- Praveen Saini ( 34299 points)

8.397 dfa top gateoverflow.in/27740

No of states in minimal dfa of binary strings starting with 100 and length is congruent to 1 mod 12

theory-of-computation

We have two language

L1 = { all strings over {0,1} start with 100} having regular expression 100(0+1)*

having DFA M1 :

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1211 of 2244

and, L2 = { |w|mod12 =1 , w∈{0,1}* }

having DFA M2 :

And we have to find L1 ∩ L2 using cross product of two DFA having x0y0 as start state and x3y1 will be final state
satisfying both conditions

States\Symbols 0 1

->x0y0 x4y1(dead) x1y1


x1y1 x2y2 x4y2(dead)
x2y2 x3y3 x4y3(dead)
x3y3 x3y4 x3y4
x3y4 x3y5 x3y5
x3y5 x3y6 x3y6
x3y6 x3y7 x3y7
x3y7 x3y8 x3y8
x3y8 x3y9 x3y9
x3y9 x3y10 x3y10
x3y10 x3y11 x3y11
x3y11 x3y0 x3y0
x3y0 x3y1 x3y1
x3y1* (final) x3y2 x3y2
x3y2 x3y3 x3y3
dead dead dead

[Remember in case of intersection strings must be accepted by both DFA's (i.e, satisfying both conditions) so once we get dead state of any DFA that will remain
dead state, and final state will have finals of both ]

So Resulting DFA will be

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1212 of 2244

having 16 states .

 2 votes -- Praveen Saini ( 34299 points)

16 States

 1 votes -- Amar Vashishth ( 17865 points)

8.398 dfa for wxwR , w,x belong to (a+b)^+ top gateoverflow.in/27552

Can anybody draw DFA for (a(a+b) + a(a+b)+)+(b(a+b)+ b(a+b)+) ?

How many number of states in above dfa?

theory-of-computation


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1213 of 2244

a(a+b)+a(a+b)+ + b(a+b) +b(a+b)+

= (a(a+b)+a +b(a+b) +b)(a+b)+

Here is NFA for it

And equivalent Minimal DFA is

having 7 states

 4 votes -- Praveen Saini ( 34299 points)

8.399 why are turing machines countably infinite ? top gateoverflow.in/27148

why in diagonalization method , we complement the diagonal bits first , and then prove that the language does not belong to the table so power set of all strings is
uncountable.

http://cs.stackexchange.com/questions/10780/why-is-this-true-there-are-countably-many-turing-machines

We are trying to prove that the set of languages is uncountable. So, first we assume it as countable. We define a matrix

1. a row represent a language


2. a column represent either 0 or 1 meaning string represented by that column is in L.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1214 of 2244

So, the matrix is infinite in both row as well as column.

Now, if the set of languages are countable all languages must be present here. But this is not true and to show why, we
define a new language by taking the diagonal entries of the matrix and complementing them. This complementing ensures
that at least for one string (the diagonal string for each language) our new language will be different from every other
language in the matrix, making it necessarily a new language. And that's all we want.

 1 votes -- Arjun Suresh ( 124125 points)

8.400 How to construct PDA for the given language ? top gateoverflow.in/27010

If input symbol is{ a, b} and L ={no of a's =2*no of b's } , issue here is that since we do not have any sequence so what
should be done when I see any a or b ?

Sorry for such a late reply, please check whether this answer is correct or not.

 0 votes -- Morphine ( 273 points)

8.401 How do we empty non-terminals from the stack in this pda ? top gateoverflow.in/26987

In this one how come from q1 we are directly converting it into qf , since non-terminals have not been emptied , this
method is for converting grammar in GNF to PDA .

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1215 of 2244

8.402 Which of the following properties of a Recursively enumerable set L


is/are recursively enumerable? top gateoverflow.in/27263

A) L is regular
B) L is finite
C) L is set of palindromes

Can a regular set be a proper subset of an irregular set?

Can a finite set be a proper subset of an infinite set?

Can a set of palindromes be a proper subset of a set of non-palindromes?

If you can answer this you should know the answer because that is what Rice;s theorem part 2 says.

http://www.gatecse.in/803-2/

 1 votes -- Arjun Suresh ( 124125 points)

L is regular not closed for RE since this is Regularity property.

L is finite not closed for RE since this is finiteness property.

 1 votes -- Anirudh Pratap Singh ( 4091 points)

8.403 recursive enumerable or not top gateoverflow.in/27284

Tell whether language is re or non re

1)Does L(M) contain atleast two strings?

2)Is L(M) infinite?

3)Is L(M) context free language?

4)is L(M) =(L(M))^R

8.404 What is the language accepted by below NFA ? top gateoverflow.in/27531

I am having problem while converting it into NFA since it is an epsilon-NFA , so I got

q0----> {q0,q1,q2} on a

q1---> {q0,q1,q2} on a

then finally for DFA I got {q0,q1,q2} and q0 as two states such that {q0,q1,q2}---> {q0,q1,q2} on a and q0 --->
{q0,q1,q2} on a ,plz tell the mistake ,I am unable to catch it.

http://gatecse.in/w/images/c/c5/2012_12.png


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1216 of 2244

I. Check the strings reaching the final state

{ a,aa,aaa,aaaa,......} = a + , or, { all strings over {a}, except ∊}

II. Remove ∊-moves

∊-closure(q0) = {q0}

∊-closure(q1) = {q0,q1,q2}

∊-closure(q2) = {q0,q2}

NFA with ∊-moves to NFA

States\Symbols a
->q0 {q0,q1,q2}
q1* {q0,q1,q2}
q2 {q0,q1,q2}

DFA

States\Symbols a
->q0 {q0,q1,q2}
{q0,q1,q2}* {q0,q1,q2}

L = a + = {a,aa,aaa,aaaa,aaaaa,....}

 2 votes -- Praveen Saini ( 34299 points)

8.405 show L is re but not rec top gateoverflow.in/27293

let L be language consisting of pair of tm codes and an integer (M1,M2,k) such that L(M1) intersect L(M2)contains atleast k
strings show L is RE but not recursive

To Prove: L is RE but not REC.

Proof:
Let a turing machine M accepts the language L.

What that machine does is that for each set ⟨M1 , M2 , k⟩ (which is its own input) it simulates some strings on the machines M1 and M2 i.e. give
a string at a time to both of them as input to those machines. If they accept atleast k of those input strings presented by M to them then we
say, accepted and Halt our turing mahcine M.
So, Machine M halts and accepts on all accepted inputs. Hence, L is RE.

but, if no string is common to M1 and M2 , say, input set is ⟨a ∗ , b ∗ , 7⟩ then machine M will never halt. it keeps feeding those machines ∞ input
strings.
Hence, it does not halt on all strings which are not in the language. ∴ L is not REC.

Hence, L is RE but not REC.

 1 votes -- Amar Vashishth ( 17865 points)

8.406 recursive enumerable or not top gateoverflow.in/27285

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1217 of 2244

Tell whether language is re or non re

1)Does L(M) contain atleast two strings?

2)Is L(M) infinite?

3)Is L(M) context free language?

4)is L(M) =(L(M))^R

Use rice theorm

Tyes = ∑* and Tno= ∅. so not rec

http://gatecse.in/wiki/Rice%27s_Theorem_with_Examples

just go through it once.

 1 votes -- Anirudh Pratap Singh ( 4091 points)

8.407 toc top gateoverflow.in/29049

which languages are closed under membership?

also explain how r u finding it?

8.408 Regular top gateoverflow.in/29090

L={xwwr |x,w ∈ (a + b)+} this is not regular


proof ?

L={XWWr | X,W∊(a+b)+}

Here WW r is NCFL(because we can push all the term of W in a stack and W r pop those terms.So it is CFL and also here
middle term is not known . So it is NCFL)

here X is regular i.e. (a+b)+

Now reguler .CFL= CFL [Only phi . CFL=phi i.e. regular, but here phi is not possible , as X= (a+b) + ]

So, it cannot be regular

 0 votes -- srestha ( 11585 points)

8.409 Consider languages L and L1 top gateoverflow.in/30040

Consider languages L and L_{1}, each over the alphabet {a,b }, where
L_{1} = \left \{w \mid w contains some x \in L as substring \right\}

Which of the following must be true about L and L_{1} ?

I. If L is regular, then L_{1} is regular.

II. If L is context-free, then L_{1} is context-free.

III. If L is recursive, then L_{1} is recursive.

(A) I only (B) III only (C) I and III only (D) II and III only (E) I, II, and III

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1218 of 2244

theory-of-computation

8.410 Plz explain top gateoverflow.in/29996

. Consider these 2 statements:

S1: LR = L, if and only if L is the language of palindromes. where LR is obtained by reversing all the strings of L.

S2: | L1∙ L2 | = | L1 | × | L2 |

Relation?

(a) Both are F (b) Both are T 2 (c) S1 → T, S2 → F (d) S1 → F, S2 → T

8.411 decidability top gateoverflow.in/29907

if A is context free language and B is a language such that B⊂A then B must be?

It may or may not be CFL , but I think It must be CSL.

example:

1. L = {aibjck | i = j or j = k , i, j, k ≥ 0} is CFL.

but its subset {an bn cn | n ≥ 0} is CSL.

2.L = {ambn | m ≥ n, m, n ≥ 0} is CFL

but its subset {an bn | n ≥ 0} is also CFL , so CSL too

 4 votes -- Praveen Saini ( 34299 points)

8.411 if Lis a language of even binary number then L is? top gateoverflow.in/29906

It will be regular

 0 votes -- srestha ( 11585 points)

8.412 DFA top gateoverflow.in/30630

construct DFA that accepts all binary numbers are divisible by either 2 or 3

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1219 of 2244


Selected Answer

DFA M1 that accepts binary no's divisible of 2

DFA M2 that accepts binary no's divisible of 3

Find DFA M by UNION (using cross product) that accepts binary no's divisible by 2 or 3

Q↓Σ→ 0 1

→ x0 y0 ∗ x0 y0 x1 y1
x1 y1 x0 y2 x1 y0

x0 y2 ∗ x0 y1 x1 y2
x1 y0 ∗ x0 y0 x1 y1
x0 y1 ∗ x0 y2 x1 y0
x1 y2 x0 y1 x1 y2

States having any of x0 or y0 are final states ( bcoz of union)

States x0 y0 and x1 y0 are equivalents (clearly as in table) so one of them can be removed (minimization)

Minimized DFA M

Q↓Σ→ 0 1
→ x0 y0 ∗ x0 y0 x1 y1
x1 y1 x0 y2 x0 y0
x0 y2 ∗ x0 y1 x1 y2
x0 y1 ∗ x0 y2 x0 y0
x1 y2 x0 y1 x1 y2

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1220 of 2244

having 5 states

 1 votes -- Praveen Saini ( 34299 points)

8.413 why do we add an initial state while transforming PDA acceptance by


final state into PDA acceptance by empty string ? top gateoverflow.in/30849

I have gone through this link already but still couldn't catch up the logic , so please clarify what is it trying to convey ?

http://cs.stackexchange.com/questions/44195/pda-transformation-between-acceptance-by-empty-stack-and-final-states?
rq=1

theory-of-computation

8.414 Let L ≤ ML′ denote that language L is mapping reducible (many to one
reducible) to language L top gateoverflow.in/32216

Let L ≤ ML′ denote that language L is mapping reducible (many to one reducible) to language L′. Which one of the following
is True?

1. If L ≤ PL′ and L′ is semidecidable then L is semidecidable.


2. If L ≤ PL′ and L is RE then L′ is RE.
3. If L ≤ PL′ and L is decidable then L′ decidable.
4. If L ≤ PL′ and L is recursive then L′ is recursive.

Could anyone please solve this and explain the this reducibility logic ?

theory-of-computation made-easy test-series

8.415 REL top gateoverflow.in/32108

How to tell whether a language is recursively enumerable or not?

Also answer the question with proper algorithm :-)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1221 of 2244

No I think ans will be (C)

M will be non recursive enumerable here.

After accepting 312929 strings it will accepting inputs, but here it accepts all. So, here is a chance of forming loop.(we can
think like dfa, when dfa accepts all, it forms a self loop on last state). But when we examining loop doesnot gives 'yes'
answer. So, 'yes' answer not possible. According to rice theorem it will be non trivial property. So, M will be non recursive
enumerable here.

 0 votes -- srestha ( 11585 points)

8.416 construct NFA top gateoverflow.in/31911

Construct a transition table and diagram for the NFA

M=({q1,q2,q3},∂,q1,{q3}) where ∂ is given by

∂(q1,0)={q2,q3}, ∂(q1,1)={q1},

∂(q2,0)={q1,q2}, ∂(q2,1)=∅,

∂(q3,0)={q2}, ∂(q3,1)={q1,q2},

8.417 #toc top gateoverflow.in/29873

L1 = {a mbnckdl | if(m=n) then (k=l)}

L2 = {a mbnckdl | if(n=k) then (k=l)}

which of the above two languages are not cfl ??

how to solve such type of questions?

One that can be implemented with PDA (with the help of one stack), will be CFL.

L1 = {ambn ckdl | if(m = n)then(k = l)}

L1 is CFL , if no of a ′ s = no of b ′ s then we need to ensure no of c ′ s = no of d ′ s

Push a ′ s into stack, pop them with b ′ s (as we need to check m = n or not) , now if stack is empty and c is in input, it means
m = n holds, now push c ′ s and then pop c ′ s with d ′ s , if stack again goes empty and we have nothing in input it mean k = l
(that is what we required) , accepted.

L2 = {ambn ckdl | if(n = k)then(k = l)}

L2 is not cfl.

Push a ′ s into stack, then Push b ′ s into stack , pop b ′ s with c ′ s (as we need to check n = k or not), suppose n = k holds, means
when we get d in input , we have a ′ s on stack. now we have to check k = l , i.e, no of d ′ s = no of c ′ s , it is not possible as we
don't have c ′ s now to check it.

 2 votes -- Praveen Saini ( 34299 points)

8.417 How can we convert left -recursive grammar to right-recursive

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1222 of 2244

grammar and vice-versa ? top gateoverflow.in/29842

Simply reverse the grammar.

Ex;

A→Aa/a(left rec)

Reverse the grammer

A→aA/a(right rec)

You can do vice versa.Note : In case of Left Linear or Right Linear not for all.

 0 votes -- Manojk ( 3365 points)

8.418 what is the union of DCFL with a regular language ? top gateoverflow.in/29260

Consider the following languages L1 and L2


L1 = {ambn | m, n ≥ 0}
L2 = {ambn | m = n}
¯
L2
if(L1 ∪ ) = L then what is the language L?
a. L = {ambn | m, n ≥ 0}
b. L = {ambn | m! = n}
c. L = (a + b) ∗ − {an bn }
d. L = (a + b) ∗ − {ambn | m! = n}

Complement of L2 will be DCFL ,Now when we take the union with regular , the resulting language should be also DCFL , so
answer should be option C , why is it given as option a ?

theory-of-computation


Selected Answer

Say, A is universal set , A = Σ ∗ = (a + b) ∗

It is clear that L1 is subset of A, and L2 is subset of L1.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1223 of 2244


¯
it is clear from the diagram that L1 ∪ L2 = L = Σ ∗ = (a + b) ∗

Note :

¯ ¯ ¯
m n
It is very often to see, that we thought L2 = {a b | m = n}= {ambn | m ≠ n} but remember L2 also contain simple a, or a ∗ or b ∗ or b ∗ a ∗ or
strings as aba or many things.

¯
Actually L2 = Σ ∗ − {an bn }

 8 votes -- Praveen Saini ( 34299 points)

Ans will be (a mbn m,n>=0) ⋃ (b m a n m≠ n) //since both said a should come first then b come.

most aprropriate is a

 1 votes -- Anirudh Pratap Singh ( 4091 points)

8.419 find which of the following CFL which are not, plz discuss one by one..
top gateoverflow.in/29205

1. L={a i b j ck | k=max{i,j}}

2. L={0n 1m | m≤n2}

3. L={0n 1m | m≠n2}

4. {0n 1m |m≠n, m≠2n, m≠3n}


5. {ai b j ck| i≠j or j ≠k or i≠k}
6. {0,1}*-{(0 n 1)n | n≥1}
7. {ai b j | 2i=3j}

8. if L is regular then L c={xz | (∃y)[|x|=|y|=|z|, xyz∈L]}


is??

9. L={0,1}*-{(0 m 1m)n | m,n≥1}

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1224 of 2244

1) L={aibj c k | k=max{i,j}} is not CFL. As it not satisfying prefix property

2) Not CFL.
n m 2
L={0 1 | m≤n }

Cannot draw PDA for it

3)Not CFL.

L={0n 1m | m≠n2}

Same as previous

4)Yes CFL.

{0n 1m |m≠n, m≠2n, m≠3n}

Here 3 condition satisfying in a CFL

5)Yes it is NCFL

{ai bj c k| i≠j or j≠k or i≠k} union of CFL are NCFL

6) Not CFL

L={0,1}*-{(0n 1)n | n≥1}


n
(0 1)n cannot be done in one stack

7)Yes it is CFL.

L={ai bj | 2i=3j}

S->aaSbbb/aabbb

8)Yes CFL.
c
L ={xz | (∃y)[|x|=|y|=|z|, xyz∈L]} ,

Here L=xnynzn i.e. CSL.

Now Lc=(x+y+z) * - xnzn = {xiyjzk | i!=k}


m m n
9) Not CFL. L={0,1}*-{(0 1 ) | m,n≥1} =regular - CFL

=regular ⋂ (CFL)'

= regular ⋂ recursive = recursive

 0 votes -- srestha ( 11585 points)

8.420 determine ambiguous or unambiguous top gateoverflow.in/29184

if any language is given , how we can determine that its grammar is ambiguous or unambiguous

ex. L = {a nbcm | n > 1, m ≤ n}

its very big confusion for me . please explain in brief ?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1225 of 2244

8.421 why is the infinite intersection of regular languages not regular ? top
gateoverflow.in/29331

I have gone through this link but still couldn't understand this , it is telling according to demorgan's law ,Now If I consider L
to be an irregular language so

(L1'∪L2'∪L3'∪......infinite)'= Now this will give infinite intersection of regular languages ,and this is irregular ,but how ?

http://www.eecs.berkeley.edu/~luca/cs172-07/solutions/practice1-sol.pdf

theory-of-computation

8.422 No of final state top gateoverflow.in/29344

A FA accepting language L(A) has n states and m transition.L(A) is given as

L(A)={x| if x∊L(A) then u∊L(A) for ∃u,v∊∑* where x=uv }

Find no of final state in above NFA?

theory-of-computation

8.423 what is the relation between CFG , LL(K) ,LR(K) and regular grammars
? top gateoverflow.in/29786

I am unable to get the basic difference between these and which one are actually parsed by a top down parser and a bottom
up parser ?

theory-of-computation

8.424 regular top gateoverflow.in/29756

http://gateoverflow.in/28207/how-to-tell-which-of-the-languages-are-regular

 1 votes -- srestha ( 11585 points)

8.425 Is the intersection of a CFL with another CFL decidable ? top gateoverflow.in/29618

If the problem is L(G1)∩L(G2)= Empty , then if G1 and G2 are both cfl's then is it decidable ?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1226 of 2244

According to me it should be decidable since if the intersection is regular then we can identify whether the language is empty
or not and if it is CFL then also through the grammar we can check it out seeing the start symbol .

theory-of-computation


Selected Answer

NO.

CFLs are not closed under intersection. If you make an intersection of two CFLs, you may or may not get a CFL.
But the intersection of CFL with a regular language is always CFL. There are ways to do it.

So, CFL intersection CFL is undecidable while CFL intersection regular language is decidable.

 1 votes -- Monanshi Jain ( 5827 points)

8.426 Correct sustring in below fsm. top gateoverflow.in/26800

Answer = option B

 0 votes -- Amar Vashishth ( 17865 points)

8.426 Correct substring in in fsm. top gateoverflow.in/26798

8.427 lang top gateoverflow.in/19517

given l={anbn⋂anbncn}

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1227 of 2244

cfl
csl

reg
dcfl
none

theory-of-computation


Selected Answer

a^n b^n and a^n b^n c^n have no string in common (assuming positive n) . Hence the language given in question is
empty.

Empty language is regular.

 0 votes -- Mari Ganesh Kumar ( 1837 points)

8.428 How can we say r* and r+ may be equal?? Is it correct? top gateoverflow.in/19119

How can we say r* and r+ may be equal?? Is it correct?


Selected Answer

not at all.
r ∗ = empty string(ε) and all strings of length ≥ 1.
r + = only all strings of length ≥ 1. This doesn't contain the empty string ε

 0 votes -- Avdhesh Singh Rana ( 1509 points)

8.429 toc top gateoverflow.in/18426

L={xwwr |x,w ∈ (a + b)+}

CFL
CSL

none

DCFL


Selected Answer

I guess, L should be CFL.

L is a concatenation of L1 = {x | x ∈ (a + b) +} and L2 = {ww r | w ∈ (a + b) +}.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1228 of 2244

Here L1 is a regular language, & L2 is a non deterministic CFL.

Since every regular language is context-free, L1 is also a CFL.

& since CFLs are closed under concatenation, L = L1L2 should be a CFL.

Why not a DCFL?

Since L2 is non deterministic CFL so probably it should not be a DCFL.

 0 votes -- Anurag Pandey ( 8183 points)

8.430 toc top gateoverflow.in/18415

l={anblak:n+l+k>5}
a.CFL
b.CSL
c.REGULAR
d.none

theory-of-computation


Selected Answer

It must be a regular language, L = {w | w ∈ a*b*a* and |w| > 5}.

--------------------------------------------------------------------------------------------

another approach:

L can be represented as follows:

L = {w| w ∈a*b*a*} - {w | w ∊ a*b*a* and |w| <= 5}.

It is clear that {w| w ∈a*b*a*} is a regular language.

Now since the language {w | w ∊ a*b*a* and |w| <= 5} contains a finite number of strings in it, we can say that it is also
regular.

Since regular languages are closed under difference, L must be regular.

 1 votes -- Anurag Pandey ( 8183 points)

8.431 Infinite intersection of regular language is not regular ! top gateoverflow.in/20180

Can someone give the intuition behind this ? Moreover an example will also be helpful ..

theory-of-computation


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1229 of 2244

Let x1 , x2 , x3 , … be the sequence 0, 1, 4, 6, 8, 9, … of non-prime, non-negative integers.

Let axi be a string of xi number of a’s (that is, ax3 = a4 = aaaa)

Let the language Li = a ∗ − axi . { }


Now consider L = The infinite intersection of the sequence of languages L1 , L2 , …. That is,



L = i =1 Li = L1 ∩ L2 ∩ L3 ∩ …

Note that L = {a p
}
∣ p is prime .

Hence L is not regular.

Another easy example would be (this one with unions as opposed to intersections):

Let Li = {a b } for some given value i.


i i

Then, L1 = {ab}, L2 = {aabb}, L3 = {aaabbb} and so on.

Now consider L = The infinite union of the sequence of languages L1 , L2 , … That is,



L = i =1 Li = L1 ∪ L2 ∪ L3 ∪ …

Thus, L = {a b ∣ ∀i > 0 } which is CFL but not Regular.


i i

 1 votes -- Leen Sharma ( 2935 points)

8.432 regular or not top gateoverflow.in/20629

L1= Set of all strings having equal number of 00 and 11. L2= Set of all strings having equal number of 01 and 10. (a) Both
are Regular (b) Both are Context free (c) L1 is regular, L2 is Context Free (d) L1 is CF, L2 is Regular

this prob is solved before .

ans will be d)

L2 can be considered as all of the stings start and with same elements (0 or 1 )

 0 votes -- Pranay Datta ( 6113 points)

8.433 toc top gateoverflow.in/20883

all FA is regular language but every regular language is not FA.?? wt does it mean.??

theory-of-computation

8.434 Regular or cfl top gateoverflow.in/20594

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1230 of 2244

theory-of-computation

Option A :

L1 U L2 is ∑ * and the RE is (0+1)* Therefore its regular.

Option B :

L1 ⋂ L2 is a^nb^n which is CFL and not regular .

is correct .

Option C is also true for the above reason

Therefore answer will be option D.

 0 votes -- Riya Roy ( 4767 points)

8.435 http://gatecse.in/wiki/Identify_the_class_of_the_language q9 gateoverflow.in/20577

top

http://gatecse.in/wiki/Identify_the_class_of_the_language

9.

L = { wxwy ∣ w, x, y ∈ (a + b)+}

how can this be regular? If w is not a or b?

The given is a set definition. So, the set must include all strings satisfying the definition.

Now, as per our definition w, x, y can be any non zero length string over {a, b} and w starts the string followed by x and
again w and ending with y.

Now, any string must start with either a or b. Lets consider the first case:

Starting with a:

So, here w can be a, aa, ab, aaa, …. Whatever be w, it must repeat after x and minimum length of x is 1.

Now, I take a string abaa, here w = a, x = b, y = a. So, this is in L.

Similarly, given any string of length at least 4, I can split it like this to w, x and y provided the first character repeats at
some point other than the end, and there is no split possible if there is no repeat (There might be multiple splits possible,
but that doesn't cause any problem- as long as a single split is there, the string is in L). So, if we can just ensure this
repeat, we found the condition for a string to be in L. And this condition check can be done using a regular expression
a(a + b) + a(a + b) + ∣ b(a + b) + b(a + b) + ).

 1 votes -- Arjun Suresh ( 124125 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1231 of 2244

8.436 no of state in minimal finite automata that accept the string from
alphabet {a,b,c} top gateoverflow.in/18324

no of state in minimal finite automata that accept the string from alphabet {a,b,c} where no of a is divisible by 2 or 3 and no
of c is divisible by 6?? plzz explain!!!

if X is the set of States which count na(No of as) then possible states for counting a will be X={ (naMod20, naMod30),
(naMod20,naMod31),(naMod20,naMod32), (naMod21,naMod30)} Here (Mod20,Mod30) means the state where naMod2=0
and naMod3=0, Similarly interpret the others. Now Y is the set of states which count nc(No ofcs) then possible states will
be. Y={ncMod60, ncMod61, .........,ncMod65} : ncMod60 means the state where ncMod6=0 similarly interpret the others.

Now the possible states for the machine will be : Z={X*Y} ={(namod20,namod30,ncMod60), ......
(naMod21,naMod30,ncMod65). so no of State will be |Z|=24.You can get some idea from the below image how the state
could be look like. for X Set,

 0 votes -- Arun Gorain ( 77 points)

8.437 Are these DCFL? Why ? top gateoverflow.in/17860

1) an bn ∪ an b2n ; n ≥ 0

2) an cbn ∪ an db2n ; n ≥ 0

3)can bn ∪ dan b2n ; n ≥ 0

theory-of-computation


Selected Answer

1) It is not DCFL and it's in CFL

Reason: given a input after reading all a's we will not deterministically know whether to pop out 'a' for single 'b'
(a^nb^n)or double 'b'(a^nb^2n)

2)It is in DCFL

Reason: you can use 'c' and 'd' to deterministically decide whether it is a^nb^n or a^nb^2n after reading all a and the
next ip charecter

3) it is in DCFL

Reason: you can use 'c' and 'd' to deterministically decide whether it is a^nb^n or a^nb^2n after reading the first ip
charecter(i.e,.whether the first char is c or d)

 1 votes -- Mari Ganesh Kumar ( 1837 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1232 of 2244

8.438 equivalence of regular expression top gateoverflow.in/16979

which of following pairs are equivalent?

1)(r1*)*=r1*

2)r1*(r1+r2)*=(r1+r2)*

3)(r1+r2)*=(r1*r2*)*

4)(r1r2)*=r1*r2*

i think 1,2,3 are eqivalent,

1- (a*)*=a*

r1*(r1+r2)*=(r1+r2)*

putting r1* as null we can generate the rhs. and if we take into consideration r1still all the strings are included

3 is also equivalent .

but 4th is saying r1should always followed by r2 but the RHS can generate r1r1.

 0 votes -- Ravi Singh ( 7303 points)

8.439 regular expression for the following top gateoverflow.in/16971

find RE for L on {a,b}

1.L={w:w mod 3=0}

2.L={w: na(w) mod 3=0}

3 .L={w: n a(w) mod 5>0}

repeat 1 2 3 for {a ,b,c}

1.((a+b)(a+b)(a+b))*

2.(b+ab*ab*a)*

3.[(b*ab*)+(b*ab*ab*)+(b*ab*ab*ab*)+(b*ab*ab*ab*ab*)]+[b+(ab*ab*ab*ab*a)]*

 0 votes -- sonu ( 1267 points)

8.440 Turing machine checks for unequal number of a's and b's top gateoverflow.in/16330

We need to desing a turing machine which accepts strings of a's and b's such that the number of a's and number of b's in
the string w are not equal.

What is the minimum number of states needed for such a turing machine

there is a proof for these two statements

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1233 of 2244

1- " every single tape turing machine can be converted to equivalent turing machine with 3 states "

2- " every single tape turing machine can be converted to a equivalent 2 state multitape turing machine."

search google for the proof. its valid point. so now the answer can be 2,3 depending on the fact it is multitape or single
tape or if u can make it using 2 state or one state which i think is not possible

 0 votes -- Ravi Singh ( 7303 points)

8.441 GNF top gateoverflow.in/17024

consider the following CFG find minimum no of productions when converted in GNF form

S->AA|0

A->SS|1

Replace S by A1 and A by A2 + a new variable Z we get the same grammar but in GNF:

A1 → 0A1ZA2 | 1ZA 2 | 0A1A2 | 1A2 | 0


A2 → 0A1Z | 1Z | 0A1 | 1
Z → 0A1ZA1 | 1ZA 1 | 0A1A1 | 1A1 | 0A1ZA1Z | 1ZA1Z | 0A1A1Z | 1A1Z

 2 votes -- Amar Vashishth ( 17865 points)

8.442 which of the following is FALSE? top gateoverflow.in/17445

which of the following is FALSE with respect to possible outcomes of executing a Turing Machine over a given input?

a)it may halt and accept the input

b)it may halt by changing the input

c)it may halt and reject the input

d)it may never halt


Selected Answer

Intuitively option B might be correct.

If the input belongs to a recursive language, either it may halt and accept the input or it may halt and reject the input.

If the input belongs to a recursively enumerable language, then either it may halt and accept the input or it may never
halt.

I don't think it can halt by changing the input, because TM just transits from one state to another state on a given input. It
only does the transitions that it is supposed to do on the given input as per it's definition.

TM is like a slave and input is like the command given by a master, so possibly it can not alter commands given to it.
However I am not very sure about it.

 0 votes -- Anurag Pandey ( 8183 points)

8.443 solve this one top gateoverflow.in/17700

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1234 of 2244

L=b^m right??


Selected Answer

Correct answer would be C, L is Deterministic Context Free Language.

Aplhabet set : {a, b, c} for all L, L1 & L2.

L1 : set of all the strings that have some number of a’s followed by ANY number of b’s followed by exactly the same
number of c’s as the number of a’s.

For example: ac, abc, abbc, aacc, aabcc all these strings are in L1.

L2 : set of all the strings that have any number of a’s followed by exactly the same number of c’s, but NO b’s in between
a’s & c’s. For Example: ac, aacc, aaaccc, aaaacccc all these strings belongs to L2.

Since L = L1 - L2 , L is the the set of all strings that consists of any number of a’s followed by ATLEAST one b, followed by
exactly the same number of c’s as the number of a’s.

i.e. L = {a^n b^m c^n | m>0, n>=0} For example: abc, abbc, abbbc, abbbbc, aabcc aabbcc all these strings belongs to
L.

L is not a regular language since we can not keep count & compare powers using regular language.(Pumping Lemma can
be used to show that L is not regular)

Now why L is DCFL?

L is DCFL because there is a deterministic pushdown automata exists that accepts L.

Acceptance by empty stack:

On reading an ‘a’ push that into stack, on reading a ‘b’ do not alter stack, on reading a ‘c’ pop an ‘a’ from the stack, at last
if number of a’s will be equal to number of b’s in the string, the stack will become empty & thus the string will be in L
otherwise it won’t.

Thus L is a DCFL.

 0 votes -- Anurag Pandey ( 8183 points)

8.444 Plz solve this top gateoverflow.in/17696

Let L=(a^P)* |P is a prime no. then minimum no of states in NFA that accepts the language L is : _____
i think no nfa can accept this language. so the no of states is 0 in NFA. but ans is given :3


Selected Answer

L = {aa, aaa, aaaa, aaaaa, …} becaue there is a * at end and (aa + aaa) ∗ it self will generate all strings in a and we don't need to
consider further prime numbers.

i.e., L contains all strings in a except a. So, we need a start state, another state for single a and then a final state. So, 3
states (for both DFA and NFA).

 1 votes -- Arjun Suresh ( 124125 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1235 of 2244

8.445 Plz solve this one top gateoverflow.in/17695

the formula is n^(n*m+1)*2^n ,where n=no of states and m= no of input symbols. right??


Selected Answer

A DFA is a 5-tuple - (Q, Σ, Δ, q0 , F), where

Q - set of states

Σ - input alphabet set

Δ - transition function Δ: Q × Σ → Q

q0 - start state

F- set of final states.

So, if any of the above 5 changes we get a different DFA.

We are given n states and m input symbols. So, first 2 components won't change.

F can be any subset of states and for n states we can have 2n possible subsets.

q0 must be unique in a DFA and can be any one of n states- n ways.

Δ is a function and no. of possible functions from a set of n × m elements to a set of n elements is nnm.

So, total no. of DFAs = nnm × n × 2n = nnm+1 .2n

 1 votes -- Arjun Suresh ( 124125 points)

8.446 Identify the class of given mod based language top gateoverflow.in/25089

L = {a nbm | n mod m = 0 , n>=0 , m>0} Given language is

A) CFL

B) CSL

C) DCFL

D) REC

E) RE

theory-of-computation

8.446 If DFA is constructed from NFA using lazy subset construction method
, is it guaranteed to be the minimized DFA ? top gateoverflow.in/25136

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1236 of 2244

8.447 what happens when we take union of two languages and then take its
reversal ? top gateoverflow.in/26590

If I have two languages then according to me

(L1 UNION L2 )^r =L1^r UNION L2^r this equality must hold true ,but I read somewhere so this equality wasn't true , so
what is the conclusion ?

e.g . (01+11)^r = 10+11 (LHS)

now RHS will be (10+11)

So I guess equality must hold true .

theory-of-computation

I believe you are correct, the equality should be true in every case.

L1 and L2 are sets containing strings.

In (L1 U L2) r we are firstly combining sets and then taking each string from the combined set and reversing it.

In case of L1 r U L2r we are firstly reversing each string and then combining the sets of reversed strings.

Clearly Union is an operation on sets & Reversal is an operation on strings of the set.

Since ultimately you are going to reverse all the strings in L1 & L2 it does not matters whether you reverse them before
Union or after.

Also finiteness of sets should not affect this equality.

 4 votes -- Anurag Pandey ( 8183 points)

take any two dfa .. with end with (a+b)*..

now try to apply logic u get nfa.

ur logic is true untill language is finite... check plz

 1 votes -- Anirudh Pratap Singh ( 4091 points)

8.448 what happens when we take cartesian product of two DFA's ? top gateoverflow.in/26417

when we take the cartesian product of two DFA's then what happens to the dead state of two DFA's , do we combine it also
in the cartesian product ?

yes Both dead states will combine ..

 1 votes -- Digvijay Pandey ( 26245 points)

8.449 TOC top gateoverflow.in/25966

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1237 of 2244

8.450 how to find L1/L2? top gateoverflow.in/25959

Given L1= (011)*01 and L2= 101 find L1/L2? A. (011)*01 B.(011)* C. 101 D. None of the above

L1= (011)*01 and L2= 101

( 011 ) ∗ 01
101
L1/L2 =
( 011 ) ∗ 01101
101
= = (011) ∗ 01
optionA

 2 votes -- Umang Raman ( 10379 points)

8.451 what is the regular expression equivalent to the DFA ? top gateoverflow.in/26639

I tried it through state elimination method but I am getting stucked at the outgoing edge from D to A .


Selected Answer

I. Using State Elimination

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1238 of 2244

FA given :

Remove State B

Removing State C

Simplify it

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1239 of 2244

Regular expression is (01+10)(11+1(01+10))*

II. Using Arden's Theorem

A=∊ + D0 ------- I

B= A0+D1 -------II

C=A1 -----------III

D=B1+C0 --------- IV

Putting II and III in IV

D= (A0+D1)1+A10

=A(01+10) +D11

Apply Arden's Theorem

D= A(01+10)(11)* - - - - - V

Put V in I

A=∊+A(01+10)(11)*0

​Apply Arden's Theorem

A= ((01+10)(11)*0)* - - - - VI

​Put VI in V

​Regular expression, D = ((01+10)(11)*0)*(01+10)(11)*

= (01+10)(11)*(0(01+10)(11)*)* [ bcoz (pq)*p = p(qp)*]

= (01+10)(11+0(01+10))* [ bcoz p*(qp*)* = (p+q)*]

 3 votes -- Praveen Saini ( 34299 points)

8.452 How to solve below recurrence relation ? top gateoverflow.in/26640

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1240 of 2244


I tried till k=5 and then got 2 as no of words ,N(1)=N(3)=0 ,N(2)=N(4)=N(5)=2

N(0) = N(1) = 0

N(2) = 2

N(k) = 2N(k − 3) + N(k − 2) is the recurrence relation as we can get a string in L by appending "001" or "010" to a string in L
(by looking from final state) or by appending "11".

Thus,

N(3) = 0

N(4) = 2

N(5) = 4

N(6) = 2

N(7) = 8

N(8) = 10

N(9) = 12

N(10) = 26

N(11) = 32

N(12) = 50

N(13) = 84

N(14) = 114

 0 votes -- Arjun Suresh ( 124125 points)

8.453 How to design grammar for below language ? top gateoverflow.in/26785

L={w ={a,b}* : (no of a's -no of b's) mod 3 =1 }

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1241 of 2244

here double circle shows required states

 0 votes -- srestha ( 11585 points)

8.454 how to approach this kind of questions , any algorithm ??? top gateoverflow.in/26755

Which one of the following strings is not accepted by the finite automaton described by the regular expression (0 + 1(01 ∗ 0) ∗ 1) ∗
?

1100100011011001011
0110100010111010010
0100011010111010101
1101001101100010011

theory-of-computation


Selected Answer

Yes, design Dfa for given regular expression, and traverse the input, if with given we reach the final state, then input is
accepted else rejected.

DFA

then traverse input

Option a, b, d is accepted by DFA, option c is rejected

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1242 of 2244

[ Note: if input string is small, it is better to try combination from regular expression, well for this problem, I feel DFA is
much better]

 2 votes -- Praveen Saini ( 34299 points)

8.455 Understanding Rice theorem top gateoverflow.in/26675

Please share some good resources and questions which can make it easier for me to understand and apply Rice theorem.

theory-of-computation

http://www.gatecse.in/803-2/

 2 votes -- Arjun Suresh ( 124125 points)

8.456 DFA top gateoverflow.in/25906

Number of states in the minimized DFA that accepts all strings over alphabets Σ = {0, 1} in which number of 0 ′ s is divisible by
8 or number of 0 ′ s is divisible by 16 is _______.


Selected Answer

L1 = number of 0's divisible of 8 , we will have 8 states, ( as each state represent modulo-8)

L2= number of 0's divisible of 16, those are divisible of 16 are already divisible of 8, is already present is L1, i.e, L2 is
subset of L1.

So L1 U L2 = L1 only

we will have simple DFA over {0,1},such that no of 0's are divisible of 8 , having 8 states only

 2 votes -- Praveen Saini ( 34299 points)

8.457 CYK top gateoverflow.in/25904

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1243 of 2244


Selected Answer

table entries in CYK algorithm is in the form of a triangular matrix.

first row of table consist of 10 entries(columns) the next row contains 9 then next one contains 8 and so on.. until the last
row which contains just one entry.

n(n + 1) 10 × 11
entries in CYK algorithm = 2 = 2 = 55

 5 votes -- Amar Vashishth ( 17865 points)

8.458 DFA top gateoverflow.in/25333

I believe, qi = qj is the correct answer. Here is the proof idea: Since w is non empty, assume w = ax, where 'a' is the first
letter of string w and x is the remaining part(x can or cannot be empty). Clearly state q0 and qf will wind up in same state
after reading first symbol of string w, since delta(q0, a) = delta(qf, a). Let us suppose that delta(q0, a) = delta(qf, a) = P.
Then for both q0 and qf after scanning the first symbol 'a' they will reach state P and after reaching P, delta_hat(P, x) will
be common to both of them. Hence delta_hat(q0, w) = delta_hat(qf, w).

 3 votes -- Anurag Pandey ( 8183 points)

8.459 Match the following : top gateoverflow.in/25177

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1244 of 2244

theory-of-computation

I think answer should be option B


since FA + 2 counter(2 or <2) = FA + 2 PDA (2 or <2) = Turing machine
so option a c d are matched to 1

 1 votes -- Umang Raman ( 10379 points)

8.460 type of given language ? top gateoverflow.in/25158

let P,Q,R be three languages. if P nd R are regular and if PQ=R the Q is ?

Let the operation is concatenate. as no operation is given . i think we should consider it as concatenate. so Q may or may
no be regular for ex . p=X | x∈(a+b)* now assume that q be a language ww. w belong to the same domain as x. so now
the new language p.q= L={xww∣w,x∈(a+b)∗}

xww which will be regular. q may or may not be regular and cfl . it can be csl also..

for more .:http://gatecse.in/wiki/Identify_the_class_of_the_language

 1 votes -- Ravi Singh ( 7303 points)

Q can be anything

Take P as ∅

∅L = ∅

so, L can be anything

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1245 of 2244

 1 votes -- Himanshu Agarwal ( 8861 points)

8.461 Language is regular or not? top gateoverflow.in/25501

Reverse of regular is Regular and reverse of non regular is non regular.

 2 votes -- Leen Sharma ( 2935 points)

8.462 Properties of Regular Language top gateoverflow.in/25505

Union of Regular and non Regular is?

B may be or may not be regular. e.g Let A = a ∗ b ∗ andB = an bn thenA\cupB = a ∗ b ∗ but consider A = abandB = an bn thenA ∪ B = an bn
which is not regular.

 0 votes -- Suhit Kalubarme ( 87 points)

8.463 CFG top gateoverflow.in/25901

Why is S2 not a correct option?

Yes, S2 is not correct cause if the language generated by it is bound to contain ∈ then we cannot remove that. Doing so
will alter the language definition.

So S2 is false.

 4 votes -- Amar Vashishth ( 17865 points)

Suppose we have a Grammar

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1246 of 2244

S → bA

A → aA|∊

set of strings,language, generated is { b, ba, baa, baaa,....}

if we remove null from it ( following the rules)

we will get

S → bA|b

A → aA|a

set of strings ,language, derived will be remains same.

But if we have Grammar

S → aS|∊ , set of strings derived is { ∊,a,aa,aaa,......}

and we remove null from it , we will get

S → aS|a , set of strings derives is {a,aa,aaa,......}

languages will differ.

Yes,for S2 only if we are not getting , null in language , directly ,S → ∊ , or indirectly, S → A, A → ∊ (for example)

 3 votes -- Praveen Saini ( 34299 points)

8.464 toc top gateoverflow.in/25639

Suppose we have a language L and it is finite, now if we take a complement of language L than what can we say about the
language L / ?
a.) Language is decidable
b.) Undecidable??

theory-of-computation

L is finite, so we can construct DFA for that .

Now complement of that language is just do nonfinal state as final and also final state as nonfinal. So, it is also a DFA.

So, it must be decidable

 2 votes -- srestha ( 11585 points)

L = Regular

L' = Regular (Since Complement of a Regular Language is Regular )

And Every Regular Language is Decidable.

 2 votes -- Aditya Gaurav ( 1831 points)

8.464 What type of language will be the complement of a^nb^n where


n>=0? top gateoverflow.in/25507

Complement of any language L is L ′ = Σ ∗ − L. The given language is DCFL and not regular and hence its complement
cannot be regular as regular set is closed under complement. Since DCFL too is closed under complement, L ′ is DCFL.

 0 votes -- Arjun Suresh ( 124125 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1247 of 2244

8.465 Which of the following is true? (L′ is the Complement of language L) top
gateoverflow.in/32217

Let L be the language containing only the string S where

S = 0 if you will never clear the gate.

1 if you will clear the gate some day.

Which of the following is true? (L′ is the Complement of language L)

1. L is decidable
2. L′ is decidable
3. L and L′ both are decidable
4. L is undecidable

theory-of-computation made-easy test-series

Answer will be (3)

In L 'Yes' and 'no' both answer possible.

In L' also 'Yes' and 'No' ans possible

So, both are decidable

 2 votes -- srestha ( 11585 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1248 of 2244

9 Computer Networks top


9.1 Ace Test Series: Bit stuffing using 8 bit delimiter pattern top gateoverflow.in/36920

Why answer is not C?

computer-networks ace-test-series


Selected Answer

Bit stuffing pattern 01111110

ip string : 011111101

0 111110101 is the correct ans

0 is introduced to distinguish data and end delimiter

Refer the concept of bit stuffing again. Its a simple question

 1 votes -- Akhil Nadh PC ( 1967 points)

01111110 is considered flag and not data , ..so if u want to send data 011111101
u need to stuff extra 0 after 5 consecutive ones so that will be not treated as flag or delimiter and will be considered data

 1 votes -- sarvani videla ( 125 points)

9.2 Back Off Delay: Cn-ques1 ethernet and csma-cd top gateoverflow.in/27094

Suppose two nodes, A and B, are attached to opposite ends of a 900 m cable, and that they each have one frame of 1000
bits (including all headers and preambles) to send to each other. Both nodes attempt to transmit at time t=0. Suppose there
are four repeaters between A and B, each inserting a 20 bit delay. Assume the transmission rate is 10 Mbps, and CSMA/CD
with backoff intervals of multiples of 512 bits is used. After the first collision, A draws K=0 and B draws K=1 in the
exponential backoff protocol. Ignore the jam signal.

Ques-1. What is the one-way propagation delay (including repeater delays) between A and B in seconds. Assume that the
signal propagation speed is 2 * 108m/sec.

Ques-2. At what time (in seconds) is A's packet completely delivered at B.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1249 of 2244

Ques-3. Now suppose that only A has a packet to send and that the repeaters are replaced with bridges. Suppose that each
bridge has a 20 bit processing delay in addition to a store-and-forward delay. At what time in seconds is A's packet delivered
at B?

My work:- propagation tim = 4.5 *10 -6 sec

Transmission time by A = 100 *10-6 sec.

For 2nd ques.I am not getting how to take collision and back off delay...

then how to solve for bridges.

computer-networks csma-cd back-off-delay ethernet bridges repeater

A]900/(2 * 10^8)m/s + (4*20)/10000000) = 12.5 micro seconds

B]frame transmission time is (1000bits/10*106bps)=100 µsec


At time t = 0 , both A and B transmit.
At time t = 12.5µ sec , A detects a collision.
At time t = 25µ sec last bit of B 's aborted transmission arrives at A .
At time t = 37.5µ sec first bit of A 's retransmission arrives at B .
At time t= 37.5 µsec + 100 µsec =137.5 µsec. A 's packet is completely delivered at B .

C]Each Bridge introduces additional 1000-bit store-and-forward delay and 20-bit processing delay. Total delay introduced
is 4080-bit time or 408 µs. Transmission delay is 1000-bit time or 100 µs. Propagation delay is 4.5 µs. A’s packet reaches
B at time 408 + 100 + 4.5 = 512.5µs

 2 votes -- gate rk ( 71 points)

9.3 Computer: Question on hamming code with even parity top gateoverflow.in/38551

Please check how the correct answer is B.

computer computer-networks hamming-code

Ans is B bcoz r1 is 1, r2 is 0, r4 is 0 so 1010101...

 0 votes -- jiitalok ( 37 points)

9.4 Congestion Control: What is the size of current sender's window? (TCP
congestion control) top gateoverflow.in/31421

During a TCP connection, the size of the window advertized by the receiver is 20KB. The last byte sent by the sender is
20480 and and the last byte acknowledged by the receiver is 8384. If the current congestion window is 18KB, then current
size of sender's window is _______ (in KB) ?

As far as I know, the current effective size should be "Adv. Window - (Unacknowledged bytes)" . But, the results in an
ambiguity here. As it will give approx (20kb-12kb) = 8KB . But , how is this ever possible because congestion window is
already 18KB??

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1250 of 2244

Where am I going wrong??

computer-networks tcp congestion-control

9.5 Congestion Control: Question on congestion window and slow start of


TCP top gateoverflow.in/36618

Given solution:

I couldn't understand from reaching 1KB to 16KB why it took 50ms not 40ms. Please check

computer-networks congestion-control tcp


Selected Answer

1||2|| 4|| 8 ||16|| 17|| 18|| 19|| 20|| 21|| 22|| 23|| 24|| 25|| 26|| 27|| 28|| 29|| 30|| 31|| 32

Just Count the no. of vertical lines thats the ans ie., 20*10=200 msec irrespective what is all given in solution just stick to
ur concept :)

 2 votes -- Anirudh Pandey ( 343 points)

9.6 Congestion Control: CN: TCP Congestion Control top gateoverflow.in/33836

A TCP machine is sending windows of 65,535 bytes over a 1-Gbps channel that has a 10-msec one-way delay. What is the maximum throughput
achievable? What is the line efficiency?

Answer:

One window can be sent every 20 msec. This gives 50 windows/sec, for a maximum data rate of about 3.3 million bytes/sec. The line efficiency is then 26.4
Mbps/1000 Mbps or 2.6%.

But they have taken 20 msec as RTT and in the question they have given 10 msec one-way delay. Why they have taken RTT? why we can't use one-way
delay itself ?

computer-networks congestion-control

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1251 of 2244

given L= 65535 * 8 bits

BW = 1*10^9 ,RTT =20 msec

so bandwidth delay product = 1*10^9*20*10^-3 =20*10^6

but we can send only 65535 * 8 bits

so efficiency = 65535 *8 / 20* 10^6 = 2.6 %

throughput = efficiency * BW

 1 votes -- Prabhanjan R ( 747 points)

9.7 Congestion Control: Additive increase multiplicative decrease top gateoverflow.in/34918

consider "additive increase multiplicative decrease".one MSS is 512B.If TCP sender don't perceive path as congested

What will be congestion window size after 4RTTs provided congestion window is assigned MSS initially

congestion-control

After 4 RTTS:

1->2->4->8->16

So, Congestion Window after 4RTT = 16 * MSS = 16 * 512B = 8KB

 2 votes -- Anshul Khantwal ( 185 points)

9.8 Congestion Control: Slow start top gateoverflow.in/33409

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1252 of 2244

congestion-control

9.9 Congestion Control: slow start - tcp congestion control top gateoverflow.in/37567

Q).Suppose that TCP congestion window is set to 28KB and time-out occurs.The window size after the next six successful
transmission bursts (Assume maximum segment size is 2KB and TCP uses congestion avoidance) is _______(in KB)

congestion-control computer-networks tcp made-easy

2,4,8,14,16,18 so Ans=18

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1253 of 2244

 1 votes -- gkumar kumar ( 27 points)

9.10 Congestion Control: TCP Congestion Control top gateoverflow.in/34067

computer-networks congestion-control tcp

4---8---16---32 ---now time out---4---8---16(additive increase) ---20----24---28----32

so congestion window =16

10 RTT

so 10*50=500

 0 votes -- Pooja ( 22773 points)

9.11 Congestion Control: Slow start top gateoverflow.in/30380

if initially given that sender send 2mss

Then how slow start will it be

2mss,4mss,8mss,........

And conestion avoidence will be increament by +2 each time or +1.

Please suggest me these are right or wrong

congestion-control

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1254 of 2244

We start the "slow start phase" with the window size given .... but after the threshold we always increase by 1MSS So
according to your question if threshold is at 16MSS then you will do like 2 4 8 16 and then 17 18 till timeout.

 0 votes -- Anirudh Pandey ( 343 points)

9.12 Congestion Control: slow start-congestion control- congestion detection


top gateoverflow.in/37568

Initially (as slow start )

full window 12MSS

cwnd = 1MSS

ssthresh = 6MSS

1MSS sent

after 1st RTT -> cwnd = 2 ,

and so on subsequent RTT -> 4 , 5 ,6, 7, 8,9,10,11,12

so 11RTT

so answer should be 110ms

but none of the option matches

congestion-control computer-networks tcp made-easy

Sender window = 24KB


Thresold = 12KB

2KB --> 4KB --> 8KB --> 12KB --> 14KB --> 16KB --> 18KB --> 20KB -- > 22KB --> 24KB
Total 10 RTT..

Time = 10*10 = 100ms

 1 votes -- Digvijay Pandey ( 26245 points)

9.13 Crc Polynomial: Patterson Chap 2 Q 19 top gateoverflow.in/30933

19. Suppose we want to transmit the message 1011 0010 0100 1011
and protect it from errors using the CRC8 polynomial
x8 + x2 + x1 + 1.
(a) Use polynomial long division to determine the message that
should be transmitted.
(b) Suppose the leftmost bit of the message is inverted due to
noise on the transmission link. What is the result of the
receiver’s CRC calculation? How does the receiver know that
an error has occurred?

computer-networks reference-book difficult crc-polynomial

a) The remainder is 10010011. So the message is 1011 0010 0100 1011 10010011

b) Remainder is 1011 0110 is not zero.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1255 of 2244

 0 votes -- zambus ( 159 points)

9.14 Crc Polynomial: CRC can detect all bursts of upto m errors if generator
polynomial G(x) is of degree? top gateoverflow.in/7238

crc-polynomial computer-networks

CRC can only detect bust error of length m if the generator polynomial is of degree m. If you can recall how we generate
the CRC for a particular message.

1.Both sender and reciver agree on a generator polynomial of degree say m.

2. sender adds m zero bits to the message.

2. sender findes the reminder of the binary division of the message witht the generator polynomial (Note: the reminder
can be of the length atmost m).

3. sender adds the reminder to the message and send it to the reciver.

4. reciver again divides the message with the generator polynomial and see if the reminder is zero.

5. since we need to change atleast m+1 bits to make the message with CRC code have zero reminder when divided by
the polynomial. I can detect all busrst errors of length m.

 0 votes -- Gowthaman Arumugam ( 1079 points)

9.15 Crc Polynomial: Patterson Chap 2 Q 18 top gateoverflow.in/30936

18. Suppose we want to transmit the message 11100011 and protect it from errors using the CRC polynomial x3 + 1. (a)
Use polynomial long division to determine the message that should be transmitted. (b) Suppose the leftmost bit of the
message is inverted due to noise on the transmission link. What is the result of the receiver’s CRC calculation? How does the
receiver know that an error has occurred?

reference-book computer-networks crc-polynomial

Message transmitted is 11100011100

At receiver side remainder=100 (it should have been zero)so error occured

 1 votes -- Pooja ( 22773 points)

9.16 Crc Polynomial: ISRO-2013-40 top gateoverflow.in/43979

If the frame to be transmitted is 1101011011 and the CRC polynomial to be used for generating checksum is x4 + x + 1, than
what is the transmitted frame?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1256 of 2244

A. 11010110111011
B. 11010110111101
C. 11010110111110
D. 11010110111001

isro2013 computer-networks crc-polynomial

frames transmitted 1101011011

CRC polynomial 10011

Answer is 11010110111110

 0 votes -- srestha ( 11585 points)

9.17 Cryptography: Diffie Hellman top gateoverflow.in/29738

computer-networks cryptography


Selected Answer

for diffie hellman n and n-1/2 should be prime

1)107 and 107-1/2=53 both are prime

2)37 is prime but 37-1/2=18 is not prime

3)47 and 47-1/2=23 are prime

4)109 is prime but 109-1/2-54 is not prime

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1257 of 2244

so ans is 1 and 3 ie c

 4 votes -- Pooja ( 22773 points)

answer = option A

ii and iii cannot be correct as they are close to a perfect square

 1 votes -- Amar Vashishth ( 17865 points)

9.18 Cryptography: ISRO-2013-21 top gateoverflow.in/43843

What will be the cipher text produced by the following cipher function for the plain text ISRO with key k = 7. [ Consider
′ A ′ = 0, ′ B ′ = 1, . . . . ′ Z ′ = 25]

Ck(M) = (kM + 13) mod 26

A. RJCH
B. QIBG
C. GQPM
D. XPIN

isro2013 cryptography

Answer is A

See A=0 B=1 C=2 .......... you will get I = 8 ................

Now you just apply the cipher function character wise ,

BY THE WAY IN THE ABOVE FUNCTION M STANDS FOR 1 character one by one of input

So our first character is I

C( I ) = ( KM+13) MOD 26 =(7*8+13)MOD 26 = 17 and if you see 17 is R value

So just from the first character you can get answer RJCH

 0 votes -- Dexter ( 1933 points)

9.19 Cryptography: ISRO-2013-46 top gateoverflow.in/44152

Which of the following encryption algorithms is based on the Fiestal structure?

A. Advanced Encryption Standard


B. RSA public key cryptographic algorithm
C. Data Encryption standard
D. RC4

isro2013 cryptography

@srestha

Fiestal structure are block cipher . Not a symmetric Cyrptogaraphy

A symmetric is one which use same key for Encryption and Decryption

Infact it should be DES AES and tripple DES as block cipher ( or fiestal ) They amke use of P and S boxes .

 0 votes -- Dexter ( 1933 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1258 of 2244

9.20 Csma Cd: Csma cd top gateoverflow.in/30023

Why in csma cd transmission time=2*propogation time

csma-cd

To detect collision in worst case:


transmission time >= 2 * propagation time.

 0 votes -- Monanshi Jain ( 5827 points)

9.21 Csma Cd: Frame size (jamming signal) top gateoverflow.in/29736

computer-networks csma-cd

125000 Bytes (or 125 KB) should be the right answer.

Jamming signal is like a negative acknowledgement used to inform all the nodes connected to a link that collision
occurred.

Suppose a node P is transmitting frames to other node Q which is 200 km away from P.

Now suppose the frame sent by P to Q collides with another frame, at a point very near to Q after travelling 199.99 km,
then to inform node P about collision, the jamming signal has to travel almost 200 km.

So in the worst case, P will get informed about collision only after two way propagation delay.

& if P receives jamming signal after it has completed its frame transmission, then will never know that which frame
caused the collision & that the frame that it sent to Q has been collided & lost.

So the frame that P is going to transmit should be large enough to be transmitted until a longest two way propagation
time.

That is frame transmission time must be at least as much as 2*Propagation time.

Here 2 * Propagation time = 2 * 10 -3 seconds,

& Transmission rate = 500 Mega bits per second.

Let frame size be L bits.

Then (L / 500 * 10 6) >= 2 * 10-3

Hence L >= 10 6 bits or L >= 1,25,000 Bytes or L >= 125 KB.

 1 votes -- Anurag Pandey ( 8183 points)

9.22 Csma Cd: Csma cd top gateoverflow.in/31202

http://gateoverflow.in/?qa=blob&qa_blobid=5597532308294999298

csma-cd

9.23 Csma Cd: In P-persistent CSMA network there are 5 systems in a slot.
The probability of station not transmitting the data is 0.6. Only two stations
should transmit the data to avoid collision. What is the probability that
channel is collision free? top gateoverflow.in/7537

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1259 of 2244

In P-persistent CSMA network there are 5 systems in a slot. The probability of station not transmitting the data
is 0.6. Only two stations should transmit the data to avoid collision. What is the probability that channel is
collision free?

My answer is 0.6825 and answer given is 0.34 - 0.35.

I solved this as P (no collision) = either 2 stations are transmitting or 1 station or none.

computer-networks csma-cd

In question ask only two stations transmit. So, we consider two stations only.

probability =5C2(0.42)(0.63)=0.3456

 2 votes -- hareesh ( 33 points)

9.24 Csma Cd: csma/cd top gateoverflow.in/30257

Two csma/cd stations are trying to send frames..After each frame is sent they contend for channel using backoff exponential
algorithm?What is probability that contention ends on round k?

computer-networks csma-cd

Contention ends on round k means that earlier in k-1 trial it didn't succeed and finally it succeeded on kth Contention.

Probability of no success in ith Contention = 1/2^i

probability that contention ends on round k = (1/2)(1/2^2)(1/2^3)...(1/2^k)*(1-1/2^k)

 0 votes -- Abhishek Kumar ( 71 points)

9.25 Delay: Delay - Computer Networks top gateoverflow.in/27221

We wish to send a message of size 150,000 bytes over the network. There are four hops, each of length 20km and running
at 100 Mb/s. Before sending we split the message into 1500 byte packets. What is the end-to-end delay of the message?

Make following assumptions :

# The switches "store and forward " packets along the path.

# For each hop, propagation speed = speed of light in copper = c = 2 * 10^8 m/s.

# The delay over each of the links is identical.

# Net queueing delay is zero.

# Net nodal processing delay is zero.

delay computer-networks

Message is divided into 100 packet each of size 1500 bytes

Transmission time = 1500/100 =15 microsecond

Propogation delay over a link = 20km/20*10^8=200 microsec

S----R1------R2------R3--------R4--------D

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1260 of 2244

Since Router/switches are store and forward device we wont consider ack time

below table shows packet1 and packet 2 reaches different hops

S R1 R2 R3 R4 D
0 215 430 645 860 1075
15 230 445 660 875 1090

Now to reach 100th packet at D we need 1075+99*15 =2560microsecond

 0 votes -- saurav04 ( 649 points)

9.26 Distance Vector Routing: Distance vector routing top gateoverflow.in/33771

computer-networks distance-vector-routing


Selected Answer

A is right.

delay A to B = 4

A to D = 5

A to c =6.

then the table will be,

1st case, vector table of A via B

A B C D E F

0 4 8 8 7 6

via B B B B B B

2nd case

vector table of A via C

A B C D E F

0 10 6 8 13 10

via C C C C C C

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1261 of 2244

3rd case

vector table of A via D

A B C D E F

0 6 8 5 8 11

via D D D D D D

comparing all the tables

final table is

A B C D E F

0 4 6 5 7 6

- B C D B B

 2 votes -- Sayantan Ganguly ( 5061 points)

9.27 Distance Vector Routing: Distance vector top gateoverflow.in/36360

In distance vector routing how the distance vectors are update when two paths have same cost

eg. Initial Distance vector of A B C D are

A- [0 ∞ 1 2]

B- [∞ 0 3 2]

C- [1 3 0 ∞]

D- [2 2 ∞ 0]

what will be distance vector of A after 1 iteration. Please mention via node and why u choose that node??

computer-networks distance-vector-routing

9.28 Error Correction: Peterson Davie 2.13 top gateoverflow.in/43149

Show that two-dimensional parity provides the receiver enough information to correct any 1-bit error (assuming the receiver
knows only 1 bit is bad), but not any 2-bit error.

peterson-davie descriptive error-correction

I would like to explain this answer :)

In the question above we are talking about parity -- which is one of the methods used for Error Correction and detection

Now assume data we need to send is

ROW 1 : 1 1 1

Row 2 : 0 1 1

Row 3 : 1 0 1

now what we need to do we need to calculate parity ( assume even parity of 1 ) rowwise and columnwise .

So for rowise ( ROW 1) we will get parity bit as 1 ( we need to make even no of ones by counting parity and databits )

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1262 of 2244

for row 2 : parity bit will be 0

for row 3 parity bit will be 0

now again calculate for columwise

coloum1 : parity bit is 0

column2 parity bit is 0

coloumn 3 parity bit is 1

now sender sends data and even parity bits that it calculate (rowwise and coloumnwise)

So data send here is :

Row 1 : 1 1 1

Row 2 : 0 1 1

Row 3 : 1 0 1

PRow : 1 0 0 where P row mean rowise parity

Crow : 0 0 1 where C mean colown parity ( calculated above )

Now next thing :

Reciever get data :

Assume he get

1 0 1

0 1 1

1 0 1

now he will calcuated parity rowise and columwise

so for row 1 : parity is 0

for row 2 : it is 0

for row 3 it is 0

now colum wise

col 1 : 0

col2 : 1

col 3 : 1

Now final step :

if we see parity at sender side was ( Rowise parity was ) : 1 0 0

f we see parity at column side was ( Rowise parity was ) : 0 0 0

see the first bit is changes from 1 -- 0 so error ( first row )

f we see parity at sender side was ( columnwise parity was ) : 0 0 1

f we see parity at column side was ( columwise parity was ) : 0 1 1

here the third bit doenst match it gt change from 1-- 0 ( second column)

Now the intersection or position of first row and 2 column , we have an error

And look the under lined 0 ( above ) . It is an erro bit . since we know the postion we flip the bit to 1

hence this way we can detect 1 bit error

But sometimes we cant detect also beacuse parity bits might get corrupted with data bits . so that they satisfy even parity
criteria .

( you can try for out 2 bits :)) -- Just change any 2 bits and follow same procedure you wont be able to find out position
of that on reciever side

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1263 of 2244

The fact when we cant distinguish or find error even with the help of parity bits . Such errors are called meaningful
errors

 0 votes -- Dexter ( 1933 points)

9.29 Error Correction: Peterson Davie 2.21b top gateoverflow.in/43222

With 1 parity bit we can detect all 1-bit errors. Show that at least one generalization fails, as follows:

(b) Find an N (not necessarily minimal) such that no 32-bit error detection code applied to N-bit blocks can detect all errors
altering up to 8 bits.

peterson-davie error-correction difficult

9.30 Error Correction: Peterson Davie 2.21a top gateoverflow.in/43221

With 1 parity bit we can detect all 1-bit errors. Show that at least one generalization fails, as follows:

(a) Show that if messages m are 8 bits long, then there is no error detection code e = e(m) of size 2 bits that can detect all 2-
bit errors. Hint: Consider the set M of all 8-bit messages with a single 1 bit; note that any message from M can be
transmuted into any other with a 2-bit error, and show that some pair of messages m 1 and m 2 in M must have the same error
code e.

peterson-davie difficult error-correction

9.31 Error Detection: ISRO-2013-18 top gateoverflow.in/43816

How many check bits are required for 16 bit data word to detect 2 bit errors and single bit correction using hamming code?

A. 5
B. 6
C. 7
D. 8

isro2013 error-detection

9.32 Error Detection: Parity Bit top gateoverflow.in/43130

How many parity bits will be required for transmitting a 16-bit data ?

a 6 b 3 c 2 d 1

error-detection


Selected Answer

n is data bit

k is number of parity bits

n + k ≤ 2k − 1 , as parity bits are used at the locations in power of 2 ′ s .

n ≤ 2k − k − 1

n = 16

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1264 of 2244

16 ≤ 2k − k − 1

k=5

 2 votes -- Praveen Saini ( 34299 points)

9.33 Ethernet: ISRO-2013-39 top gateoverflow.in/43978

Ethernet layer- 2 switch is a network element type which gives.

A. Different collision domain and same broadcast domain.


B. Different collision domain and different broadcast domain.
C. Same collision domain and same broadcast domain.
D. Same collision domain and different broadcast domain.

isro2013 computer-networks ethernet

(A)Different collision domain and same broadcast domain


A broadcast domain is a logical division of a computer network, in which all nodes can reach each other by broadcast at
the data link layer. A broadcast domain can be within the same LAN segment or it can be bridged to other LAN segments.
A broadcast domain encompasses a set of devices for when one of the devices sends a broadcast, all the other devices
receive a copy of the broadcast. In terms of current popular technologies: Any computer connected to the same Ethernet
repeater or switch is a member of the same broadcast domain

collision domain is the set of LAN interfaces whose frames could collide with each other, but not with frames sent by any
other devices in the network. The collision is happened when to computer in same time want to use bandwidth. The
CSMA/CD algorithm that deals with the issue of collisions, and some of the differences between how hubs and switches
operate to create either a single collision domain (hubs) or many collision domains (switches). Generally speaking in easy
terms, A collision domain is a set of network interface cards (NIC) for which a frame sent by one NIC could result in a
collision with a frame sent by any other NIC in the same collision domain.

http://gateoverflow.in/18788/ethernet-layer-switch-is-a-network-element-type-which-gives

 0 votes -- srestha ( 11585 points)

9.34 Ethernet: An image is 1600 x 1200 pixel with 3 bytes/pixel .The time
taken to transmit it over gigabit ethernet is top gateoverflow.in/18291

An image is 1600 ∗ 1200 pixels with 3 bytes/pixel .Assume that the image is incompressible.The time taken to transmit the
image over a gigabit ethernet (in ms) is _______________.

computer-networks ethernet


Selected Answer

1600*1200 pixels
1 pixels---------------- 3 bytes
than 1600*1200-----------3*1600*1200 bytes

=5760000 bytes

=5760000*8 (bits)=46080000 bits

gigabit ethernet means 10 9bits/sec

so than in 10 69 bits---------------------- 1 sec

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1265 of 2244

46080000 bits -------------------------46080000/10 9 =0.04608 sec

=46.08msec

 0 votes -- kunal chalotra ( 3567 points)

9.35 Ethernet: If an ethernet destination address is top gateoverflow.in/32818

computer-networks ethernet

Ans is multicast becuase 1st byte is 07 - 0000 0111,

Address transmission Left to right byte by byte ,however each byte is sent first LSB then MSB.

So for LSB 0 -Unicast, LSB-1 Multicast

 2 votes -- UK ( 1341 points)

it will be multicast

 2 votes -- srestha ( 11585 points)

9.36 Ethernet: Time taken to transmit= ? top gateoverflow.in/17640

ethernet


Selected Answer

Total size of image = 1600 * 1200 * 3 * 8 bits = 46080000 bits.

Its gigabit ethernet => 1 gigabits per second => 10 9 bits per second.

=> 109 bits = 1second


1
109
=> 1bit = sec

1
9
=> 46080000 bits = 10 * 46080000 = 0.046080 sec = 46.08 ms

 0 votes -- CrimeMasterGoGo ( 2221 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1266 of 2244

9.37 Ethernet: Ethernet top gateoverflow.in/34078

if an ethernet station collide 4 time in trying to transmit a single frame how long might it be before the next attempt?
a)768 microsec
b)819.2 microsec
c)409.6 microsec
d)none

ethernet


Selected Answer

In general, after the cth failed attempt, resend the frame after k · 51.2μs, where k is a random integer
between 0 and 2c − 1

so here max waiting time occurs when we choose the value of k max between 0 to 2^4 - 1 = 15

so we choose value of k =15. now waiting time = 15 *51.2 μs = 768 μs

ref: https://en.wikipedia.org/wiki/Exponential_backoff

 1 votes -- Sayantan Ganguly ( 5061 points)

9.38 Ethernet: ISRO-2013-38 top gateoverflow.in/43976

In the Ethernet, which field is actually added at the physical layer and is not part of the frame.

A. Preamble
B. CRC
C. Address
D. Location

isro2013 computer-networks ethernet

The first field(Preamble) of 802.3 frame contains 7 bytes of alternating 0s and 1s that alerts the receiving system to the
coming frame and enables it to synchronize its input timing. Preamble is added at the physical layer and is not part of the
frame.

 1 votes -- Nishant Arora ( 213 points)

9.39 Ethernet: Formula for calculating efficiency of ethernet top gateoverflow.in/27636

What formula to use for calculating efficiency of ethernet is it


1 1 1
1 +6.44a 1 +5.44a 1 +5a
or or ​
I saw three versions for calculating the same thing in different places. I want to know which one is correct.

computer-networks ethernet


Selected Answer

In CSMA/CD, for success, only 1 station should transmit while others shouldn't.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1267 of 2244

P(success)=nC1*p * (1-p) n-1 Binomial thm.

For max P(success), differentiate and equate to zero(line in limits to get maxima and minima).

We get P(max)=1/e
1
1 1
e
p (max)
Number of times we need to try before getting 1st success= = =e
transmissiontime(Tt )

Efficiency= numberofcollision (C ) ∗ 2 ∗ propagationtime(Tp ) +Tt +Tp

Here number of times we need to try=e, ie C=e.


Tt 1

Put a= Tp and divide by Tt, we get: e∗ 2a +1 +a

Put e=2.72, efficiency = 1 +6.44a

 1 votes -- Tehreem Ansari ( 1327 points)

hi

its 1st one in case csma/cd is used

regards

Piyush

 1 votes -- Piyush Kapoor ( 253 points)

9.40 Ethernet: Ethernet top gateoverflow.in/25724

Q). Ethernet implements ________ service for its operation

(a). Connection oriented

(b). Connection less

(c). a and b

(d). a or c

computer-networks ethernet

Ethernet is connectionless.Upper layer protocols(not all) like TCP establishes connection.Connection is implemented
through software and connection oriented Ethernet is also there but by default Ethernet is connectionless.

 3 votes -- Rohan Ghosh ( 1515 points)

9.41 Expectation: Probability of Successful transmission top gateoverflow.in/37053

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1268 of 2244

Q If probability of frame reaching safely is 0.1 then mean number of transmissions of a frame to make it success is _____.

How to solve this question?

computer-networks probability expectation


Selected Answer

mean number of transmissions of a frame to make it success = 1/0.1

=10

 3 votes -- bhawanagupta15 ( 349 points)

9.42 Fragmentation: Fragmentation top gateoverflow.in/18224

Fragmentation is done by Network layer or Transport Layer ?

fragmentation

fragmentation is done by network layer as per according to size of MTU(MAXIMUM transfer unit).

 0 votes -- kunal chalotra ( 3567 points)

9.43 Fragmentation: Extended question to find the fragment sizes GATE-CS-


2004 top gateoverflow.in/38202

Consider three IP networks A, B and C. Host HA in networks ‘A’ sends message each containing 180 B of application data to
a host HC in network HC. The TCP layer prefixes 20 Bytes header to
the message. This passes through on intermediate network ‘B’. The maximum packet size, including 20B IP headers in each
network is:
A. 500 Bytes
B. 100 Bytes
C.1000 Bytes
The network A and B are connected through 512 Kbps link, while B and C are connected by a 256 Kbps link.

1. Assuming that the packets are correctly delivered, how many Bytes including headers, are
delivered to IP layer at destination for one application message in the best case? Consider only data packets.
A. 220 B.240 C. 260 D. 280

2. What is the rate at which application data is transferred to host HC? Ignore errors,
acknowledgements and other overheads?
A. 196 Kbps B. 177.23 Kbps C. 354.5 Kbps D. 325.5 Kbps

3. What is the extra overhead caused by fragmentation?


A. 40 Bytes B. 20 Bytes C. 0 Bytes D. 60 Bytes

computer-networks fragmentation gate2004


Selected Answer

1.Application layer can recieve any amount of data ..in the given question A recieves 180 Byte of data and sends it to
transport layer.

2.transport layer on recieving it adds a header of 20 Bytes to it total frame size=180+20=200B and sends it to network
layer.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1269 of 2244

3.network layer on recieving 200 B of data adds 20 Bytes of header total length=220 Bytes..as maximum packet
size=1000 B so no need of fragmentation and then it sends to network B.

4 As B can recieve 100 byte of data only but A is sending 220 byte of data...first of all 20 byte of is removed by network
layer of B and then divide it into 3 fragments (80+20),(80+20),(40+20) ...and then send it to network C.

5.so network layer will recieve 260 Byte of data...(ANSWER)

PART B..

rate of transfer=(180(useful data)/260(total data))*240(bottleneck bandwidth)

=166.15KBps

part C->

without fragmentation -:headers required=220

with fragmentation=260

extra overhead=260-220=40 Bytes

 1 votes -- sourav anand ( 1585 points)

9.44 Fragmentation: Offset of the Last fragment top gateoverflow.in/39172

Why is it 416 ?

computer-networks fragmentation ace-test-series normal


Selected Answer

Mtu is 440

Ip header =20

So 420 bytes still there for data

Amount of data in fragment should be divisible by 8

420 not divisible by 8 so we take 416

 1 votes -- Pooja ( 22773 points)

9.45 Frame: Calculating frame length when bit rate, propagation delay(in
bits) and length of link is given. top gateoverflow.in/37881

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1270 of 2244

Assume CSMA/CD protocol. Find the least frame length in bytes for a 2 Mbps bit rate and 1.5km long network where propagation delay is 4.25
nano seconds per metre _______

computer-networks frame csma-cd

TT=2PT

TT= frame length/ bandwidth= frame length/2mbps

PT=4.25nsx1.5km= 6.375μs

TT=2PT

Framelength/2x106= 2x6.375μs

Framelength= 4x6.375= 25.5bits= 3.18 byte

But I m lilbit confused about least frame length here.

 0 votes -- Khushboo Tak ( 1961 points)

9.46 Go Back N: Size of Sequence Number Field top gateoverflow.in/29723

Consider a Go Back N sliding window protocol that uses a frame size of 2KB to send data on a 10KBPS link with a Round Trip Time of
100 milli seconds.To achieve a link utilization of 50%, the minimum number of bits required to represent the sequence number field
is _____ .

Here per frame transmission time is 0.2 seconds & given RTT is 0.1 second.

How it is possible?

Am I misinterpreting the question?

computer-networks sliding-window go-back-n


Selected Answer

Transmission time= 2KB / 10KBPS

=2*2 10 / 10 * 2 10 sec
=1/5 sec= 0.2 sec=200ms

RTT= 100m =0.1 sec

then, propagation delay = 100/2=50 ms

So, 2a = 2tp / tt = 2 *50/200 = 1/2

Min no. of bits in sequence no of field ceil(log 2(1+2a))

=ceil(log(3/2)) = 1

 2 votes -- srestha ( 11585 points)

9.47 Go Back N: CN: Go Back N top gateoverflow.in/33966

Station A needs to send a message consisting of 15 packets to station ‘B’ using a sling window (window size 4) and go-back-
N error control strategy. All packets are ready and immediately available for transmission. If every 6th packet that ‘A’

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1271 of 2244

transmits gets lost (but no Acks from ‘B’ ever gets lost), then what is the number of packets that ‘A’ will transmit for sending
the message to ‘B’ ? (a) 29 (b) 33 (c) 27 (d) 25

go-back-n sliding-window computer-networks


Selected Answer

1 2 3 4 5 6 7 8 9 6 7 8 9 10 11 8 9 10 11 12 13 10 11 12 13 14 15 12 13 14 15 14 15

Total 33

 4 votes -- Monanshi Jain ( 5827 points)

9.48 Go Back N: Number of packets to be transmitted if every 6th is lost


GBN? top gateoverflow.in/37742

Station A needs to send a message consisting of 15 packets to station ‘B’ using a sling window (window size 4) and go-back-
N error control strategy. All packets are ready and immediately available for transmission. If every 6th packet that ‘A’
transmits gets lost (but no Acks from ‘B’ ever gets lost), then what is the number of packets that ‘A’ will transmit for sending
the message to ‘B’ ?
(a) 29

(b) 33

(c) 27

(d) 25

computer-networks sliding-window go-back-n


Selected Answer

Since every 6th packet get lost : packets will be send like shown below

1 2 3 4 5 6 (lost) 7 8 9

6 7 8 (lost) 9 10 11

8 9 10(lost) 11 12 13

10 11 12 (lost) 13 14 15

12 13 14(lost) 15

14 15

So , Total 33 packets . option B

 3 votes -- Nitish Vashisth ( 593 points)

9.49 Go Back N: What is the number of packets to be transmitted in GBN if


every 7th packet is lost? top gateoverflow.in/34290

Station X needs to send a message consisting of 12 packets to station Y using GBN with window size = 4. All packets are
ready and available for transmission. If every 7th packet that X transmits gets lost (but no ACK loss), total how many
packets X needs to transmit?

computer-networks sliding-window go-back-n

1 2 3 4 5 6 7 8 9 10 7 8 9 10 11 12 10 11 12

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1272 of 2244

packet 7 is lost

packet 10 is lost

19 packets are transmittted

 2 votes -- Pooja ( 22773 points)

9.50 Go Back N: GO-BACK-N problem top gateoverflow.in/14661

sliding-window go-back-n


Selected Answer

RTT = Tp + Tack + 2PD

PD = 1000km/(2 * 10^8) = 5 ms

Tack = Tp = 0 (transmission time is ignored in question).

So, RTT = 2 * 5ms = 10ms.

In RTT, in Go-Back-N protocol, N frames are transmitted. N = 8 here.

So, time to transmit 8 frames = 10 ms.

Each frame of of size 1024.

So, time to transmit 8 * 1024 = 8Kb (2^13 bits) = 10 ms.

Time taken to send 1M (2^20) bits = 10 ms * 2^7 = 1280 ms = 1.28 s.

Ref: http://web.mit.edu/modiano/www/6.263/lec3-4.pdf

 2 votes -- Arjun Suresh ( 124125 points)

9.51 Hamming Code: hamming code top gateoverflow.in/39392

how this relation (m+r+1)<=2^r comes??

please explain.

computer-networks hamming-code

We have to transfer m message bits, and employ error correction. For that purpose let no of parity bits added be p. Now
error can occur in m message bits or p parity bits or no error therefore total

m+p+1 possibilities , To cover all these possibilities,

2^p >=m+p+1

coz after receiving parity bits using those p bits we must be able to identify all these possibilities.

eg

0 0 0 ( no change in p4,p2,p1 after calculating at receiver end) it means no error in data and parity

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1273 of 2244

If its

1 0 1 means error in pos 5 ( p1 covering 1,3,5,7 and p4 covering 4,5,6,7

Both doesnt match means error at pos 5)

Thus with 3 bits u can cover 8 possibilities

 0 votes -- Anurag Semwal ( 4775 points)

9.52 Ip: Mtu top gateoverflow.in/31136

Consider a network having a host P connected to another host Q via two routers Rl and R2. P is connected to R1 through a
link that can support a maximum frame length of 1024 bytes including header of size 12 bytes. R1 is connected to R2
through a link that supports a maximum frame length of 256 bytes including an 8bytes header. R2 is connected to the host Q
through the link that can support a maximum frame length of 512 bytes including the frame header of 12bytes. Suppose a
TCP message having 800bytes of data and 20 bytes of TCP header is passed to the IP at host P for delivery to Q. Find the
total number of bytes that are sent from host P to Q (including all the headers).
http://gateoverflow.in/?qa=blob&qa_blobid=626145120644117638

ip header

Ans 868

 0 votes -- Saurabh ( 19 points)

9.53 Ip Packet: Steps taken by a Router on receiving a packet. top gateoverflow.in/29660

A Router outside the organization received a packet 224.240.7.91. Consider following steps that a router may take:
1. The router looks in its routing table to find out how to route the packet to the destination
2. The router looks at the first byte of the address to find the class
3. The default mask for the class is ANDED (logical AND operation) and address is found.

Which of the above steps actually the router takes?

In case, more than one steps are taken, mention the sequence of steps also.

According to me, a Router takes the following steps:

a) If the ethernet destination address of the arriving frame belongs to the router, accept the frame, else drop it.

b) Examine the IP version and length of the datagram.

c) Decrement the TTL, update the IP header checksum.

d) Check to see if TTL == 0.

e) If the IP destination address is in the forwarding table, forward to the correct outgoing port(s) for the next hop.

f) Find the ethernet destination address for the next hop router.

g) Create a new ethernet frame and send it.

There should not be any need of finding the class of the IP address if we are going to use forwarding table for finding the next hop.So step 2
should not be taken.

Also if the router will have an entry for the destination IP address of the packet, it will forward the packet otherwise it will simply drop the
packet.So step 3 should not be taken.

So the router should take only step 1.

Am I missing something?

What should be the correct answer to this question?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1274 of 2244

routing ip-packet computer-networks

u went too deep . what i think this happens in short,

take the first entry of the rounting table and and with subnet mask of that entry, if it is match just send it to the interface,
else go to next . till you hit a default entry, i think router does not use the class address instead it already have the n/w id
+ subnet mask of n/w.

so according to me only one true step is 1.

 1 votes -- Ravi Singh ( 7303 points)

9.54 Ipv6: ISRO-2013-42 top gateoverflow.in/43982

IPv6 does not support which of the following addressing modes?

A. Unicast addressing
B. Multicast addressing
C. Broadcast addressing
D. Anycast addressing

isro2013 computer-networks ipv6


Selected Answer

C)Broadcast Addressing

for Unicast, multicast IPV6 supprt IPV4 firewall

http://serverfault.com/questions/227442/why-cant-ipv6-send-broadcasts

 1 votes -- srestha ( 11585 points)

9.55 Ipv6: IPv6 top gateoverflow.in/25898

ipv6

Comparison Between IPv4 and IPv6 :


© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1275 of 2244

 3 votes -- Vinay Yadav ( 1739 points)

9.56 Ipv6: IPv6 does not support which of the following addressing modes?
top gateoverflow.in/17043

IPv6 does not support which of the following addressing modes?

a)Unicast addressing

b)Multicast addressing

c)Broadcast addressing

d)Anycast addressing

ipv6


Selected Answer

C) Broadcast Addressing. IPv6 does not implement traditional IP broadcast, and therefore does not define broadcast
addresses. In IPv6, the same result can be achieved by sending a packet to the link-local all nodes multicast group which
is analogous to IPv4 multicast.

 1 votes -- admin ( 1411 points)

9.57 Jnuee 2006: Computer Networks question JNUEE 2006 top gateoverflow.in/32120

Sliding Window Protocol with Selective Reject/Repeat gives better performance than other protocols when

a) buffer is sufficient and bandwidth is limited

b) buffer is moderate and bandwidth is sufficient

c) buffer is moderate and bandwidth is limited

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1276 of 2244

d) buffer is sufficient and bandwidth is sufficient

computer-networks jnuee-2006 made-easy workbook-question

In case of selective repeat suppose sender is sending n packet then receiver has to wait for n packet .So
buffer requirement is high in case of selective repeat .

In case selective repeat no of retransmissions are less so bandwidth requirement is limited.

So Option A is Correct.

 0 votes -- Manojk ( 3365 points)

9.58 Leaky Bucket: Leaky bucket top gateoverflow.in/36444

leaky-bucket computer-networks


Selected Answer

Leaky Bucket strategy tries to give the average of all bursty outputs :

15*3 + 6*2 + 5*3 = 72 Mb

This amount is produced in 3+2+2+2+3 = 12 sec .

Avg output is 72/12 = 6Mbps .

Ans B.

 3 votes -- Riya Roy ( 4767 points)

9.59 Network Addressing: A host with IP address 10.100.100.100 wants to


use loopback testing,WHAT are the source and destination addresses? gateoverflow.in/9322

top

1. 10.100.100.100 & 10.100.100.100

2. 10.100.100.100 & 255.255.255.255

3. 10.100.100.100 & 127.1.100.1

4. 127.100.100.100 & 10.100.100.100

network-addressing

Loop Back testing means Source and Destination should be same.

So I suggest ANS is 1.

 3 votes -- Venkata Krishna Reddy Yatam ( 47 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1277 of 2244

1 is the answer. 127.XXX are reserved for loopback though 127.0.0.1 is the usual implemented one (just a convention).

http://en.utrace.de/whois/127.100.100.100

2 choice is broadcasting and hence cannot be the answer.

 3 votes -- Arjun Suresh ( 124125 points)

9.60 Network Addressing: What is the IP address for last host of subnet to
which given IP belongs? top gateoverflow.in/37745

Consider the following IP address and subnet mask.


IP Address : 201.59.60.138
Subnet Mask : 255.255.255.240
What is the IP address for last host of subnet to which given IP belongs?

Given Answer : 201.59.60.142

My solution :

1 0 0 0 1 0 1 0 AND
1 1 1 1 0 0 0 0 <---- SUBNET MASK last octact

1 0 0 0 0 0 0 0 <--- Network ID of given IP

last system wil have IP address 201.59.60.255


.255 cannot be used

So , 201.59.60.254

What is the mistake with my approach ?


computer-networks network-addressing


Selected Answer

1 0 0 0 1 0 1 0
1 1 1 1 0 0 0 0 <---- SUBNET MASK last octact

1 0 0 0 0 0 0 0 <--- Network ID of given IP (Red--Subnet bits,Blue Host bits)

In Subnet mask you have four 1's ,it means 4 bit have been borrowed from host.

So total no of subnet possible is 2^4-2

And Total Host Possible is 2^4-2---> given that it's a Class C IP Address.

In the Network Id Don't change the Subnet part because it doesn't belong to host.

So finally the Last host of the Subnet will be 10001110==142

We can't put all 1's to the Host bits because it belongs to the broadcast address.

Finally 201.69.60.142 is the last host of the Subnet.

As in the question it was not mentioned Last Host of the last subnet,you can't put all 1's to the Subnet part.

 3 votes -- Ankesh Gautam ( 665 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1278 of 2244

9.61 Network Addressing: class c network subnet problem top gateoverflow.in/39157

A class c n/w has been connected to a router with mask 255.255.255.49. a packet with ip 195.200.180.173 arrived at
router.find the no of subnet in the network.

computer-networks network-addressing

8 subnets will be there in class c host id bits are 8 and that are the last ones . in the last ones we have taken 3 bits i.e(
32, 16, 1) . for sbnetting convention is that , take the bits from starting but we can take bits from anywhere . so by 3 bits
8 subnets are possible .

 1 votes -- Ravi Singh ( 7303 points)

9.62 Network Protocols: ISRO-2013-47 top gateoverflow.in/44154

The protocol data unit for the transport layer in the internet stack is

A. Segment
B. Message
C. Datagram
D. Frame

isro2013 network-protocols

PDU used for Transport Layer is A)Segment

 0 votes -- srestha ( 11585 points)

9.63 Network Security: Kurose Ross, 6th Edition PN0 744 top gateoverflow.in/30596

Modular Arithmatic - Network Security chapter

Revise Question 7

Suppose n = 10,000, a = 10,023, and b = 10,004. Use an identity of modular


arithmetic to calculate in your head (a • b) mod n

network-security

(a*b)mod n=(a mod n*b mod n)mod n

a=10023

b=10004

(10023*10004)mod 10000=(10023 mod 10000*10004 mod 10000)mod 10000

=23*4 mod 10000

=92 mod 10000

=92

 2 votes -- Pooja ( 22773 points)

a=1023
b=10004
n=10000

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1279 of 2244

Therefore, a mod n = 23 and b mod n = 4.


So (a * b) mod n = 23 * 4 = 92.

 1 votes -- Monanshi Jain ( 5827 points)

9.64 Network Security: How to calculate "value" in GCD(value,constant


value) = 1 in RSA? top gateoverflow.in/28684

How to calculate resulting values of "someValues" in GCD(someValues,60)=1 in RSA ?

network-security computer-networks

9.65 Network Security: SHA 1 hash algo. create N-bit message digest out of
a message of 512bit blocks. So is has a message digest of_? top gateoverflow.in/28879

SHA 1 hash algo. create N-bit message digest out of a message of 512bit blocks. So is has a message digest of_?
A.4 words of 32bits
B.5 words of 32bits
C.16 words of 32bits
D.8 words of 32bits

How to get its message digest?

network-security computer-networks

9.66 Network Security: ISRO-2013-45 top gateoverflow.in/43986

A packet filtering firewall can

A. Deny certain users from accessing a service


B. Block worms and viruses from entering the network
C. Disallow some files from being accessed through FTP
D. Block some hosts from accessing the network

isro2013 computer-networks network-security

A firewall typically establishes a barrier between a trusted, secure internal network

A packet filtering firewall Block some hosts from accessing the network

Packet filtering works on 3 layer of OSI model .Most of the work is done between the network and physical layers.

it is (D) as answer

 0 votes -- srestha ( 11585 points)

9.67 Network Security: Kurose Ross 6th Edition PN 746 R32 top gateoverflow.in/30615

R32. Why must an application gateway work in conjunction with a router filter to be effective?

network-security computer-networks

9.68 Network Security: Kurose Ross 6th Edition PN 745 R17 top gateoverflow.in/30607

Please explain answer of following question.

R17. What does it mean to say that a nonce is a once-in-a-lifetime value? In whose
lifetime?
Ans given -> Once in a lifetimes means that the entity sending the nonce will never again use that value to check whether another entity is “live”.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1280 of 2244

Please explain the answer.

network-security computer-networks

9.69 Network Switching: propagation delay top gateoverflow.in/8968

Two hosts are connected via a packet switch with 10 7 bits per second links. Each link has a propagation delay of 20
microseconds. The switch begins forwarding a packet 35 microseconds after it receives the same. If 100 bits of data are to
be transmitted between the two hosts using a packet size of 500 bits, the time elapsed between the transmission of the first
bit of data and the reception of the last bit of the data in microseconds is _____.

computer-networks network-switching


Selected Answer

Since packet size is 500 bits even though we need only 100 bits, we have to send 500 bits.

Transmission time for 500 bits = Time for 500 bits to travel

= 500/107 seconds = 50 microseconds

So, after 50 microseconds he packet is completely transmitted. But the packet must reach the other end and this happens
exactly after propagation delay which here is 20 microseconds. So, the switch receives the packet after 50 + 20 = 70
microseconds.

Given in question, switch forwards after 35 microseconds. So, after 70 + 35 = 105 microseconds, the switch forwards the
packet and at 105 + 70 = 175 microseconds the receiver receives the last bit of data. (70 is same as the time to reach
the switch as propagation delay is same for the two links as given in question).

 0 votes -- Arjun Suresh ( 124125 points)

9.70 Network Switching: Packet switching top gateoverflow.in/33452

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1281 of 2244

Q 30). Consider a route in a store and forward networking going through 9 intermediate nodes.The packet contains 1100 bits
and are transmitted at 64 Kpbs . Assume propogation delay over the links are negligible.As packet travels along the route, it
encounters an average of 5 packets when it arrives at each node. How long does it take for the packets to get to the receiver
if the nodes transmit on a " first come first served" basis (in ms) ?

network-switching

9.71 Network Switching: Ckt switching top gateoverflow.in/30024

is the total time in ckt switching is more than the packet switching

network-switching

It depends. the total time in circuit switch is setup time + transmission time+ propagation delay + end up time.

while in packet switching it only take the transmission time and propagation delay . but transmission is done at every
hope.
circuit switch is like connecting a lan between two computer while packet switching is like transfering data using the
internet in between.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1282 of 2244

if the data is in a bulk. lan will be usefull while if it is a small packet then packet switch will be best.

 2 votes -- Ravi Singh ( 7303 points)

9.72 Network Switching: Resource allocation in packet switching and circuit


switching top gateoverflow.in/38195

Resource Reservation is a feature of:


A. Circuit Switching
B. Packet Switching
C. Both (A) and (B)
D. None of these

PS: In virtual packet switching resouce allocation is done during setup, while in datagram packet switching, there is no
allocation. http://www.slideshare.net/mukeshnt/chap-8-switching

network-switching resource-allocation computer-networks

9.73 Numerical Type: Peterson Davie 3.28 top gateoverflow.in/43612

Suppose a switch is built using a computer workstation and that it can forward packets at a rate of 500, 000 packets per
second, regardless (within limits) of size. Assume the workstation uses direct memory access (DMA) to move data in and out
of its main memory, which has a bandwidth of 2 Gbps, and that the I/O bus has a bandwidth of 1 Gbps. At what packet size
would the bus bandwidth become the limiting factor?

peterson-davie numerical-type

9.74 Numerical Type: Peterson Davie 2.20b top gateoverflow.in/43212

The CRC algorithm as presented in this chapter requires lots of bit manipulations. It is, however, possible to do polynomial
long division taking multiple bits at a time, via a table-driven method, that enables efficient software implementations of
CRC.We outline the strategy here for long division 3 bits at a time (see Table 2.5); in practice, we would divide 8 bits at a
time, and the table would have 256 entries. Let the divisor polynomial C = C(x) be x3 + x2 + 1, or 1101. To build the table for C,
we take each 3-bit sequence, p, append three trailing 0s, and then find the quotient q = p ⌢ 000 ÷ C,

Ignoring the remainder. The third column is the product C × q, the first 3 bits of which should equal p.

(b) Fill in the missing entries in the table.

peterson-davie numerical-type

9.75 Numerical Type: Peterson Davie 2.20c top gateoverflow.in/43219

The CRC algorithm as presented in this chapter requires lots of bit manipulations. It is, however, possible to do polynomial
long division taking multiple bits at a time, via a table-driven method, that enables efficient software implementations of
CRC.We outline the strategy here for long division 3 bits at a time (see Table 2.5); in practice, we would divide 8 bits at a
time, and the table would have 256 entries. Let the divisor polynomial C = C(x) be x3 + x2 + 1, or 1101. To build the table for C,
we take each 3-bit sequence, p, append three trailing 0s, and then find the quotient q = p ⌢ 000 ÷ C,

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1283 of 2244

Ignoring the remainder. The third column is the product C × q, the first 3 bits of which should equal p

(c) Use the table to divide 101001011001100 by C. Hint: The first 3 bits of the dividend are p = 101, so from the table
the corresponding first 3 bits of the quotient are q = 110.Write the 110 above the second 3 bits of the dividend, and subtract
C × q = 101110, again from the table, from the first 6 bits of the dividend. Keep going in groups of 3 bits. There should be no
remainder.

peterson-davie numerical-type

9.76 Numerical Type: Peterson Davie 2.20a top gateoverflow.in/43210

The CRC algorithm as presented in this chapter requires lots of bit manipulations. It is, however, possible to do polynomial
long division taking multiple bits at a time, via a table-driven method, that enables efficient software implementations of
CRC.We outline the strategy here for long division 3 bits at a time (see Table 2.5); in practice, we would divide 8 bits at a
time, and the table would have 256 entries. Let the divisor polynomial C = C(x) be x3 + x2 + 1, or 1101. To build the table for C,
we take each 3-bit sequence, p, append three trailing 0s, and then find the quotient q = p ⌢ 000 ÷ C,

Ignoring the remainder. The third column is the product C × q, the first 3 bits of which should equal p.

(a) Verify, for p = 110, that the quotients q = p ⌢ 000 ÷ C and q = p ⌢ 111 ÷ C are the same; that is, it doesn’t matter what
the trailing bits are.

peterson-davie numerical-type

9.77 Numerical Type: Peterson Davie 2.18a top gateoverflow.in/43158

Suppose we want to transmit the message 11100011 and protect it from errors using the CRC polynomial x3 + 1.

(a) Use polynomial long division to determine the message that should be transmitted.

peterson-davie numerical-type


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1284 of 2244

The message sent would be 11100011 100 !

 1 votes -- Dexter ( 1933 points)

9.78 Numerical Type: Peterson Davie 2.15 top gateoverflow.in/43151

Prove that the Internet checksum computation shown in the text is independent of byte order (host order or network order)
except that the bytes in the final checksum should be swapped later to be in the correct order. Specifically, show that the
sum of 16-bit words can be computed in either byte order. For example, if the one’s complement sum (denoted by +′) of 16-
bit words is represented as follows,
[A, B] + ′ [C, D] + ′ . . . + ′ [Y, Z]
The following swapped sum is the same as the original sum above:
[B, A] + ′ [D, C] + ′ . . . + ′ [Z, Y]

peterson-davie numerical-type

9.79 Numerical Type: Peterson Davie 2.17 top gateoverflow.in/43153

Show that the Internet checksum can be computed by first taking the 32-bit ones complement sum of the buffer in 32-bit
units, then taking the 16-bit ones complement sum of the upper and lower half words, and finishing as before by
complementing the result. (To take a 32-bit ones complement sum on 32-bit twos complement hardware, you need access to
the “overflow” bit.)

peterson-davie difficult numerical-type

9.80 Numerical Type: Peterson Davie 2.18b top gateoverflow.in/43160

Suppose we want to transmit the message 11100011 and protect it from errors using the CRC polynomial x3 + 1.

(b) Suppose the leftmost bit of the message is inverted due to noise on the transmission link. What is the result of the
receiver’s CRC calculation? How does the receiver know that an error has occurred?

peterson-davie numerical-type


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1285 of 2244

its easy

Your message is 11100011

CRc polynomial is : 1001

Now we know That in this CRC calculation remainder what we get is padded with message

So when we apply 11100011/ 1001 ( using mod 2 operator ) we get Remainder as 100

So from the sender side message that would be transmitted is 11100011 100 ( message + remainder )

Now this message is send over channel but now according to given condition it is said due to noise , The leftmost bit get
changed

So now actual message that is recieved by reciever : 01100011 100 .

Now the things that happen on Reciever side : It take (message + reaminder ) / 1001 Now for this divison if it get
remainder 000 then your message is perfect or correct

Now if i do (1100011 100)/ 1001 = you will get remainder as 010 which is not equal to required 000

Hence in this way Reciever would be able to detect error

Note that if your CRc Polynomial is n bit then the remainder will be n-1 bits

 1 votes -- Dexter ( 1933 points)

9.81 Numerical Type: Peterson Davie 2.19a top gateoverflow.in/43204

Suppose we want to transmit the message 1011001001001011 and protect it from errors using the CRC8 polynomial.

x8 + x2 + x1 + 1

(a) Use polynomial long division to determine the message that


should be transmitted.

peterson-davie numerical-type

message is 1011001001001011

CRC is 100000111

Now apply mod 2 operator

Error free message will be received by receiver is 1011001001001011 01011100

 1 votes -- srestha ( 11585 points)

9.82 Numerical Type: Peterson Davie 2.19b top gateoverflow.in/43207

Suppose we want to transmit the message 1011001001001011 and protect it from errors using the CRC8 polynomial

x8 + x2 + x1 + 1

(b) Suppose the leftmost bit of the message is inverted due to noise on the transmission link. What is the result of the
receiver’s CRC calculation? How does the receiver know that an error has occurred?

peterson-davie numerical-type

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1286 of 2244

pag

page 2 :

 0 votes -- Dexter ( 1933 points)

9.83 Numerical Type: Peterson Davie 2.23b top gateoverflow.in/43386

Consider an ARQ algorithm running over a 40-km point-to-point fiber link.

(b) Suggest a suitable timeout value for the ARQ algorithm to use.

peterson-davie numerical-type

Here PT=200µs

RTT=400µs

Timeout =2*RTT

=800µs

 0 votes -- Manojk ( 3365 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1287 of 2244

9.84 Numerical Type: Peterson Davie 2.37 top gateoverflow.in/43532

Suppose A is connected to B via an intermediate router R, as in the previous problem. The A − R link is instantaneous, but the
R − B link transmits only one packet each second, one at a time (so two packets take 2 seconds). Assume A sends to B using
the sliding window protocol with SWS = 4. For Time = 0, 1, 2, 3, 4, state what packets arrive at and are sent from A and B. How
large does the queue at R grow?

peterson-davie numerical-type

9.85 Numerical Type: Peterson Davie 2.42a top gateoverflow.in/43544

Suppose the round-trip propagation delay for Ethernet is 46.4μs. This yields a minimum packet size of 512 bits (464 bits
corresponding to propagation delay + 48 bits of jam signal).

(a) What happens to the minimum packet size if the delay time is held constant, and the signalling rate rises to 100 Mbps?

peterson-davie numerical-type

9.86 Numerical Type: Peterson Davie 2.36b top gateoverflow.in/43529

Suppose A is connected to B via an intermediate router R, as shown in Figure 2.37. The A − R and R − B links each accept
and transmit only one packet per second in each direction (so two packets take 2 seconds), and the two directions
transmit independently. Assume A sends to B using the sliding window protocol with SWS = 4.

(b) What happens if the links have a propagation delay of 1.0 second, but accept immediately as many packets as are offered
(i.e., latency = 1 second but bandwidth is infinite)?

peterson-davie numerical-type

9.87 Numerical Type: Peterson Davie 2.29 top gateoverflow.in/43421

Give some details of how you might augment the sliding window protocol with flow control by having ACKs carry additional
information that reduces the SWS as the receiver runs out of buffer space. Illustrate your protocol with a timeline for a
transmission; assume the initial SWS and RWS are 4, the link speed is instantaneous, and the receiver can free buffers at the
rate of one per second (i.e., the receiver is the bottleneck). Show what happens at T = 0, T = 1, . . . . . . , T = 4 seconds.

peterson-davie numerical-type

9.88 Numerical Type: Peterson Davie 2.42c top gateoverflow.in/43547

Suppose the round-trip propagation delay for Ethernet is 46.4μs. This yields a minimum packet size of 512 bits (464 bits
corresponding to propagation delay +48 bits of jam signal).

(c) If compatibility were not an issue, how might the specifications be written so as to permit a smaller minimum packet
size?

peterson-davie numerical-type

9.89 Numerical Type: Peterson Davie 2.36a top gateoverflow.in/43528

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1288 of 2244

(Figure 2.37)

Suppose A is connected to B via an intermediate router R, as shown in Figure 2.37. The A − R and R − B links each accept
and transmit only one packet per second in each direction (so two packets take 2 seconds), and the two directions
transmit independently. Assume A sends to B using the sliding window protocol with SWS = 4.

(a) For Time = 0, 1, 2, 3, 4, 5, state what packets arrive at and leave each node, or label them on a timeline.

peterson-davie numerical-type

9.90 Numerical Type: Peterson Davie 2.41 top gateoverflow.in/43542

Coaxial cable Ethernet was limited to a maximum of 500m between repeaters, which regenerate the signal to 100% of its
original amplitude. Along one 500-m segment, the signal could decay to no less than 14% of its original value (8.5dB). Along
1500 m, then, the decay might be (0.14)3 = 0.3%. Such a signal, even along 2500 m, is still strong enough to be read; why then
are repeaters required every 500 m?

peterson-davie numerical-type difficult

9.91 Numerical Type: Peterson Davie 2.25b top gateoverflow.in/43391

Suppose you are designing a sliding window protocol for a 1-Mbps point-to-point link to the stationary satellite revolving
around the Earth at an altitude of 3 × 104 km. Assuming that each frame carries 1 KB of data, what is the minimum number of
bits you need for the sequence number in the following cases? Assume the speed of light is 3 × 108 m/s.

(b) RWS = SWS

peterson-davie numerical-type

Here PT=(3*10^3*10^4)/(3*10^8)

=.1 sec

TT=8192*10^-6 sec

W=1+2a (here a=PT/TT)

=25

Here SWS=RWS

Sequece No cover Twice the window size i.e. 50 packet

So Sequence bit =6

 0 votes -- Manojk ( 3365 points)

9.92 Numerical Type: Peterson Davie 2.40 top gateoverflow.in/43541

The 1982 Ethernet specification allowed between any two stations up to 1500mof coaxial cable, 1000mof other point-to-point
link cable, and two repeaters. Each station or repeater connects to the coaxial cable via up to 50mof “drop cable.” Typical
delays associated with each device are given in Table 2.6 (where c = speed of light in a vacuum = 3 × 108 m/s). What is the
worst-case round-trip propagation delay, measured in bits, due to the sources listed? (This list is not complete;
other sources of delay include sense time and signal rise time.)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1289 of 2244

peterson-davie numerical-type

9.93 Numerical Type: Peterson Davie 2.23a top gateoverflow.in/43385

Consider an ARQ algorithm running over a 40-km point-to-point fiber link.

(a) Compute the one-way propagation delay for this link, assuming that the speed of light is 2 × 108 m/s in the fiber.

peterson-davie numerical-type

algorithm running over a -km point-to-point fiber link.


(a) Compute the one-way propagation delay for this link, assuming that the speed of light is m/s in the fiber.

Solution . Propagation time= time to reach first bit from sender side to reciever side.

Tpt = distance / lite of speed = 40 km / m/s

= 40 × 103 / 2 × 108 = 200 micro second

 0 votes -- Anirudh Pratap Singh ( 4091 points)

9.94 Numerical Type: Peterson Davie 2.23c top gateoverflow.in/43387

Consider an ARQ algorithm running over a 40-km point-to-point fiber link.

(c) Why might it still be possible for the ARQ algorithm to time out and retransmit a frame, given this timeout value?

peterson-davie numerical-type

9.95 Numerical Type: Peterson Davie 2.24 top gateoverflow.in/43389

Suppose you are designing a sliding window protocol for a 1-Mbps point-to-point link to the moon, which has a one-way
latency of 1.25 seconds. Assuming that each frame carries 1 KB of data, what is the minimum number of bits you need for
the sequence number?

peterson-davie numerical-type

Here Latency from Moon to sender is given = 1.25

so from sender to reciever = sender to Moon + Moon to sender = 2 × sender to Moon = 2.50 s

Total no. of bits transmitted in RTT= 2 × P.T. ×Bandwidth = 2× 2.50 × 1 ×106 = 5× 106 bits

No. of frame transmitted = Total no. of bits transmitted in RTT / frame size

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1290 of 2244

6 / 1 kB = 5 × 106 / 8 × 103 = 625 frames


= 5 × 10

so for sliding window protocol use anyone protocol go back, selective repeat etc

 1 votes -- Anirudh Pratap Singh ( 4091 points)

9.96 Numerical Type: Peterson Davie 2.25a top gateoverflow.in/43390

Suppose you are designing a sliding window protocol for a 1-Mbps point-to-point link to the stationary satellite revolving
around the Earth at an altitude of 3 × 104 km. Assuming that each frame carries 1 KB of data, what is the minimum number of
bits you need for the sequence number in the following cases? Assume the speed of light is 3 × 108 m/s.

(a) RWS = 1

peterson-davie numerical-type

Here PT=(3*10^3*10^4)/(3*10^8)

=.1 sec

TT=8192*10^-6 sec

W=1+2a (here a=PT/TT)

=25

If RWS=1

No of sequence bit=5

 0 votes -- Manojk ( 3365 points)

9.97 Numerical Type: Peterson Davie 2.42b top gateoverflow.in/43546

Suppose the round-trip propagation delay for Ethernet is 46.4μs. This yields a minimum packet size of 512 bits (464 bits
corresponding to propagation delay +48 bits of jam signal).

(b) What are the drawbacks to so large a minimum packet size?

peterson-davie numerical-type

9.98 Osi Protocol: Protocol Stack top gateoverflow.in/35938

Match The Following

Half Duplex Mode


Full Duplex Mode
Point TO Point Link
Broadcast Link

1. Physical Layer
2. Session Layer
3. Transport Layer
4. Data Link Layer

Solution

I think everyone is matching with Physical Layer .

Solution Given as

Half Duplex Mode - Session Layer


Full Duplex Mode - Session Layer
Point TO Point Link - Physical Layer
Broadcast Link - Physical Layer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1291 of 2244

Please Correct the mistakes if any.

osi-protocol

9.99 Peterson Davie: Peterson Davie 3.38a top gateoverflow.in/43640

Suppose an IP packet is fragmented into 10 fragments, each with a 1% (independent) probability of loss. To a reasonable
approximation, this means there is a 10% chance of losing the whole packet due to loss of a fragment. What is the
probability of net loss of the whole packet if the packet is transmitted twice,

(a) Assuming all fragments received must have been part of the same transmission?

peterson-davie descriptive difficult

a)The probability of loosing both the packet is=0.1(chances of loosing 1st packet)*0.1(chances of loosing 2nd
packet)=0.01

 0 votes -- Nishant Arora ( 213 points)

9.100 Peterson Davie: Peterson Davie 3.38c top gateoverflow.in/43643

Suppose an IP packet is fragmented into 10 fragments, each with a 1% (independent) probability of loss. To a reasonable
approximation, this means there is a 10% chance of losing the whole packet due to loss of a fragment. What is the
probability of net loss of the whole packet if the packet is transmitted twice,

(c) Explain how use of the Ident field might be applicable here.

peterson-davie descriptive difficult

c)An implementation might (though generally most do not) use the same value for Ident when a packet had to be
retransmitted. .

 0 votes -- Nishant Arora ( 213 points)

9.101 Peterson Davie: Peterson Davie 3.38b top gateoverflow.in/43641

Suppose an IP packet is fragmented into 10 fragments, each with a 1% (independent) probability of loss. To a reasonable
approximation, this means there is a 10% chance of losing the whole packet due to loss of a fragment. What is the
probability of net loss of the whole packet if the packet is transmitted twice,

(b) Assuming any given fragment may have been part of either transmission?

peterson-davie descriptive difficult

b)chances of loosing any single fragment is 0.01*0.01=0.0001.


Now if any of the 10 fragment is lost then whole packet is lost and the probability that this happens atleast one for the 10
different fragments is =10*0.0001=0.001

 0 votes -- Nishant Arora ( 213 points)

9.102 Peterson Davie: Peterson Davie 3.32b top gateoverflow.in/43625

Suppose a 10-Mbps Ethernet hub (repeater) is replaced by a 10-Mbps switch, in an environment where all traffic is between a
single server and N "clients." Because all traffic must still traverse the server-switch link, nominally there is no improvement
in bandwidth.

(b) What other advantages and drawbacks might a switch offer versus a hub?

peterson-davie descriptive

9.103 Peterson Davie: Peterson Davie 3.35 top gateoverflow.in/43633

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1292 of 2244

Some signalling errors can cause entire ranges of bits in a packet to be overwritten by all 0s or all 1s. Suppose all the bits in
the packet, including the Internet checksum, are overwritten. Could a packet with all 0s or all 1s be a legal IPv4 packet? Will
the Internet checksum catch that error? Why or why not?

peterson-davie descriptive

No, this would not be legal, as the packet has structure to it and is not just a collection of data.

All 0's and 1's over the entire packet will change the VER and HLEN fields resulting in non IPV4 packets.

The starting 4 bit of IP Packet decide whether the packet is IP4 or IPV6.other than this possibility if other possibilty occur then the router
will understand that it is modified by noise.

 0 votes -- Nishant Arora ( 213 points)

9.104 Peterson Davie: Peterson Davie 3.34 top gateoverflow.in/43632

Why does the Offset field in the IP header measure the offset in 8-byte units? (Hint: Recall that the Offset field is 13 bits
long.)

peterson-davie descriptive

The IPv4 header allocates only 13 bits to the Offset field, but a packet’s length can be up to 2 16 -1.

In order to support fragmentation of a maximum-sized packet, we must count offsets in multiples of 2 16−13= 23bytes.

 0 votes -- Nishant Arora ( 213 points)

9.105 Peterson Davie: Peterson Davie 3.30 top gateoverflow.in/43621

A stage of an n × n banyan network consists of (n/2)2 × 2 switching elements. The first stage directs packets to the correct half
of the network, the next stage to the correct quarter, and so on, until the packet is routed to the correct output. Derive an
expression for the number of 2 × 2 switching elements needed to make an n × n banyan network. Verify your answer for n = 8.

peterson-davie descriptive difficult

9.106 Peterson Davie: Peterson Davie 3.33 top gateoverflow.in/43629

What aspect of IP addresses makes it necessary to have one address per network interface, rather than just one per host? In
light of your answer, why does IP tolerate point-to-point interfaces that have nonunique addresses or no addresses?

peterson-davie descriptive

IP addresses include the network/subnet, so that interfaces


on different networks must have different network portions
of the address. Alternatively, addresses include location
information and different interfaces are at different locations,
topologically.
Point-to-point interfaces can be assigned a duplicate
address (or no address) because the other endpoint of the link
doesn't use the address to reach the interface; it just sends.
Such interfaces, however, cannot be addressed by any other
host in the network.

source:see section 2.2.7

http://www.freesoft.org/CIE/RFC/1812/24.htm

 0 votes -- Nishant Arora ( 213 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1293 of 2244

9.107 Peterson Davie: Peterson Davie 3.32a top gateoverflow.in/43622

Suppose a 10-Mbps Ethernet hub (repeater) is replaced by a 10-Mbps switch, in an environment where all traffic is between a
single server and N "clients. "Because all traffic must still traverse the server switch link, nominally there is no improvement
in bandwidth.

(a) Would you expect any improvement in bandwidth? If so, why?

peterson-davie descriptive

9.108 Peterson Davie: Peterson Davie 3.36 top gateoverflow.in/43636

Suppose a TCP message that contains 1024 bytes of data and 20 bytes of TCP header is passed to IP for delivery across two
networks interconnected by a router (i.e., it travels from the source host to a router to the destination host). The first
network has an MTU of 1024 bytes; the second has an MTU of 576 bytes. Each network's MTU gives the size of the largest IP
datagram that can be carried in a link layer frame. Give the sizes and offsets of the sequence of fragments delivered to the
network layer at the destination host. Assume all IP headers are 20 bytes.

peterson-davie descriptive

Before entering the first network,we have an IP datagram of 1024+20(TCP header)+20(IP header)=1064 bytes.so the IP
payload is 1044 bytes .This datagram needs to split into 2 fragments.

Fragment 1: IP header of 20 bytes and data of 1000 bytes.Offset is 0.


Fragment 2:IP header of 20 bytes and data of 48 bytes.offset is 1000/8=125.

When fragment 1 goes through the second network,it needs to be split into two fragments.Each fragment can contain at
most 576-20=556 bytes of data.since 556 bytes is not a multiple of 8,each fragment can in fact contain atmost 552 bytes
of data.so we have following 2 fragments:

Fragment 3: IP header of 20 bytes and data of 552 bytes.Offset is 0.


Fragment 4:IP header of 20 bytes and data of 56 bytes.offset is 552/8=69

Finally,fragment 2 goes as is through the second network since it is of size 48 bytes.

The fragment that reach the destination are 3,4 and 2.They are assembled in this order this is because their offsets are in
increasing order(0,69,125).

 0 votes -- Nishant Arora ( 213 points)

9.109 Peterson Davie: Peterson Davie 3.37 top gateoverflow.in/43639

Path MTU is the smallest MTU of any link on the current path (route) between two hosts. Assume we could discover the path
MTU of the path used in the previous exercise, and that we use this value as the MTU for all the path segments. Give the
sizes and offsets of the sequence of fragments delivered to the network layer at the destination host.

peterson-davie descriptive

Considering this previous question

http://gateoverflow.in/43636/peterson-davie-3-36

we know Path MTU is the smallest MTU of any link on the current path (route) between two hosts.

In this case Path MTU is 576 bytes.

Maximum IP payload size is 576-20=556 bytes.

we need to transfer 1024+20=1048 bytes in the IP payload.

This would be fragmented into 2 fragments of size 552 and 496 bytes.

There are 2 packets in total if we use Path MTU.In previous case, we needed 3 packets.

 1 votes -- Nishant Arora ( 213 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1294 of 2244

9.110 Peterson Davie: Peterson Davie 2.14 top gateoverflow.in/43150

Show that the Internet checksum will never be 0xFFFF (that is, the final value of sum will not be 0x0000) unless every byte in
the buffer is 0. (Internet specifications in fact require that a checksum of 0x0000 be transmitted as 0xFFFF; the value 0x0000 is
then reserved for an omitted checksum. Note that, in ones complement arithmetic, 0x0000 and 0xFFFF are both
representations of the number 0).

peterson-davie descriptive

9.111 Peterson Davie: Peterson Davie 2.35b top gateoverflow.in/43435

Suppose that we run the sliding window algorithm with SWS = 5 and RWS = 3, and no out-of-order arrivals.

(b) Give an example showing that MaxSeqNum -1 is not sufficient.

peterson-davie descriptive

9.112 Peterson Davie: Peterson Davie 2.35c top gateoverflow.in/43436

Suppose that we run the sliding window algorithm with SWS = 5 and RWS = 3, and no out-of-order arrivals.

(c) State a general rule for the minimum MaxSeqNum in terms of SWS and RWS.

peterson-davie descriptive

Max Sequence Number>=SWS+RWS

 0 votes -- Manojk ( 3365 points)

9.113 Peterson Davie: Peterson Davie 2.38 top gateoverflow.in/43535

Consider the situation in the previous exercise, except this time assume that the router has a queue size of 1; that is, it can
hold one packet in addition to the one it is sending (in each direction). Let A ′ s timeout be 5 seconds, and let SWS again be 4.
Show what happens at each second from Time = 0 until all four packets from the first window-full are successfully delivered.

peterson-davie descriptive

9.114 Peterson Davie: Peterson Davie 2.39 top gateoverflow.in/43540

What kind of problems can arise when two hosts on the same Ethernet share the same hardware address? Describe what
happens and why that behavior is a problem.

peterson-davie descriptive

9.115 Peterson Davie: Peterson Davie 2.35a top gateoverflow.in/43434

Suppose that we run the sliding window algorithm with SWS = 5 and RWS = 3, and no out-of-order arrivals.

(a) Find the smallest value for MaxSeqNum. You may assume that it suffices to find the smallest MaxSeqNum such that if
DATA[MaxSeqNum] is in the receive window, then DATA[0] can no longer arrive.

peterson-davie descriptive

Max Seq no. = SWS+RWS = 5+3=8

 0 votes -- Shivam Dwivedi ( 55 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1295 of 2244

9.116 Peterson Davie: Peterson Davie 2.34b top gateoverflow.in/43433

Consider the sliding window algorithm with SWS = RWS = 3, with no out-of-order arrivals and with infinite-precision sequence
numbers.

(b) Show that if ACK[6] may be sent (or, more literally, that DATA[5] is in the sending window), then ACK[2] (or earlier) cannot
be received.

These amount to a proof of the formula given in Section 2.5.2, particularized to the case SWS = 3. Note that part (b) implies
that the scenario of the previous problem cannot be reversed to involve a failure to distinguish ACK[0] and ACK[5].

peterson-davie descriptive

9.117 Peterson Davie: Peterson Davie 2.32a top gateoverflow.in/43429

Draw a timeline diagram for the sliding window algorithm with SWS = RWS = 4 frames in the following two situations. Assume
the receiver sends a duplicate acknowledgment if it does not receive the expected frame. For example, it sends DUPACK[2]
when it expects to see Frame[2] but receives Frame[3] instead. Also, the receiver sends a cumulative acknowledgment after
it receives all the outstanding frames. For example, it sends ACK[5] when it receives the lost frame Frame[2] after it already
received Frame[3], Frame[4], and Frame[5]. Use a timeout interval of about 2 × RTT.

(a) Frame 2 is lost. Retransmission takes place upon timeout (as usual).

peterson-davie descriptive

9.118 Peterson Davie: Peterson Davie 2.32b top gateoverflow.in/43430

Draw a timeline diagram for the sliding window algorithm with SWS = RWS = 4 frames in the following two situations. Assume
the receiver sends a duplicate acknowledgment if it does not receive the expected frame. For example, it sends DUPACK[2]
when it expects to see Frame[2] but receives Frame[3] instead. Also, the receiver sends a cumulative acknowledgment after
it receives all the outstanding frames. For example, it sends ACK[5] when it receives the lost frame Frame[2] after it already
received Frame[3], Frame[4], and Frame[5]. Use a timeout interval of about 2 × RTT.

(b) Frame 2 is lost. Retransmission takes place either upon receipt of the first DUPACK or upon timeout. Does this scheme
reduce the transaction time? (Note that some end-to-end protocols, such as variants of TCP, use similar schemes for fast
retransmission.)

peterson-davie descriptive

9.119 Peterson Davie: Peterson Davie 2.33 top gateoverflow.in/43431

Suppose that we attempt to run the sliding window algorithm with SWS = RWS = 3 and with MaxSeqNum = 5. The Nth packet
DATA[N] thus actually contains N mod 5 in its sequence number field. Give an example in which the algorithm becomes
confused; that is, a scenario in which the receiver expects DATA[5] and accepts DATA[0] - which has the same transmitted
sequence number - in its stead. No packets may arrive out of order. Note that this implies MaxSeqNum ≥ 6 is necessary as
well as sufficient.

peterson-davie descriptive

9.120 Peterson Davie: Peterson Davie 2.44a top gateoverflow.in/43554

Suppose the Ethernet transmission algorithm is modified as follows: After each successful transmission attempt, a host waits
one or two slot times before attempting to transmit again, and otherwise backs off the usual way.

(a) Explain why the capture effect of the previous exercise is now much less likely.

peterson-davie descriptive

9.121 Peterson Davie: Peterson Davie 2.44b top gateoverflow.in/43555

Suppose the Ethernet transmission algorithm is modified as follows: After each successful transmission attempt, a host waits
one or two slot times before attempting to transmit again, and otherwise backs off the usual way.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1296 of 2244

(b) Show how the strategy above can now lead to a pair of hosts capturing the Ethernet, alternating transmissions, and
locking out a third.

peterson-davie descriptive

9.122 Peterson Davie: Peterson Davie 3.25 top gateoverflow.in/43592

Cell switching methods (like ATM) essentially always use virtual circuit switching rather than datagram forwarding. Give a
specific argument why this is so (consider the preceding question).

peterson-davie descriptive

9.123 Peterson Davie: Peterson Davie 3.26 top gateoverflow.in/43593

Suppose a workstation has an I/O bus speed of 800 Mbps and memory bandwidth of 2 Gbps. Assuming direct memory access
(DMA) is used to move data in and out of main memory, how many interfaces to 100-Mbps Ethernet links could a switch
based on this workstation handle?

peterson-davie descriptive

9.124 Peterson Davie: Peterson Davie 3.29a top gateoverflow.in/43615

Suppose that a switch is designed to have both input and output FIFO buffering. As packets arrive on an input port they are
inserted at the tail of the FIFO. The switch then tries to forward the packets at the head of each FIFO to the tail of the
appropriate output FIFO.

(a) Explain under what circumstances such a switch can lose a packet destined for an output port whose FIFO is empty

peterson-davie descriptive

9.125 Peterson Davie: Peterson Davie 3.24 top gateoverflow.in/43591

What percentage of an ATM link's total bandwidth is consumed by the ATM cell headers? Ignore padding to fill cells or ATM
adaptation layer headers.

peterson-davie descriptive

9.126 Peterson Davie: Peterson Davie 3.23 top gateoverflow.in/43589

Suppose a bridge has two of its ports on the same network. How might the bridge detect and correct this?

peterson-davie descriptive

9.127 Peterson Davie: Peterson Davie 2.44c top gateoverflow.in/43556

Suppose the Ethernet transmission algorithm is modified as follows: After each successful transmission attempt, a host waits
one or two slot times before attempting to transmit again, and otherwise backs off the usual way.

(c) Suppose the Ethernet transmission algorithm is modified as follows: After each successful transmission attempt, a host
waits one or two slot times before attempting to transmit again, and otherwise backs off the usual way.

peterson-davie descriptive

9.128 Peterson Davie: Peterson Davie 3.3 top gateoverflow.in/43586

For the network given in Figure 3.45, give the datagram forwarding table for each node. The links are labeled with relative
costs; your tables should forward each packet via the lowest-cost path to its destination.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1297 of 2244

peterson-davie descriptive

Host incoming interface Next hop

A 3 C

C 1 E

B 2 E

D 2 E

E 1 C

F 6 C

 0 votes -- srestha ( 11585 points)

9.129 Peterson Davie: Peterson Davie 3.4 top gateoverflow.in/43588

Give forwarding tables for switches S1 to S4 in Figure 3.46. Each switch should have a default routing entry, chosen to
forward packets with unrecognized destination addresses toward OUT. Any specific destination table entries duplicated by
the default entry should then be eliminated.

peterson-davie descriptive

Host incoming interface outgoing interface

A,B 1,2 3

1,3 2

C 2,3 1

D 2 1

 0 votes -- srestha ( 11585 points)

9.130 Peterson Davie: Peterson Davie 2.31b top gateoverflow.in/43426

Draw a timeline diagram for the sliding window algorithm with SWS = RWS = 3 frames, for the following two situations. Use a
timeout interval of about 2 × RTT

(b) Frames 4 to 6 are lost.

peterson-davie descriptive

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1298 of 2244

9.131 Peterson Davie: Peterson Davie 2.34 top gateoverflow.in/43432

Consider the sliding window algorithm with SWS = RWS = 3, with no out-of-order arrivals and with infinite-precision sequence
numbers

(a) Show that if DATA[6] is in the receive window, then DATA[0] (or in general any older data) cannot arrive at the receiver
(and hence that MaxSeqNum = 6 would have sufficed).

These amount to a proof of the formula given in Section 2.5.2, particularized to the case SWS = 3. Note that part (b) implies
that the scenario of the previous problem cannot be reversed to involve a failure to distinguish ACK[0] and ACK[5].

peterson-davie descriptive

9.132 Peterson Davie: Peterson Davie 3.29b top gateoverflow.in/43616

Suppose that a switch is designed to have both input and output FIFO buffering. As packets arrive on an input port they are
inserted at the tail of the FIFO. The switch then tries to forward the packets at the head of each FIFO to the tail of the
appropriate output FIFO.

(b) What is this behavior called?

peterson-davie descriptive

9.133 Peterson Davie: Peterson Davie 2.26 top gateoverflow.in/43393

The text suggests that the sliding window protocol can be used to implement flow control. We can imagine doing this by
having the receiver delay ACKs, that is, not send the ACK until there is free buffer space to hold the next frame. In doing so,
each ACK would simultaneously acknowledge the receipt of the last frame and tell the source that there is now free buffer
space available to hold the next frame. Explain why implementing flow control in this way is not a good idea.

peterson-davie descriptive

9.134 Peterson Davie: Peterson Davie 2.31a top gateoverflow.in/43424

Draw a timeline diagram for the sliding window algorithm with SWS = RWS = 3 frames, for the following two situations. Use a
timeout interval of about 2 × RTT.

(a) Frame 4 is lost.

peterson-davie descriptive

9.135 Peterson Davie: Peterson Davie 3.29c top gateoverflow.in/43617

Suppose that a switch is designed to have both input and output FIFO buffering. As packets arrive on an input port they are
inserted at the tail of the FIFO. The switch then tries to forward the packets at the head of each FIFO to the tail of the
appropriate output FIFO.

(c) Assume that the FIFO buffering memory can be redistributed freely. Suggest a reshuffling of the buffers that avoids the
above problem, and explain why it does so.

peterson-davie descriptive

9.136 Peterson Davie: Peterson Davie 2.16 top gateoverflow.in/43152

Suppose that one byte in a buffer covered by the Internet checksum algorithm needs to be decremented (e.g., a header hop
count field). Give an algorithm to compute the revised checksum without rescanning the entire buffer. Your algorithm should
consider whether the byte in question is low order or high order.

peterson-davie descriptive

9.137 Peterson Davie: Peterson Davie 3.29c top gateoverflow.in/43618

Suppose that a switch is designed to have both input and output FIFO buffering. As packets arrive on an input port they are

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1299 of 2244

inserted at the tail of the FIFO. The switch then tries to forward the packets at the head of each FIFO to the tail of the
appropriate output FIFO.

(c) Assume that the FIFO buffering memory can be redistributed freely. Suggest a reshuffling of the buffers that avoids the
above problem, and explain why it does so.

peterson-davie descriptive

9.138 Peterson Davie: Peterson Davie 2.22 top gateoverflow.in/43224

Consider an ARQ protocol that uses only negative acknowledgments (NAKs), but no positive acknowledgments (ACKs).
Describe what timeouts would have to be scheduled. Explain why an ACK-based protocol is usually preferred to a NAK-based
protocol.

peterson-davie descriptive

9.139 Peterson Davie: Peterson Davie 2.28b top gateoverflow.in/43398

In stop-and-wait transmission, suppose that both sender and receiver retransmit their last frame immediately on receipt of a
duplicate ACK or data frame; such a strategy is superficially reasonable because receipt of such a duplicate is most likely to
mean the other side has experienced a timeout.

(b) Suppose that, like data, ACKs are retransmitted if there is no response within the timeout period. Suppose also that both
sides use the same timeout interval. Identify a reasonably likely scenario for triggering the Sorcerer’s Apprentice bug.

peterson-davie descriptive

9.140 Peterson Davie: Peterson Davie 2.27 top gateoverflow.in/43395

Implicit in the stop-and-wait scenarios of Figure 2.17 is the notion that the receiver will retransmit its ACK immediately
on receipt of the duplicate data frame. Suppose instead that the receiver keeps its own timer and retransmits its ACK only
after the next expected frame has not arrived within the timeout interval. Draw timelines illustrating the scenarios in Figure
2.17(b) to (d); assume the receiver’s timeout value is twice the sender’s. Also redraw (c) assuming the receiver’s timeout value
is half the sender’s.

peterson-davie descriptive

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1300 of 2244

9.141 Peterson Davie: Peterson Davie 2.30 top gateoverflow.in/43423

Describe a protocol combining the sliding window algorithm with selective ACKs. Your protocol should retransmit promptly,
but not if a frame simply arrives one or two positions out of order. Your protocol should also make explicit what happens if
several consecutive frames are lost.

peterson-davie descriptive

9.142 Peterson Davie: Peterson Davie 2.28a top gateoverflow.in/43396

In stop-and-wait transmission, suppose that both sender and receiver retransmit their last frame immediately on receipt of a
duplicate ACK or data frame; such a strategy is superficially reasonable because receipt of such a duplicate is most likely to
mean the other side has experienced a timeout.

(a) Draw a timeline showing what will happen if the first data frame is somehow duplicated, but no frame is lost. How long
will the duplications continue? This situation is known as the Sorcerer’s Apprentice bug.

peterson-davie descriptive

9.143 Probability: What is the max # of users can an ISP serve @least 95%
of the time assuming probability of each user being active is .1? top gateoverflow.in/25402

esP

SI
na
nac
sresu
fo
m
u
rm
n
e
u
bm

ix
aeht
si
W
tah
gnieb
resu
hcae
fo
yt i l ib a
b
orp
ISP has edge router with 200Mbps (1Mbps=10^6 bits per sec) and wants to provide each user with 2Mbps connection.

computer-networks probability

9.143 Pure_aloha: Let a cluster of stations share 48 Kbps of pure Aloha


channel. Every station outputs frames of length 1024 bits on an average of
every 50 seconds. Then what is the maximum value of number of stations?
top gateoverflow.in/5713

pure_aloha


Selected Answer

Since its pure aloha. So max Bandwidth utilization is 18% of 48Kbps.

And its given

Each station transmits 1024 bits ----> 50 seconds

(1024/50)bits-----> 1 second

Lets say there are N stations.

So N*(1024/50)=18% of 48*1000

N=Floor(421.875)

N=421

 1 votes -- sonu ( 1267 points)

9.144 Reference Book: Patterson Chap 2 Q 25 top gateoverflow.in/30957

25. Suppose you are designing a sliding window protocol for a 1-Mbps point-to-point link to the stationary satellite revolving
around the Earth at an altitude of 3 × 104 km. Assuming that each frame carries 1 KB of data, what is the minimum number

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1301 of 2244

of bits you need for the sequence number in the following cases? Assume the speed of light is 3 × 10 8 m/s. (a) RWS=1 (b)
RWS=SWS

reference-book computer-networks sliding-window

Official Solution =>

25. One-way latency of the link is 100 ms. (Bandwidth)× (roundtrip


delay) is about 125 pps × 0.2 sec, or 25 packets. SWS should be
this large.
(a) If RWS= 1 , the necessary sequence number space is 26.
Therefore, 5 bits are needed.
(b) If RWS= SWS, the sequence number space must cover twice
the SWS, or up to 50. Therefore, 6 bits are needed.

 2 votes -- Akash ( 26315 points)

9.145 Reference Book: Patterson Chap 1 Q 23 top gateoverflow.in/30927

23. Assume you wish to transfer an n B file along a path composed of


the source, destination, 7 point-to-point links, and 5 switches.
Suppose each link has a propagation delay of 2 ms and a
bandwidth of 4 Mbps, and that the switches support both circuit
and packet switching. Thus, you can either break the file up into
1-KB packets or set up a circuit through the switches and send
the file as one contiguous bitstream. Suppose that packets have
24 B of packet header information and 1000 B of payload,
store-and-forward packet processing at each switch incurs a
1-ms delay after the packet had been completely received,
packets may be sent continuously without waiting for
acknowledgments, and circuit setup requires a 1-KB message to
make one round trip on the path, incurring a 1-ms delay at each
switch after the message has been completely received. Assume
switches introduce no delay to data traversing a circuit. You may
also assume that filesize is a multiple of 1000 B.
(a) For what filesize n B is the total number of bytes sent across
the network less for circuits than for packets?
(b) For what filesize n B is the total latency incurred before the
entire file arrives at the destination less for circuits than for
packets?
(c) How sensitive are these results to the number of switches
along the path? To the bandwidth of the links? To the ratio of
packet size to packet header size?
(d) How accurate do you think this model of the relative merits
of circuits and packets is? Does it ignore important
considerations that discredit one or the other approach? If so,
what are they?

computer-networks reference-book

9.146 Reference Book: Patterson Chapt 1 Foudnation Q 13 top gateoverflow.in/30918

13. Suppose a 1-Gbps point-to-point link is being set up between the Earth and a new lunar colony. The distance from the moon to the Earth is
approximately 385,000 km, and data travels over the link at the speed of light—3 × 108 m/s.

(a) Calculate the minimum RTT for the link.

(b) Using the RTT as the delay, calculate the delay × bandwidth product for the link.

(c) What is the significance of the delay × bandwidth product


computed in (b)?
(d) A camera on the lunar base takes pictures of the Earth and

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1302 of 2244

saves them in digital format to disk. Suppose Mission Control


on Earth wishes to download the most current image, which
is 25 MB. What is the minimum amount of time that will
elapse between when the request for the data goes out and
the transfer is finished?

computer-networks reference-book

tp=385000*10^3/3*10^8=1.28 sec

1)RTT=2*1.28=2.56

2)bandwidth delay product=10^9*2.56=2560 Mbits

3)bandwidth delay product gives no of bits which can be sent in one rtt

4)2.56 10^9 bits

? 25MB

min time=25MB*2.56/10^9

=0.512 sec

 0 votes -- Pooja ( 22773 points)

9.147 Reference Book: Patterson Chap 1 Q 24 top gateoverflow.in/30926

24. Consider a network with a ring topology, link bandwidths of 100 Mbps, and propagation speed 2 × 108 m/s. What would
the circumference of the loop be to exactly contain one 1500-byte packet, assuming nodes do not introduce delay? What
would the circumference be if there was a node every 100 m, and each node introduced 10 bits of delay?

computer-networks reference-book

9.148 Reference Book: Patterson Chap 1 Q 16 top gateoverflow.in/30921

16. Calculate the latency (from first bit sent to last bit received) for
the following:
(a) 100-Mbps Ethernet with a single store-and-forward switch in
the path and a packet size of 12,000 bits. Assume that each
link introduces a propagation delay of 10 µs and that the
switch begins retransmitting immediately after it has finished
receiving the packet.
(b) Same as (a) but with three switches.
(c) Same as (a), but assume the switch implements “cutthrough” switching; it is able to begin retransmitting the
packet after the first 200 bits have been received.

computer-networks reference-book

1)transmission time=12000/100*10^6= 120 us

packer reaches at switch=120+10=130us

then from switch to destination=130

so total latency=260us

2)for 3 switches =130*4=520 us(as packet has to go over 4 links)

3)For “cut-through”, a switch needs to only decode the 200 bits before it begins to forward. This takes 2 us. This delay
replaces the switch transmit delays in the previous answer for a total delay of one transmit delay + 3 cut through
decoding delays + 4 propagation delays = 120+3*2+4*10=166 us

 1 votes -- Pooja ( 22773 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1303 of 2244

9.149 Reference Book: Patterson Chap 2 Q 24 top gateoverflow.in/30937

24. Suppose you are designing a sliding window protocol for a


1-Mbps point-to-point link to the moon, which has a one-way
latency of 1.25 seconds. Assuming that each frame carries 1 KB of
data, what is the minimum number of bits you need for the
sequence number?

computer-networks reference-book sliding-window

Bandwidth delay product=1.25*2*10^6

Size of sender window=1.25*2*10^6/8*10^3

=312.5(313 aprox)

In sliding window sws=rws

No of seq no=312.5*2=625

To represent 625 10 bits are required

 1 votes -- Pooja ( 22773 points)

9.150 Reference Book: Patterson Cha 1 Q 22 top gateoverflow.in/30925

22. Suppose that a certain communications protocol involves a


per-packet overhead of 50 bytes for headers and framing. We
send 1 million bytes of data using this protocol; however, one
data byte is corrupted and the entire packet containing it is thus
lost. Give the total number of overhead + loss bytes for packet
data sizes of 1000, 10,000, and 20,000 bytes. Which size is optimal?

computer-networks reference-book

9.151 Reference Book: Peterson Chap 1 Q5 top gateoverflow.in/30833

5. Consider a point-to-point link 4 km in length. At what bandwidth


would propagation delay (at a speed of 2 × 108m/s) equal transmit delay for 100-byte packets? What about 512-byte packets?

computer-networks reference-book

Propagation delay(pd) = d/v

Now it(pd) should be equal to L/B

so L/B = d/v

B = L*v/d = 100*8*2*10^8/4*1000 bits/sec = 4*10^7 bits/sec = 40 Mbps

For 512 byte packet size B = 40*512/100 Mbps = 204.8 Mbps

 0 votes -- Abhishek Kumar ( 71 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1304 of 2244

9.152 Reference Book: Patterson Chap 1 Q 19 top gateoverflow.in/30923

19. Calculate the delay × bandwidth product for the following links.
Use one-way delay, measured from first bit sent to first bit
received.
(a) 100-Mbps Ethernet with a delay of 10 µs.
(b) 100-Mbps Ethernet with a single store-and-forward switch
like that of Exercise 16(b), packet size of 12,000 bits, and 10 µs
per link propagation delay.
(c) 1.5-Mbps T1 link, with a transcontinental one-way delay of
50 ms.
(d) 1.5-Mbps T1 link between two groundstations
communicating via a satellite in geosynchronous orbit,
35,900 km high. The only delay is speed-of-light propagation
delay from Earth to the satellite and back.

computer-networks reference-book

9.153 Reference Book: Patterson Chap 1 Q 18 top gateoverflow.in/30922

18. Calculate the effective bandwidth for the following cases. For (a) and (b) assume there is a steady supply of data to send; for (c) simply
calculate the average over 12 hours. (a) 100-Mbps Ethernet through three store-and-forward switches as in Exercise 16(b). Switches can send
on one link while receiving on the other. (b) Same as (a) but with the sender having to wait for a 50-byte acknowledgment packet after sending
each 12,000-bit data packet. (c) Overnight (12-hour) shipment of 100 DVDs that hold 4.7 GB each.

computer-networks reference-book

9.154 Reference Book: Patterson Chap 1 Q 21 top gateoverflow.in/30924

21. Suppose a host has a 1-MB file that is to be sent to another host.
The file takes 1 second of CPU time to compress 50% or 2 seconds
to compress 60%.
(a) Calculate the bandwidth at which each compression option
takes the same total compression + transmission time.
(a) Explain why latency does not affect your answer.

computer-networks reference-book

9.155 Reference Book: Patterson Chap 1 Q 15 top gateoverflow.in/30920

15. For each of the following operations on a remote file server, discuss whether they are more likely to be delay sensitive or bandwidth sensitive: (a) Open a file.
(b) Read the contents of a file. (c) List the contents of a directory. (d) Display the attributes of a file.

computer-networks reference-book

9.156 Ring: What does it mean when the propagation delay is given in bits?
top gateoverflow.in/14345

Studying ring latency for Ring topology, there were few mentions of propagation delay in bits. While I have learned to
convert the time given in bits to seconds, what does the statement means when it says "the propagation delay of a
channel is 10 bits"?

I came to a conclusion that for a bit to propagate the whole channel and reach at the end of the channel there must be 10
bits in the channel. Or in short, the capacity of the channel is 10 bits.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1305 of 2244

Am I right? Please advice.

computer-networks ring


Selected Answer

As you must know, the propagation delay (measured in time units) doesn't depend on the channel bandwidth and is a characteristic of the transmission media
used. Given by tp= l./v , where "l" is the length of the cable and "v" is the velocity of signal in that media.

Coming to your question, if the propagation delay is given in bits, then not only the media but also the bandwidth or data rate of the channel has a role to play.

The propagation delay in bits is the amount of data(bits) transmitted by the sender (A) in time t p. You can observe that in this time, the first bit reaches

the receiver and simultaneously the last bit is transmitted by the sender. So in other words you can say propagation delay in bits is the no. of bits required to fill
up the channel. P.D.(bits)=tp(s)×bw(bps)

So saying it is the capacity of the channel maybe misleading to some extent as we can have same propagational delay in bits for different pairs of channel
bandwidth and media. Rather you can say it is the combined capacity of the channel+media.

But again in the specific cases such as Ethernet or Token ring where the media is more or less fixed (10base5 etc) you CAN say that it is the capacity of the
channel only.

Hope this does the job. :)

 3 votes -- devarshi ( 373 points)

9.157 Routers Bridge Hubs Switches: Peterson Davie 3.27 top gateoverflow.in/43611

Suppose a workstation has an I/O bus speed of 1 Gbps and memory bandwidth of 2 Gbps. Assuming DMA is used to move
data in and out of main memory, how many interfaces to 100-Mbps Ethernet links could a switch based on this workstation
handle?

peterson-davie routers-bridge-hubs-switches numerical-answers


Selected Answer

Some terms you should know before solving this question

Memory bandwidth is the rate at which data can be read from or stored into a semiconductor memory by a processor.

I/O buses connect the CPU to all other components, except RAM. Data are moved on the buses from one component to
another, and data from other components to the CPU and RAM. The I/O buses differ from the system bus in speed.

A bottleneck, in a communications context, is a point in the enterprise where the flow of data is impaired or stopped
entirely. Effectively, there isn't enough data handling capacity to handle the current volume of traffic.

Since I/O bus speed is less than Memory bandwidth,it is bottleneck.

Effective bandwidth that the I/O bus can provide is 1000/2 =500Mbps because each packet crosses the I/O bus twice.

Therefore, the number of interfaces is 500/100 = 5

 1 votes -- Nishant Arora ( 213 points)

9.158 Routing: Bandwidth top gateoverflow.in/34201

if delays are recorded as 8 Bit numbers in 50 router network and delay vector are exchanged twice a second how much
bandwidth per full duplex line is chewed by distributed routing algorithm. Assume each router has 3 lines to other routers
a)400 bps
b)800 bps
c)1200 now

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1306 of 2244

d) none

routing

A Network has 50 routers in which every router has a delay of 8bit .


Delay is actually a metric of router and has a proper field in routing table .
Hence total size of delay field is 50 * 8bits = 400bits
Also a router is connected to other routers which means it is a dedicated path , hence full utilization
of bandwidth will be there .

This field is updated twice a second onto each line .


Hence, 800 bps is needed in each direction (as it is full duplex)
for each line.

 0 votes -- Kapil Phulwani ( 51 points)

9.159 Routing: if delays are recorded as 8 bit numbers top gateoverflow.in/36373

if delays are recorded as 8 bit numbers in a 50 router network and delay vectors are excahngesd twice a second
how much bandwidth per(full duplex)line is chewed up by the distributed routing algorithm? assume that each
router has three lines to other routers.

a) 400 bps

b)800 bps

c)1200 bps

d)None of these

Answer is :- B

can any one provide explanation about this answer?

computer-networks routing

9.160 Routing Table: Routing Table top gateoverflow.in/41594

We know routing table looks something like this .


Network ID Subnet Mask Interface

Question : We go with larger subnet mask in case of two matches. !! Why ? I know that's fact and
called https://en.wikipedia.org/wiki/Longest_prefix_match !! What is already setup in the backend side so that we're
choosing one with the larger subnet mask??

2) I guess this question has some relation with the previous one.

If i have to divide a network in 5 unequal subnets. then which is the correct method ?

computer-networks routing routing-table ipv4 subnetting

I think we choose the subnet mask with longest match because it's more reliable in determining route to deliver packets
while routing.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1307 of 2244

As for the second part of the question, it would be given how many hosts you need to accommodate in each subnet.
Subnet mask can be adjusted accordingly to suit your needs.

Reference: https://learningnetwork.cisco.com/thread/64710

 0 votes -- Rukas ( 11 points)

9.161 Rsa: how to solve it how to calculate m & e?? top gateoverflow.in/11981

Using data p=3, q=11, n=pq, d=7 in RSA algorithm find the cipher text of the given plain text SUZANNE

(A) BUTAEEZ
(B) SUZANNE
(C) XYZABCD
(D) ABCDXYZ

computer-networks network-security rsa


Selected Answer

Answer will be (a)

explanation

Encryption RSA algorithm


Cipher text = ((plaintext)^e)mod n
From the given problem we know p =3,q = 11, d =7, n=33 find z :: z = ((p-1)*(q-1)) => 2*10 = 20
Find 'e' or 'd' using the given method : (de) mod z = 1
Therefore (7e)mod 20 = 1 => with trail and error giving e =3, => (7*3)mod 20 = 1
Finding e=3 we go to the encryption by converting the given plain text equivalent number starting a=1,b=2...z=26
Therefore SUZANNE = 19,21,26,1,14,14,5 taking single character and apply encryption
(19^3) mod 33 = 28 ie (28-26) = 2 => B
(21^3) mod 33 = 21 => U
(26^3)mod 33 = 20 => T
(1^3)mod 33 = 1 => A
(14^3)mod 33 = 5 =>E
(5^3)mod 33 = 26 => Z

 2 votes -- Rohan Ghosh ( 1515 points)

9.162 Rto: Calculating RTO timer top gateoverflow.in/36454

How to calculate RTO value

Given:

Initial RTT 20ms

next round trip 40ms

aplpha is 0.5

computer-networks rto

effective RTT=alpha* initial RTT + (1-alpha)*new RTT

=0.5*20+0.5*40

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1308 of 2244

=10+20=30ms

 0 votes -- bhawanagupta15 ( 349 points)

9.163 Serial Communication: ISRO-2013-19 top gateoverflow.in/43817

What is the maximum number of characters (7 bits + parity) that can be transmitted in a second on a 19.2 Kbps line. This
asynchronous transmission requires 1 start bit and 1 stop bit.

A. 192
B. 240
C. 1920
D. 1966

isro2013 serial-communication


Selected Answer

bandwidth is 19.2Kbps

I think

19.2*10^3 bits -is transfer per second

19200 bit is transfer per second

Now they say 1 character is made 7 bits + 1 parity = 8 bits

Since it is asynchronous whenver you are sending it would require 1 start and stop bit

So 10 bit now is required to send 1 character

Number of character that can be send is 19200/10 = 1920 character

 1 votes -- Dexter ( 1933 points)

9.164 Sliding Window: from swp top gateoverflow.in/42608

in what protocol or protocols, it is possible for the sender to receive an ack for a packet that falls outside of its
current window

a. stop and wait b. selective repeat c.gbn d. all of the above

computer-networks sliding-window

Ans is d

this is the concept of delayed ack which can occur in any of the protocol

 0 votes -- Manojk ( 3365 points)

9.165 Sliding Window: Calculating maximum throughput for given window


size top gateoverflow.in/36044

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1309 of 2244

Given solution of the problem:

I was thinking of using this formula, η = 1 +2a for this question. What is wrong in using it. Please explain

computer-networks sliding-window


Selected Answer

You can solve this problem using η=N/1+2a also as follows


Transmission time= Frame length/Bandwidth = (512*8)/1024000 = 4msec (as 1Kb data must be taken as 1024 bits) ;
Propagation delay = 40msec (given) ;
a= 40/4= 10msec
N= 7
efficiency =N/(1+2a) = 7/(1+20) =0.33
Throughput=efficiency*bandwidth = 0.33*1024000 = 341.33 Kbps
In the solution you have pasted
they have used the formula as
Efficiency = Amount of data sent/Amount of data that could be sent Efficiency = Amount of data sent / (RTT * Bandwidth)
Throughput=Efficiency *Bandwidth ...as bandwidth is both in numerator and denominator both cancels out

 1 votes -- sarvani videla ( 125 points)

9.166 Sliding Window: In SWP if first packet is transmitted on link, will it


wait for window size to fill completely or start propagating? top gateoverflow.in/33376

In SWP, if windows size of the sender is 5, transmission delay is 15ms and propagation delay is 25ms.

So,if first packet is transmitted on link, will it wait for the windows size to fill completely or it will start propagating?

I think it will start propagating, because its independent of propagation delay?!

computer-networks sliding-window


Selected Answer

Yes, it will start propagating as soon as it is available. SWP means we cannot send more packets than the size of window.

 2 votes -- Monanshi Jain ( 5827 points)

9.167 Sliding Window: What is the effect on line utilization, if we increase


the number of frames for a constant message size? top gateoverflow.in/32384

a) lower line efficiency

b) higher line efficiency

c) no change in line efficiency

d) no relation between line efficiency and frame size

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1310 of 2244

computer-networks sliding-window

No change in line efficiency.

Line efficiency will increase , only when we have some hops between sender and receiver.

For this question we will consider that there is no hop between sender and receiver so , dividing a constant message in k
frames or increase the number of frames to ( k+i),will not effect link utilization.

 1 votes -- Savir husen khan ( 121 points)

9.168 Sliding Window: Sliding window top gateoverflow.in/33566

consider sliding window algorithm with Ws =9 and Wr=7 and no out of order arrivals .what is smallest value of Max
sequence number?
a) 7 b)15 c)8 d )16

sliding-window

seq no = Ws + Wr = 16.

now seq no starts from 0.so 0 to 15..total 16.

so max seq no = 15

 1 votes -- Sayantan Ganguly ( 5061 points)

9.169 Sliding Window: point to point link to the moon top gateoverflow.in/30750

Suppose you are designing the sliding window protocol for a 1 Mbps point to point link to the moon, which has one way
latency(delay) of 1.25 seconds. assuming that each frame carries 1 KB of data, What is minimum number of bits you need
for sequence number?

computer-networks sliding-window

window size(w)=(bandwidth*two way propagation delay)/frame size

so here w=(10^6*2*1.25)/(1*1024*8)

=305

by default sliding window means go_back n ARQ

so here 2^n-1=305

n=9 bits

 0 votes -- pritika kundu ( 677 points)

9.170 Sliding Window: If RTT=100micro sec,bandwidth=10mbps,throughput


in sliding window protocol for a window size of 100 bits is _______mbps? top
gateoverflow.in/15759

What should be the throughput in sliding window protocol for a window size of 100 bits in terms of mbps is?.If RTT is equal to
100microsec and bandwidth is 10mbps

computer-networks sliding-window

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1311 of 2244


Selected Answer

Efficiency = Amount of data sent/Amount of data that could be sent

= 100 / (RTT * Bandwidth)

= 100/(100 * 10)

= 0.1

Throughput = Efficiency * Bandwidth = 0.1 * 10Mbps = 1 Mbps

 1 votes -- Arjun Suresh ( 124125 points)

9.171 Sliding Window: Which utilization formula to use and why? top gateoverflow.in/18765

Consider sliding window protocol for a 10 MBps point to point link with propagation delay of 2 sec. If frame size is of 4kB
then what wil be the minimum number of bits number required for the sequence number?

Which approach to take and why? Notice the difference in frame numbers, why does this arise and which one is correct. The
answer is not affected in this question.

computer-networks sliding-window


Selected Answer

Question is incomplete- I suppose we want to maximize the "utilization".

Now, if you blindly follow the formula you will always have confusion. If we imagine the actual scenario- its all very easy.
For maximum utilization, the sender must send frames continuously until the ACK of first packet send comes back. This
time for arrival of ACK is called RTT.

RTT = Propagation time for frame (time for the first bit of frame to reach destination) + Time for frame to transmit (Time
difference between first and last bit of frame to reach destination) + Propagation time for ACK + Transmission time for
ACK.

= 2s + 4kB/10MBps + 2s + 0 (ACK being small)

= 2s + .0004 + 2s = 4000.4 ms.

Now, no, of bytes that could be sent during this time = 10MBps * 4000.4ms = 40004 KB = 10001 frames.

Now, for sending 10001 frames we need lg10001 = 15 bits for the sequence number field.

 0 votes -- Arjun Suresh ( 124125 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1312 of 2244

9.172 Sliding Window: Sliding window protocol top gateoverflow.in/25722

Consider three nodes A, B, C connected in series. Node A is connected to Node B via 3Gbps link, 500km length. The links are full
duplex, but no other traffic on the links. A large file is to be sent from node A to node C. Packets are 1024bytes.Assume
velocity of propagation as 2 × 108 m/sec.

Q1). What is the round trip time?

(a). 5.23m sec (b). 7.24m sec

(c). 1.28m sec (d). 8.98m sec

Q2). Suppose an end to end sliding window protocol is used what is the optimal value of sender’s window

(a). 28 (b). 38

(c). 54 (d). 72

sliding-window

for 1 I got 5.15 ms

 1 votes -- akash ( 735 points)

9.173 Sliding Window: Sliding window size? top gateoverflow.in/7538

In sliding window protocol, assume a 3-bit sequence number field. A and B have windows, which has 3-bit sequence number.
If A sends 3 frames and waits for all the 3 acknowledgments until the timer expires. Which of the following "could not be"
the sender's "window size" after the timer expires. Assume receiver receives all the three frames correctly. But ACK's send
by receivers may be lost.

a. 4

b. 7

c. 6

d. 5

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1313 of 2244

answer is given as 4.

sliding-window computer-networks

With 3 bit we will have 2^3 sequence number =8(0-7)

I think its a hint A sends 3 frame and wait for all frame means it using Selective Repeat protocol coz it doesn't support
Cumulative ACK it support individual ACK for each frame which is lost or NAK if no frame is lost.

So in Selective repeat protocol Max SWS = Max sequence number +1/2= 7+1/2 = 4

Here ACK is lost so after time expires it again sends 3 frame since in first attempt he sent 3 frame and it was expecting for
ACK but didn't get!

So Sender Window Size couldn't be = 4

 0 votes -- Umang Raman ( 10379 points)

9.174 Sliding Window: Sliding window top gateoverflow.in/30870

When full duplex link is given then

Rtt=2*pt or pt

sliding-window

9.175 Sliding Window: Sliding window top gateoverflow.in/30871

When full duplex link is given then

Rtt=2*pt or pt

sliding-window

As the Name suggest RTT = Round Trip Time means Total time to travel one round(from sender to the Receiver and again
Receiver to the Sender). So it doesn't depend on either the link is Simplex or full duplex. It will be always 2*Propagation
delay

 0 votes -- Abhishek Kumar ( 71 points)

9.176 Sliding Window: window size in sliding window protocol top gateoverflow.in/19905

A 50kbps satellite channel with 550ms round trip propagation delay using sliding window protocol sends 2000 bits frame then
window size, w will be:

w >= 7.75bits

w >= 14.5bits

w >= 15.5bits

w >= 20.5bits

computer-networks sliding-window

My Answer is

Given RTT Propagation delay=550ms

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1314 of 2244

i.e 2*Propagation delay=550


L=2000 bits
B=50kbps
Transmission time=2000/50 =40ms
Window size=1+2a
=1+(550/40)
=1+13.75=14.75
So window size >=14.75

 0 votes -- shivanisrivarshini ( 2067 points)

9.177 Sliding Window: RTT top gateoverflow.in/30319

A) What is Round Trip Time ?

B) Explain R.T.T. clearly for Stop n Wait , Go-Back-N , Selective Repeat ARQ .

sliding-window computer-networks

9.178 Slotted_aloha: Aloha top gateoverflow.in/20135

Consider a slotted aloha channel with bandwidth 5Mbps. if frame size is equal to 10 user slots then what is effective data
rate of a user if every 2nd slot is occupied by him?(Assume data if required)

slotted_aloha

9.179 Slotted_aloha: Aloha top gateoverflow.in/34586

You have two computers, A and B, sharing a wireless network in your room. The network runs the slotted Aloha protocol with
equal-sized packets. You want B to get twice the throughout over the wireless network as A whenever both nodes are
backlogged. You configure A to send packets with probability p. What should you set the transmission probability of B to, in
order to achieve your throughout goal?

a. p/(1 + p)
b. p/(1 + 2p)
c. 2p/(1 + p)
d. 1/2

slotted_aloha

Option C is correct.

slotted Aloha - Time is divided in slots, so, either A or B transmits only at beginning of a slot.

Given, A's probability to transmit = p

Let B's probability to transmit = x

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1315 of 2244

So, probability of unsuccessful transmission = probability that both A & B transmit = x * p

probability of successful transmission by A = P(A) - P(A∩B) = p - xp

probability of successful transmission by B = P(B) - P(A ∩B) = x - xp

Now, since B should have twice the throughput of A, this gives

x - xp = 2* (p - xp)

=> x + xp = 2p

=> x= 2p/ (1+p) Option C (Ans).

 4 votes -- Himanshu Agarwal ( 8861 points)

9.180 Stop And Wait: Calculating link utilization in stop and wait protocol top
gateoverflow.in/37229

Given solution:


1 1

η = 1 +2a = 1 +8.23 = .10834

Why this method is giving different result?

Please explain.

stop-and-wait sliding-window

Take upto 4 places of decimal or approximate to 8.24 its giving right answer...

1/(1 + 8.2397)=0.12136

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1316 of 2244

 0 votes -- Abhishekcs10 ( 1001 points)

9.181 Stop And Wait: Average transmission rate top gateoverflow.in/27469

Please help me to solve problem 8.

computer-networks stop-and-wait made-easy


Selected Answer

106 bits ↔ 1sec


100
106
100bits ↔ = 0.1ms

0.1ms is the transmission time

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1317 of 2244

TT
TT + 2PT
η=
0.1ms
= 0.1ms + 2 × 1sec
0.1ms
= 0.1ms + 2 × 1000ms
= 4.99975 × 10 −5

answer for Q.9 = η and if that's the efficiency then the actual bandwidth that was utilized is η × C

Hence, answer = option B

 1 votes -- Amar Vashishth ( 17865 points)

In Stop and Wait we can transmit only one packet in 1 RTT.

As the name suggests, after sending 1 packet, Stop & Wait protocol stops & waits until the ACK is received or a time out
occurs.

So we can transmit 1 packet or 100 bits in 1 RTT.

That is transmission rate is 100 bits per RTT, or 100 bits per 2 second.

So Transmission rate = 50 bps.

Now link utilization = Current transmission rate / rate at which we could have transmit the data using the full capacity of
the link (or channel)

so link utilization = 50 bps / 100,000 bps = 0.0005

We can see here Stop & Wait can be astoundingly inefficient, hence we need sliding window protocols.

Choosing appropriate windows size in sliding window protocol leads to quite higher link utilizations.

 2 votes -- Anurag Pandey ( 8183 points)

9.182 Stop And Wait: in swp ,sender utilization top gateoverflow.in/42677

If the packet size is 1KB and propagation time is 15ms, the channel capacity is 109 b/s then find the transmission time and
utilization of sender in stop and wait protocol.

stop-and-wait


Selected Answer

Packet Size = 1KB, Bandwidth = 109 bps, Propagation Time = 15 ms


Packet Size 1 KB 1024×8
Bandwidth 109 bps 9
Transmission Time = = = 10 bps ≈ 0.008 ms.

Sender Utilization = Fraction of Time Sender is busy (Same as link utilization which is the fraction of time the link is
carrying useful data)

In Stop-and-wait, sender can retransmit only when ACK arrives for the send data which requires 1 transmission time for
the data packet, 1 propagation delay for the data packet to reach the receiver, 1 propagation delay for the ACK to reach
the sender. (ACK normally being small its transmission time can be ignored unless given in question). So,
Transmission Time 0.008 0.001

Utilization = Transmission Time +2 ×Propagation Time = 0.008+2 ×15 = 30.008 = 0.000266 = 0.026%.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1318 of 2244

 5 votes -- Digvijay Pandey ( 26245 points)

Here in the given L= 1* 1024 * 8 bits, Tp =15ms= 15000 micro sec

channel capacity = BW (units in b/s) so,BW= 10^9 b/s

Now,Tt = L/B =1*1024*8 / 10^9 =8.1 micro sec

Utilisation is 1 / 1+2a where a is Tp/Tt

1+2a= 3704.7 , 1 / 1+2a =1 / 3704.7 = 0.02%

 2 votes -- Prabhanjan R ( 747 points)

9.183 Stop And Wait: Transmission rate in a 3 node 2 link sliding window
system top gateoverflow.in/18636

The distance between A to B is 4000 km. The distance between B and C is 1000 km.The propogation delay is 5 micro sec/
km for both the links. The data rate between A and B is 100kbps. Both the links are full duplex. All data frames are 1000 bits
long and ACK frames are negligible. Window size is 4.

What is the required transmission rate (in kbps) between B and C so that buffers of node B are not flooded?

A. 100

B.150

C.200

D.250

computer-networks stop-and-wait sliding-window linear-algebra

In order to ensure no flooding, data transfer rate between B-C must be same (or greater) as that between A-B.

Lets consider the no. of bits transmitted by A until it receives ACK and let time for this be S.

S = 2* Propagation delay + Transmission delay for packet + Transmission delay for ACK

= 2*20 ms + 10 ms + 0

= 50ms.

Window size is 4.

So, in 50ms, A could send up to 4 packets = 4000 bits. Data rate being 100 kbps, allows upto 100 *50 = 5000 bits in
50ms, so we are fine and we have effective data rate of 4kb/50ms = 80kbps.

Now, we know that in every 50ms, we are getting 4000 bits at B. (with a buffer of size 4000 bits we can assume no
flooding for this)

Lets consider the no. of bits transmitted by B until it receives ACK and let time for this be T.

T = 2* Propagation delay + Transmission delay for packet + Transmission delay for ACK

= 2 * 5ms + 1000/x ms, where x is the data rate in kbps

In T ms, B sends 1000 bits. We want B to send at 80kbps which implies T = 1000/80 = 12.5ms

So, 12.5 = 10 + 1000/x

x = 1000/2.5 = 400 kbps.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1319 of 2244

 1 votes -- Arjun Suresh ( 124125 points)

9.184 Stop And Wait: ISRO-2013-41 top gateoverflow.in/43981

What will be the efficiency of a Stop and Wait protocol, if the transmission time for a frame is 20ns and the propagation time
is 30ns?

A. 20%
B. 25%
C. 40%
D. 66%

isro2013 computer-networks stop-and-wait

Efficiency in Stop and Wait Protocol is given by

Efficiency = T,transmission / (T,transmission + 2* T,propagation)

Efficiency= 20 / (20+2*30)

= 20/80 =0.25

For percentage = 0.25 * 100 =25% Option (B) is correct

 0 votes -- Ashwani Kumar ( 83 points)

9.185 Stop And Wait: Stop and Wait top gateoverflow.in/39063

Bandwidth of a link is 1000 Mbps and round trip time is given as 250 μ sec. If frame size is 500 bits, the utilization (in percentage) of channel when STOP and WAIT ARQ is used is _______.

stop-and-wait made-easy


Selected Answer

Efficiency = Useful Time / Total Time = TT / RTT


TT = 500b/ 1000Mb = 0.5 μs
RTT = 250μs
Efficiency = 0.5/250 = 0.5/250 = 0.002
Efficiency (in %) = 00.2 %

 2 votes -- Digvijay Pandey ( 26245 points)

9.186 Stop And Wait: Efficiency of Stop n Wait protocol top gateoverflow.in/17750

What will happen if Ttrans> (Ttrans+2*Tprop) in efficiency formula of stop n wait protocol? What it logically mean?

stop-and-wait


Selected Answer

this is not possible , you are saying like this A>A+B (A and B are positive number )

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1320 of 2244

Anyway in stop and wait you have to wait for acknowledge . (even if Tx>2Tp) if Tp is negligible then only efficiency is
going to be 1 .

 2 votes -- Pranay Datta ( 6113 points)

It means you are transmitting through a balck hole where time is moving backward . so that at the other point of time you
got the same packet till at one point you are still transffering it . ASTROPHYSICS. " time is relative" it is definitely
possible Theoretically. my personal opinion is that time cannot run backwards. it can squeeze or slow down.

 2 votes -- Ravi Singh ( 7303 points)

9.187 Stop And Wait: CN stop and wait bandwidth is 1.5 Mbps top gateoverflow.in/30743

If the bandwidth f the line is 1.5 Mbps, RTT is 45ms and packet size is 1KB, then find link utilization stop and wait protocol.

stop-and-wait computer-networks

--> Utilization = transmission time / ( transmission time + RTT )

--> Transmission time = Length of packet / Bandwidth

= 1KB / 1.5 Mbps = 1*10^(3)*8 / 1.5*10^(6) = 5.33 msec.

--> Utilization = 5.33 / (5.33 + 45) = 0.1059 = 10.59% . [ Rtt = 45 msec(given) ]

 0 votes -- Vinay Yadav ( 1739 points)

9.187 Subnetting: If a organisation requires 30 hosts.which is the best


possible mask that can be used? top gateoverflow.in/129

subnetting computer-networks


Selected Answer

Since organistation has 30 hosts, Class C network with /24 Prefix should be used since it can support 254 hosts.

Now there are 30 hosts, so the minimum number of bits required for host number is 5, since 25 − 2 is 30.

The rest of bits i.e 3 can be used as subnet number.

So the mask is 11111111.11111111.11111111.11100000

For reference have a look at http://andthatsjazz.org/wbglinks/pages/reads/misc/ip.html

 6 votes -- Omesh Pandita ( 2209 points)

9.188 Subnetting: A company is granted the site address 181.55.0.0. the


company needs 1000 subnets top gateoverflow.in/12913

i) What is the DBA of the last subnet?

ii) what is address of 4th last host of 2nd last subnet in the company ?

subnetting

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1321 of 2244

1) here total no of subnet is 1024 , so total bit in subnet =10

IP is 181.55.0.0 so its a class B , means 16 bit for host id part .

but here so last subnet would be: 181.55.11111111.11000000

but in qustn last subnet is 1000 so we have to subtract 24:11000

so last subnet is :181.55.11111001.11000000

directed broadcast of last subnet(all host bit 1): 181.55.11111001.11111111=181.55.249.255

2) our last subnet is 181.55.11111001.11XXXXXX,

so 2nd last would be: 181.55.11111001.10 XXXXXX

4th host of 2nd last subnet: 181.55.11111001.10111111

181.55.249.191

 0 votes -- Pyuri sahu ( 1237 points)

9.189 Subnetting: An organization is granted the block 150.36.0.0/16.The


administrator wants to create 512 subnets. top gateoverflow.in/17556

An organization is granted the block 150.36.0.0/16.The administrator wants to create 512 subnets.

Find number of addresses in each subnet. Find the first and last addresses in subnet 1.
(A) 128, 150.36.0.1 and 150.36.0.127 (B) 128, 150.36.0.129 and 150.36.0.255
(C) 126, 150.36.0.1 and 150.36.0.126 (D) 126, 150.36.0.129 and 150.36.0.254.

subnetting

Ans - c

512 subnets => 9 bits from host id are reserved. Therefore, 150.36.NNNNNNNN.NHHHHHHH is our scenario. There the
first network id is : 150.36.00000000.00000000 => 150.36.0.0 and the first usable IP address is 150.36.0.1 The
broadcast address of this subnet will be 150.36.0.127 => The last usable IP address of first subnet will be : 150.36.0.126

 1 votes -- CrimeMasterGoGo ( 2221 points)

9.190 Subnetting: Cidr top gateoverflow.in/33429

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1322 of 2244

subnetting

Given an IP address of block: 210.69.92.39/26


so we are left with 6 bits for host id,whose 1st address is all six 0s and last address is all six ones.

so in one subnet maximum 2^6 = 64 addresses are possible.

now i am writing the blocks of addresses as per subnet.

1st block -- 210.69.92.0 to 210.69.92.63 (the address given in the qs is resides in this block)

2nd block-- 210.69.92.64 to 210.69.92.127

3rd block-- 210.69.92.128 to 210.69.92.191

4th and last block-- 210.69.92.192 to 210.69.92.255

so 2nd last block is 3rd block.. and the last host is which usable 210.69.92.190 /26.

so answer is A

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1323 of 2244

 1 votes -- Sayantan Ganguly ( 5061 points)

9.191 Subnetting: Finding directed broadcasting address for network. gateoverflow.in/34308

top

If pic is not clear: Data:

Dept1 (with X link) has 287 hosts. Dept2 (with Y link) has 510 hosts. Dept3 (with Z link) has 254 hosts.

Qstn: If above network uses class C network 192.203.16.0 then find DBA for dept Y. (Assume all are in the same network.)

How can this be done? Dept2 has 510 hosts , so 9 bits needed. But as it is a Class C IP, can you get my confusion? Kindly
help me clarify it. How to even proceed for this qstn?

EDIT: Here's the explanation pic

subnetting computer-networks


Selected Answer

First of all this question is wrong. This complete network can not be configured with single class C network. !

Yes, Y can not be configured because 510 > 254 (Maximum hosts configurable in any class C) !

Directed Broadcast Id => Network ID followed by all 1's in Host ID part .

So none of option is correct !

 1 votes -- Akash ( 26315 points)

9.192 Subnetting: CN: Subnetting top gateoverflow.in/33994

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1324 of 2244

Two computers A and B are configured as follows. A has IP address 203.197.17.157 and netmask
255.255.128.0. B has IP address 203.192.192.201 and netmask 255.255.192.0. Which one of the following
statements is true?

A. A and B both assume they are on same network.

B. B assumes A is on same network but A assumes B is on a different network.

C. A assumes B is on same network, B assumes A is on a different network.

D. A and B both assume they are on different networks.

computer-networks subnetting

--> IP of A AND Netmask of A = 203.197.17.157 AND 255.255.128.0

= 203.197.0.0

--> IP of A AND Netmask of B = 203.197.17.157 AND 255.255.192.0

= 203.197.0.0

--> As, both AND operation gives similar result . So, A assume B on same Network .

--> IP of B AND Netmak of B = 203.192.192.201 AND 255.255.128.0

= 203.192.128.0

--> IP of B AND Netmask of A = 203.192.192.201 AND 255.255.192.0

= 203.192.192.0

--> As,both AND operation gives different result . So, B assume A is on different network.

--> Answer (c) option.

 2 votes -- Vinay Yadav ( 1739 points)

9.193 Subnetting: number of subnets top gateoverflow.in/17670

In class C , if subnet mask is 255.255.255.224 then calculates number of subnet? (A) 6 (B) 8 (C) 4 (D) None of the Above

subnetting

The default mask for the class C address of 192.x.x.x is 255.255.255.0 The mask in the example is 255.255.255.224 (using 3
extra bits for subnetting, above and beyond the default). So 2^3 is 8 combinations:

000 001 010 011 100 101 110 111

In the old days, we couldn't use the all 000 or all 111 combination for subnetting, so the formula was 2^extra
bits used for custom subnetting, or 2^3 in our example, -2 (for the 2 that used to not be able to be used),
which would leave 6.

Today, current IOS&Cisco has the ability to use the 000 and 111 option with an option called subnet zero and so on
current IOS there would be 8 possible subnets, not just 6.

 1 votes -- Mahesh Kumar ( 153 points)

9.194 Subnetting: Cidr top gateoverflow.in/31221

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1325 of 2244

An internet service provider (ISP) has the following chunk of IP address available with it: 192.248.128.0/22. The ISP wants
to give half of this chunk to organization A and one fourth of remaining half to organization B and organization C then what
is the valid allocation of address to A, B and C?
(A) 192.248.128./23, 192.248.128.0/23, 192.24S.128.0/25
(B) 192.248.128.0/23, 192.248.128.0/25, 192.248.128.0/25
(C) 192.248.128.0/22, 192.248.128.0/23, 192.248.128.0/24
(D) None
http://gateoverflow.in/?qa=blob&qa_blobid=12308793692587589147

computer-networks subnetting

192.248.128.0/22
Total host possible = 32 - 22 = 10 = > 2^10 = 1024

so half of chunk to A means 512 host = 2^9 = 232−23

i.e. 192.248.128.0/23 or 192.248.130.0/23

now one fourth of rmaining half to B and C


means 128 host to each = 2^9 = $2^{32-25}

i.e B 192.248.130.0/25 or 192.248.128.0/25


C 192.248.130.128/25 or 192.248.128.128/25

Here no matching combination in options


So option D.

 1 votes -- Umang Raman ( 10379 points)

9.195 Subnetting: ISRO-2013-43 top gateoverflow.in/43984

What is IP class and number of sub-networks if the subnet mask is 255.224.0.0?

A. Class A, 3
B. Class A, 8
C. Class B, 3
D. Class B, 32

isro2013 computer-networks subnetting

Subnet mask is 11111111.11100000.00000000.00000000

here 8 bit for network ( all 8 ones )

And 8 bit for network id belong to class A

And next 3 ones used for subnet . Since 3 ones so number of subnet is 2^3=8.

So answer is b

 0 votes -- Dexter ( 1933 points)

9.196 Tcp: Find wrap around time top gateoverflow.in/20900

Consider 100 mbps network with 24 bit sequence number field find the wrap around time for sequence no?

tcp

sequence possible=2^24.

wraparound time=(2^24)/100Mbps

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1326 of 2244

 0 votes -- asutosh kumar Biswal ( 215 points)

9.197 Tcp: An ACK number in TCP always means that top gateoverflow.in/32817

An ACK number of 1000 in TCP always means that

(a) 999 bytes have been successfully received

(b) 1000 bytes have been successfully received

(c) 1001 bytes have been successfully received

(d) None of the above

computer-networks tcp

Answer is D none of the above.cause, The client sets the segment's sequence number to a " random value".then ,the server replies with a ACK. The
acknowledgment number is set to one more than the received sequence number + 1.

REF: https://en.wikipedia.org/wiki/Transmission_Control_Protocol ,go through the connection establishment part.

 0 votes -- Sayantan Ganguly ( 5061 points)

9.198 Tcp: TCP top gateoverflow.in/32878

You are hired to design a reliable byte stream protocol that uses a sliding window protocol like TCP .The protocol
will run over 1Gbps n/w. the RTT is 140 ns and maximum segment lifetime (MSL)is 60sec.

How many bits would you require in the Advertise window field of TCP header to keep pipe full??

computer-networks tcp


q1) Max. amount of data that can be send by the sender = 140 ns * 1 Gbps = 140 b = 140/8 B
No. of bits needed to represent 140/8 B of data < = No. of bits needed to represent 2^8/2^3 B of data
No. of bits needed to represent 140/8 B of data is at most 5 bits.
Advertised window field needs 5 bit so that it can send 140/8 B of data to keep the pipe full.

q2) Data send in MSL = 1Gbps * 60 sec = 60 Gb = 60/8 GB


Max. no. of bits in sequence no. field of TCP header to prevent wrap around of data = log(base 2) (60 * 10^9/8) = 33 bits

 1 votes -- zambus ( 159 points)

9.199 Tcp: The order of packets top gateoverflow.in/36085

Five segments of data of sizes 100B , 400B , 200B , 300B and 50B are sent using TCP and PSH bit is set on each of the segments. There are no
retransmission timeouts. The acks received are 101,101, 701,701, and 1051. In which order are the segments received

tcp

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1327 of 2244

let sequence number starts from 1.


1st Ack is 101 that means Packet 100B received correctly.
Next ACK is 101 that means 400B delayed and receiver send one more ACK saying only 101 is received at receiver till
now.
Next ACK is 701 that means from 1 to 700B received at receiver. i.e. Any sequence of 400B and 300B . ( why any
sequence bcoz it may possible that 400B arrived first & receiver sent an ACK but that ACK was lost and after that 300B
received at receiver & next ACK i.e. 701 reaches sender's end correctly.
2nd possibility is 300B arrived 1st then Receiver will send ACK 101 only bcoz 400B is still not arrived ..)

same for last two packets.

PS : if no ACK was lost then sequence will be 100B ----> 300B ----> 400B -----> 50B----> 300B

 0 votes -- Digvijay Pandey ( 26245 points)

9.200 Tcp: Tcp top gateoverflow.in/34877

what is timed wait state in tcp

tcp

9.201 Tcp: Acknowledgement in tcp top gateoverflow.in/32936

In TCP while connection establishment there is pure acknowledgement. I have read that the pure acknowledgements do not
consume a sequence number as the receiver does not include acknowledgement while merging the segments. The data is
extracted and sequenced according to sequence number.

But then what goes into the sequence number field while sending the pure ack. It has to be a number anyways...but what is
the number kept and why...??

tcp computer-networks

as you know TCP have three phase-:

1.connection establishment

2.data transfer

3.connection termination

1.connection establishment-

during REPLY ACK field is used for valid acknowledgement..

but in DATA TRANSFER phase there is a field in TCP header acknowledgement number (NOT GET CONFUSE WITH ACK
FLAG)

which contains sequence number of the segment expecting next.

 0 votes -- sourav anand ( 1585 points)

9.202 Tcp: Size of senders window ? top gateoverflow.in/39167


Consider a TCP connection using the slow start congestion control scheme with an initial threshold value of 64 kB and a Maximum Segment Size (MSS) of 2 kB. The receiver’s advertised
window is initially 32 kB. The first transmission attempt is numbered 0, and all transmission attempts are successful except for the timeouts on attempt number 4. Which of the following
represents size of sender’s congestion window at attempt number 10?

tcp computer-networks

The answer should be 20Kb

Attempt number Window Size

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1328 of 2244

0 1

1 2

2 4

3 8

4 16 ( slow start threshold set to 8 )

5 1

6 2

7 4

8 8 ( slow start ends)

9 9 (linear increase starts)

10 10

10MSS = 20Kb

 0 votes -- nikhil1008 ( 243 points)

9.203 Tcp: Find the size of Sender's window if: top gateoverflow.in/32145

During a TCP connection, the size of the window advertised by the receiver is 20 KB. The last byte sent by the sender is
20480 and the last byte acknowledged by the receiver is 8384. If the current congestion window is 18 KB, then the current
size of the sender's window is _______ (in KB).

computer-networks tcp


Selected Answer

in TCP congestion window changes dynamically depending on congestion window , advertised window by receiver ,
amount data unacknowledged .

Reason :

window size : amount of data we can transmit before acknowledgement received.

in sliding window protocol , until acknowledgment received, copy of transmitted data kept in buffer.

window size= min (congestion window , advertised window) = 18 KB

size of unacknowledged data =20480-8384 =12096 bytes = 11.8 KB

as this 11.8 KB is not acknowledged till now, this data is present in buffer , so (effective window size ) the amount of data
that is possible to transmit before acknowledgement received is

current active window size = 18 KB - 11.8 KB = 6.2 KB

 3 votes -- pramod ( 2071 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1329 of 2244

9.204 Tcp: TCP connection top gateoverflow.in/3863

Suppose a client C repeatedly connects via TCP to a given port on a server S, and that each time it is C that initiates the
close. If time-wait state lasts for 60 seconds, then how many TCP connections a second can 'C' make with all available
ports? Assume client port are in the range of 1024 to 5119.

A) 70 per sec B)10 per sec C) 13 per sec D) 100 per sec

computer-networks tcp


Selected Answer

No. of available ports = 5119 - 1024 + 1 = 4096

Due to time-wait state of 60s, any repeated connection to same port requires an interval of at least 60s.

Now assume a time interval of Ns. Number of TCP connections possible in this time = 4096*N/60 (as after every 60s, a
port can be reused for a new connection).

So, average number of connections that can be opened per second = 4096*N/(60 * N) = 4096/60 ≈ 70

http://www.isi.edu/touch/pubs/infocomm99/infocomm99-web/

 4 votes -- Arjun Suresh ( 124125 points)

9.205 Tcp: An Acknowledgement by TCP at sender guarantees? top gateoverflow.in/27825

1.Data has been delivered to the application.


2.Date has been received by TCP module.
3.Data has been received by the Application interface.
4.None

What should be the answer?? I think 1st and 3rd are correct?!

computer-networks tcp

It means that data has been delivered to the application.


So option 1 is correct.

 0 votes -- Monanshi Jain ( 5827 points)

9.206 Tcp: TCP & UDP top gateoverflow.in/34387

computer-networks tcp


Selected Answer

2 and 3 are correct.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1330 of 2244

TCP and UDP both provides error control (although UDP uses only Checksum) and multiplexing.

 3 votes -- Monanshi Jain ( 5827 points)

9.207 Throughput: Calculating throughput for slotted ALOHA top gateoverflow.in/37893

Consider a system generating 20 bit frames and connected through a shared 20kbps channel. Find throughput in percent if slotted ALOHA is
used and frame rate is 1000 fps.

computer-networks slotted_aloha throughput

Frame size = L = 20 bits


Rate = R = 20kbps
Transmission time,T = L/R = 1 * 10-3 s
Throughput, S = G e-G, where G= Number of frames per T
So, G = 1000 * 10-3 = 1
Therefore, S = e-1 = 0.368 = 36.8%

 0 votes -- prathams ( 1141 points)

9.208 Token Ring: Computer Networks, Token Ring top gateoverflow.in/15608

Tp
Tt
In a token ring, if a < 1, i.e < 1 , then will not the data get corrupted because it will come in contact with the data that is
still being transmitted ?

token-ring computer-networks


Selected Answer

yes . it will corrupt the data thats why if we want to apply such type of topologies bit delayer were introduced in between
so that the data may not collide . so we always calculate first . whether a is less than 1 then we calculate the bit delayer
required and then apply it in somewhere in the middle . it delays the data for some time.

 0 votes -- Ravi Singh ( 7303 points)

9.209 Wifi: What do you suggest to study for WiFi and IPv6? top gateoverflow.in/28706

Topics such as

WiFi
IPv6

are introduced for the first time in the revised syllabus for GATE. If there are people working in this area or are in proximity
of the topics above, please suggest what are technically important areas among these technologies.

Provide sources and references for them.

wifi ipv6 computer-networks

For Ipv6 :
1.Advertising of message like unicast ,multicast, anycast
2.Special IP address for loopback,DHCP,Multicast
3.IPv6 address Hierarchy

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1331 of 2244

4.Jumbograms(basic conept)
5.IPv4 in IPv6
6.IPv6 Header
7.Extension headers basic only like types and basic usage.
8.Flow label

WiFi :
1.Basic concepts
2.Why CSMA/CD is not used in WiFi.
3.Architecture
4.AdHoc : IBSS
5.Distributed Systems
6.IFS(Inter frame space)
7.Collision avoidance
8.Poll cycle
9.Hidden node
10.Physical and Virtual Carrier sense
11.Exposed terminal
12.WiFi (802.11) Frame format
13.Frame control (from frame format) .

 7 votes -- Shashank Chavan ( 2439 points)

Just go through this below mentioned site only once. I guess this more than enough for gate related to the IPv6 and
Wireless Basics.

IPv6 : http://www.9tut.com/ipv6-tutorial

Wireless: http://www.9tut.com/wireless-tutorial

 2 votes -- Prasanna Ranganathan ( 2045 points)

For ipv6 refer 1)chapter 20 of data communication and networking fourth edition forouzan 2)chapter 27 of tcp/ip protocol
suite forouzan

 2 votes -- Pooja ( 22773 points)

9.210 Workbook Question: Computer Networks DRDO-2008 top gateoverflow.in/32123

Two ground stations are connected by a 10Mbps satellite link. The altitude of the satellite is 36,000km and the speed of the
signal is 3x108 m/sec. What should be the packet size for channel utilization of 50% using GBN sliding window protocol.
Window size is 100. Assume that the acknowledgement packets are negligible in size and there are no errors during
communcations.

a) 1.5 Kbytes

b) 3 Kbytes

c) 4.5 Kbytes

d) 6 Kbytes

computer-networks drdo-2008 made-easy workbook-question

Here the altitude of the satellite is 36,000km ,i.e.d=36000 *1000 m

speed of the signal (v) = 3x108 m/sec

propagation delay tp =(36000 *1000 ) /(3x108) =12/100 sec.

Let packet size = L

bandwidth of channel B= 10Mbps

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1332 of 2244

then transmission time tt =L/(10*106)

then , a=tp /tt

Window size N=100

utilization=50%=1/2

Now,
Utilization =N/(1+2a)

or,1/2=100/(1+2tp /tt)

or, L=1.5 Kbytes

Ans (a)

 1 votes -- srestha ( 11585 points)

9.211 Workbook Question: What is the total time required from the below
communication? top gateoverflow.in/32087

Host A is sending data to host B over a full duplex link. A and B are using the sliding window protocol for flow control. The
sender and receiver window sizes are 5 packets each. Data packets (sent only from A to B) are all 1000 bytes long and the
transmission time for such a packet is 50 μsec. Acknowledgement packets (sent only from B to A) are very small and require
negligible transmission time. The propagation delay over the link is 200 μsec. What is the total time required in this
communication?

a) 250 μsec

b) 200 μsec

c) 275 μsec

d) 450 μsec

computer-networks made-easy workbook-question

9.212 Workbook Question: What are the advantages of star topology? gateoverflow.in/32049

top

(a) Less number of cables are required

(b) More number of cables are required

(c) It is a distributed topology

(d) Security is high

computer-networks made-easy workbook-question

I think (D) could be the answer

Because star topology if one cable is down , other cable could connect the whole device. So, better secure than bus
topology.

But problem here is it depends on centralized system, so, ambiguity in question

http://computernetworkingnotes.com/network-technologies/network-topologies.html

 0 votes -- srestha ( 11585 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1333 of 2244

9.213 ISRO 2011/1 : Encoding technique used in Gigabit ethernet over optic
fiber medium? top gateoverflow.in/19325

Encoding technique used to transmit the signal in Gigabit Ethernet technology over optic fiber medium is ???

A) differential manchester

B) non return to zero

C) 4B/5B encoding

D) 8B/10B encoding

isro computer-networks

for gigabit ethernet encoding technique used is 8B/10B and for standard ethernet it is manchester encoding

 0 votes -- Pooja ( 22773 points)

9.214 subnetting top gateoverflow.in/17917

An ISP is granted a block of addresses starting with 190.100.0.0/16 (65,536 addresses). The ISP
needs to distribute these addresses to three groups of customers as follows:
a. The first group has 64 customers; each needs 256 addresses.
b. The second group has 128 customers; each needs 128 addresses.
c. The third group has 128 customers; each needs 64 addresses.
Design the subblocks and find out how many addresses are still available after these allocations


Selected Answer

Group 1 : 2^6 * 2^8 = 2^14

Group 2 : 2^14

Group 3 : 2 ^13

since there are chunks of 2^14 we first allot these addresses to the groups by dividing in 4 parts

Group 1 :

190.100.0.0/18 to 190 . 100.63.255/18

Group 2 :

190.100.64.0/18 to 190.100.127.255/18

Group 3 :

190.100.100 00000.0/19 to 190.100.100 11111.255/19

or 190.100.128.0/19 to 190.100.159.255/19

Remaining addresses are :

190.100.160.0/19 to 190.100.191.255/19

and

190.100.192.0/18 to 190.100.255.255/18

 0 votes -- Riya Roy ( 4767 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1334 of 2244

9.215 Any one give answer with Explanation top gateoverflow.in/19339

the protocol in play here has a minimum header length of 20 Bytes how can you ask someone to go below this value?

 1 votes -- Amar Vashishth ( 17865 points)

9.216 WHAT IS THE SUBNET MASK.. top gateoverflow.in/17704

An organization having class A network wants a subnet for 510 departments.The subnet mask should be?


Selected Answer

since it is a class A network so , first byte will be used for network id and the rest 3 byte will be used for subnet and host
id.

Since , there should be 510 departments and hence the address space of the network should be divided into 510 parts.

so,the lefstmost 9 bit of the 3 byte will be 1 as it will be fixed to divide the add space in 512 parts.

Note - each 1 in the binary no divide it in 2 regions.

so,required subnet mask = 11111111 11111111 10000000 00000000

subnet mask is 255.255.128.0

 0 votes -- Saurav Kumar Gupta ( 1455 points)

9.216 what is congestion control ? where it is used at which layer of OSI


model? what is token bucket and leaky bucket algo . top gateoverflow.in/43397

When congestion window size is greater than reciever window size then congestion control is used.

It is used at Transport layer of OSI model.

Token Bucket And leaky bucket algo

http://www.idc-online.com/technical_references/pdfs/data_communications/Leaky_Bucket_Algorithm.pdf

 0 votes -- Anirudh Pratap Singh ( 4091 points)

9.217 A sender sends a series of packets to the same destination using 5 bit
sequence numbers. top gateoverflow.in/17884

A sender sends a series of packets to the same destination using 5 bit sequence numbers. If the sequence number starts
with 0, what is the sequence number after sending 100 packets ?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1335 of 2244

With 5bit no of sequence no. Possible is 32 ie (0-31)

For frames 1-32 seq no 0-31

For frame 33-64 seq no 0-31

For frame 65-96 seq no 0-31

Now 97 98 99 100

0 1 2 3

So after sending 100 packets sequence no is 4

 1 votes -- Pooja ( 22773 points)

9.218 for the 8 bit word 00111001,the check bits stored with it would we
0111 top gateoverflow.in/19183

for the 8 bit word 00111001,the check bits stored with it would we 0111.suppose when the word is read from memory ,the
check bits are calculated to be 1101. what is the data word that was read from memory

9.219 What is the bit error rate? top gateoverflow.in/18087

Data is transmitted continuously at 2.048 Mbps rate for 10 hours and received 512 bit errors.What is the bit error rate?

a)6.9e -9

b)6.9e-6

c)69e-9

d)4e -9

Error rate in Mbps = error bit/time (x) = 512/10*60*60 Mbps

Bandwidth (y) = 2.048 Mbps

Error rate = x/y = (512*/10*60*60)/2.048 = 6.9*10^(-9)

 0 votes -- Digvijay Pandey ( 26245 points)

9.220 from only IP address can we recognise that how many subnet bits are
there and how many host bits are there.??? top gateoverflow.in/18248

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1336 of 2244

Caption

The ip address can be divided into 3 parts --netid + subnetid+hostid

--no of bits n of netid can be predicted according to the class used in addressing in classful notation and it will be given in
\n formate in classless notation.

--Remaining 32-n bit is used for subnetting and Hostid.

---if no of subnetts is 2 m and size of each sunet is k then

-----to recognise each subnet,we should have unique id for each subnet.since there is 2 m subnet so, m bit will be
needed for subnetting and rest will be used for hostid.

NOTE- we should use the leftmost bit of (32-n) bit for subnetting which will ensure serial addresses to be serial but it is
not always necessary bt practically this is the only way

 0 votes -- Saurav Kumar Gupta ( 1455 points)

9.221 computer networks top gateoverflow.in/18250


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1337 of 2244

Link utilization= (transfer time /(transfer time + 2*Propogation Time))*100

Transfer time = Message size/BW = 2KB/2Mbps = 2*8*10^3/2*10^6 = 8*10^-3 second = 8 ms

PT= 25(given)

putting the values (8/(8+50))*100= 13.79 %

 0 votes -- Umang Raman ( 10379 points)

9.222 Lightweight Directory access protocol is used for top gateoverflow.in/18149

Lightweight Directory access protocol is used for

a)Routing the packets

b)Authentication

c)obtaining IP address

d)domain name resolving

i guess its option B ) Authentication

The main idea of LDAP is to keep in one place all the information of a user (contact details, login, password, permissions), so that it is easier to
maintain by network administrators.

 0 votes -- Umang Raman ( 10379 points)

9.223 The encoding technique used to transmit the signal in giga ethernet
technology over fiber optic medium is top gateoverflow.in/18138

The encoding technique used to transmit the signal in giga ethernet technology over fiber optic medium is

a). Differential Manchester encoding

b). Non return to zero

c). 4B/5B encoding

d). 8B/10B encoding

computer-networks

8B/10B.

8 Bit data converted into 10 bit data. 8B/10B is combination of 5B/6B and 3B/4B.

 0 votes -- Digvijay Pandey ( 26245 points)

9.224 ethernet layer-2 switch is a network element type which gives gateoverflow.in/18788

top

a)Different collision domain and same broadcast domain

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1338 of 2244

a)Different collision domain and different broadcast domain

a)same collision domain and same broadcast domain

a)same collision domain and different broadcast domain


Selected Answer

Switch act as a collision domain separator not not as a broadcast domain separator.

a) Different collision domain and same broadcast domain option A is correct.

 1 votes -- Umang Raman ( 10379 points)

9.225 In which layer of network architecture , the secured socket layer (SSL)
is used? top gateoverflow.in/18114

In which layer of network architecture , the secured socket layer (SSL) is used?

a)physical layer

b)session layer

c)application layer

d)presentation layer

(b) option
most probably it should in be session layer
SSL name itself tells that it is higly secured layer which is used during our payments gateway .
Eg: when we are used to go for online payment ,that payment gateway is considered in ssl layer..

 0 votes -- kunal chalotra ( 3567 points)

9.226 Which is the correct definition of a valid process transition in an


operating system? top gateoverflow.in/18557

Which is the correct definition of a valid process transition in an operating system?

a)Wake up:ready->running

b)Dispatch:ready->running

c)Block:ready->running

d)Timer runout:ready->blocked


Selected Answer

Wake up :blocked to ready

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1339 of 2244

Dispatch:ready to running

Wait running to block

Time out running to ready

So ans is b

 0 votes -- Pooja ( 22773 points)

9.227 Time taken for the entire message to reach from source to destination
top gateoverflow.in/42515

A 64000-byte message is to be transmitted over a 2-hop path in a storeand- forward packet-switching network. The network
limits packets to a maximum size of 2032 bytes including a 32-byte header. The transmission lines in the network are error
free and have a speed of 50 Mbps. Each hop is 1000 km long and the signal propagates at the speed of light (3 × 108
meters per second). Assume that queuing and processing delays at the intermediate node are negligible. How long does it
take to deliver the entire message from the source to the destination?

My solution

Total amount of data=64000 bytes.

Limiting size of packet including header =2032 bytes. so we'll get 64000/2000=32 packets

Total overhead for header-32*32 bytes= 1024 bytes.

As it is 2 Hop and uses store and forward we have to send it through each hop where each hop will first store and then
transmit. We have 32 packets need to be sent.

Time taken for the first packet to reach destination- Transmission time sender+propagation time up to 1st hop +
Transmission time of 1st hop+ propagation time up to 2nd hop + Transmission time of 2nd hop+ propagation time up to
receiver

(2032*8)/(50*10^6) + (1000*10^3)/(3*10^8) +(2032*8)/(50*10^6) + (1000*10^3)/(3*10^8)+ (2032*8)/(50*10^6) +


(1000*10^3)/(3*10^8)=

[3*{(2032*8)/(50*10^6) + (1000*10^3)/(3*10^8)}] = 107.526 mesc

The first packet reaches at 107.526mses.

The second packet would have transferred immediately just after the first packet transmission is over at sender.

The first packet transmission ends at 32.512 msec at sender. So the second packet will just start after this time. Hence a
dealy of 32.512msec will occur for the second packet to reach the destination. Similarly for next upcoming packets.

Hence to send all the 32 packets to receiver it takes 107.526+ 31*32.512 msec= 1115.398 msec

Can anyone confirm this answer. Please help if any error is there .

computer-networks

i think ans should be like this

1 packet's RTT + (31 * (max(Transmissinon time,Propagation time ))) since total 32 packets needs to send

we can relate it with pipeline concept co.

am i right??

 0 votes -- Gabbar ( 469 points)

9.228 jacobson's algo top gateoverflow.in/38895

i have not used deviation and still got the answer using ERTT=IRTT*alpha+(1-alpha)*NRTT.what is the use of deviation in

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1340 of 2244

this question?

test-series

9.229 DATA LINK LAYER top gateoverflow.in/20530

A group of 2n − 1 routers are interconnected in a centralized binary tree with a router at each tree node . Router 1
communicates with Router j by sending a message to the root of the tree. The root then sends a message back down to j
Derive an approximate expression for the minimum number of hops per message for large N , assuming that all the router
pairs are equally likely

1). 2N − 4

2). N − 4/2

3). N − 4/2

4). N − 4

computer-networks

Answer is 2N-4

binary tre having 2 n-1 routers

In Nth level of tree each node(router) will take n-1 hops to tranfer to root and half of the total routers are on this level.
(n-1)*1/2 hops

N-1 level 's nodes will take n-2 hops to tranfer to root and half of the remaining routers are on this level. (n-2)*1/4 hops

N-2 level 's nodes will take n-3 hops to tranfer to root and half of the remaining routers are on this level. (n-3)*1/8 hops

N-3 level 's nodes will take n-4 hops to tranfer to root and half of the remaining routers are on this level. (n-4)*1/16 hops

So in total i router to root

= (n-1)*1/2+ (n-2)*1/4+ (n-3)*1/8+ (n-4)*1/16+......

= n-2

Similarly root to router j again n-2

Mminimum no. Hops = 2(n-2)= 2n-4

 0 votes -- Khushboo Tak ( 1961 points)

9.230 cn top gateoverflow.in/38920

Assume 10 Mbps Ethernet and two stations A and B on it’s same segment. The RTT between two nodes is 650 bit times. A
and B start transmitting frame and collision occurs and both sends 30-bit jam signal. Find the time at which both nodes A
and B sense an idle channel (in μsec).

225 bit to go from A to B.


let just before B der is collision. 50 bit jamming signal. so it will take 225+50 bit to reach A.

Total time = 225 + 50 + 225 = 500 bit time.
Time in second = 500/10M = 50 micro second

 0 votes -- Digvijay Pandey ( 26245 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1341 of 2244

9.231 Question on calculating total transmission time between two hosts top
gateoverflow.in/38930

I am not able to convince myself why transmission time needs to be added for each link if store and forward is not being
forward. Please check

computer-networks

9.232 Bit Rate of receiver top gateoverflow.in/39141

In synchronous transmission, 5 eight bit characters are included in 30 eight bit information characters. If bit rate of sender is 4200 bits/sec, what is the bit rate of receiver (in bits per sec)?

computer-networks made-easy

Time required for sending = 240 bits / 4200 bits/sec = 24/420 sec

Time required for receiving = 35*8 bits / receiver rate

Equate both and get the answer.

 0 votes -- nikhil1008 ( 243 points)

9.233 number of keys required for n individuals to communicate using


private and public encryption top gateoverflow.in/38530

how many keys are required for n indiviuals to communicate using secret and public key

9.234 made easy top gateoverflow.in/38293

What is the total over header bits (Headers & Retransmission) with data frames consisting of 40 bit header and 3960 data bits.
ACK frames never occur. NAK frames are 40 bits ,the error rate (in bits) for frame is 2% and for NAK frame is negligible (upto 2
decimal place)

ans-:120.80

made-easy test-series


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1342 of 2244

let 100 frames of DATA + Header (3960+40) are sent..


total 4000*100 bits are sent..

2% is error rate that means 2 NAK frame for every 100 DATA frames..
80 bit per 100 frame for NAK..

bcause of 2 NAK frame we will again send 2 data frame i.e. 2*4000 = 8000 bit
Total (Data + Overhead) bit sent = 4000*100 + 80 + 8000 = 408080 bit
Original Data = 3960*100 = 396000 bit

Overhead = (408080 - 396000) bit = 12080

but this overhead is for 100 frames..


for 1 frame it will be 120.80 Bit

 1 votes -- Digvijay Pandey ( 26245 points)

9.235 made easy top gateoverflow.in/38089

is it correct?

made-easy test-series


Selected Answer

Yes it is correct. As a Class C and if this IP is used as DHCP or in local network it is treated and preferred as 0.0.0.x

 0 votes -- Shashank Chavan ( 2439 points)

9.235 interdomain routing top gateoverflow.in/37937

9.236 made easy top gateoverflow.in/38142

For a class C network if IP address of a computer is 200.99.39.112 and subnet mask is 255.255.255.224 the first host of
first subnet (represent last octet) is ________.

my question is that whether to take 1st host as '000' or '001'.?

according to me 1st host should be 000,so accordingly answer will be 200.99.39.00000001..ANSWER=1

but they had taken 200.99.39.00100001..ANSWER=33

made-easy test-series


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1343 of 2244

All 0s in Host id part represent 1st address of network (Subnet) and all 1s in Host id id part represent Directed Broadcast
address of that Network (Subnet)..

In case of Subnet u r allowed to take all 0s as well as all 1s as Subnet bit bt Host should not be all 0s or All 1s..

 1 votes -- Digvijay Pandey ( 26245 points)

9.237 Smallest window size top gateoverflow.in/21283

Consider a 40 kbit/s network link connecting the earth to the moon. The moon is about 1.5 light-seconds from earth.
If a sliding-window protocol is used instead, what is the smallest window size that achieves the maximum data rate?

Solution provided:

Achieving full rate requires a send window of at least


bandwidth-delay product = 5 packets/s * 3 s = 15 packets.

My doubt is y we are not taking tramission delay? Inorder to achieve maximum utilisation sender ha sto send frames
continuosly until ack received.

RTT=TD+PD(Frame)+TD(ack)+PD(ack)

=((1 × 103 × 8) ÷ (40 × 103 )) + 1.5 + 1.5

=3.2secs

Maximum number of bytes that can be sent in 3.2s=16000

number of packets=16

which is the ryt method?

9.238 window size top gateoverflow.in/20679

To find minimum window size we need to find no of frames which can be sent in one RTT

Window size=1024kbps*100ms/512*8

=25

 1 votes -- Pooja ( 22773 points)

9.239 Computer Network top gateoverflow.in/21139

Which 2 control signals are used for handshaking between computer and modem for existence ?

1) Request to send , clear to send

2)Ring Indicator and Data carrier detect

3)Data set ready and terminal set ready

4) Data Carrier detect And data terminal Ready .

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1344 of 2244

computer-networks

9.240 Network layer top gateoverflow.in/21143

The routine table of a router is shown below :

Destination subnet Interface


132.81.0.0 255.225.0.0 eth0
132.81.64.0 255.255.224.0 eth1
132.81.68.0 255.255.255.0 eth2
132.81.68.64 255.255.255.224 eth3

A packet begining a destination address 132.81.68.132 arrive at the router . on which of the interfaces it cant be forwarded ?

a) eth 0 b ) eth 1 c) eth 2 d) eth 3

computer-networks

a is the answer as the destination address is class-b ip address and on AND ing with subnet mask on match will be
obtained

 0 votes -- Shivani Jaiswal ( 23 points)

9.241 consider the token bucket with maximum rate R=20 Mbps. suppose we
want to make sure that.. top gateoverflow.in/20010

Consider a token bucket with maximum rate R = 20 Mbps suppose we want to make sure that the maximum rate can only
be sent for at-most 5 seconds at a time , and at- most 150 Mb can be sent over any 10 second window. Consider the
required value for the bucket depth (b) in Mb

We are sending the maximum rate for 5 seconds,so we send 20 ∗ 5 = 100 Mb in 5 seconds. We can only send 150 Mb in
any 10-second window, so 150 − 100 = 50 Mb, we can send in the remaining 5 seconds, so rate = 50/5 = 10 Mbps. Now,
in order to ensure the bucket has enough tokens to sustain a 5-second burst at 20 Mbps, we require b = (M − rate) ∗ 5 =
(20 − 10) ∗ 5 = 50 Mb bucket depth.

M-- maximum rate at which data can be send

 0 votes -- Ashish Gupta ( 631 points)

9.242 Application Layer top gateoverflow.in/21167

WHICH OF THE FOLLOWING IS FALSE ?

1)DNS IS A CLIENT SERVER APPLICATION

2) DNS TREE HAVE ONLY 64 LEVELS

3)DNS ORGANISE THE NAMESPACE IN HIERARCHICAL STRUCTURE

4) DNS USE THE UDP FOR SOME MESSAGES WHILE SOME FOR TCP .

computer-networks

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1345 of 2244


Selected Answer

2) DNS TREE HAVE ONLY 64 LEVELS is false

DNS tree can have upto 128 levels

refer forouzan for further details

 2 votes -- dirac ( 173 points)

9.243 total delay in sliding window and without sliding window top gateoverflow.in/19906

amount of time it would take to send 500 packets using 6-packet size window and without sliding window will be, when the
time to send in one direction is 5 ms

31000, 5000

4600, 21600

5000, 30000

30000, 5000.......... pls explain the logic behind?

With sliding protocol throughput will be n (size of the packet) times of stop and wait(n.B/1+2a).Here without sliding
window means simple stop and wait.As n=6,from the option c we can see that 5000 × 6=30000.Hence c will b the
answer.Time to send 5 ms i have not considered

 0 votes -- Rohan Ghosh ( 1515 points)

9.244 Efficiency of token ring under delayed token release/ early token
release/ intermediate token release top gateoverflow.in/19833

Compute utilization of token ring LAN where all stations are queued to send. Given the following parameters:

ring length=5000 metres

signal propagation=5 ns/m

no. of stations=25

mean frame length=100bytes

data rate=100Mbps

efficiency of token ring under delayed token release strategy?

21.4% 33% 30.8% 41.3%

token ring is out of syllabus . no need to study this topic.

 1 votes -- Ravi Singh ( 7303 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1346 of 2244

9.245 ISRO_A 2015/53 top gateoverflow.in/19790

An ACK number of 1000 in TCP always means that

a)999 bytes have been successfully received

b)1000 bytes have been successfully received

c)1001 bytes have been successfully received

d)None of the above


as initial sequence number is random number.

we can't tell what is the ACK 1000 in TCP , as it depends on initial random sequence number.

so answer is none of the above

 0 votes -- pramod ( 2071 points)

9.246 stop and wait top gateoverflow.in/20686

bandwidth of a link is 1000 Mbps and round trip time is 250 micro seconds.If the frame size is 500 bits the link utilization (
IN %) of channel using stop and wait protocol is ?


Selected Answer

Bandwidth-delay product = 1000 × 106 × 250 × 10 −6 = 250000

But the system is sending only 500 bits

so, Link utilisation is 500/250000 × 100 = 0.2%

 1 votes -- Prabhanjan R ( 747 points)

Efficiency=transmission time / (transmission time + 2propogation time)

Efficiency=tt/(tt+2tp)

or Efficiency=1/ 1+ 2pt/tt

=1/1+250/0.5

=1/501

= 1.9960 * 10 -4

=0.000199

In % = 0.000199 *100 =0.01996

is anythng wrong?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1347 of 2244

 1 votes -- Anirudh Pratap Singh ( 4091 points)

9.247 Suppose an IP packet has been fragmented. Then which of the


following is a set of fragments? top gateoverflow.in/21018

Suppose an IP packet has been fragmented. Then which of the following is a set of fragments?

A) 128, 56, 84, 42

B) 372, 408, 12, 56

C) 248, 72, 120, 18

D) 48, 88, 70, 52

computer-networks

Concept is all Fragment offset (except last fragment) should be multiple of 8. bcoz Fragment Offset size if 13 bit and data
coming from Transport layer is of size 16 bit so we need scaling. To store 16 bit data into 13 bit Fragment offset we need
scaling of 8.

only option C satisfy given condition.

 1 votes -- Digvijay Pandey ( 26245 points)

9.247 the set of all equivalence classes of a set with cardiity c top gateoverflow.in/41171


Selected Answer

Set of all equivalence classes of any equivalence relation forms a partitions.

 0 votes -- Leonidas Leonidas ( 97 points)

9.247 which is stateful application layer protocol? top gateoverflow.in/39437

computer-networks

http is stateless application layer protocol

ftp is statefull application layer protocol

tcp is statefull but its not an application layer protocol

and there is discussions regarding pop3. it is stateful until download, as well as stateless across sessions.

probably answer will be ftp and pop3

 0 votes -- Sreyas S ( 1353 points)

9.248 sliding window protocol top gateoverflow.in/20683

in a sliding window protocol assume a 3 bit sequence number field. A and B have windows which has 3 bit sequence
number.If A sends 3 frames and waits for all three acknowledgments until the timer expires.Which of the following could not
be the sender's window size after the timer expires.Assume receiver receives all the three frames correctly but ack from

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1348 of 2244

receiver may be lost--

4, 7, 5, 6

With 3 bit sequence no max window size=8

So with every ack window size reduces by 1

So if 1 ack comes window size=7

If 2 ack come window size=6

If 3 comes window size=5

So 4 is not possible

 0 votes -- Pooja ( 22773 points)

9.248 Does TDM affect the bandwidth of the link ? top gateoverflow.in/41800

computer-networks


Selected Answer

Time Division Multiplexing means that multiple users are allowed to transmit on a communication channel in a Round
Robin manner.

Example:

Say there are 4 users and time slot is 5 seconds. It means in first 5s, user 1 can transmit data, in next 5s user 2 can
transmit data and so on, cycle repeats beginning from user 1 again.

Effect On Bandwidth

In Ideal situations, where every station is working properly, it does not effect bandwidth. But there can be many cases,
where wastage of bandwidth occurs and these are:

1. If a user in its time slot does not have any data to transmit, it leads to complete wastage of bandwidth.

2. If a user machine goes down due to failure then also the entire bandwidth is wasted.

For the above 2 mentioned scenarios, frequency division multiplexing is more fault tolerant.

 1 votes -- Computer_Engineer ( 107 points)

9.249 link layer packet switching top gateoverflow.in/41834

Host A (on TCP/IP v4 network A) sends an IP datagram D to host B (also on TCP/IP V4


network B). Assume that no error occurred during the transmission of D. When D reaches B,
which of the following IP header field(s) may be different from that of the original datagram
D?
(i) TTL (ii) Checksum (iii) Fragment Offset
(A) (i) only (B) (i) and (ii) only
(C) (ii) and (iii) only (D) (i), (ii) and (iii)

Gate 2014 quetion from set -3. Bdw solution is

TTL value change from one router to another router so change .

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1349 of 2244

Checksum change since TTL value change so checksum computed again.

Fragment Offset change when another router further dived the packet .

so all will be change

 2 votes -- Anirudh Pratap Singh ( 4091 points)

9.250 ISRO_A 2015/55 top gateoverflow.in/19453

A certain population of ALOHA users manages to generate 70 request/sec.If the time is slotted in units of 50 msec,then
channel load would be

a)4.25

b)3.5

c)450

d)350

(b) option

(70*50)/1000
=3.5

 0 votes -- kunal chalotra ( 3567 points)

9.251 Two stations 'A' and 'B' are connected via a point to point link and
exchange frames.. top gateoverflow.in/17353

Two stations 'A' and 'B' are connected via a point to point link and exchange frames with m=3 where m is the size of the
sequence number field in bits. Station 'A' sends frames in the following order(fig).

What will be the buffer frames in the current window of 'A' just after the time-out and what are the values of X and Y if go-

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1350 of 2244

back-n ARQ sliding window protocol is used?


(A) Buffer frames of A: 2345601 X=2 Y=3
(B) Buffer frames of A: 1234567 X=1 Y=2
(C) Buffer frames of A: 2345670 X=2 Y=3
(D) Buffer frames of A: 1234560 X=1 Y=2

computer-networks


Selected Answer

NAK is used for selective repeat ARQ!!! the ans should be option C. Because frame 2 has been lost and that's why the
frames 3 and 4 has been discarded.So after the time out the sender should resend frame 2.Therefore X=2 and Y=3.The
buffer frames of the current window is 2345670

 3 votes -- Sudipta Paul ( 283 points)

9.252 distance vector algo top gateoverflow.in/6519

Consider a network having 6 nodes A, B, C, D, E and F. The measured


delay between A to B, A to D and A to C are 4, 5 and 6 respectively. routing table of A using distance vector routing?
The vector tables of B, D, C are given as follows
A B C D E F
Vector table of B = (2 0 4 4 3 2)
Vector table of C = (5 4 0 2 7 4)
Vector table of D = (5 1 3 0 3 6)

0 4 6 5 7 6

 1 votes -- Pooja ( 22773 points)

9.252 In computer network when we transfer data bw 2 stations, when we


should take propagation time as 1 pt and when should we take it as 2pt
while solving numericals top gateoverflow.in/6729

If pt is propagation time then it should always be 1pt.

I guess the confusion is in getting the RTT. For RTT should we add 1pt or 2pt? It is actually 1pt for frame + 1pt for ACK.
Now ACK being small, 1pt for ACK is usually ignored. When ACK is piggy backed, we use pt for ACK = pt for frame, and
hence use 2pt.

 2 votes -- Arjun Suresh ( 124125 points)

9.253 plz answer.. top gateoverflow.in/6395

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1351 of 2244

Error rate is 1% so out of100 frames sent only a


single frame will contain error. We need to resend a frame after sending 100 frames. So fraction of bw wasted is 1-
0.98=0.02

 0 votes -- Bhagirathi Nayak ( 10239 points)

9.254 which of the following IP can be used by both source and destination>
top gateoverflow.in/6387

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1352 of 2244

ii. is Limited Broadcast address which is always used as Destination address.

iv. is Directed Broadcast address which is also always used as Destination Address.

 2 votes -- Gate Keeda ( 16619 points)

9.254 each bridge seemsto be interconnected. then how to get this spanning
tree? top gateoverflow.in/6272

9.254 TCP implements SWP for flow control. It advertises window field in
TCP header is used for this purpose then compute it's value if MaxRcvBuffer
is 100 Bytes, NextByteExpected is 51 and LastByteRead is 40 ________. top
gateoverflow.in/6333

Last byte read is 41


Next byte expected is 51
So the bytes between 41 and 50 are still in buffer i.e. 10 bytes and size of buffer is 100.
So 90 bytes of buffer are empty. Advertised window is 90

 1 votes -- Viral Kapoor ( 1777 points)

9.255 TCP/ UDP top gateoverflow.in/7890

At transport layer "pseodoheader" is attached with each outgoing data from transport layer(along with data from upper layer
and its own header).Psedoheader is a part or snapshot of header from network layer.. My question is being upper layer of
network layer how transport layer generates the pseodoheader,, which is generated by network layer in as next step...

Maybe this can also help

http://www.tcpipguide.com/free/t_TCPChecksumCalculationandtheTCPPseudoHeader-2.htm

 0 votes -- Madhur Rawat ( 2379 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1353 of 2244

9.256 There are 200 computers in a lab which are attached to an ethernet 10
Mbps with a coaxial cable of 1500m .The packets are 800 bits long/ The
propagation speed is 2*10^8 m/sec. On avg how many packets can each
comp. send per second ? top gateoverflow.in/9561

There are 200 computers in a lab which are attached to an ethernet 10 Mbps with a coaxial cable of 1500m .The packets are
800 bits long. The propagation speed is 2*10^8 m/sec. On avg how many packets can each computer send per second ?
Options 1) 42 packets/sec 2) 44 packets/sec 3) 62 packets/sec 4) None

bandwidth allotted to each computer = 10*10^6/200


= 50000 bps
each computer transfer 50000 bit in 1 second.
no of packet = 50000/800
= 62

 4 votes -- Digvijay Pandey ( 26245 points)

9.257 networks top gateoverflow.in/10778

Monitor is an example of which of the following communication mode?

Response:

Simplex

Half duplex

Full duplex

None of these


Selected Answer

I think It is simplex.

As Simplex is a one way communication

half duplex is a two way communication but one way at a time not simultaneous (eg. as walkie-talkie over and out)

full duplex is a two way communication simultaneously , as we talk over mobile

 3 votes -- Praveen Saini ( 34299 points)

9.258 networking TCP IP prob top gateoverflow.in/11838

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1354 of 2244

We have to send 800 + 20 = 820 bytes.

From P to R1:

Maximum frame length supported is 1024 and 820 + 12 is within one frame- 832 bytes transferred.

From R1 to R2:

Maximum frame length is 256 bytes including 8 bytes header. We have 832 - 12 = 820 bytes (IP header added by P would
be removed here). So, this requires ceil (820/(256 - 8)) = 4 frames - 3 * 256 + 820 - (248*3) + 8 = 852 bytes
transferred.

From R2 to Q:

We need to send 248 bytes in a frame and maximum frame length is 512 bytes including 12 bytes header. So, four
frames frames are required - 3 * (248 + 12) + (76 + 12) = 868 bytes transferred.

 1 votes -- Arjun Suresh ( 124125 points)

9.259 networking top gateoverflow.in/10777

What setting of THT (token holding time) will be optimal for a network that had only one station active at a time?

Response:

10 ms

Depends on the size of the ring

Infinity

Can't say


Selected Answer

Infinity. With just one active station for optimal network, the Token Holding Time must be as large as possible.

 1 votes -- Arjun Suresh ( 124125 points)

9.260 network general top gateoverflow.in/10776

Which type of ACK is used in 802.5?

Response:

Cumulative ACK

Independent ACK

Piggybacking ACK

None of these

piggybacking ack, because in token ring, frame contains a frame status byte which have two bits A(Address recognized)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1355 of 2244

and C(frame copied) which are initially and 0 and 0 after sending data received by destination they are changed by 1 and
1 and coming back to the sender with A =1 and C =1 which is piggybacking ack .

Ref: http://www.cs.montana.edu/~halla/csci466/lectures/lec10-2.7-token.html

 1 votes -- sonam vyas ( 6441 points)

9.261 how many bits fit in a cable top gateoverflow.in/9562

A 100 Km long cable runs at 154 Mbps data rate. The prop speed in the cable is 2/3 of light. how many bits fit in the cable ?

1) 772
2) 700
3) 782
4) 770


Selected Answer

d 105
v 2 ×108
tp = = = 0.5 × 10 −3

No of bits = t p x bandwidth = 0.5 × 10 −3 × 154 × 106 = 77000

 1 votes -- CrimeMasterGoGo ( 2221 points)

9.261 The round trip delay for a 100 Mbps Ethernet having 48 bit jamming
signal is 64 * 10^-6 sec. What is the minimum frame size? 1. 400 bytes 2.
800 bytes 3. 600 bytes 4. 1400 bytes top gateoverflow.in/5987

2 * propagation delay + transmission time for jamming signal <= transmission time for frame
64 μs + 48/100 μs <= transmission time for frame
64.48 μs <= l/100 μs
l >= 6448 bits >= 806 bytes.

 5 votes -- Arjun Suresh ( 124125 points)

9.262 In a token ring network, the transmission speed is 10 Mbps and


propagation speed is 2 * 108 m/sec. The 1-bit delay in this network is
equivalent to how many meters of cable? top gateoverflow.in/5826

In process synchronization what is true about disabling interrupts and TSL?

1)Disabling interrupt is applicable only for single processor system

2)TSL is applicable only for single processor system

3)Both could be used in multiprocessor system

4)none of the above

1 bit delay means time to transmit 1 bit..which is 10'^-7 sec...the length will be traveled by signal in this time is
2*10^8*10^-7 meters=20 meters..1 bit delay is equivalent to 20 meters on cable

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1356 of 2244

 3 votes -- debdas ( 79 points)

9.263 An organization has class B n/w wishes to form subnet for 64


departments. The subnet mask will be.?? top gateoverflow.in/44036

plzz give the explaination also...

class B network has Subnet Mask 255.255.0.0=11111111.11111111.00000000.00000000

Subnets required 64=2 6

So, Subnet Mask for 64 departments will be 11111111.11111111.11111100.00000000=255.255.252.0

 2 votes -- srestha ( 11585 points)

Class B has 16 network bits and rest 16 host bits.

Subnettting is done by chossing bits from host. So in order to make 64 subnets we have to carry log2(64)= 6bits from
host.

Now look NID.NID.XXXXXXXX.XXXXXXXX we carry 6 bits and we know subnet mask contain 1 for NID and subnet bits and
0 for host bits so Mask will be 11111111.11111111.11111100.00000000 : 255.255.252.0

 1 votes -- Ashwani Kumar ( 83 points)

9.264 security top gateoverflow.in/44009

Which of the following is the


process by which a user’s access to
physical data in the application is
limited, based on his privileges ?
(A) Authorization
(B) Authentication
(C) Access Control
(D) All of these

I would say Access Control List is one of the way to implement Authorization .

I rem a bit of it

Access control in an OS is represented by matrix

We have a row defined for each user

and coloumn defined for physical data such as Files A , files B

Then if i have access to file A then a bit set it

and for file B if not

There is a thin line between Authorization an Access control

But what i think if they say Physical data ( it mean we are actually talking about files records and all ) Who has access to
which is captured by Access Control

And Overall access is defined by authorization

But acCess control link is not usually used through tmatrIx .it takes a lot of space . Because it captures both right for all
the files in a system

So instead of this a new approach was implemented called "Capabilities "

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1357 of 2244

where with user we will associated all the files it can access and in which mode

If a system has A---Z files

and if i am dealing with A and B in Write mode for both

Then i will just have this information stored for it . I wont have any related to C ---Z . That why this method was more
favourable over access Control ( Because in Access Control if user dont work with C---Z files also then also information
about is stored by setting bit 0 )

// i have choosen system security as my final year subject . You can read Information security by Mark Stamp .
Seriosusly a good book

 0 votes -- Dexter ( 1933 points)

9.265 A CSMA/CD network running at 4Gbps over 1Km cable with no


repeaters. Signal speed in is 2*10^8 m/sec. top gateoverflow.in/44132

What is Minimum frame size?

L>=2*(d/v)*B

>=2*(1000/2*108)*4*109

=40000bits =5000 Bytes

 1 votes -- srestha ( 11585 points)

9.266 Character stuffing !! top gateoverflow.in/389

i am understanding Character stuffing from an online resource !!

It says "

sing the special character of <DEL> and <STX> and <ETX> for start/end framing, the message:

AB<DEL>C<STX><ETX>DE

would be sent as (stuffed characters are underlined):

<STX>AB<DEL><DEL>C<DEL><STX><DEL><ETX>DE<ETX>...<STX>

"
but they state that the problem with this method is

" We can't use this method in situation like this when message is

<DEL><STX>A<DEL><ETX>

"

why we can't do that ??

converting this <DEL><STX>A<DEL><ETX> to our codeword will give output something like this

<STX><DEL><DEL><DEL><STX>A<DEL><DEL><DEL><ETX><ETX>

where receiver will loose the sync ??

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1358 of 2244

9.267 can 255.255.31.0 be a n/w mask..? top gateoverflow.in/44302

Can 255.255.31.0 be a n/w mask..? mask is cont. no of 1's and then no of 0's.. So in this case it
is..11111111.11111111.00011111.00000000.. how come 1 has come in between ..? plz explain ..

Yes this is a discontinuous subnet mask.But practically these are not being used a lot nowadays.

Mostly Such kind mask is used in many question where you have given many IP addresses and

they will ask whether the IP addressed could belong to this same network or not.

They are mostly used in ACLs.

To Know More about discontinuous Mask:https://routerjockey.com/2010/05/19/using-discontiguous-wildcard-masks-in-acls/

 0 votes -- Manojk ( 3365 points)

9.267 what are traffic descriptors?? is it representing data flow or bursty


traffic?? top gateoverflow.in/191


Selected Answer

From Wikipedia:

When a connection is requested by an application, the application indicates to the network

The Type of Service required


The Traffic Parameters of each data flow in both directions
The Quality of Service (QoS) Parameters requested in each direction

These parameters form the traffic descriptor for the connection.

 2 votes -- Arjun Suresh ( 124125 points)

9.268 Congetion Window in TCP top gateoverflow.in/1909

Let the size of congestion window of a TCP connection be 32 KB when a timeout occurs. The round trip time of the
connection is 100 msec and the maximum segment size used is 2 KB. The time taken (in msec) by the TCP connection to get
back to 32 KB congestion window is _________.


Selected Answer

http://gateoverflow.in/1794/gate2014-1_27?show=1794#q1794

 1 votes -- Dhananjay ( 657 points)

9.269 ISRO-2013-44 top gateoverflow.in/43985

Which algorithm is used to shape the bursty traffic into a fixed rate traffic by averaging the data rate?

A. Solid bucket algorithm


B. Spanning tree algorithm
C. Hocken helm algorithm
D. Leaky bucket algorithm

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1359 of 2244

isro2013 computer-networks

Its D.

 1 votes -- dhairya ( 69 points)

Answer D) Leaky Bucket Algo

 1 votes -- srestha ( 11585 points)

9.270 if an ip address is given and it is divided into 4 subnets then what is


the length of subnetwork ? top gateoverflow.in/43903

what is the length of subnet ID. plz someone explain me with an example..plz..

If we have to make 4 subnets then we have to choose 2 bits (00, 01,10,11) . As it is class C, 3 octets are for NID and 1
octet is for HID. Among Hosts we have to choose 2 bits so no of remaining hosts are configured from last 6 bits i.e. 2^6 -
2

 0 votes -- Ashwani Kumar ( 83 points)

9.271 Error Detection top gateoverflow.in/5495

If odd parity is used for ASCII error detection the number of 0's per 8 bit symbol is

a) even

b) odd

c) Indeterminant

if Odd parity is used, there should be odd number of 1's in 8 bit symbol.

so, there should be ODD number of 0's too

 0 votes -- innovwelt ( 27 points)

9.272 I am not getting how ARP protocol actually works.Please someone


clarify my doubt. top gateoverflow.in/4972

Suppose two systems are there in two different LANs, LAN-1 and LAN-2 respectively.System-1 (present in LAN-1) wants to
communicate to system-2(present in LAN-2), for which sys-1 needs the MAC ddress of that system in adition to its IP
address.So, it sends an ARP request messgae which contains the destination IP address which is broadcasted by the switch
present at the interface of LAN-2.
My doubt is, how does the system-2 will come to know, that the request messgae belongs to it..? I think dest. IP which is
present inside the ARP request message belongs to the public IP(of the LAN).[correct me, if i am wrong].Then,how the
system-2 is going to reslove that request packet belongs to it..? Please explain.

basically u don't even need to know the mac address of the final host. always the mac address which will be used will be
the next hope. which in this case will be default gateway. and arp request outside the network are not entertained .

 0 votes -- Ravi Singh ( 7303 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1360 of 2244

9.272 ARP protocol belongs to which layer of OSI model.? According to me it


is neither completely layer-3 (Network layer) nor completely layer-2(data
link layer).Please clarify top gateoverflow.in/4966


Selected Answer

You are correct.

https://en.wikipedia.org/wiki/Address_Resolution_Protocol

 1 votes -- Arjun Suresh ( 124125 points)

9.273 computer networks top gateoverflow.in/2483

Tanenbaum connection establishment

computer-networks gate-2009

Part 1)

The 15 bit wide clock counter can produce 2 15 sequence numbers, producing 1 every 100 milliseconds. (1 msec = 10 -3
sec)

⇒ 1 sequence number is produced in 100 x 10 -3 sec,

⇒ 215 sequence numbers can be produced in 2 15 x 100 x 10-3 seconds = 3276.8 sec ⇒ 54.61 minutes.

As the sequence numbers will start repeating after the expiry of lifetime (which is given as 60 sec, we dont have any
issue)

Part 2)

240 sequence numbers in 60 sec,


60

⇒ 1 sequence number in ⇒ 240 sec


60

⇒ 215 sequence numbers in ⇒ 240 × 215 = 8192 sec ⇒ 136.53 minutes

 1 votes -- CrimeMasterGoGo ( 2221 points)

9.274 y not a? top gateoverflow.in/12069

Which of the following is widely used inside the telephone system for long-haul data traffic ?

(A) ISDN
(B) ATM
(C) Frame Relay
(D) ISTN

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1361 of 2244

ATM (Asychronus Transfer Mode)

 0 votes -- Raghuveer Dhakad ( 849 points)

9.275 255.255.31.0 how many number of subnet bits is there if it is subnet


mask top gateoverflow.in/12923

If it is super net mask how many super net bits is there

its a subnet of class B . so 16 net 16 host id .

255.255.31.0 =

255.255. 00011111.00000000 there are 8+3 = 11 0`s 21 1`s

so no. of subnet possible 2^(21-16 ) = 32

Supernet means combination of two or more networks (or subnets) with a common Classless Inter-Domain Routing
(CIDR) . So max supernet subnet mask for this will be Class b subnet mask . 255.255.0.0 .

 0 votes -- Pranay Datta ( 6113 points)

9.276 Efficiency of ethernet top gateoverflow.in/25082

If the transmission delay is 200ms and throughput is 50 then what is the RTT for the Ethernet

(A). 40ms

(B). 80ms

(C). 20ms

(D).None

computer-networks

I think its link utilization 50%

T.T

% Link Utilization = T.T+2 ∗ P.T ∗ 100


T.T = 2P.T.

200

50 = 200 +R. .T.T ∗ 100


R.T.T = T.T = 200ms
.

 0 votes -- Umang Raman ( 10379 points)

9.277 what is the value of the decryption key if the value of the encryption
key is 27? top gateoverflow.in/17421

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1362 of 2244

In a system an RSA algorithm with p=5 and q=11,is implemented for data security.what is the value of the decryption key if
the value of the encryption key is 27?

a)3

b)7

c)27

d)40


Selected Answer

RSA Algorithm http://courses.cs.vt.edu/~cs5204/fall00/protection/rsa.html and example


https://www.cs.utexas.edu/~mitra/honors/soln.ht

Answer of above ,
p=5 , q=11 , encryption key(e) = 27

n = p*q = 5*11= 55
φ(n) = (p - 1) * (q - 1) = 4 * 10 = 40
Given[e = 27], d such that (d * e) % φ(n) = 1

decryption key (d) --> (d * 27) % 40 = 1


so , when d =3 than L.H.S = R.H.S

Answer option (a).

 0 votes -- Vinay Yadav ( 1739 points)

9.278 Is there any difference in between propagation delay and propagation


time or both are same ??? top gateoverflow.in/17288

A 5-stage pipelined processor has Instruction Fetch (IF), Instruction Decode (ID), Opearnd Fetch (OF), Perform Operation
(PO) and Write Operand (WO) stages. The IF, ID, OF and WO stages take 1 clock cycle each for any instruction. The PO
stage takes 1 clock cycle for ADD and SUB instructions, 3 clock cycles for MUL instruction and 6 clock cycles for DIV
instruction respectively. Operand forwarding is used in the pipeline. What is the number of clock cycles needed to execute
the following sequence of instructions?

Instruction Meaning of instruction


t0 : MUL R2 , R0 , R1 R2 ← R0 ∗ R1
t1 : DIV R5 , R3 , R4 R5 ← R3 /R4
t2 : ADD R2 , R5 , R2 R2 ← R5 + R2
t3 : SUB R5 , R2 , R6 R5 ← R2 − R6

(A) 13

(B) 15

(C) 17

(D) 19

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1363 of 2244

both are same.

 1 votes -- Amar Vashishth ( 17865 points)

9.279 Which of the following transmission media is not readily suitable to


CSMA operation? top gateoverflow.in/17272

Which of the following transmission media is not readily suitable to CSMA operation?

a)Radio

b)Optical fibers

c)Coaxial cable

d)Twisted pair

a) Radio. Wireless transceivers can't send and receive on the same channel at the same time, so they can't detect
collisions.

 1 votes -- admin ( 1411 points)

in radio a large number of channels may be there and csma cd cannot be used as , the collision may not be detected . it is
used in lan technologies where there is a physical wire.

 1 votes -- Ravi Singh ( 7303 points)

a. Radio

 1 votes -- Amar Vashishth ( 17865 points)

9.280 A packet filtering firewall can ? top gateoverflow.in/16989

A packet filtering firewall can

a)deny certain users from accessing a service

b)block worms and viruses from entering the network

c)disallow some files from being accessed through FTP

d)block some hosts from accessing the network


Selected Answer

A packet filtering firewall will be able to look only till network layer because at that layer it is called packed. so it will be
able to take decision on all the info it can see at that layer. at that layer ip of users are available . so it can discard
packets according to ip. so answer d. option a require a layer 4 firewall. (tl) option b requires layer 5 firewall (application
layer) and option c may also need layer 5 .

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1364 of 2244

 0 votes -- Ravi Singh ( 7303 points)

9.281 On a LAN ,where are IP datagrams transported? top gateoverflow.in/17270

On a LAN ,where are IP datagrams transported?

a)In the LAN header

b)In the application field

c)In the information field of the LAN frame

d)After the TCP header


Selected Answer

there is nothing called as lan frame. there are ethernet frames. so if they are talking about the ethernet frame then the
answer will be c

if question is asking where the actual data is present in a ip datagram. it is after tcp header as the ipdatagram contains
tcp segment. so it is like .

ip header | tcp header | data |||

 0 votes -- Ravi Singh ( 7303 points)

9.282 what is the number of the last byte? top gateoverflow.in/17422

A IP packet has arrived in which the fragmentation offset value is 100,the value of HLEN is 5 and the value of total length
field is 200.what is the number of the last byte?

a)194

b)394

c)979

d)1179


Selected Answer

Data length=200-4*5=180

Starting number of first byte of fragment=100*8=800

Number of last byte=800+179=979

Ans c

 0 votes -- Pooja ( 22773 points)

9.283 which of the following statements is correct? top gateoverflow.in/17439

Assume the following information.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1365 of 2244

Original timestamp value =46

Receive timestamp value=59

Transmit timestamp value=60

Timestamp at arrival of packet=69

which of the following statements is correct?

a)Receive clock should go back by 3 milliseconds

b)Transmit and Receive clocks are synchronized

c)Transmit clock should go back by 3 milliseconds

d)Receive clock should go ahead by 1 milliseconds


Selected Answer

Ans a.

This topic is from ICMP and I dont think its in GATE syllabus anymore. Still it goes like this :

Note : TS -> Timestamp

assume there is a sender and a reciever.

Original TS : Time at which sender sent packet acc to its own clock.

Recieving TS : Time at which reciever recieves that packet acc to its own clock.

Transmit TS : Time at which reciever sent a reply of that packet acc to its own clock.

Returned TS : Time at which sender of recieves the reply acc to its own clock.

=> Sending time = Recieving time - Original time

=> Recieving time = Return time - Transmit time

=> RTT = Sending Time + Recieving time (Think why ?)

RTT

=> One way time should be 2 => 10ms

=> Sender sent the packet at 46 and reciever should have recieved it at 56 , but its recieving it at 59, => its 3 ms ahead.
So it should set its clock 3 ms behind to sync with sender.

 0 votes -- CrimeMasterGoGo ( 2221 points)

9.284 Baud Rate - ISRO 2008/14 top gateoverflow.in/18449

Assume that each character code consists of 8 bits. The number of characters
that can be transmitted per second through an synchronous serial line at 2400
baud rate, and with two stop bits, is:
(a) 109 (b) 216 (c) 218 (d) 219

isro


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1366 of 2244

The baud rate is the rate at which information is transferred in a communication channel. Serial ports use two-level
(binary) signaling, so the data rate in bits per second is equal to the symbol rate
in bauds. Ref: https://en.wikipedia.org/wiki/Serial_port#Speed.

"2400 baud" means that the serial port is capable of transferring a maximum of 2400 bits per second."

So, transmission rate here = 2400 bps

An eight bit data (which is a char) requires 1 start bit, 2 stop bits = 11 bits.

So, number of characters transmitted per second = 2400 / 11 = 218.18.

Since we can only count the fully transmitted ones, we take floor = 218.

 0 votes -- Arjun Suresh ( 124125 points)

9.285 What is the primary purpose of a VLAN? top gateoverflow.in/18555

What is the primary purpose of a VLAN?

a)Demonstrating the proper layout for a network

b)Simulating a network

c)To create a virtual private network

d)Segmenting a network inside a switch or device

d)option

VLAN:actuall physically system can be placed anywhere but logically they are belonging to a group.

Network architects set up VLANs to provide the network segmentation services traditionally provided only by routers in LAN
configurations

https://en.wikipedia.org/wiki/Virtual_LAN#Uses

 0 votes -- kunal chalotra ( 3567 points)

9.286 Which of the following is not a valid multicast MAC address? top gateoverflow.in/17449

Which of the following is not a valid multicast MAC address?

a)01:00:5E:00:00:00

b)01:00:5E:00:00:FF

c)01:00:5E:00:FF:FF

d)01:00:5E:FF:FF:FF


Selected Answer

Answer : D
multicast MAC Address range of 01-00-5E-00-00-00 to 01-00-5E-7F-FF-FF

Source: http://www.aiotestking.com/juniper/what-is-a-valid-multicast-mac-address/

 0 votes -- Sahil Gupta ( 1005 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1367 of 2244

9.287 which of the following is not an address of this organization? top gateoverflow.in/17446

An organization is granted the block 130.3412.64/26.it needs to have 4 subnets.which of the following is not an address of
this organization?

a)130.34.12.124

b)130.34.12.89

c)130.34.12.70

d)130.34.12.132


Selected Answer

The 4 subnets :

130.34.12.64-130.34.12.79

130.34.12.80-130.34.12.95

130.34.12.96-132.34.12.111

130.34.12.112-130.34.12.127

So ans is d

 0 votes -- Pooja ( 22773 points)

9.288 which packet belongs to this supernet? top gateoverflow.in/17443

A supernet has a first address of 205.16.32.0 and a supernet mask of 255.255.248.0. A router receives 4 packets with the
following destination addresses.which packet belongs to this supernet?

a)205.16.42.56

b)205.17.32.76

c)205.16.31.10

d)205.16.39.44


Selected Answer

AND ip address and supernet mask whichever option gives address of supernet is the ans

Here is d the ans

 0 votes -- Pooja ( 22773 points)

9.289 Let bandwidth of a token ring is 4 Mbps top gateoverflow.in/43539

Let bandwidth of a token ring is 4 Mbps and THT be 15ms. What is the maximum frame size
and maximum payload size

computer-networks

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1368 of 2244

9.290 127 loopback address question top gateoverflow.in/16728

till which layer the loopback packet goes . i mean to ask that the lowest layer till which packet travel and then come back. I
read that it goes to data link layer . but is the point to send it to data link layer as the address 127 is know at the network
layer. at the same page i also read that it will return as the address 127 will be known . which is know at network layer . so i
m confussed till which point the packet will go .

computer-networks

It should return from Network Layer of the host in my opinion, however i was'nt able to find exact answer to this question .

Why do we have the Loopback address and why is it 127.0.0.1??? Early on when the Department of Defense in the US was designing TCP/IP, they decided that
they should reserve a portion of the space for testing. They rather randomly selected the 127 space for this purpose. In fact - it is the entire space 127 space that
they reserved. Many do not realize this, since the most common implementation is to assign 127.0.0.1. So try pinging the address 127.1.2.3 on your PC and it
might just respond if your vendor supports testing with other numbers in the reserved loopback space.

What is the fact that your machine responds to 127.0.0.1 really telling you???
This is telling you that TCP/IP is properly initialized on your device. You might not have external interfaces set up properly,but the TCP/IP stack is
indeed there and it is functional once you do the remaining required configurations.

Notice the creators of TCP/IP had no idea there would be an IP address shortage when they selected this space! They sure wasted a lot of addresses for this
testing purpose.

Remember also that you can create your own loopback interfaces on Cisco devices. For example, you can do this:

interface loopback 101
ip address 10.10.10.1 255.255.255.0

This creates a virtual interface on your device that you can use for a wide variety of purposes - like testing a feature!
reference:https://learningnetwork.cisco.com/thread/52391

 0 votes -- Anurag Semwal ( 4775 points)

9.291 ipv6 top gateoverflow.in/14485

in IPV6 what is the total number of router between source and destination.please explain every step

9.292 tcp problem top gateoverflow.in/14662

Q). Consider a TCP machine having window size 32KB over a 512Mbps channel that has one way delay of 20msec . The line
efficiency in percentage is __________.


Selected Answer

RTT = 2 * Propagattion delay (Ignoring transmission times)

= 2 * 20ms = 40 ms.

In 40ms, window size 32 KB is sent.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1369 of 2244

Efficiency = Actual data sent/Max data that can be sent

= 32 KB/ 40ms * 512Mbps

= 32 * 8/40 * 512

= 0.0125

= 1.25%

https://www.switch.ch/network/tools/tcp_throughput/?mss=1460&rtt=80&loss=1e-
06&bw=512&rtt2=40&win=32&Calculate=Calculate

 2 votes -- Arjun Suresh ( 124125 points)

9.293 Q:- why it is said that one of the key characteristic of distance vector
routing is knowledge about the entire network while one of the key
characteristic of link state routing is knowledge about the neighborhood ??
top gateoverflow.in/14005

it's question of adaptive routing protocol of computer network.

computer-networks

9.293 the message "COMPUTERNETWORKS" is encrypted using columnar


tranposition with a key "LAYER" then the encrypted code will be?? top gateoverflow.in/13190

this one is simple and intersting just make the colum arrangement as below

3 1 5 2 4

L A Y E R (assign number from 1 onwards as per aplhabetical order e.g A=1 E=2.....) IGNORE ""

C O M P U

T E R N E

T W O R K

NOW write all letters of column 1 then 2 3,4,5 and ans will be OEWPNRCTTSUEKMRO

 0 votes -- Sanjay Sharma ( 799 points)

9.293 A bridge uses IP address and router uses MAC address- true or false top
gateoverflow.in/43610

FALSE

bridge uses MAC Address

Router uses IP Addresses

 1 votes -- srestha ( 11585 points)

9.294 Given code word 1110001010 is to be transmitted with even parity


check bit. top gateoverflow.in/13111

Given code word 1110001010 is to be transmitted with even parity check bit. The encoded word to be transmitted for this

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1370 of 2244

code is
(A) 11100010101 (B) 11100010100
(C) 1110001010 (D) 111000101

computer-networks ugcnet-june-2013-3


Selected Answer

i think the answer is A) .

because even parity will make it even no of 1`s , i mean see in the transmitted data 1110001010 there are five 1 which is
odd . to make it even it will add extra 1 as parity . so it will be 11100010101 .

 4 votes -- Pranay Datta ( 6113 points)

9.295 In stop and wait protocol , every 4th packet is lost.Find number of
packets ? top gateoverflow.in/14772

In stop and wait protocol , every 4th packet is lost.If 8 packets are being sent, Find number of packets ?

Answer given is : 10

Shouldn't Acknowledgements considered as well , in such case answer should be 18 , Right ?


Selected Answer

Stop and Wait are easy to calculate- a resent happens only for the lost packet.

After 4 sends, we have a loss.

So, packet 4 lost, resent.

Packet 7 lost (since 4 was resent), resent.

So, totally 2 packets needs to be resent out of 8- 10 packets needs to be sent.

ACK won't be counted as packets as they are usually very very small.

 2 votes -- Arjun Suresh ( 124125 points)

9.296 255.255.31.0 how many number of subnets and hosts are there if it is
subnet mask. top gateoverflow.in/15197

Which combination of the following features will suffice to characterize an OS as a multi-programmed OS?

(A) More than one program may be loaded into main memory at the same time for execution.
(B) If a program waits for certain events such as I/O, another program is immediately scheduled for execution.
(C) If the execution of a program terminates, another program is immediately scheduled for execution.

A. A
B. A and B
C. A and C
D. A, B and C

so as we know that there are 5 classes where d and e class are not used for networking and there is no subnet in them .

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1371 of 2244

so basically if classes is not given subnet can vary .but here it is simple d and e cannot be used so we just ruled out the d
and e definitely this is class c network. subnet mast that tells the number of 1 bits in the network id field are 8+8+5=21.
no of subnet will be see the last octate . 8-5=3 so we have actually borrowed 3 but from the network id .so number of
subnet will be 2^3=8 . 2^ because by one bit i can only represent 2 possiblity

assuming classfull ip addressing. for cidr the data is insufficient to tell the number of subnets.

 2 votes -- Ravi Singh ( 7303 points)

9.296 what are the ip address used by CIDR address 192.168.10.0/20 give
the range top gateoverflow.in/15914

the /20 states that there are 20 network bits in this so just leave them and for range just put all 0's in host bits and then
all 1 in that .
192.168.00001010.00000000.. so range will be from 192.168.0.0 to 192.168.15.255. note that you are given an ip in
this range it does not means that range will start after it only .

 0 votes -- Ravi Singh ( 7303 points)

9.297 subnets top gateoverflow.in/16625

The subnet mask for a particular network is 255.255.252.0. Which of the following pairs of
IP addresses could belong to this network?
A. 172.57.88.62 and 172.57.87.233
B. 10.35.28.2 and 10.35.29.4
C. 191.203.31.87 and 191.234.31.88
D. 128.8.129.43 and 128.8.131.42


Selected Answer

Option b as in this pairs both have the same network id as 10.35.28.0

 0 votes -- ANI ( 503 points)

9.298 Computer Networks : Number of repeaters top gateoverflow.in/15768

To prevent signal alteration, what is the maximum number of repeaters that can be placed on one 10 Base 5 or 10 Base 2
network?

computer-networks


Selected Answer

the answer is 4

The IEEE802.3 specifications state the rules of network extension. The maximum number of the repeaters that can be used in one transmission path between two nodes is four, the
maximum number of network segment between two nodes is five.

 0 votes -- Ravi Singh ( 7303 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1372 of 2244

9.299 Computer Networks - IEEE 802.4 top gateoverflow.in/15645

Imagine 2 LAN bridges, both connecting a pair of 802.4 networks.The first bridge is faced with 100 512 byte frames per
seconds that must be forwarded. The second is faced with 200 4096 byte frame per second. Which bridge do you think will
need the faster CPU?

I know that the answer is first case but why ? Acc to me the context switches and all depends on the number of frames
passing through point which is higher in second case. So how is it that ans if first case ?

computer-networks

The 100 frames/sec bridge would need a

faster CPU. Although the other one has a

higher throughput, the 100 frames/sec

bridge has more interrupts, more process

switches, more frames passed and more of

everything that needs the CPU.

 0 votes -- Rohan Ghosh ( 1515 points)

9.300 Computer Networks, Baud Vs Bit Rate top gateoverflow.in/15622

At some places it is written that Baud rate = 2 * Bit rate and some places its written that Bit rate = 2 * Baud rate? I am
confused, what is the relation between the two ?

computer-networks

Bit rate is a measure of the number of data bits (that's 0's and 1's) transmitted in one second. A figure of 2400 bits per
second means 2400 zeros or ones can be transmitted in one second, hence the abbreviation 'bps'. Baud rate by
definition means the number of times a signal in a communications channel changes state.It may vary.like in Manchester
encoding and differential Manchester encoding baud rate= 2*bit rate.

Baud rate is mostly used in telecommunication and electronics, representing symbol per second or pulses per second,
whereas bit rate is simply bit per second. To be simple, the major difference is that symbol may contain more than 1 bit,
say n bits, which makes baud rate n times smaller than bit rate.

Suppose a situation where we need to represent a serial-communication signal, we will use 8-bit as one symbol to
represent the info. If the symbol rate is 4800 baud, then that translates into an overall bit rate of 38400 bits/s. This could
also be true for wireless communication area where you will need multiple bits for purpose of modulation to achieve
broadband transmission, instead of simple baseline transmission.

 1 votes -- Rohan Ghosh ( 1515 points)

9.301 How to determine the length of the cable? top gateoverflow.in/17651

(100Base5) is thick Ethernet = Bandwidth of 100 Mbps and the maximum length of cables

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1373 of 2244

is 500 meters .
Now ,we have-->Bandwidth = 100 Mbps

Length of cable = 500 m , velocity = 2*10^8 m/s


(example-http://gateoverflow.in/966/gate2003_83?show=966#q966)

Propagation time = length of cable / velocity


= 500 / 2*10^8 = 2.5 microsec
Transmission time for x bits = x / 100*10^6

= 0.0x microsec
[ As CSMA/CD ,transmission time must be greater than twice the propagation delay ]

So, 0.0x > 2*2.5 --> x > 500 bits .


Answer --> 500 bits.

 0 votes -- Vinay Yadav ( 1739 points)

9.302 Digital Signature vs. Encryption? top gateoverflow.in/37008

in terms of confidentiality.
digital signature ncrypts the message but doesnt provide confidentiality.
WHY?

What my understanding is that

Digital Signature is used to provide authenticity


To check who sends the msg nad time

It encrypt the contents using senders private key anybody can open it using public key and It just ensure the authenticity
and integrity of the msg .

However

Confidentiality can be provided by further encrypting the entire message plus signature with either the receiver's public
key (public-keyencryption) or a shared secret key (symmetric encryption)

 2 votes -- Akhil Nadh PC ( 1967 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1374 of 2244

9.303 Aloha top gateoverflow.in/33780

Plz explain it .

its made easy question, they have provided solution for A and marked C as correct


Selected Answer

Totalnumberofrequest / second

Totalchannelload = Totalnumberofslots/ second

As average station makes 36 request / hour. So each station makes a request every 3600 sec / 36 request = 100 sec.

Total load is 10000 requests per 100 sec, i.e., 10000 / 100 = 100 request per second.

Number of slots in 1 second = 1 sec / 100 microsec = 10000 slots per second.
100 1
10000 100
Totalchannelload = =

 0 votes -- prathams ( 1141 points)

9.304 exponential backoff top gateoverflow.in/29948

Nodes A and B are connected with 100 Mbps ethernet segment with 6 microsec pop.delay between them.Suppose A,B send
frames at t=0 and frames get collided.after first collision A draws k=0 and bdraws k=1.if jam signal is ignored and timeout is
1 RTT then at what time A's packet gets completely delivered to B...assume packet size 1000 bits.

a)28 microsec

b)16 microsec

c)22 microsec

d)38 microsec


Selected Answer

at t=0 both A and B transmit and after 1RTT i.e (TT+2PT) =10+12 =22 microsecond collision detected

A will again transmit while B wait for P.T i.e(6 microsecond) and A segment reach B after TT+PT=10+6=16

therefore after 22+16 =38 microsec A segment delivered to B

 2 votes -- saurav04 ( 649 points)

9.305 How long does it take for the packet to get to the receiver? top gateoverflow.in/33787

Consider a route in a store and forward network going through 9 intermediate nodes. The packet contains 1100 bits and are
transmitted at 64 Kbps. Assume propagation delay over the links are negligible. As a packet travels along the route, it

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1375 of 2244

encounters an average of 5 packets when it arrives at each node. How long does it take for the packet to get to the receiver if
the nodes transmit on a "first come first served" basis (in ms) ?

computer-networks


Selected Answer

945.3125 msec (Ans)

Here, packet goes like this - sender > 9 intermediate nodes > receiver
Frame Size

Transmission Time for one packet (T.T.) = Bandwidth


1100 bits
64 Kbps
= = 17.1875 msec

whenever a packet is transmitted by a node , it eventually get received by

next node immediately , as propagation delay is negligible.

After one T.T. it is received by next node , when it encounters 5 more

packets which are to be transmitted before it (FCFS used).

So, for this packet to be transmitted for first intermediate node = 6 * T.T.

so, it gets received immediately by 2nd intermediate node (tp = 0)

So, Total time = T.T. + 9 * (6 T.T.) { At Sender 1 T.T. & at each

Intermediate node 6 T.T.}

= 55 T.T. = 55 * 17.1875

= 945.3125 msec (Ans)

 0 votes -- Himanshu Agarwal ( 8861 points)

9.306 error rate top gateoverflow.in/33813

my ans 25

9.307 GBN top gateoverflow.in/33818

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1376 of 2244

my ans 19


Selected Answer

My Answer is

 0 votes -- shivanisrivarshini ( 2067 points)

9.308 line efficiency top gateoverflow.in/33814

solve in detail...........

Line efficiency = throughput / bandwidth ----- (1)

Throughput = window size / rtt ------(2)

So throughput = 65535/40 * 10^3 = 1638375

And bandwidth = 512 Mbps

Therofore Line efficiency(in %) = 2.56

 0 votes -- rj123 ( 11 points)

9.309 Link utilization top gateoverflow.in/33649

Bandwidth of a link is 1000 Mbps and RTT is given as 250 micro seconds. If frame size is 500 bits. the utilization(in %age) of
channel when stop and wait ARQ used is _________.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1377 of 2244

computer-networks


Selected Answer

lu%=(TT/TT+2PT)*100
TT=data/ bandwidth
=500/1000*106
=0.5 microsec

RTT=250microsec
so LU %=(0.5/0.5+250)
=0.5/250.5
=0.00199 *100
=0.199

≅0.2(ans)

 1 votes -- kunal chalotra ( 3567 points)

9.310 Offset value of last segment top gateoverflow.in/33626

computer-networks


Selected Answer

no of packets= 1 ceil [200/280]=5

so offset of fifth ie last packet= starting address of fifth packet /8=1120/8=140 (1120 as 4 packets carry 1120 bytes)

 2 votes -- Pooja ( 22773 points)

9.311 Router top gateoverflow.in/30001

The intermediate router between source and destination do not need the following information in IP header

a.Protocol

b.Identification number

c.Source IP

d.Version

ans given = ALL FIELDS ARE REQUIRED.

But according to me Identification number is not required at router. because identification number is used for
reassembling of packets. and Reassembling is not done at router.

plz clarify.......

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1378 of 2244


Selected Answer

Identification no is even required in Routers becase

Routers do Fragmentation of packets in case of MTU size is less than packet size. They will need to include Identification
no in Fragments !

 4 votes -- Akash ( 26315 points)

Yes, Protocol, Identification number, Source IP and Version, all are required by the intermediate routers.

Identification number is required due to fragmentation done my the intermediate routers. In case of MTU size is less than
the size of the packet, so here identification number is required in fragments.

Protocol, Source IP and version are also necessary to process and send the packets correctly.

 1 votes -- Monanshi Jain ( 5827 points)

9.312 window size top gateoverflow.in/30070

the round trip delay between sender and receiver is 160ms and the bottleneck bandwidth of the link is 256 kbps.Sender uses
sliding window protocol to send a 64 byte packet.The optimal size of the window that sender should use is ?

Optinal window size=bandwidth delay product/packet size

=256kbps*160ms/64*8

=80

 3 votes -- Pooja ( 22773 points)

The optimal window size (W) =2CI/F

here C is channel capacity or bandwidth

2I is round trip delay(I is for one way propagation delay)

F is frame size or packet size

W=(256*10^3*160*10^-3)/(64*8)

=80bits.

 1 votes -- pritika kundu ( 677 points)

9.313 Contention top gateoverflow.in/33440

What is difference between contention and contentionless protocol

9.314 Contention top gateoverflow.in/33441

What is difference between contention and contentionless protocol

9.315 Sliding Window Protocol top gateoverflow.in/33582

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1379 of 2244

Assume that SWP is designed for a 1mbps point to point link to the moon which has 1 way latency(delay) of 1.25sec
Assuming that each frame carry 1KB of data, find

1. number of sequence number required

2. number of bits required to represent sequence number.

for 1st question i got ans 306.17, is it accepted or we have to round


it as 307
plz clarify

no of seq no = no of window size = n

n = tx+2tp / tx

tx = 8 * 10^-3 / 10^-6 = 8 ms

tp = 1250 ms

so, n = (2500+8) / 8 = 313.5 so,314 0r 313

no of bits = ceil(log 313) = 9 .

 1 votes -- Sayantan Ganguly ( 5061 points)

9.316 Stop and wait top gateoverflow.in/29970

if packet size is 1KB and propogation time 15msec, channel capacity 10^9 b/s , find transmission time and sender utilization in stop and wait protocol ?


Selected Answer

transmission time = 10^3*8/10^9 = 8*10^-6 s.

utilization = 8*10^-6/(8*10^-6+30*10^-3) =2.66*10^-4

 2 votes -- Sayantan Ganguly ( 5061 points)

9.317 DBA top gateoverflow.in/33822

9.318 Packet size top gateoverflow.in/33823

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1380 of 2244

Distance from Station A to Satellite = 6000 * 10 3 m

Time to reach satellite = 6000 * 10 3 / (3 * 108) = 0.02 sec

RTT = 4 * Time to reach satellite( A -> S : S -> B : B -> S : S -> A)

Efficiency = 63 * T t / (Tt + 4 * 0.02)

0.5 = 63 * T t / (Tt + 4 * 0.02)

0.5 * T t + (0.5 * 4 * 0.02) = 63 * T t

Tt = 6.4 * 10 -4 sec

Tt = Packet Size / Link BW

Packet Size = 6.4 * 10 -4 * 1 * 10 6 bits = 640 bits = 80 bytes.

 0 votes -- prathams ( 1141 points)

9.319 subnet top gateoverflow.in/34033


Selected Answer

My Answer is

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1381 of 2244

 1 votes -- shivanisrivarshini ( 2067 points)

9.320 Binary exponential backoff top gateoverflow.in/33985

if 50 stations are there and if each slot contain 25 microsec then what would be max waiting time for a station for safe
transmission
a)200 b)300 c)250 d)400

In binary exponential backoff, the threshold or limit of collision is upto 10 collision.

as each slot contain 25 microsec.

max waiting time 250 microsec.

 0 votes -- Sayantan Ganguly ( 5061 points)

9.321 switching top gateoverflow.in/34047

A sends 2 frames of 1000 bit each to B via switch S.Bandwidth=10Mbps propogation delay over links=5us find time when
second packet reaches B completely

Frame 2 will be recieved at reciever after ≈ 310 µs ,if switch uses a store and forward mechanism.

http://inst.eecs.berkeley.edu/~ee122/fa09/notes/04-Performancex6.pdf

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1382 of 2244

 0 votes -- bahirNaik ( 2479 points)

9.322 ethernet top gateoverflow.in/34050

If RTT is 40 ms and transmission delay is 200 ms then what is throughput of Ethernet?

a)55% b)67% c)50%d)none

ethernet uses csma/cd ..

so efficiency of ethernet=1/6.44+a

a=propogation delay/transmission delay=20/200=0.1

efficiency=1/1.644=60.8%

now bandwidth of standard ethernet =10 mbps..

so throughput=efficiency*throughput=60 kbps(approx)

 0 votes -- sourav anand ( 1585 points)

9.323 Please explain? top gateoverflow.in/34065

A 8-node network runs the carrier sense Multiple Access (CSMA) MAC protocol. The maximum data rate of the network is 10
Megabits/s. Including retries, each node sends traffic according to some unknown random process at an average rate of 1
Megabit/s per node. Given that the network's utilization is 0.75. No packets get dropped in the network except due to
collisions, and each node's average queue size is 5 packets. What fraction of packets sent by the nodes (including retries)
experience a collision?_________% (correct to two decimal places).

9.324 Backoff Time period top gateoverflow.in/34051

A and B are the only two stations on an Ethernet. Each has a steady queue of
frames to send. Both A and B attempt to transmit a frame, collide, and A wins
the first backoff race. At the end of this successful transmission by A, both A and B attempt to transmit and collide. The
probability that A wins the second backoff race is
(a) 0.5 (b) 0.625 (c) 0.75 (d) 1.0


Selected Answer

After 2nd Collison a collision no =1 and B collision no=2(as A win first race)
So possible cases are
A B
0 0
0 1
0 2
0 3
1 0
1 1

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1383 of 2244

1 2
1 3
Thus p (a win 2nd Collison )=5/8=.625

 2 votes -- komal07 ( 905 points)

9.325 RSA Algorithm top gateoverflow.in/29531

Here p=3 and q=5,

Φ(n)= (p-1) (q-1)

Φ(n)=2*4 = 8

and e=9 and e*d mod Φ(n)=1

for d=1 this evaluates to 1. So value of d is 1.

 1 votes -- amantanwar2 ( 21 points)

9.326 fermats thm top gateoverflow.in/29945

Is there any relation between Fermats Th m and Primitive root

This two are related in manner:-

Fermat's little theorem states that if p is prime and , then

This will simply give you whether a number is prime or not. Now the point is whatever the value you choose for a will give
that both 'a ' and 'p' are coprime to each other so that coprime concept we use while finding primitive roots. For
example if you want to find whether number 3 is primitive root of modulo 7 then you have to take in consideration
coprimes of 7 which you can do with Fermat's Little Theorem.

So these both concepts covered in single roof i.e. Number Theory

 1 votes -- Abbas Gabru ( 49 points)

9.327 TCP MSS top gateoverflow.in/33825

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1384 of 2244


Selected Answer

slow start

transmission attempt MSS

0 2 KB

1 4 KB

2 8 KB

3 16 KB

4 32 KB .......... as timeout occurs at attempt no 4 ..

now new threshold = 32 / 2 =16 KB .. again it statrts from initial segment size

5 2 KB

6 4 KB

7 8 KB

8 16 KB ............. threshold reached ...now additive increase

(NB:in some problem we add initial mss size given in problem in additive increase,in some case we add 1 mss .gate will
give marks for both)

9 17 KB

10 18 KB

so answer is 18 KB.

(if we take initial mss size then answer will be 20 KB ,but as per definition 18 KB will be the answer)

 1 votes -- Sayantan Ganguly ( 5061 points)

9.328 Subnet top gateoverflow.in/33824

The router connecting a company's network to the internet applies the mask 255.255.255.192 to the
destination address of incoming IP packets. If one of the incoming packet has a destination address of
154.33.7.220, then find the network ID, subnet bits and host ID bits of incoming packets respectively
a. 154.33.7, 11. 011100
b. 154.33, 11000000. 011100
c. 154.33, 0000011111. 011100
d. 154.33.7. 011111. 011100

My Answer is

Since IP is 154.33.7.220 so it belongs to Class B
so the network bits are first 16 bits
Therefore network id is 154.33.0.0

Subnet mask is 255.255.255.192

In subnet mask number of 1's represent Network or subnet bits

255.255.11111111.11000000
and 154. 33.00000111.11011100
--------------------------------------------
154.33. 00000111.11 011100
------------------ -----------
subnetid hostid

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1385 of 2244

 0 votes -- shivanisrivarshini ( 2067 points)

9.329 efficiency top gateoverflow.in/33826


Selected Answer

--> Each node transmit 50 frames per second (given).

--> Frame length = 2500 bits , Number of nodes = 100 , Transmission rate = 10^8 bps (given).

--> So, Bits transmit by 100 node = 2500*100*50 = 125*10^5 bps

--> Efficiency(%) of Protocol = (125*10^5 / 10^8 )*100 = 12.50% .

 1 votes -- Vinay Yadav ( 1739 points)

9.330 Fragmentation top gateoverflow.in/33827

header size not given.


Selected Answer

mtu is 480.

payload is 460 B.

A sends payload 1600 B to B

so total data A sends to B = (460+20,460+20,460+20 ,220+20) = 1680 B.

 2 votes -- Sayantan Ganguly ( 5061 points)

9.331 Slow start top gateoverflow.in/33834

my ans 65ms

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1386 of 2244

slow start

mss - 2 KB

4 KB

8 KB

16 KB

32 KB

as no congestion ..no threshold...

so total 4 RTT.. (considering 2 to 4 ,1 RTT...in this way4 to 8,8 to 16,16 to 32)

5 th RTT will be 32 to 64 KB

so before 5 th RTT full window can be sent..

so total 4 RTT will be needed.

total time =4*5 = 20 millisec

 1 votes -- Sayantan Ganguly ( 5061 points)

9.332 Stop n wait top gateoverflow.in/32983

A channel has propagation delay of 10 ms .For 320 bits frame what will be channel bit rate if stop -n-wait give efficiency of
50%?

I have solved this using 2 approaches but getting different answers(as in the picture). Can anyone plz explain where i am

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1387 of 2244

wrong?

Your first approach is not understandable. Why are you multiplying propagation delay with the Bandwidth? I think it will
not give total amount of data that could be sent.
Method 2 is correct.

 0 votes -- Monanshi Jain ( 5827 points)

9.333 Selective repeat top gateoverflow.in/32953

A computer uses the following sequence numbers:0,1,2,3,4,5,6,7,0,1,2,3,...

What will be sender's and receiver's window size that are not possible in SR protocol?

a )4,4 b)5,3 c)7,1 d)5,4

D. 5,4

Since in SR, Ws+Wr = Sequence number


Here sequence number is 0 to 7 = 8 and 5+4=9 thus 5,4 is wrong.

C. option is also wrong,


Wr, Ws both should not be 1 in SR, as Ws=7 here, it will become Go Back N.

 0 votes -- Shashank Chavan ( 2439 points)

9.334 Ip addressing top gateoverflow.in/31144

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1388 of 2244

http://gateoverflow.in/?qa=blob&qa_blobid=18152128369856966495

9.335 assume 10 Mbps Ethernet and two station A and B on it's same
segment....... top gateoverflow.in/30343

assume 10 Mbps Ethernet and two station A and B on it's same segment. The RTT between two nodes is 650 bit times. A and
B start transmitting frame and collision occure and both sends 30 bit jam signal. find the time at which both nodes A and B
sense an idle channel(in micro sec)_____

RTT + 1 Propagation delay

65microsec + 32.5 microsec=97.5

 0 votes -- Er Lucky ( 309 points)

9.336 Ttl top gateoverflow.in/31222

http://gateoverflow.in/?qa=blob&qa_blobid=3365268112291698752

21

TTL field is modified only at Network layer. When a packets routes through Router/Network layer it checks the value of
TTL field and accepts the packets and decrements the value of ttl by 1 if it is not 0. In Case if it is 0 then network layer
simply discards the packets. LANs (HUbs) work at data link layer. Here packets is passing through 2 routers R1 and R2. so
at the router it will be decremented to 24-1-1 = 22. Now t the Receiver end also it will pass through Network layer and
there also it will be decremented by 1. Finally at the Receiver end value of TTL field will be 22-1 = 21.

 1 votes -- Abhishek Kumar ( 71 points)

9.337 check the question top gateoverflow.in/30168

100 nodes are connected to a 1000 meter length coaxial cable,using some protocol each node can transmit 50 frames/sec.

where the average frame length is 2500 bits.the transmisson rate at each node is 100 mbps.what is the numeric value of
efficiency of the protocol(in %)?

80%....

Given configuration can send only 40 frames instead of 50 frames...

 1 votes -- Er Lucky ( 309 points)

9.337 Sliding window protocol top gateoverflow.in/31789

9.338 computer top gateoverflow.in/31470

Why CWS = 1 and increase it at an exponential rate to catch up to SSThresh before slowing down ?

If TCP knows that the congestion is near TWS = SSThresh, then why not just set CWS = SSThresh ?

(CWS =congestion win size,TWS =Transmission win size,SST hresh =slow start thresold )

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1389 of 2244

computer-networks

9.339 TCP slow start right ans???????????? top gateoverflow.in/31065

Im not sure whether question is wrong.


Here it is how i did it,
1st rtt 1packets
2nd rtt 2packets
3rd rtt 4packets

nth rtt 2^n-1 packets

Hence, Summation of packets will be (2^n+1 - 2)

To transmit 2000MB , 1000 packets are needed.

1000=2^n+1 - 2
log 998 = n+1
n= 9.96-1
n= 8.96 for 1000 packets

thus n transmission each with 100sec = 8.96*100 = 896/60 = 14.93 minutes

You can also calculate direct but for 9th(summation will be 1023) packet you will get 900/60 = 15 minutes

 1 votes -- Shashank Chavan ( 2439 points)

9.340 Suppose host A want to send a large file to host B. .. top gateoverflow.in/30344

Suppose host A want to send a large file to host B. the path from host A to host B has 3 links of rates R1=512 Kbps, R2=2
Mbps and R3=1 Mbps. what is the throughput for the file transfer(in Kbytes per minuts)_____

512 kbps....

They r connected in series even though one of channel is fast it has to wait for another channel to complete it's work...till
ack come from the slower channel or data comes from slower channel...faster channel has to wait...

 0 votes -- Er Lucky ( 309 points)

9.341 Kurose Ross Chapter 5 Q 52 top gateoverflow.in/30779

P52. Consider a network in which all nodes are connected to three other nodes. In

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1390 of 2244

a single time step, a node can receive all transmitted broadcast packets from
its neighbors, duplicate the packets, and send them to all of its neighbors
(except to the node that sent a given packet). At the next time step, neighboring
nodes can receive, duplicate, and forward these packets, and so on. Suppose that uncontrolled flooding is used to provide broadcast in such a
network. At time step t, how many copies of the broadcast packet will be
transmitted, assuming that during time step 1, a single broadcast packet is
transmitted by the source node to its three neighbors.

computer-networks

Here u will get ternary tree

There will be root node having three children

Then this nodes will have 2 children( 2 because it already connected to it parent node)

At step 1 3 packet

At step 2 3*2=6 packet

At step 3 6*2=12 packet

So at step t =3×2^t-1

 4 votes -- Pooja ( 22773 points)

9.342 Patterson Chap 1 Foundtion Q 2 top gateoverflow.in/30808

Calculate the total time required to transfer a 1000-KB file in the


following cases, assuming an RTT of 50 ms, a packet size of 1 KB
data, and an initial 2 × RTT of “handshaking” before data is sent:
(a) The bandwidth is 1.5 Mbps, and data packets can be sent
continuously.
(b) The bandwidth is 1.5 Mbps, but after we finish sending each
data packet we must wait one RTT before sending the next.
(c) The bandwidth is “infinite,” meaning that we take transmit
time to be zero, and up to 20 packets can be sent per RTT.
(d) The bandwidth is infinite, and during the first RTT we can
send one packet ( 21−1), during the second RTT we can send
two packets (22−1), during the third we can send four ( 23−1),
and so on. (A justification for such an exponential increase
will be given in Chapter 6.)

computer-networks

part a)

Initial Handshaking = 2 * R.T.T. = 2*50 ms = 100 ms

we can send continuously :

to send 1000KB file, & BandWidth is 1.5 Mbps..

So, time to transmit is 1000KB / 1.5 Mbps = 5333.33 ms

Total Time = T.T. + Initial Handshaking time


= 5333.33 + 100 = 5433.33 ms

part b)

Initial Handshaking = 2 * R.T.T. = 2*50 ms = 100 ms

time to send 1 packet = 1KB / 1.5 Mbps = 16 / 3 ms

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1391 of 2244

Inter packet gap = 1 R.T.T. = 50 ms

Total Time = Initial Handshaking time + 1000 packets T.T.

+ 999 * R.T.T.(waiting time)


= 100 + 1000(16/3) + 999(50)

= 55383.33 ms = 55.38 sec.

part c)

Initial Handshaking = 2 * R.T.T. = 2*50 ms = 100 ms

packet size is 1 KB , so 1000 packets will be transmitted ,only 20 per R.T.T.

So, it takes 1000 / 20 = 50 R.T.T.

but in last R.T.T , transmission time is '0' , so we will not consider it

=> 49 R.T.T. = 2450 ms

Total Time = Initial Handshaking time + packets T.T.

= 100 + 2450 = 2550 ms

part d)

Initial Handshaking = 2 * R.T.T. = 2*50 ms = 100 ms

1000 packets to be transmitted ,

In 1st R.T.T = 1 packet

In 2nd R.T.T. = 2 packet

In 3rd R.T.T. = 4 packets & so on

like this we will take 10 R.T.T.

But again in last R.T.T time taken will be '0' , so will not consider this

=> 9 R.T.T = 450 ms

Total Time = Initial Handshaking time + packets T.T.

= 100 + 450 = 550 ms

 1 votes -- Himanshu Agarwal ( 8861 points)

9.343 Subnet top gateoverflow.in/30773

What could be the network mask if DBA of a network is 168.17.07.255?

A 255.255.248.0

B. 255.255.252.0
C. 255.255.254.0
D. 255.255.255.0


Selected Answer

For DBA of network all host bit should be 1

168.17.00000111.11111111

a. 255.255.11111000.00000000
b.255.255.11111100.00000000
c.255.255.11111110.00000000

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1392 of 2244

d.255.255.11111111.00000000

so i think all can be network mask for it.

 0 votes -- Umang Raman ( 10379 points)

9.344 Computer networks top gateoverflow.in/30769

A group of N stations share 100 Kbps slotted ALOHA channel. Each station output, a 500 bits frame on an average of 5000
ms; even if previous one has not been sent. What is the required value of N?

Each Station Throughput = 500/5000 = 100bit/sec


therefore for N station = N * 100 bits / sec

Throughput of slotted aloha = .368 * 100Kbps

Therefore .368*100*10^3 = N*100


N= 368

 1 votes -- Umang Raman ( 10379 points)

9.345 Data Link Layer top gateoverflow.in/30612

Compute the fraction of the bandwidth that is wasted on overhead (headers and retransmissions) for protocol 6 on a heavily
loaded 50 kbps satellite channel with data frames consisting of 40 header and 3960 data bits. Assume that the signal
propagation time from the earth to the satellite is 270 msec. ACK frames never occur. NAK frames are 40 bits. The error rate
for data frames is 1% and the error rate for NAK frames is negligible. The sequence numbers are 8 bits.

computer-networks

Let's take total 100 packets has to send 1% error means 1packet lost...

total overhead = 40*100+ 4040(retransmission of packet)

Total overhead / total data sent=

(8040/100*4000+4040)*100%

=1.989% overhead

So 100% equals 50kbps then 1.989%

Gives almost 1kbps

 3 votes -- Er Lucky ( 309 points)

9.346 No. of RTTs. top gateoverflow.in/31857

Ans is 5 RTT ,but I think it should be 4 RTTs. Please correct me.

9.346 What is RTT? It is 2*Propagation delay or Transmission


time+2*Propagation delay? top gateoverflow.in/31909

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1393 of 2244

RTT = 2*Propagation delay.

 0 votes -- prathams ( 1141 points)

9.347 Synchronous bits top gateoverflow.in/32766

Can Any Body Explain ?

test-series computer-networks

9.348 Time division multiplexing top gateoverflow.in/32736

A link carries data from n connections. In TDM, the data rate of link is _______ time faster and uni-duration is
________________ time shorter than a single link connection.

a)n,n

b)(n+1),(n+1)

c)n, n+1

d)(n+1),n

Please explain

9.349 TCP top gateoverflow.in/30071

let the size of the congestion window of a TCP connection be 32KB.When time out occurs the maximum segment size used is
2KB.If the time taken by the TCP connection to get 32 KB congestion window size is 480 ms than the RTT is??


Selected Answer

2---4---8---16---18---20--22--24---26--28--30---32

12RTT=480ms

1RTT=40ms

 3 votes -- Pooja ( 22773 points)

9.350 Pick the systems that can be used in both priority and non-priority
modes top gateoverflow.in/32819

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1394 of 2244

computer-networks

9.351 When a signal travels through a transmission medium top gateoverflow.in/32821

When a signal travels through a transmission medium, its power becomes 100 times. Then there would be power

(a) Gain of 100 (b) Loss of 100

(c) Gain of 20dB (d) Loss of 20dB


computer-networks made-easy

9.352 The parameter which gives the probability top gateoverflow.in/32820

computer-networks made-easy

9.353 manchester encoding top gateoverflow.in/32735

Which of following options is not an useful property of manchester line code for ethernet

a)continuous energy

b)continuous clock transition

c)no dc component

d)no signal change at 1 to 0 transition

9.354 SWP top gateoverflow.in/30124

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1395 of 2244

try this...........

optimal window size=bandwidth delay product/frame size

=160ms*256kbps /64*8

=80

 0 votes -- Pooja ( 22773 points)

9.355 Subnet and addresse top gateoverflow.in/30135

plz solve it.......

An organization is granted the block 150.36.0.0/16.The administrator wants to create 512 subnets. Find number of
addresses in each subnet.

number of address and no. of hosts are same or different ?

clarify.....

Number of subnet = 512 i.e 9 bits


so total bits for subnetting 16+9 = 25

so host bits are 32 -25 = 7

therefore total number of address = 2^7 = 128


total host address = 128 -2 = 126

 3 votes -- Umang Raman ( 10379 points)

no of bits for host=32-16-9=7

so no of host =2^7-2=126

no of address=128

 3 votes -- Pooja ( 22773 points)

9.356 Checksum top gateoverflow.in/32022

What will be the sum of the checksum and data if there are no errors?-0 or +0?This question is from Arihant

It should be +0, since we get all digits 0 in the answer if the data is correct. For -0 we should get a negative sign 1 in the
beginning of the digits.

 0 votes -- Utk ( 1385 points)

9.357 congestion window top gateoverflow.in/32169

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1396 of 2244


Selected Answer

Threshold = congestion window/2 = 32/2 = 16 KB.

first approach...

MSS - 2 KB

4 KB

8 KB

16 KB THRESHOLD reached,now additive increase

18 KB

20 KB

22 KB

24 KB

26KB

28KB

30 KB

32 KB

total 12 RTT

12 RTT take 480 ms

so RTT = 40 ms

2 nd approach

MSS - 2 KB

4 KB

8 KB

16 KB THRESHOLD reached,now additive increase

17KB

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1397 of 2244

18KB

19 KB

20 KB

21 KB

22 KB

23 KB

24 KB

25 KB

26 KB

27 KB

28 KB

29 KB

30 KB

31 KB

32 KB KB

20 RTT =480 ms

RTT= 24 ms.

I did it 2 way cause,some solution considers ,in the time of additive increase ,just add the the initial mss size,some
solution consider it as strictly 1 mss.

REF:

1. http://gateoverflow.in/2156/gate2012_45

2. http://gateoverflow.in/1794/gate2014-1_27

one qs consider it 1 mss ,though initial size has given as 2 mss

and other consider it as 2 mss.

 1 votes -- Sayantan Ganguly ( 5061 points)

9.358 TTL top gateoverflow.in/32208

Which of the following is the purpose of TTL field in DNS record?

1) If a record is lost during transmission , it will not circulate endlessly

2) Cached copies of the record will expires automatically

3) Redundant servers can trace the record back to it's creation time so that it can be validated

4) None of these


Selected Answer

Should be 2 cached copies expire automatically after sotme time.this is done to get fresh data ue updated data and not
cached data

 4 votes -- Pooja ( 22773 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1398 of 2244

9.359 backoff top gateoverflow.in/32209

First Backoff Race (X(0,1) ,Y(0,1))possible combinations : (0,0) (0,1) (1,0) (1,1)

Here Y wins implies (1,0)

Second Backoff Race (x,Y) possible combinations: ((here x packet is getting in collision second time so for X(0,1,2,3) and
Y(0,1))

Now there are 8 possibilities out of which 1 is where x wins i,e.,(0,1)

so ans is 1/8 = 0.125

 3 votes -- Prabhanjan R ( 747 points)

9.360 compute the fraction of bandwidth that is wasted on overhead on a


50Kbps satellite ? top gateoverflow.in/28666

compute the fraction of bandwidth that is wasted on overhead on a heavily loaded 50kbps satellite channel with data frames consisting of 40 header and 3960 data
bits .
ACK frames never occur.NAK frames are 40 bits .Error rate for data frames is 1% and error rate for NAK frames is negilgible .
In this one it is not mentioned how many frames do we send so then how can we calculate total no of bits in this ?

Out of 100 frames send 1 will be lost.

Total data bits = 3960*100 bits


total size of Hader= 40 *100 bits
Nak= 40 bits

when the sender receives NAK,

It will send a data frame again,( the frame size is 4000 bits)

Total wastage= (4000) lost data frame + (4000) retransmit lost data frame + (40) Nak bits = 8040 bits

 2 votes -- Anirudh Pratap Singh ( 4091 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1399 of 2244

9.361 Record Route top gateoverflow.in/34174

computer-networks

is the answer 11?

 0 votes -- Nitin Sharma ( 379 points)

9.362 Time Delay in Circuit Switching top gateoverflow.in/36954

A and B are 4 hops apart on a Circuit Switched Network where each hop is 100 mile long. Per hop processing delay is 5µs.
Packets are 1500 Bytes long. All links have a Transmission speed of 56Kbps. speed of light in wire is 125,000 miles/s. If B
sends a 10 packet message to A, how long will it take A to receive message up to the last bit?

9.363 more than one segment in one datagram top gateoverflow.in/36921

my question can more than one meesage can be in one segment and can more than one segment be in one datagram and
more than one datagram can be present in one frame

computer-networks

This question is ambiguous .

Lets start with TL ipv4 maximum data could be transmitted is 64kB (16 bit in Total Length Field See IpV4 Header )
65535 B

In Data Link Layer If we are using Ethernet It can hold upto 1500B

Network Layer Divide Segments According to Which layer is creating bottle neck ( according to data mentioned here
bottle neck will be caused by DLL . No NL takes packets of size 1460 B )

Application Layer can send any amount of data to NL and it the duty of NL to divide the data to fit into one segment .

Make a clear question with all parameters .

 0 votes -- Akhil Nadh PC ( 1967 points)

9.364 Time delay in Packet Switched Network top gateoverflow.in/36956

A and B are 4 hops apart on a Packet Switched Network where each hop is 100 mile long. Per hop processing delay is 5µs.
Packets are 1500 Bytes long. All links have a Transmission speed of 56Kbps. speed of light in wire is 125,000 miles/s. If B
sends a 10 packet message to A, how long will it take A to receive message up to the last bit?

9.365 Packet Lost1.1 top gateoverflow.in/36987

Station X needs to send a message consisting of 12 packets to Station Y using a siding window (window size 4) and go-back-
n error control strategy. All packets are ready and immediately available for transmission. If every 7th packet that X
transmits gets lost (but no acks from Y ever get lost), then the number of packets that X will transmit for sending the
message to Y are _______.

9.366 Satelite communication UTILISATION1.1 top gateoverflow.in/36991

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1400 of 2244

A 1 Mbps satellite link connects two ground stations. The altitude of the satellite is 6000 km and speed of the signal is 3 ×
108 m/s. What should be the packet size for a channel utilization of 50% for a satellite link using go-back-63 sliding window
protocol?

Assume that the acknowledgment packets are negligible in size and that there are no errors during communication.

not enough data!.

its a triabgle and just with the height of trinage i cannot determine base of the triabgle

 0 votes -- viv696 ( 1431 points)

9.367 SWP Window size1.1 top gateoverflow.in/36988

Consider a link of length 1000 km with 10 9 bps rate connecting a sender and receiver. Assume a fixed packet length of 2500
bytes and sender always has packets to send. Packets are never lost or corrupted in the connection. The necessary window
size to achieve 90% utilization for a sliding window protocol is _________ (Assume signal propagation is 2 μsec per km
[Approximately])

let window size=w

TT=2500*8/(10^9)=20μsec

PD=2*1000=2000μsec

efficiency=w*TT/(TT+2PT)

0.9=w*(1/201)

w=201*0.9=180.9=181

 0 votes -- bhawanagupta15 ( 349 points)

9.368 stop and wait ARQ top gateoverflow.in/26376

In stop and wait ARQ system bandwidth delay product is 80000 bits..1 bit takes 20 ms to make round trip..if link utilization
is only 10%,then what is size of frame in bytes?


Selected Answer

Efficiency = amount of data sent / maximum data it can send .

In stop and wait ARQ only one packet is sent before acknowledgement received.

Efficiency = L /(RTT × bandwidth)

given bandwidth delay product I.e nothing but RTT × bandwidth.

L= (10/100 )× 80000 = 8000 bits =1000 bytes.

 2 votes -- pramod ( 2071 points)

Bandwidth*RTT = 80,000bits

Efficiency = TT/(TT+RTT) = 0.10 //given

0.90 TT = 0.10*RTT

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1401 of 2244

0.90 * Frame_Size / Bandwidth = 0.10*RTT

Frame_Size = 0.10*Bandwidth*RTT/ 0.90 = 0.10*80,000/0.90 = 80,000/9 = 8888.88bit ~= 1111Byte

 1 votes -- Digvijay Pandey ( 26245 points)

9.369 RTT top gateoverflow.in/36908

A ---- B ----- C ---- D ---- E

A is sending packets to E using a reliable transport protocol. Each link above can transmit one packet per second. There are no queues or other sources of
delays at the nodes (except the transmission delay of course).

A. What is the RTT between A and E?

9.370 What is keylogger? top gateoverflow.in/36550

Under what category is it classified?

computer-networks

9.371 Consider the two hosts A and B are connected via a Router as shown
below top gateoverflow.in/36506

My doubt is , should we not take RTT in calculation ?

computer-networks

9.372 What is keylogger? top gateoverflow.in/36551

Under what category is it classified?

computer-networks

Keylogger is kind of malware which records your keystrokes while you are typing also it may spy/monitor your computer.
And Keylogger might be programmed such that keylogger will send that keystrokes back to the hacker.
Keystrokes will include all kind of typing you do from keyboard like username,passwords,chatting etc
While most of the keyloggers does not track mouse movements and other things as its primary purpose is keylogging, but
they can be also used for screen capture,packet sniffing,information stealing etc.
Keylogger might be in Firewall-Network Security.

 1 votes -- Shashank Chavan ( 2439 points)

9.373 Sliding Window Protocol related top gateoverflow.in/26792

Consider a Sliding Window Protocol for a 10MBps point- to -point link with propagation delay of 2sec. If frame size is 4 kB.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1402 of 2244

The minimum number of bits required for the sequence number is what?


Selected Answer

Sequence(min)=1+2(T prop/ T trans)

Here T prop=2 sec=2000msec

T trans=4*!0^3/(10*10^6)=4/10000=.0004sec=.4ms

therefore, Sequence(min)=1+2*5000=10001

Bits min=log 10001=upper limit(13.28)=14

 3 votes -- srestha ( 11585 points)

9.374 Important topics of NETWORKS in 2016? top gateoverflow.in/36848

What are the important topics of Computer networks?


Selected Answer

1.Swp

2.Min size of the frame in ethernet

3.Tcp Ip header

4.Fragmentation

5.Subnet , Supernet

6.Application layer protocols

7.Distance vector algorithm

8.RSA algorithm

 1 votes -- munna kumar ( 309 points)

9.375 Checksum doubt? top gateoverflow.in/36831

what does this line mean???

9.376 Congestion Window 1.1 top gateoverflow.in/36992

Consider a TCP connection using the slow start congestion control scheme with an initial threshold value of 64 kB and a
Maximum Segment Size (MSS) of 2 kB. The receiver’s advertised window is initially 32 kB. The first transmission attempt is
numbered 0, and all transmission attempts are successful except for the timeouts on attempt number 4. Which of the
following represents size of sender’s congestion window at attempt number 10?


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1403 of 2244

0-2

1-4

2-8

3-16

4-32(lost)

5-2

6-4

7-8

8-16(slow start over)

9-18

10-20


my answer: 20
made easy answer given: 18!

 0 votes -- Aspi R Osa ( 1305 points)

9.377 Multiple Links between S & D1.1 top gateoverflow.in/36995

Consider a source computer (S) transmitting a file of size 106 bits to a destination computer (D) over a network of three
routers (R1 , R2 and R3) and four links (L1, L2, L3 and L4). L1 connects S to R1; L2 connects R1 to R2; L3 connects R2 to
R3; and L3 connects R3 to D. Let each link be of length 100 km. Assume signals travel over each link at a speed of 108
meters per second. Assume that the link bandwidth on each link is 1 Mbps. Let the file be broken down into 1000 packets
each of size 1000 bits. What is the total sum of transmission and propagation delays in transmitting the file from S to D?
1) 1007

2) 1010

3) 3000

4) 3003

Option (A) 1007ms

propogation delay from Source computer (S) to R1 = (Distance) / (Link Speed) = 10^5/10^8 = 1ms
Total prorogation delay to travel from S to D = 4*1 ms = 4ms ( since four links are in between L1, L2, L3 and L4)

transmission delay for 1 packet = (Number of Bits in one packet) / Bandwidth = (1000/10^6) = 1ms.

total transmission delay for 1 packet = 4 * 1ms = 4ms ( since four links are in between L1, L2, L3 and L4)

The first packet will take 8ms to reach Destination Computer (D). While first packet was reaching D, other packets must have been
processing in parallel. So D will receive remaining packets 1 packet per 1 ms from R3. So remaining 999 packets will take 999 ms. And total
time will be 999 + 8 = 1007 ms

 0 votes -- shashank ( 17 points)

9.378 find channel load top gateoverflow.in/37330

The measurement of slotted aloha channel with infinite number of users shows that 10% slots are idle. what is the channel
load(G)?

computer-networks

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1404 of 2244

9.379 Solve the subnetting problem top gateoverflow.in/37317

An organization is granted the block 190.76.0.0/16. The administrator wants to create 1024 subnets using 10 bits. The first
and last addresses in subnet 1024 respectively are?

9.380 ME Network1.1 top gateoverflow.in/37349

header bits=40

NAK bits=40

retransmitted bits=4000*0.02=80

total overhead bits=40+40+80=160

 0 votes -- bhawanagupta15 ( 349 points)

9.380 what is the meaning of zero subnet and dba subnet top gateoverflow.in/26311

If a network address is subnetted, the first subnet obtained after subnetting the network address is called subnet zero.
Consider a Class B address, 172.16.0.0. By default the Class B address 172.16.0.0 has 16 bits reserved for representing the host portion,
thus allowing 65534 (216-2) valid host addresses. If network 172.16.0.0/16 is subnetted by borrowing three bits from the host portion, eight
(23) subnets are obtained.Then first subnet of first network 172.16.0.0/19 is called subnet zero.

Direct broadcast address used to broadcast a datagram in particular network. It is the last address of subnet and can be hear by all hosts in subnet. Like
sender wants broadcast in a network having network ID 192.168.23.0 then sender has to mention receiver address as 192.168.23.255.

 1 votes -- Avdhesh Singh Rana ( 1509 points)

9.381 relation between full duplex and baseband transmission top gateoverflow.in/25452

if a link is using baseband transmission for e.g Ethernet....thats means one signal can pass through the link at a time.....that
means a baseband transmission can never be full duplex??? can anyone explain what is the relation between baseband
transmissions, broadband transmissions, full-duplex and half duplex link?


Selected Answer

Baseband transmission is bidirectional and uses digital signal.But in baseband transmission sending and receiving can not
be done at same time.So it's half duplex transmission.

Broadband transmission is unidirectional and uses analog signal.2 channels are required-1 for sending and 1 for
receiving.Hence it's simplex transmission for 1 channel but 2 wires working together makes it duplex.

 0 votes -- Rohan Ghosh ( 1515 points)

9.382 CSMA/CD top gateoverflow.in/25723

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1405 of 2244

The network consists of 4 hosts distributed as shown below: Assume this network uses CSMA/CD . And signal travels at 3 X
105 km/sec

If sender sends at 1Mbps. What could be the minimum size of packet?

(a).600 bits

(b). 400 bits

(c). 6000 bits

(d). 1500 bits

computer-networks

in CSMA/CD-

L/B = 2(D/V)

SO "L " IS DIRECTLY PROPORTIONAL TO "D"

=>MINIMUM SIZE=MINIMUM DISTANCE,,

AND WITH MINIMUM DISTANCE OF 90KM WE WILL GET 600BITS ..WITH DISTANCE OF 40,51,54,57 WE WILL GET <400
BITS....

SO 90 KM SATISFIES

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1406 of 2244

 0 votes -- asutosh kumar Biswal ( 215 points)

9.383 Supernetting top gateoverflow.in/37272

computer-networks

All are same Network i.e. Class B Network .


Supernetting Possible only if Network id's are different ..

 1 votes -- Digvijay Pandey ( 26245 points)

9.384 packet switching top gateoverflow.in/26369

In packet switching network packet are routed from source to destination along a single path having 2 intermediate nodes ,if
message size is 48 bytes and each packet contain header of 6 bytes then find optimal packet size...

(Basic Assumption is that all packets are of same size)

The key here to solve this problem is the fact that packet transmissions from intermidiate switches (routers here) can be
overlapped.

Case(1): Message is not at all splitted and no. of packets (of 54B each) is 1...

Transmission Time @ source = 54/bandwidth

Transmission Time @ switch R1 = 54/bandwidth

Transmission Time @ switch R2 = 54/bandwidth

Hence total time= 3*54/bandwidth = 162/bandwidth

Case(2): Message is split in 2 packets (30B each)

Transmission Time @ source = 2*30/bandwidth

Transmission Time @ switch R1 = 30/bandwidth ......{note 2 packets are transmitted on the line in parallel}

Transmission Time @ switch R2 = 30/bandwidth

Hence total time = 120/bandwidth

----------------

Similarly perform with 3 packets of 22B each : Total Time = 110/bandwidth

With 4 packets of 18B each: Total time = 72/b + 18/b + 18/b = 108/bandwidth

With 6 packets of 14B each : Total time = 84/b + 14/b + 14/b = 112/bandwidth

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1407 of 2244

------------

Thus for sending entire file in minimum time with error-free channel (to save retransmissions of bigger packet sizes) one
should go for a split of 4 packets where each packet is having the size of 18B.

------------

TIP - There was a question in Gate-14 (Set 1) which is based on this very concept :)

 1 votes -- Tushar Shinde ( 1523 points)

9.385 goBackN1.1 top gateoverflow.in/37003

MY QUESTION IS:
In Go BACK-N:

N is? window size or Sender window size?

A 1 Mbps satellite link connects two ground stations. The altitude of the satellite is 6000 km and speed of the signal is 3 ×
108 m/s. What should be the packet size for a channel utilization of 50% for a satellite link using go-back-63 sliding window
protocol?

Assume that the acknowledgment packets are negligible in size and that there are no errors during communication.

In GBN, N means Sender Window Size only and not receiver.

 0 votes -- G VENKATESWARLU ( 129 points)

9.386 Congestion Window 1.2 top gateoverflow.in/36996

Consider the effect of using slow start on a line with 5 millisec round trip time and no congestion. The receiver window is 36
KB and the maximum segment size = 2 KB. The time (in milliseconds) before the first full window can be sent is ________.

threshold=18MSS. first transmission ->2MSS->4MSS->8MSS->16MSS->32MSS->34MSS->36MSS.

7RTT,therefore 7*5=35 msec.

 0 votes -- Chanpreet Virk ( 21 points)

9.387 Subnetting top gateoverflow.in/30873

I want to have an idea about how the divisions are done.Please explain

An Internet Service Provider (ISP) is granted a block of addresses starting with


145.75.0.0/16. The ISP needs to distribute these addresses to three groups of customers as
follows:
(a) The first group has 128 customers; each needs 256 addresses.
(b) The second group has 128 customers; each needs 64 addresses.
(c) The third group has 64 customers; each needs 128 addresses.
Find the first address of 128th customer of 2nd group and how many addresses are still
available with ISP after these allocations.
(A) 145.75.127.128/24, 32768 (B) 145.75.159.192/26, 16384
(C) 145.75.159.192/26, 32768 (D) 145.75.191.128/25, 16384

1) First Group = 128 customer , per customers 256 address ,

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1408 of 2244

so for 256 address , we need 8 bits (for host)

host contain = 8 bits and 32-8= 24 for NID ,

so for group 1 st 128*256(per customer) = 32768 address ,

it will be like

145.75.0.0/24 to 145.75.0.255/24 for 1st customer(as each customer have 256 address)

145.75.1.0/24 to 145.75.1.255/24 for 2nd customer ..

....

145 .75.127.0/24 to 145.75.127.255/24 for 128th customer

now group 2 64 address so need 6 bit for host and remaining are 26 bits

so total address for it 64*128 =8192

address like 147. 75.128.0/26 to 147.75.128. 63 /26 (for customer 1st)

147.75.128.64/26 to 147.75. 128.127/26 (for customer 2nd )

147.75.128.128/26 to 147.75.128.191/26(3rd

147.75 .128.192/26 to 147.75.128.255/26(4th

147.75.129.0/26 to 147.75.129.63/26(5th)

......

147.75..159.192 /26 to 147.75.159.255/26 (last 128th customer )

so second group first address of 128 customer is 147.75.159.192/26 and

remaining address = 2^16 - (32768+8192)=16384

so B is correct

 2 votes -- sonam vyas ( 6441 points)

Ans is B.
for 1st group 128 customer and each need 256 address{Note: they call address not host}
So 1st group have address range
145.75.0.0 - 145.75.127.255.
now 2nd group
128 customer and 64 address So
145.75.10000000.00 {rest 6 bit for address contain by each customer} -> 1st customer of 2nd group
145.75.10000000.01 {rest 6 bit for address contain by each customer} -> 2nd customer of 2nd group
145.75.10000000.10 {rest 6 bit for address contain by each customer} -> 3rd customer of 2nd group
and so on
145.75.10011111.11 {rest 6 bit for address contain by each customer} -> 128th customer of 2nd group
means 145.75.159.192 {for 1st address of 128th customer all 6 bit will be 0's, So 11000000=192} and subnet is
8+8+8+2=26
So 145.75.159.192/26

addresses contain by 1st group=2 15


addresses contain by 2nd group=213
addresses contain by 3rd group=213
So how many address are still available 216 -215 -213 -213 =16384

 1 votes -- Jaikishan Apurva ( 787 points)

9.388 Congestion Window 1.3 top gateoverflow.in/37023

The initial congestion window size over a TCP is 1. If slow start algorithm is used and the size of congestion window
incremented by 1 whenever an ACK is received i.e. after first rounda trip time congestion window size is 2 segments. Assume
that connection never leaves slow start. The number of RTT’s to send 3999 segments are _______.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1409 of 2244


Selected Answer

Verify this logic:

For every packet sent the window size increases by 2. So when

wind=2...... RTT =1

wind=4..... RTT= 1+2

wind=8...... RTT=1+2+3

.....

wind=2048..... RTT=1+2+3+4+....11=66

Now after this for every ack 2 packets so to send remaining 1951/2

when window size reaches 2048 66 round trips. Now for remaining packets 3999-2048=1951. For every ack one packet
will be sent so required RTT = 1951/2=975.5. so total would be 1041

is it right approach?

 0 votes -- Sumit1311 ( 641 points)

9.389 ROUTING TABLE 1.1 top gateoverflow.in/37030

Shouldn't the distance between a and b be 2?


So, none of these.

 0 votes -- Aspi R Osa ( 1305 points)

9.390 For a class C network if IP address of a computer is 200.99.39.112 and


subnet mask is 255.255.255.224 top gateoverflow.in/36493

For a class C network if IP address of a computer is 200.99.39.112 and subnet mask is 255.255.255.224 the first host of
first subnet (represent last octet) is ________.

My doubt is :

Since , we are using 3 bits for subnet here , ( as 224 means 1110 0000 )

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1410 of 2244

So , won't the first subnet start from

000

I mean to say , first subnet : 000 , so 1st host in 1st subnet : 000 0 0001 , which is 1

1st host in 2nd subnet : 001 0 0001 , which is 33 .

They have given ans as 33.

Can you please clarify this ?

computer-networks

make diffrence in net id and subnet id .. ooo is net id and 001 is subnt

 0 votes -- Prashant Singh ( 11 points)

9.391 Ethernet Related top gateoverflow.in/27063

If an Ethernet station collides 3 times in trying to transmit a single frame, how long might it wait before the next attempt?

A]786 Micro seconds

B]819.2 Micro seconds

C]409.6 Micro seconds

D]None of these

9.392 TCP, find avg no of packet in queue..? top gateoverflow.in/28055

Consider a 107 bps link that is 400km long, with a queue large enough to hold 2000 packets. Assume that packets arrive at the
queue with an average rate of 4000 packets per second and that the average packet length is 2000 bits. Find the average
number of packets in the queue?

packet length 2000 bits

link 107bps

Transmission time=2000/107 =0.2 ms

2000 packets hold in 400 km

4000 packets/sec " " 800 km/sec

Propagation Time 400/800 =500 ms

Efficiency=(0.2/(0.2+2*500))*100

=(0.2/1000.2)*100

=0.019%= 0.02%

Avg no of packets in queue = 4000*0.02 =80 packets/second

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1411 of 2244

 1 votes -- srestha ( 11585 points)

9.393 Cryptography top gateoverflow.in/34814

Its ans given by many aspirant as C but why not its D ??As our goal is to achieve perfect hashing rather than collision .Just take the example of any real world
application like gmail,yahoo,hotmail all of them are designed such that the two passwords should not generate the same Hash Value

Consider the following two statements:

i. A hash function (these are often used for computing digital signatures) is an injective function.
ii. A. encryption technique such as DES performs a permutation on the elements of its input alphabet.

Which one of the following options is valid for the above two statements?

A) Both are false


B) Statement (i) is true and the other is false
C) Statement (ii) is true and the other is false
D) Both are true

9.394 Tcp top gateoverflow.in/34923

Consider a reliable byte stream protocol that use SWP running over 100 Mbps network .Propagation delay is 80 ms and
maximum segment lifetime is 80 s

a) How many bits are needed for receiver window size in TCP?

A) 19 B)20 C)21 D)none

B) how many bits we need in sequence field in Tcp header?

A) 21 B)28 C)30 D)15

B)

WAT = MAX SEQ NO. POSSIBLE / BANDWIDTH

HERE WAT =80 SEC(MSL)

and B.W. = 100 Mbps= 100MBps/8 (bit to byte)

now max seq no.possible= log (wat *bw) (base 2)

=log (80 * 100*10^6/8) (base 2)

=30 bits

 1 votes -- Anirudh Pandey ( 343 points)

9.395 IP Addressing top gateoverflow.in/34941

In the below given network, the source IP address is 10.1.1.10.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1412 of 2244

Suppose a host X with IP address 192.16.1.97 is connected through two routers R 1 and R 2 to another host Y with IP address
10.1.1.7. Router R1 has two IP addresses 192.16.1.135 and 192.16.1.110. Router R 2 has two IP addresses 10.1.1.67 and
10.1.1.155. The network mask used is 255.255.255.224. Which IP address should X configure its gateway?

R1 is connected with 2 IPs namely 192.16.1.135 and 192.16.1.110.

X has IP address 192.16.1.97 with 192.16.1.011***** as network id in the last octet. So, the gateway should also have the same network id
as 192.16.1.011*****. 192.16.1.110 has the same Network ID and hence should be the gateway for X node.

 1 votes -- Anshul Khantwal ( 185 points)

9.396 Please clear some doubt in channel sensing part of computer networks
top gateoverflow.in/35107

I am giving two questions along with answers

Q1 )

Suppose ‘A’ and ‘B’ are on same 10Mbps Ethernet segment and the propagation delay
between two nodes is 275 bit times. Suppose A and B are on two ends of the wire and tries to send a frame at time t=0 and
frames collide. Then at what time (in bits) they finish transmitting a jam signal. Assume 48 bit jam signal.
A. 598 B. 323 C. 502 D. 227

Here in this question , time taken to send the jam signal is => Tp + (time taken to send 48 bit jam signal , i.e 48 bit times =
(275 + 48 ) =323 bit times

this part is clear to me. Now the next question.

Q2)

Assume 10 Mbps Ethernet and two stations A and B on it’s same segment. The RTT between two nodes is 650 bit times. A
and B start transmitting frame and collision occurs and both sends 30-bit jam signal. Find the time at which both nodes A
and B sense an idle channel (in μsec).

Here , Tp = 0.5 * RTT = 325 bit times , so , add 30 bit jam signal = 325 + 30 = 355 bit times.

But they have also added Tp once again , 355 + 325 = 680 bit times.

Can you please justify the last Tp addition part ? Is it due to the fact that , in order to sense the channel idle , we need send
one bit , so , one propagation delay is needed ?

computer-networks

Tp = 0.5 * RTT = 325 bit times , so , add 30 bit jam signal = 325 + 30 = 355 bit times.

Both nodes A and B need to sense an idle channel. This would need propogation of these Jamming signals. So, another Tp
would be added to 355 bit times.

So, 680 bit times needed to sense an idle channel.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1413 of 2244

 0 votes -- Anshul Khantwal ( 185 points)

9.397 user datagram top gateoverflow.in/34953

The following is a dump header of UDP HEADER in hexadecimal format 5EFA00FD001C3297, what is the total length of user
datagram? is a packet form client to server or vice versa?

computer-networks

9.398 Find NID and Host ID bits, given destination address & mask to apply.
top gateoverflow.in/34740

from MadeEasy test series.

computer-networks

answer = option C

Class B NID = 154.33.0.0


31st subnet, subnet bits = 0000 0111 11
Host bits = last 6 bits from destination address = 01 1100

 1 votes -- Amar Vashishth ( 17865 points)

9.399 Routing top gateoverflow.in/34703

This is GATE 2014 set-2 question....

My question is what would be the ans if intruder is sniffing at Router 1 ??? then according to me ans should be option c and
d

Q.27 An IP machine Q has a path to another IP machine H via three IP routers R1, R2, and R3.
Q—R1—R2—R3—H
H acts as an HTTP server, and Q connects to H via HTTP and downloads a file. Session layer
encryption is used, with DES as the shared key encryption protocol. Consider the following four
pieces of information:
[I1] The URL of the file downloaded by Q

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1414 of 2244

[I2] The TCP port numbers at Q and H


[I3] The IP addresses of Q and H
[I4] The link layer addresses of Q and H
Which of I1, I2, I3, and I4 can an intruder learn through sniffing at R2 alone?
(A) Only I1 and I2
(B) Only I1
(C) Only I2 and I3
(D) Only I3 and I4


Selected Answer

Yes, packet sniffing at R1 will have information about TCP port number for Q and H, IP address of Q and H, and the link
layer address of Q only, since the DLL will only know the address of the immediately connected physical link (ie MAC
address) and not aware of the DLL of the H node, which is, although on 'a logical' link with Q, but different physical link
with R1.

 2 votes -- Utk ( 1385 points)

9.400 Frame Size top gateoverflow.in/34228

Suppose the round trip propagation delay for 10Mbps Ethernet has 24.2micro sec The network has 48bit jamming signal
then what is minimum frame size in bits


Selected Answer

RTT delay = 24.2 micro sec

So , we need to calculate time taken to send 48 bit jamming signal ::

10*(10^6) bits -----> 1 sec.

48 bit -------------> 48/(10*10^6) = 4.8 micro sec

So , total time = (24.2 + 4.8 ) microsec = 29 microsec.

Min frame size is the data to be sent in 29 microsec = 29*10^-6 * 10 * 10^6 = 290 bits

 2 votes -- Shounak Kundu ( 3757 points)

9.401 What is bit time in below question ? top gateoverflow.in/28665

Suppose A and B are on same 10Mbps ethernet segment and the propogation delay between nodes is 225 bit times.
Suppose A and B send frames at t=0 , the frames collide then at what time they finish travelling a 48 bit jam signal ?

In this question how come propogation delay is in bit times , it should be transmission time which is equal to length of frame / bandwidth .

9.402 computerNetwork top gateoverflow.in/34242

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1415 of 2244

computer-networks

find the netwrok id of given network by anding 255.255.192.0 with the given ip 157.106.46.234 so it will give.
157.106.0.0 . now take the ips and and with the subnet mask . if the same network id is obtained then its in same
network/ a is in the same network while b is not . because option d

 1 votes -- Ravi Singh ( 7303 points)

9.403 How to solve large exponential using fast exponential modular


arithmetic? top gateoverflow.in/28577

How to solve modulus of large exponential like 191^15 mod 719 using fast modular arithmetic with left to right binary form.

computer-networks


Selected Answer

Method I
191^15 % 719
m=191
n=719
e=15 write in binary 01111
d= binary bits
Three rule to be followed during process
1.intially d = 1
2.if d=0 do d^2%n and write it as new d
3.if d=1 do d^2*m % n and write it as new d

0 1 1 1 1
intial d=1 do d^2%n 1 1 531 326 403
m * 191 191 191 191
d*m%n=new d 1 191 42 432 40

therefore 191^15%719 = 40

Method II(but it wont work for prime power)

191^15 %719
=(191^3%719)^5
=(42^5%719)
=40

 1 votes -- Umang Raman ( 10379 points)

9.404 Test Series Question CN top gateoverflow.in/34310

Well Network Layer switch is called Router. This is little confusing.. ( Link layers switch is called bridge :P )

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1416 of 2244

computer-networks test-series

When switch is mentioned, it refers to L2 device only. L3 switch term came late when the switches started coming with
routable configs. It's not a proper official term.

 1 votes -- CrimeMasterGoGo ( 2221 points)

devices layers at which they work

repeater-->phy layer

hub-------->phy layer

switch--->phy+data link

bridges---->physical layer+data link layer

router------>physical+data link +network layer.

as data link layer uses MAC address

and router uses both MAC address and logical(IP address)

so answer is both switch and bridge

 1 votes -- sourav anand ( 1585 points)

9.405 What are the basics Equations Useful in Computer Network top gateoverflow.in/35300

Propogation Delay
Transmission Delay
Line Utilisation
Link Utilisation
RTT

RTT = Transmission Time + 2 * Propogation Time ?

(or)

RTT = 2 * Propogation Time

I found the 2d quation used in SWP problems But didn't understand why transmission time is not taken into consideration ?

9.406 What is the maximum data rate per connection ? top gateoverflow.in/35309

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1417 of 2244

9.407 Firewall top gateoverflow.in/35898

in what way does a firewall increase security of VPN?

a)configured to allow certain ports to access VPN

b)restrict use of specific application software on network

c)limit speed in which transmission of data is carried out

9.408 Computer Network Formulas top gateoverflow.in/35871

I am confused about efficiency formulas of ethernet,standard ethernt,csma cd ,sliding


window?

Will you please list down some formulas?

computer-networks

9.409 madeeasy test TCP total overhead top gateoverflow.in/28035

What is the total over header bits (Headers & Retransmission) with data frames consisting of 40 bit header and 3960 data
bits. ACK frames never occur. NAK frames are 40 bits, the error rate for frame is 2% and for NAK frame is negligible.

1. 80.4
2. 80.8
3. 160.4
4. None of these.

http://gateoverflow.in/30612/gateoverflow.in

 0 votes -- SURABHI GUPTA ( 19 points)

9.410 IPv6 Question - Which of the following is/are true? top gateoverflow.in/36187

Which of the following is/are true?


S1 : In both IPV4 and IPV6 header size is same.
S2 : IPV6 is connection oriented where as IPV4 is connectionless.

a) Only S 1

b) Only S 2

c) Both S 1 and S 2

d) Neither S 1 nor S 2

test-series made-easy computer-networks

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1418 of 2244


Selected Answer

only S2.IPV6 connection oriented,but ipv4 connectionless.Header size of both are different

 1 votes -- Sayantan Ganguly ( 5061 points)

D) Neither S1 nor S2

Header size for both are different.


Both are connectionless.

 1 votes -- Monanshi Jain ( 5827 points)

Option d) is true neither s1 nor s2


and IPV6 is connection less.
r e f f : https://technet.microsoft.com/en-
us/library/cc785430(v=ws.10).aspx

 1 votes -- Ankit Chourasiya ( 289 points)

9.411 For example, if C is 100 Mbps, the mean frame length, 1/µ, is 10,000
bits, top gateoverflow.in/27555

For example, if C is 100 Mbps, the mean frame length, 1/µ, is 10,000 bits, and the frame arrival rate, l, is 5000 frames/sec, then T = 200 µsec. Note that if we
ignored the queueing delay and just asked how long it takes to send a 10,000 bit frame on a 100-Mbps network, we would get the (incorrect) answer of 100
µsec. That result only holds when there is no contention for the channel.

Now let us divide the single channel into N independent subchannels, each with capacity C/N bps. The mean input rate on each of the subchannels will now
be l/N. Recomputing T we get

how this t calculated can anybody tell?

9.412 How many TCP connections can be opened between two ports? gateoverflow.in/27724

top

Is it only single TCP connection or Multiple connections?

computer-networks


Selected Answer

At any time between two particular end hosts, only one TCP connection can be there between any two ports.

A TCP connection is uniquely identified by 5 pieces of information in the TCP and IP headers.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1419 of 2244

1. IP Source Address(IPSA)

2. IP Destination Address(IPDA)

3. Protocol ID field in IP Datagram

4. TCP Source Port number

5. TCP Destination Port number.

IPSA & IPDA uniquely identify the end hosts & the Protocol ID field in the IP datagram tell us the connection is TCP.

The TCP source and destination port numbers identify the application processes on the end hosts.

Together AT ANY INSTANT, all 5 fields uniquely identify the TCP connection internet wide.

Whenever a TCP connection initiates, the end host who initiates the connection, picks a unique source port ID.

But in a TCP header the source port ID can not be more than 16 bits, so at a time we can have 2 16 = 64k different
connections, between a pair of end hosts, if the end host at the other end always listens at a specific port number.

When a TCP connection closes, the port number become available for reuse.

 2 votes -- Anurag Pandey ( 8183 points)

9.413 overhead top gateoverflow.in/35776

how to approach

computer-networks

9.414 Ip addresses and Gate Calculator top gateoverflow.in/35496

Is there any way of calculating binary equivalent of the given IP address on the virtual calculator provided? Or we need to
use manual calculations for it?

9.415 TCP retransmission timer top gateoverflow.in/35434

If TCP round trip time is currently 20 ms and ACK comes in after 30 ms then what is the timeout period for next
transmission . Use α=0.9 and β=2

9.416 Width of bit in link top gateoverflow.in/35310

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1420 of 2244

9.417 TCP and IP overhead top gateoverflow.in/35438

Suppose a TCP entity receive 2MB file from application layer and IP layer is willing to carry blocks of max size 1600 B.
Calculate amount of overhead incurred from segmenting file into packet sized units. Assume both TCP and IP header of 20 B.

IP can carry max block size=1600B in which 40B will be TCP+IP header.

so data bytes in 1 packet=1560

#packets=2MB/1560B

=2*(2^20)/1560=1344.328=1345(approx)

Total overhead=1345*40=53800B

 0 votes -- bhawanagupta15 ( 349 points)

9.418 tcp-max no of segments top gateoverflow.in/35441

Let a file of 16 GB has to be transferrred from host A to host B. Assume an MSS size of 2048B. Then what is maximum
number of segments that can be transferred such that TCP sequence no don't get exhausted.Assume TCP sequence field 32
bits

a)2^21 b)2^23 c)2^11 d)none

As seq field 32 bit,so wrap around of TCP is 2^32 B

That means using TCP we can transfer maximum 4 GB data

So,max no of segment that can be transferred is 2^32/2048 = 2^21

 1 votes -- Sayantan Ganguly ( 5061 points)

9.419 Supernetting in CIDR top gateoverflow.in/35459

Can i perform superneting and perform these addresses ?

100.1.2.0/25

100.1.2.128/26

100.1.2.192/26

computer-networks

9.420 IPV4 top gateoverflow.in/37871

Which of the following IP address requires approval from ISP for obtaining them?

(i) 172.19.24.24 (ii) 13.13.13.13

(iii) 192.168.20.1 (iv) 192.167.0.1

a. Only (i) and (iii)


b. Only (i) and (iv)
c. Only (ii) and (iii)
d. Only (ii) and (iv)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1421 of 2244

why are these address special that they have to be approved from ISP?


Selected Answer

1st and 3rd IP address are private ip address of class B and class C respectively.

Private IP range:

class C 192.168.0.0 - 192.168.255.255 (65,536 IP addresses)


class B 172.16.0.0 - 172.31.255.255 (1,048,576 IP addresses)
class A 10.0.0.0 - 10.255.255.255 (16,777,216 IP addresses)

these can be used by intra-network, ip allocation by your home wifi router to your laptop, mobiles etc (class c, thats why
most of the router admin panel can be accessed at class c address that is 192.168.x.x by default) as a NAT.

2nd and 4th IP does not belong to private IP thus they are with ISP.

 0 votes -- Shashank Chavan ( 2439 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1422 of 2244

10 Digital Logic top


10.1 Adder: Number of AND gates for carry lookahead generator top gateoverflow.in/36022

I am unable to prove it. Please explain

digital-logic adder

A and B are input bits

(Assumption: Nothing mentioned ,so any number of inputs are possible in and gate)

Generator function G = A.B

Propagation function P = A xor B

general equation for carry is C(i+1) = G(i) + P(i)C(i)

Therefore for C(0+1) = G(0) + P(0)C(0) requires 1 AND gate

C(1+1) = G(1) + P(1)C(1)

= G(1) + P(1)[G(0) + P(0)C(0)]

= G(1) + P(1)G(0) + P(1)P(0)C(0) requires 2 AND gate

Similarly 3 AND gate for C(1+ 2)

Therefore, for 8 bit no. of and gates required = 1+2+3...+8 = 36 (Hence n*(n+1)/2)

 1 votes -- Sandeepan Baidya ( 131 points)

10.2 Bcd: ISRO-2013-11 top gateoverflow.in/43801

When two BCD numbers 0x14 and 0x08 are added what is the binary representation of the resultant number?

A. 0x22
B. 0x1c
C. 0x16
D. Results in overflow.

isro2013 number-representation bcd

0X14=14

0X08=8

addition of these two numbers in binary is 22

22 binary representation 0X22

 1 votes -- srestha ( 11585 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1423 of 2244

10.3 Binary Codes: excess 3 codes top gateoverflow.in/28724

Convert 11012 to corresponding excess − 3 binary number.


(A) 10000
(B) 01000110
(C) 100110
(D) 10110

number-representation binary-codes


Selected Answer

(1101)2 = (13) 10 = (0001 0011) BCD = (0100 0110) XS-3

Examples :

 7 votes -- Praveen Saini ( 34299 points)

10.4 Boolean Algebra: How many of 16 boolean functions in 2 variables x and


y can be represented using only top gateoverflow.in/18849

How many of 16 boolean functions in 2 variables x and y can be represented using only the given set of operators, variables x
and y ,and values 0 and 1?

a) { ∼ }

b) { ⋅ }

c) { + }

d) { ⋅ , + }

digital-logic boolean-algebra

x y f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15


0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
0 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
1 0 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1
1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1

f0=0, f1= x.y, f2=x.y', f3= x, f4=x'.y, f5=y, f6=x xor y, f7= x +y, f8=(x+y)' , f9= x xnor y, f10=y',
f11=x+y', f12 = x', f13= x'+y, f14=(x.y)', f15=1

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1424 of 2244

a) {~} = using only NOT , we can get only f0=0, f15=1, f5=y,f6=x,f10=y',f12=x' (6 functions)

b){.} = using AND only f0=0, f1=x.y,f15 =1 , f5=y,f6= x(5 functions){ using idempotentency properties}

c){+} = using it only f0=0,f15=1, f7=x+y ,f5=y,f6=y(5 function)

d){. +} = using these we get f0=0,f15=1,f5=y,f6=x,f7=x+y,f1 =x.y ....(6 functions)

 4 votes -- sonam vyas ( 6441 points)

a) The only function values we can get are x, y, 0, 1, x', y', Therefore the answer is 6.
b) Since x.x = x, x.1 = x, and x.0 = 0 for all x, the only functions we can get are x, y, 0, 1, and xy.
Therefore the answer is 5.
c) By duality the answer here has to be the same as the answer to part (b), 5.
d) We can get the 6 distinct functions x, y, 0, 1, xy and x+y. Any further applications of these
operations,however, returns us to one of these functions. For example, xy+ y=x

Therefore final answer is a)6 b) 5 c)5 b)6

Thanks to pramod!!

 3 votes -- Umang Raman ( 10379 points)

10.5 Boolean Algebra: The number of possible boolean functions that can be
defined for n boolean variables over n valued boolean algebra is top gateoverflow.in/32446

digital-logic boolean-algebra


Selected Answer

2n possible combinations in truth table

All these combinations can either take value 0 or 1

n
So no of boolean func=22

 2 votes -- Pooja ( 22773 points)

10.6 Boolean Algebra: number of binary operations on set top gateoverflow.in/37543

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1425 of 2244

permutation boolean-algebra

For number of binary operation (lets denote set with R) since

|R|=4

binary operation( R X R ->R) would be 4^(4*4) =4^16

 2 votes -- Abhishekcs10 ( 1001 points)

No of binary operation on a set with n element=n^(n^2)

here n=4

Ans 4^16

 1 votes -- Manojk ( 3365 points)

10.7 Boolean Algebra: Boolean function property top gateoverflow.in/37539

digital-logic boolean-expressions boolean-algebra

IF THAT MEANS SELF DUAL FUNCTION then....

(0,7)..(1,6)...(2,5)..(3,4).. the choices will be 2X2X2X2=16

i think that miss print..

 0 votes -- Deepesh Kataria ( 1207 points)

10.8 Boolean Expressions: How to solve this boolean Exp? top gateoverflow.in/18210

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1426 of 2244

Boolean Exp is (A+B).(B+C)

Please give the detailed explanation.

boolean-expressions digital-logic

apply distributive law u will get (b+ac)

 0 votes -- Saurav Kumar Gupta ( 1455 points)

10.9 Boolean Expressions: Boolean expression from venn diagram top gateoverflow.in/29476

The Boolean Expression for the shaded area in the venn diagram.

¯
ˉ
a. ACW + ABCW
ˉ
b. ABC + ABW
c. (A + B + C)W
ˉ
d. AW + BW + AB

I couldn't understand the explaination of the above problem please explain.

digital-logic boolean-expressions


Selected Answer

F=a-(b+c)+b-(a+c)+c-(a+c)

=> a(b+c)'+b(a+c)'+c(a+b)'

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1427 of 2244

=>(ab'c'+ba'c'+ca'b')∩W or ab'c'+ba'c'+ca'b')W [Because W is universal set]


And on putting k-map you'll get same result

Given options are wrong

 2 votes -- Avdhesh Singh Rana ( 1509 points)

f=(A'B'C +ABC)+(A'BC'+ABC)+(AB'C'+ABC)

=A'B'C +A'BC'+AB'C'+ABC

=A⨁B⨁C

 1 votes -- srestha ( 11585 points)

10.10 Boolean Expressions: How do I solve this Boolean expression? gateoverflow.in/17427

top

How do I solve this Boolean expression?

(A + B) ⋅ (B + C) ⋅ (C + A)

Kindly write the step wise explanation with properties used.

boolean-expressions


Selected Answer

Given: (A + B) ⋅ (B + C) ⋅ (C + A)

Associative (A + B) ⋅ (B + C)
abc = (ab)c ( )
 ⋅ (C + A)

Distributive BB
x(y + z) = xy + xz

(AB + AC +  + BC) ) ⋅ (C + A)
Idempotent B + BC
xx = x

(AB + AC + )
 ⋅ (C + A)

Associative, (AB + AC + B) ⋅ (C + A)
Absorption 
x + xy = x

AA CC AA
Distributive
ABC + B + A  + C + BC + BA
AC
Idempotent ABC + AB 
 + AC + AC + BC + BA
Associative, AB BA
Absorption  + AC + BC + 
Idempotent AB + AC + BC

Hence, the simplified expression is:

AB + AC + BC

 0 votes -- Vinay Yadav ( 1739 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1428 of 2244

10.11 Boolean Expressions: Question on checking equality of boolean


expresssions? top gateoverflow.in/29384

Which of the following relation is not true?


¯ ¯ ¯ ¯
(A) AB + AC + BC = AB + AC (B) XY + YZ = (Y + Z)(Y + X)
¯ ¯ ¯ ¯ ¯ ¯
(C) A. B. C = A + B + C (D) AB + AB = A + BC

Given answer: D
Except C I couldn't prove other options as equal.

digital-logic boolean-expressions


Selected Answer

A) Consensus Theorem
B) Consensus Theorem (after applying distributive law)
C) De Morgan's Law
D) Non-sense.

answer = option D

 3 votes -- Amar Vashishth ( 17865 points)

1. is Consensus property.

3. is demorgn law

2. just multiply right side two bracket.

 2 votes -- Anirudh Pratap Singh ( 4091 points)

10.12 Booths Algorithm: Question on booth's algorithm top gateoverflow.in/33418

Given answer is 8 with following explanation:

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1429 of 2244

I couldn't understand the approach. Please explain.

digital-logic booths-algorithm


Selected Answer

append a 0 at LSB and start scanning from LSB to MSB

if 1 is encountered after a 0 [ 10] then place -1 as shown in fig.

if 0 is encountered after a 1 [ 01] then place +1

if 0 is encountered after a 0 [ 00] then place 0

if 1 is encountered after a 1 [ 11] then place 0

then calculate no. of +1 and -1 's which is total no. of addition/subtraction operation required.

http://gateoverflow.in/3753/gate2005-it_8

 1 votes -- Khushboo Tak ( 1961 points)

10.13 Canonical Normal Form: Kindly have a try .... IN canonical POS form
following equation is written as (ABC)=AB+BC+AC (A)πM(0,1,2,4)
(B)πM(3,5,6,7) (A)πM(0,1,2,3) (A)πM(4,5,6,7) top gateoverflow.in/2824

Kindly have a try .... IN canonical POS form following equation is written as

F(A,B,C)=AB+BC+AC

(A)πM(0,1,2,4)

(B)πM(3,5,6,7)

(C)πM(0,1,2,3)

(D)πM(4,5,6,7)

digital-logic canonical-normal-form


Selected Answer

F(A, B, C) = AB + BC + AC

= ABC ′ + ABC + ABC + A ′ BC + AB ′ C + ABC

= ABC ′ + ABC + A ′ BC + AB ′ C

= Σm(6, 7, 3, 5) (m - minterm and M-maxterm))

= πM(0, 1, 2, 4) (proof shown below)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1430 of 2244

F(A, B, C) = Σm(3, 5, 6, 7)

 F ′ (A, B, C) = Σm(0, 1, 2, 4)

 F ′ (A, B, C) = m 0 + m 1 + m 2 + m 4

 (F ′ ) ′ (A, B, C) = (m 0 + m 1 + m 2 + m 4 ) ′

 F(A, B, C) = (m 0′ m 1′ m 2′ m 4 ) (DeMorgan's law)

 F(A, B, C) = (M0 M1 M2 M4 )

 F(A, B, C) = πM(0, 12, 4) (Complement of a minterm is its corresponding maxterm, for example, m 0 = A ′ B ′ C ′ and
m 0′ = (A ′ B ′ C ′ ) ′ = A + B + C = M0 )

Ref: http://www.cs.uiuc.edu/class/sp08/cs231/lectures/04-Kmap.pdf

 2 votes -- Arjun Suresh ( 124125 points)

First take the function, this is in SOP so find the min terms of the equations

so min terms are 3,5,6,7

For Finding the MAX TERMS subtract these min terms from whole possible terms with 3 variable which are
{0,1,2,3,4,5,6,7}- {3,5,6,7} = (0,1,2,4)

ans is option A

 1 votes -- GANNA ( 149 points)

A will be the answer try to put this value on karnaugh map and remaining will be your answer.

 1 votes -- Arpit Dhuriya ( 175 points)

10.14 Canonical Normal Form: ISRO-2013-28 top gateoverflow.in/43963

The most simplified form of the Boolean function

x(A, B, C, D) = ∑ (7, 8, 9, 10, 11, 12, 13, 14, 15)

(expressed in sum of minterms) is?

A. A + A'BCD
B. AB + CD
C. A + BCD
D. ABC + D

isro2013 digital-logic canonical-normal-form


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1431 of 2244

Option C

 1 votes -- Praveen Saini ( 34299 points)

10.15 Circuits: What will be the value of f ? top gateoverflow.in/16281


¯
Q).Consider the circuit shown below of 2:1 MUX is given by the function g = ac + bc

combinational circuits


Selected Answer

According to the function g=ac +bc' when c=0 ,data on line b will be selected and if c=1 data on ine a will be
seected .

so ,g= E*x' + 0*x=E*x'

f =y'x+y(output of 1st mux g)

=(xy' + Ex'y)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1432 of 2244

note; the g function is given to determine the 0th and 1th line of the mux.

 1 votes -- Saurav Kumar Gupta ( 1455 points)

10.16 Circuits: How to approach this problem top gateoverflow.in/29477

Given answer: A
Please explain

digital-logic circuits


Selected Answer

To get F=1 as sum of product we have to complete the circuit

A should be 1
B&C both cant be 0 therefore using truth table B+C
For D it can be either 0 or 1 therefore D+D'
id D then =0 then P=1 if D=1 P'=1
Doing and operation A.(B+C)(D'P+DP')

 1 votes -- Umang Raman ( 10379 points)

10.17 Clock Frequency: Maximum clock frequency for the circuit top gateoverflow.in/36329

In the following digital circuit shown above, the worst case delay is of 30 nsec and the AND gate has delay of 10 nsec. The
maximum clock frequency of the circuit to operate is _ MHz.

I calculated as follows : TClk ≥ Tflip −flop + TANDgate

1 1
f Clk
So, ≤ 40

Here, we will just add the flip-flop delay once? The solution gives the frequency as 14.2 MHz, adding the delay due to flip-
flop twice. Why?

digital-logic digital clock-frequency

10.18 Clock Frequency: What is the o/p according to given timing diagram?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1433 of 2244

top gateoverflow.in/33015

a) A = 0, 1, 0, 0, B = 1, 0, 1, 1
b) A = 1, 0, 1, 1, B = 0, 1, 0, 0
c) A = 1, 1, 0, 0, B = 1, 1, 0, 0
d) A = 0, 1, 0, 0, B = 0, 1, 0, 0

I thought it would be (c) as previous states should persist for 1st clock. But answer given is (a). Can somebody please
explain??

digital-logic flip-flop clock-frequency clockcycle


Selected Answer

So value of A,B at timing 1,3,5,8 is


A:-0,1,0,0
B:-1,0,1,1
So option A is right

 3 votes -- Jaikishan Apurva ( 787 points)

10.19 Combinational: Digital logic : Find


the value of f top gateoverflow.in/19234

I know , this is pretty basic question , still could not get it right
¯
I got the answer as B + C

Am I doing something terribly stupid here ?

digital-logic combinational

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1434 of 2244

It's easy . just use the k Map in this type of questions. it will take u fast to the simplification. the terms here one are.
0,2,4,6. all lies at the

bc->

a |

00 01 11 10
0 1 1
1 1 1

subcube of 4 will be formed. and will give answer c'. now we are just oring b with it. so answer is b+c'.

 1 votes -- Ravi Singh ( 7303 points)

10.20 Combinational: No. of Half Adders top gateoverflow.in/28284

How many half adders are required to realize the following 4 functions?
f1 = A ⊕ B ⊕ C
¯ ¯
f2 = ABC + ABC
¯ ¯ ¯
f3 = ABC + (A + B)C
f4 = ABC

combinational

10.21 Counter: counter top gateoverflow.in/28268

The initial state of a MOD 16 down counter is 0110 . After 37 clock pulses, the state of the counter will be

A. 0001
B. 1011
C. 1101
D. 1010

counter


Selected Answer

I.

After every 16 clock pulse counter reach to initial state.

After 32 clock pulses counter will be at 0110

after 33 clock pulse, 0101

After 34 clock pulse, 0100

After 35 clock pulse, 0011

After 36 clock pulse, 0010

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1435 of 2244

After 37 clock pulse, 0001.

II

After Every 16 clock pulses counter will be at initial state, 0110

37 mod 16 = 5.

​As it is a down counter, it will be 5 states down from 0110 = 0110 - 0101= 0001.

 3 votes -- Praveen Saini ( 34299 points)

10.22 Counter: Modulus of counter1.1 top gateoverflow.in/37464

Please Explain the inverted clock. How is the first Flip flop getting the Clock input?
What Cr(complement) means?
And how to judge MSB LSB

counter


Selected Answer

Cr(compliment) means clear bits on logic zero input, so when A = 1 and B = 1 the flip flops are clear and are reset 000,
as this is a up counter and it is clear on A =1 B =1 , it will be cleared on ABC = 110 which is 6 so it is mod 6 counter.

 0 votes -- Vikram Bhat ( 587 points)

10.23 Counter: If the initial stage of mod-11 counter is 0110, then what will
be the counting sequence for next 24 clock pulses? top gateoverflow.in/17409

If the initial stage of mod-11 counter is 0110, then what will be the counting sequence for next 24 clock pulses?

What will be counting sequence for the next 17 clock pulses if the counter is mod-16 down counter and the initial value is
1110?

counter


Selected Answer

(1) ANS-1000

BEZ OF MOD -11 COUNTER SEQUENCE IS

1->2->3->..................10->1

WHEN START FROM 0110 AFTER 22 CLOCK IT REACH AT THAT STATE THEN I HV REMAINING 2 CLOCK
THEN FORWARD TWO STATE THEN WE GET 1000.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1436 of 2244

(2) ANS-1101

 0 votes -- sweta kumari ( 93 points)

10.24 Counter: Finding modulus of a Counter top gateoverflow.in/37650

The modulus value of the below a synchronous counter is __________.

digital-logic counter flip-flop made-easy


Selected Answer

It is an asynchronous counter.

it goes from 0, 1, 2. . . so on till it get cleared and returned to 0 again.

It will return to 0/Clear when NAND will produce 0.

That will happen at A and B both are 1, i.e, ABC at 110.

But state 110 will not be counted

we have previous state 101,

then
A B C
1 0 1
  
this is old 1 Change to 1 Change to 0

Actually 110 is not result in states, and counter get cleared (with new B as 1, and Old A as 1).

We get states as 0, 1, 2, 3, 4, 5, 0, 1, . . . .

MOD6 Counter.

 7 votes -- Praveen Saini ( 34299 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1437 of 2244

10.25 Counter: A cascade of three identical modulo-5 counters has an overall


modulus of ? top gateoverflow.in/9580

(A) 5 (B) 25 (C) 125 (D) 625

gate2014ee-1 digital-logic counter


Selected Answer

125..
cascading two modulo M and modulo N counter gives modulo M*N counter..

 7 votes -- Digvijay Pandey ( 26245 points)

10.26 Counter: T flipflop counters top gateoverflow.in/36573

What will be the value of G1 and G2 how to calculate them?

flip-flop counter


Selected Answer

Sequence of counter given

00 − 10 − 11 − 01 − 00

From sequence given, we get the state table as

Q2 Q1 Q 2+ Q 1+
0 0 1 0
0 1 0 0
1 0 1 1
1 1 0 1

Now we have present state and next state, use excitation table of T flip-flop

Q2 Q1 Q 2+ Q 1+ T2 T1

0 0 1 0 1 0
0 1 0 0 0 1
1 0 1 1 0 1
1 1 0 1 1 0

From table, T2 = Q 2 ⊙ Q 1 and T1 = Q 2 ⊕ Q 1

G 1 = T1 = Q 2 ⊕ Q 1

G 2 = T2 = Q 2 ⊙ Q 1

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1438 of 2244

 0 votes -- Praveen Saini ( 34299 points)

10.27 Counter: Dfa and counter difference? top gateoverflow.in/17749

#digitalelectronics and #deterministicFA


please clarify this.....
In constructing dfa ,say (num) divisible by 8 or just mod 8 we need minimum of 4 states ,

1. So for constructing mod 8 counter we need minimum of states 4(we have to count only 8 not by shifting so i decided to
use 4 states rather 8),

to represent 2 state - 1 ff needed so for representing 4 states(mod 8 counter) - 2 ff needed .....whether using 2ff can we
construct mod 8 counter?

2. I tried by constructing states representing 0 as 00 ; 1,3,5,7 as 01; 2,6 as 10 and 4 as 11 (see diag below) and I
constructed the mod 8 counter using present state and next state (i took this as random not inorder but according to diag),
making last transition as 11 to 00; remaining can be anything ,though we have 2 variable and 8 transitions so I used normal
algebraic reduction for constructing combi.circuit.... whether my approach is correct ?refer diag 2

3. If there are any other suggestions.. welcomed

counter finite-automata

actually counter and num mod 8 dfa is 2 different thing. mod 8 counter is a ckt which generate a sequence of 8 different
state without taking any input wherease dfa goes to next state by consuming input . mod 8 counter needs only 3 states so
3 fflops. ur method doesnt seems correct . check it https://www.cs.tau.ac.il/~nin/Courses/mivne98/counters/

 0 votes -- Saurav Kumar Gupta ( 1455 points)

10.28 Data Hazards: Boolean expression hazards top gateoverflow.in/37538

Which of the following expression remove hazard from : xy + zx ′ ?

A. xy + zx ′

B. xy + zx ′ + wyz

C. xy + zx ′ + yz

D. xy + zx ′ + wz

digital-logic digital boolean-expressions data-hazards

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1439 of 2244


Selected Answer

Fill f(x, y, z) = xy + x ′ z in K-map

Hazard occurred because a variable and its complement passed through different number of logic operations.

In other words, if a variable and its complement are present in different product terms, may cause Hazards.

Here it is variable x, that may cause Hazard.

So make an extra pair in K-map that doesn't contain variable x.

so f(x, y, z) = xy + x ′ z + yz is Hazard Free.

 1 votes -- Praveen Saini ( 34299 points)

10.29 Decoder: Output expression of the decoder top gateoverflow.in/36749

A 3 line to 8 line Decoder is used to implement a 3-variable Boolean function as shown in figure.

The simplified form of output Y is.

ˉ ˉ ˉ
A. XY + YZ + XYZ
ˉ ˉ
B. XZ + YZ + XYZ
ˉ ˉ ˉ
C. XY + XZ + XYZ
ˉY ˉ ˉ ˉ
D. X + XZ + XYZ

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1440 of 2244

digital-logic decoder ace-test-series

HERE its written like this(Z is MSB)

ZYX ....

NOW TAKE 0's outside and it will be NAND GATE now it says when enteries are either (1,3,5,6) we get 1

so fill 1 at those places and it will turn out to be Z'Y'X+Z'YX+ZY'X+ZYX' THAT MATCHES WITH c

JUST MAKE THE OPTION C IN CANONICAL FORM

 0 votes -- Deepesh Kataria ( 1207 points)

10.30 Demux: Why are demux not universal combinational circuit? top gateoverflow.in/38112

The internal of a demux is:

It contains a NOT and an AND. Then, why is it not universal? Using demorgans law can't we get OR?

digital demux gates universal-circuit

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1441 of 2244

Demux is not a universal gate as it has only 1 input line, hence boolean expression can be implemented.

If we use select lines as input ,then it becomes decoder.

 0 votes -- Deepika Bagaria ( 37 points)

10.31 Digital: The boolean expression f(x,y,z) in its canonical form for the
decoder circuit shown below is top gateoverflow.in/35123

Note : the bubbles are NOT gates

digital digital-logic

It will be better if we simplifies it as follow

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1442 of 2244

Now it can be solved easily

The decoder will be enable only when z is 0, it means at minterms 1, 3, 5, and 7 we will get all Decoder outputs as 0, so F
will be 0 at minterms 1, 3, 5 and 7, we need to check Function F only at minterms 0, 2, 4 and 6.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1443 of 2244

at minterm 0, D 0 = 1, D 2 = 0, D 4 = 0 and D 6 = 0, so f1 = 0 and f2 = 0 , so F = 0

at minterm 2, D 0 = 0, D 2 = 1, D 4 = 0 and D 6 = 0, so f1 = 0 and f2 = 0 , so F = 0

at minterm 4, D 0 = 0, D 2 = 0, D 4 = 1 and D 6 = 0, so f1 = 0 and f2 = 1 , so F = 1

at minterm 6, D 0 = 0, D 2 = 0, D 4 = 0 and D 6 = 1, so f1 = 0 and f2 = 1 , so F = 1

so, F(x, y, z) = Σm(4, 6)

 10 votes -- Praveen Saini ( 34299 points)

10.32 Digital: A digital circuit which compares two numbers A2A1A0 and
B2B1B0 is shown in figure top gateoverflow.in/35122

How it is that EXNOR is a odd function?

digital-logic digital


Selected Answer

¯
(A2 ⊕ B2 ) ⊕ (A1 ⊕ B1 ) ⊕ (A0 ⊕ B0 ) = (A ⊕ B ) ⊙ (A ⊕ B ) ⊕ (A ⊕ B ) = (A ⊕ B ) ⊕ (A ⊕ B ) ⊙ (A ⊕ B )
2 2 1 1 0 0 2 2 1 1 0 0

a) ((0 ⊕ 1) ⊕ (1 ⊕ 1)) ⊙ (0 ⊕ 1) = 1 ⊙ 1 = 1

b) ((0 ⊕ 1) ⊕ (1 ⊕ 0)) ⊙ (0 ⊕ 1) = 0 ⊙ 1 = 0

c) ((1 ⊕ 1) ⊕ (0 ⊕ 1)) ⊙ (1 ⊕ 0) = 1 ⊙ 1 = 1

d)((1 ⊕ 0) ⊕ (0 ⊕ 1)) ⊙ (1 ⊕ 1) = 0 ⊙ 0 = 1

I think they mean to ask invalid combination and did typo :D

Another way,
Xor gives 1 when having odd no's of 1 ′ s in input, otherwise 0. so take the complement of that result of xor, will get 1 for
option a,c,d and 0 for option b.

 1 votes -- Praveen Saini ( 34299 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1444 of 2244

Firstly EXNOR gate gives Output as 1 When all the inputs are 0's or all the inputs are 1's

Now go from bottom to Top 3 inputs must be 0's or 1's

If you observe in option 2 when u do xor with corresponding bits all are 1's

but in option 1 A2 violates this condition.

 1 votes -- Prabhanjan R ( 747 points)

10.33 Dual Function: Computing the dual of the boolean function top gateoverflow.in/36297

Suppose, f(A, B, C, D) = ∑ m(0, 2, 4, 6) is a boolean expression, expressed in minterm form. How can I calculate and express the
dual of the function?

I have tried the method using the exact definition, but it turns out to be very cumbersome and prone to errors. Any other
method?

dual-function boolean-expressions boolean-algebra digital-logic


Selected Answer

f(A, B, C, D) = Σm(0, 2, 4, 6)

f(A, B, C, D) = A ′ B ′ C ′ D ′ + A ′ B ′ CD ′ + A ′ BC ′ D ′ + A ′ BCD ′

Dual of f,

fd (A, B, C, D) = (A ′ + B ′ + C ′ + D ′ ). (A ′ + B ′ + C + D ′ ). (A ′ + B + C ′ + D ′ ). (A ′ + B + C + D ′ )

= M15. M13. M11. M9

= ΠM(9, 11, 13, 15)

= Σm(0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14)

That's it.

Note:

In Dual of f, that is fd , we replace AND (. ) by OR ( + ), OR ( + ) by AND (. ), 0 by 1 and 1 by 0 ONLY.

In Complement of f, that is f ′ , we need to replace all variable, say x , by it complement variables , say x ′ , also.

 2 votes -- Praveen Saini ( 34299 points)

10.34 Dual Function: dual of function top gateoverflow.in/28725

Dual of EX-OR is equal to


(A) NAND
(B) NOR
(C) EX-NOR
(D) None of these

dual-function boolean-expressions boolean-algebra

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1445 of 2244


Selected Answer

EX-OR, A ⊕ B = A ′ B + AB ′

Dual of EX-OR = (A ′ + B). (A + B ′ ) = A ′ B ′ + AB = A⊙B = EX-NOR

[Note :

Dual is different concept from Complement

In Dual, Replace AND with OR , OR with AND and replace 1's by 0's and 0's by 1's

In complement, In addition to above, we also replace Binary variables by its complement's, mean x by x' or x' by x.

In case of EX-OR , dual of EX-OR is same as its complement, but for different expression, it may differ. ]

 8 votes -- Praveen Saini ( 34299 points)

(AB')+(BA') dual is ((A'B)+(B'A))'

= ((A'B)' . (B'A))'

=(A+B')(B+A')

=AB+A'B' i.e. EX-NOR gate

if a function f(x)=f(x 1 ,x2,........xn) then its dual will be f((x 1)',(x2)',...............,(xn)')'

 3 votes -- srestha ( 11585 points)

answer = option D

its the Law of Duality which is applied on the entire equation/formula not on just an expression.
for more info check : http://math.stackexchange.com/questions/408409/duality-principle-in-boolean-algebra

 1 votes -- Amar Vashishth ( 17865 points)

10.35 Flip Flop: flip flip output top gateoverflow.in/35820

I think given answer is wrong. can anybody help?

digital-logic flip-flop


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1446 of 2244

J1 = Q 0 , K1 = Q 0′ , Q 1+ = J1 Q 1′ + K1′ Q 1 = Q 0 Q 1′ + Q 0 Q 1 = Q 0

J0 = Q 1′ , K0 = Q 1 , Q 0+ = J0 Q 0′ + K0′ Q 0 = Q 1′ Q 0′ + Q 1′ Q 0 = Q 1′

Q 1+ Q 0+
Initially 0 0
CP-1 0 1
CP-2 1 1
CP-3 1 0
CP-4 0 0

it is a mod 4 counter, after every 4th clock pulse, it will return to initial.

333mod4 = 1 , so after 332 clock pulse it will return to 00 and on 333rd it will reach to 01.

 1 votes -- Praveen Saini ( 34299 points)

10.36 Flip Flop: ISRO-2013-30 top gateoverflow.in/43965

In a three stage counter, using RS flip flops what will be the value of the counter after giving 9 pulses to its input? Assume
that the value of counter before giving any pulses is 1.

A. 1
B. 2
C. 9
D. 10

isro2013 digital-logic flip-flop


Selected Answer

3 stage counter with RS FF is 3 bit counter, so after every 8 clock pulse, it will return to initial state.

Initial state is 1, state after 8 clock pulse will be 1, So, after 9th clock pulse , state will be 2.

 1 votes -- Praveen Saini ( 34299 points)

10.37 Flip Flop: What happens when the input of a flip flop changes exactly
at the time of the clock pulse transition? top gateoverflow.in/17717

Will the output be as per previous values or new values?

flip-flop digital-logic

It depends upon implementation . say if its a D Flip flop then it will change the output (if 0 then 1 like that ), if J K then it
may change or not ,

say both of J and K are attached to input . then input 1010101 , then for 0 (j=0 k= 0)it will not change the state .

 0 votes -- Pranay Datta ( 6113 points)

10.38 Flip Flop: Design a counter for the following binary sequence:
0,4,5,3,1,6,2,7 and repeat.Use JK flip-flops | IIIT-Hyderbad top gateoverflow.in/42222

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1447 of 2244

Design a counter for the following binary sequence: 0,4,5,3,1,6,2,7 and repeat.Use JK flip-flops

digital-logic flip-flop


Selected Answer

Please see the solution in the image below. putting image because lot of editing required.

 1 votes -- Lord_Krishna ( 665 points)

10.39 Flip Flop: When a JK flip flop is constructed from an SR flip flop gateoverflow.in/32443

top

When a J-K flip-flop is constructed from an SR flip-flop

a) S = JQ, R = K+JQ

b) J = S, K = R

c) J = SR'Q, K = S'(R+Q)

d) S = JQ', R = KQ

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1448 of 2244

flip-flop digital-logic

D) S=JQ', R=KQ

To eliminate racing condition when S=1 & R=1, we connect S=JQ' & R=KQ

 0 votes -- vamsi2376 ( 1185 points)

10.40 Floating Point Representation: largest normalized number. top gateoverflow.in/27888

what is the largest normalized number hat can be represented in iee754.

they say the exponent can't be all ones so if can't be all ones then how the exponent - bias came to be 127. the maximum
exponent should be 254 and it should be 126. and why we use -126 while finding denormalized number.

digital-logic floating-point-representation


Selected Answer

Denormalized numbers are for filling the gap between 0 and the smallest positive number in normalized representation.
This link should be good.

http://steve.hollasch.net/cgindex/coding/ieeefloat.html

 1 votes -- Arjun Suresh ( 124125 points)

10.40 Functional Completeness: How to prove if a boolean function is


functionally complete? top gateoverflow.in/42522

functional-completeness

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1449 of 2244

A set of Boolean function is called functionally complete, if all other Boolean functions can be constructed from this set.

eg:- {AND,OR,NOT} is a functionally complete set.

As, from this set we can derive NOR,NAND,XOR, XNOR,etc any type of function.

 2 votes -- Ashish Gupta ( 631 points)

A set is said to functionally complete if we can derive a set witch is already functionally complete. Eg. of functionally
complete set {AND ,OR,NOT}, {OR,NOT},{AND,NOT} So to prove a boolean functionally complete derive any one of the
above.

 2 votes -- Manojk ( 3365 points)

10.41 Functional Completeness: ISRO-2013-22 top gateoverflow.in/43845

Any set of Boolean operators that is sufficient to represent all Boolean expressions is said to be complete. Which of the
following is not complete?

A. {NOT, OR}
B. {NOR}
C. {AND, OR}
D. {AND, NOT}

isro2013 functional-completeness


Selected Answer

NAND AND NOR are universal gate and with the help of these gates we can implement any other function. Hence they are
called functionally complete

option a)

Not + Or = Nor gate only

option b ) It says NOR

option d ) And + not = NAND gate

So remaining is option c---which is answer :)

 1 votes -- Dexter ( 1933 points)

10.42 Functional Dependencies: Pas besoin de porter le kilt pour être en


Scottish... top gateoverflow.in/43775

http://www.chaloma.be/birkenstock-sandales-femmes-c-51.html Pas besoin de porter le kilt pour être en Scottish... Composition : dessus coton 100% -
intérieur laine 100% - semelle feutre avec patin caoutchouc anti-dérapant. La charentaise est un chausson chaud, confortable et léger. Livrée avec une trousse cadeau. ATTENTION CHAUSSE
PETIT : nous vous conseillons de prendre une pointure au-dessus. 2 articles ou...

functional-dependencies

What is this ? It is not a sales website you should go somewhere else to sale your Sandales. And it is not a functional
dependencies Question.nor DLD.

 0 votes -- shekhar chauhan ( 643 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1450 of 2244

10.43 Gray Code: Question on gray code top gateoverflow.in/33762

I read somewhere that gray code is self-complementing but I couldn't find any explanation for that. Please tell if anyone has
some idea about it.

digital-logic gray-code


Selected Answer

It's not self complementing because as per definition of Self Complementing "9 complement of number and 1's
complement of digits must be same"

0001 -> 0001(Gray Code) I's complement :1110 9's complement (9-1 = 8):: 1000 so it's not same

 1 votes -- deepakanand41 ( 123 points)

10.44 Gray Code: Mux & Gray Code top gateoverflow.in/34133

digital-logic gray-code


Selected Answer

(92)10 = (10010010)bcd = (11011011)graycode = (219)10

Input line I219 will be selected.

 1 votes -- Praveen Saini ( 34299 points)

10.45 Ieee Representation: Floating point top gateoverflow.in/32875

The decimal equivalents of 01440000 a 32- bit hexadecimal representation of IEEE single-precision floating point number is

a. 1.11 × 2 −125
b. 1.88 × 2 −125
c. 1.68 × 2 −124
d. 1.88 × 2 −129

floating-point-representation ieee-representation

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1451 of 2244


Selected Answer

01440000

0|000 0001 0|100 0100 0000 0000 0000 0000

1st bit sign = +ve

next 8 bits - x-cess 127 bias so exponent = 2-127 = -125

mantissa 100 01 = (1.10001) = (1+1/2+1/32)=49/32= 1.53

1.53125 * 2^-125

 4 votes -- bahirNaik ( 2479 points)

10.46 Ieee Representation: please explain what is the precision in terms of


the number of decimal digits? top gateoverflow.in/15030

In the standard IEEE 754 single precision floating point representation, there is 1 bit for sign,23 bits for fraction and 8 bits
for exponent .what is the precision in terms of the number of decimal digits?

a) 5 b) 6 c)7 d) 8

number-representation ieee-representation

Precision is the number of digits we can represent accurately.

1.2 × 108 - precision is just 2 and rest we have 8 zeroes which might not be accurate.

So, in IEEE 754 floating point representation we have 23 precision bits and we also have one implied bit before '.' making
it 24 precision bits. With 24 bits we can represent 24log2 = 7 decimal digits.

 0 votes -- Arjun Suresh ( 124125 points)

10.47 K Map: Question on K-maps top gateoverflow.in/33757

Given explanation.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1452 of 2244

I am not able to understand what is asked in the question. Please explain.

digital-logic k-map

There is two types of K-Maps 1) All Possible Type 2) Minimal Type

All Possible Type

Every combination we have to count 17

Minimal Type

only minimal we have to count 14

 0 votes -- deepakanand41 ( 123 points)

10.48 K Map: Let f(x,y,z) = x' + y'x + xz be a switching function. Which one
of the following is valid? top gateoverflow.in/6650

Let f(x, y, z) = x ′ + y ′ x + xz be a switching function. Which one of the following is valid?

A. y ′ x is a prime implicant of f
B. xz is a minterm of f
C. xz is an implicant of f
D. y is a prime implicant of f

digital-logic k-map


Selected Answer

xz is an implicant and ¬y is both prime and essential prime implicant. The sop would be z + ¬x + ¬y.

Implicant: Something that implies a function is its implicant


Prime implicant: The most reduced (minimal) implicant
Essential prime implicant: The prime implicant which cannot be avoided in any SOP

Ref: https://en.wikipedia.org/wiki/Implicant

 4 votes -- Shaun Patel ( 5445 points)

10.49 K Map: K-Map top gateoverflow.in/37001

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1453 of 2244

How to comprehend this k-map? Usually we have 00,01,10,11 terms in K-map. But what does those (C+D) terms signify

k-map digital-logic

answer is (B+D)

 0 votes -- Registered user 7 ( 343 points)

10.50 K Map: Number of literals in this K-map top gateoverflow.in/35941

They have taken 1 extra combination which is already a subset of 2 other combos. Is it because that they have asked ALL
POSSIBLE k-maps??? Is it right?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1454 of 2244

k-map digital-logic ace-test-series

No it is 14 only..
1 Quad and 3 Pair.

ABC' + A'C'D + A'BC + AB'C + BD

 0 votes -- Digvijay Pandey ( 26245 points)

10.51 Logic: boolean algebra top gateoverflow.in/18694

which of the following boolean algebra expression is incorrect ?

a . (abc)' + bc + ac = c

b . (a+b)(a'(b'+c'))' + b'c' + a'c' = 1

c . ab + a'c + bc = ab +ac

d . ab + ac' = b

guys can anyone solve this question...

i am not finding the way how to solve this...

digital logic


Selected Answer

a)(abc)'+bc+ac=a'+b'+c'+bc +ac

=a'+ac+b'+c+bc

= a'+c+b'+c'+b

=a'+1

=1

so a is incorrect

b)(a+b)(a'(b'+c'))'+b'c'+a'c'=(a+b)(a+bc)+b'c'+a'c'

=a+abc+ab+bc+b'c'+a'c'

=a(1+bc+b)+bc+b'c'+a'c'

=a+bc+b'c'+a'c'

≠1

so b is incorrect

c)ab+a'c+bc=ab+a'c (consensus theorem)

d)ab+ac'!=b

so all options seems incorrect

 0 votes -- Pooja ( 22773 points)

10.52 Logic: counting speed top gateoverflow.in/18964

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1455 of 2244

what is the maximum counting speed of 4-bit binary counter which is composed of flip-flops with a propagation delay of
25ns?

digital logic

i think it will be 25 ns because it is given , the maximum speed, which can be attained by sychronous counter only.

and here is 4 bit counter http://www.electronics-tutorials.ws/counter/count_3.html

 0 votes -- Ravi Singh ( 7303 points)

10.53 Multiplexer: Number of multiplexer required top gateoverflow.in/37532

The number of two input multiplexers required to construct a 210 input multiplexer is,

A. 31

B. 10

C. 127

D. 1023

digital-logic test-series multiplexer


Selected Answer

2 10

No of 1st level 2: 1MUX = 2 = 29


29

No of 2nd level 2: 1MUX = 2 = 28


.
.
.
21

no of 10th level 2: 1MUX = 2 = 1


sum of all, Number of 2: 1MUX required = 29 + 28 + . . . . . . . . . + 1 = 1023

 1 votes -- Digvijay Pandey ( 26245 points)

10.54 Multiplexer: multiplexer top gateoverflow.in/11336

by using a 8 * 1 MUX if 4 variable function is realized then the circuit is ?

(a) unique circuits

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1456 of 2244

(b) 2 possible circuits

(c) multiple possible circuits

(d) not possible to realise the boolean function

multiplexer

Ans -(c) Multiple possible circuit

we have a 8*1 Mux and a 4 variable boolean function(say w,x,y,z) .So , to implement a 4 variable boolean
function by using a 8*1 mux

1.>we need to apply any three of the input to the three selection line of mux which can be done in 24 ways.
(The first selection line s 0 can be w or x or y or z and in the same way s1 has 3 possibilty ,s2 has 2 possibilty

total combination=4ways *3ways*2ways=24ways)

2.>The remaining one input will be adjusted in the 8 input line.

so,for each possible combination out of those 24 combination we will get a completly different ckt but the
functionality of all thesr ckt will be same.

 1 votes -- Saurav Kumar Gupta ( 1455 points)

10.55 Multiplexer: ME_Digital1.1 top gateoverflow.in/37379

multiplexer

the answer you have chosen is correct only. no qualms.

 0 votes -- resilientknight ( 51 points)

10.56 Multiplexer: Function F implemented using MUX top gateoverflow.in/34288

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1457 of 2244

digital-logic multiplexer


Selected Answer

F = A ′ B ′ I0 + A ′ BI1 + AB ′ I2 + ABI3

F = A ′ B ′ C + A ′ BC + AB ′ C ′ + ABC (assuming order as ABC, A MSB and C LSB)

F(A, B, C) = Σm(1, 3, 4, 6)

 4 votes -- Pooja ( 22773 points)

10.57 Nand Nor: Number of Nor gates top gateoverflow.in/35739

Consider the Boolean function f(A, B, C, D) = Π(1, 2, 4, 5, 6, 8, 10). Determine the minimum number of NOR gates required to
implement the function f. Assume both primed and unprimed variables are available.

Please help me how to solve this kind of problems

digital-logic nand-nor

We need minimum number of NOR gates so it is better to find function in POS

C′D ′ C′D CD CD ′
A′B′ 0 0 0
A′B 0 0 0
AB
AB ′ 0 0

we get 3 quads, (0, 1, 4, 5), A ′ C ′ , (0, 2, 4, 6), A ′ D ′ and (0, 2, 8, 10), B ′ D ′

F′ = A′C′ + A′D ′ + B′D ′

F = (A + C)(A + D)(B + D)

F = (A + CD)(B + D)
¯
¯ ¯
(A + CD) + (B + D)
F=

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1458 of 2244

¯
¯
¯
¯
′ ′
(A + C + D ) + (B + D)
F=

We need 4 Nor gates

 3 votes -- Praveen Saini ( 34299 points)

10.58 Network Switching: Simplify given switching network top gateoverflow.in/34189

digital-logic network-switching boolean-expressions

i am getting ABD'+ACD'.

A(B+C)D'(P+P')

 0 votes -- pritika kundu ( 677 points)

10.59 Number Representation: ISRO-2013-13 top gateoverflow.in/43803

The number 1102 in base 3 is equivalent to 123 in which base system?

A. 4
B. 5
C. 6
D. 8

isro2013 number-representation


Selected Answer

Answer 5

(1102)3=1⨉33+1⨉32+2=38

(123)x=1⨉x2+2x+3

Now, 1⨉x 2+2x+3=38

x=5

 2 votes -- srestha ( 11585 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1459 of 2244

10.60 Number Representation: ISRO-2013-17 top gateoverflow.in/43814

Two eight bit bytes 11000011 and 01001100 are added. What are the values of the overflow, carry and zero flags respectively, if
the arithmetic unit of the CPU uses 2's complement form?

A. 0, 1, 1 ′
B. 1, 1, 0
C. 1, 0, 1
D. 0, 1, 0

isro2013 digital-logic number-representation


Selected Answer

I think it is D

11000011

01001100

= (1) 00001111 with Carry =1 (specified in bracket )

The zero flag will be set if result is 0 . but here the result is not 0 so zero flag is set to 0

For overflow we have condition of C = Carryout Exor Carry In

where Carry out is carry from MSB (bit 8 ) // taking byte as from bit1 to bit 8

Carry in carry from bit 7

So carry out = 1

carry in 1

so exor of both of them is 0 --- which will be carry flag

So option d

carry flag - 1sum -- 0 overflow is 0

 2 votes -- Dexter ( 1933 points)

10.61 Number Representation: number syatem top gateoverflow.in/44239

A decimal number has


25 digits. The number of bits
needed for its equivalent
binary representation is,
approximately,
a) 50
b) 55
c) 80
d) 75
Explain??

number-representation

Here d=digits in decimal representation

n= bit in binary representation

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1460 of 2244

d>n log10 2

25=n*.3010

n=83 Apx

 2 votes -- Manojk ( 3365 points)

10.62 Number Representation: ISRO-2013-8 top gateoverflow.in/43765

Which logic gate is used to detect overflow in 2's compliment arithmetic?

A. OR gate
B. AND gate
C. NAND gate
D. XOR gate

isro2013 number-representation


Selected Answer

Overflow detection circuit for 2's complement addition

One way to detect it is to XOR the carry in and the carry out.
1. If the sum of two positive numbers yields a negative result, the sum has overflowed.
2. If the sum of two negative numbers yields a positive result, the sum has overflowed.
3. Otherwise, the sum has not overflowed.

It is important to note the overflow and carry out can each occur without the other. In unsigned numbers, carry out is
equivalent to overflow. In two's complement, carry out tells you nothing about overflow.

The reason for the rules is that overflow in two's complement occurs, not when a bit is carried out out of the left column, but
when one is carried into it. That is, when there is a carry into the sign. The rules detect this error by examining the sign of the
result. A negative and positive added together cannot overflow, because the sum is between the addends. Since both of the
addends fit within the allowable range of numbers, and their sum is between them, it must fit as well.

 2 votes -- shekhar chauhan ( 643 points)

Xor gate is used .

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1461 of 2244

 2 votes -- Dexter ( 1933 points)

10.63 Number Representation: What is the value of base x? top gateoverflow.in/40435

Given

(135)x + (144)x = (323)x

What is the value of base x ?

number-representation


Selected Answer

here is my solution

 4 votes -- Joker ( 685 points)

SHORTCUT:

(135)x + (144) x = (323) x

Just take last digit of each term and compare, 5+4=9, but it is coming as 3, so divide it by such a number so that
remainder will remain 3. so, 6 is the answer.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1462 of 2244

 2 votes -- Aryan ( 223 points)

x = 6 explaination : (135)base x + (144) base x = (323)base x means... (1x^2 + 3x + 5) + (1x^2 + 4x + 4) = (3x^2 +


2x + 3) ...... then .... 2x^2 + 7x + 9 = 3x^2 + 2x + 3 x^2 - 5x - 6 = 0 ...... by division method we get ... (x-6)(x+1)=0
so .... as x must be positive ..x=6

 1 votes -- Rahul Singla ( 187 points)

10.64 Number Representation: why do we have terminology of positive and


negative zero ? top gateoverflow.in/25861

If we use diminished radix representation then representation for 0 will be b^n-1 where b is the base so this representation
is for 0 , how come we are associating +0 and -0 for this ?

Normally also we have representation for 0 , so again this b^n-1 is a representation for 0 so why to associate sign to it ?

number-representation


Selected Answer

lets take example for all the cases. signed , unsigned , 1;s and 2's . i think they generated the system by dividing all the
numbers into half,. But they even willingly can't represent +0 and -0 see this

10 -10 +0 -0
unsigned 1010 n/a 0000 n/a
signed 01010 11010 00000 10000
1's 01010 10101 00000 11111
2's 01010 10110 00000 00000

everything other than zero has different form except zero . so even though they thought of following the same convention
it could not be followed.

 0 votes -- Ravi Singh ( 7303 points)

10.65 Number Representation: Verify whether 4-3-1-1 code is self


complementing or nt? top gateoverflow.in/35279

Please provide codes for 0-9 decimal using 4311 code..i am little bit confused in it..I know the property that addition 9
makes it self complemetory..but how m nt understanding..plz help..

number-representation


Selected Answer

Yes It is a self-complementing code

n 4311
0 0000
1 0001
2 0011
3 0100
4 0101
5 1010
6 1011

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1463 of 2244

7 1100
8 1110
9 1111

1). There is property, of self complementing code, that,code of 9 ′ s of a decimal number is obtained directly by changing
0 ′ s to 1 ′ s and 1 ′ s to 0 ′ s

example: 9 ′ s complement of 2 is 7, change 0 ′ s to 1 ′ s and 1 ′ s to 0 ′ s in 4311 code of 2 , we will get 1100, that is 4311 code of 7

2). Interesting thing I found that sum of weights of self-complementing weighted code makes a total of 9, i.e,
4 + 3 + 1 + 1 = 9, checked with other self-complementing codes as 2421, 84 − 2 − 1, 5211, and 642 − 3.

 1 votes -- Praveen Saini ( 34299 points)

10.66 Number Representation: Is 2's complement of -57 is 110001110 ? top


gateoverflow.in/35626
Please answer silly but needful question

number-representation

10.67 Number Representation: hexadecimal subtraction top gateoverflow.in/29729

Given that (E0B)16 − (ABF)16 = Y.


The radix 8’s compliment of Y is ?

number-representation


Selected Answer

(EOB)16 - (ABF) 16 =(34C)16

(34C)16 =(1514)8

for 7's complement (7777) 8 - (1514)8 =(6263)8

for 8's complement (6263)8 +1 =(6264)8

 4 votes -- srestha ( 11585 points)

10.68 Overflow: Overflow condition in boolean expression top gateoverflow.in/37692

two 2's complement nos. having sign bits x and y are added and the sign bit of result is z. Then the occurrence of overflow is
indicated by the expression???

The answer is given as x'y'z + xyz' .

As far as I know, Overflow is indicated by Cn XOR C(n-1).

So, here Cn is 'z' and C(n-1) is x+y . Whose XORing gives me.. x'y'z + xz' + yz'.

digital-logic boolean-expressions overflow made-easy

overflow will occur when sign of z is different from x and y

ie x y 0 and z 1 or x y 1 and z=0

that gives x'y'z+xyz'

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1464 of 2244

 0 votes -- Pooja ( 22773 points)

10.69 Pla: ISRO-2013-29 top gateoverflow.in/43964

How many programmable fuses are required in a PLA which takes 16 inputs and gives 8 outputs? It has to use 8 OR gates
and 32 AND gates.

A. 1032
B. 776
C. 1284
D. 1536

isro2013 digital-logic pla

10.70 Radix: Value of R1 R2 and R3 top gateoverflow.in/36824

√36r1 + 25r2 = 21r3


Find r1 r2 r3.. ?

radix


Selected Answer

r3=3

r2=7 and r1=8

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1465 of 2244

 1 votes -- . ( 135 points)

10.71 Self: ugc net top gateoverflow.in/43902

self dual-function

Option d is right .

 0 votes -- Dexter ( 1933 points)

10.72 Sequential: what is 9 clock cycles what are output at q0 q1 q2? gateoverflow.in/16030

top

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1466 of 2244

digital-logic sequential circuit-output


Selected Answer

Clock pulse ↓ state (q2q1q0)↓

Starting 000

1st clock 001

2nd clock 010

3rd clock 100

4th clock 011

5th clock 111

6th clock 100

7th clock 010

8th clock 100

9th clock 010

 1 votes -- Digvijay Pandey ( 26245 points)

10.73 Sequential: A switch tail ring counter is made by using a single D FF. top
gateoverflow.in/32444

A switch-tail ring counter is made by using a single D FF. The resulting circuit is

(a) SR flip-flop (b) JK flip-flop

(c) D flip-flop (d) T flip-flop

sequential digital-logic flip-flop

Answer is d.

https://www.youtube.com/watch?v=NgHdSqy1YKw

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1467 of 2244

 0 votes -- . ( 135 points)

10.74 Sequential: Which of the following circuit is called Latch top gateoverflow.in/32442

made-easy sequential

10.75 Sequential: Consider the following circuit of counter top gateoverflow.in/38382

sequential digital-logic

10.76 Sequential: digital _made easy top gateoverflow.in/38413

answer given is 101

Consider the sequential circuit given below

If all the flip flops are initially cleared then the count after 115 clock pulses ( Q 2Q 1Q 0) is ________.

made-easy test-series digital-logic sequential


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1468 of 2244

Characteristic equation of JK FF, Q t +1 = JQ t′ + K ′ Q t

J0 = 1, K0 = Q 2 , Q 0+ = Q 0′ + Q 2′ = (Q 0 Q 2 ) ′

J1 = Q 0 ⊙ Q 2′ , K1 = 1, Q 1+ = (Q 0 ⊕ Q 2 )Q 1′

J2 = Q 1 , K2 = 1, Q 2+ = Q 1 Q 2′

Clock Pulse Q 2 Q 1 Q 0
Initially 000
1 001
2 011
3 101
4 000

So This is a mod- 4 counter, and it reach to initial state after every 4 clock pulses.

115mod4 = 3, it means it will reach to initial states after 112 clock pulses. so at Clock pulse 115 it will be move 3 up in
sequence and reach to state 101

 3 votes -- Praveen Saini ( 34299 points)

I'm getting the sequence 000->001->011->101->000


By this every 4th pulse will give start state.
Therefore when you do 115%4 = 3,
You'll get the same result as after pulse 3 ie 101 {Q2,Q1,Q0}

 2 votes -- BhaveshSethi ( 141 points)

0->1->3->5->0

so after 4 clock pulse you get to point where you started.

here 0 is the state where you statred from.

so after 4 clock pulse you will reach 0 again.\

not 4+4+4+4+......+4 pulse will make you reach 0 again

now 115%4 =3

so after 28*4 =112 pulse you are at 0

now frm 0 apply 3 pulse.

you get to 5.

 1 votes -- viv696 ( 1431 points)

10.77 Sequential: Digital Logic Morris Mono 5.6 top gateoverflow.in/30956

A sequential circuit with two D flip-flops A and B, two inputs x and y, and one output z is specified by the following next-state
and output equations :

A(t + 1) = x ′ y + xB

B(t + 1) = x ′ A + xB

z=A

(a) Draw the logic diagram of the circuit.


(b) List the state table for the sequential circuit.
(c) Draw the corresponding state diagram.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1469 of 2244

digital-logic sequential reference-book

10.78 Sequential: digital logic top gateoverflow.in/37022

How is the correct ans c?

digital-logic sequential

Q 3+ = Q 2

Q 2+ = Q 1

Q 1+ = Q 0

Q 0+ = D

D = (Q 3 ⊙ Q 2 ) ⊙ Q 0

Q0 Q1 Q2 Q3 D
initially 0 0 0 1 1
CP-1st 1 0 0 0 1
CP-2nd 1 1 0 0 1
CP-3rd 1 1 1 0 0
CP-4th 0 1 1 1 0
CP-5th 0 0 1 1 0
CP-6th 0 0 0 1 −

 0 votes -- Praveen Saini ( 34299 points)

10.79 System: number representation top gateoverflow.in/31824

decimal number are represented in sign magnitude form +9286 and +801 convert them to signed 10s complement and
perform following operations( 1 digit required for sign)

1)-9286+ (+801)

2)-9286+(-801)

easy number system

1)-9286+ (+801)=

-9286=100000-9286= 90714

then, 90714+ (+801)=91515

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1470 of 2244

100000-91515=-8485

2)-9286+(-801)

-9286=90714

-801=99199
90714+99199=89913

100000-89913=-10087

 0 votes -- srestha ( 11585 points)

10.80 Systems: number conversions top gateoverflow.in/31814

represent number 6248 in

BCD

excess three code

2421 code

6311 code

easy number systems


Selected Answer

BCD : 0110 0010 0100 1000

EX-3 : 1001 0101 0111 1011

2421 : 1100 0010 0100 1110

6311 :1000 0011 0110 1011

 1 votes -- Prabhanjan R ( 747 points)

BCD conversation :- Convert each digit into groups of four binary digits equivalent.

6248 = 6 - 0110 2-0010 4 - 0100 8-1000

(6248)10 = (0110 0010 0100 1000)


BCD

EXCESS THREE CODE :-

Add +3 in each digit then convert into groups of four binary digit equivalent.

6+3 = 9 , 2+3=5 , 4+3 = 7, 8+3 = 11,

(9)10 = (1001)excess3 , (5)10 = (0101)excess3, (7)10 = (0111)excess3, (11)10 = (1011)excess3

Now,combine together (6248)10=(1001 0101 0111 1011)excess3

2421 CODE :- Represent each decimal digit in binary with respect to weight 2 4 2 1.

6 = 0x21 + 1x22 + 1x21 + 0x20. 2 = 0x21+ 0x22 + 1x21 + 0x20.

4 = 0x21 + 1x22 + 0x21 + 0x20. 8 = 1x21 + 1x22 + 1x21 + 0x20.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1471 of 2244

combine all those. ANS :- (0110 0010 0100 1110)2421

6311 CODE :- Represent each decimal digit in binary with respect to weight 6 3 1 1.

6 = 1x61 + 0x31 + 0x11 + 0x11. 2 = 0x61+ 0x31 + 1x11 + 1x11.

4 = 0x61 + 1x31+ 0x11 + 1x11. 8 = 1x61 + 0x31 + 1x11 + 1x11.

combine all those. ANS :- (1000 0011 0101 1011)6311


Thank you....

 1 votes -- ASHUTOSH KAKADIYA ( 55 points)

Assuming the number 6248 in decimal .

BCD : 0110 0010 0100 1000

Excess 3: 1001 0101 0111 1011

2-4-2-1 0110 0010 0100 1110 (This is not unique since the representation in 2-4-2-1 varies) Each digit is
represented as the summation like 6 is obtained 4+2 , so bit position 4,2 is made 1 in the first digit )

6-3-1-1 1000 0011 0110 1011 (This representation is also not unique and is one of the representations.

 1 votes -- Riya Roy ( 4767 points)

10.81 Digital Logic top gateoverflow.in/37021

A digital circuit shown below has two 3-bit input A2 A1 A0 and B2 B1 B0 .

To obtain output Y = 1, the number of possible cases are ______.

digital-logic


Selected Answer

Output of XOR, Y, (A2 ⊕ B2 ⊕ A1 ⊕ B1 ⊕ A0 ⊕ B0 ), is 1, only when we have ODD number of 1 ′ s in input.

Possibilities

1. One 1 out of 6 inputs = 6 C1 = 6

2. Three 1 ′ s out of 6 inputs = 6 C3 = 20

3. Five 1 ′ s out of 6 inputs = 6 C5 = 6

Total possibilities to get Y = 1 are 6 + 20 + 6 = 32

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1472 of 2244

 3 votes -- Praveen Saini ( 34299 points)

TO GET y=1 .possible cases are:

001,,,,,,010,,,,100....111

001-> A2 B2=(00,11) ,A1 B1=(00,11) ,A0B0=(10,01).....means we have 2x2x2 = 8 ways ...similarly for all ..

TOTAL 4x8=32

 1 votes -- Deepesh Kataria ( 1207 points)

10.82 ME_Test_Series_DLD_Question - All the logic gates in the circuit


shown below have finite propagation delay. top gateoverflow.in/36189

All the logic gates in the circuit shown below have finite propagation delay. The circuit can be used as a clock generator, if

a) X = 0

b) X = 1

c) X = 0 or 1

d) X = Y

made-easy test-series digital-logic


Selected Answer

it looks like asynchronous sequential circuit.


here, Next state, Y = x ⊕ y , where x is input , y is present state

Present state input


Next state Y
y x
0 0 0
0 1 1
1 0 1
1 1 0

At x = 0, circuit reach to stable state, if y is 0, it will remain 0, or if it is 1 it will remain 1.

At x = 1 , states goes 0 to 1 , 1 to 0, so on , will not reach to stable state.

At x = y, next state will remain always at 0, as seen in table.

so , At x = 1 , the above circuit will generate the sequence of 0,1,0,1.. , can be used as clock generator.

 2 votes -- Praveen Saini ( 34299 points)

10.83 dbms top gateoverflow.in/37047

r(a,b,c,d,e) what is largest no. of candiate keys at the same time

10.84 plz explain top gateoverflow.in/11625

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1473 of 2244

A JK flip flop has propagation delay of 13ns. what is the largest MOD ripple counter that can be constructed using such flip
flop and can be operated upto 10MHZ?

1.MOD - 32

2 MOD - 64

3 MOD - 128

4 MOD - 256


Selected Answer

For ripple counter T(clock) >= N*(propagation delay of FF) // N is no of FF as the output from the final flipflop comes only
after propagation delay of all n FFs.

Frequency = 10MHz means T(clock) = 0.1 Micro second


Apply formula,
0.1 micro second >= N* 13ns
Max value of N is 7..
With 7 Flip Flop, max mod value is 128..

Ref: http://mti.kvk.uni-obuda.hu/adat/tananyag/digit2/angolkepzes/dt_2_lecture04w.pdf

 4 votes -- Digvijay Pandey ( 26245 points)

10.85 COUNTER top gateoverflow.in/37117

10.86 ME_Test_Series-DLD top gateoverflow.in/36190

In figure, initially Q = A = B = 0. After three clock triggers, the states of Q, A and B will be respectively is ___________.

made-easy test-series digital-logic


Selected Answer

Positive edge trigger Counter is used.

After 3 clock pulse, new Q, A and B will be 1,1 and 0 , respectively

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1474 of 2244

Q goes 0 to 1 ,
work as positive edge
Clock pulse 1 Old Q =0 New Q = 1 trigger to Counter old AB = 00 New AB = 01
clock,
Counter goes UP
Q goes 1 to 0 ,
work as negative edge
Clock Pulse 2 Old Q =1 New Q =0 trigger to Counter old AB = 01 New AB = 01
clock,
No change at Counter
Q goes 0 to 1 ,
work as positive edge
Clock Pulse 3 Old Q =0 New Q = 1 trigger to Counter old AB = 01 New AB = 10
clock,
Counter goes UP

 2 votes -- Praveen Saini ( 34299 points)

10.87 Decoder top gateoverflow.in/37191

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1475 of 2244

digital-logic

10.88 wts mean of this statement?? top gateoverflow.in/12089

In 2’s complement the significant information is contained in the 1’s of positive numbers and 0’s of the negative numbers.

Integer
2's Complement
Signed Unsigned

5 5 0000 0101

4 4 0000 0100

3 3 0000 0011

2 2 0000 0010

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1476 of 2244

1 1 0000 0001

0 0 0000 0000

-1 255 1111 1111

-2 254 1111 1110

-3 253 1111 1101

-4 252 1111 1100

-5 251 1111 1011

look at the above example.

The most significant (leftmost) bit indicates the sign of the integer; therefore it is sometimes called the sign bit.

If the sign bit is zero,

then the number is greater than or equal to zero, or positive.

If the sign bit is one,

then the number is less than zero, or negative.

 0 votes -- Rohan Ghosh ( 1515 points)

10.89 ugc net dec 2012 paper 2 code 87 computer science & application top
gateoverflow.in/11695

http://ugcnetonline.in/question_papers_december2012.php

in this paper 2 question 1 y ans is not d y a plz explain must

The answer is A . C can`t be 0 so option(c) is canceled and if you put option (b) values then Y= 0 (i think 'f' is Y here ). So
(b) is canceled . Remaining A and D both satisfied the circuit (Y =1 ) but if you see they say the "STEADY state" , so
before turning on the circuit the value of Y (f) may be 0 , now

option (d) then A(1) nand 0(f) = 1 ------> B(1) nand 1 = 0 -----> C(1) and 0 = 0 (f)

option (a) then A(0) nand 0(f) = 1 ------> B(0) nand 1 = 1 -----> C(1) and 1 = 1 (f) satisfied the circuit .

 0 votes -- Pranay Datta ( 6113 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1477 of 2244

10.90 what is minimum no of SOP expressions ? top gateoverflow.in/36431

In a K-Map , it was found that essential prime implicants are covering all terms except 2 minterms . Those 2 minterms are in
turn covered by 3 non-essential prime implicants each , so how to approach for calculating no of minimal SOP's ?

10.91 Please explain how to approach such problems top gateoverflow.in/36374

Given explanation:

I always fail to solve such questions. Please tell what is the approach to solve such problems?

digital-logic

10.92 solve this question from multiplexer top gateoverflow.in/12329

10.93 expalin EPI with K MAP HERE.?? top gateoverflow.in/12198

Consider the Boolean expression f(A,B,C,D) = Σm (0, 1, 2, 5, 7, 8, 10, 12,


14, 15). Find the possible number of essential prime Implicants .??

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1478 of 2244

sorry i hav not equipment to drow this so to cover green color 1 there are two only possible way to group these green 1's
so EPI are

(a)B'D'

(b)AC'D'

SO ONLY 2 EPI

 2 votes -- saket nandan ( 1853 points)

10.94 Calculating number of NAND gates required for building a circuit gateoverflow.in/36802

top

I want to know is there any standard way to find out number of NAND

gates required to build the circuit. For example in


this question:

digital-logic

My Answer is

In Question they have asked to find no. of nand gates so get sop form of that function and have nand gates at last nand gate replace it with or gate representation of nand gate

If No. of Nor gates are asked then get pos form of function and have all nor gates replace last nor gate with and representation of nor gate

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1479 of 2244

 0 votes -- shivanisrivarshini ( 2067 points)

10.95 The digital operations such as AND, OR, NOT can be performed by
using top gateoverflow.in/3321

The digital operations such as AND, OR, NOT can be performed by using

A)switches

B)amplifiers

C)rectifiers

D)oscillators

digital-logic

switches, which are nothing but multiplexers.

 1 votes -- Arjun Suresh ( 124125 points)

10.96 commment top gateoverflow.in/12566

Which of the following is functionally complete set?


a. {NOT, OR}
b. {AND, OR}
c. {AND}
d. All of these


Selected Answer

A collection of logical operators is called functionally complete if every compound proposition is logically equivalent to a
compound proposition involving only these logical operators.
So here option A is correct. NOT & OR form a functionally complete collection of logical operators.

 5 votes -- Anurag Pandey ( 8183 points)

10.97 solve top gateoverflow.in/12562

Given (135)x + (144)x = (323)x. What is the value of base x ?


Selected Answer

this problem has a shortcut .

in which base : 5+4 = 3 occurs

the answer is in base 6 .

you dont have to calculate all . ( its a shortcut :D )

 2 votes -- Pranay Datta ( 6113 points)

10.98 ME Test Series Question - DLD top gateoverflow.in/35495

The number of AND gates are present inside a 5-bit carry look ahead generator circuit are ______.

test-series made-easy digital-logic

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1480 of 2244

For n bit cla ,the no of AND gate is n*(n+1)/2

So,for 5 bit, the no of AND gate is 15

 1 votes -- Sayantan Ganguly ( 5061 points)

10.99 solve top gateoverflow.in/12561

Minimum number of 2 × 1 multiplexers required to realize the following


function

f=A'B'C+A'B'C'
Assume that inputs are available only in true and boolean constants 1
and 0 are available.

this f = a'b'c +a'b'c =a'b' =(a+b)' which is NOR of a and b and to implement a NOR gate two 2:1 multiplexers are
required. Therefore answer is 2.

 2 votes -- shreshtha5 ( 1227 points)

f= A'B'C+A'B'C ' = A 'B'(C+C') = A'B'

so three 2:1 mux required to implement this function ( if you use 2:1 MUX only)

and if we use a not gate then this function can be implemented by only one 2:1 MUX .

 1 votes -- Pranay Datta ( 6113 points)

10.100 plz answer.. top gateoverflow.in/12673

Answer is B )

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1481 of 2244

 0 votes -- Pranay Datta ( 6113 points)

10.101 ME Test Series - DLD Question on Binary Counter top gateoverflow.in/35024

A binary counter is being pulsed by a 256 KHz clock signal.The output frequency from the MSB flip-flop is 2 KHz. The MOD
number is _______ .

digital-logic made-easy test-series


Selected Answer

f out

fout = N

256

2= N

N = 128

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1482 of 2244

 2 votes -- Praveen Saini ( 34299 points)

10.102 how many flip flops are required to design modulo-272 counter A.8
B.9 C.27 D.11 top gateoverflow.in/12684

THE

digital-logic


Selected Answer

(b) option

9 flip flops required

becoz :: {2 n>=N} .....

 2 votes -- kunal chalotra ( 3567 points)

10.103 what is the ans of this question? how to slove it? top gateoverflow.in/34780

Caption

AND and Inverter are serial

OR gate is parallel to them ,

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1483 of 2244

So

Max of( AND and Inverter , OR gate ) = Max of (10+6 , 11) = 16

 1 votes -- Pranay Datta ( 6113 points)

10.104 ME Test Series - DLD top gateoverflow.in/35020

Consider the logical circuit shown below:

If initially ABC = 000 then after how many clock pulses the circuit will reach its initial stage?

a) 5

b) 6

c) 7

d) 8

test-series made-easy digital-logic


Selected Answer

JA = C ′ , KA = C, So, A + = JAA ′ + KA′ A = C ′ A ′ + C ′ A = C ′


D B = A, So B + = D B = A

JC = B, KC = B ′ , So C + = JCC ′ + KC′ C = BC ′ + BC = B

So,A + = C ′ , B + = A, and C + = B

Initially ABC = 000 so counter goes as

000

100

110

111

011

001

000

After 6 clocks it will be back to initial state

Note:


1. Characterstic equation of JK FF , Qt+1 = JQt + K ′ Qt and of D FF, Qt+1 = D

2. It is a Johnson counter , having n flip-flops or (n-bit Johnson counter), and having 2n states.

3. n-bit Johnson counter is also known as mod2n counter.

 4 votes -- Praveen Saini ( 34299 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1484 of 2244

10.105 solve top gateoverflow.in/12556

In a particular number system having base B.

(√41)B =(5)10
The value of ‘B ’ is _____.


Selected Answer

(√41)b = (5)10

so , (41)b = (25)10 (squaring both)

now(41)b means

4*b1 + 1*b0 = 4b+1

therefore 4b+1 = 25

then b = 6 .

 5 votes -- Pranay Datta ( 6113 points)

10.106 Tcp Udp top gateoverflow.in/35775

An application uses UDP to send 7300 bytes of data in a single message on a path with MTU 1500 and there is an error in one of the datagrams transmitted. The
application is a reliable one and so retransmits the data again. If the same application is written to use TCP instead of UDP and there is an error in one of the
datagrams transmitted, what is the difference in bytes retransmitted using UDP as compared to TCP

computer-networks

Data send by udp =14600 (two times )

Data sent by TCP (7300 + 1500) =8800

Difference =5800

Since Udp is being used there is no reciever window and buffer that will store out of order datagrams and since its given
that the application is relaible it retransmits the whole message again.

Now Tcp has got buffer at reciving window that stores out of order segemants.

Assuming a datagram of 1500 bytes (MTU) is having error,the rest will be stored and ack will be generated for this missing
segement.Thus only this 1 would be retransmitted by the sender (after RTO or recieving 3 consective Ack's)

 0 votes -- Furqan Khan ( 11 points)

10.107 solve this question from cominational circuit top gateoverflow.in/12330

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1485 of 2244


Selected Answer

XYZ ABC

000 010

001 011

010 100

011 101

100 010

101 011

110 100

111 101

A = Y, B = Y', C = Z

 3 votes -- Digvijay Pandey ( 26245 points)

10.108 the concept of multipliers in Digital logic? top gateoverflow.in/37337

can somebody explain the concept of MULTIPLIER circuits?

please dont give links.

10.109 Universal Gate top gateoverflow.in/36075

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1486 of 2244

digital-logic


Selected Answer

NOT GATE by GATE 3 : Connect X terminal by X and Y terminal by 0.


OR GATE by GATE 3 : Let 2 level GATE 3.
1st level GATE3 inputs are :
Connect X erminal by X and Y terminal by Y

let output of this GATE is X' + Y.


Now connect this X'+Y to X terminal of next level GATE3 and Connect Y terminal by Y..

output of 2nd level GATE3 is X + Y

now i got OR as well as NOT gate from GATE3, i will make all GATE by using OR + NOT GATE..

 2 votes -- Digvijay Pandey ( 26245 points)

10.110 Number of Gate levels required top gateoverflow.in/35867

digital-logic test-series

refer this

http://cse10-iitkgp.virtual-labs.ac.in/cla_design.html

according to this for a 4 bit adder there has to be 2*4=8 gate levels. i.e. 2 per adder (AND and OR) and total 4 adders in
a 4 bit adder.

 0 votes -- dinesh94sahu ( 19 points)

10.111 Total propagation delay in Carry look ahead adderIn a 4-b top gateoverflow.in/35865

In a 4-bit carry look ahead adder, the propagation delay of Ex-OR gate is 20ns ,AND and OR gates is 10 ns.The sum and
carry output of full adder takes 20ns and 10ns respectively.The total propagation delay of the above adder in ns is
__________

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1487 of 2244

digital-logic test-series

20ns for Ex-OR GATE + 10ns For Internal NAND GATE + 10ns For next level OR GATE + 20ns for External Ex_OR GATE.
Total : 20ns + 10ns + 10ns + 20ns = 60ns

 1 votes -- Digvijay Pandey ( 26245 points)

10.112 K-Map top gateoverflow.in/12496

The expression obtained by K-Map is

a)Unique

b)Not Unique

c)Depend on Mapping

d)Can't say


Selected Answer

Expression obtained by k map need not to be unique.. it depends on mapping..

 3 votes -- Digvijay Pandey ( 26245 points)

10.113 Clock Pulses Needed top gateoverflow.in/35836

The number of Clock pulses needed to change the contents of an 8-bit-up-counter from (10101011) to (00111010) is
______________

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1488 of 2244

digital-logic made-easy


Selected Answer

171 → 255 → 58 = 84 + 59 = 143

 2 votes -- Amar Vashishth ( 17865 points)

10.114 Counter top gateoverflow.in/35863

A dual - slope analog to digital converter uses a N- bit counter,when input signal Va is being integrated ,the counter is
allowed to count up to a value

a) 2^N -2

b)2^N-1

c) Proportional to Va

d)inversely proportional to Va

digital-logic test-series

10.115 Digital Logic top gateoverflow.in/36136

digital-logic


Selected Answer

¯
′ ′
NAND with invert input = OR as A B = A + B

So

P(x, y, z) = Σ(1, 2, 4, 7)

= x ′ y ′ z + x ′ yz ′ + xy ′ z ′ + xyz

= x ′ (y ′ z + yz ′ ) + x(y ′ z ′ + yz)

= x ′ (y ⊕ z) + x(y ⊕ z) ′

= x⊕y⊕z

Q(x, y, z) = Σ(3, 5, 6, 7)

= x ′ yz + xy ′ z + xyz ′ + xyz

= (x ′ yz + xyz) + (xy ′ z + xyz) + (xyz ′ + xyz)

= yz + xz + xy

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1489 of 2244

Note:

After getting P(x, y, z) = Σ(1, 2, 4, 7) and Q(x, y, z) = Σ(3, 5, 6, 7), it must be clear, they are SUM and CARRY output of Full Adder.

 2 votes -- Praveen Saini ( 34299 points)

My Answer is

 2 votes -- shivanisrivarshini ( 2067 points)

10.116 digital top gateoverflow.in/11297

Minimise the following problems using the Karnaugh maps method.

Z = f(A,B,C) = + B + AB + AC

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1490 of 2244


Selected Answer

A'B'C' : 000

A'B = A'BC' + A'BC : 010 | 011

ABC' : 110

AC = AB'C + ABC : 101 | 111

= min { 0, 2, 3, 5, 6, 7}

Now solve k- Map..

0 1 3 2
4 5 7 6

So, 2-3-6-7, 0-2, and 5-7 can be combined. We get

B + AC + A'C'

 3 votes -- Digvijay Pandey ( 26245 points)

10.117 Derive the time complexity of the carry lookahead adder. top gateoverflow.in/42416

time-complexity

10.118 substract top gateoverflow.in/9698

( 1100 0000 0001 0010.0010 0101 ) 2 - ( 10111001110.101 ) 2 = ?

Explain in details how this substraction is performed .

digital-logic

take 2s complement of 101 1100 1110.101 which is 010 0011 0001. 011
add it to 1100 0000 0001 0010.0010 0101.

 2 votes -- Digvijay Pandey ( 26245 points)

10.119 solve top gateoverflow.in/9607

digital-logic

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1491 of 2244

both even and odd..is this correct??

 0 votes -- gate2016 ( 259 points)

10.120 solve top gateoverflow.in/9606

digital-logic


Selected Answer

Consider a state 100 representing 001 as Q2 is the rightmost in figure. The FFs are triggered on rising edge (0-1).
Ignoring the flip flop delays as it is asynchronous counter,

111 - next state 011, CLK1 changed from 1-0


011 - next state 101, CLK1 changed from 0-1, CLK2 changed from 1-0
101 - next state 001, CL1 changed from 1-0,
001 - next state 110, CLK1 changed from 0-1, CLK2 changed from 0-1
110 - next state 010, CLK1 changed from 1-0
010 - next state 100, CLK1 changed from 0-1, CLK2 changed from 1-0
100 - next state 000, CLK1 changed from 1-0
000 - next state 111, CLK1 changed from 0-1, CLK2 changed from 0-1

So, cycle repeats 7-6-5-4-3-2-1-0-7 mod 3 down counter.

So, A is the answer.

 3 votes -- Arjun Suresh ( 124125 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1492 of 2244

sir , plzz check it in above explanation i hav done this question for negative edge triggering so it will give up counter but if
i will do it by positive edge triggering then we will get down counter

so answer will be always down couter from any initial state

 2 votes -- saket nandan ( 1853 points)

10.121 decimal equivalent of BCD top gateoverflow.in/42241

What is decimal equivalent of BCD 11011.1100 ?

(A) 22.0 (B) 22.2 (C) 20.2 (D) 21.2

BCD is weighted Code which is 8421.


and BCD Code 0-9 digit only.
for eg. lets take N=12, now convert 12 into binary which is (1100)2
now Convert N=12 into BCD(Binary Coded Decimal) which is 0001 0010

So how we convert Binary no. to BCD :- just ADD 0110 into Binary Number
So 1100+0110= 10010 (make pair of 4 from right So 0001 0010 which is 12)

Now Move to the question:-


given BCD is 11011.1100 make pair of 4 we see its range is not between 0-9..So we need to correction it by adding 0110
to the place where range is not between 0-9.

0001 1011.1100
+
0000 0110.0110
=
0010 0010.0010
now make pair of 4 and we see
22.2
So ans is B

 3 votes -- Jaikishan Apurva ( 787 points)

10.122 BCD Adder top gateoverflow.in/10230

A decimal parallel adder that add n decimal digits needs how many BCD adder stages

1. n

2. 2n

3. 1

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1493 of 2244

4 n^2

10.123 00,01,10,11 as output using 2 JK flip flops top gateoverflow.in/41527

I want to know how the bit pattern 00, 01 ,10,11 may be obtained using a counter (2 JK flip flops, synchronous).

Truth table for JK :

next
clock J K
state
old
0 dc dc
value
old
1 0 0
value
1 0 1 0
1 1 0 1
1 1 1 toggle

Well according to your question, assume values of q0=0 and q1=0.

DESIRED OUTPUT IS : 00 01 10 11

J1=K1=1, J1=Q0 exor Q1 , k0=0

 0 votes -- s_ddwl ( 147 points)

10.123 The minimum no of NAND gates required to implement A+AB'+AB'C?


top gateoverflow.in/41842

ZERO Because After simplifying You would get This

A(1+B'+B'C) which is equal To A

So No need For any NAND gate


 8 votes -- saif ahmed ( 931 points)

10.123 the mimimum no of 2-input nand gates required to implement th


function F=(x'+y')(z+w)? top gateoverflow.in/41977

4 two input NAND gates

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1494 of 2244

F = (x' + y') .z + (x' +y') .w

= (xy)' .z + (xy)' .w

= ( ( (xy)'.z )' . ( (xy)'.w )' )'

We can tie the inputs 'x' and 'y' to 1 s t NAND gate to implement the function (xy)' and the output of this gate can be
connected to the inputs of the 2nd and 3 rd NAND gate.The other remaining input of the 2nd and 3 rd NAND gate will be 'w' and 'z'.The
output of 2nd and 3 rd NAND gate will than be connected to the inputs of the 4 th NAND gate.

 1 votes -- Aditya Sharma ( 687 points)

10.124 finding prime implicant top gateoverflow.in/43783

Which of the following can be a prime implicant of a function f(A,B,C)?


a) AB + C
b) BC + A
c) AC + B
d) AB

digital-logic

A prime implicant is one which is power of 2 in size . say if you have prime implicant of size 2^2 = (4) then each element
would be adjacent to 2 elements

So if you all prime implicant is of size 2

Option a

AB+C = 2^2 + 2^1 = 4 + 2 = 6 ( which is not power of 2 )

Same calculation goes for BC + A , AC+ B

But for option d

AB = 2^2 = 4 ( which is power of 2 )

Hence option d is correct

 0 votes -- Dexter ( 1933 points)

10.125 No. of minimal SOP expression top gateoverflow.in/43798

In K-map it was found out that essential prime implicants are covering all terms except 2 minterms.
Those 2 minterms are in turn covered by 3 non-essential prime implicants each.
What is the number of minimal Sum of product expression?.

digital-logic

First things we are going to add essential prime implicants in every min SOP + Extra min terms we have to add

Here extra min term which is required is 2 .So we have to cover those 2 min terms using extra terms .In order to cover each min terms they are saying that we
have 3 choices because they are saying that 2 minterms are in turn covered by 3 non-essential prime implicants each.

So

essential prime implicants +____+____ Here for each Blank we have 3 choices so 3*3 =9

9 Min Sop are possible.

 1 votes -- shekhar chauhan ( 643 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1495 of 2244

10.125 Can you please explain how there will be 2n-1 gates will be required ?
top gateoverflow.in/8913

See here:
http://deploy.virtual-labs.ac.in/labs/cse13/array_multiplier/Experiment.php?tid=T006&code=C001

 0 votes -- Arjun Suresh ( 124125 points)

10.126 solve top gateoverflow.in/9601

digital-logic

When UP/DOWN' input is 1, counter counts up and otherwise the counter counts down. So, for the negative edge of the
clock, the counting sequence will be

1 2 1 2 3 2 3 4 3 ...

The second clock produces 2, and after wards for every consecutive 3 pulses, we get an increment. So, we get 16 for clock
pulse number

2 + 3(16 − 2) = 44.

 2 votes -- Arjun Suresh ( 124125 points)

10.127 No. of P.I, ESPI,Redundant P.I, Minimal SOP, Minimal Expressions. top
gateoverflow.in/44028

For the given function f(A,B,C,D)=∑ (0, 4, 5, 10, 11, 13, 15) , find the following?
1) How many Prime Implicants are there?
2) How many Essential Prime Implicants are there?
3)How many Redundant Prime Implicants are there?
4) What is Minimal SOP?
5) How many minimal expressions are there?

digital-logic

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1496 of 2244

1)7 Prime Implicant

2)4 Essential P.I

3) Redundant Prime Implicant =3

4) Minimal SOP = C' +D+AB'

5) 2 type of minimal expression are there

 0 votes -- srestha ( 11585 points)

10.128 solve it top gateoverflow.in/9600

digital-logic


Selected Answer

Initially say, Q0=0 and Q1=0


¯
so J0=0 K0=1 and J1=1 k1 =1 [ J0 = Q1 and J1= Q0 and K0 &K1 is always 1]

Then next state Q0= 0 and Q1 = 1

so J0= 1 K0=1 and J1 = 1 K1=1

then next state Q0= 1 and Q1= 0

so J0= 0 K0=1 and J1 =0 K1=1

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1497 of 2244

next state is Q0= 0 and Q1=0

so state sequence is 00,01,10,00,.... is mod3 counter

follow given table for next state

J K Qt+1
0 0 Qt

0 1 0
1 0 1
¯
1 1 Qt

 2 votes -- Praveen Saini ( 34299 points)

10.129 solve top gateoverflow.in/9602

digital-logic


Selected Answer

3 bit jonson counter ..


initially unset means Q0,Q1,Q2 all are 0..
clock no Q2 Q1 Q0 decimal equivalent
0 0 0 0 0
1 1 0 0 4
2 1 1 0 6
3 1 1 1 7
4 0 1 1 3
5 0 0 1 1
6 0 0 0 0

now check options ..


A gives same decimal equivalent(with order) as above..

 2 votes -- Digvijay Pandey ( 26245 points)

10.130 solve top gateoverflow.in/9603

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1498 of 2244

digital-logic


Selected Answer

D = X' Z + Y Z' which an be compared with eq D = J Q' + K' Q hence option D is correct

 3 votes -- gate2016 ( 259 points)

10.131 minimization of circuit top gateoverflow.in/342


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1499 of 2244

My answer :- RS 60 :)

 2 votes -- Akash ( 26315 points)

10.132 solve top gateoverflow.in/9604

digital-logic

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1500 of 2244

¯
¯ ¯
1.Q3. Q2.Q3
Y= ( )

=Q3+Q2Q3

 2 votes -- Praveen Saini ( 34299 points)

10.132 The three outputs x1x2x3 from a 8 x3 priority enxoder top gateoverflow.in/43813

8-to-3 Bit Priority Encoder

Output Q0

Output Q1

Output Q2

Then the final Boolean expression for the priority encoder including the zero inputs is defined as:

In practice these zero inputs would be ignored allowing the implementation of the final Boolean expression for the outputs of the 8-to-3 priority encoder. We can constructed a
simple encoder from the expression above using individual OR gates as follows.

Digital Encoder using Logic Gates

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1501 of 2244

 0 votes -- shekhar chauhan ( 643 points)

10.133 Combinational Circuits top gateoverflow.in/10231

A combinational circuit is to be designed to implement a boolean Function with 3 Boolean Variables which gives output 1 if all
the inputs have same value, otherwise give 0 . If only basic gate (AND,OR,NOT) are available and if complimneted variable
is not available , then determine the minimum no of gates to design the circuit ?

1) 3

2) 4

3) 5

4) 6

10.134 dld top gateoverflow.in/39317

And is C

 0 votes -- ashish patel ( 11 points)

10.135 minimal compatibility classes top gateoverflow.in/37536

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1502 of 2244

digital-logic

WRITE THEM AS EXPRESSION= ae+acd+ad+bd

ae+ad(c+1)+bd

ae+ad+bd

 0 votes -- Deepesh Kataria ( 1207 points)

10.136 Combinational Circuits top gateoverflow.in/10237

X = A'B+A'B'C'

= A'(B+B'C')

=A'(B+B')(B+C')

=A'(B+C') minimized POS

=A'B+A'C' minimized SOP

 1 votes -- Praveen Saini ( 34299 points)

10.137 The state transistion diagram for the logic circuit is ? top gateoverflow.in/9579

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1503 of 2244

gate2012-ec

When A is 0, Y = X0 = Q' and hence next Q = Q'.

When A is 1, Y = X1 = Q and hence next Q = Q

Hence D choice.

 1 votes -- Arjun Suresh ( 124125 points)

10.138 Carry vs overflow top gateoverflow.in/1142

If we take a n bit register to store result of addition/subtraction of two n bit unsigned binary numbers , then if the end-carry
occurs , then the end-carry is the part of the result . Is it overflow or not ?

If we take a n bit register to store result of addition/subtraction two n bit signed binary numbers , then if the end-carry
occurs ,then it is the sign-bit of the result . Is it overflow or not ?

digital-logic


Selected Answer

"If we take a n bit register to store result of addition/subtraction of two n bit unsigned binary numbers , then if the end-carry occurs , then the end-carry is the part
of the result . Is it overflow or not ?"

It is indeed overflow. But overflow means nothing for unsigned operations. It is meant only for signed operations. If the carry happens out of the most significant
bit position, then result is wrong and this is denoted by CARRY flag for unsigned numbers.

"If we take a n bit register to store result of addition/subtraction two n bit signed binary numbers , then if the end-carry occurs ,then it is the sign-bit of the result .
Is it overflow or not ?"

Yes. It is overflow. And we get wrong answer here (since sign changes). And this is exactly why overflow flag is used for signed operations.

Overflow is useful for signed operations while carry flag is useful for unsigned operations.

http://teaching.idallen.com/dat2343/10f/notes/040_overflow.txt

 3 votes -- Arjun Suresh ( 124125 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1504 of 2244

10.138 A one-to-four line demultiplexer is to be implemented using


memory.How many bits must each word have? top gateoverflow.in/10360

digital-logic


Selected Answer

2 select line A and B will work as address lines, so we have 4 addresses (or words)

Each word will have 4 bits

so memory required is 4 x 4 = 16 bits

 1 votes -- Praveen Saini ( 34299 points)

10.139 Aspi_R_Osa floating point doubt1.1 top gateoverflow.in/37478

Solution:

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1505 of 2244

HOW IS THIS 0.329 calculated in BINARY?

10.140 digital counters plz solve. top gateoverflow.in/11508

This counter can count 0 to 7 (mod 8 ,without this or two input gate ) . it will count like this 000 001 ......... 101 110 111
.

the question says its a mod 6 counter so with the help of OR gate we can do it .

whenever MSB and middle significant bit get 1 their corresponding C ` value get 0 . so if we use OR gate then only for the input
value of 0 0 , it produced 0 and the counter gets cleared .

and it look like this 000 001 010 011 100 101 000 001 ..... ( whenever 1st two bit gets 1 its get cleared means when 110 appear
immediately C1 C2 C3 goes to 0 ... means 000 )

 1 votes -- Pranay Datta ( 6113 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1506 of 2244

10.140 how many NAND gate required for AC+BD+AB top gateoverflow.in/37443

According to me it should be 4.

1 for (AC)'

1 for (BD)'

1 for (AB)'

then combine all into 1 Nand as ((AC)'.(BD)'.(AB)')'---->AC+BD+AB.

 0 votes -- Tehreem Ansari ( 1327 points)

10.141 plz answer..... top gateoverflow.in/13245

A 4 bit presetable UP counter has preset input as 0101. The preset operation takes place as soon as the counter reaches
1111.The modulus of the counter is -

5,10,11,15

I think It will mod11 , as it goes through 11 states from 5 to 15.

mod 11 counter is sufficient with the combination circuit that add 101 to state outputs.

 2 votes -- Praveen Saini ( 34299 points)

10.142 Decoder top gateoverflow.in/10234

Which of following statement is true ?

S1. Any boolean function can be realized using decoder

s2. One multiplexer can realize 1 function at a time

a) S1 is true

b) S2 is true

3) Both are true

d) none of them

Both are true

One multiplexer is used for one function as it has only one output line

and decoder can be used to implement any function as if we have n input line it give 2 n output line , one for each
minterm.

 2 votes -- Praveen Saini ( 34299 points)

10.143 Find the no. of gates top gateoverflow.in/37716

In a multiplication of two 3 digit numbers (a2 a1 a0 ) and (b2 b1 b0) how many AND,XOR and OR
gates required?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1507 of 2244


Selected Answer

a2 a1 a0
× b2 b1 b0
− − − − − −
a2 b0 a1 b0 a0 b0
a2 b1 a1 b1 a0 b1 ×
a2 b2 a1 b2 a0 b2 × ×
− − − − − −
M5 M4 M3 M2 M1 M0

Initially need 9 AND gates for a0 b0 , , . . . . . . . . . . , a2 b2

then

To get M1 , we need a Half adder to add two bits.

To get M2 , we have to add 3bits + 1carry. so Need one full adder and one half adder, there will be two carry's.

To get M3 , we have to add 2bits + 2carry's, So need one full adder and one half adder, there will be two carry's

To get M4 , we have to add 1bit+ 2 carry's, so need one full adder.

*red denoting Full Adder, and cyan denotes half adder.

9 ANDs, 3 Half adders and 3 Full adders.

1 Half Adder have 1XOR and 1AND

1 Full Adder have 2XOR, 2AND and 1OR.

so finally we need 18 AND , 9 XOR and 3 OR gates.

 2 votes -- Praveen Saini ( 34299 points)

10.144 number system top gateoverflow.in/38482

A particular number system has 18 symbols from 0 to 9 , A,S,C,D,E,F,G and T. If two numbers GATE and CSE are given to
the adder the output of the adder is

a) G7CA

b) T76C

c) T7CA

d) T5SA

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1508 of 2244

As in a new number system created with radix 18 (0-9, A,S,C,D,E,F,G and T)

A -10,S-11...T-17

So

GATE --> 16 10 17 14

CSE --> 12 11 14

-------------------------------------------

T5SA <-- 17 5 11 10

So option d is correct

 0 votes -- rrakesh ( 17 points)

10.145 Couldn't understand how to approach this problem on digital logic top
gateoverflow.in/38553

Q) What is the maximum clock frequency that the sequential circuit which has the longest flip-flops delay of 2ns , the longest
setup time and hold time among the flip-flops of 1.5ns and 1ns, and the longest combinational path consists of 15 NAND
gates with tPLH = 1ns and tPLH = 0.8ns can run on for reliable operations? (31.74) MHz(correct to two decimal places).

digital-logic

10.146 Number of Prime Implicants top gateoverflow.in/39112

digital-logic

option A. The minimized expression is AC' + B'D' + BD .

 0 votes -- Sreyas S ( 1353 points)

10.147 duality top gateoverflow.in/38330

Consider the circuit diagram given below

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1509 of 2244

Given f1 = Σm (1, 2, 4, 6, 7)
f 2 = Σm (2, 3, 4, 5)
f 3 = Σm (0, 1, 2, 3)
f 4 = Σm (0, 2, 4, 6)
If the boolean function fd is dual of f 4, then the boolean function ‘f’ is ____________.

Σm (0, 1, 2, 3, 4, 5, 6, 7)
Σm (0, 1, 2, 3, 6, 7)
Σm (0, 1, 2, 3, 7)
None of these


Selected Answer

p = f1 XOR f2 = {1,3,5,6,7}
q= (p AND f3)' = {1,3}' = {0,2,4,5,6,7}

fd= dual of f4 =f4


f4' = {1,3,5,7}
r = q OR f4' = {0,1,2,3,4,5,6,7}

 2 votes -- jaunty ( 111 points)

10.148 duality top gateoverflow.in/38315

given F=∑m(0,2,4,6)

then find its F' and Fdual...in SOP form


Selected Answer

F(x, y, z) = Σm(0, 2, 4, 6) = x ′ y ′ z ′ + x ′ yz ′ + xy ′ z ′ + xyz ′

Complement of Function,

F ′ (x, y, z) = (x + y + z)(x + y ′ + z)(x ′ + y + z)(x ′ + y ′ + z)

F ′ (x, y, z) = Π M(0, 2, 4, 6)

F ′ (x, y, z) = Σm(1, 3, 5, 7)

Dual of Function,

Fd (x, y, z) = (x ′ + y ′ + z ′ )(x ′ + y + z ′ )(x + y ′ + z ′ )(x + y + z ′ )

Fd (x, y, z) = M7 . M5 . M3 . M1

Fd (x, y, z) = Π M(1, 3, 5, 7)

Fd (x, y, z) = Σm(0, 2, 4, 6)

Note:

In Dual of f, that is fd , we replace AND (. ) by OR ( + ), OR ( + ) by AND (. ), 0 by 1 and 1 by 0 ONLY.

In Complement of f, that is f ′ , we need to replace all variable, say x , by it complement variables , say x ′ , also.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1510 of 2244

Refer : http://gateoverflow.in/36297/computing-the-dual-of-the-boolean-function

 4 votes -- Praveen Saini ( 34299 points)

10.149 Number of Input and Output lines top gateoverflow.in/37840

A input function can take values {0,1,2,4,6,7} and the output can take {0,2,4,6}.

Then how many bits (lines) are required for input and output ?

My doubt is: Since only 4 different states are required to be represented (for output) , so why not use only 2 bits?

digital-logic

Answer:

Bits required for input : 3 bits

Bits required for output : 3 bits.

That's it.

 0 votes -- Lord_Krishna ( 665 points)

10.150 decoder top gateoverflow.in/38015

10.151 Combinational Circuits top gateoverflow.in/10232

A combinational circuit is to be designed to implement a boolean Function with 3 Boolean Variables which gives output 1 if all
the inputs have same value, otherwise give 0 . If only basic gate (AND,OR,NOT) are available and if complimented variable
is not available , then determine the minimum no of gates to design the circuit ?

1) 3

2) 4

3) 5

4) 6

6 gates are required

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1511 of 2244

 2 votes -- Praveen Saini ( 34299 points)

10.152 Complement vs. dual? top gateoverflow.in/37357

Is COMPLEMENT OF DUAL=DUAL OF COMPLEMENT?

How can we relate in terms of minterms,

like if f(x,y,z)=0,1,2,3,
then complement = 4,5,6,7

what would be the dual?


Selected Answer

yes!

COMPLEMENT OF DUAL=DUAL OF COMPLEMENT

Complement of dual

we have function, F(w, x, y, z, + , . , 0, 1)

dual of it, FD(w, x, y, z, . , + , 0, 1)

complement of it,[FD(w, x, y, z, . , + , 0, 1)] ′ = FN(w ′ , x ′ , y ′ , z ′ , + , . , 1, 0)

Dual of complement

we have function, F(w, x, y, z, + , . , 0, 1)

complement of it, [F(w, x, y, z, + , . , 0, 1)] ′ = FC(w ′ , x ′ , y ′ , z ′ , . , + , 1, 0)

dual of it,FN(w ′ , x ′ , y ′ , z ′ , + , . , 1, 0)

Example:

consider a + b' .
i)( COMPLEMENT OF DUAL)its dual is ab'. now the complement is (ab')'=a'+b
ii)(DUAL OF COMPLEMENT)its complement is a'b. dual would be a'+b.

 1 votes -- Satya narayana ( 129 points)

10.153 ugc net dec 15 top gateoverflow.in/33806

function of memory management unit is :

1)Address translation

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1512 of 2244

2)Memory Allocation

3)Cache management

4)All

10.154 OPERATION ON VALID DECIMAL NUMBER top gateoverflow.in/19676

a computer uses 8 digit mantissa and 2 digit exponent. If a=0.052 and b=28E+11 then b+a-b will be

result in overflow

underflow

5.28E+11

10.155 full adder using nor gates top gateoverflow.in/19677

minimum no. of nor gates required for implementing full adder:

Ans is 9

 0 votes -- srestha ( 11585 points)

10.156 ISRO-2015 top gateoverflow.in/19795

How many 32K *1 RAM chips are needed to provide a memory capacity of 256K bytes?

a) 8

b) 32

c) 64

d) 128


Selected Answer

No of chips=256K*8/32K*1

=64

 0 votes -- Pooja ( 22773 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1513 of 2244

10.157 How to realize the Boolean Expression C + B ′ A using Gates? top gateoverflow.in/19936

Note: It's B compliment.

digital-logic

It can be realised by 4 nor gates of 2 input nor.

C+B'A = (C+A)(C+B')

 1 votes -- Umang Raman ( 10379 points)

10.158 32 bit floating point representation of given decimal number top gateoverflow.in/19675

32 bit floating point representation of decimal number 3.284*10^4 is

(A) 010001101111110111000000000000

(B) 110001101111110111000000000000

(C) 011010101111110111000000..

(D) 11101010111110111000000..

For IEEE 754 single precision representation answer would be


32840.000000 0x47004800

#include<stdio.h>
int main() {
float f = 3.284e4;
printf("%f 0x%02x%02x%02x%02x\n", f,
*((char*) &f+3),*((char*) &f +2) , *((char*) &f+1), *((char*) &f+0));
}

The above code is run on a little-endian machine and hence the byte reversal. So, the answer would be

0x47004800 = (0100 0111 0000 0000 0100 1000 0000 0000) 2

32840 = (1000000001001000) 2

So, in normalized representation (implicit 1), we have 15 positions to be shifted for exponent and IEEE using bias as 127,
we get exponent field = 127 + 15 = 142 = (10001110)2

The number is positive, so sign bit is 0.

Thus we get sign bit followed by 8 exponent bits followed by 23 mantissa bits (after removing the leading 1)

0 100 0111 0 000 0000 0100 1000 0000 0000 = 0x47004800

 0 votes -- Arjun Suresh ( 124125 points)

10.159 don't care conditions for the given minimized boolean expression to
hold top gateoverflow.in/19672

The boolean expression A`BE+BCDE+BC`D`E+A`B`D`E`+B`C`DE` can be simplified to BE+B`D`E`, if the don't care
conditions are:

(A) ABCDE+AB`CDE`

(B) ABCD+AB`CDE`+ABCD`E

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1514 of 2244

(C) AB`CDE`+ABCDE+ABCD`E

(D) none

A`BE+BCDE+BC`D`E+A`B`D`E`+B`C`DE` = ∑m(0,2,4,9,11,13,15,18,31,25)

BE+B`D`E` = ∑m(0,4,9,11,16,20,25,29,31)

missing minterm are 16 20 19 which can't be achieved by any expression given in option so
option D none.

 0 votes -- Umang Raman ( 10379 points)

10.160 ISRO_A 2015/7 top gateoverflow.in/19462

If half adders and full adders are implements using gates,then for the addition of two 17 bit numbers (using minimum gates)
the number of half adders and full adders required will be

a)0,17

b)16,1

c)1,16

d)8,8


Selected Answer

Option c ) 1 half adder 16 Full adder

 1 votes -- Umang Raman ( 10379 points)

10.161 ISRO_A 2015/3 top gateoverflow.in/19485

How many 32 K x 1 RAM chips are needed to provide a memory capacity of 256 K-bytes?

a)8

b)32

c)64

d)128


Selected Answer

total number of RAM chip = Total size /1 RAM size


=256K bytes/ 32*1

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1515 of 2244

= 28 * 210 *23/ 25* 210

= 26 = 64
Option C

 0 votes -- Umang Raman ( 10379 points)

10.162 ISRO_A 2015/4 top gateoverflow.in/19487

A modulus -12 ring counter requires a minimum of

a)10 flip-flops

b)12 flip-flops

c)8 flip-flops

d)6 flip-flops


Selected Answer

12 flip flops required.


In ring counter, n flip flops generate n states where in twisted ring counter n flip flops generate 2n states.
for more info
http://www.electronics-tutorials.ws/sequential/seq_6.html

 1 votes -- Avdhesh Singh Rana ( 1509 points)

10.163 No. of MUX, NAND and NOR top gateoverflow.in/20201

To inpkement half adder we require 5 nand or 5 nor gates

If we inplement half adder using mux we require 3 mux,2 for generating sum(xor) and 1 for carry

With one 2:4 decoder we can implement half adder

 1 votes -- Pooja ( 22773 points)

10.164 denormalized range top gateoverflow.in/20889

how they find the range of denormalized number exponent . what i know is that exponent in denormalized number is all
zeros . which will lead to zero . we use access 128 in ieee 754 single precision so how exponent - bias becomes 126...and
secondly what does actually denormalized means. in case of explicit implementation it is also normalized and there is no
leading 1 before the decimal point. ?


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1516 of 2244

IEEE 754 uses normalized representation by default. i.e., it adds an implicit 1 to the left of mantissa (before "."). But
normalization has a problem as it means, the smallest positive number that can be represented is

1.0 × 20 −bias and bias is 127 which gives 1.0 × 2 −127 .

To allow smaller numbers than this we need to use denormalized representation. To incorporate this, all 0 exponent (and
non-zero mantissa) is taken for denormalized representation. That is, if all the exponent bits are 0s, there will be no
implied 1. Moreover normalized representation can no longer have all 0s as exponent- the smallest positive number in
normalized representation now becomes

1.0 × 21 −bias and bias is 127 which gives 1.0 × 2 −126 .

Now, in denormalized representation, exponent is fixed- all 0's and we add a bias of "-126". Now, we have all 23 bits for
mantissa. The smallest positive number than can be represented becomes (the last mantissa bit is 1)

1.0 × 2 −23 × 2 −126 = 1.0 × 2 −149 .

http://steve.hollasch.net/cgindex/coding/ieeefloat.html

 0 votes -- Arjun Suresh ( 124125 points)

10.164 How many minterms are present in 8 input EXOR gate ? top gateoverflow.in/26487


Selected Answer

A : 1 min term

A Ex OR B = A'B + AB' : 2 min terms

A Ex OR B Ex OR C = 4 min terms

for n variable Ex OR number of min terms are 2^(n-1).

now put n= 8, number of min terms are 2^7 =128

 3 votes -- Digvijay Pandey ( 26245 points)

10.164 K digits are required in base b for a number ,how many digits are
required in base x ? top gateoverflow.in/26621


Selected Answer

Largest number in base b = bk − 1.

Let l be the required no. of bits in base x which gives the largest number as xl − 1

klog b

We need xl − 1 ≥ bk − 1  xl ≥ bk  llogx ≥ klogb  l ≥ log x

 2 votes -- Arjun Suresh ( 124125 points)

log b^k base x = k (log b )/log x

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1517 of 2244

 1 votes -- Digvijay Pandey ( 26245 points)

10.165 ROM size to build adder/substractor top gateoverflow.in/26836

The size of the ROM required to build an 8-bit adder/ subtractor with mode control, carry input, carry output and two’s
complement overflow output is given as
(A) 2^16 × 8 (B) 2^18 × 10
(C) 2^16 × 10 (D) 2^18 × 8


Selected Answer

total input to the rom decoder will be (8+8 ( two 8 bit number ) +1( mode ) +1( carry in))

so total number of words out of decoder will be 2^18 . result will be 8 bit so 8 vertical lines +( 1 for carry ) +1 ( for
saying underflow) .

answer will be B.

a little more here .

https://www.google.co.in/search?q=8-bit+adder%2F+subtractor&oq=8-
bit+adder%2F+subtractor+&aqs=chrome..69i57.4118j0j7&sourceid=chrome&es_sm=93&ie=UTF-8#q=rom+required+8-
bit+adder%2F+subtractor

 2 votes -- Ravi Singh ( 7303 points)

10.166 Digital top gateoverflow.in/27742

Explain whether x'y+xy' is functionally complete opr or not???

digital-logic

Any gate is functionally complete if and or not can implemented by it...

And and or gate cant be inplemented by exor gate

So it is not functionally complete

 2 votes -- Pooja ( 22773 points)

ok you want to prove it is not functionally complete . so it should be able to derive and and/or or not. first i want to
extract and /or from the exor expression by replacing only in terms of other so that the whole equation comes in one
variable only. but u can see u can't do it , whole equation ends in 0. like putting b =a , a.a'+a'.a=0. so i put b =1, then i
can derive not. at this point it can't be functionally complete ., but partially functionally complete because we always have
to take help from 1. now moving on to next step. now i wan to get and /or . so in tis equation a'b+ab'. try all the
combinations like . a=a', b=b, and a=a b=b', a=a', b=b'. you can see there is no way u can get and or. so not functionally
complete .

 1 votes -- Ravi Singh ( 7303 points)

10.167 carry look ahead adder vs ripple carry adder top gateoverflow.in/26355

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1518 of 2244


Selected Answer

The correct answer is C ,

S1: the point we use the carry look ahead adder is to do fast calculation. When carry are available at the same time.
Calculation is done in the same cycle. and result is obtained after one cycle .

s2: the cost is higher as a there is a need of extra hardware for like, AND OR gates in carrylookahead adder.

 1 votes -- Ravi Singh ( 7303 points)

Option A is correct since for carry look ahead adder carry present at start so no need to wait , but in ripple
adder we wait for output at 1st half adder or full adder.

Edited:
Cost of carry look ahead adder is more b/c used two level and or gate ...(calculate Gi= Ai*B i and Pi= Ai exor
Bi) then start normal functioning .

 1 votes -- Anirudh Pratap Singh ( 4091 points)

10.168 How to solve below question on digital waveform ? top gateoverflow.in/25971

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1519 of 2244

10.169 Flip-Flop top gateoverflow.in/25079

This is positive edge triggered up counter so after two clocks output will be 6 ie 110 so ans is d

 0 votes -- Pooja ( 22773 points)

10.170 what is type of decoder required ? top gateoverflow.in/15028

suppose you want to build a memory with 4 byte words and a capacity of 2^21 bits.what is type of decoder required if the
memory is built using 2K X 8 RAM chips?


Selected Answer

here u have to built a memory using some chips so first of all wht u should now is the ram implementation. here it is

so the type of decoder required will dependent on the number of rows . not number of columns . columns are for data
whenevr one row is selected the whole data on that row will be extracted by data lines . and that how each word size
matters. if your memory is byte addressable then 8 vertical lines will be there if itis one word where each word is of two
byte the it will be 2*8= 16 as we know every row should accomodate one word if the memory is word addressable else
one byte if byte addressable .

so leaving the chips required first of all take a look at what we have to make . given is 4 byte word memory . mens
memory is word addressable where each word is of 4 byte . so data lines required will be 4*8=32 . and total capacity is
2^21 bit so number of rows required will be equal to 2^21/2^4=2^16

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1520 of 2244

so here we are now with an idea of what e have to make

now finally we have to make it using 2k *8 chip which mens 2^11 rows . so now dividing 2^16/2^11 is the actual no of
adress line required if i use these chips direct implementation will require 2^16 adress line .

so which is 32so we need a 5*32 decoder .

*** if answer is wrong please let me know .

 2 votes -- Ravi Singh ( 7303 points)

10.171 Counter top gateoverflow.in/25890

10.172 ISRO 2011/6 top gateoverflow.in/19328

evaluate (X ⊕ Y) ⊕ Y ?

isro digital-logic


Selected Answer

(X⊕Y)⊕Y=(XY'+XY')Y'+(XY+X'Y')Y

=XY'+XY

=X

Another way to solve problem

EXOR operation is associative

(X⊕Y)⊕Y=X⊕(Y⊕Y)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1521 of 2244

=X⊕0

=X

 2 votes -- Pooja ( 22773 points)

10.173 Digital Logic top gateoverflow.in/15586

digital-logic

D is answer

A.[B+C].[D[P+P']] = f thus the only way to reach is option d

 0 votes -- Ravi Raaja ( 147 points)

10.174 Truth Table for 4 variables? top gateoverflow.in/17793

Someone please tell me the truth table for 4 variables, say (A,B,C,D). What all 16 possible input combinations will be?
Thank you in advance.

digital-logic


Selected Answer

Input combinations will be binary numbers from 0000-1111. For each of this 2 possible outputs- 0 or 1. So, 2^16 possible
boolean functions.

 1 votes -- Arjun Suresh ( 124125 points)

10.175 Find the minterms of the product of two functions top gateoverflow.in/17971

Given f=f1.f2, where f1=∑m(0,1,5)+d(2,3,7)

and f2=∑m(1,2,4,5)+d(0,7)

f=??

According to me F is AnD operation of f1 and f2 so in f minterm will be common min-term of both function.

since it is AND operation true is only for f1=1 f2=1.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1522 of 2244

and for dont care first take common and

then check the f1 dont care is present in minterm of f2 or not if yes then take it in(e.g. let 2 in f1 be 1 and 2 is in f2 so it
will be 1) similarly check for f2 vice versa. this is done because . 1 and Dn't care is a don't care because the value will now
depend on what i take the don't care to be . so we just take intersections of don't care with minterms of f2.

f1=∑m(0,1,5)+d(2,3,7)

f2=∑m(1,2,4,5)+d(0,7)

f=∑m(1,5)+d(0,2,7)

 0 votes -- Umang Raman ( 10379 points)

10.176 max no of boolean expression that can be formed for the function
f(x,y,z) satisfying the relation f(x',y,z') = f(x,yz) top gateoverflow.in/18173

Consider the following sequence of micro-operations.


MBR ← PC MAR ← X PC ← Y Memory ← MBR

Which one of the following is a possible operation performed by this sequence?

(A) Instruction fetch

(B) Operand fetch

(C) Conditional branch

(D) Initiation of interrupt service

f(x',y,z') = f(x,y,z) means y remains same and the for x z values the function does`nt have any effect .

so in kmap for 2 3 6 7 y is 1 . and the remaining 0 1 4 5 we put dontcare . so in the function 2 3 6 7 will be there but all these dont
care have 2 choices either its present or not present . 24 = 16 possibilities . ( i may be wrong :D )

 0 votes -- Pranay Datta ( 6113 points)

10.177 minimum 4*16 line decoders required to realize 8*256 line decoders
are top gateoverflow.in/16141

i m getting 16 but the answer is 17 .please explain


Selected Answer

for 8*256 decoder 1 would required in first level and 16 in second level ....the best way to apprach this question is
starting from 2nd level see 256 output lines so 256/16 decoder now to select one of 16 decoder we neead one 4:16
decoder so ans is 1+16=17

 3 votes -- Pooja ( 22773 points)

10.178 max clock frequency in ripple counter top gateoverflow.in/16142

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1523 of 2244

A 3 bit ripple counter uses j k flip flops.if the propagation delay of each flipflop is 50 nsec,then the maximum clock frequency
that can be used in megahertz... please explain the soln

max clock frequency=1/3*50*10^-9 clock frequncy=1/t (for asychronous tt= n*propogation delay)

=6.67 MHz

 0 votes -- Pooja ( 22773 points)

10.179 Find the correct option top gateoverflow.in/9598

digital-logic

bcz these asynchronous ips are active low hence option D is correct one.

 1 votes -- gate2016 ( 259 points)

10.180 If a 3 bit multiplicand is multiplied to a 2 bit multiplier, minimum


number of two input AND, XOR, and OR gates, needed? top gateoverflow.in/16938

If a 3 bit multiplicand is multiplied to a 2 bit multiplier, minimum number of two input AND, XOR, and OR gates, needed in
the design are respectively?

A) 16,14,1
B) 7, 3, 1
C) 10, 4, 1
D) 8, 4, 1

digital-logic


Selected Answer

let the three bit multiplicand be 111 and two bit multiplier be 11

1 1 1

* 1 1

1 1 1

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1524 of 2244

1 1 1 here we need 6 AND gates TO MULTIPLY

1 0 1 0 1

TO ADD GREEN BITS WE NEED 1 HALF ADDER AND FOR YELLOW BIT WE NEED 1 FULL ADDER AND ONE MORE HALF
ADDER FOR LAST BIT

AS WE KNOW HALF ADDER NEEDS 1 XOR (FOR SUM) AND 1 AND GATE(FOR CARRY BIT)

FULL ADDER NEED 2 XOR (FOR SUM)AND 3 AND GATE AND 1 OR GATE(FOR CARRY BIT)

THEREFORE 2 HALF ADDER =2-XOR GATE +2 AND GATE

1 FULL ADDER =2-XOR GATE+3-AND GATE+1-OR GATE

THEREFORE TOTAL 11 AND GATES 4 XOR GATES AND 1 OR GATE

TO MINIMIZE WE CAN IMPLEMENT 1 FULL ADDER WITH 2 HALF ADDER + 1 OR GATE (2-XOR GATE+2-AND GATE+1-OR
GATE)

THEN IT WOULD BE 10 AND GATE 4 XOR GATE AND 1 OR GATE .(OPTION C)

 0 votes -- Umang Raman ( 10379 points)

10.181 which one is not self complemetry code top gateoverflow.in/6652


Selected Answer

Self complementing code is a code wherein sum of weights is 9. Except for D, all other options have sum of weights=9

 2 votes -- Keith Kr ( 5467 points)

if we find 9's complement of the no

and also find the 1's complement of the no according to given weightage then if it will stisfied then given weightage is self
complemantary code.

9's complement 2 is 7 for this if we represent 2 by weightage and take 1's complememnt then the no is
selfcomplememntry code

representation of 7 by taking its


representation
CODE 1's complement according to result
of 2
given codes
2421 0010 1101 yes
5211 0011 1100 yes
84-2-
0110 1001 yes
1
here 2 can't
641-
be 1010 no
3
representation

 1 votes -- saket nandan ( 1853 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1525 of 2244

d) 641-3

 1 votes -- Praveen Muraleedharan ( 21 points)

10.182 the noninverting buffer have delay of 2 ns and 4ns both xor and all
wire have zero delay how many transition top gateoverflow.in/17579

Here, the value of p should be 24, not 23 as taken...also no reason is given for this assumption by the author (Navathe ).
Can anyone explain this ?

10.183 Digital logic top gateoverflow.in/18245

A number system uses 20 as the radix. The excess code that is necessary for its equivalent binary coded representation is ??

digital-logic

for representing 20 5bits are required

20 is base ie 0-19 can be presented

now compleemtn of x =19-x

with 5 bits no represented is 31

so we are getting 31-x

in order to get proper result

we use excess 6 code(12/2=6) as difference between 31 and 19 is 12

u can refer this link

https://books.google.co.in/books?
id=wFNMpKd6_y8C&pg=PA173&lpg=PA173&dq=A+number+system+uses+20+as+the+radix.+The+excess+code+that+is+necessary+

 0 votes -- Pooja ( 22773 points)

10.184 the minimum number of two input NAND gate required to realize one
AND gate is (complemented inputs is not available). top gateoverflow.in/18423

options are

1. 1
2. 2
3. 3
4. 4

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1526 of 2244

Answer is 2.

 0 votes -- Payal Rastogi ( 485 points)

10.185 what will be the output? top gateoverflow.in/18901

Actually I don't know how to find MUX equation. please provide answer with explanation.

Ans - D

 0 votes -- admin ( 1411 points)

10.186 when we realize a 64x1 mux using 4x1 muxes we have levels? gateoverflow.in/18902

top

options are:-

A) 2

B)3

C)4

D)5

Please provide answer with explanation.


Selected Answer

At level 1 we need 64/4 =16 4:1 MUX we will have 16 output at this level

At level 2 we need 16/4 = 4 4:1 MUX we will have 4 output at this level

At level 3 we need 4/4=1 4:1 MUX we will have 1 output at this level

So total 3 level require to realize 64x1 mux using 4x1 muxes

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1527 of 2244

 0 votes -- Umang Raman ( 10379 points)

10.187 A X:Y decoder can be constructed using how many A:B decoder with
enable? top gateoverflow.in/18903

options are :

A)Y/B

B)X/A

3)X/B

4)Y/A


Selected Answer

Here we follow the reverse process of MUX in finding the levels and deocder at each level

At last level Y/B=Output

if ouput < B then we use 1 more level i.e. level 1 with one decoder

if output >B then keep on dividing with output and increasing the levels.

e.g. 4:16 realize by 3:8

last level 16/8=2 3:8 decoder

level1 =1 3:8 decoder

total 2 level 3 3:8 decoder.

 0 votes -- Umang Raman ( 10379 points)

10.187 this is gate cs 2007 question about 4 bit counter. top gateoverflow.in/6226

10.188 A decimal no has 30 digits.Approxiamately, how many digit would the


the binary representation have? top gateoverflow.in/16076

a.)30 b.)60 c.)90 d)120

my soln-10^30 = 2^x

so,x=30log10 base 2 which is 96(approx)

please explain where is the mistake

actually 1030 -1 but its close to 10 30 so yes you are right , its greater than 90

so ans will be D)120

 0 votes -- Pranay Datta ( 6113 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1528 of 2244

10.189 BCD to Binary converter top gateoverflow.in/18475

digital-logic


Selected Answer

Q 45] write 29 in BCD format 0010 1001

D1C1B1A1D0C0B0A0 = 0 0 1 0 1 0 0 1 geen data will enter in IC1 now read it in BCD format 1 0 1 0 0 = 1 4

14 will be converted into binary format by IC1 i.e Y5Y4Y3 Y2Y1=0 1 1 1 0 output of IC1 option B

Q 46] input for IC2 D1C1Y 5 Y4Y3 = 0 0 0 1 1 =0 3

03 will be converted into binary format by IC2 i.e Y5 Y4Y3Y2Y1 = 0 0 0 1 1

now output will be B 6B5B4B3B2B1B0 = (Y4Y3Y2Y1)Ic2(Y2Y1)Ic1A o = 0011101 Option A

 1 votes -- Umang Raman ( 10379 points)

10.190 If i consider XOR gate takes 0 delay i am getting ans as 16 , top gateoverflow.in/18487

digital-logic

I think so!

16ns would be delay for next state.

 1 votes -- Umang Raman ( 10379 points)

10.191 Circuit Initialization Time - ISRO 2014/53 top gateoverflow.in/18498

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1529 of 2244

isro digital-logic


Selected Answer

If we ignore delay of exor gate then total delay is 16 . NOT and OR gate running independently but AND gate can't run
until NOT gate give output to AND gate.So NOT and AND are working sequencially . so (6+10) total delay.

 1 votes -- Avdhesh Singh Rana ( 1509 points)

10.192 how to solve this?? top gateoverflow.in/27782

the minimum decimal equivalent of the number 11C.0 is.. a)183 b)194 c)268 d)269

they have asked the minimum decimal number which will be obtained when base will be the smallest , and the smallest
base possible here is 13 , as c is 12 ( a base n number can only contain digits from 0 to (n-1))

solving considering base 13.

1*13^2+1*13^1+12*13^0+ 0*13^-1= 194.

more at

http://www.engineerclub.in/2014/09/ies-previous-year-solution-part-1.html

 2 votes -- Ravi Singh ( 7303 points)

10.193 No of switching fn for f (A, B, C, D)=BD+B'D' top gateoverflow.in/14726

How to approach this question ?

digital-logic

We have 2^4 = 16 total function, out of which we got 8 minterms(i.e 1) and the remaining will be 0. (maxterms).

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1530 of 2244

f(a,b,c,d) filled in K-map

Now by constructing function table we get only one boolean function possible as shown below:

 0 votes -- Gate Aspirant Mkr ( 79 points)

10.194 A' + AB' = A'+B' top gateoverflow.in/4065

Can somebody please prove A'+ AB' = A' + B' using both methods vann diagram and alegebric simplification.

Please upload the pic of Vann Daigram.Thanks!

digital-logic

A' + AB' = A'B + A'B' + AB'


= A'B + A'B' +A'B' + AB'
= A'(B+B') + B'(A'+A)
= A' + B'

Alternatively (much better approach)

A' + AB' will become TRUE if A' is true or if AB' is true. If A' is true we don't need to consider AB' and if A' is false, it means
A is true and hence we need to consider only B'.

 2 votes -- Arjun Suresh ( 124125 points)

A'+AB'

(A'+A) (A'+B') BY DISTRIBUTED LAW

A'+A =1 BY IDENTITY LAW

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1531 of 2244

1.(A'+B')

A'+B'

 1 votes -- mukesh soni ( 69 points)

10.195 After 3-clock pulses , what is the content of shift Register top gateoverflow.in/32833

I could not understand here both the outputs point to D3 bit . How to proceed in this scenario ?

digital-logic

10.196 plz answer top gateoverflow.in/13418

minimum number of states required to detect n-bit sequence are ( for sequence detector)

log2n , 2 n , n-1 , n ??

Let N be total number of states, each state can be represented by

n=log2 N bits,so the minimum number of states required to detect n bit sequence will be 2^n

 1 votes -- Rohan Ghosh ( 1515 points)

10.197 a dynamic ram has refresh cycle of 32 bits per msec top gateoverflow.in/32954

a dynamic ram has refresh cycle of 32 times per msec. Each refresh operation requires100 nsec and a memory cycle
requires 250 nsec what percentage of memory's total operating time is required for refreshes

First we will find how many no cycle will be there in one memory operation-

Given that in 1 msec(10 6 nsec) no of refresh cycle =32 cycle

then we can find cycle in 250 nsec (which is 1 memory cycle time) no of refresh cycle = (32*250)/10 6 cycle

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1532 of 2244

Now we can find total time taken by refresh operation in 1 memory cycle

1 cycle of refresh operation required 100 nsec

(32*250)/106 cycle of refresh operation required = ((32*250)/10 6)*100= 0.8 nsec

now find percentage of memory's total operating time is required for refreshes (100/250)*0.8 = 0.32%

 0 votes -- Anoop Sonkar ( 4167 points)

10.198 A pulse train can be delayed by a finite number periods using of clock
top gateoverflow.in/32445

digital-logic

option (a) is correct because using shift register using D-flip flop we can delay serial input signal to appear at serial output
by keeping clock at low level for some finite amount of time.

 1 votes -- Shashank Kumar ( 2029 points)

10.199 counter top gateoverflow.in/13419

a divide by 78 counter can be realised by using-

a) 6 numbers of mod- 13 counters

b) 13 numbers of mod 6 counters

c) one mod 13 counter followed by one mod 6 counter

d) 13 numbers of mod 13 counter

ans-

only a , only b , only c, both a and b ?

A divide by 78 means Modulo 78 counter.

Overall Mod of the connected counter =M1 * M2 * M3.....Mn.

in option C it is 13*6 = 78.

Therefore answer is C.

 2 votes -- Riya Roy ( 4767 points)

10.200 find the output of the decoder top gateoverflow.in/31218

The boolean expression f (x, y, z) in its canonical form for the decoder circuit shown below is

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1533 of 2244

Π M(4, 6)
Σ m(0, 1, 2, 3, 5, 7)
Σ m(4, 6)
Π M(0, 1, 2, 3, 5)

Ans is ∑m(4,6)

Is it right???

 0 votes -- Khushboo Tak ( 1961 points)

10.201 Minimum NAND/NOR Gates - Realization for


ExOR,ExNor,Adder,Subtractor top gateoverflow.in/31359

Minimum No of Gates NAND/NOR


Ex- Ex- Half Half Full Full

OR Nor Adder Subtractor Adder Subtractor
NAND ? ? ? ? ? ?
NOR ? ? ? ? ? ?


Selected Answer

Minimum Number of Gates: Nand/Nor


Half Half Full Full
Exor Exnor
Adder Subtractor Adder Subtractor
NAND 4 5 5 5 9 9
NOR 5 4 5 5 9 9

Exor Using Nand Gates

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1534 of 2244

Exor Using Nor Gates

Ex-Nor using Nand Gates

Ex-Nor using Nor Gates

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1535 of 2244

Half Adder using Nand Gates

Half Adder Using Nor Gates

Half Subtractor using Nand Gates

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1536 of 2244

Half Subtractor using Nor gates

Full Adder using Nand Gates

Full Adder using Nor gates

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1537 of 2244

Full Subtractor using Nand Gates

Full Subtractor using Nor Gates

 8 votes -- Praveen Saini ( 34299 points)

10.202 clock frequency top gateoverflow.in/32002

A digital system has clock generator that produces pulses at frequency of 80 MHz design circuit that provides clock with
cycle time of 50 ns


Selected Answer

2 edge triggered T Flip Flops can be used to do it.


Given clock frequency = 80 MHz,

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1538 of 2244

1
−9
desired clock frequency = 50× 10 Hz = 20 MHz,

so we have to divide given clock frequency by 4 in order to achieve the desired clock frequency.

This can be done with the help of two edge triggered T flip flops as follows:


I am using -ve edge triggered flip flops here.

T input of both the flip flops is 1 .

Clock pulses from the given clock generator are passed to the first flip flop.

Output of first flip flop i.e. Q1 will change only on the -ve edges of given clock pulse, so it can be seen from the pulse plot that frequency of
Q1 will be half of that
of given clock pulse.

So Q1 will produce pulse of frequency 40 MHz.

Q1 is being fed to the clock input of second flip flop.

And the output of second flip flop i.e. Q2 will change only on -ve edges of Q1,so the frequency of pulse produced by Q2 will be half of the pulse produces by Q1
and quarter of the pulse produced by the given clock generator.

80

Thus the frequency of the pulse produced by Q2 = 4 = 20 MHz.



Hence Q2 if used as a clock, will provide the clock cycle time of 50 ns.

 2 votes -- Anurag Pandey ( 8183 points)

T = $\frac{ 1}{80MHz}$ = 12.5 ns

Using D flip flop 4 state counter at the Clock of 80MHz will produce the output.

T = 4*12.5 = 50ns

 1 votes -- Umang Raman ( 10379 points)

10.203 multiplexers top gateoverflow.in/13417

minimum number of ( 2*1) multiplexers required to realize the following function if inputs are available only in true form-

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1539 of 2244

F(A,B,C)= A'B +A'B'C'

4,2,1,3 ??

3 variable function can be implemented with 4*1 MUX or 8*1 MUX. No. Of 2*1 mux reqd to implemet 4*1 is 3 And no. Of
2*1 reqd to implement 8*1 is 7. 7 isn't given in the options. So it shud be 3. Is it ? What's the answer ?

PS. Additional circuitry like Not gate might also be needed.

 2 votes -- saloni ( 205 points)

10.204 solve top gateoverflow.in/13388

How many different BCD numbers can be stored in 12 switches? (Assume two position or on-off switches).
(a) 2^12 (b) 2^12-1 (c) 10^12 (d) 10^3

digital-logic


Selected Answer

With 4 bit we can represent 10 BCD no.

12 switches means 12 bit space.

Total 10*10*10 BCD no.

 3 votes -- Digvijay Pandey ( 26245 points)

10.205 Counting switching functions top gateoverflow.in/13269

By using 16 bit binary in BCD , how many switching functions can exist ?

Now , since this is BCD anything above 1001 is invalid. Considering 16 bits : 1001 1001 1001 1001

Above is number of possible combinations : 0 - 9999 There are 10^4 possible combinations. Number of switching functions :
2^(10^4)

Answer given is (10^4). Am I missing something obvious ?

BCD no. range is (0to 9) = 10 numbers


oooo oooo oooo oooo
.
.
.
1001 1001 1001 1001
total possiblity of each quad 10 10 10 10

so total switching function possible = 10*10 *10*10 = 10000

 1 votes -- Umang Raman ( 10379 points)

I think 2^(10^4) is correct answer. Don't know why (10^4) is given. (It is size of truth table)

 1 votes -- Akash ( 26315 points)

10.206 which of the following is termed as minimum error code top gateoverflow.in/17266

which of the following is termed as minimum error code

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1540 of 2244

a)Binary code

b)Gray code

c)Excess 3 code

d)octal code


Selected Answer

b) Gray Code

aka :
reflected binary code
cyclic permutation code

 0 votes -- Amar Vashishth ( 17865 points)

10.207 Finding F's complement of a number top gateoverflow.in/33863

Given answer: C. Please tell me how to approach this problem.

digital-logic


Selected Answer

its base 15 means . the system will have 15 number - 0 to E. And 15 is represented as F . so it is asking the radix
complement of the number, now the radix complement can be written as dimnishd radix complement + 1.

so dimnished radix biggest number of n digit - number.

here biggest digit is e . so

eeee- 3a2e = b4c0

radix will be b4c0 + 1 = B4C1

 3 votes -- Ravi Singh ( 7303 points)

10.208 Output Waveform top gateoverflow.in/34130

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1541 of 2244

digital-logic


Selected Answer

here is the pic

 2 votes -- Prabhanjan R ( 747 points)

considering initially Q is 0 implies Q comp is 1 so option D is correct

 1 votes -- shivanisrivarshini ( 2067 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1542 of 2244

10.209 check plzz top gateoverflow.in/13385

Consider the following sequential circuit.

What are values of Q0 and Q1 after 4 clock cycles, if the initial values are 00 ?
(a) 11 (b) 01 (c) 10 (d) 00


Selected Answer

correct me if wrong!

q0q1

(initial) 00

(1 clock) 10

(2 clock ) 01

(3 clock ) 11

( 4 clock) 00

this will be answer.............

 1 votes -- kunal chalotra ( 3567 points)

10.210 Question on base of digits top gateoverflow.in/33755

Given answer is 101 but I am getting 35. Please check.

digital-logic


Selected Answer

(3)4 + (2)4 = (5)10 = (11)4 , that will give one carry.

Now, carry, (1)4 + (2)4 + (1)4 = (4)10 = (10)4

So, on adding we get, (2.3)4 + (1.2)4 = (10.1)4

(10.1)4 × (10)4 = (101)4

Or, Another way is to convert them in decimal, then after doing all calculation, convert back to desired base.

Note: In base 4, we can only { 0, 1, 2, 3}, in any calculation(adding or multiplication) if get 4 or above. It need to convert

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1543 of 2244

back into base 4

 3 votes -- Praveen Saini ( 34299 points)

Convert into binary then add and again convert to 4 base with multiplication with 10

(2.3)4 + (1.2) 4 => (01.11)2+ (01.10)2 => (0100.01)2 => (10.1)4

(10.1)4 *10 = (101)4 Solved

 1 votes -- deepakanand41 ( 123 points)

10.211 Question on multivibrator top gateoverflow.in/33682

Please explain how the answer is (A).

digital-logic

10.212 Question on multivibrator top gateoverflow.in/33683

Please explain how the answer is (A).

digital-logic


Selected Answer

2 points
1:- if circuit have odd number of NOT gate then it is "Astable Multivibrator"

2:- if circuit have even number of NOT gate then it is "Bistable Multivibrator"

 2 votes -- Jaikishan Apurva ( 787 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1544 of 2244

10.213 Implementing 256 X 4 memory with 16 X 2 memory. top gateoverflow.in/33684

please explain me how to approach such problems.

digital-logic

No of rows =256/16 =16

No of columns = 4/2=2

 3 votes -- pritika kundu ( 677 points)

10.214 Digital Morris Mono 5.1 top gateoverflow.in/30826

5 .1 The D latch of Fig. 5.6 is constructed with four NAN D gates and an inverter. Consider the following three other ways for obtai ning a D latch . and in eac h case draw the logic diagra m and
verify the circu it operation;
(a) Use NOR gates for the SR latch part and AND gates for the other two. An inverter may be
needed .
(b) Use NOR gates for all four gates. Inverte rs may be needed .
(c) Usc four NAND gates only (without an inverte r). This can be done by con nect ing the output
of the upper gate in Fig. 5.6 (the gate that goe s to the SR latch) to the input of the lower gate
(instead of the inverter output)

digital-logic


Selected Answer

First we design RS latch and Flip-flop with NAND and NOR gates, and then convert it into D Flip-Flop, by using equation
¯
R = D and S = D

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1545 of 2244

 1 votes -- Praveen Saini ( 34299 points)

10.215 Digital Counter Problem top gateoverflow.in/30645

digital-logic

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1546 of 2244


Selected Answer

Q2 Q1 Q0
← Initial/
0 0 0
Data input bit ↓
New Q0 = Data
New Q2= Q1 New Q1 =Q2 ⊕ Q0 1
Input bit
0 0 1 0
0 1 0 0
1 0 0 1
0 1 1 1
1 1 1 0
1 0 0 0
0 1 0 0
1 0 0 0
0 1 0 ← Final Q2Q1Q0

010 should be the answer.

 2 votes -- Praveen Saini ( 34299 points)

10.216 how to find expression top gateoverflow.in/5820

Answer is C

In question they are asking for table Y which is lsb in the compressed input. it is simple 4 to 2 encoder
you need the table

D3 D2 D1 D0 X Y V
0 0 0 0 x x 0
0 0 0 1 0 0 1
0 0 1 x 0 1 1
0 1 x x 1 0 1
1 x x x 1 1 1

taking Y value in karunaugh map


you have reduced value

D3 + D2'D1

 4 votes -- Arpit Dhuriya ( 1791 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1547 of 2244

10.217 essential prime implicants top gateoverflow.in/13753

(B) option is correct.

 3 votes -- kunal chalotra ( 3567 points)

10.218 no. of gates top gateoverflow.in/28864


Selected Answer

After solving with K- Map , we get expression as (A+C) . (A+D) . (B+D)

which can be written as (A+ CD). (B+D)


¯
¯
(A + CD). (B + D)
=

¯
¯ ¯
A + CD + B + D
=

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1548 of 2244

¯
¯
¯
¯
′ ′
A+C +D +B+D
=

As, variable are available both primed and Unprimed form. We are having 4 , 2-Input Nor Gates..

 2 votes -- Himanshu Agarwal ( 8861 points)

10.219 How to approach this question on digital logic? top gateoverflow.in/29383

Given answer: D
Please explain

digital-logic


Selected Answer

This type of question are very simple. Just remember the following prints :

1- Open connection of a TTL family Logic gate is always 1.

2- Open connection of a ECL family Logic gate is always 0.

3- Any potential (+10V, Vcc ) is taken as 1.

4 - Earth/Ground is taken as zero .

2 NOT gates always cancel each other, (0')'=0. So, output of XOR, 0 ⊕ A = A, First Input to OR.

AND gate with TTL is connected to +10V taken as 1 and open connection will be counted as 1, output of AND = 1,
Second Input to OR.

From the OR gate,

A+1 = 1

 2 votes -- Ravi Singh ( 7303 points)

answer = option D

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1549 of 2244

simulated circuit with open ends and using all gates from TTL(shown in blue) logic : Output is still positive, Though
presence of Input A effects the output. But it never goes negative/zero. that is shown by the glowing probe in figure 2.

 1 votes -- Amar Vashishth ( 17865 points)

10.220 minimum number of gates top gateoverflow.in/28723

is


Selected Answer

4 nand gate
(x'+y')(z+w) = (x'+y')z + (x'+y')w = (xy)'z + (xy)'w

make (xy)' as common nand gate input for z and w then there output to one more nand gate.

¯
¯ ¯
¯ ¯
((xy)z). ((xy)w)

 2 votes -- Umang Raman ( 10379 points)

10.221 digital logic: max clock frequency top gateoverflow.in/28649

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1550 of 2244

Twisted Ring Counter = Jhonson Counter


There are 4 d flip flop means there will be total 8 total states
f
2n
Frequency =
1 1

= 8Tc = 8 ∗ 40 = 3.125Mhz

 0 votes -- Umang Raman ( 10379 points)

10.222 no. of prime implicants top gateoverflow.in/28007

what is the no. Of prime implicants in f(w,x,y,z)=∑ (1,4,6,7,8,9,10,11,15) ?

wx/yz 00 01 11 10
00 1
01 1 1 1
11 1
10 1 1 1 1

Prime Implicant are : 6


(8,9,10,11) (9,1) (4,6) (6,7) ( 6,15) (11,15)

 2 votes -- Umang Raman ( 10379 points)

A PRIME IMPLICANT is a product term that cannot be combined with


another term to eliminate a variable.

A single 1 is a prime implicant if it is not adjacent to any other 1's.


Two adjacent 1's form a prime implicant if they are not contained in
a group of four adjacent 1's.
Four adjacent 1's form a prime implicant if they are not contained in
a group of eight adjacent 1's.
So, there are wx',wyz,xyz,yw'x,z'w'x,y'zx'

 2 votes -- Avdhesh Singh Rana ( 1509 points)

10.223 How to check whether A EX-NOR(BC) =(A EX-NOR B) (A EX-NOR C) ?


top gateoverflow.in/14693

Taking A=0, LHS= B'+C'


and RHS= B'C'
Taking A=1 ,LHS=BC
RHS= BC
Now for A=1 it is satisfied while for A=0 not satisfied so does the identity hole or not ?

digital-logic

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1551 of 2244

method (1)

LHS=A x-nor (BC)=ABC+(A)'(BC)'=ABC+(A)'(B'+C')=ABC+A'B'+A'C'

RHS=(AB+A'B')(AC+A'C')=ABC+A'B'C'

SO, LHS!=RHS

method(2)

(A xnor
Ax-
ABC B)(A
nor(BC)
xnor C)
0001 1
0011 0
0101 0
0110 0
1000 0
1010 0
1100 0
1111 1

so from this truth table also LHS != RHS

 3 votes -- saket nandan ( 1853 points)

10.224 COUNTER top gateoverflow.in/13803

how many MOD -4 counters are needed to provide line that operates at 62.5 KHZ from a 16 MHZ crystal?

4,8,12,16

let der are n counters of mod 4..


16000 = 62.5 (4*4*4* .... n times) // mode n counter * mode m counter = mod mn counter
16000 = 62.5*4*4^(n-1)
256 = 4^n
n = 4

four counter needed..

 3 votes -- Digvijay Pandey ( 26245 points)

10.224 to multiply a binary number we have to do left shift...for division right


shift....i think this is applicable only only we get the result as pure integer
...if the result is fraction ..then this will not work....write ur comments...pls
top gateoverflow.in/128


Selected Answer

I guess you meant multiplication and division by power of 2. For multiplication your question answers itself, as answer is
always an integer. For division, answer to your question is "yes"- it won't work. Because when we use shift instead of
division, compiler will just use shift instruction provided by the CPU (if it does). So, lets take Intel architecture and this is
what Intel manual says for SAR (Shift Arithmetic Right) Instruction.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1552 of 2244

"Using the SAR instruction to perform a division operation does not produce the same result as the IDIV instruction.
The quotient from the IDIV instruction is rounded toward zero, whereas the “quotient” of the SAR instruction is
rounded toward negative infinity. This difference is apparent only for negative numbers. For example, when the
IDIV instruction is used to divide -9 by 4, the result is -2 with a remainder of -1. If the SAR instruction is used to
shift -9 right by two bits, the result is -3 and the “remainder” is +3; however, the SAR instruction stores only the
most significant bit of the remainder (in the CF flag)"

So, for positive numbers, when we want only the quotient we can safely use shift in place of division by power of 2.
Otherwise we should not use shift.

Reference: http://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-
developer-manual-325462.pdf

 1 votes -- Arjun Suresh ( 124125 points)

10.225 Identifying self dual function top gateoverflow.in/29414

Given answer: D
I am not getting how to approach this question.

digital-logic


Selected Answer

A Self dual function is a function such thatf = fD

option D). f = Σm(1, 2, 4, 7)

F = A ′ B ′ C + A ′ BC ′ + AB ′ C ′ + ABC = (A ′ B ′ + AB). C + (A ′ B + AB ′ ). C ′

¯ ¯
= (A ⊕ B). C + (A ⊕ B). C = (A ⊕ B) ⊕ C

Now its dual (Dual is obtained by complementing the input variables and then by complementing the function)

fD = ((AB + A ′ B ′ )C ′ + (AB ′ + A ′ B)C) ′


¯
= ((A ⊕ B) ′ C ′ + (A ⊕ B)C) ′ = ((A ⊕ B) ⊙ C)

= (A ⊕ B) ⊕ C

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1553 of 2244

 2 votes -- srestha ( 11585 points)

There are two conditions for Self Dual fn->

1.must be neutral fn(number of maxterm=number of minterm)

2.no two mutually exclusive term should be present(for three variable(0,7)both should not be present)

now here 1st condition is satisfied ..so checking 2nd condition

A-> minterms 3 and 4 both are present and are ME(sum is 7) so not a self dual function

B->minterms 0 and 7 are present so no SD fn

C->minterms 2 and 5 are present so again no SD fn

D->no ME terms are present

so option D is correct..

 2 votes -- Joker ( 685 points)

10.226 Carry lookahead adder top gateoverflow.in/29551

In a 4-bit carry look ahead adder, the propagation delay of EX − OR gate is 20ns, AND and OR gates is 10ns. The sum and carry
output of full adder takes 20ns and 10ns respectively. The total propagation delay of the above adder in ns is__________.


Selected Answer

carry look ahead generator has inputs P(i) =A(i) EXOR B(i) , Gi = A(i) AND B(i) , delay max(20,10) = 20

carry generation circuit C(i+1) = G(i) + C(i) P(i) , delay = 10 + 10 = 20

to generate sum S(i+1) = C(i) EXOR P(i) , delay= 20

Total delay to generate carry = 20+20 = 40 ns

Total delay to generate Sum = 20 +20 +20 = 60 ns

 0 votes -- pramod ( 2071 points)

10.227 Find the correct output top gateoverflow.in/9599

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1554 of 2244

digital-logic


Selected Answer

at t<t0
output of NOR gate is 1. and input Vi is 1 so input to Ex-or gate is 1,0 ..
final output ll be 1..

at t0<t<t1
input to NOR gate is 1 but still output or NOR gate is 1 (due to propagation delay). Input to Ex-OR gate is 1,1 and final
output ll b 0..

at t1<t<t3
input to NOR gate is 1 and here output of NOR gate is 0.
Input to Ex-OR gate is 0,1 but fiinal output ll b 0 (due to propagation delay of Ex- OR gate)..

at t>t3.
input to NOR gate is 1 and here output of NOR gate is 0.
Input to Ex-OR gate is 0,1 and fiinal output ll b 1..

Option A..
m assuming difference between two consecutive ti (i=0 to3) value is 10nsec..

 1 votes -- Digvijay Pandey ( 26245 points)

10.228 boolean expressions top gateoverflow.in/29822

The maximum number of boolean expressions that can be formed for the function f(x,y,z) satisfying the relation
f(x',y,z')=f(x,y,z) is

We have 4 pairs here.

(0,0,0) and (1,0,1)

(0,0,1) and (1,0,0)

(0,1,0) and (1,1,1)

(0,1,1) and (1,1,0)

Here all pairs have 2 choices (mapped to either 0 or 1 ).

4 pairs having 2 choices

So 24​=16

Hence 16 is the Answer.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1555 of 2244

 2 votes -- Leen Sharma ( 2935 points)

10.229 POS and SOP top gateoverflow.in/29511

when we can say POS and SOP are same ?

pos and sop can be interconverted to each other

and thus GENERALLY LOOKS LIKE THEY ARE NOT SAME

but what if there is a single term with single variable function??

example: f(A,B,C,D)=A

SOP AND POS WILL BE A only

clearly its SAME

 0 votes -- anas ( 11 points)

10.230 dgital top gateoverflow.in/7745

Which of the following multiplier pattern of boothe algo gives better performance and how:

1..01111111110

2..1111100011111

3..011111011111

4..111111111000

While using the Booth algorithm, performance is good if the multiplier pattern is continuously of same type. it takes the
negative value of actual number with multiplier when it goes from 0 to 1 and takes the positive value if it is making the
moving from 1 to 0.

eg:

1) multiplying by 1

x *1 = x*2 -x

2) multiplying by 6 (110)

x* 6 = 8*x - 2*x

here it starts scanning from right most bit (it initialize the first bit to 0) and takes the negative of number when it
encounter 0 to 1 transition(-2*x) and takes the positive of number(8*x) when it goes from 1 to 0 (or end of bit).

Therefore, here options (1) and (4) give the better performance, because in both cases it has to take only once the
positive of the number and once the negative of the number.

 2 votes -- suraj ( 3299 points)

10.231 What's the best way to approach this question in digital logic? gateoverflow.in/29474

top

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1556 of 2244

Given answer: A
Please explain

digital-logic


Selected Answer

to select I0 line AB should be 00 and now C is connected to I0 so fro min term ABCD here ABC are 001 D can take o or 1

so we get 0010 0011 ie m2 and m3

similarly for I1 we get AB as 01 and D 0 so 01C0 c can be 0 or 1 so 0110 and 0100 ie m4 and m6

Similarly for I2 AB 10 and D is 0 so we get 10C0 ie 1010 and 1000 ie 8 and 10

For I3 we have ABA' ie gives 0

So F=∑(m2,m3,m4,m6,m8,m10)

 2 votes -- Pooja ( 22773 points)

10.232 how to find this expression? top gateoverflow.in/5818

For 0000 all satisfies (F=0).

For 0111 , a,c doesn't satisfy (F=0)

For 1111 , b doesn't satisfy (F=1) .

So ans is d.

 0 votes -- Meme Iamam ( 65 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1557 of 2244

10.233 plz answer... top gateoverflow.in/13246

according to me..

Q2 Q1 Q0

0 1 0(initial state)

0 1 0 (1 clock)

0 1 0 (2 clock)

0 1 0(3 clock)

0 1 0(4clock)

NAND gate is there receiving input AS 0(from q2 state),1(from clock) giving output as 1 to both the first and second flip
flop

now first flip flop give output as 0 and after that input going to second flip flop is the previous state ie q0 which is 0
making second flip flop disable, similarly for thrid flip flop initially q1 is 1 making flip flop enable therefore it will no toggle
as input is 0 therefore output will be zero..

p value will be 1

therefore (d) option correct

 0 votes -- kunal chalotra ( 3567 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1558 of 2244

11 General Aptitude top


11.1 Cbt 1: ME CBT-1 q-10 top gateoverflow.in/37036

Samples of old matured wine were tested and their respective % of pure wine in each sample were as given in table.
Remaining constituent in each sample was water

If any two samples are mixed from above. Then on maximum, the number of distinct pairs of samples will never give desired
composition and more than 60% of wine is_______.

cbt-1 made-easy gate-aptitude

11.2 Solve the problem top gateoverflow.in/20854

Find the sum of all the 4 digit numbers that can be formed with the digits 3,2,3,4.

Ans- 39996

No of 4 digit numbers formed=4!/2!=12

Now 2 and 4 will occur at units tens hundred and thousand place 3 times

3 will occur at each place 6 times

Sum of digits at units tens hundred and thousand place=3×2+3*4+6*3=36

Sum of all numbers=36×1000+36*100+36*10+36=39996

 0 votes -- Pooja ( 22773 points)

11.2 Where i can find the complete tutorials of general aptitude and discrete
mahematics top gateoverflow.in/171

General aptitude is a vast area but for GATE they ask only from a small section which is clearly mentioned in GATE
syllabus. Many people won't prepare for these but it is advisable to just read the sections mentioned in GATE syllabus from
a recommended book for aptitude such as Aggarwal.

Discrete Mathematics is an important area in GATE CSE. This you should definitely read from one of the recommended
books such as Kenneth H. Rosen.

For more books: http://gatecse.in/gatecse/index.php?title=Best_books_for_CSE

 0 votes -- Arjun Suresh ( 124125 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1559 of 2244

12 Verbal Ability top


12.1 Algebra: Aptitude top gateoverflow.in/27078

a b

b a
+

a b

b a

Given =1

If a and c are positive integers, then how many ordered pairs are possible for (a, c), where: a + 4b2 + c ≤ 8?

A. 45
B. 28
C. 17
D. 18

combinatorics algebra

Ans will be 45

((a^2+b^2)/ab)/((a^2-b^2)/ab)=1

=>(a^2+b^2)/(a^2-b^2)=1

=>(a^2+b^2)=(a^2-b^2)

=>2b^2=0

=>b=0

a+c<=8

=>a=8 c=0 =1 ordered pair

=>a=7 c=0,1 =2 ordered pair

=>a=6 c=0,1,2

...............

=>a=0 c=0,1,2.......,8 =9 ordered pair

no, of ordered pair 1+2+..........9=45

 3 votes -- srestha ( 11585 points)

12.2 Made Easy_test Series: Statements & Conclusions top gateoverflow.in/36974

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1560 of 2244

mathematical-logic made-easy_test-series

12.3 Mocktest: Mock Test 2016 GA top gateoverflow.in/35811

mocktest

12.4 Number Series: What will be the next Number? top gateoverflow.in/43050

0, 11, 36, 81, ____?

number-series


Selected Answer

Answer will be 152.

Let Consider p is the position for which we are calculating the value. P starts from 1 and goes infinite.

Then It is using (((p^3)-2) + ((p^2)-1) + p) formula. This will give the result.

 2 votes -- Rude Maverick ( 3063 points)

Ans yes 152

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1561 of 2244

 5 votes -- Manojk ( 3365 points)

12.5 Testbook: TestBook Live Test 2 Aptitude Q 1 top gateoverflow.in/36714

I think answer given by them is stupid. ( If anyone is allowed to seat anywhere, people will buy economy class & will want to
seat in First class :P

I think any option apart from first one does not even make sense :P

test-series testbook verbal-ability passage-reading

Option C implies all seats are non-first class. I guess that is a decent answer :) All other options do not even come close.

 0 votes -- Arjun Suresh ( 124125 points)

12.6 Testbook: TestBook Live Test 1 top gateoverflow.in/36107

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1562 of 2244

Here I do not agree with Answer given. I think first is more better approximation, second is not, because in paragraph we
are talking about TIME, and in ans they have marked it as Green They are talking about "PARTS of earth-> Locations"

test-series testbook verbal-ability passage-reading

12.7 Venn Diagrams: aptitude top gateoverflow.in/30424

A survey is conducted among 125 people of India. Among them 25 people have neither a valid visa nor a valid passport and
70 people have a valid visa.

How many people have only a valid passport?

(a) 30 (b) 40

(c) 70 (d) 50

How many people don’t have a valid visa?

(a) 30 (b) 40

(c) 55 (d) 50

easy venn-diagrams


Selected Answer

No of people who has either a valid visa or a valid passport or a valid visa and passport 125-25=100

70 people has a valid visa or valid visa and passport

So, the people who has only a valid passport=100-70=30

Ans will be (a)

the people donot have a valid visa is also 30

And No. of people who doesnot have either a valid visa or a valid passport =25

So, No. of people who donot have a valid visa =30+25=55

Ans will be (C)

 2 votes -- srestha ( 11585 points)

12.8 Aptitute top gateoverflow.in/38076

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1563 of 2244

In how many ways can 4 letters be selected from the letters of the 3 words "GATE MADE EASY"?

1. 70
2. 112
3. 113
4. 127

From a well shuffled deck of 52 cards, cards are dealt. The probability that the 13th card is the first king to be dealt is
______ × 10 −1

Q9 : I am getting 126

Q10 : I am getting .43


Selected Answer

GATE MADE EASY

3- A
3- E
all other letters 1 each.

So, assume all distinct letters- we have to choose 4 from 8- 8 C4 = 70.

Now, for 2 As, all others distinct - 7 C2 = 21.

3 A's - 7 C1 = 7.

For E's also we get 21 + 7 = 28 similar choices.

So, total number of combinations 70 + 28 + 28 = 126.

But we missed "AAEE" - this makes it 127.

The question asks to find ways of choosing letters- and not the number of possible words. Hence we are using
combination and not permutation.
48C
12 .4 37.38.39
52C
Q10. 13
= 49.50.51 = 0.4388.

 1 votes -- Arjun Suresh ( 124125 points)

12.9 PLz solve this top gateoverflow.in/38515

Let a 2 = b+c b 2 = a+c c 2 =a+ b then find the value of (1/1+a)+(1/1+b)+(1/1+c) = ??

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1564 of 2244


Selected Answer

a2 = b+c b2 = a+c c2 =a+ b

2
a+a = a+ b+c =a(1+a)
b+b2 = a+b+c =b(1+b)
2
c+c =a+ b +c=c(1+c)

So:

(1/1+a)+(1/1+b)+(1/1+c)=a/(a+b+c) + b/(a+b+c)+c /(a+b+c)

=(a+b+c)/(a+b+c)

=1

 0 votes -- Tehreem Ansari ( 1327 points)

12.10 aptitude-race top gateoverflow.in/37794

In 100 m race A beats B by 6 sec B beats C by 3 sec.If A beats C by 25m time taken by A to complete 100 m is


Selected Answer

Distance = 100m

Time taken by A to complete 100m = tsec

Time taken by B to complete 100m = (t + 6)sec

Time taken by C to complete 100m = (t + 6) + 3 = (t + 9)sec

So A beat C by 9 sec and by 25m

it means C takes 9 sec to cover 25m

25

Speed of C = 9 m/s

100
25
9
Time taken by C = = 36 sec

t + 9 = 36 sec

Time take by A to complete 100m, t = 27 sec

 3 votes -- Praveen Saini ( 34299 points)

12.11 which option is incorrect part of sentence ? top gateoverflow.in/13978

[A]. I could not put up in a hotel


[B]. because the boarding and lodging charges
[C]. were exorbitant.
[D]. No error.

it will b 'at' instead of 'in' a hotel

 0 votes -- Rohan Ghosh ( 1515 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1565 of 2244

12.11 TESTBOOK LIVE TEST1 Q1 top gateoverflow.in/36759

12.12 aptitude top gateoverflow.in/39306

Four undergraduates are staying is a room. They agreed that older enjoys the more space. Manu is two months older than
Sravan, who is one month younger than Trideep. Pavan is one month older than Sravan. Who will enjoy more space in room?

(A) Manu (B) Sravan (C) Trideep (D) Pavan


Selected Answer

Manu is two months older than Sravan,

Sravan is one month younger than Trideep.

Pavan is one month older than Sravan.

Manu>Trideep=Pavan>Sravan

 2 votes -- Tehreem Ansari ( 1327 points)

12.13 Doubt rergarding one question's answer in GATE 2016 top gateoverflow.in/41615

This was one of the questions asked in GATE 2016 that which of these 4 words is odd one out:- mock, deride, praise, jeer.
Praise seems to be the obvious answer but at the GATE website, it is mentioned that mock is the answer. Can anyone
explain me why?

a] mock : to laugh at in scornful manner

b] deride : express a contempt for

c] praise : to express warm approval.

d] jeer : make rude or mocking remarks.

hence [c] is the answer.

 1 votes -- Lord_Krishna ( 665 points)

12.14 What will be the next Number? top gateoverflow.in/43051

1, 10, 33, 76, _____?


Selected Answer

Answer will be 145.

Let Consider p is the position for which we are calculating the value. P starts from 1 and goes infinite.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1566 of 2244

Then It is using (((p^3)-p) + ((p^2)-p) +p) formula. This will give the result.

 4 votes -- Rude Maverick ( 3063 points)

Answer 145

Series is {12 +03 , 3 2 + 1 3 , 5 2 + 2 3 , 7 2+ 33 , 92 + 4 3}

 2 votes -- srestha ( 11585 points)

Try to do such qus Using brute Force

 1 votes -- Manojk ( 3365 points)

12.15 Complete the sentence: Dare __ mistake. top gateoverflow.in/5635

Dare __________ mistake.

A. commit

B. to commit

C. committed

D. commiting

verbal-ability


Selected Answer

commit. No need of "to" after dare here.

http://www.thefreedictionary.com/DARE

 2 votes -- Arjun Suresh ( 124125 points)

12.15 Universalism is to particularism as diffuseness is to _______________


top gateoverflow.in/41930

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1567 of 2244

Universalism is opposite of particularism


So,
Diffuseness is the nature of Spreadness
Its Opposite can be::
Briefness or Specific or Concision

 1 votes -- saif ahmed ( 931 points)

12.15 which book is good for verbal aptitude top gateoverflow.in/41624

For GATE they usually ask from some GRE books- yes this is one part where they copy questions :P

You can first see all previous verbal questions- http://gateoverflow.in/general-aptitude/verbal-ability

Sorry, I'm not good in verbal ability to suggest you a good book. May be some others can.

 1 votes -- Arjun Suresh ( 124125 points)

12.16 which part of sentence is an error ? top gateoverflow.in/13979

[A]. You can get


[B]. all the information that you want
[C]. in this book.
[D]. No error.

Answer given is option B but whats wrong in saying this "all the information that you want " ?

option b.it will b 'informations'

 0 votes -- Rohan Ghosh ( 1515 points)

12.17 Which of the part of the sentence is incorrect ? top gateoverflow.in/14027

[A]. Many times the news has been published


[B]. in the papers that the end of the world will be certain
[C]. if a nuclear war breaks out.

According to me it should be like Many times, news has been published in the papers that the end of the world is certain if a
nuclear war breaks out.

ans is a

 1 votes -- Sanjay Sharma ( 799 points)

12.18 Which part of sentence is incorrect ? top gateoverflow.in/14031

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1568 of 2244

[A]. While walking slowly in the park


[B]. on a quiet summer afternoon
[C]. a mad dog suddenly attacked him from behind

[D]. No error.

According to me the option A sound correct so then whats the issue with that ?

its (a)
correct sentence - while he was walking slowly in the park.

 1 votes -- Ishan ( 21 points)

12.19 How To prepare For English- Verbal Ability top gateoverflow.in/28953

I've realized that Answering Verbal questions in GATE without any preparation will mostly lead to negative marks ! So trying
to improve if I could !

Syllabus for Verbal Ability: English grammar, sentence completion, verbal analogies, word groups,

instructions, critical reasoning and verbal deduction.

It has bulk of marks. I'm looking to increase my couple of marks by preparing Verbal, If I can !

0. Have you prepared for it ? How you prepared for it, Please share your experience !

1. Which books to use ?

Please give title author.

2. Whether GRE books are more relevant for GATE or CAT Books ? If you have prepared for this exams, using which exams
book will be better for GATE point of view ? Please give exact book name you are suggesting.

3. Are there any good FREE video lectures available ?

verbal-ability

http://www.amazon.in/Word-Power-Made-Norman-Lewis/dp/8183071007/ref=sr_1_1?
s=books&ie=UTF8&qid=1449024675&sr=1-1&keywords=word+power+made+easy

 1 votes -- Nitin Sharma ( 379 points)

12.20 squares and cubes top gateoverflow.in/26885

Let p,q,r,s,t be consecutive positive integers such that p+q+r is perfect square and p+q+r+s+t is perfect cube..find smallest
possible value of r

12.20 Please suggest book / notes / lectures for verbal ability. top gateoverflow.in/16021

verbal-ability

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1569 of 2244

Try verbal ability by Arun Sharma .its a nice book

 0 votes -- sdpshaw ( 99 points)

12.21 problem in sharing top gateoverflow.in/16014

Three roomattes a,b,c decided to prepare food combinely for two months.So they buy cooking stuffs as needed and there
individual investments are 1200 , 1300, 1600 in 2 month(both of 31 days).After these they wanted to calculate individual
cost for food . what amount will be shared between them to make fair(equality in money) for this period

A and B will pay rs (4100/3)-1200 and (4100/3)-1300 to C as the total expenditure is 4100 and c has paid more than
4100/3.

 1 votes -- Saurav Kumar Gupta ( 1455 points)

12.22 Which of the following options is the closest in meaning to the


sentence below? top gateoverflow.in/30396

8. Which of the following options is the closest in meaning to the sentence below? “As a woman, I have no country.” (A)
Women have no country. (B) Women are not citizens of any country. (C) Women’s solidarity knows no national boundaries.
(D) Women of all countries have equal legal rights.

Option C

It is a metaphorical statement.

 0 votes -- Gate Brahmachari ( 123 points)

12.23 mixtures top gateoverflow.in/30412

Two varieties of rice are mixed together in the ratio 2:3. The cost price of each kg of second variety is Rs.5 more than the
cost price of each kg of first variety of rice. If the cost price of mixture is Rs.25, then find the cost price of first variety of
rice.

(a) Rs.20 (b) Rs.22

(c) Rs.23 (d) Rs.24


Selected Answer

let the mixture be 2x and 3x

total mixture=5x

let CP of 1st mixture is C/kg

threfore CP of 2nd mixture is C+5/kg

now

total CP=5x *25

2x *C + 3x *(C+5)=5x *25

x(2C+3C+15)=125x

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1570 of 2244

5C=110

C=22

Option B

 1 votes -- Sandip Shaw ( 755 points)

12.24 which part of the sentence is incorrect ? top gateoverflow.in/14029

[A]. As much as I admire him for his sterling qualities.


[B]. I cannot excuse him for
[C]. being unfair to his friends.
[D]. No error.

Ans A Replace ‘As much as’ by ‘Howsoever much’

 0 votes -- Sanjay Sharma ( 799 points)

12.25 idea of this passage top gateoverflow.in/34135

verbal-ability

Most of the passage is regarding the upward trend in global temperatures. So D will be good choice, I think.

 1 votes -- Salman ( 615 points)

12.26 number series top gateoverflow.in/30470

find next number in series

0, 5, 10, 15, 30, 35, 70, 75

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1571 of 2244

Selected Answer

The series goes as follows :

Add 5 for the first and double it next term.

0 , 0+5 , 5*2 , 10+5 , 15*2 , 30+5, 35*2 , 70+5 , 75*2

Next term is 150 .

 7 votes -- Riya Roy ( 4767 points)

Its like we are adding 5 to all the odd position terms and multiplying by 2 all the even even terms.
Like:
0 is at position 1, means its an odd position => add 5
5 is at position 2, means its an even position => multiply number at this position by 2, and so on..

Therefore, the series is like:


0 , 0+5 , 5*2 , 10+5 , 15*2 , 30+5, 35*2 , 70+5 , 75*2, ...

So, next term is 150.


 3 votes -- Monanshi Jain ( 5827 points)

12.27 Which is best book for Verbal ability? top gateoverflow.in/296

Verbal Ability includes following topics.

Verbal Ability : English Grammar, Sentence Completion, Verbal Analogies, Word Groups, Instructions, Critical Reasoning and Verbal Deduction.

verbal-ability

I think that is a difficult question to answer. Probably you can refer some GRE books- but that would be a bit too much for
GATE. Usually the verbal questions asked in GATE are just a bit low standard compared to CAT exams. So, if you are not
comfortable with verbal, you can prepare using CAT materials and avoiding tough ones.

 0 votes -- gatecse ( 9515 points)

12.28 Which part of sentence is incorrect ? top gateoverflow.in/14034

[A]. The retiring principal asked his old pupils


[B]. to take the interest in the school
[C]. after he has retired.
[D]. No error.

According to me the answer must be C , after his retirement , plz correct me .

I think the answer should be B. (intuition)

Incorrect: to take the interest in the school

Correct: to take interest in the school

 2 votes -- Vinayak Mehta ( 31 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1572 of 2244

13 Numerical Ability top


13.1 Ace Pregate: Summation of a series : 1 + 4/7 + 9/7^2 + 16/7^3 + ....
top gateoverflow.in/37521

Let S = 1 + 4/7 + 9/7^2 + 16/7^3 + ....

i.e, summation of (n+1)^2 / 7^n = ? (upto infinity)

ace-pregate aptitude summation

Got a clue from brilliant.org

 5 votes -- Tushar Shinde ( 1523 points)

13.2 Ace Test Series: Aptitude : Lease or buy top gateoverflow.in/35421

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1573 of 2244

numerical-ability ace-test-series


Selected Answer

Total cost for purchase after 4 years = 4000 * (1.14)^4 = 6755.9

Total cost for leasing after 4 years = ((1250 * 1.14 + 1250) * 1.14 + 1250 )*1.14 + 1250 = 6151.43 (assuming rent is
paid at end of a year). So, leasing is preferable.

 1 votes -- Arjun Suresh ( 124125 points)

13.3 Algebra: A tiled floor of a room has Dimensions top gateoverflow.in/30917

A tiled floor of a room has dimensions m × m Sq.m. Dimensions of the tiles used are n × n Sq.m. All tiles used are green tiles except diagonal
tiles which are red.

After some years some green tiles are replaced by red tiles to form an alternate red and green tile pattern. How many green tiles are
removed? (m is not equal to n and total no. of tiles are odd)

A) (m 2 − 4mn + 2n2 )/2n2

B) ((m − 2mn)2 − n2 )/2n2

C) (m 2 − 4mn − n2 )/2n2

D) (m 2 − 4mn − 2n2 )/2n2

algebra

13.4 And: distance top gateoverflow.in/39913

Two cars start at the same time from Mumbai and pune and proceed towards each other at the rate of 60 km and 40 km per
hour, respectively.when they meet , it is found that one car has travelled 20 km more than the other. Find the distance
between Mumbai and pune

time speed and distance

Let at the time t hrs , they meets

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1574 of 2244

Distance covered by that move from Mumbai, say x = 60t Km

Distance covered by that move from Pune, say y = 40t Km

Distance between Mumbai and Pune = x + y = 60t + 40t = 100t Km

one having more speed with cover more distance in same time.

so, x = y + 20

60t = 40t + 20

t = 1hr

Distance between Mumbai and Pune = 100 × 1 = 100Km

 1 votes -- Praveen Saini ( 34299 points)

13.5 Binary Tree: Labeled binary tree top gateoverflow.in/38149

Number of labeled binary trees are there on vertices {1,2,3,4} that have only vertex 1 as leaf and every binary trees has 4
nodes are _______.

binary-tree


Selected Answer

We have 4 nodes out of which 1 is a leaf and there are no mode leaf nodes. So, we must have 4 levels with one node in
each. Each node in levels 2, 3 and 4 have two choices- either to be left child or right child. So, totally 2 × 2 × 2 = 8 ways.
Now, 2, 3, 4 can be permuted in any order in first 3 levels and each permutation gives a different binary tree. So, total
number of binary trees = 8 × 3! = 48.

 2 votes -- Arjun Suresh ( 124125 points)

lets Vertex 1 is Leaf & it is fixed.


Exactly one leaf means at each level will be one & only one node..

Except root every node have 2 choices : 1. Left node 2. Right node
Total 4 nodes, so Number of possible combination for unlabeled tree are 2*2*2 = 8

We have to find Number of Labeled tree so multiply 8 by 3!


= 8*3! = 48

 1 votes -- Digvijay Pandey ( 26245 points)

13.6 Cat2009: CAT2009-6 top gateoverflow.in/33036

10% of the voters did not cast their vote in an election between two candidates. 10% of the votes polled were found invalid.
The successful candidate got 54% of the valid votes and won by a majority of 1620 votes. The number of voters enrolled on
the voters list was:

a. 25000
b. 33000
c. 35000
d. 40000

cat2009 numerical-ability sets


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1575 of 2244

Let n is number of voters enrolled

10% of voters did not cast their vote.

So, Number of voters actually voted = 0.9n

10% of those voted, are found invalid

​So, Number of valid votes counted = 0.81n

The sucessful candidate got 54% of valid votes and win by majority of 1620

So, lossing candidate got 46% of valid votes as it is two candidate election

​Difference of 8% of valid votes = 1620

8
100
× 0.81n = 1620

​So, n = 25000

 1 votes -- Praveen Saini ( 34299 points)

13.7 Cat2009: CAT2009-9 top gateoverflow.in/33047

The shaded portion of figure shows the graph of which of the following?

a. x(y − 2x) ≥ 0
b. x(y − 2x) ≤ 0
1

( )
c. x y + 2 x ≥ 0

( )
d. x y − 2 x ≤ 0

cat2009

Equation of line is that passed through (0, 0) and (1, 2) is

y = 2x

For shaded portion in First quadrant

Shaded portion is above that line

means y ≥ 2x ​or, y − 2x ≥ 0

And bounded by x ≥ 0

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1576 of 2244

So It must satisfies x(y − 2x) ≥ 0 (product of inequalities)

For the second portion, y − 2x ≤ 0 and x ≤ 0

Here also, x(y − 2x) ≥ 0 (here product reverse the direction of inequalities)

 1 votes -- Praveen Saini ( 34299 points)

13.8 Cat2009: CAT2009-10 top gateoverflow.in/33048

y y

(
If f x + 8 , x − 8
) = xy, then f(m, n) + f(n, m) = 0

a. Only when m = n
b. Only when m ≠ n
c. Only when m = − n
d. For all m and n

cat2009 numerical-ability functions

y y
8 8
Let x + = m and x − =n

By solving these equations, we will get


m+n
2
x= and y = 4(m − n)

y y
8 8
As, f(x + , x − ) = xy
m+n
2
So,f(m, n) = × 4(m − n) = 2(m 2 − n2 )

and, f(n, m) = 2(n2 − m 2 ) [by interchanging ]

f(m, n) + f(n, m) = 2(m 2 − n2 ) + 2(n2 − m 2 ) = 0

It is always 0,irrespective of value of m and n,

Option D

 2 votes -- Praveen Saini ( 34299 points)

13.9 Cat2009: CAT2009-3 top gateoverflow.in/33025

In a certain zoo, there are 42 animals in one sector, 34 in the second sector and 20 in the third sector. Out of this, 24 graze in
sector one and also in sector two. 10 graze in sector two and sector three, 12 graze in sector one and sector three. These
figures also include four animals grazing in all the three sectors are now transported to another zoo, find the total number of
animals.

a. 38
b. 56
c. 54
d. None of the above.

cat2009 numerical-ability sets

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1577 of 2244


Selected Answer

A = 42

B = 34

C = 20

A ∩ B = 24

B ∩ C = 10

A ∩ C = 12

A∩B∩C=4

A∪B∪C = A+B+C−A∩B−B∩C−A∩C+A∩B∩C

A ∪ B ∪ C = 42 + 34 + 20 − 24 − 10 − 12 + 4

= 54

 1 votes -- Praveen Saini ( 34299 points)

13.10 Cat2009: CAT2009-1 top gateoverflow.in/32900

1 1
m n m n
If mxm − nxn = 0, then what is the value of x +x + x −x in terms of xn ?
2mn
xn (n 2 −m2 )
a.
2mn
xn (n 2 +m2 )
b.
2mn
n 2 2
c. x (m −n )
2mn
xn (m2 +n 2 )
d.

cat2009 numerical-ability


Selected Answer

mxm − nxn = 0

xm n
n
So, x = m

1 1
xm xm
1
xm +xn
+
1
xm −xn
=
xn
( ) ( )
xn
+1
+
xn xn
−1

( )
1 1
1 n n
n m m
= x +1
+ −1

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1578 of 2244

m 1 1

= xn
( n +m
+ n −m
)
2mn
n 2 2
= x (n −m )

 1 votes -- Praveen Saini ( 34299 points)

13.11 Cat2009: CAT2009-2 top gateoverflow.in/32901

ˉ
If log(0.57) = 1.756, then the value of

log57 + log(0.57)3 + log√ 0.57 is:

a. 0.902
ˉ
b. 2.146
c. 1.902
ˉ
d. 1.146

cat2009 numerical-ability


Selected Answer

log57 + log(0.57)3 + log√ 0.57

= log(100 ∗ 0.57) + log(0.57)3 + log√ 0.57

1
2
= log(100) + log(0.57) + log(0.57)3 + log(0.57)

= 2 + log(0.57) + 3log(0.57) + 2 log(0.57)

= 2 + 4.5log(0.57)

= 2 + 4.5( − 1 + 0.756)

= 0.902

 2 votes -- Praveen Saini ( 34299 points)

13.11 Combinations: How many 4 digit numbers are divisible by 5 can be


formed with digits 0,1,2,3,4,5,6 and 6? top gateoverflow.in/9142

permutation combinations


Selected Answer

Unit digit can be chose in 2 ways- either 0 or 5.

When unit digit is 5:


With just a single 6:

Number of numbers possible = 5 * 5 * 4 = 100 (as MSD cannot be a 0)

Now, two 6's can come as 66x 6x6 or x66, and this counts to 5 + 5 + 4 = 14 numbers (for the last case, x can only be
from 1-4 and not 0)

So, total numbers ending in 5 = 100 + 14 = 114.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1579 of 2244

When unit digit is 0:


With just a single 6:

Number of numbers possible = 6 * 5 * 4 = 120

Now, two 6's can come as 66x 6x6 or x66, and this counts to 5 + 5 + 5 = 15 numbers.

So, total numbers ending in 0 = 120 + 15 = 135.

Thus, total numbers divisible by 6 = 114 + 135 = 249.

 1 votes -- Arjun Suresh ( 124125 points)

13.12 Combinatorics: Aptitude top gateoverflow.in/29385

what is the unit digit in

(3474)1793 ∗ (225)317 ∗ (451)491

combinatorics numerical-ability


Selected Answer

4 ; 4*4=16 ; 4*4*4=64 ; 4*4*4*4=256 ; 4*4*4*4*4=1024

you can see Here if number of 4 in unit place is odd then unit digit will be 4 and number of 4 in unit place
is even then unit digit will be 6.

Now

5 ; 5*5 =25 ; 5*5*5=125 ; 5*5*5*5=625

Here unit digit will be 5 always.

1 ; 1*1 =1 ; 1*1*1 =1 ; 1*1*1*1=1

Here unit digit will be 1 always.

(3474)1793 :- Here number of 4 in unit place is odd so unit digit will be 4.

(225)317 :- Here unit digit will be 5.

(451)491 :- Here unit place result will be 1.

So unit digit in ( 3474)1793 *( 225 )317 * ( 451 )491}

4*5*1=20
1793 317 491
Hence unit digit in ( 3474) *( 225 ) * ( 451 ) will be ZERO.

 7 votes -- Leen Sharma ( 2935 points)

13.13 Expectation: Probability top gateoverflow.in/20640

We are given a set X = {x1, x2, …, xn } where xi = 2i. A sample S (which is a subset of X) is drawn by selecting each xi
1

independently with probability Pi = 2 . The expected value of the smallest number in sample S is:

a) 1/n

b) 2

c) √ n

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1580 of 2244

d) n

probability expectation

13.14 Geometry: B.Math. 2005 top gateoverflow.in/41792

Let 0 < θ < π.

The area of the triangle in the plane formed by the vertices ( − 1, 0), (1, 0), (cosθ, sinθ) is

a. not more than 1


b. can be more than 1 but not more than 2
c. can be more than 2 but not more than π
d. can be more than π but not more than 2π

numerical-ability geometry

Two coordinates of triangle lies on the x-axis, ( − 1, 0) and (1, 0).

so base of the triangle = 2

height of triangle will be = sinθ

so area will be 2 × 2 × sinθ = sinθ

for 0 < θ < π, maximum value of sinθ will be 1 only at θ = 90 ∘ .

Area of given triangle can be maximum 1

 0 votes -- Praveen Saini ( 34299 points)

13.15 Logarithms: Doubt on logarithms top gateoverflow.in/42025

What is the difference among the following:

log ² n, logn ² , loglogn, (logn) ²

logarithms


Selected Answer

By default base of log = 10. i.e.,

log100 = 2  102 = 100

For base e we use ln and for base 2 we use lg.

Now, coming to question, lets take n = 1000.

1. log2 n = logn × logn = 3 × 3 = 9.


2. logn2 = log1000000 = 6.
3. loglogn = log3 = 0.4771.
4. (logn)2 = log2 n = 9.

 5 votes -- Arjun Suresh ( 124125 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1581 of 2244

13.16 Logical Reasoning: Who among the following teaches Chemistry gateoverflow.in/9770

top

Eight people – A, B, C, D, E, F, G and H are sitting around a circular table facing the centre, but not necessarily in the same
order. All of them are at equidistant. Each one of them teaches different subjects viz., English, Hindi, Mathematics, Biology,
Psychology, Physics, Chemistry and Accounts, but not necessarily in the same order.

The person who teaches Accounts, sits third to the right of G. C is an immediate neighbour of G. The person who teaches
Mathematics sits second to the left of C. B sits third to the right of H. H teaches neither Accounts nor Mathematics. Only two
persons sit between C and the person who teaches Physics. A and F are immediate neighbours of each other. Neither A nor F
teaches Accounts. The person who teaches English sits second to the right of A. Two persons sit between D and the person
who teaches Hindi. D does not teach Accounts. The person who teaches Psychology is an immediate neighbour of the person
who teaches Accounts. The person who teaches Physics sits second to the left of A. One of the immediate neighbours of G
teaches Chemistry.

1. Who among the following teaches Chemistry?


(1) A
(2) H
(3) D
(4) G
(5) None of these

logical-reasoning


Selected Answer

A B C D E F G

We have eight people and eight seats around a round table, so a person has two neighbours. Just writing the given
conditions: '-' shows a place taken by a undecided person. (Accounts) means the person teaching Accounts.

1. G _ _ (Accounts)
2. G C or C G
3. (Maths) _ C
4. H _ _ B
5. H no Accounts no Maths
6. C _ _ (Physics) or (Physics) _ _ C
7. A F or F A - both not Accounts
8. A _ (English)
9. D _ _ (Hindi) or (Hindi) _ _ D D not Accounts
10. (Accounts) (Psychology) or (Psychology) (Accounts)
11. (Physics) _ A
12. G (Chemistry) or (Chemistry) G

First seeing Accounts- it is not taught by G or C or H or A or F or D. So either B or E. But seeing the conditions 1 and 4, B
cannot be Accounts as G != H. So, Accounts must be taught by E - condition 13.

So,
G _ _ E
E is teaching Accounts

Now A F cannot go in the two missing places above as


G A F E would mean G A F E H _ _ B, making A and B (or F and B) the neighbors of G, but C must be a neighbor of G as
per question.

So, E is teaching Accounts and AF cannot be between G and E. Also, an interesting condition is given in conditions 6 and
11 because it says either C _ _ _ _ A or A C. Now lets see the possibilities for placing H _ _ B by trying to place H in all
possible places.

Case 1: G H _ E B _ _ _ but we have C neighbor of G, so, we get


G H _ E B _ _ C -After C the fifth place is taken by B. So, A C must be there. Thus, we get
G H D E B F A C as Case 1.

Case 2: G _ H E _ B _ _ only place for A F is at the end and C is a neighbor of G. So, this case leads to G C H E D B A F
(again using C _ _ _ _ A).

Case 3: G _ _ E H _ _ B - again we can place C and AF giving G C D E H F A B as case 3.

Case 4: G B _ E _ _ H _ - again we can place C and AF giving G B D E A F H C as case 4.

Case 5: G _ B E _ _ _ H - again we can place C and AF giving G C B E D F A H as case 5.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1582 of 2244

So, lets assign the subjects in each case:

Condition Case 1 Case 2 Case 3 Case 4 Case 5


No. G H D E BG C H E D BG C D E HG B D E AGCBEDFAH
FAC AF FAB FHC
E- E -E -
13 Accounts E - Accounts Accounts Accounts E - Accounts
8 G - English G - English G - English H - English G - English
11 B - Physics D - Physics H - Physics D - Physics D - Physics
H -
3 F - Maths F - Maths B - Maths F - Maths
Maths violates 5
C -
9 C - Hindi Hindi violates F - Hindi C - Hindi
12
D - D -A -
10
Psychology Psychology Psychology
H - C -B -
12 Chemistry Chemistry Chemistry
A - Biology A - Biology G - Biology

So, there are 3 possibilities for Chemistry- H, C or B. So, answer must be None of these.

 1 votes -- Arjun Suresh ( 124125 points)

Answer : (2) H

G-English,H-Chemistry,D-Psychology,E-Accounts,B-Physics,F-Math,A-Bio,C-Hindi (anti clockwise)

This satisfy all the given conditions in this question.

 1 votes -- gaurav1989 ( 21 points)

13.17 Modular Arithmetic: What will be the in the units place of? top gateoverflow.in/17609

(
Q1) What is the units digit of 3911– 3211 ? )
(a) 1 (b) 5

(c) 7 (d) 8

Q2) What will be in the unit place of 458 + 1911– 6218?

(a) 0 (b) 2

(c) 3 (d) 7

modular-arithmetic


Selected Answer

In these type of questions, i.e. when you raise a number to some power, find the pattern of unit digit and then solve.

(1) 3911 − 3211

For 3911 : Unit digit of 39 is 9, and thus unit digits of its powers will be 9,1,9,1,... So 3911 ends in 9.

For 3211 : Unit digit of 32 is 2, and thus unit digits of its powers will be 2,4,8,6,2 (and then pattern continues). So 3211
ends in 8.

So unit digit of 3911 − 3211 = 9 − 8 = 1

Solve second question similarly and we get 5 + 9 - 4 = 0 for unit digit.

 2 votes -- Happy Mittal ( 9253 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1583 of 2244

13.18 Probability: Conditional probability top gateoverflow.in/6783

probability


Selected Answer

One side of the tossed coin is head. So, our sample space now has only two possible coins - HH and HT but both are not
equally probable.

In our sample space we can have 6 possible outcomes: (HT means Head turns up and Tail is on other side)

HH, HH, HT, TH, TT, TT all of which are equally probable.

Now, Head turns up means we now have only 3 events HH, HH and HT and only HT is favorable for the other side being
Tail. So, required probability is 1/3.

 1 votes -- Arjun Suresh ( 124125 points)

It will be equal to

(probability of getting head on the coin with head and tail.) / (probability of getting head in any coin)

=(1/3*1/2)/(1/3*1 +1/3 *0 +1/3*1/2)

=1/3

 3 votes -- Anurag Semwal ( 4775 points)

13.19 Probability: The average time between successive occurrences of


earthquakes ? top gateoverflow.in/30171

In any given year, the probability of an earthquake greater than Magnitude 6 occurring in the Garhwal Himalayas is 0.04.
The average time between successive occurrences of such earthquakes is ____ years.

aptitude probability


Selected Answer

0.04 × n = 1
1
0.04
n=
= 25

answer = 25 years

 3 votes -- Amar Vashishth ( 17865 points)

13.20 Probability: total probability top gateoverflow.in/20203

A bag contains 3 balls. Given that one of the balls is red and the other two balls can be either red or non-red..what is the
probability of picking up a red ball?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1584 of 2244

probability


Selected Answer

First let's see what are the possibilities for other two balls :

RR , NR or RN ( this gives same probability for drawing a Red ball ) , NN

Case 1(RR) : (Including R it becomes RRR)

probability of Drawing a red ball here is 1 {As all balls become RED }

probability of occuring of this case is 1/4 {As other cases can be RN,NR,NN }

So, Total probability of Drawing a red ball for this case = 1/4 * 1

Case 2(NR or RN) : (Including R it becomes RNR,RRN)

probability of Drawing a red ball here is 2/3 {As 2 balls are RED }

probability of occuring of this case is 2/4 {As other cases can be RR,NN }

So, Total probability of Drawing a red ball for this case = 2/4 * 2/3

Case 3(NN) : (Including R it becomes RNN)

probability of Drawing a red ball here is 1/3 {As one ball is RED }

probability of occuring of this case is 1/4 {As other cases can be RN,NR,RR }

So, Total probability of Drawing a red ball for this case = 1/4 * 1/3

Summing up , we get (1/4 * 1) + (2/4 * 2/3) + (1/4 * 1/3) = 2/3

 1 votes -- Himanshu Agarwal ( 8861 points)

13.21 Probability: Probability top gateoverflow.in/4933

10 men and their wives participate in a corporate mixed-doubles tennis championship. What is the probability that no couple
play in the second game?

A. 0.6222
B. 0.3111
C. 0.4285
D. 0.2777

probability


Selected Answer

A mixed doubles game has 4 players- 2 men and 2 women.

Number of ways to select men = 10 C2

Number of ways to select women = 10 C2

So, total number of ways = 10 C2 * 10 C2

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1585 of 2244

Cases were no couples are there = 10 C2 * 8C2 (select 2 men from all 10 possibilities and select 2 women from all
possibilities excluding the 2 wives)

So, required probability = 10 C2 * 8C2 / (10 C2 * 10 C2)


= 8*7/(10*9)
= 56/90
= 0.6222

 3 votes -- Arjun Suresh ( 124125 points)

13.22 Probability: Probability top gateoverflow.in/37706

Ram and Ramesh appeared in an interview for two vacancies in the same department. The probability of Ram's selection is
1/6 and that of Ramesh is 1/8. What is the probability that only one of them will be selected?

(A) 47/48

(B) 1/4

(C) 13/48

(D) 35/48

P(Ramesh U Ram) = P(Ramesh) + P(Ram) - P(Ramesh ∩ Ram)

= 1/6 + 1/8 - 1/6 * 1/8 = 13/48

ie. option (C)

Am i correct ? Please comment..

probability

Must be B.

Only one of them is selected if one of below two conditions hold.

Ram is selected and Ramesh is not selected (1/6 * 7/8), or


Ramesh is selected and Ram is not selected (1/8 * 5/6)

Because only one of the two conditions is supposed to hold, we add the two probabilities to get 1/4.

Edit :
When you solve by using

P(Ram ∪ Ramesh) = P(Ram) + P(Ramesh) − P(Ram ∩ Ramesh), it actually expands as :

¯ ¯
P(Ram) + P(Ramesh) − P(Ram ∩ Ramesh) = P(Ram). [P(Ramesh) + P(Ramesh)] + P(Ramesh). [P(Ram) + P(Ram )] − P(Ram). P(Ramesh)

When you simplify these terms by opening the parenthesis, you will find that you are adding an extra P(Ram). P(Ramesh).
Hence, the incorrect answer.

Hope it helps.

 1 votes -- Gaurav Sharma ( 1383 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1586 of 2244

13.23 Probability: What is the Probability top gateoverflow.in/42977

A point P is randomly chosen in the line AB of length 2a. What is the probability that the area of the rectangle having sides
AP and PB will exceed a2 /2?

probability


Selected Answer

1/ √ 2 should be the right answer.

Let AP = x,
then PB = (2a − x).
Since point P can be anywhere between A & B, x belongs to [0, 2a], thus the total the length of total available range interval
for x = (2a − 0) = 2a.
Area of the rectangle having sides lengths equal to the length of AP & PB = x. (2a − x).
Length of interval range of x, in which x. (2a −x) >a 2 / 2
Length of total available range interval for x
Required Probability = .
_____________________________________________

Finding the interval for x in which (x. (2a − x)) > (a2 )/2.
x. (2a − x) > a2 /2
 2ax − x2 > a2 )2
 2ax − x2 − a2 > a2 /2 − a2
 − x2 + 2ax − a2 > − a2 /2
 x2 − 2ax + a2 < a2 /2
 (x − a)2 < a2 /2
 | x − a | < a/ √ 2 ------------------------- Inequality I
 When x < a, − (x − a) < a/ √ 2
 When x < a, (x − a) > − a/ √ 2
 x > a − (a/ √ 2).

So when x belongs to [0, a], the range of x in which x. (2a − x) will be greater than a2 /2 would be (a − (a/√2), a].
Now, when x > a, from inequality I, (x − a) < a/ √ 2,
 When x > a, x < a + (a/ √ 2).

So when x belongs to [a, 2a], the range of x in which x. (2a − x) will be greater than a2 /2 would be [a, a + (a/ √ 2)).
Hence, overall when x will belong to (a − (a/ √ 2), a] ∪ [a, a + (a/ √ 2)), that is, (a − (a/ √ 2), a + (a/ √ 2)), then (x. (2a − x)) will be greater
than a2 /2.

So length of favourable interval = ((a + (a/ √ 2)) − (a − (a/ √ 2))) = √2a. & the length of all available interval, i.e. the interval
[0, 2a] = 2a − 0 = 2a.

Hence, the required probability = (√ 2a)/(2a) = 1/ √ 2.

 1 votes -- Anurag Pandey ( 8183 points)

13.24 Probability Using Tree Method: Probability top gateoverflow.in/37197

http://www.techtud.com/doubt/virtual-gate-2015-question-6

How to solve this question using tree method of probability?

probability engineering-mathematics probability-using-tree-method

In the question u are required to calculate A's winning probability so it would be-->

Let probability that A throws sum 8 be P(A) (=5/36) and probability that B throws 7 be P(B) ( =6/36) in a single attempt

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1587 of 2244

therefore P(A')=31/36 and P(B')=30/36

so A's winning probability -->

P(A)+ P(A')*P(B')*P(A)+P(A')*P(B')*P(A')*P(B')*P(A)+........ (it is simply either A throws 8 in first attempt or in third attempt and so on while B does not throws a 7)

5/36 + (31/36)*(30/36)*(5/36) + (31/36)*(30/36)*(31/36)*(30/36)*5/36 +.....

(5/36){ 1+(31/36)*(30/36) + ((31/36)*(30/36))^2 +......) (This forms a infinite geometric series )

therefore

=(5/36)*1/(1-155/216)

=(5/36)*(216/61)

=30/61

 1 votes -- Abhishekcs10 ( 1001 points)

13.25 Quadratic Equations: B.Stat. 2005 top gateoverflow.in/41760

If √ 3 + 1 is a root of equation 3 x 3 + ax 2 + bx + 12 = 0 where a and b are rational numbers, then b is equal to

A. -6
B. 2
C. 6
D. 10

numerical-ability quadratic-equations normal


Selected Answer

√3 + 1 and − √3 + 1 are two roots of this equation


so 3(√ 3 + 1)3 + a(√ 3 + 1)2 + b(√ 3 + 1) + 12 = 0

3(3√ 3 + 9 + 3√ 3 + 1) + a(3 + 2√ 3 + 1) + b(√ 3 + 1) + 12 = 0

a(3 + 2√ 3 + 1) + b(√ 3 + 1) + 18√ 3 + 42 = 0

a(4 + 2√ 3) + b(√ 3 + 1) + 18√ 3 + 42 = 0 -----(1)

using other root,

3( − √ 3 + 1)3 + a( − √ 3 + 1)2 + b( − √ 3 + 1) + 12 = 0

3( − 3√ 3 + 9 − 3√ 3 + 1) + a(3 − 2√ 3 + 1) + b( − √ 3 + 1) + 12 = 0

a(3 − 2√ 3 + 1) + b( − √ 3 + 1) − 18√ 3 + 42 = 0

a(4 − 2√ 3) + b( − √ 3 + 1) − 18√ 3 + 42 = 0 -------(2)

using (1) and (2)

4a + b = − 42 [ by adding ]

2a + b = − 18 [ by subtracting]

a = − 12 and b = 6

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1588 of 2244

 4 votes -- Praveen Saini ( 34299 points)

13.26 Quadratic Equations: CAT2009-4 top gateoverflow.in/33028

The ratio of the roots of bx2 + nx + n = 0 is p: q, then

q p l

a. √ p
+ √ q
+ √ n
=0
p q n

b. √ q
+ √ p
+ √ l
=0
q p n

c. √ p
+ √ q
+ √ l
=0
p q l

d. √ q
+ √ p
+ √ n
=0

cat2009 numerical-ability quadratic-equations

let α and β are roots of quadratic equation bx2 + nx + n = 0


n n

so sum of roots α + β = − b and product of roots, αβ = b

α p

Ratio of roots given, β = q

α+β p +q

so β = q -------(1)
β q

And α = p

α+β p +q
α
= p --------(2)

from, (2) and (1)

α+β α+β p +q p +q
α β p
× = × q

(p +q )2 (α+β)2
pq αβ
=
(p +q ) (α+β)
√pq √αβ
= -------------(3)

lets try to compute

p q

√ √ q
+ p

p +q
√pq
=

(α+β)
√αβ
= [From (3)]
−n
b


n
b

==

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1589 of 2244

= − √ b

p q n

so, √ √ q
+ p
= − √ b

p q n

√ √ √ q
+ p
+ b
=0

 0 votes -- Praveen Saini ( 34299 points)

13.27 Ratios: CAT2009-7 top gateoverflow.in/33038

The resistance of a wire is proportional to its length and inversely proportional to the square of its radius. Two wires of the
same material have the same resistance and their radii are in the ratio 9:8. If the length of the first wire is 162cms, find the
length of the other.

a. 64cm
b. 120cm
c. 128cm
d. 132cm

cat2009 numerical-ability ratios


Selected Answer

Resistance of a wire is directly proportional to its length and inversely proportional to square of its radius
l
2
So, Resistance, R ∝ r

l
r2
R = k , where k is some constant.

​Say R1 , l1 , and r1 are Resistance, length and radius for first wire, similarly R2 , l2 , and r2 for second wire

r1
9
r2
​Given, = 8 and l1 = 162cm

​And, both wire having same resistance,

​So, R1 = R2

l1 l2

r21 r22
k =k

r2

()
8

()
2 2
r1 9
l2 = l1 = 162 ×

128cm

 1 votes -- Praveen Saini ( 34299 points)

13.28 Ratios: aptitude question on ratios top gateoverflow.in/13168

In a Certain office,1/3 of the workers are women,1/2 of the women are married and 1/3 of the married women have

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1590 of 2244

children. If 3/4 of the men are married and 2/3 of the married men have children. What part of the workers are without
children??

a)5/18 b) 4/9 c)11/18 d)17/36

my answer is 11/18 but given to be correct is 5/18??help guys.. but please mention the complete procedure.

numerical-ability ratios


Selected Answer

Workers without children = men without children + women without children

Let X be the total workers.

Women with children = X/3 * 1/2 * 1/3 = X/18

Men with children = 2X/3 * 3/4 * 2/3 = X/3

So, workers without children = X - X/18 - X/3 = 11/18

Now married workers without children = married women without children + married men without children

= X/3 * 1/2 * 2/3 + 2X/3 * 3/4 * 1/3 = X/9 + X/6 = 5/18

May be this is what is meant in question.

 2 votes -- Arjun Suresh ( 124125 points)

13.29 Test Cases: Made Easy Advanced FLT 1 top gateoverflow.in/31567

Q.5

In the given figure, triangles ABC and PQR are right angled triangles with angle C and Q being right angles. QR is parallel to
AC and AB = 300 cm, PQ = 20 cm and QR = 100 cm. The length of side BC to the nearest integer is ___________ cm.

numerical-ability made-easy test-cases


Selected Answer

Answer : 59 cm

In the right angled ΔPQR, using Pythagoras theorem,

PR2 = PQ 2 + QR2 .

⇒ PR = √1002 + 202,
⇒ PR = 102 cm ( after rounding off).

Now in the right angled triangles ΔPQR and ΔBCA,

∠PQR = ∠BCA = 90 ∘ ,

also QR is parallel to AC,

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1591 of 2244

so ∠QRP = ∠CAB ( as they are alternate interior angles).

Now since the above two pairs of angles in ΔPQR and ΔBCA are equal, the third pair of angles i.e. ∠QPR and ∠CBA will
also be equal to each other.

Hence ΔPQR and ΔBCA are similar triangles.

Using a property of similar triangles, ratio of corresponding sides of both the triangles will be same,

BC PQ

that is AB = PR ,

PQ×AB
PR
⇒ BC = ,
20×300
102
⇒ BC = = 58.82 cm.

 2 votes -- Anurag Pandey ( 8183 points)

13.30 Virtualgate: Row echelon form having more than 2 non-zero entries
Virtual Gate 2016 top gateoverflow.in/38665

1). If the row reduced form of a matrix has more than two non-zero entries in any row, then the corresponding system of
equations has inifinitely many solutions.

2). If the row reduced form of a matrix has more than two non-zero entries in any row. then the corresponding system of
equations either has infinitely many solutions or no solutions.

For infinite or no solutions, shouldn't the number of equations be less than number of variables? If we have more than 2 non
zero, then its good, because then we will have more number of equations? How is the answer C?

virtualgate matrices

Reduced row echelon form is used to find the nature of the solution set of the system.whether the solution is finite or infinite or single

A linear system is said to be consistent, if it has either one solution or infinitely many solutions. A system is inconsistent if it has no solutions.now first thing is
how do we determine whether the system of linear equation is consistent or inconsistent , well consider a system of equations where we have 'n' columns or
variables and 'm' numbers of rows or equations .In augmented matrix form if the right most column or the n+1 column is not a pivot or leading 1 ,we have a
consistent system,otherwise we have an inconsistent system ,statement below is a theorem

THEOREM:

A).A linear system is consistent if, and only if the rightmost column of the augmented matrix is not a
pivot column.

Once it is decided that the our system is consistent we have a to find the number of dependent and independent or free variables.Again all the variables
corresponding to the pivot columns are dependent variables and rest are free variables the system of equations below and its reduced echelon form shows the
dependent and independent variables.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1592 of 2244

[x1 a1 + x2 a2 + . . . + xn an = b] and its augmented matrix is [a1 , a2 . . . an , b]

[ ]
1 −1 0 0 3 6
0 0 1 0 −2 1
0 0 0 1 4 9
0 0 0 0 0 0
0 0 0 0 0 0

Here column 1, 3, 4 are pivots while columns 2, 5, 6 are not pivots or represent free variables.Here column 6 is not a pivot which shows that
system of equation is consistent

equipped with information about the system consistency and free variables .we are able to find the nature of solution. Again a theorem

THEOREM:

B). If a linear system is consistent, and if there are no free variables, there exists only 1 solution. If
there are free variables, the solution set contains infinitely many solutions.

In picture above r is the number of pivots or non zero rows and n is the number variables

According to the above theorems and explanations C can only be true iff instead of no solution it is one solution.This question has some discrepancies.

A very good resource i found on this topic is available at http://linear.ups.edu/html/section-TSS.html

 0 votes -- ibia ( 577 points)

13.31 Virtualgate: A natural number n is such that 120≤ n ≤ 240. If HCF of n


and 240 is 1, how many values of n are possible? Virtual gate top gateoverflow.in/38652

A
natural
number
n
is
such
that
120

n

240.
If
HCF
of
n
and
240
is
1,
how
many
values
of
n
are
possible?
Options:

24
32
36
40

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1593 of 2244

aptitude virtualgate


Selected Answer

HCF of n and 240 is 1

240 = 24 × 3 × 5

so we need to find the numbers, such that, 120 ≤ n ≤ 240 , and not divisible of 2 or 3 or 5

Numbers divisible by 2 such that 120 ≤ n ≤ 240 = 120 − 59 = 61

Numbers divisible by 3 such that 120 ≤ n ≤ 240 = 80 − 39 = 41

Numbers divisible by 5 such that 120 ≤ n ≤ 240 = 48 − 23 = 25

Numbers divisible by 2 and 3 such that 120 ≤ n ≤ 240 = 40 − 19 = 21

Numbers divisible by 2 and 5 such that 120 ≤ n ≤ 240 = 24 − 11 = 13

Numbers divisible by 3 and 5 such that 120 ≤ n ≤ 240 = 16 − 7 = 9

Numbers divisible by 2 ,3,and 5 such that 120 ≤ n ≤ 240 = 8 − 3 = 5

Numbers divisible by 2 or 3 or 5 such that 120 ≤ n ≤ 240 = 61 + 41 + 25 − 21 − 13 − 9 + 5 = 89

Total numbers such that 120 ≤ n ≤ 240 = 121

Total numbers such that 120 ≤ n ≤ 240 and not divisible by 2 or 3 or 5 = 121 − 89 = 32

 2 votes -- Praveen Saini ( 34299 points)

13.32 Virtualgate: Virtual Gate 2016 set I Birthday problem top gateoverflow.in/38657

Q) Vivek and Rishabh just become friend with Suchita , and they want to know when her birthday is Suchita gives them a list
of 10 possible options?

May 15 May 16 May 19

June 17 June 18

July 14 July 16

August 14 August 15 August 17

Suchita then tells Vivek and Rishabh separately the month and the day of her birthday respectively

Vivek : I don't know when Suchita's birthday is, but I know that Rishabh does not know too.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1594 of 2244

Rishabh: At first Ididn't know when Suchita's birthday is, but i know now.

Vivek: Then I also know when Suchita's birthday is.

So when is Suchita's birthday?

(A). May 16

(B). June 17

(C). July 16

(D). Data insufficient

How to solve? The answer is C, but how?

virtualgate aptitude

13.33 Virtualgate: If N = 888 up to 100 digits, what is the remainder when N


is divided by 625?_Virtual Gate 2016 top gateoverflow.in/38643

If N = 888 up to 100 digits, what is the remainder when N is divided by 625?

Options:

128
138
338
388

virtualgate


Selected Answer

625 × 16 = 10000
i.e. anything which is multiple of 10000 will also be multiple of 625

8888…8 8888…8
 
100 times = 96 times × 10000 + 8888

88888888888888…8

So to find reminder of 100 times , just find Reminder when 8888 is divided by 625

8888 = 625 × 14 + 138


So, 138 is reminder.

 2 votes -- Digvijay Pandey ( 26245 points)

13.34 Work Time: Time and Work top gateoverflow.in/34992

4
5
Atul does half as much work as Anshu in of the time. If together they take 16 days to complete the work, how many days
shall Anshu take to do it?

A. 23
B. 25
C. 26
D. 30

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1595 of 2244

numerical-ability work-time


Selected Answer

Let speed of Anshu be a.

x
a
Time Anshu takes for x amount of work = .

4x 8x

Time Atul takes for x amount of work = 2 × 5a = 5a .

5a

Speed of Atul = 8

5a 13a

When both works, effective speed = a + 8 = 8 .

13a

16 days to complete work with speed 8 .

13a 1

So, no. of days to complete with speed a = 16 × 8 × a = 26.

 3 votes -- Arjun Suresh ( 124125 points)

--> Let Anshu takes x Days , than Atul takes (2*(4/5)x) = 8x/5 Days.

--> Together Atul and Anshu takes = 16 Days . So, Together 1 Day work = 1 / 16 .

--> Taking 1(one) Day work of , Anshu + Atul = Together .

--> (1 / x) + (5 / 8x) = 1 / 16 , Solving x = (16*13) / 8 = 26 Days [Anshu].


 2 votes -- Vinay Yadav ( 1739 points)

13.35 Work Time: Chain rule top gateoverflow.in/41656

If 9 engines consume 24 metric of coal , when each is working a 8 hours a day ;

how much coal will required for 8 engines each running 13 hours a day it is been given that 3 engines of former type
consume 4 engines of latter type ?

aptitude numerical-ability work-time

9 engines consume 24 metric of coal , when each is working a 8 hours a day


24 1

So, per hour consumption of one former engine = 8 ×9 = 3 .

3 engines of former type consume 4 engines of latter type


3

So, the newer engine consumes less by a factor of 4 .

how much coal will required for 8 engines each running 13 hours a day
1 3
3
Will be 8 × 13 × × 4 = 26.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1596 of 2244

 1 votes -- Arjun Suresh ( 124125 points)

13.36 least significant digit of 2 ^ (3 * (10 ^ 100) ) top gateoverflow.in/42827

100
Find the least significant digit of 23 ×10

A. 2
B. 4
C. 6
D. 8

numerical-ability


Selected Answer

100
23 ×10

= 230…00

= 275×4 ×100 …0

So, Required answer = 6 [As 2 is a cycle of 21 = 2, 22 = 4, 23 = 8, 24 = 6(unit digit is 6)]

So, least significant bit is unit digit i.e. 6

 6 votes -- srestha ( 11585 points)

The answer given above is correct. Least significant digit is 6. Here is a different approach.

24 = 16 , 28 = 256

Thus, any power of 2 which is multiple of 4 will have least significant digit as 6.

If multiple of 4 plus 1 remainder then least significant digit will be 2.

Plus 2 then 4, plus 3 then 8.

24 = 16

25 = 32

26 = 64

27 = 128

Now, we can have 3 ∗ 10100 = 75 ∗ 1098 ∗ 4

So least significant digit is 6.

 3 votes -- Utk ( 1385 points)

13.37 IIIT H Pgee 2016 top gateoverflow.in/42974

WHICH IS NOT A FORM OF DATA

1)characters

2)Numbers

3) Image

4) Sound

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1597 of 2244

5) none of these


Selected Answer

All are type of data

http://www.socialresearchmethods.net/kb/datatype.php

 5 votes -- Manojk ( 3365 points)

13.38 If word MAJORITY is encoded as PKBNXSHQ , then how is DAUGHTER


encoded ? top gateoverflow.in/42503

If word MAJORITY is encoded as PKBNXSHQ , then how is DAUGHTER encoded ?

aptitude


Selected Answer

Caption

 4 votes -- Manojk ( 3365 points)

13.39 Find A Missing value GATE 2015 AG top gateoverflow.in/38844

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1598 of 2244

aptitude


Selected Answer

for first row ( 6+4)/2=5


for second row (7+4+1+2)/2=7
(middle no is sum of remaining no/2)

similarly for last row


we get 3+3/2=3

 9 votes -- Pooja ( 22773 points)

13.40 aptitude top gateoverflow.in/39033

1. S, P, M and E are four persons, working on project efficiency of M is twice that of others and M

works only for half of the total days worked by E. M works 6 hours/day and E works 12

hours/day. Ratio of contribution of work to project of M and E is (i.e., work done by

M work done by

(A) 1 : 1 (B) 1 : 2 (C) 1 : 4 (D) 1 : 3

aptitude

let efficiency of E be x work/hr

eff of M =2xperhr

ratio of work of M/E=2x*6(d/2) / x*12*d =1:2

 3 votes -- Anurag Semwal ( 4775 points)

13.41 Find odd one out? top gateoverflow.in/6784

numerical-ability

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1599 of 2244

Check difference between no. Of chars between last two characters

 2 votes -- Anurag Semwal ( 4775 points)

13.42 Permution & C top gateoverflow.in/43381

There are four persons wearing different colour shirts and four gift packs of colours, same as
those of the shirts. The number of ways in which the gifts, one each to a person, could be
given such that a gift does not go to a person of his shirt colour is


Selected Answer

It is a derangement problem

Formula here used is 4!(1 - 1/1! +1/2! -1/3! +1/4!) =9

Answer is 9

 2 votes -- srestha ( 11585 points)

13.42 A shopkeeper makes a profit of q% by selling an object for RS 24 .had


the c.p and s.p interchanged ,it would have led to a loss of 62.5q% .with the
latter c.p ,what should be the new selling price to get a profit of q%? gateoverflow.in/12388

top

Given: q/100 = (24 - x)/x


(5/8 )*q/100 = (24 - x)/24
Divide both the equations to get
8/5 = 24/x
=> x = 15
=> q = 0.6

Now we have c.p. = 24 and profit = 0.6


Therefore s.p. = 1.6*24 = 38.4

 1 votes -- Rohan Ghosh ( 1515 points)

13.43 aptitude-area top gateoverflow.in/37793

ABCD is square eacg side measuring 4√2.P Q RS are mid points of side AB BC CD DA A circle is drawn inside quadrilateral by
joining PQRS touching all sides..Find area of circle


Selected Answer

If I am not getting it wrong.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1600 of 2244

 2 votes -- Praveen Saini ( 34299 points)

13.44 probability top gateoverflow.in/37868

QUESTION 8 : A bag contains 5 balls out of which some or maybe all are black. 2 balls are drawn from the bag and both are found to be black.
What is the probability that all balls in the bag are black?

As three balls are left in the bag, we first draw the third ball & check for its colour & so on.

Probability of all balls to be black is given by

p(b)=p(third)*p(fourth)*p(fifth)

=((1/3)*1/2)) * ((1/2)*(1/2)) * ((1)*(1/2))

=1/48

 0 votes -- Vivek Srivastava ( 283 points)

13.45 ugc net paper 2 computer science code 87 top gateoverflow.in/11850

25. Suppose that someone starts with a chain letter. Each person who receives the letter is asked to send it on to 4 other
people. Some people do this, while some do not send any letter. How many people have seen the letter, including the first
person, if no one receives more than one letter and if the chain letter ends after there have been 100 people who read it but
did not send it out ? Also find how many people sent out the letter ?

(A) 122 & 22 (B) 111 & 11 (C) 133 & 33 (D) 144 & 44

combinatory


Selected Answer

Either a person sends to 4 people or he doesn't send it. So, let x be the number of persons who sends to 4 people. 100
people didn't send any letter. Except 1 (the initial person) all others (x + 100) must have a sender. So, we can write

No. of receivers = 4 × No. of senders + 1(Initial person doesn't have a sender)

x + 100 = 4x + 1  3x = 99x = 33

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1601 of 2244

 2 votes -- Arjun Suresh ( 124125 points)

ans-c

from basic, consider one sender , he send to four other who only read

" two " they send to seven other "

" three " they send to ten other receiver who only read

this form AP having comman difference 3, and a/q total number of reciever who only read is 100 that is our last term

so, 4+(n-1)*3=100

n=33 this is the no. of reader who send to four other

already there are 100 viewer who only read

so total viewer will be 33+100=133

 3 votes -- sanjay aprice ( 43 points)

13.46 Total number of solutions top gateoverflow.in/39201

If x1 + x2 + x3 + x4 = 98 and x1 , x2 , x3 and x4 are odd numbers, calculate total number of solutions of the equation?

combinatory


Selected Answer

LET

X1=2a+1

X2=2b+1

X3=2c+1

X4=2d+1 .....................

2a+1 +2b+1 +2c+1 +2d+1=98 ....2a+2b+2c+2d=94 .....a+b+c+d=47

reduced to distributing 47 items in 4 different boxes ..then 47+4-1C4-1=50C3

 3 votes -- Deepesh Kataria ( 1207 points)

13.47 A vessel is filled with liquid, 3 parts of which are water and 5 parts
syrup.... top gateoverflow.in/42211

A vessel is filled with liquid, 3 parts of which are water and 5 parts syrup. How much of the mixture must be drawn off and replaced with water so that the mixture
may be half water and half syrup?

1 1
A. B.
3 4

1 1
C. D.
5 7

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1602 of 2244

Answer is C

Suppose the vessel initially contains 8 litres of liquid. Let x litres of this liquid be replaced with water.
3x

Quantity of water in new mixture = (3 − 8 + x) litres

5x

Quantity of syrup in new mixture = (5 − 8 ) litres


3x 5x
8
(3 − + x) = (5 − 8 )

5x + 24 = 40 - 5x

10x = 16
8

∴ x = ( 5 )
8 1 1

So, the part of mixture replaced = ( 5 ∗ 8 ) = 5

 2 votes -- vamsi2376 ( 1185 points)

13.48 The sum of all integers from 1 to 1000 that are divisible by 2 or 5 but
not divisible by 4 equals top gateoverflow.in/41761

The sum of all integers from 1 to 1000 that are divisible by 2 or 5 but not divisible by 4 equals

1. 175000
2. 225500
3. 149500
4. 124000


Selected Answer

numbers divisible by 2=1000/2=>500

numbers divisible by 5=1000/5=>200

but numbers like 10,20,30...are divisible by both 2 & 5 so they will be counted twice so we need to subtract them..to get
the numbers that are only divisible by 5

that is multiples of 10

numbers divisible by 10=1000/10=>100

numbers divisible by 4=1000/4=>250

sum=(2+4+6.....+1000) + (5+10+15....+1000) - (10+20+30....+1000) - (4+8+12....+1000)

sum= 2(1+2+3....500) + 5 (1+2+3...200.) - 10(1+2+3...100) - 4(1+2+3....250)

sum = 2*(500)*(501)/2 + 5 *200*201/2 -10*100*101/2 -4 *250*251/2

sum = 250500 + 100500 - 50500 - 125500

sum= 175000

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1603 of 2244

 3 votes -- Tauhin Gangwar ( 509 points)

13.49 Find divisor and quotient top gateoverflow.in/8887

In a long division sum the remainders from first to last


are 221,301,334 and 280. Find divisor and quotient if
dividend is 987654?

Le y is divisor, y >334 ( largest given remainder) and abcd is quotient

so

a*y+221 =987 ---- ---- (I)

b*y+301 =2216 -----------(II)

c*y+334 =3015 -------------(III)

d*y+280=3344 --------------(IV)

from eq (I)

a*y =766

if a= 1 then y = 766 or if a= 2 y= 383 (a cannot be greater than 2 bcoz y> 334)

from eq (II)

b*y =1915

putting values of y from above if y = 766 then b= 2.5 or if y = 383 then b= 5

b cannot be 2.5 so y = 383 , b = 5 , a = 2.

from eq(III)

c= 7

from eq (IV)

d= 8

987654 / y = abcd + 280/y

y (divisor) = 383

abcd (quotient) = 2578

Remainder = 280

 1 votes -- Praveen Saini ( 34299 points)

13.50 permutation top gateoverflow.in/9145

How many numbers without repeating the number or digit less than 1000 are divisible by 5 can be formed ?

numerical-ability

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1604 of 2244

No of three digit numbers

1)ending with 5 =9*8=72

2)ending with 0=8*8=64

No of two digit numbers

1)ending in 5=9

3)ending in 0=8

One digit number=1

So total numbers=64+72+17+1=154

 0 votes -- Pooja ( 22773 points)

13.51 B. Math. 2005 top gateoverflow.in/41798

Let S = { (a 1 , a2 , a 3 ) | 0 ≤ a i ≤ 9 and a 1 + a 2 + a 3 is divisible by 3}. Then the number of elements in S is

1. 327
2. 333
3. 334
4. 336

numerical-ability

All numbers b/w 000 to 999 which are divisible by 3. So, total 334 elements.

 1 votes -- Avdhesh Singh Rana ( 1509 points)

13.52 apitude top gateoverflow.in/41824

How many 4 digit no. can b formed wit digits 1, 2, 3,4,5 which r divisible by 4 and digits not repeated?

144 / 168 / 182 / none

Answer is 24.

Last 2 digits should be divisible by 4 for the number to be divisible by 4.Last two digits should be 12 or 32 or 52 or 24 and
corresponding to these 4 possibilities we can have 3*2=6 numbers in the starting two digits.

So total 4 digit numbers will be 6*4=24.

 5 votes -- Aditya Sharma ( 687 points)

13.52 What is the Remainder when 16^3 +17^3+18^3 +19^3 is devided by


70 top gateoverflow.in/9270


Selected Answer

use the formula x3+y3 =(x+y)(x2-xy+y2)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1605 of 2244

then group 173 and 183 and 163 and 193 in both the cases x+y gives 35 take 35 as common from the entire
expression the resultant expression within the bracket will be (16² - 16·19 + 19² + 17² - 17·18 + 18²)

the entire expression evaluates to be as even and hence the original expression is divisible by both 35 and 2
and hence by 70. So the resultant remainder is 0

 5 votes -- computer science research ( 255 points)

13.53 8 litres are drawn from a cask full of wine and is then filled with
water.... top gateoverflow.in/42210

8 litres are drawn from a cask full of wine and is then filled with water. This operation is performed three more times. The ratio of the quantity of wine now left in cask
to that of water is 16 : 65. How much wine did the cask hold originally?

A. 18 litres B. 24 litres

C. 32 litres D. 42 litres

Answer is C

Let initial quantity of wine =x litre

After a total of 4 operations, quantity of wine


y 8

x(1 − x )n => x(1 − x )4


Given that after a total of 4 operations, the ratio of the quantity of wine left in cask to that of water = 16:65
8

x(1 − x )4 16
x
= 81

8 2
x 4
(1 − ) = ( 3 )4
8 2

(1 − x ) = 3

x−8 2

( x )= 3

3x - 24 = 2x

x = 24

 1 votes -- vamsi2376 ( 1185 points)

13.54 Arihant Gate tutor 2014 top gateoverflow.in/39453

The traffic lights at three different road crossings change after every 50s,75s and 100s respectively.If they start changing
simultaneously at 10 am,after how much time will they change again simultaneously?(Ans:-5min)

For such questions, take LCM of all the numbers.

For this problem, it comes out to be 300(s) i.e. 5 minutes.

So, 300 seconds is the least interval after which they will change simultaneously; and they will continue to change
simultaneously in the interval of multiples of 300 seconds(5 minutes).

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1606 of 2244

 0 votes -- Gaurav Sharma ( 1383 points)

13.54 The odds in favour, of standing first of three students Amit, Vikas and
Vivek appearing at an examination are 1:2.2: 5 and 1 :7. respectively. What
is the probability that either of them' will stand firs t (assume that a tie for
the first place is not possible) top gateoverflow.in/9388

aptitude

The odds (in favor) of an event or a proposition is the ratio of the probability that the event will happen to the probability that the event will not happen

So, required probability = P(First person standing first) + P(Second person standing first) + P(Third person standing first)

= 1/(1+2) + 2/(2+5) + 1/(1+7)

= 1/3 + 2/7 + 1/8

= (56 + 48 + 21)/168

= 125/168

 1 votes -- Arjun Suresh ( 124125 points)

13.55 logarithms top gateoverflow.in/41132

2 pow 64 not 264

20 should be the correct answer.

To find the number of digits(not bits) in a number, say x, we need to find the ceiling of log base ten of x, that is

log10x .
Given log2 = 0.30103, it seems a bit incomplete as the base of logarithm is not mentioned.

However since 100.30103 ≈ 2, so it can be inferred that in log2 = 0.30103 the base of log should be 10.

Coming to the original question, the number of digits in 264 would be

 ( ) 
log10 264 = 64log102  = 64 × 0.30103 = 19.26592 = 20.

 1 votes -- Anurag Pandey ( 8183 points)

13.56 Series top gateoverflow.in/41391

what out odd one in series 7 , 8 , 18 , 57 , 228 , 1165 , 6996


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1607 of 2244

The answer is 228...it should be 232...

7*1+1=8

8*2+2=18

18*3+3=57

57*4+4=232....

 5 votes -- Nishu ( 433 points)

13.57 aptitude top gateoverflow.in/41826

There is a rectangular Garden whose length and width are 60m X 20m.There is a walkway of uniform width around garden.
Area of walkway is 516m^2. Find width of walkway

1/2/3/4


Selected Answer

Plz see the picture

 2 votes -- Rajesh Pradhan ( 463 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1608 of 2244

Let the width of the the walkway be x

Area of the outer rectangle will be (60+2*x) * (20+2*x)....(As length and width will get increased by 2*x)

Area of inner rectangle =60*20=1200

(60+2*x) * (20+2*x) -1200=516

(60+2*x) * (20+2*x) =1716

x2 + 40*x -129=0

Rejecting the negative value ,we get x=3

So answer is 3

 2 votes -- Aditya Sharma ( 687 points)

13.58 triangular numbers top gateoverflow.in/37144

Natural numbers like 1, 3 = 1 + 2, 6 = 1 + 2 + 3 etc are referred to as triangular numbers. In other words, a triangular
number is a natural number which is equal to the sum of all the preceding natural numbers. How many triangular numbers
exist if a set of first 2100 natural numbers is taken?

13.59 What are the values of "c"? top gateoverflow.in/30594

ABC is a 3 digit number.The sum of its digits is 8.If each of BA and BC are 2 digit numbers such that BA=BC-2,then the
number of values "C" can take?

aptitude

BA=BC-2

we can write this one as A+10B =C+10B -2

i.e A=C-2

sum of digits A+B+C=8 an A=C-2

possibilities

2 2 4

1 4 3

so C can take {3,4}

3 0 5 also satisfies those two conditions but BA and BC won't be 2 digit numbers as B=is 0

 1 votes -- pramod ( 2071 points)

13.60 Complete the series top gateoverflow.in/30242

Fill in the missing number in the series.

2 3 6 15 ______ 157.5 630

aptitude


Selected Answer

2 x 1.5 =3
3 x 2 = 6
6 x 2.5 =15
15 x 3 = 45 <- ans

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1609 of 2244

45 x 3.5 = 157.5 and so on, the multiplying series in increased by 0.5

 5 votes -- Shashank Chavan ( 2439 points)

2*1.5 = 3
3*2 = 6
6*2.5 = 15
15*3 = 45
45 * 3.5 = 157.5

So 45

 1 votes -- BhaveshSethi ( 141 points)

multiply the first number (2) by 1.5 then increasing the multiplier by 0.5 at each step.
2 x 1.5 = 3
3 x 2.0 = 6
6 x 2.5 = 15
15
x
3.0
=
45
45 x 3.5 = 157.5
157.5 x 4.0 = 630
Hence Answer is 45.

 1 votes -- Leen Sharma ( 2935 points)

13.61 How to solve this Logarithm division? top gateoverflow.in/19510

Hello folks, how to solve Log64/Log16 ( i.e. log 64 divided by log 16) what will be the value?

Kindly explain with the properties you used while solving.

Thanks!


Selected Answer

Assuming base as 2

log2 64 log2 26
log2 16 log2 24
=

=
4
{using property: logaam = m
3
2
=

Also, you don't even need to assume the base 2 for log. Remember the following property of logarithms:

logxa
logxb
= logba

So,

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1610 of 2244

logx64
logx16
= log1664

3
=
2
{ ∵ √163 = 163 / 2 = 64

 2 votes -- Pooja ( 22773 points)

13.62 General Apptitude top gateoverflow.in/31423


Selected Answer

Say, X liter whisky containing 60% alcohol

Y " " " 18% "

then ,(X+Y) " " " 25% "

According to the question,

60 X + 18 Y = 25(X+Y)

=>35 X = 7 Y

=> X/Y =1/5

Ans will be (C)

 0 votes -- srestha ( 11585 points)

13.63 Made Easy FLT Advanced 1 Q 10 top gateoverflow.in/31594

Q.10

Given and Q = a,b,c are positive integers. What is the number of ordered triplets ( a, b, c) such
that a + 2b + c ≤ 40?

aptitude test-series made-easy


Selected Answer

P=a/c+a/b+1

or, P=(ab+ac+bc)/bc.................(i)

Q=b/a+b/c+1

or, Q=(ab+ac+bc)/ac....................(ii)

from (i) and (ii)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1611 of 2244

P/Q =ac/bc =a/b =11

or, a=11b

if b=1 a=11

equation a + 2b + c ≤ 40

or, 11+2+c≤40

or,c≤27
So, C can get 27 values and for that 27 values we get 27 triplets

like(11,2,1),(11,2,2),...................(11,2,27)....................i

Now,when b=2 ,a=22

Now, C value can be upto 14, So 14 triplets.................ii

Now, b=3 then a=33 ,c can be 1 only

So,triplet (33,6,1).......................................................iii

Now,from i,ii,iii we get

27+14+1=42 triplets

 3 votes -- srestha ( 11585 points)

13.64 Made Easy Advanced FLT 1 Aptitude top gateoverflow.in/31566

Q.4

Three friends Mukesh, Rajesh and Chetan walk from point A to B which are the two ends of the diameter of a semi circular
park. Mukesh takes the shortest path along the diameter whereas Chetan takes the longest path which is along the
periphery and Rajesh walks along two straight lines AC and CB where C is a point on the periphery of the semi circular park
such that AC + CB is maximum possible length. If all three reach B simultaneously, then what is the ratio of speeds of
Mukesh, Rajesh and Chetan respectively?

2 : 2*root(2) : pi

2*root(2) : 2 : pi

root(2) * pi : pi : root(2)

pi : 2 * root(2) : 2

numerical-ability


Selected Answer

2: 2√ 2: π

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1612 of 2244

 2 votes -- Praveen Saini ( 34299 points)

13.65 Find the odd one from the following group: top gateoverflow.in/30238

Find the odd one from the following group:



W,E,K,O I,Q,W,A F,N,T,X N,V,B,D

(A) W,E,K,O
(B) I,Q,W,A

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1613 of 2244

(C) F,N,T,X
(D) N,V,B,D

aptitude


Selected Answer

First letter [after 7 letters] Second letter [after 5 letters] Third letter [after 3 letters] Fourth letter

option d). N,V,B,D is odd one.

[Note: I am assuming A starts again after Z]

 1 votes -- Praveen Saini ( 34299 points)

W,E,K,O I,Q,W,A F,N,T,X N,V,B,D


23,5,11,15 9,17,23,1 6,14,20,24 14,22,2,4 - Alphabetically ordered numbers
Diff:
8,6,4 8,6,4 8,6,4 8,6,2

N,V,B,D Is odd man out!

 1 votes -- Shashank Chavan ( 2439 points)

13.66 square and regular octagon top gateoverflow.in/20125

square and regular octagon has same perimeter..find ratio of area octagon to square...


Selected Answer

Let the lengths of the sides of square be b and the sides of octagon be a.

Given: 4b = 8a
 b = 2a

A regular octagon can be divided into 4 triangles and 1 square .

Area of the square within the octagon can be calculated as follows:

(2acos(22.5 ∘ ) ) × (2acos(22.5 ∘ ) )
= 4a2 cos2 (22.5 ∘ )

= 4a2 sin2 (67.5 ∘ )

1 − cos2x

= 2a2 (1 − cos(135 ∘ ) ) { sin2 x =


2

(
= 2 × a2 1 + sin(45 ∘ ) )
Area of the triangle can be calculated as follows:

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1614 of 2244


2
(acos(22.5 ∘ ) × asin(22.5 ∘ ) )
a2 sin(45 ∘ )
= 2
{sin2x = 2sinxcosx
a2 sin(45 ∘ )
2
=

Area of 4 triangles = 2 × a2 sin(45 ∘ )


∴ Area of the octagon = 2a2 + 2a2 √ 2

Ratio of area of octagon to area of square:

2a2 + 2a2 √ 2

= b2

2a2 + 2a2 √ 2

4a2
=

1 + √2

= 2

 0 votes -- Riya Roy ( 4767 points)

13.67 Made Easy FLT 5 Q7 top gateoverflow.in/29359

Three boxes labeled A, B and C have a total of 249 marbles. If 3 dozen marbles are transferred from box ‘ A’ to box ‘B’, box
‘B’ will have 5 times the number of marbles in box ‘ A’. Instead, if 21 marbles are transferred from box ‘ B’ to box ‘C’, the
number of marbles in box ‘B’ will be 1.5 times the number of marbles in box ‘ C’. How many marbles should be transferred
from box ‘A’ or ‘B’ so that the number of marbles in both ‘ A’ and ‘B’ is identical?

30 from box ‘A’ to box ‘B’


30 from box ‘B’ to box ‘A’
36 from box ‘A’ to box ‘B’
36 from box ‘B’ to box ‘A’

made-easy numerical-ability

Let x y z be no of marbles in box A B C

acc to ques we get following equations

x+y+z=249

y+36=5(x-36)

y-21=1.5(x+21)

solving this we get x=69 y=129 and z=51

now to have equal marbles in box A and B we transfer k marbles from B to A

129-k=69+k

2k=60

k=30

so ans is b

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1615 of 2244

 1 votes -- Pooja ( 22773 points)

13.68 aptitude top gateoverflow.in/27842

A man drives 25 km in city and then increases its speed by one fourth of its original and reaches its destination 40 mins
early..if he had done the same 10 km earlier it would have saved another 5 min...find total distance travelled by car?


Selected Answer

Let (x+25)Km is total distance , t hr is time to reach the destination with speed s km/h

so time = distance/time

(x+25)/s = t ---------------(i)

if after 25km he increase his speed by 1/4 of original ,i.e, with 1.25s km/h , he reach his destination 40 min early , i.e
40/60 hr early,i.e, he takes (t - 40/60) hrs

25/s + x/1.25s = t - 40/60 --------(ii)

if after 15km he increase his speed by 1/4 of original ,i.e, with 1.25s km/h , he reach his destination 45 min early , i.e
45/60 hr early, i.e, he takes (t - 45/40) hrs

15/s + (x+10)/1.25s = t - 45/60 -----(iii)

subtract (iii) from (ii)


10/s -10/1.25s = 5/60

s = 24 km/h

subtract (ii) from (i)

x/s - x/1.25s = 40/60

x = 10s/3 = (10 * 24)/3

x = 80 km

Total distance = x+ 25 km = 80 +25 km = 105 Km .


 2 votes -- Praveen Saini ( 34299 points)

13.69 Made Easy Question 10 FLT 5 top gateoverflow.in/29363

Q.10

Venkat earns Rs 18,00,000 per annum which is spent under various heads as under:
Food : 24%
Transportation and House rent : 19%
Clothing : 9%
Miscellaneous heads : 22%
Savings : 14%
Loan installment : Rs 18,000 per month.
If he cuts down his expenditure on food by 4.33% and his clothing expense is down by 4% and the entire saving thus
achieved is used to pay off his loan, then the increase in the monthly installment of loan that he can afford is Rs
______________ .

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1616 of 2244

made-easy numerical-ability numerical-answers

Rs 2098.8 should be the right answer.

Current food expenditure are 24% of the annual income, after reducing it by 4.33%, it will become
(100 −4.33 )

( 24 × 100
) % = 22.9608%.

(100 −4 )

Current clothing expenses 9% of the annual income, after reducing it by 4%, it will become 9 ×
( 100
) % = 8.64.

Thus total annual savings achieved by chopping Food & Clothing expenses = ((24 − 22.9608) + (9 − 8.64))% of Rs 18, 00, 000.

= 1.3992% of Rs 18, 00, 000.

= 25185.60 Rs

25185.60
12
So we can increase the monthly instalments by Rs or Rs 2098.8

 2 votes -- Anurag Pandey ( 8183 points)

13.70 Solve the problem top gateoverflow.in/20728

A boy sells apples for 12 cents each and pears for 7 cents each.Suppose the boy collected
$3.21.How many apples and pears did he sell?

$1 = 100 cents , so, $3.21 = 321 cents

Multiple Answers possible :

eg1: 4 apples , 39 pears

eg2: 11 apples, 27 pears

 0 votes -- Himanshu Agarwal ( 8861 points)

13.71 What can you deduce? top gateoverflow.in/30169

The monthly rainfall chart based on 50 years of rainfall in Agra is shown in the following figure. Which of the following are
true? (k percentile is the value such that k percent of the data fall below that value)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1617 of 2244

(i) On average, it rains more in July than in December


(ii) Every year, the amount of rainfall in August is more than that in January
(iii) July rainfall can be estimated with better confidence than February rainfall
(iv) In August, there is at least 500 mm of rainfall

(A) (i) and (ii) (B) (i) and (iii)


(C) (ii) and (iii) (D) (iii) and (iv)

aptitude

Yes (B) should be the right answer.

What any point (x, y) at the 95 percentile line denotes ?

In the month x, out of 50 years approx 47 - 48 year's rainfall is below y mm.

What any point (x, y) at the 5 percentile line denotes ?

In the month x, out of 50 years approx 2 - 3 years's rainfall is below y mm.

Logically 5 percentile curve must always lie below 95 percentile which actually is the case here.

(I) ON AVERAGE, it rains more in July than in December : It is a direct conclusion from the "Average" curve on the
graph.

Since July lies above in Average curve than December, it implies that on average, July is more rainy than December.

So it must be true.

(II) EVERY YEAR, the amount of rainfall in August is more than that in January : The plot gives no information
about the rainfall during individual years, it is a combined plot of 50 years.

Out of 50 years, there are 2 -3 years when the rainfall may drop to a very minimal value (say 0 mm) in August & in the
same year it is also possible that 100 mm Rain falls in January.

So the given information is insufficient to deduce this fact.

Hence false.

Above two deductions are strong enough to answer this question, as only option B is consistent with the conclusions
derived so far.

(III) July rainfall can be estimated with better confidence than February rainfall : It can be observed that the
difference between 95 percentile plot and 5 percentile plot at July is smaller than that at February (thin shaped graph at
July & thick at February).

It shows that for 90% of the data, variance in rainfall at February is higher than variance in rainfall at July.

It means that in July most of the times(90%) the rainfalls are densely spread around average rainfall, but in Feb they are
sparsely spread around the average rainfall.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1618 of 2244

Densely spread means less chances of committing errors during estimation.

So it should also be true.

(IV) In August there is AT LEAST 500 mm of rainfall : This is false, as the plot does not provides any information
about the minimum & maximum rainfall in any Month.There might be no rainfall (0 mm) during August in a particular
year.

 0 votes -- Anurag Pandey ( 8183 points)

13.72 What is the cost of production in Rs per tonne for a daily production of
100 tonnes? top gateoverflow.in/30165

A foundry has a fixed daily cost of Rs 50,000 whenever it operates and a variable cost of Rs 800Q, where Q is the daily
production in tonnes. What is the cost of production in Rs per tonne for a daily production of 100 tonnes?

gate-aptitude aptitude

total production cost = 50000 + 800Q


= 50000 + 800 × 100
= 130000

130000

this is a cost for 100 tonnes. So, per ton production cost = 100 = 1300

 1 votes -- Amar Vashishth ( 17865 points)

13.73 numerical aptitude top gateoverflow.in/17608

There are 1000 villages and 1000 salesmen. 1st salesman visits every village. 2nd salesman visits every 2nd village starting
from the second village. 3rd salesman visits every 3rd village starting from the third village. This process goes on till 1000th
salesman visits the 1000th village (i.e. last village). Which of the following villages is visited by maximum number of
salesman?

(a) 384 (b) 720

(c) 490 (d) 900

Correct answer is 840.

A village v is visited by salesman s if v is a multiple of s.

So a village which is visited by maximum number of salesman has largest number of multiples (between 1 and 1000).

We can find the required village by finding L.C.M. of first few numbers until it crosses 1000. We will stop when L.C.M. goes
beyond 1000. So required village will be largest L.C.M (or its multiple) of first few numbers which is just smaller than
1000.

L.C.M. of 1 is 1.

L.C.M. of 1,2 is 2.

L.C.M. of 1,2,3 is 6.

L.C.M. of 1,2,3,4 is 24.

L.C.M. of 1,2,3,4,5 is 120.

L.C.M. of 1,2,3,4,5,6 is 120.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1619 of 2244

L.C.M. of 1,2,3,4,5,6,7 is 840.

L.C.M. of 1,2,3,4,5,6,7,8 is 840.

We can't go beyond 840 because L.C.M. of 1,2,3,4,5,6,7,8,9 is 2520 which is beyond 1000.

So correct answer is 840. Here is the code to verify : http://ideone.com/nzaAzI

 1 votes -- Happy Mittal ( 9253 points)

if we solve using finding factor method i think it should 720 because salesman only visit a village if it divides completely
that village number according to question.

so 384 = 2^7 * 3 -> factors((7+1)*(1+1)=16)

720 = 2^4 * 3^2 * 5 factors((4+1)(2+1)(1+1)=30)

490 = 2 * 5 * 7^2 factors((1+1)(1+1)(2+1)=12)

900 = 2^2 * 3^2 * 5 ^2 factors((2+1)(2+1)(2+1)=27)

so 720 has highest no. of factors among all.

 1 votes -- Umang Raman ( 10379 points)

13.74 How to evaluate the below summation ? top gateoverflow.in/16757

2 i
∑∑
i j (1)

value of i and j must be initialized then only we can calcuate the result because iteration of inner loop depends upon the
outer loop.

if i and j=0 then the ans will be 6.

 0 votes -- Saurav Kumar Gupta ( 1455 points)

13.75 CisternPipes top gateoverflow.in/35140

A tank is filled by three pipes with uniform flow. The first two pipes operating simultaneously fill the tank in the same time
during which the tank is filled by the third pipe alone. The second pipe fills the tank 5 hours faster than the first pipe and 4
hours slower than the third pipe. The time required by the first pipe is:

A. 6 hours B. 10 hours
C. 15 hours D. 30 hours

numerical-ability


Selected Answer

Option c

Let A is 1st pipe B 2nd and C 3rd pipe

Let B can do work in x hr

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1620 of 2244

A can do work in x+5 hr

C can do work in x-4 hr

A can fill tank in 1 hr is 1/x+5 work

B can fill tank in 1 hr is 1/x work

A and B together can fill tank in 1 hr is (1/x) + 1/(x+5)

=(2x+5)/(x2+5x) work

A and B can together fill the tank in (x 2+5x)/(2x+5) hr

(which is equal to the time C cn fill the tank alone)

X-4= (x2+5x)/(2x+5)

By solving it x=10 hr

So A cn fill the tank in 10+5= 15 hr

 3 votes -- Khushboo Tak ( 1961 points)

13.76 permutation top gateoverflow.in/34908

consider a stack A with 4 elements a,b,c,d with a being top of the stack . satck B is empty . an element popped out of stack
A printed imidiatly or pushed to stack B. an entry popped out of stck B can only be printed . in tis arrangement how many
numbers of possible permutation will be there to print output?

i think 4! = 24 will be answer

 0 votes -- Khushboo Tak ( 1961 points)

13.77 How can two angles be 90 degree in a right angled triangle ? top gateoverflow.in/14654

If the ratio of sine of angles of a triangle is 1:1: sqrt(2) then the ratio of square of its greatest
side to sum of the squares of other two sides is ...

I am not getting that if sin A=1 then A =90 as well as sin B =1 then B =90 , so how can it be possible , a bit confused in this
,plz clarify this ...


Selected Answer

In the question, ratio of sine of angles is 1: 1: √ 2, not actual sine of angles.

Here just by looking, we can infer the three angles as 45, 45, 90 degrees (hence ratio of sine is 1:1: √ 2). It is a right
angled triangle, and so square of largest side is equal to sum of squares of other two sides, and so the ratio asked in
question is 1.

In general, you can find angles as follows : Given ratio of sine as 1:1: √ 2, let actual sine of angles be k, k, √ 2k.

Now in a triangle, A+B+C = 180 degrees i.e. A+B = 180-C

So sin(A + B) = sin(180 − c)

 sinAcosB + cosAsinB = sinC

 k 1 − k2 +
√ √1 − k2 ∗ k = √2k
 2 1 − k2 =
√ √2

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1621 of 2244

 4(1 − k2 ) = 2

1
√2
 k=

1 1
√2 √2
So sine of angles are , , 1, hence angles are 45, 45, 90 degrees.

 3 votes -- Happy Mittal ( 9253 points)

13.78 remainder=? top gateoverflow.in/35861

remainder=?

5625/7=?

5 mod 7 = 5

25 mod 7 = 4

125 mod 7 = 6

625 mod 7 = 2

3125 mod 7 = 3

15625 mod 7 = 1

If we take number pattern repeats like this { 5 4 6 3 2 1.........}

for 5^624 mod 7 = 1 so next number will be 5 which is 5^625

 2 votes -- Prabhanjan R ( 747 points)

125
5625 = 55 = 3125125

3125125 mod 7 = (3125 mod 7)125 = 3125 mod 7 = 35 mod 7


25
( ) ( )5
= (243 mod 7)25 = 525 mod 7 = 55 mod 7 = (3125 mod 7)5 = 35 mod 7 = 5.

 1 votes -- Arjun Suresh ( 124125 points)

13.79 and loss - apti question top gateoverflow.in/14160

A man purchases 11 articles @ 10rs per article and sells 10 articles @11 rs per article.Find The Overall Loss or Gain% ?

a)23%

b)21%

c)26%

d)20%

answer is B option but i want explanation for this type of GA questions .Thanks

numerical-ability

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1622 of 2244

Selected Answer

If we go by general questions like these, your question is slightly incorrect. It should be "11 articles at Rs. 10" (not per
article). Similarly "10 articles at Rs. 11" (not per article).

Now cost price of 1 article = Rs. 10/11

Selling price of 1 article = Rs. 11/10

So profit = 11/10 - 10/11 = 21/110.


21

( ) 110

10

profit% =
( ) ∗ 100 = 21%
11

For your exact question, the answer is simple, profit on one article = Rs. (11-10) = Re. 1

Profit % = 10 () ∗ 100 = 10%

In general, for these type of questions, find CP and SP of one item and find profit/loss accordingly.

 4 votes -- Happy Mittal ( 9253 points)

13.80 perfect square top gateoverflow.in/26882

1)If P+45 and P+136 are two perfect squares(P is integer) then how many value exist?

1)1 2)0 3)4 4)2

2)if n+50 and n+81 are two perfect squares fibd sum of digits of n


Selected Answer

P+45=x^2

=>P=x^2-45............i

P+136=y^2

=>P=y^2-136............ii

from i and ii we get

x^2-45=y^2-136

=>y^2-x^2=91

=>(y+x)(y-x)=13*7

So, y+x=13.............iii

and y-x=7...............iv

solving iii and iv we get

y=10, x=3

putting it in eqn. i

P=9-45=-36

So, 1 solution

Ans is 1)

Part 2

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1623 of 2244

n+50=x^2

n+81=y^2

X^2-50=y^2-81

y^2-x^2=31

y=16 x=15

n=225-50=175

So sum of digits=9

 2 votes -- srestha ( 11585 points)

13.81 aptitude top gateoverflow.in/34907

hariharan is fond of shopping , he took an amount of more than 10 and less than 20 rs, with aform of 1rs coins and 20 paisa
coins ...when he come back he had as many 1rs nots as many 20paisa coins and as many 20paisa coin as he originally had
one rupiee notes . total was reduced by two third thus he spent ?

Let x is the number of 1Rs notes and y is the number of 20 paisa coins.

The amount he,originally, had , x + (0.20)y

when he come back after shopping ,then he had, number of 1Rs notes is as many as 20 paisa coins he originally had, and
Number of 20 paisa coins is as many as 1Rs notes, he originally had .

so amount now he has, y + (0.20)x

Total amount after shopping is reduced by 3 .

so y + (0.20)x = 3 (x + 0.20y)

3y + 0.6x = x + 0.2y

0.4x = 2.8y

x = 7y ------(1)

Hariharan originally took the amount for the shopping was greater than 10Rs and less than 20Rs

10 < x + (0.20)y < 20 ----(2)

From (1) and (2) ,we get x = 14, y = 2

So, Total amount, he originally had, x + 0.20y = 14.4

Amount left after shopping , y + 0.20x = 4.8

Amount He spent = Rs 9.6

 2 votes -- Praveen Saini ( 34299 points)

13.82 aptitude-tank top gateoverflow.in/34507

It takes 30 min to empty a half full tank by draining it at constant rate. It is decided to simultaneously pump water into the
half full tank while draining it. What is the rate at which water should be pumped so that it gets full in 10 minutes?

A. 4 times draining rate

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1624 of 2244

B. 3 times draining rate


C. 2.5 times draining rate
D. 2 times draining rate

numerical-ability


Selected Answer

Let x is the length of Tank.

Rate of doing tank empty, by draining, is, say, Vd

it takes 30 min to do tank empty by draining when it is half filled , 2 distance, with rate Vd

x
2
x
30 2
Vd = or = 30Vd

Say Vu is the rate of filling tank

so Vu − Vd is rate of filling tank while its draining

It take 10min to fill , half filled tank ( 2 ) while it is draining .

(Vu − Vd ) × 10 = 2

10Vu − 10Vd = 30Vd

Vu = 4Vd

Rate of filling tank = 4 × Rate of doing it empty

 7 votes -- Praveen Saini ( 34299 points)

Let d be Draining Rate, p be Pumping Rate and L be the capacity of the tank.

L
30 × d = 2

L
2
(10 × p) − (10 × d) =

10 ⋅ (p − d) = 30 ⋅ d

p−d=3⋅d

p=4⋅d

Hence, option A is the correct answer.

 3 votes -- Pooja ( 22773 points)

13.83 minimum value top gateoverflow.in/4932

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1625 of 2244

1 1 1 1 1
a b c d
If a, b, c, d and e are positive real numbers, then the minimum value of (a + b + c + d + e)( + + + + e ) is

1. 25
2. 5
3. 125
4. Cannot be determined.

Its answer is A) 25, when all a,b,c,d and e are=1, in all other cases It will be greater than that. Try Hit and trial and option
elimination

 0 votes -- Prateeksha Keshari ( 1619 points)

13.84 the number of bit strings of length 8 that will either start with 1 or end
with 00 is? top gateoverflow.in/15898

the number of bit strings of length 8 that will either start with 1 or end with 00 is?

a) 32 b) 128 c) 160 d)192

string starting with 1 - 8 places 1 place fixed .7 places have 2 choices . 2^7=128

ending with 00- 8 places 2 fixed. =2^6=64

common strings will be there that have been counted twice are . starting with 1 and ending with 00. such number of
string will be .

fix 3 position rest have 2 choices=32

total = 128+64-32=160

 0 votes -- Ravi Singh ( 7303 points)

13.84 . The probability that two friends are born in the same month is_? (a)
1/6 (b) 1/12 (c) 1/144 (d) 1/24 top gateoverflow.in/15032


Selected Answer

Let us say that what is the probability that they are not born in same month?

A can be born in any of 12 months and B can be born in any of the remaining 11 months ⇒ Total possible cases = 12 x
11 = 132

Total Sample space with us : 12 x 12 = 144


132

⇒ The probability that they are not born in same month = 144

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1626 of 2244

132 12 1

⇒ The probability that they are born in the same month 1 − 144 = 144 ⇒ 12

Alternatively,

Let the first friend be born in any of the 12 months. For the second friend we have 12 cases and only 1 is favorable. So,
1

probability = 12 .

 1 votes -- CrimeMasterGoGo ( 2221 points)

B) 1/12

 1 votes -- Pranay Datta ( 6113 points)

13.84 In order to maintain the price line , a trader allows a discount of 10%
on the marked price of goods in his shop . however ,he still makes a gross
profit of 17% on the cost price .Find the profit percent he would have made
on the selling price had he sold at the marked price ? top gateoverflow.in/14738


Selected Answer

let the CP be 100

gain% =17%

gain = gain %/100 *100

=17/100*100

gain=17

Sp-Cp=gain

sp-100=17

SP=17+100

SP=117

discount= 10% of MP

let MP be x

10/100x=1/10x

discount
=1/10x

SP=MP-discount

117=x-1x/10

10x/10 - 1x/10=117

9x/10=117

9x=117*10

x=1170/9

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1627 of 2244

x=MP=130
MP-CP=difference between both

130-100= 30

convert the difference into percent

difference/CP*100

30/100*100

30%

therefore, the MP is 30% above the CP.

 0 votes -- ayeshan ( 91 points)

ans is 30% . let us suppose c.p.=100 so after discount he sold at 117 so that he gets 17% profit

now let us suppose x is the marked price so as per question

x-x/10=117=>x=130

now without discount profit would have been (130-100)*100/100=30%

 2 votes -- Sanjay Sharma ( 799 points)

13.85 Test Seires question top gateoverflow.in/34304

test-series numerical-ability


Selected Answer

I think 2 is correct answer ->

Logic ->

Break in set of 3, 3 and 2 coins.

Now compare two set of 3 coins each. Now if they are equal then throw them away & Compare remaining 2 coins with
each other. Then lighter one is correct.

In case if one set of 3 coins is lighter than other set, throw remaining 5 coins away.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1628 of 2244

Compare any two coins , if one of them is light that coin is defective. If both are equal coin we have not compared is light.

 5 votes -- Akash ( 26315 points)

13.86 How much percent more than the cost price should a shopkeeper mark
his goods ... top gateoverflow.in/14737

How much percent more than the cost price should a shopkeeper mark his goods, so that after allowing a discount of 12.5 he
should have a gain of 5 on his outlay?


Selected Answer

Suppose cost price is Rs. 100, then since he wants 5% profit, he should sell it at Rs. 105, but Rs. 105 is after applying
12.5% discount.

So after giving discount on some Rs. x, he should have Rs. 105. i.e.
12.5x

x − 100 = 105  x = 120

So he should mark the goods at Rs. 120 i.e. 20% more than cost price.

 3 votes -- Happy Mittal ( 9253 points)

13.87 Area of triangles top gateoverflow.in/37262

Triangles ABC and CDE have a common vertex C with side AB of triangle ABC being parallel to side DE of triangle CDE. If
length of side AB = 2 cm and length of side DE = 7 cm and perpendicular distance between sides AB and DE is 7.2 cm, then
find the sum of areas of triangle ABC and triangle CDE.

aptitude


Selected Answer

Proof ∆ABC ≂∆CDE (alternate angle and vertical angle are same ,so using AA property both are similar) therefore,

Area ∆ABC/Area ∆CDE =(AB/DE)^2 =(2/7)^2 ,Now we know that Area ∆ABC = 1/2 *h1*AB and Area ∆CDE = 1/2
*h2*DE where h1 and h2 are height of triangle ABC and CDE respectively

4/49 =(h1*2)/(h2*7) --> h1/h2 =2/7 Now h1+h2 =7.2 we get h1 = 1.6 and h2= 5.6 and sum of both triangle area
=21.2

 0 votes -- saurav04 ( 649 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1629 of 2244

14 Mathematical Logic top


14.1 Eigen Value: Eigen Vector top gateoverflow.in/31032

The linear operation L(x) is defined by the cross product L(x) = b × x, where b = [ 0 1 0 ]T and x = [ x1 x2 ]
x3 T are three
dimensional vectors. The 3 × 3 matrix M of this operation satisfies

[]
x1
L(x) = M x2
x3

Then the eigenvalues of M are

(A) 0, + 1, − 1
(B) 1, − 1, 1
(C) i, − i, 1
(D) i, − i, 0

how to solve this..??

eigen-value engineering-mathematics

14.2 Equivalence Classes: Consider these statements, of which the first three
are premises and the fourth is a valid conclusion. top gateoverflow.in/43437

“All hummingbirds are richly colored.”


“No large birds live on honey.”
“Birds that do not live on honey are dull in color.”
“Hummingbirds are small.”

Question is how do we know that what we should assume before converting such a problem using quantifiers. As they they
assumed in this solution like P(x), Q(x), R(x), ....are some statements..

Let P(x), Q(x), R(x), and S(x) be the statements “x is a hummingbird,” “x is large,” “x lives on
honey,” and “x is richly colored,”.

in my solution if i assume something else other then these and i get some different ans , so that ans would be right or wrong
.

mathematical-logic equivalence-classes

14.3 First Order Logic: Write first order expression for the following top gateoverflow.in/19451

1. God loves everyone.


2. Only believers respect God.
3. Frida is a non-believer.
4. To get love someone, one must respect that entity.

mathematical-logic first-order-logic

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1630 of 2244

LG(x) = God loves x

God loves everyone = ∀x LG(x)

B(x) = x is a believer
RG(x) = x respects God

Only believers respect God = (


∀x: RG(x)  B(x) )

B(x) = x is a believer

Frida is a non-believer = ¬B(Frida)

L(y, x) = y loves x
R(x, y) = x respects y

To get love from someone,


one must respect that entity
= (
∀y, x: L(y, x)  R(x, y) )

This question is so full of religious propaganda XD

 2 votes -- Pragy Agarwal ( 13675 points)

14.4 First Order Logic: ugc net 13 top gateoverflow.in/43111

Which of the following is a correct predicate logic statement for “Every Natural number has one successor” ?

(A) ∀x∃y (succ(x, y) ∧ (∃z succ(x, z) ⇒ equal (y, z)))

(B) ∀x∃y (succ(x, y) ∨ (∃z succ(x, z) ⇒ equal (y, z)))

(C) ∃y∀x (succ(x, y) ∧ (∃z succ(x, z) ⇒ equal (y, z)))

(D) ∀x∃y succ (x, y)

first-order-logic


Selected Answer

Successor of a number 'X' is that number which is very next to 'X'.

∀x∃y (succ(x, y) ∧ (∃z succ(x, z) ⇒ equal (y, z)))

 3 votes -- Digvijay Pandey ( 26245 points)

14.5 First Order Logic: Write these graph properties as first order expression
(assume graph is undirected) top gateoverflow.in/19577

1. The given graph is a clique (there is edge between every pair of vertices)

2. Every vertex has degree at least two (there is minimum two edges starting from every vertex )

first-order-logic


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1631 of 2244

There is an edge between


E(x, y) = the vertecies x and y
in the given graph

The given graph


G is a clique
= ∀x, y:
( x∈G
∧ y∈G
∧ x≠y
 E(x, y)
)
Every vertex in G
has degree ≥2
=
(
∀x x ∈ G  ∃v ∃w:
( E(x, v) ∧ E(x, w )
∧ x≠v ∧ x≠w
∧ v≠w ))
 2 votes -- Pragy Agarwal ( 13675 points)

14.6 First Order Logic: Propositional logic top gateoverflow.in/32319

which one is not tautology?

1.((p v q)^(r v s)) -> ((p^r) v q vs)

2. ((p v q)^(r v s)) -> (q v s)

3.((p v q)^(r v s)) -> (r v q v s)

4.((p v q)^(r v s)) -> (p v q v s)

5.((p v q)^(r v s)) -> (p v q)

please tell how to approach this types of qs,this type of qs came many times in gate.I tried it by making table,but it is not
doable..so,help me.

mathematical-logic first-order-logic


Selected Answer

You can do that even without picking pen with the help of boolean algebra

Note: p → q = pˉ or q = pˉ + q

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1632 of 2244

 5 votes -- Praveen Saini ( 34299 points)

Simple Trick to solve such questions without anything......

See Try to prove that the given option is not tautology by making T--->F i.e., Try to make LHS of Implication True and
RHS be False...

Opt a)

((p v q)^(r v s)) -> ((p^r) v q vs)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1633 of 2244

See LHS can be true only when and is true

p V q can be true either q is true or p or both.

if q is made true then RHS also becomes true as q is there with Or

So if p is made true then r V s of LHS has to be true. ie. r or s has to be true to make LHS true. (so i take p to be true)

If s is made true then RHS also becomes true which we do not want as T-->T is True

if r is made true and since we had taken p as true as LHS then RHS also becomes true thus there is no scope that RHS
becomes False.thus it is tautology..

Now Opt b)

((p v q)^(r v s)) -> (q v s)


proceed as above.

Try to make LHS T and RHS F.

If q on LHS is made true then RHS becomes True which we do not want

So p has to be true in order to make LHS "and" True.

Now Either r or s has to be true so if we take s true then LHS becomes true and consequently RHS becomes true. but now we
put r as true it becomes that T--->F so it is not tautology...

So you can proceed with other options...With Practice it becomes clear


 1 votes -- Anirudh Pandey ( 343 points)

14.7 First Order Logic: First Order Logic Question: English to predicate gateoverflow.in/32926

top

2. Let S(x) be the predicate "x is a student," B(x) the predicate "x is a book, " and H(x,y) the predicate "x has y, " where the universe of discourse is the
universe, that is the set of all objects. Use quantifiers to express each of the following statements.

a) Every student has a book.

b) Some student does not have any book.

c) Some student has all the books.

d) Not every student has a book.

e) There is a book which every student has.

Answers:

a) x ( S(x) y ( B(y) H(x, y) ))

b) x ( S(x) y ( B(y) H(x, y) ))

c) x ( S(x) y ( B(y) H(x, y) ))

d) x ( S(x) y ( B(y) H(x, y) ))

e) x ( B(x) y ( S(y) H(x, y) ))

will someone explain briefly ? I tried my best to dechiper in to predicate, But failed.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1634 of 2244

mathematical-logic first-order-logic engineering-mathematics

This type of questions are somewhat tricky...Okk let starts with statment...

See every statement and see the beginning phrase properly..if it statemts with

1) Every or all = 2) There exist or Some = 3)Not every =

No focus on each question implication is used whenever there you have to ensure that there is no condition such that left
is true and rhs is false. and AND is used when both have to occur simultaneously...and note never assume anything out
of question...

a) Every student has a book.

Means there will not be any one who is student and will not have means if he is student he has to have book means if
Left(L) is true then that student have a book(Right Side ). Since there is "a book" means a single will do ur work. and
since u cannot assume so if he is not a student then he may or may not have book .Thus,implication..Since student is
main concern so x will be bound others..AND implies in right side that the object chosen y has be simultaneously a book
and student must possess it. and since "a book" so one book will do it so there exist.

x ( S(x) y ( B(y) H(x, y) ))

b) Some student does not have any book.

Or it can be read as there exist one student who does not have any book..Means You have to check entire book list and
has to ensure that this student must not have any(simulatenously means he is student and check entire list that he does
not have book).

x ( S(x) y ( B(y) H(x, y) ))

e) There is a book which every student has.

Or All student have some particular book.....and this particular book can be any so


x B(x). and simulatenously you have to check that every student must possess that book so AND.in RHS we have implication which means there should
be any student (Left=T) which do not have that book (Right=F)

x ( B(x) y ( S(y) H(x, y) ))....

Try other one you will get it.....

I hope i m clear

 0 votes -- Anirudh Pandey ( 343 points)

14.8 First Order Logic: logic top gateoverflow.in/15719

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1635 of 2244

mathematical-logic first-order-logic

14.9 First Order Logic: Logic top gateoverflow.in/37681

Which of the following are true?

∃x(P(x)->Q(x)) ->(∀xP(x)->∀xQ(x))

∃xP(x)->∀x Q(x) ->∀x(P(x)->Q(x))

first-order-logic mathematical-logic

HERE IS THE ANSWER:

1.∃x(P(x)->Q(x)) ->(∀xP(x)->∀xQ(x))
LHS:∃x(P(x)->Q(x))== ∃x(~P(x)vQ(x))

∃x~P(x)v∃xQ(x)

~∀xP(x)v∃xQ(x)which is ∀xP(x)->∃x
Q(x); HENCE FALSE
2.∃xP(x)->∀x Q(x) ->∀x(P(x)->Q(x))

LHS:∃xP(x)->∀x Q(x)==~∃xP(x)v∀x Q(x)

∀x(~P(x)v∀x Q(x)

∀x(~P(x)v Q(x) ) TAKING ∀x common

∀x(P(x)->Q(x)):HENCE TRUE

 5 votes -- Deepesh Kataria ( 1207 points)

14.10 First Order Logic: Logic top gateoverflow.in/26745

How to approach the question where , 2 premises are given and conclusion is asked, what i know is that i can check whether
it will be a valid. ?

there will be flood.

if it is raining for long , there will be flood .

what will be conclusion of both the premises. ??

mathematical-logic first-order-logic


Selected Answer

You can not conclude here anything . This is fallacy of affirming the conclusion.

there will be flood. -> Lets say we write it as F

if it is raining for long -> R

if it is raining for long , there will be flood .-> R->F

Now we have

R->F

We can not conlude anything here. As we are affirming conclusion here, but it does not derive anything.

So we can say from above Two statements, " there will be flood." Same statement given to else, Nothing more.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1636 of 2244

More Info->

See you have statement p->q

Then if you say q is true.

p->q,q => This is fallacy of affirming the conclusion.You can not derive here.

Also this is called fallacy of converse. i.e. If you derive p, then it is because you are assuming q-> p, which is incorrect.

Second one ->

p->q,~p => Fallacy of denying the hypothesis, You can not derive anything here..

If you try to derive ~q, then you are saying that ~p->~q, which is incorrect. It is also called fallacy of inverse.

 3 votes -- Akash ( 26315 points)

(there will be flood ) AND (it is not raining for long OR there will be flood )

===>> there will be flood.

 2 votes -- Digvijay Pandey ( 26245 points)

14.11 First Order Logic: Made Easy top gateoverflow.in/37967

Match the following Lists

List-I

A. There are atmost two apples.

B. There are exactly two apples.

C. There is atmost one apple.

D. There is exactly one apple.

List-II

1. ∀x∀y∀z((Apple(x) ∧ Apple(y) ∧ Apple(z)) → (x = y ∨ x = z ∨ y = z))

2. ∀x∀y((Apple(x) ∧ Apple(y)) → (x = y ∨ y = x))

3. ∃x∃y(Apple(x) ∧ Apple(y) ∧ (x ≠ y) ∧ ∀z(Apple(z) → ((z = x) ∨ (z = y))))

4. ∃x(Apple(x) ∧ ∀y(Apple(y) → (x = y)))

Codes:

A B C D

(a) 1 2 3 4

(b) 3 2 1 4

(c) 1 3 2 4

(d) 3 1 2 4

a. a
b. b
c. c
d. d

made-easy test-series first-order-logic

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1637 of 2244


Selected Answer

option C should be the correct answer.

Apple(p): p is an apple.

1) For all x, y & z, if (x is an apple and y is an apple and z is an apple), then (either x is same as y or x is same as z or y is
same as z).It means we have at most 2 apples.

2) For all x & y if (x is an apple and y is an apple) then (either x is same as y or y is same as x).It means we have at most
1 apple. here x & y need not to apple always but "if" both of them are apples then they are same apples, it says that we
may or may not have apples but if we have then we can not have more than 1 apple.

3) There exists an x & y such that x is an apple and y is an apple and x & y are different apples and for every z if z is an
apple then either z is same as x or z is same as y.It means we have exactly 2 apples.

4) There exists an x such that x is an apple and for every y if y is an apple then x & y are same. It means we have exactly
1 apple.

 4 votes -- radha gogia ( 4369 points)

14.12 Groups: Comment on (R,*) group / commutative / monoid top gateoverflow.in/7297

Which of the following true about (R,*)?

1) Group but not commutative

2) A commutative group

3) Not a semigroup

4) Not a monoid

groups


Selected Answer

Its a monoid.
Closure, associativity, Identity are defined for Real numbers.But inverse is not defined as R can be zero also. So (R,*) is
neither Group nor Abelian(commutative), but Monoid.

 3 votes -- GateMaster Prime ( 1263 points)

14.13 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-22 top gateoverflow.in/42734

Write each of these statements in the form “if p, then q” in English. [Hint: Refer to the list of common ways to express
conditional statements.]

A. It is necessary to wash the boss’s car to get promoted.


B. Winds from the south imply a spring thaw.
C. A sufficient condition for the warranty to be good is that you bought the computer less than a year ago.
D. Willy gets caught whenever he cheats.
E. You can access the website only if you pay a subscription fee.
F. Getting elected follows from knowing the right people.
G. Carol gets seasick whenever she is on a boat.

kenneth-rosen mathematical-logic

14.14 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-21 top gateoverflow.in/42732

For each of these sentences, state what the sentence means if the logical connective or is an inclusive or (that is, a
disjunction) versus an exclusive or. Which of these meanings of or do you think is intended?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1638 of 2244

A. To take discrete mathematics, you must have taken calculus or a course in computer science.
B. When you buy a new car fromAcme Motor Company, you get $2000 back in cash or a 2% car loan.
C. Dinner for two includes two items from column A orthree items from column B.
D. School is closed if more than 2 feet of snow falls or if the wind chill is below −100.

kenneth-rosen mathematical-logic

14.15 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-20 top gateoverflow.in/42731

For each of these sentences, determine whether an inclusive or, or an exclusive or, is intended. Explain your answer.

A. Experience with C++ or Java is required.


B. Lunch includes soup or salad.
C. To enter the country you need a passport or a voter registration card.
D. Publish or perish.

kenneth-rosen mathematical-logic descriptive


Selected Answer

Inclusive OR : A or B or Both
Exclusive OR : Either A or B but NOT both

a. Experience with C++ or Java is required : Inclusive OR


b. Lunch includes soup or salad : Inclusive OR
c. To enter the country you need a passport or a voter registration card : Inclusive OR
d. Publish or perish : Exclusive OR

 2 votes -- Digvijay Pandey ( 26245 points)

14.16 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-23 top gateoverflow.in/42739

Write each of these statements in the form “if p, then q” in English. [Hint: Refer to the list of common ways to express
conditional statements.]

A. It snows whenever the wind blows from the northeast.


B. The apple trees will bloom if it stays warm for a week.
C. That the Pistons win the championship implies that they beat the Lakers.
D. It is necessary to walk 8 miles to get to the top of Long’s Peak.
E. To get tenure as a professor, it is sufficient to be world-famous.
F. If you drive more than 400 miles, you will need to buy gasoline.
G. Your guarantee is good only if you bought your CD player less than 90 days ago.
H. Jan will go swimming unless the water is too cold.

mathematical-logic kenneth-rosen

A) If the wind blows from the northeast , then it snows

B) if it stays warm for a week , then the apple trees will bloom

C) if the Pistons beat the Lakers then they win the championship

D) if u get to the top of Long’s Peak then It is necessary to walk 8 miles

E) if u get tenure as a professor, then it is sufficient to be world-famous

F) If you drive more than 400 miles, then you will need to buy gasoline

G) if you bought your CD player less than 90 days ago , then only your guarantee is good

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1639 of 2244

H) if the water is too cold then Jan will not go swimming

 0 votes -- srestha ( 11585 points)

14.17 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-26 top gateoverflow.in/42742

Write each of these propositions in the form “p if and only if q” in English.

A. For you to get an A in this course, it is necessary and sufficient that you learn how to solve discrete mathematics
problems.
B. If you read the newspaper every day, you will be informed, and conversely.
C. It rains if it is a weekend day, and it is a weekend day if it rains.
D. You can see the wizard only if the wizard is not in, and the wizard is not in only if you can see him.

kenneth-rosen mathematical-logic descriptive


Selected Answer

They are saying represent in "P if and only if Q" form. Actually double implications are commutative so "P if and only if Q"
is same as "Q if and only if P".

A. You get an A in this course if and only if you learn how to solve discrete mathematics problems.
B. You will be informed if and only if you read the newspaper every day.
C. It rains if and only it is a weekend day.
D. You can see the wizard if and only if he is not in.

 2 votes -- Digvijay Pandey ( 26245 points)

14.18 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-28 top gateoverflow.in/42744

State the converse, contrapositive, and inverse of each of these conditional statements.

A. If it snows tonight, then I will stay at home.


B. I go to the beach whenever it is a sunny summer day.
C. When I stay up late, it is necessary that I sleep until noon.

kenneth-rosen mathematical-logic

1.If it snows tonight, then I will stay at home.

converse =If I will stay at home then it snows tonight.

contrapositive, =If I will not stay at home then it not snows tonight.

inverse =If it not snows tonight, then I will not stay at home.

2.I go to the beach whenever it is a sunny summer day.

converse = It is a sunny summer day whenever I go to the beach.

contrapositive, =it is not a sunny summer day whenever I did not go to the beach.

inverse =I did not go to the beach whenever it is not a sunny summer day.

 0 votes -- Anirudh Pratap Singh ( 4091 points)

14.19 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-29 top gateoverflow.in/42745

How many rows appear in a truth table for each of these compound propositions?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1640 of 2244

A. p → ¬p
B. (p ∨ ¬r) ∧ (q ∨ ¬s)
C. q ∨ p ∨ ¬s ∨ ¬r ∨ ¬t ∨ u
D. (p ∧ r ∧ t) ↔ (q ∧ t)

kenneth-rosen mathematical-logic

Number of rows = 2 n where n is number of variables

A. Only 1 variable so 2 rows


B. 4 variables so 16 rows
C. 6 variables so 64 rows
D. 4 variables so 16 rows

 0 votes -- shivanisrivarshini ( 2067 points)

14.20 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-27 top gateoverflow.in/42743

State the converse, contrapositive, and inverse of each of these conditional statements.

A. If it snows today, I will ski tomorrow.


B. I come to class whenever there is going to be a quiz.
C. A positive integer is a prime only if it has no divisors other than 1 and itself.

mathematical-logic kenneth-rosen

A. If it snows today, I will ski tomorrow.


B. converse =if I will ski tomorrow ,it snows today.
C. inverse=If it not snows today, I will not ski tomorrow.
D. contrapositive = if I will not ski tomorrow ,it not snows today.

Do same for other parts.

 0 votes -- Anirudh Pratap Singh ( 4091 points)

14.21 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-19 top gateoverflow.in/42729

For each of these sentences, determine whether an inclusive or, or an exclusive or, is intended. Explain your answer.

A. Coffee or tea comes with dinner.


B. A password must have at least three digits or be at least eight characters long.
C. The prerequisite for the course is a course in number theory or a course in cryptography.
D. You can pay using U.S. dollars or euros.

mathematical-logic kenneth-rosen descriptive


Selected Answer

Coffee or tea comes with dinner : Exclusive OR


A password must have at least three digits or be at least eight characters long : Inclusive OR
The prerequisite for the course is a course in number theory or a course in cryptography : Inclusive OR
You can pay using U.S. dollars or euros : Exclusive OR

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1641 of 2244

 2 votes -- Digvijay Pandey ( 26245 points)

14.22 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-25 top gateoverflow.in/42741

Write each of these propositions in the form “p if and only if q” in English.

A. If it is hot outside you buy an ice cream cone, and if you buy an ice cream cone it is hot outside.
B. For you to win the contest it is necessary and sufficient that you have the only winning ticket.
C. You get promoted only if you have connections, and you have connections only if you get promoted.
D. If you watch television your mind will decay, and conversely.
E. The trains run late on exactly those days when I take it.

kenneth-rosen mathematical-logic

A. You buy an ice cream cone if and only if it is hot outside

B. You win the contest if and only if you have the only winning ticket

C. You get promoted if and only if you have connections

D. Your mind will decay if and only if you watch television

E. The trains run late if and only if I take it

 1 votes -- shivanisrivarshini ( 2067 points)

14.23 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-24 top gateoverflow.in/42740

Write each of these statements in the form “if p, then q” in English. [Hint: Refer to the list of common ways to express
conditional statements]

A. I will remember to send you the address only if you send me an e-mail message.
B. To be a citizen of this country, it is sufficient that you were born in the United States.
C. If you keep your textbook, it will be a useful reference in your future courses.
D. The Red Wings will win the Stanley Cup if their goalie plays well.
E. That you get the job implies that you had the best credentials.
F. The beach erodes whenever there is a storm.
G. It is necessary to have a valid password to log on to the server.
H. You will reach the summit unless you begin your climb too late.

kenneth-rosen mathematical-logic

14.24 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-15 top gateoverflow.in/42724

Let p, q, and r be the propositions


p : Grizzly bears have been seen in the area.
q : Hiking is safe on the trail.
r : Berries are ripe along the trail.
Write these propositions using p, q, and r and logical connectives (including negations).

A. Berries are ripe along the trail, but grizzly bears have not been seen in the area.
B. Grizzly bears have not been seen in the area and hiking on the trail is safe, but berries are ripe along the trail.
C. If berries are ripe along the trail, hiking is safe if and only if grizzly bears have not been seen in the area.
D. It is not safe to hike on the trail, but grizzly bears have not been seen in the area and the berries along the trail are
ripe.
E. For hiking on the trail to be safe, it is necessary but not sufficient that berries not be ripe along the trail and for grizzly
bears not to have been seen in the area.
F. Hiking is not safe on the trail whenever grizzly bears have been seen in the area and berries are ripe along the trail.

kenneth-rosen mathematical-logic

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1642 of 2244

14.25 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-6 top gateoverflow.in/42630

Suppose that SmartphoneA has 256 MB RAM and 32 GB ROM, and the resolution of its camera is 8 MP; Smartphone B has
288 MB RAM and 64 GB ROM, and the resolution of its camera is 4 MP; and Smartphone C has 128 MB RAM and 32 GB ROM,
and the resolution of its camera is 5 MP. Determine the truth value of each of these propositions.

A. Smartphone B has the most RAM of these three smartphones.


B. Smartphone C has more ROM or a higher resolution camera than Smartphone B.
C. Smartphone B has more RAM, more ROM, and a higher resolution camera than Smartphone A.
D. If Smartphone B has more RAM and more ROM than Smartphone C, then it also has a higher resolution camera.
E. Smartphone A has more RAM than Smartphone B if and only if Smartphone B has more RAM than Smartphone A.

mathematical-logic kenneth-rosen

A. Smartphone B has the most RAM of these three smartphones. = true as smartphone B is 288 Mb most of among three.
B. Smartphone C has more ROM or a higher resolution camera than Smartphone B. =False since smartphone B has more
rom and camera resolution.
C. Smartphone B has more RAM, more ROM, and a higher resolution camera than Smartphone A. = False since resolution
of Smartphone A has more than Smartphone B.
D. If Smartphone B has more RAM and more ROM than Smartphone C, then it also has a higher resolution camera. =
False because Camera of Smartphone c has more i.e. 5MP.
E. Smartphone A has more RAM than Smartphone B if and only if Smartphone B has more RAM than Smartphone A.=
False since smartphone B always have more RAM than A . then it Smartphone B cant have less than smartphone A.

 0 votes -- Anirudh Pratap Singh ( 4091 points)

14.26 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-7 top gateoverflow.in/42631

Suppose that during the most recent fiscal year, the annual revenue of Acme Computer was 138 billion dollars and its net
profit was 8 billion dollars, the annual revenue of Nadir Software was 87 billion dollars and its net profit was 5 billion dollars,
and the annual revenue of Quixote Media was 111 billion dollars and its net profit was 13 billion dollars. Determine the truth
value of each ofthese propositions for the most recent fiscal year.

A. Quixote Media had the largest annual revenue.


B. Nadir Software had the lowest net profit and Acme Computer had the largest annual revenue.
C. Acme Computer had the largest net profit or Quixote Media had the largest net profit.
D. If Quixote Media had the smallest net profit, then Acme Computer had the largest annual revenue.
E. Nadir Software had the smallest net profit if and only if Acme Computer had the largest annual revenue.

kenneth-rosen mathematical-logic

A. Quixote Media had the largest annual revenue. = False since Acme Computer was 138 billion dollars.
B. Nadir Software had the lowest net profit and Acme Computer had the largest annual revenue.= True since Nadir
Software had the lowest net profit= 5bd lowest among three and Acme Computer was 138 billion dollars greatest among
three.
C. Acme Computer had the largest net profit or Quixote Media had the largest net profit. = False since Quixote Media net
profit was 13 billion dollars. one is true.
D. If Quixote Media had the smallest net profit, then Acme Computer had the largest annual revenue. true since Acme
Computer had the largest annual revenue = 138 true so p->q= q is true since Acme Computer had the largest annual
revenue = 138.
E. Nadir Software had the smallest net profit if and only if Acme Computer had the largest annual revenue. true b/c Nadir
Software had the smallest net profit = 5bd and Acme Computer had the largest annual revenue = 138 so both are true.

 0 votes -- Anirudh Pratap Singh ( 4091 points)

14.27 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-8 top gateoverflow.in/42636

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1643 of 2244

Let p and q be the propositions


p : I bought a lottery ticket this week.
q : I won the million dollar jackpot.
Express each of these propositions as an English sentence.

1. ¬p
2. p ∨ q
3. p → q
4. p ∧ q
5. p ↔ q
6. ¬p → ¬q
7. ¬p ∧ ¬q
8. ¬p ∨ (p ∧ q)

kenneth-rosen mathematical-logic

Not (I bought a lottery ticket this week) = I not bought a lottery ticket this week..

Either I bought a lottery ticket this week or won the million dollar jackpot or both.

If i bought a lottery ticket this week then I won the million dollar jackpot.

I bought a lottery ticket this week and won the million dollar jackpot.

I bought a lottery ticket this week if and only if I won the million dollar jackpot.

IF i not bought a lottery ticket this week then i not won the million dollar jackpot.

I not bought a lottery ticket this week and/ as well as not won the million dollar jackpot .

Either I not bought a lottery ticket this week or I bought a lottery ticket this week and won the million dollar jackpot .

 0 votes -- Anirudh Pratap Singh ( 4091 points)

14.28 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-5 top gateoverflow.in/42629

What is the negation of each of these propositions?

A. Steve has more than 100 GB free disk space on his laptop.
B. Zach blocks e-mails and texts from Jennifer.
C. 7 · 11 · 13 = 999.
D. Diane rode her bicycle 100 miles on Sunday.

mathematical-logic kenneth-rosen


Selected Answer

A. Steve has less than or equal to 100 GB free disk space on his laptop.
B. Zach allows e-mails or texts from Jennifer.
C. 7 . 11 . 13 ≠ 999
D. Diane did not ride her bicycle 100 miles on Sunday.

 1 votes -- Anirudh Pratap Singh ( 4091 points)

14.29 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-4 top gateoverflow.in/42628

What is the negation of each of these propositions?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1644 of 2244

A. Jennifer and Teja are friends.


B. There are 13 items in a baker’s dozen.
C. Abby sent more than 100 text messages every day.
D. 121 is a perfect square.

kenneth-rosen mathematical-logic

A. Jennifer or Teja are not friends.


B. There are not 13 items in a baker’s dozen.
C. Abby sent less than or equal 100 text messages every day.
D. 121 is not a perfect square.

 0 votes -- Anirudh Pratap Singh ( 4091 points)

14.30 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-1 top gateoverflow.in/42591

Which of these sentences are propositions? What are the truth values of those that are propositions?

1. Boston is the capital of Massachusetts.


2. Miami is the capital of Florida.
3. 2 + 3 = 5.
4. 5 + 7 = 10.
5. x + 2 = 11.
6. Answer this question

kenneth-rosen mathematical-logic


Selected Answer

First Lets talk about the definition of the Proposition first,

"Proposition is a declarative statement, which has true or false value".

So, Statement should be declarative, not command or request etc. For example If I say " New Delhi is capital of
India". Here I am declaring that New Delhi is Capital of India, Hence it is proposition. But the statement like " Please
give me a glass of water." or "Don't use Gate Overflow unless and until you have completed with your
chapters". Here one is request and second one is command hence they are not proposition. However we can say that
"Every proposition is a statement but every statement is not proposition".

Now come to the questions:

1. Boston is the capital of Massachusetts. => (Proposition, Declarative statement)


2. Miami is the capital of Florida. => (Proposition, Declarative statement)
3. 2 + 3 = 5.
=> (Proposition, Declarative statement)
4. 5 + 7 = 10.
=> (Proposition, Declarative statement)
5. x + 2 = 11. => (Its a declarative statement but its is not a proposition, because the truth value
depend on the value of variable x, if value of variable x is equal to 9 then it will be true else it will be false. Its basically a
First Order Logic.)
6. Answer this question => (Not a Proposition, Because its a command)

 4 votes -- Rude Maverick ( 3063 points)

14.31 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-2 top gateoverflow.in/42626

Which of these are propositions?What are the truth values of those that are propositions?

A. Do not pass go.


B. What time is it?
C. There are no black flies in Maine.
D. 4 + x = 5.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1645 of 2244

E. The moon is made of green cheese.


F. 2n ≥ 100

kenneth-rosen mathematical-logic

A. Do not pass go. => not a proposition. why? because its an order.

B. What is the time? => not a proposition. Why ? because its a question.

C. There are no black files is the main. => a proposition. why? It can have truth value either true or false.

D. 4+x=5 => Not a proposition. Why? because its truth value depends on 'x'.

E. The moon is made of green cheese. => a proposition. Why? because, Its truth value is false.

F. 2n > 100 => Not a proposition. Why? because, Its truth value depends on truth value depends on the value of
'n'.

 1 votes -- Lord_Krishna ( 665 points)

14.32 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-3 top gateoverflow.in/42627

What is the negation of each of these propositions?

A. Mei has an MP3 player.


B. There is no pollution in New Jersey.
C. 2 + 1 = 3.
D. The summer in Maine is hot and sunny.

mathematical-logic kenneth-rosen

The negations of the above statements are :

A. Mei has not an MP3 player.

B. There is pollution in New Jersey.

C. 2+1 ≠ 3

D. The summer in the maine is not hot or not sunny.

 0 votes -- Lord_Krishna ( 665 points)

14.33 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-9 top gateoverflow.in/42717

Let p and q be the propositions “Swimming at the New Jersey shore is allowed” and “Sharks have been spotted near the
shore,” respectively. Express each of these compound propositions as an English sentence.

A. ¬q
B. p ∧ q
C. ¬p ∨ q
D. p → ¬q
E. ¬q → p
F. ¬p → ¬q
G. p ↔ ¬q
H. ¬p ∧ (p ∨ ¬q)

kenneth-rosen mathematical-logic

Sharks have not been spotted near the shore.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1646 of 2244

Swimming at the New Jersey shore is allowed and Sharks have been spotted near the shore.

if swimming at the New Jersey shore is allowed then Sharks have been spotted near the shore.

if swimming at the New Jersey shore is allowed then Sharks have not been spotted near the shore.

Sharks have not been spotted near the shore or Swimming at the New Jersey shore is allowed.

 0 votes -- Anirudh Pratap Singh ( 4091 points)

14.34 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-10 top gateoverflow.in/42719

Let p and q be the propositions “The election is decided” and “The votes have been counted,” respectively. Express each of
these compound propositions as an English sentence.

A. ¬p
B. p ∨ q
C. ¬p ∧ q
D. q → p
E. ¬q → ¬p
F. ¬p → ¬q
G. p ↔ q
H. ¬q ∨ (¬p ∧ q)

mathematical-logic kenneth-rosen

14.35 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-30 top gateoverflow.in/42746

How many rows appear in a truth table for each of these compound propositions?

A. (q → ¬p) ∨ (¬p → ¬q)


B. (p ∨ ¬t) ∧ (p ∨ ¬s)
C. (p → r) ∨ (¬s → ¬t) ∨ (¬u → v)
D. (p ∧ r ∧ s) ∧ (q ∧ t) ∨ (r ∧ ¬t)

kenneth-rosen mathematical-logic

Number of rows = 2n where n is number of variables


A. 2 variables so 4 rows
B. 3 variables so 8 rows
C. 6 variables so 64 rows
D. 5 variables so 32 rows

 0 votes -- shivanisrivarshini ( 2067 points)

14.36 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-16 top gateoverflow.in/42726

Determine whether these biconditionals are true or false.

A. 2 + 2 = 4 if and only if 1 + 1 = 2.
B. 1 + 1 = 2 if and only if 2 + 3 = 4.
C. 1 + 1 = 3 if and only if monkeys can fly.
D. 0 > 1 if and only if 2 > 1

kenneth-rosen mathematical-logic

A. 2 + 2 = 4 if and only if 1 + 1 = 2. = T <->T= True.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1647 of 2244

B. 1 + 1 = 2 if and only if 2 + 3 = 4. = T<->F = False.


C. 1 + 1 = 3 if and only if monkeys can fly.= Not known
D. 0 > 1 if and only if 2 > 1 = F<->T= False

 1 votes -- Anirudh Pratap Singh ( 4091 points)

14.37 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-17 top gateoverflow.in/42727

Determine whether each of these conditional statements is true or false.

A. If 1 + 1 = 2, then 2 + 2 = 5.
B. If 1 + 1 = 3, then 2 + 2 = 4.
C. If 1 + 1 = 3, then 2 + 2 = 5.
D. If monkeys can fly, then 1 + 1 = 3.

mathematical-logic kenneth-rosen

1. If 1 + 1 = 2, then 2 + 2 = 5. false since T->F is False.

2. If 1 + 1 = 3, then 2 + 2 = 4. True since F->T is True.

3. If 1 + 1 = 3, then 2 + 2 = 5. True since F-> F id True.

4. If monkeys can fly, then 1 + 1 = 3. not known.

 0 votes -- Anirudh Pratap Singh ( 4091 points)

14.38 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-14 top gateoverflow.in/42723

Let p, q, and r be the propositions


p : You get an A on the final exam.
q : You do every exercise in this book.
r : You get an A in this class.
Write these propositions using p, q, and r and logical connectives (including negations).

A. You get an A in this class, but you do not do every exercise in this book.
B. You get an A on the final, you do every exercise in this book, and you get an A in this class.
C. To get an A in this class, it is necessary for you to get an A on the final.
D. You get an A on the final, but you don’t do every exercise in this book; nevertheless, you get an A in this class.
E. Getting an A on the final and doing every exercise in this book is sufficient for getting an A in this class.
F. You will get an A in this class if and only if you either do every exercise in this book or you get an A on the final.

kenneth-rosen mathematical-logic

14.39 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-13 top gateoverflow.in/42722

Let p and q be the propositions


p : You drive over 65 miles per hour.
q : You get a speeding ticket.
Write these propositions using p and q and logical connectives (including negations).

A. You do not drive over 65 miles per hour.


B. You drive over 65 miles per hour, but you do not get a speeding ticket.
C. You will get a speeding ticket if you drive over 65 miles per hour.
D. If you do not drive over 65 miles per hour, then you will not get a speeding ticket.
E. Driving over 65 miles per hour is sufficient for getting a speeding ticket.
F. You get a speeding ticket, but you do not drive over 65 miles per hour.
G. Whenever you get a speeding ticket, you are driving over 65 miles per hour.

kenneth-rosen mathematical-logic

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1648 of 2244

14.40 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-11 top gateoverflow.in/42720

Let p and q be the propositions


p : It is below freezing.
q : It is snowing.
Write these propositions using p and q and logical connectives (including negations).

A. It is below freezing and snowing.


B. It is below freezing but not snowing.
C. It is not below freezing and it is not snowing.
D. It is either snowing or below freezing (or both).
E. If it is below freezing, it is also snowing.
F. Either it is below freezing or it is snowing, but it is not snowing if it is below freezing.
G. That it is below freezing is necessary and sufficient for it to be snowing.

mathematical-logic kenneth-rosen

A. P ∧ Q
B. P ∧ ~Q
C. ~P ∧ ~Q
D. P ⊕ Q
E. P -> Q
F. (P V Q) ∧ ( P -> Q)
G. P <-> Q

 0 votes -- shivanisrivarshini ( 2067 points)

14.41 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-12 top gateoverflow.in/42721

Let p, q, and r be the propositions


p : You have the flu.
q : You miss the final examination.
r : You pass the course.
Express each of these propositions as an English sentence.

A. p → q
B. ¬q ↔ r
C. q → ¬r
D. p ∨ q ∨ r
E. (p → ¬r) ∨ (q → ¬r)
F. (p ∧ q) ∨ (¬q ∧ r)

kenneth-rosen mathematical-logic

a. If you have the flu then you will miss the final examination.
b. You will pass the course if and only if you don't miss the final examination.
c. If you miss the final examination then you will not pass the course.
d. You have the flu or you miss the final examination or you pass the course.
e. if you have the flu then you will not pass that course or if you miss the final examination then you will not pass that course.
f. If you have the flu and you miss the final examination or you don't miss the final examination and pass the course.

 0 votes -- Digvijay Pandey ( 26245 points)

14.42 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-18 top gateoverflow.in/42728

Determine whether each of these conditional statements is true or false.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1649 of 2244

A. If 1 + 1 = 3, then unicorns exist.


B. If 1 + 1 = 3, then dogs can fly.
C. If 1 + 1 = 2, then dogs can fly.
D. If 2 + 2 = 4, then 1 + 2 = 3

mathematical-logic kenneth-rosen


Selected Answer

P ----> Q is FALSE iff P is True and Q is False.


Check options,
A. 1+1= 3 : FALSE i.e. P is false here so no need to check Q. Statement is TRUE.
B. Same as option A.
C. 1+1= 2 : TRUE i.e. P is true so Check Q part i.e. "Dogs can fly" it is FALSE (i am taking CAN as usual). P is true Q is
false so Statement is also False.
D. Here P is True , Q is also True so Statement is also True.

 1 votes -- Digvijay Pandey ( 26245 points)

14.43 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-32 top gateoverflow.in/42749

Construct a truth table for each of these compound propositions.

A. p → ¬p
B. p ↔ ¬p
C. p ⊕ (p ∨ q)
D. (p ∧ q) → (p ∨ q)
E. (q → ¬p) ↔ (p ↔ q)
F. (p ↔ q) ⊕ (p ↔ ¬q)

kenneth-rosen mathematical-logic

http://web.stanford.edu/class/cs103/tools/truth-table-tool/

Generate any truth table.

 1 votes -- Anirudh Pratap Singh ( 4091 points)

14.44 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-43 top gateoverflow.in/42847

Find the bitwise OR, bitwise AND, and bitwise XOR of each of these pairs of bit strings.

A. 101 1110, 010 0001


B. 1111 0000, 1010 1010
C. 00 0111 0001, 10 0100 1000
D. 11 1111 1111, 00 0000 0000

kenneth-rosen mathematical-logic

14.45 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-44 top gateoverflow.in/42848

Evaluate each of these expressions.

A. 1 1000 ∧ (0 1011 ∨ 1 1011)


B. (0 1111 ∧ 1 0101) ∨ 0 1000
C. (0 1010 ⊕ 1 1011) ⊕ 0 1000
D. (1 1011 ∨ 0 1010) ∧ (1 0001 ∨ 1 1011)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1650 of 2244

mathematical-logic kenneth-rosen descriptive


Selected Answer

A.11000 ∧ 11011 => 11000


B.00101 V 01000 => 01101
C.10001 ⊕ 01000 => 11001
D.11011 ∧ 11011 => 11011

 0 votes -- shivanisrivarshini ( 2067 points)

14.46 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-42 top gateoverflow.in/42846

What is the value of x after each of these statements is encountered in a computer program, if x = 1 before the statement is
reached?

A. if x + 2 = 3 then x := x + 1
B. if (x + 1 = 3) OR (2x + 2 = 3) then x := x + 1
C. if (2x + 3 = 5) AND (3x + 4 = 7) then x := x + 1
D. if (x + 1 = 2) XOR (x + 2 = 3) then x := x + 1
E. if x < 2 then x := x + 1

mathematical-logic kenneth-rosen


Selected Answer

initailly

x=1

A. x+2=3 (true) => x=2

x=1

B. x+1=3 (false) or 2x+2=3 (false) =>x=1

x=1

C.2x+3=5 (true) and 3x+4=7 (true) => x=2

x=1

D. x+1=2(true) xor x+2=3 (true) =>x=1

x=1

E. x<2 (true) =>x=2

 1 votes -- shivanisrivarshini ( 2067 points)

14.47 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-41 top gateoverflow.in/42844

Explain, without using a truth table, why (p ∨ q ∨ r) ∧ (¬p ∨ ¬q ∨ ¬r) is true when at least one of p, q, and r is true and at least
one is false, but is false when all three variables have the same truth value.

kenneth-rosen mathematical-logic descriptive


Selected Answer

Now the statement is true only when both expressions in it are true.

Let's consider the first expression which is

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1651 of 2244


(p ∨ q ∨ r)

This is certainly true when any one of the three p,q,r is true.

Let's consider the second expression:

(¬p ∨ ¬q ∨ ¬r)


This is always true when any one of the p,q,r is false.

Thus combining above two, for the above statement to be true at least one of the p,q,r should be true and at least one
should be false.
QED

 1 votes -- tdk93 ( 151 points)

14.48 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-40 top gateoverflow.in/42843

Explain, without using a truth table, why(p ∨ ¬q) ∧ (q ∨ ¬r) ∧ (r ∨ ¬p) is true when p, q, and r have the same truth value and it is
false otherwise.

mathematical-logic kenneth-rosen descriptive

14.49 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-45 top gateoverflow.in/42849

Fuzzy logic is used in artificial intelligence. In fuzzy logic, a proposition has a truth value that is a number between 0 and 1,
inclusive.A proposition with a truth value of 0 is false and one with a truth value of 1 is true. Truth values that are between 0
and 1 indicate varying degrees of truth. For instance, the truth value 0.8 can be assigned to the statement “Fred is happy,”
because Fred is happy most of the time, and the truth value 0.4 can be assigned to the statement “John is happy,” because
John is happy slightly less than half the time. Use these truthvalues to solve below Exercises.

1. The truth value of the negation of a proposition in fuzzy logic is 1 minus the truth value of the proposition. What are the
truth values of the statements “Fred is not happy” and “John is not happy?”

mathematical-logic kenneth-rosen descriptive

Since Fred is happy truth value is 0.8 it means that Fred is unhappy truth value become 0.2

John is happy truth value 0.4 it means that John is unhappy truth value becomes 0.6

 0 votes -- shivanisrivarshini ( 2067 points)

14.50 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-31 top gateoverflow.in/42747

Construct a truth table for each of these compound propositions.

A. p ∧ ¬p
B. p ∨ ¬p
C. (p ∨ ¬q) → q
D. (p ∨ q) → (p ∧ q)
E. (p → q) ↔ (¬q → ¬p)
F. (p → q) → (q → p)

kenneth-rosen mathematical-logic

http://web.stanford.edu/class/cs103/tools/truth-table-tool/

Simple truth table generator.

 0 votes -- Anirudh Pratap Singh ( 4091 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1652 of 2244

14.51 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-50 top gateoverflow.in/42913

Fuzzy logic is used in artificial intelligence. In fuzzy logic, a proposition has a truth value that is a number between 0 and 1,
inclusive.A proposition with a truth value of 0 is false and one with a truth value of 1 is true. Truth values that are between 0
and 1 indicate varying degrees of truth. For instance, the truth value 0.8 can be assigned to the statement “Fred is happy,”
because Fred is happy most of the time, and the truth value 0.4 can be assigned to the statement “John is happy,” because
John is happy slightly less than half the time. Use these truthvalues to solve below Exercises.

An ancient Sicilian legend says that the barber in a remote town who can be reached only by traveling a dangerous mountain
road shaves those people, and only those people, who do not shave themselves. Can there be such a barber?

mathematical-logic kenneth-rosen descriptive

14.52 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-49 top gateoverflow.in/42912

Fuzzy logic is used in artificial intelligence. In fuzzy logic, a proposition has a truth value that is a number between 0 and 1,
inclusive.A proposition with a truth value of 0 is false and one with a truth value of 1 is true. Truth values that are between 0
and 1 indicate varying degrees of truth. For instance, the truth value 0.8 can be assigned to the statement “Fred is happy,”
because Fred is happy most of the time, and the truth value 0.4 can be assigned to the statement “John is happy,” because
John is happy slightly less than half the time. Use these truthvalues to solve below exercise.

The nth statement in a list of 100 statements is “Exactly n of the statements in this list are false.”

a. What conclusions can you draw from these statements?


b. Answer part (a) if the nth statement is “At least n of the statements in this list are false.”
c. Answer part (b) assuming that the list contains 99 statements

kenneth-rosen mathematical-logic descriptive difficult

14.53 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-48 top gateoverflow.in/42911

Fuzzy logic is used in artificial intelligence. In fuzzy logic, a proposition has a truth value that is a number between 0 and 1,
inclusive.A proposition with a truth value of 0 is false and one with a truth value of 1 is true. Truth values that are between 0
and 1 indicate varying degrees of truth. For instance, the truth value 0.8 can be assigned to the statement “Fred is happy,”
because Fred is happy most of the time, and the truth value 0.4 can be assigned to the statement “John is happy,” because
John is happy slightly less than half the time. Use these truthvalues to solve below exercise.

Is the assertion “This statement is false” a proposition?

mathematical-logic kenneth-rosen descriptive difficult

14.54 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-47 top gateoverflow.in/42910

Fuzzy logic is used in artificial intelligence. In fuzzy logic, a proposition has a truth value that is a number between 0 and 1,
inclusive.A proposition with a truth value of 0 is false and one with a truth value of 1 is true. Truth values that are between 0
and 1 indicate varying degrees of truth. For instance, the truth value 0.8 can be assigned to the statement “Fred is happy,”
because Fred is happy most of the time, and the truth value 0.4 can be assigned to the statement “John is happy,” because
John is happy slightly less than half the time. Use these truthvalues to solve below exercise.

The truth value of the disjunction of two propositions in fuzzy logic is the maximum of the truth values of the two
propositions. What are the truth values of the statements “Fred is happy, or John is happy” and “Fred is not happy, or John
is not happy?”

mathematical-logic kenneth-rosen descriptive

14.55 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-39 top gateoverflow.in/42842

Construct a truth table for (p ↔ q) ↔ (r ↔ s)

kenneth-rosen mathematical-logic descriptive

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1653 of 2244

14.56 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-46 top gateoverflow.in/42909

Fuzzy logic is used in artificial intelligence. In fuzzy logic, a proposition has a truth value that is a number between 0 and 1,
inclusive.A proposition with a truth value of 0 is false and one with a truth value of 1 is true. Truth values that are between 0
and 1 indicate varying degrees of truth. For instance, the truth value 0.8 can be assigned to the statement “Fred is happy,”
because Fred is happy most of the time, and the truth value 0.4 can be assigned to the statement “John is happy,” because
John is happy slightly less than half the time. Use these truthvalues to solve below exercise.

The truth value of the conjunction of two propositions in fuzzy logic is the minimum of the truth values of the two
propositions. What are the truth values of the statements “Fred and John are happy” and “Neither Fred nor John is happy?”

kenneth-rosen mathematical-logic descriptive

14.57 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-34 top gateoverflow.in/42836

Construct a truth table for each of these compound propositions.

A. p ⊕ p
B. p ⊕ ¬p
C. p ⊕ ¬q
D. ¬p ⊕ ¬q
E. (p ⊕ q) ∨ (p ⊕ ¬q)
F. (p ⊕ q) ∧ (p ⊕ ¬q)

mathematical-logic kenneth-rosen

14.58 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-33 top gateoverflow.in/42834

Construct a truth table for each of these compound propositions.

A. (p ∨ q) → (p ⊕ q)
B. (p ⊕ q) → (p ∧ q)
C. (p ∨ q) ⊕ (p ∧ q)
D. (p ↔ q) ⊕ (¬p ↔ q)
E. (p ↔ q) ⊕ (¬p ↔ ¬r)
F. (p ⊕ q) → (p ⊕ ¬q)

kenneth-rosen mathematical-logic

14.59 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-38 top gateoverflow.in/42841

Construct a truth table for ((p → q) → r) → s

kenneth-rosen mathematical-logic

14.60 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-35 top gateoverflow.in/42837

Construct a truth table for each of these compound propositions.

A. p → ¬q
B. ¬p ↔ q
C. (p → q) ∨ (¬p → q)
D. (p → q) ∧ (¬p → q)
E. (p ↔ q) ∨ (¬p ↔ q)
F. (¬p ↔ ¬q) ↔ (p ↔ q)

mathematical-logic kenneth-rosen

14.61 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-36 top gateoverflow.in/42839

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1654 of 2244

Construct a truth table for each of these compound propositions.

A. (p ∨ q) ∨ r
B. (p ∨ q) ∧ r
C. (p ∧ q) ∨ r
D. (p ∧ q) ∧ r
E. (p ∨ q) ∧ ¬r
F. (p ∧ q) ∨ ¬r

kenneth-rosen mathematical-logic

14.62 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1 QueNo-37 top gateoverflow.in/42840

Construct a truth table for each of these compound propositions.

A. p → (¬q ∨ r)
B. ¬p → (q → r)
C. (p → q) ∨ (¬p → r)
D. (p → q) ∧ (¬p → r)
E. (p ↔ q) ∨ (¬q ↔ r)
F. (¬p ↔ ¬q) ↔ (q ↔ r)

mathematical-logic kenneth-rosen

14.63 Mathematical Logic Virtualgate: The proposition {[p → (q ∨ r)] ∧ (~q)}


→ (p → r) is top gateoverflow.in/39097

The proposition {[p → (q ∨ r)] ∧ (~q)} → (p → r) is

mathematical-logic-virtualgate


Selected Answer

[p → (q ∨ r)] ∧ (~q)} → (p → r)
= ((p' + q + r)q')' + p' + r
= (p'q' + rq')' + p' + r
= (p + q)(r' + q) + p' + r
= pr' + pq + qr' + q + p' + r
=pr' + (pq + qr' +q) + p' + r = (pr' + p') + q(p + r' +1) + r
= p' +r' + q + r
=p' + q + (r + r')
= p' + q + T
= TAUTOLOGY

 3 votes -- Digvijay Pandey ( 26245 points)

implication is false when lhs is true and rhs is false

so rhs p->r is false if p is true and r is false (we assume RHS is false)

coming to lhs it is conjunction of two terms

-q is true that means q is false

p->(q or r) p is true q and r are false so T->F is false

so lhs is false and false that gives false

F->F is true

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1655 of 2244

so it is tautology(bcoz if rhs is false lhs is also false )

 2 votes -- Pooja ( 22773 points)

14.64 Matrices: Determinant of matrix top gateoverflow.in/36491

What is the determinant of matrix 2A. determinant of matrix A is 3. and IT is 4 by 4 matrix?

linear-algebra matrices


Selected Answer

for a nxn matrix A, and any scalar α, det(αA) = α^n det(A).

so answer is 48

Reference https://www.physicsforums.com/threads/determinant-of-a-matrix-multiplied-by-a-scalar.194725/

 0 votes -- artiagrahari ( 113 points)

14.65 Matrices: linearalgebra top gateoverflow.in/39260

[ ]
2 3 4
if A = 3 −1 2 then rank of the matrix (A − AT) is _____
−1 4 5

(A) 1 (B) 2 (C) 3 (D) 0

matrices

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1656 of 2244

Since determinant of A-AT = 0 ie scaler

then rank == (order of the matrix - 1)

 0 votes -- Rajib Das Bhagat ( 23 points)

14.66 Probability: Probability top gateoverflow.in/42805

A die is thrown 3 times and sum of 3 number thrown is 15 . find the chance that first throw was a 4 ?

probability


Selected Answer

Possible combination for sum (15) = Permutations of {(6,6,3) (6,5,4) (5,5,5)}


Number of Combinations in which Sum is 15 = 3!/2! + 3! + 3!/3! = 10
Number of Combinations in which 4 at 1st place = 0 + 2 + 0 = 2
P(4 at 1st toss / Sum = 15) = 2/10 = 1/5

 3 votes -- Digvijay Pandey ( 26245 points)

14.67 Probability: Probability top gateoverflow.in/26654

A bag contain 3R and 5 B balls and second bag contain 6R and 4B balls . A ball is drawn from each bag . find the probability
that both are (i)red and (2) black.?

probability

14.68 Probability: Probability Head/Tails top gateoverflow.in/36436

probability engineering-mathematics


Selected Answer

Probability of A winning :

P(A) = Event of A getting head = 1/2

P(A) + P(A'B'A) + P(A'B'A'B'A) + ... ∝

1/2 + 1/2*1/2*1/2 + 1/2*1/2*1/2*1/2*1/2 + ........ ∝ = 2/3

Therefore for B's winning = 1/3 (1-2/3)

Answer A.

 2 votes -- Riya Roy ( 4767 points)

14.69 Probability: Probability top gateoverflow.in/35785

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1657 of 2244

Three people X,Y, and Z are contesting in an election and we assume that exactly one of them wins it. Suppose that X and Z
have the same chances of winning and Y has only half the chance of X or Z. The probability that either X or Y wins the
election is _____

probability

X + X + X/2 =1

so x= 2/5.

 0 votes -- Aryan ( 223 points)

14.70 Random Variable: random variables top gateoverflow.in/35643

suppose X and Y are random variables such that

E(X)=1 (Y)=2 V(X)=1 V(Y)=2 Cov(X,Y )=1

by using above values following expression are evaluated

E(X+2Y)=p

EXY)=q

Vat(X-2Y+1)=r

find pq+r

random-variable

IF X,Y are independent than Cov(X,Y) = 0 . Here its ≠ 0 . So we they are dependent .

E(X+2Y) = E(X) + 2E(Y) = 5 = p

Cov(X,Y) = E(XY) - E(X)E(Y) on solving E(XY) = 3 =q .

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1658 of 2244

Var(X - 2Y + 1) = Var(X) + 4Var(Y) + Var(1) + 2Cov(X,-2Y) + 2Cov(X,1) + 2C(Y,1) [Var[constant]= 0 ]

Cov(X,Y) = 0 if X , Y are independent . So Cov (X,1) = 0 , Cov(Y) =0 .

= Var(X) + 4Var(Y) -4Cov(X,Y) [ Cov(X,-Y) = -Cov(X,Y) ]

On putting the values we get r=5

Therefore pq+r = 20

 0 votes -- Riya Roy ( 4767 points)

14.71 Random Variable: Continuous random distribution top gateoverflow.in/19949

The continuous random variable X has pdf f(x)=x/2, 0<=x<=2. Two independent determinations of X are made. What is the
probability that both these determinations will be greater than one? If three independent determinations had been
made,what is the probability that exactly two of these are larger than one?

random-variable probability

14.72 Zebra Puzzle top gateoverflow.in/43419

14.73 How to do this top gateoverflow.in/43438

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1659 of 2244

1. Alice is telling the truth: This results in both Carlos and John being guilty. This is
a contradiction based on my assumption.
2. John is telling the truth: We can say that Diana did not do it because Carlos is lying, but that
means that Diana would be telling the truth. Since we are assuming it is in fact only John that is
telling the truth in this scenario, we have a contradiction.
3. Carlos is telling the truth. This results in both John and Diana being guilth. This is
acontradiction based on my assumption.
4. Diana is telling the truth. This means that John is the criminal.


 1 votes -- Shivam Dwivedi ( 55 points)
share

14.74 NPTEL Discrete Mathematics Video Lecture top gateoverflow.in/44045

From the GATE CSE site I got the list of recommended Video lectures to watch. In case of Discrete Mathematics, I have
downloaded the following NPTEL video playlist: https://www.youtube.com/playlist?list=PLbMVogVj5nJQ-
tIzyygzzLLxomzlbIiE4

I would like to know are they good? I mean if someone has already gone through this playlist (Since it is a new video series).
Is it worth the time? there are 41 videos. Discrete Maths course from ADuni has also been recommended and I am currently
downloading them and I will go through all the videos once I complete the first one.

Thank you for your time.

engineering-mathematics gate set-theory&algebra

NPTEL DISCRETE MATH BY K kritivasan is more than enough for GATE..

Do NOt watch all videos first to last.. it may consume much time...

STRATEGY:
At first go through kenneth rosen

then solve exercise and see where you are getting stucked......for those parts refer to the videos .. That's it

after that obviously read the book Trembley,Manohar

 1 votes -- Uddipto ( 535 points)

14.75 Knights , Knaves , spy top gateoverflow.in/43362

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1660 of 2244

14.76 Logical Equivalence top gateoverflow.in/42040

Does (P ⋁ Q) ⋀ (R ⋁ S) and (P ⋀ R) ⋁ (Q ⋀ S) are equivalent

and also can we write (P ⋀ R) ⋁ (Q ⋀ S) as (P ⋁ Q) ⋀ (R ⋁ S) ???

mathematical-logic

No. They both are not equivalent. (From Truth Table)

when P=0,Q=1,R=1,S=0 and P=1,Q=0,R=0,S=1 both will result in different values.

 2 votes -- vamsi2376 ( 1185 points)

14.77 First Order Logic top gateoverflow.in/43877

Is the argument is valid?

i) Babies are illogical.

ii) Nobody is despised who can manage a crocodile.

iii) Illogical people are despised.

---------------------------------------------

iv) Babies cannot manage crocodiles.

B(x) :- x is a baby.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1661 of 2244

I(x) :- x is illogical.

D(x):- x is despised.

M(x):- x can manages the crocodiles.

i) ⟇x [B(x) -> ~L(x)]

ii) ⟇x [~D(x) -> M(x)]

iii) ⟇x[I(x) -> D(x)]

iv) ⟇x[B(x) -> ~M(x)]

I had made above logic from the arguments given...but I am not able get correct result.

Tell me which logic I made is wrong?

I think 2 logic is not according to condition...we are given that M(x)->~D(x)....so how the statement can be made that....
Not despised ppl are all able to manage crocodile.????

 1 votes -- Deepesh Kataria ( 1207 points)

14.78 A detective top gateoverflow.in/43279

I think Ans should be both bulter and cook are lying

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1662 of 2244

 1 votes -- Manojk ( 3365 points)

14.79 For each of these sentences, determine whether an inclusive or, or an


exclusive or, is intended. Explain your answer. top gateoverflow.in/42781

a) Experience with C++ or Java is required.


b) Lunch includes soup or salad.
c) To enter the country you need a passport or a voter
registration card.
d) Publish or perish.

mathematical-logic

14.80 ugc net top gateoverflow.in/42778


Selected Answer

P(x) = Gora gets the job.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1663 of 2244

Q(x) = Gora works hard.

R(x) = Gora will be promoted.

S(x) = Gora will be happy

a) P(x) ^ Q(x) ==> R(x) ------------- (1)

R(x) ==> S(x). -------------- (2)

~S(x). -------------- (3)

Conclusion: ~P(x) v Q(x)

From (1) & (2),

P(x) ^ Q(x) ==> S(x). ----- (4) Hypothetical Syllogism

From (3) & (4),

~S(x) ^[P(x) ^ Q(x) ==> S(x)] gives ~[P(x) ^ Q(x)] --- (5) Modus Tollens

So finally, ~P(x) v ~Q(x). So option a is valid.

b) P(x) = Puneet is guilty.

Q(x) = Pankaj is telling truth.

~P(x) v Q(x) ---------- (1)

~Q(x) ------- (2)

Conclusion to be shown : ~P(x)

From (1) & (2)

~Q(x) ^ [~P(x) v Q(x)] gives ~P(x) using Disjunctive Syllogism.

So option b is valid.

c) P(x) = n is real number

Q(x) = n is greater than 1

R(x) = n square is greater than 1

P(x) ^ Q(x) ==> R(x) ------- (1)

R(x) ---- (2)

conclusion: Q(x)

No rule of inference exists to prove the conclusion. so option c is not valid.

Here only the statement c is invalid

 1 votes -- vamsi2376 ( 1185 points)

14.81 How to find Modular Arithmetic ? top gateoverflow.in/42940

(a) Compute (7*​11*​711*​777) mod 13 by modular arithmetic.


(b) Compute (666^77) mod 11.

Please tell me the procedure to solve such a question not just Answer .I know the answer.

computer-networks engineering-mathematics


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1664 of 2244

(i) 7*11*711*777%13

try to minimize individual number

=(7*11*9*10)%13 (here 711mod13=9 and 777mod 13=10)

=(77*90)%13

=(-1 * -1)%13

=1 Ans

do other in same try to minimize

 2 votes -- Manojk ( 3365 points)

14.82 Am I correct Please explain If Im wrong top gateoverflow.in/43272

How can this English sentence be translated into a logical expression?


“You cannot ride the roller coaster if you are under 4 feet tall unless you are older than 16
years old.”

It is conditional statement Q unless ~P so if P then Q

and conditional statement Q if P So if P then Q

Let

P: You are not older than 16

Q: You are under 4 feet tall

R: You cannot ride the roller coaster

P -> (Q->R) Am I wrong ??

let P:You are older than 16 years old


Q:You are under 4 feet tall
R:You can ride the roller coaster
As q if p means p=>q and unless means (^,NOT) so this can be represented in (Q^∼P)=>∼R.

 1 votes -- Nishant Arora ( 213 points)

14.83 How to solve These Kind of problems top gateoverflow.in/43305

since jasmine becomes unhappy is samir is there so these 2 can not be invited together

1) jasmine and kanti (both r happy) possible

2)jasmine and samir not possible

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1665 of 2244

3)kanti and samir not possible (as jasmine is not there which is a prerequisite for kanti)

4)all three not possible as jasmine will be unhappy with samir

5) jasmine alone is possible as there is not condition violation for jasmine

6)only samir or kanti not possible

so only no 1) and no 5) r possible

 0 votes -- Sanjay Sharma ( 799 points)

14.84 Knights and Knaves top gateoverflow.in/43361

This question made my head revolve 360 degree many times in the exam....:) :P

 2 votes -- saif ahmed ( 931 points)

14.85 Lattice vs. hasse diagram top gateoverflow.in/36696

can hasse diagram be Infinite?

can lattice be infinite?

Whats the difference b/w hasse digram and lattice?

Hasse diagram is representation of finite poset so it can't be infinite.

https://en.wikipedia.org/wiki/Hasse_diagram

and if for every subset of poset there exists a LUB and GLB it is a Lattice.

 0 votes -- Abhishekcs10 ( 1001 points)

14.86 logic top gateoverflow.in/12847

Translate each of these statements into logical expressions


using predicates, quantifiers, and logical connectives.
a) No one is perfect.
b) Not everyone is perfect.
c) All your friends are perfect.
d) At least one of your friends is perfect.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1666 of 2244

a) No one is perfect. == Not ( one is perfect) = ~ (∃x(px))= ∀x ~p(x)= Every one is imperfect.
b) Not everyone is perfect.== Not (everyone is perfect.)= ~( ∀x(px))=∃x ~p(x)= Atleast one is imperfect.
c) All your friends are perfect. == if there is a person who is your friend then he is perfect== ∀x( F(x)→P(x))
d) At least one of your friends is perfect. == There is a person who is your friend who is perfect.

∃x (F(x)∧P(x))

 1 votes -- Anirudh Pratap Singh ( 4091 points)

14.87 Express & form negation so that no negation is to the left of the
quantifier & express this negation in simple English top gateoverflow.in/14390

Express and form negation, so that no negation is to the left of the quantifier and express this negation in simple English.

“Every student in this class has taken exactly two math classes at this school.”

The given answer is:

"There is someone in the class such that for every two different math course, these are not the two & only two
math courses this person has taken".

Please explain how this answer is derived.

mathematical-logic


Selected Answer

( student
∀x : in class(x)  ∃a∃b :
( isMathClass( a ) ∧ isMathClass( b )
∧ Taken( x ,a ) ∧ Taken( x ,b ) ∧ ∀c :
( isMathClass( c )
∧ c≠a
∧ c≠b
 ¬Taken(x, c)
)))
Reads: For every student x in class, there exist math classes a and b such that x has taken a, and x has taken b, and for
any other math class c (c ≠ a, c ≠ b), x has not taken c.

To negate it, we put an negation sign at the start of the equation, and push it in.
When we push negation sign inwards:

1. Forall (∀) changes to Exists (∃).


2. Exists (∃) changes to Forall (∀) .
3. And ( ∧ ), Or ( ∨ ) change according to De-Morgan's law.
4. Implication (p  q) changes to (p ∧ ¬q)

So, Negating the above expression, we get:

( student
¬∀x : in class(x)  ∃a∃b :
( isMathClass( a ) ∧ isMathClass( b )
∧ Taken( x ,a ) ∧ Taken( x ,b ) ∧ ∀c :
( isMathClass( c )
∧ c≠a
∧ c≠b
 ¬Taken(x, c)
)))
Pushing the negation inwards, ¬∀x: (…) will become ∃x: ¬(…). Note that the negation moves inwards.

( student
∃x :¬ in class(x)  ∃a∃b :
( isMathClass( a ) ∧ isMathClass( b )
∧ Taken( x ,a ) ∧ Taken( x ,b ) ∧ ∀c :
( isMathClass( c )
∧ c≠a
∧ c≠b
 ¬Taken(x, c)
)))
Now, we have to negate everything inside those big brackets!

The first thing inside is an implication.


Our rules say that Implication (p  q) changes to (p ∧ ¬q).

So, we get:

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1667 of 2244

( student
∃x : in class(x) ∧ ¬∃a∃b :
( isMathClass( a ) ∧ isMathClass( b )
∧ Taken( x ,a ) ∧ Taken( x ,b ) ∧ ∀c :
( isMathClass( c )
∧ c≠a
∧ c≠b
 ¬Taken(x, c)
)))
Now, we encounter ¬∃a∃b(…)
We push to negation inwards twice like this:

¬∃a∃b(…)
∀a¬∃b(…)
∀a∀b¬(…)

Overall, we get:

( student
∃x : in class(x) ∧ ∀a∀b :¬
( isMathClass( a ) ∧ isMathClass( b )
∧ Taken( x ,a ) ∧ Taken( x ,b ) ∧ ∀c :
( isMathClass( c )
∧ c≠a
∧ c≠b
 ¬Taken(x, c)
)))
Now we need to negate everything inside that second big brackets!
This time, we have a lot of ANDs.
So, we use the De-Morgan's law!

But hold on..


Notice this cool thing:

(
¬ abc x ≡ ) ¬ (( ) )
abc x ≡ ( )
¬ abc ∨ ¬x ≡ (abc)  ¬x

We can use this cool thing to quickly negate all those ANDs we have in the inner big bracket!

Heres what we get:

( student
∃x : in class(x) ∧ ∀a∀b :
( isMathClass( a ) ∧ isMathClass( b )
∧ Taken( x ,a ) ∧ Taken( x ,b )  ¬∀c :
( isMathClass( c )
∧ c≠a
∧ c≠b
 ¬Taken(x, c)
)))
Great, almost done!
Negating that ¬∀c (…) we will get ∃c ¬(…)
That is, we get:

( student
∃x : in class(x) ∧ ∀a∀b :
( isMathClass( a ) ∧ isMathClass( b )
∧ Taken( x ,a ) ∧ Taken( x ,b )  ∃c :¬
( isMathClass( c )
∧ c≠a
∧ c≠b
 ¬Taken(x, c)
)))
The last bracket now!
Remember what implications change to?
Implication (p  q) changes to (p ∧ ¬q).

So, we get:

( student
∃x : in class(x) ∧ ∀a∀b :
( isMathClass( a ) ∧ isMathClass( b )
∧ Taken( x ,a ) ∧ Taken( x ,b )  ∃c :
( isMathClass( c )
∧ c≠a
∧ c≠b
∧ ¬¬Taken(x, c)
)))
Notice that we now have two NOTs (¬¬) in a row!
We know that ¬¬p ≡ p
So, we can use that to finally get:

( student
∃x : in class(x) ∧ ∀a∀b :
( isMathClass( a ) ∧ isMathClass( b )
∧ Taken( x ,a ) ∧ Taken( x ,b )  ∃c :
( isMathClass( c )
∧ c≠a
∧ c≠b
∧ Taken(x, c)
)))
Now, lets take a step back and try to read what we just got.
It reads:

There is someone (x) in the class, such that for every two different math classes (a, b) that x has taken, there is atleast one
more math class c that x has taken!

Sounds familiar? yupe. Thats what you wanted explanation for!


There is someone in the class such that for every two different math course, these are not the two & only two math

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1668 of 2244

courses this person has taken

 4 votes -- Pragy Agarwal ( 13675 points)

14.88 logic top gateoverflow.in/15720


Selected Answer

The meaning of each option:

A: Every person z is mother of y and x is the father of z.

B: There exists a person z, y is mother of z and x is the father of y.

C: There exists a person z and z is the mother of y and x is the father of z. - the ANSWER

D: y is the mother of every person z and x is the father of y.

 2 votes -- Arjun Suresh ( 124125 points)

14.89 prositional logic top gateoverflow.in/12839

what is the difference BETWEEN "IF" and "ONLY IF" when we translate an english sentence into a logical expression???


Selected Answer

A if B is B implies A

A only if B is A implies B

A if and only if is A is equivalent to B

 3 votes -- komal07 ( 905 points)

14.90 Distribution of conjunction operator in for all clause , over two


predicates top gateoverflow.in/12126

Please explain the distribution of

for all x(P(x)^Q(x)) = (for all xP(x)) ^ (for all xQ(x))

with an example.

And also, why distribution over or doesn't work. Examples too. :)

Informal one only.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1669 of 2244

With conjunction LHS becomes stronger. It means for every x, both P(x) and Q(x) are true. So, it becomes equivalent to
RHS.

With disjunction LHS becomes weak. It means for every x, either P(x) or Q(x) is true. But RHS means for every x P(x) is
true, or for every x, Q(x) is true. Imagine saying all students in a class are either boy or girl. But, this doesn't mean all
are boys or all are girls.

 2 votes -- Arjun Suresh ( 124125 points)

here is the explanation.

 1 votes -- Anurag Pandey ( 8183 points)

14.91 kindly solve top gateoverflow.in/12017

Give a compound proposition


involving propositions p, q and r that is
true when exactly two of p, q and r are
true and is false otherwise.
(A) (pÚqÙ¬r) Ù (pÙ¬qÙr) Ù (¬pÙqÙr)
(B) (pÙqÙ¬r) Ù (pÚqÙ¬r) Ù (¬pÙqÙr)
(C) (pÙqÙ¬r) Ú (pÙ¬qÙr) Ù (¬pÙqÙr)
(D) (pÙqÙ¬r) Ú (pÙ¬qÙr) Ú (¬pÙqÙr)

(P⋂Q⋂R') -> P and Q are true and R is False [exactly two are true]

(P⋂Q'⋂R) -> P and R are true and Q is False [exactly two are true]

(P'⋂Q⋂R) -> Q and R are true and P is False [exactly two are true]

 1 votes -- Praveen Saini ( 34299 points)

14.92 y not b? top gateoverflow.in/12087

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1670 of 2244

The notation ∃!xP(x) denotes the proposition “there exists a unique x such that P(x) is true”.
Give the truth values of the following statements :

I. ∃!xP(x) → ∃xP(x)
II. ∃!x ¬P(x) → ¬∃xP(x)

(A) Both I & II are true.


(B) Both I & II are false.
(C) I – false, II – true
(D) I – true, II – false

mathematical-logic


Selected Answer

I: If there exists a unique x with P(x) true, then there exist an x with P(x) true. This is TRUE as exactly 1 is a subset of at
least one.

II: If there exists a unique x with P(x) false, then there does not exist an x with P(x) true. This is FALSE (contradiction) as
all except one x can are having P(x) true.

 6 votes -- Arjun Suresh ( 124125 points)

14.93 logic top gateoverflow.in/15721

A. for all person x der exist a job y or (let another) job z is not same as job y then x shouldn't has job z.

Let y!= z and x dont have any job then also A returns true.

B. Returns true if y!=z and x has both jobs y as well as z.

C. If z=y it will return false.

D. if z=y then ~J(x,z) otherwise no problem.

D is correct.

 1 votes -- Digvijay Pandey ( 26245 points)

14.94 Write equivalent first-order expression top gateoverflow.in/15964

All ripe mangoes are sweet.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1671 of 2244


Selected Answer

∀x(ripe(x) ∧ mangoes(x) ⇒ sweet(x))

 0 votes -- Sankaranarayanan P.N ( 7645 points)

14.95 Propositional Logic top gateoverflow.in/18679

Covert English sentence into logical expression

"You cannot ride the roller coaster if you are under 4 feet unless you are older than 16 years old "

mathematical-logic


Selected Answer

Let Q :you can ride roller coaster

R : you are under 4 ft tall

S: you are older than 16 years old

(R AND (NOT S))--> NOT (Q)

 1 votes -- priti sharma ( 637 points)

14.96 Logical Connectives top gateoverflow.in/18709

Let p : You can get A in final exam

q : You do every exercise in this book

r : You get an A in the class

Covert this sentence into logical connectives

a) You get A in final exam, but you don't do every exercise in this book, nevertheless you can get A in the class

b) Getting A on the final and doing every exercise in this book is sufficient for getting A in this class

c) you will get an A in this class if and only if you either do every exercise in this book or you can get A on the final ?

mathematical-logic


Selected Answer

for a ) p and ~q and r

for b ) (p and q ) --> r

for c ) r <---> (q or p )

Is it correct ?

 1 votes -- priti sharma ( 637 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1672 of 2244

14.97 write first order logic " everybody loves my baby but my my baby dnt
love everybody but only me" top gateoverflow.in/16892

How can you represent the famous poem line, in first order expression

"Everybody Loves My Baby, but My Baby Don't Love Nobody but Me"

14.98 Write first order expression top gateoverflow.in/16328

How can you represent the famous poem line, in first order expression

"Everybody Loves My Baby, but My Baby Don't Love Nobody but Me"

It's not an easy question as we think about logic and of course not a big also.
"Everybody loves my baby but my baby loves nobody but me" implies "I am my baby." (Please read question 3-4
times).
Let’s try to apply the language of Logic and Propositions that we learned in Coaching Classes/Self
Study/B.Tech/M.Tech...etc.

"Everybody loves my baby, but my baby don’t love nobody but me".

Suppose that our universe has one relationship, LOVES and two distinguished individuals, ME and MYBABY.

For example, LOVES(ME, MYBABY) means “I love my baby” and ∃x ~LOVES(x,ME) means "not everybody loves
me."

Let the domain for x consist of all people.Translating the proposition “ Everybody loves my baby, but my baby don’t
love nobody but me" into symbolic logic, we have

(∀x LOVES(x,MYBABY) )∧(∀x LOVES(MYBABY,x) ↔ x=ME)

Since the above conjunction is true , it follows that both propositions


∀x LOVES(x,MYBABY) and ∀x LOVES(MYBABY,x) ↔x =ME

must be true for all x. We can then substitute MYBABY for x to obtain

LOVES(MYBABY, MYBABY)∧(LOVES(MYBABY,MYBABY) ↔ MYBABY=ME)

The truth of the first proposition LOVES(MYBABY,MYBABY) together with the left-to-right implication
LOVES(MYBABY,MYBABY)→MYBABY=ME , imply that MYBABY=ME.

We must therefore conclude that individuals referred to as “ me” and “My Baby” are one and the same person.

Please refer the below links for more details.

https://www.mail-archive.com/everything-list@googlegroups.com/msg46966.html
http://griceclub.blogspot.in/2010/06/everybody-loves-my-baby-but-my-baby.html

 0 votes -- Mukesh Sharma ( 37 points)

14.99 Write Equivalent first order expression top gateoverflow.in/15966

All crows are birds but not all birds are crows.


Selected Answer

∀x(crow(x) ⇒ bird(x)) ∧ ∃x(bird(x) ∧ ¬crow(x))

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1673 of 2244

 0 votes -- Sankaranarayanan P.N ( 7645 points)

14.100 Write equivalent first order expression top gateoverflow.in/15969

There are worms inside some ripe mangoes.

inside(x, y) => y inside x.


y= worm
x= mango
∃y∃x( worm(y) ∧ ripe(x) ∧ inside(x, y))

 1 votes -- Anirudh Pratap Singh ( 4091 points)

14.101 I can't really understand the difference between the two statements :
a)for all x(C(x)->F(x)) b)there exists x(C(x)->F(x)) C(x)=x is a comedian
F(x)=x is funny top gateoverflow.in/11841

I can't really understand the difference between the two statements :


a)for all x(C(x)->F(x))
b)there exists x(C(x)->F(x))
C(x)=x is a comedian
F(x)=x is funny
the domain consists of all people
In English, the first statement implies "All comedians are funny" , and the second statement implies "Some people, if they are comedians, they are funny", if i'm not
wrong.
Apart from the fact that , the first one includes all people, and the second one includes some, is there any such difference between the two statements?

What you told are exactly correct. But "some" and "all" makes a lot of difference rt? We can say some people studying for
GATE get to IIT. But ALL people studying for GATE get to IIT is a lot different.

 1 votes -- Arjun Suresh ( 124125 points)

14.102 When do we know, it is an inclusive or and exclusive or in


propositional logic? top gateoverflow.in/11744

According to an example in Kenneth

“Students who have taken calculus or computer science can take this class.” - is an example of inclusive or

“Soup or salad comes with an entrée,” - it is almost always an example of exclusive or

Is there a chance for the second example of being inclusive or?

And how do we know for sure which one is exclusive or inclusive or when the statements almost reads the same?

mathematical-logic


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1674 of 2244

Inclusive OR means Atlesat one should be true.


Exclusive OR means exactly one should be true.

 3 votes -- Digvijay Pandey ( 26245 points)

14.103 How many solutions are there to the equation x+y+z=17 in positive
integers? top gateoverflow.in/7502

How many solutions are there to the equation x+y+z=17 in positive integers ?
A) 120 B)171 C)180 D)121

We have 17 and we want to distribute it to x, y and z such that each gets at least one. So, initially itself we take 3 and
give 1 each to x, y and z. So, now we have 14 left and have to divide this into 3. Let the 14 be as follows and we use | for
division.

X X X X X X X X X X X X X X

We need 2 | for dividing this into 3 parts. and with 2 |, our problem reduces to finding all the permutations of 14 + 2
items, where 14 and 2 of them are identical. So, our answer will be

16!/14!2! = 15 * 8 = 120

 4 votes -- Arjun Suresh ( 124125 points)

Consider that x=1, then it'll have 15 different solutions in positive integers. (1,1,15), (1,2,14) ........(1,15,1).

Similarly consider x=2, then it'll have 14 different solutions in positive integers.

Therefore, total number of different solutions in positive integers = 15 + 14 + ....... +1

= 120 solutions

Answer would be (A).

 3 votes -- suraj ( 3299 points)

14.104 How many solutions are there to the equation x+y+z=17 ?They are
non-negative integers top gateoverflow.in/7504

How many solutions are there to the equation x+y+z=17 ?They are non-negative integers
A) 120 B)171 C)180 D)121


Selected Answer

No. of solutions to the equation x+y+z=17 is given by formula

C(n+r-1, n-1)=C(3+17-1, 3-1)=C(19,2)=171

Ans (B)

 3 votes -- Keith Kr ( 5467 points)

14.105 maths_mocktest1_24 top gateoverflow.in/7853

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1675 of 2244

mathematical-logic


Selected Answer

option C

 2 votes -- Sushil Verma ( 129 points)

14.106 Which of the following is a tautology? top gateoverflow.in/7347

Which of the following is a tautology?

a. P → P ∧ Q
b. P → Q ∧ V
c. (P → Q) ∧ (Q → R) → P → R
d. (P → Q) ↔ ( ∼ Q →∼ P)

mathematical-logic

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1676 of 2244


Selected Answer

P → Q = ¬P ∨ Q
¬Q → ¬P = Q ∨ ¬P

Hence, D is correct.

C choice is also correct as → is usually taken as right associative (See here:


http://math.stackexchange.com/questions/12223/associativity-of-logical-connectives ). It'll be interpreted as

((P → Q) ∧ (Q → R)) → (P → R)

This is a tautology.

 6 votes -- Arjun Suresh ( 124125 points)

actually both (c) and (d) are correct.

d is called the contrapostive.

as for the third option

now let's say that the third option is incorrect then we can have (p -> r) false even when the left hand side is
true.

but p -> r false means p = True and R = False. Now for the left hand side to be true Q has to be false and true
at the same time. Since (p -> q) demands q to be false whereas (q -> r) demands q to be true. which is never
possible hence that is also a tutology.

 1 votes -- Tamojit Chatterjee ( 1925 points)

14.107 First order predicate logic top gateoverflow.in/6719

option c

 0 votes -- sanketg186 ( 97 points)

14.108 Use quantifiers to express:->There is exactly one person whom


everybody loves top gateoverflow.in/3889

Let L(x, y) be the statement "x loves y," where the do​main for both x and y consists of all people in the world.
Use quantifiers to express:
Q->There is exactly one person whom everybody loves.
E-some || A-for all ||
Answer-> Ex ( AyL(y,x) ^ Az((Aw L(w,z))->z=x) )
Can anyone explain the answer and how to solve these questions
i mean how to analyze these questions??

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1677 of 2244


Selected Answer

First of all we have only two quantifiers- exists and forall. So, first try to convert the given sentence into a sentence
containing those (its just English)

There is exactly one person whom everybody loves

This can be rewritten as

There is someone who is loved by everyone, and there is no one else who is loved by everyone

Again translated as:

There is someone, x, who is loved by everyone, and if there is another one, y, who is loved by everyone else,
means x and y are the same person.

This can be translated into first order logic (first order logic is just propositional logic with ∃ and ∀)

∃x(∀y(y,x) ⋀ (∀z(∀w(w,x)) ⇨ (z = x)))

Here actually in place of w, we can use y as the life of y expires immediately after ∀y(y,x) this. Using w instead of y is
strictly not needed.

You can also try to express " There is at most one person whom everybody loves"

Now, the translations I did is based on my knowledge about the expressive powers of first order logic. That is first order
logic can't be used for all statement forms- we first need to convert it into a suitable form. Luckily there are only a few
cases, which you should get experienced by solving previous year questions in this topic. You can see the below 3
questions and they should cover almost any type of question from this topic.

http://gateoverflow.in/256/gate1992_92-xv

http://gateoverflow.in/923/gate2003_33

http://gateoverflow.in/922/gate2003_32

 4 votes -- Arjun Suresh ( 124125 points)

14.109 Give the first order predicate calculus of the following statement.
“Some boys like every girl” top gateoverflow.in/5928

A). ∀(x) [ girl(x) -> ∃ (y) [ boy(y) Λ likes(y,x) ] ]

B). ∀(x) [ girl(x) Λ ∃ (y) [ boy(y) -> likes(y,x) ]

C) ∀(x) [ girl(x) -> ∃ (y) [ boy(y) -> likes(y,x) ] ]

D) None of these

mathematical-logic


Selected Answer

Option D is correct.

A - Every girl is liked by some boy.

B - Everything is a girl, and is either liked by some boy, or something is not a boy. (I know, sounds funny.)

C - Every girl is liked by some boy, or there is something which is not a boy.

 5 votes -- Pragy Agarwal ( 13675 points)

14.110 maths_mocktest1_11 top gateoverflow.in/7855

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1678 of 2244

mathematical-logic


Selected Answer

A + B, is satisfiable when either A or B is 1. But not tautology. as both A and B can 0.

A tautology means any assignment to variables produces a 1. So, it is trivially satisfiable.

A contradiction means any assignment ot variables produces a 0. So, it can never be satisfied.

Coming to B option, it says Every satisfiable formula is not tautology. This is wrong as valid formula is both satisfiable as
well as tautology. If we change "every" to "some", B option becomes correct. Actually this sentence is not grammatically
correct and can also be interpreted as "Every satisfiable formula is not a tautology" meaning some satsfiable formula is
not tautology. In this case B option becomes TRUE.

 4 votes -- Arjun Suresh ( 124125 points)

14.110 Total onto function from a to b with cardinality 4 anf 3 respectively top
gateoverflow.in/7977

3! * S(4, 3) = 3! * 6 = 36

http://gateoverflow.in/5596/no-of-surjective-functions

http://www.math.uiuc.edu/~kostochk/math413/comb.pdf

 1 votes -- Arjun Suresh ( 124125 points)

14.110 p:It is below freezing. q:It is snowing. It is either below freezing or it


is snowing but it is not snowing if it is below freezing. how do we represent
the but??? top gateoverflow.in/11333

IF it is below Freezing THEN not snowing ELSE it is snowing..

If it is below Freezing then not snowing OR If it is NOT below Freezing then it is snowing..

= (P ----> Q') ^ ( P' ----> Q) // something like IF 'X' THEN 'Y' ELSE 'Z'

= (P' + Q') ^ (P + Q)

= PQ' + P'Q

= P ◎ Q. // P Ex - OR Q

It is either Freezing or Snowing but not both..

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1679 of 2244

 1 votes -- Digvijay Pandey ( 26245 points)

14.110 Show that negation and disjunction form a functionally complete


collection of logical operators. top gateoverflow.in/11335

Disjunction : A v B
Conjunction : ~(~(A) v ~(B))
Negation. : ~A.
NAND : ~(A) v ~(B)
NOR : ~(A v B)
A Ex - OR B = ~(A v ~B) v ~(~A v B)}
A Ex - NOR B : ~{~(A v ~B) v ~(~A v B)}

 0 votes -- Digvijay Pandey ( 26245 points)

14.111 What is the correct representation of the stmt in first-order predicate


calculus ? top gateoverflow.in/10488

Given the statement : "Men who are intelligent have knowledge."

What is the correct representation of the statement in first-order predicate calculus?

a. ∀x man (x) ∧ intelligent (x) → ∃y knowledge (y) ∧ have knowledge (x, y).
b. ∀x∃y man (x) ∧ intelligent (x) → knowledge (y) ∧ have knowledge (x, y)
c. ∀x, y man (x) ∧ intelligent (x) ∧ knowledge (y) → have knowledge (x, y)
d. None of the above.


Selected Answer

a is correct.

b is wrong due to implication having lower precedence than quantifiers. It will be evaluated as
(∀x∃yman(x) ∧ intelligent(x))  (knowledge(y) ∧ have knowledge(x, y)).

Here, for the RHS, there is no quantification for x or y, meaning it must be true for every x and y.

We can make (b) correct by writing it as follows:

∀x∃y(man(x) ∧ intelligent(x)  knowledge(y) ∧ have knowledge(x, y))

Ref: https://en.wikipedia.org/wiki/First-order_logic#Notational_conventions

 6 votes -- Arjun Suresh ( 124125 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1680 of 2244

14.112 Propositional Logic top gateoverflow.in/10436

The nth statement in a list of 100 statements is “Exactly


n of the statements in this list are false.”
a) What conclusions can you draw from these statements?
b) Answer part (a) if the nth statement is “At least n of
the statements in this list are false.”
c) Answer part (b) assuming that the list contains 99
statements.

A)The n^{th} statement in a list of 100 statements is:


"Exactly n of the statements in this list are false."
1)Exactly 1 of the statements in this list are false.
2)Exactly 2 of the statements in this list are false.
3)Exactly 3 of the statements in this list are false.
.
.
98)Exactly 98 of the statements in this list are false.
99)Exactly 99 of the statements in this list are false.
100)Exactly 100 of the statements in this list are false.
Let 1) is true.
so exactly one of the statement is false.let it be 3).so other 99 statements are true.But this is clearly impossible.
In a similar fashion we can eliminate statements (2) to (98).

Can (98) be true?


Then 98 statements are false.
Which two are true?
One of them is (98); suppose the other is (37).
Then (98) says "Exactly 98 statements are false."
and (37) says "Exactly 37 statements are false."
And we have a contradiction. so (98) cannot be true.

Can (100) be true?


Then all statements are false, including (100).
This leads to a logical dilemma.

The only remaining statement is (99).


It says "Exactly 99 statements are false."
And this is possible!
Statements (1) through (98) and (100) will be false.
B)Same way we can solve it. So we will get 1-50 are true and 51-100 are false.
C)This cannot happen.

 1 votes -- Anu ( 6731 points)

14.112 the no of algebric terms involved in the expansion of a determinant top


gateoverflow.in/9643

recurrence gives required no of terms..


T(n) = n*T(n-1)
T(1)= 1

 0 votes -- Digvijay Pandey ( 26245 points)

14.113 Propositional Logic top gateoverflow.in/10435

An ancient Sicilian legend says that the barber in a remote


town who can be reached only by traveling a dangerous
mountain road shaves those people, and only those people,
who do not shave themselves. Can there be such a

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1681 of 2244

barber?

Barber is one out of set of affected people..


if barber is in trouble then above statement is illogical..

if he is in trouble then der is a barber who save him but that saver barber is in trouble. i.e. no such barber exists.

 1 votes -- Digvijay Pandey ( 26245 points)

14.114 Write the following English statement as an implication. top gateoverflow.in/18724

"Getting elected follows from knowing the right people."

mathematical-logic


Selected Answer

Let:

p = Knowing the right people.


q = Getting elected.

"Getting elected" follows from "Knowing the right people"

≡ q follows from p

≡p  q

 1 votes -- priti sharma ( 637 points)

14.115 Recurrence relation top gateoverflow.in/27590

does gate syllabus include RECURRENCE EQUATION.!!! if it is ,could any one recommend me link for good material for the
same!!!

http://www.cise.ufl.edu/~sahni/dsaaj/enrich/c19/recur.pdf

 1 votes -- Vikranth Inti ( 239 points)

14.116 Mathematical Logic Meaning of the given statements top gateoverflow.in/35928

Which predicate logic means, "There are at most two men in class"?

∀x∀y((Male(x) ∧ Male(y)) → (x = y ∨ y = x)

∃x∃y(Male(x) ∧ Male(y) ∧ x ≠ y ∧ ∀z(Male(z) → (z = x ∨ z = y)))

∀x∀y∀z(Male(x) ∧ Male(y) ∧ (Male(z)) → (x = y ∧ x = z ∧ y = z)

How do I know the meaning of the statements? I want to know the working steps.

mathematical-logic normal

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1682 of 2244


Selected Answer

∀x∀y((Male(x) ∧ Male(y)) → (x = y ∨ y = x)

For every x, y, if both are male, then x = y or y = x.

The second part of OR is redundant here as x = y is same as y = x. So, this basically means there cannot be no more than 1
man in the class (either 0 or 1 man is possible).

∃x∃y(Male(x) ∧ Male(y) ∧ x ≠ y ∧ ∀z(Male(z) → (z = x ∨ z = y)))

There are x and y such that both are men, and if there exist another man z, then x = z or y = z. This means there are
exactly two men in the class- no less no more.

∀x∀y∀z(Male(x) ∧ Male(y) ∧ (Male(z)) → (x = y ∧ x = z ∧ y = z)

For every x, y, z, if all are men, then all are the same. I guess z is redundant here and it should mean the same as in (1).

 3 votes -- Arjun Suresh ( 124125 points)

14.117 is conjunctive normal form part of gate 2016 syllaus top gateoverflow.in/36025

is conjunctive normal form part of gate syllabus?


Selected Answer

YES. Digital Electronics have POS (Product of Sum) form, SOP (Sum of Product) form. They are the variation or we can
say other names of Conjunctive Normal Form or Disjunctive Normal Form. So they are in syllabus.

 3 votes -- Rude Maverick ( 3063 points)

14.118 Associativity of implication? top gateoverflow.in/36676

a + b->c means

(a + b)-> c or a + (b->c)?

Associativity doesnt hold for IMPLICATION..


in question they will explicitly mention or they will provide brackets otherwise question will be ambiguous ..

a + b->c means (a + b)--> c bcoz precedence of + > precedence of -->

 1 votes -- Digvijay Pandey ( 26245 points)

14.119 linear algebra top gateoverflow.in/35744

let A be a diagonalizable matrix of order n*n .then which of the following is true?

a)A has atleast one Linearly Independent Eigen vector

b)A has atleast n Linearly Dependent Eigen vector

c)A has exactly one Linearly Independent Eigen vector

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1683 of 2244

d)A has exactly n Linearly Dependent Eigen vector

14.120 quantifiers top gateoverflow.in/35185

1. Let P(x, y) be a propositional function. Show that∃x ∀y P(x, y) → ∀y ∃x P(x, y) is a tautology.


2. Let P(x) and Q(x) be propositional functions. Showthat ∃x (P(x) → Q(x)) and ∀x P(x) → ∃x Q(x) always
have the same truth value.
3. If ∀y ∃x P(x, y) is true, does it necessarily follow that∃x ∀y P(x, y) is true?
4. If ∀x ∃y P(x, y) is true, does it necessarily follow that ∃x ∀y P(x, y) is true?


Selected Answer

1. We need to show that ∃x ∀y P(x, y) → ∀y ∃x P(x, y) is a tautology i.e. whenever ∃x ∀y P(x, y) is true, ∀y ∃x P(x, y) is also true.

If ∃x ∀y P(x, y) is true, it means there exists an x = c (where c is an arbitrary constant), for which P(c,y) is true for all y, which in turn means
that for all y, there exists an x (the constant c), for which P(x,y) is true i.e. ∀y ∃x P(x, y) is true. Hence proved.

2. We need to show that ∃x (P(x) → Q(x)) and ∀x P(x) → ∃x Q(x) always have the same truth value.

L.H.S = ∃x (P(x) → Q(x)) ≡ ∃x (¬P(x) v Q(x)) ≡ ∃x (¬P(x)) v ∃x Q(x) ≡ ¬∀x P(x) v ∃x Q(x) ≡ ∀x P(x) → ∃x Q(x) = R.H.S.

3. False. ∀y ∃x P(x, y) being true means for every y, there is an x (possibly different x for different values of y we choose) such that P(x,y) is
true. It doesn't mean that there is a single x which makes P(x,y) true for every y.

4. False. Almost same argument as above.

∀x ∃y P(x, y) being true means for every x, there is a y (possibly different y for every x), which makes P(x,y) to true. This doesn't mean that
there is a single x, which makes P(x,y) for every possible y.

 2 votes -- Happy Mittal ( 9253 points)

14.121 Lattice top gateoverflow.in/34192

Option a

As complement

m∨n=1 and m∧n=0

m∨p=1 and m∧p=0

So both n and p are complements of m

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1684 of 2244

For distirbutive lattice

N∧(m∨p)= (N∧m)∨(N∧p)

From lhs. n ∧(m∨p)=n∧1=n

From rhs. n∧m=0 n∧p=p

And 0∨p= p

So lhs≠ rhs that's why given lattice is non-distributive

 1 votes -- Khushboo Tak ( 1961 points)

14.122 total ways of making a question paper with 12 binary questions top
gateoverflow.in/34779
if a test consist only 12 true false questions then total ways of making test with one answer to each question?

12! 4000 11! none

Each Question -> True / False

So,
=2*2*2*.....*2
=2^12

If "one answer to each question" was not mentioned then

Each Question -> True / False / Nothing

So,
=3*3*.......*3
=3^12

 0 votes -- Hareesh Kumar ( 43 points)

14.123 Difference b/w validi and tautology? top gateoverflow.in/36681

valid statement.

vs.

Tautology.

please clear someone.


Selected Answer

Simply make three divisions as--->

Tautology--> having all value 1 in truth table

Contradiction --> having all values 0 in truth table

Contingency-> atleast one row having 0 value and atleast one row having 1 value
Now,
Valid = Tautology

Satisfiable= (Tautology or Contingency)

Unsatisfiable = Contradiction

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1685 of 2244

Invalid = Contradiction or contingency

Using above results u would be able to get solutions to all problems related to it ('and' and 'or' --> treat them as logical
connectives)

for eg.--

tautology => Satisfiable

Unsatisfiable => Contradiction....

 1 votes -- Abhishekcs10 ( 1001 points)

14.124 Is ϕ REFLEXIVE on R(ϕ->ϕ)? top gateoverflow.in/36686

Is ϕ REFLEXIVE on R(ϕ->ϕ)?

I think it is.

 0 votes -- Aspi R Osa ( 1305 points)

14.125 PREDICATE LOGIC top gateoverflow.in/37663

Recall that a predicate logic statement is contingent if its truth value depends on the choice of the universe and on the
interpretations of the predicate symbol S and the constant symbol b involved.

Consider the following predicate logic statements in which b, x and y are elements of the universe U.

I. ∀x(S(x, b) → ∃yS(x, y))


II. ∀x∃yS(x, y) → ∃y∀xS(x, y)
III. ∀x(¬S(x, x) ↔ S(b, x))

Which of the following best describes the predicate logic statements?

Statement I - Statement II - Statement III

a. Always true - Always false - Contingent.


b. Always true - Contingent - Always false.
c. Always true - Contingent - Contingent.
d. Contingent - Always true - Always false.

B?????????

 0 votes -- Deepesh Kataria ( 1207 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1686 of 2244

14.126 Verbal Ability top gateoverflow.in/38163

In these question there are 3 statements followed by 4 conclusions numbered as (a), (b), (c) and (d). Assume the given 3
statements to be true even if they are at variance with commonly known facts.

S1: Some clouds are girls.

S2: All rains are clouds.

S3: Some clouds are cars.

Conclusions:

C1: Some girls are rains.

C2: Some cars are girls.

C3: Some cars are rains.

C4: Some rains are girls.

Identify the conclusion which follows from the given 3 statements.

a. None follow.
b. Only C4 follows.
c. Only C1 follows.
d. Both C1 and C4 follows.

mathematical-logic verbal-ability


Selected Answer

Consider a set CLOUDS with RAINS, GIRLS and CARS it's subsets and all of them mutually disjoint. The given statements
are true here but none of the conclusions follow.

 1 votes -- Arjun Suresh ( 124125 points)

14.127 Find out the equivalent expression top gateoverflow.in/37060

(P∨Q)∧(P→R)∧(Q→S) is equivalent to-

a) S∧R

b)S→R

c)S∨R

d)None.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1687 of 2244


Selected Answer

PV Q is equivalent to -P->Q

Q->S

apply transititvity

-P->S

using contrapositive

-S->P

and P->R(given)

-S->R

that gives SVR

 2 votes -- Pooja ( 22773 points)

14.128 modulus top gateoverflow.in/36900

how to calculate the value of 5^13 mod 77?


Selected Answer

Whenever you see this type of question then use this method to solve this.

5^1 = 5 //Not divisible by 77, so go on increasing power of 5

5^2 = 25 //Not divisible by 77, so go on increasing power of 5

5^3 = 125 //Divisible by 77 but return remainder 48, which is a huge number. Our objective is to get as less remainder as
possible.

5^4 = 625 // Divisible by 77, and remainder is 9. It is pretty less, then stop here.

Now 5^13 = ((5^4)*(5^4)*(5^4)*5)%77

= (9 * 9 * 9 * 5) %77

= (729 * 5) %77

= (36 * 5) % 77 // 729%77 = 36

= 180 % 77 = 26
Hence 26 will be the answer.

 3 votes -- Rude Maverick ( 3063 points)

14.129 Assume the following predicate and constant symbols: top gateoverflow.in/3740

Assume the following predicate and constant symbols:

W(x,y): x wrote y

L(x,y): x is longer than y

N(x): x is a novel

a: Amit h: Harshal

Which of the following predicate logic formula represents the sentence:

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1688 of 2244

"Harshal wrote a novel which is longer than any of the Amit's novels"

A. ∀x ∃y(L(x, y) → W(x, y) ∧ W(a, x))


B. ∀x∀y(W(h, x) ∧ W(a, y)  L(x, y))
C. ∃x∀y(N(x) ∧ W(h, x)  N(y) ∧ W(a, y) ∧ L(x, y))
D. ∃x(N(x) ∧ W(h, x) ∧ ∀y(N(y) ∧ W(a, y)  L(x, y)))

mathematical-logic normal


Selected Answer

(A) For every book if there exists a shorter book, then harshal has written the shorter one and amit the longer one.

(B) Every book written by Harshal is longer than every book written by Amit.

(C) There exists an x such that if x is a novel written by Harshal, then all novels written by Amit are shorter than x.

(D) There exists an x such that x is a novel written by Harshal and all novels written by Amit are shorter than x.

So, (D) is the answer

 4 votes -- Arjun Suresh ( 124125 points)

14.130 groups top gateoverflow.in/36897

14.131 probability top gateoverflow.in/34191

if d probability dat an individual suffers a bad reaction frm injection of a serum is 0.001.determine the probability that out of
2000 indivisuals exactly 3 individuals suffer a bad reaction?

Its probability ques

binomial distribution applicable with poisson approximation ( n large p small)

mean(lambda)=n*p =2

apply poisson formula

(e ^ -2) *2^3/3¦ =. 18

 0 votes -- Anurag Semwal ( 4775 points)

14.132 Statistics top gateoverflow.in/33696

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1689 of 2244

14.133 Find the Coe​fficient top gateoverflow.in/29295

Find the coefficient of x4 in the series expansion of (1 + x + x2 ) −4 ?

How do you expand (1 + x + x2 ) −4 ? Using Taylor series?

engineering-mathematics

14.134 Question from Rosen top gateoverflow.in/30354

Let S(x) be the predicate “x is a student,” F(x) the predicate“x is a faculty member,” and A(x, y) the predicate “x has asked y a question,” where the domain consists
of all people associated with your school. Use quantifiers to express each of these statements.
a) Some student has asked every faculty member a question.
b) There is a faculty member who has asked every other faculty member a question.

It would be a great help if someone can elaborate the explanation.

1) ∃x( S(x) ^ ∀y (F(y)→A(x,y)))

here ∃x (S(x)) is there exists some students

∀y (F(y)) is for all faculty member

A(x,y) (here x is student,y is faculty member) student ask faculty member a question

So, at last we can say"Some student has asked every faculty member a question"

2)∃x( F(x) ^ ∀y (F(y)→A(x,y)))

here ∃x (F(x)) is there exists some faculty member say x

∀y (F(y)) is for all faculty member , say y

A(x,y) (here x is one faculty member,y is all faculty member) faculy member x ask faculty member y a question

So, we can say " There is a faculty member who has asked every other faculty member a question."

 1 votes -- srestha ( 11585 points)

14.135 Restriction of quantifiers top gateoverflow.in/32312

How is restriction of universal quantification same as the universal quantification of a conditional


statement while restriction of existential quantification is same as the existential quantification of a conjunction ?

it can be visualised as

∀- For universal quantifier p->q condition exists which is same as conditional statement.

if p the antecedent is true q (consequent) should be true but if p is false it q could be anything, the implication would be
true. Same is the case in universal quantifier.

∃- For existential quantifier p^q condition exists.It is same as conjunction. There must exist atleast a condition where p
and q both should be true.

 1 votes -- Abhishekcs10 ( 1001 points)

14.136 Preceence rule top gateoverflow.in/28907

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1690 of 2244

∀x∀yP(x,y)→∀x∀yP(y,x)

1.The above formula is not tautology as the formula will be seen as:
∀x∀y(P(x,y)→∀x∀yP(y,x))
--For every (x,y) if P(x,y) is true then for every (x,y) P(y,x) is true
Why it is not like:
(∀x∀y(P(x,y))→(∀x∀yP(y,x)))

How the above bracketing have been done. Is some rule of precedence used here, if yes then tell their order.

2.Will the same rule will be applied for below formula:
∀x∃yR(x,y)↔∃y∀xR(x,y)

>>>>>>> both are not same . because of the associativity the meaning changed, well u should wait for a better answer.

 0 votes -- Ravi Singh ( 7303 points)

14.137 Bipartite graph top gateoverflow.in/28770

ans is a

when partition is

one side 1 second side 13 = 13 edge

one side 2 second side 12 = 24 edge

one side 3 second side 11 = 33 edge

one side 4 second side 10 = 40 edge

one side 5 second side 9 = 45 edge

one side 6 second side 8 = 48 edge

one side 7 and another side 7 vertex.= 7*7= 49

 3 votes -- Anirudh Pratap Singh ( 4091 points)

14.138 ellipse top gateoverflow.in/28134

what is major axis in elllipse

numerical-answers

Unlike circles, Ellipses may have varying diameters.

The largest diameter of any Ellipse is known as its Major Axis.

The smallest diameter is called its Minor Axis.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1691 of 2244

Line segment AB is the major axis, & PQ is the minor axis of this ellipse.

Circles are special cases of ellipse, having length of major axis equal to that of minor axis.

So every circle is an ellipse but not every ellipse is a circle.

 0 votes -- Anurag Pandey ( 8183 points)

14.139 matrix "eigen value of A^2-3A" top gateoverflow.in/28506

Let 3rd eigen value is x.

Eigen values of A2 +3A are 1+3, 1-3, x 2 + 3x i.e 4, -2, x 2 + 3x

Compare this with given condition. x 2 + 3x = 18, x = -6, 3

None of eigen value is zero that means both A as well as A 2 + 3A are invertible.

 1 votes -- Digvijay Pandey ( 26245 points)

14.140 graph theory top gateoverflow.in/32519

How many non-isomorphic simple graph are there with 5 vertices and 3 edges?how to approach this qus....

graph-theory

I think 2

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1692 of 2244

 0 votes -- srestha ( 11585 points)

14.141 Graph theory top gateoverflow.in/32565

If a simple graph has 3 component and these component have 4,5,6 vertices ,then maximum number of edge present in
graph.

(a) 26

(b) 76

(c)30

(d)42

graph-theory

Max edges for

component 1 : 4c2 = 6

component 2 : 5c2 = 10

component 3 : 6c2 = 15

total = 6+10+15=31

max No. of edges = 31

 3 votes -- Pranay Datta ( 6113 points)

14.142 Group theory top gateoverflow.in/33334

For any group, the number of subgroups possible is ?

set-theory&algebra

14.143 Set Theory top gateoverflow.in/33359

How do we find whether the group is finite or infinte in questions like below ?

If (G,*) is a group such that (a ∗ b)2 = (a ∗ a) ∗ (b ∗ b) for all a,b belonging to G, then G is

a) Finite group

b) Infinite group

c) Abelian group

d) None of the above

set-theory&algebra


Selected Answer

Here is the definition.

Let a be an element of the group G. If there exists a positive integer n such that an = e, then a is said to have
Finite Order, and the smallest such positive integer is called the order of a, denoted by o(a). If there does not
exist a positive integer n such that an = e, then a is said to have Infinite Order.

There is no way to prove that the given group (G,*) is a finite group or not. Because It does not talk about the sets. I
have read this document. You can also read if you want to see that.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1693 of 2244

Now In the above question, The correct answer is C. The given group is an Abelien group. A group with Commutative
property is called Abelian group. Because we will get (a * b)^2 = (a * a) * (b * b), only when the group is commutative.
Like this:

(a * b)^2 = (a * b) * (a * b)
= (a * b) * (b * a) // Commutative property

= a * ((b * b) * a) // Associative property

= a * (a * (b * b)) // Commutative property

= (a * a) * (b * b) // Associative Property

Hence the given group is Abelian group. Hence Option C is the correct answer.

 3 votes -- Rude Maverick ( 3063 points)

14.144 How to represent the below proposition ? top gateoverflow.in/32961

Gold and silver ornaments are precious .

G(x): x is a gold ornament.


S(x): x is a silver ornament.
P(x): x is precious.

Now why is this statement true?

∀x (( )
G(x) ∨ S(x) → P(x) )
Why not the following?

( ) ( )
∀x G(x) ∨ ∀x S(x) → P(x)

Although universal quantifier is not distributive over disjunction but in this case the ornament will belong to only 1 category,
so is there any with this?

mathematical-logic


Selected Answer

Here ∀x (( ) )
G(x) ∨ S(x) → P(x) : It implies that if an ornament is made of either gold or silver then it is precious.

However if you write like as below,entire meaning will change.

( ) ( )
∀x G(x) ∨ ∀x S(x) → P(x)

First of all,you have made x of P(x) as free variable, so you should have out quantifier before P(x) also.

Now coming to your confusion,here it implies all ornaments made of gold or all ornaments made of silver are precious. So
here there are possibilities that some ornaments which are both gold and silver in your universe of discourse which is not
true from given context of question.

I hope it is clear.

 3 votes -- Shashank Kumar ( 2029 points)

14.145 p&c top gateoverflow.in/32796

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1694 of 2244

six balls have to be placed in the squares such that each row has atleast one ball . no of ways of doing this is-

combinatory


Selected Answer

There are 8 cells and 6 balls to place, so we can do it in ( 6 ) . Now we need to remove two cases where toprow is left out
8

without balls and second where last row is left out. So then it becomes ( 6 ) - 2 = 26.

 3 votes -- UK ( 1341 points)

14.146 How to represent the below proposition using a well-defined formula


? top gateoverflow.in/32601

The only even prime is 2.


Selected Answer

Let x = set of natural numbers.

EQUAL(X,Y) : 'X' is equal to 'Y'

EVEN(X) : 'X' is even.

PRIME(X) : 'X' is prime.

"The only even prime is "2" can be expressed as :

∀x [ (EVEN(X) ∧ PRIME(X)) ↔ EQUAL(X,2)]

Here bi-direction is necessary because if only uni-direction implication were there from Left to Right and consider if
number is even but prime ,so LHS becomes false so we can't say anything about RHS i.e whether number is two or
not.This is so because in implication,if LHS is false we can't say anything about RHS and whole implication becomes true
i.e F -> T or F is always true.

Hence we need both side implication to show that if given no. is both prime and even then it is only '2' ,and if given no. is
'2' then its even & prime both.

I hope it clear many doubts related to implication.

 1 votes -- Shashank Kumar ( 2029 points)

I am not sure but you can try my option and let me know if i m wrong....

See Question is saying No. Should be even as well as prime(even and prime) and if it is true then no.has to be 2 otherwise
formula sholud not exist....

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1695 of 2244

If x={set of all integers} and


P(x):No.is even

Q(x):No.is Prime

R(x):No. is 2

then

for all x (P(x)^ Q(x)<--->R(x))


Double Implication bcz if no.is even and prime then it has to be 2 otherwise both has to be false

 2 votes -- Anirudh Pandey ( 343 points)

14.147 How to approach this type of Mathematical logic Question top gateoverflow.in/32667

The answer is option c. I want to know how to solve these type of questions and how other options are not the correct
answer.

mathematical-logic normal

14.148 division among groups top gateoverflow.in/39178

In order to play basketball,10 childrens at playgorund divide themselves into two teams of 5 each.How many divisions are
possible?

combinatory


Selected Answer

{ABCD} LETS DIVIDE THEM IN TWO DIVISIONS .....

IF QUESTION IS HOW MANY COMBINATIONS OF 2 OUT OF 4 ...THEN =4C2=6

BUT NOW ITS ASKING DIVISION

AB CD CD AB (BOTH ARE SAME)

AC BD BD AC (BOTH ARE SAME)

AD BC BC AD (BOTH ARE SAME)

THEREFOR 4C2/2=3 NUMBER OF DIVISIONS....THERE ANSWER IS 10C5/2

 3 votes -- Deepesh Kataria ( 1207 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1696 of 2244

15 Probability top
15.1 Bayes Theorem: Bayes Probability top gateoverflow.in/32923

Supppose you have a large barrel containing a number of plastic eggs.


Some eggs contain pearl and rest contain nothing.Some eggs are painted
blue,rest are painted red.
Suppose 40 % of the eggs are painted blue,(5/13) of the eggs containing pearls
are painted blue,and 20 % of the red eggs are empty.
What is the probability that the egg painted blue contains a pearl?

probability bayes-theorem


Selected Answer

Lets say total No. of eggs= 100.

blue egg(40%)=40

red=60

20% red are empty so 12 is empty and 48 contain pearl.

5/13 egg containg pearl is painted blue so 8/13 would be red.

8X/13=48

x=78

blue containg pearl=5X/13=30

total egg painted 100,egg containing pearl 78.

so P=78/100

Blue(40) Red(60)
empty 10 12
Pearl 30 48

Ans=30/40= 3/4

 2 votes -- Pyuri sahu ( 1237 points)

15.2 Bayes Theorem: Bayes Probability Question top gateoverflow.in/33274

URN I contains 3 White,2 Black 2 Green Balls.


URN II contains 2 White,3 Black 4 Green Balls.
URN III contains 5 White,2 Black 2 Green Balls.
An urn is chosen at random and two balls are drawn,they happen to be black and green.
What is the probability that the come from urns
1) URN I
2) URN II
3) URN III ????

probability bayes-theorem engineering-mathematics


Selected Answer

Let P(E) = Probability of choosing 1Black & 1 Green balls from Urn.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1697 of 2244

P(Ei) = Probability of selecting one of three urns .

Hence P(E 1) = P(E2) =P(E3) = 1/3

P(E) = Select Urn1 & choose 1Black & 1 Green balls + Select Urn1 & choose 1Black & 1 Green balls +Select Urn1 &
choose 1Black & 1 Green balls

= P(E 1)* P(E / E1 ) + P(E2)* P(E / E2 ) + P(E3)* P(E / E3 )

2
= (1/3)* 2C 1* C 1 / (
7C ) + (1/3)* 3C *4C / (9C ) +(1/3)* 2C *2C / (9C ) = 4/63 + 1/9 + 1/27 = 40/189
2 1 1 2 1 1 2

Now we have to find probability that balls chose were from Urn 'i'

i.e P(E i / E) = ?

P(Ei / E) = P(Ei ∩ E)/P(E) = P(Ei)* P(E / Ei ) / P(E)

Now

Ans 1) for URN1 , put i =1, we have

P(E1 / E) = P(E1 ∩ E)/P(E) = P(E1)* P(E / E1) / P(E) = (4/63) / (40/189) = 3/10 (Substituting values from above calculations)

Ans 2) for URN2 , put i =2, we have

P(E2 / E) = P(E2 ∩ E)/P(E) = P(E2)* P(E / E2) / P(E) = (1/9) / (40/189) = 21/40 (Substituting values from above calculations)

Ans 3) for URN3 , put i =3, we have

P(E3 / E) = P(E3 ∩ E)/P(E) = P(E3)* P(E / E3) / P(E) = (1/27) / (40/189) = 7/40 (Substituting values from above calculations)

 3 votes -- Shashank Kumar ( 2029 points)

15.3 Binomial Theorem: Probability Binomial Distribution top gateoverflow.in/33638

Probability of getting a total of 7 atleast once in three toss of a fair die is

125/216
91/216
117/216
9/216

binomial-theorem probability

let Y be the event for getting total of 7

P(Y)=1/6

Atleast once means 1-(none)

using binomial =nCx * p^x * q^(n-x)

take x=0 for none and n=3..since tossing 3 times

=3c0 * (1/6)^0 * (5/6)^(3)

=(5/6)^3

so ans is 1-(5/6)^3 that is (91/216)

 1 votes -- Gabbar ( 469 points)

15.4 Coin: coin probability top gateoverflow.in/31076

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1698 of 2244

an unbiased coin is tossed infinite no of times.The probability that 4th head appear at 10th toss is

1) 0.067

2) 0.073

3) 0.082

4) 0.091

probability coin


Selected Answer

We can say 10th toss is a head

In previous 9 toss ,we have to take 6 tail and 3 head with probability

=(9)! / (6! *3! )

= (9*8*7)/(3*2)

=3*4*7 = 84

Now, probability of 10 th toss will be head = 84/ 2 10

=21/256 =0.082

Answer will be (3)

 6 votes -- srestha ( 11585 points)

15.5 Conditional Probability: probability top gateoverflow.in/16432

Let x be the number obtained from rolling a fair dice and you toss an unbiassed coin X times. What is the probablity that X=5
given that you have obtained 3 heads from X tosses?

conditional-probability

My Answer is 2/7.Given that 3 heads appeared it means the outcome of die roll is at least 3.Now if the out come of die roll
is 3, then ways of occurring 3 heads is 3C3, if 4 occurred in die roll then ways of occurring 3 heads is 4C3, similarly 5C3
and 6C3.so all possible ways in which 3 heads can appear is (3C3 + 4C3 + 5C3 + 6C3). The favourable outcome is when
die roll happens to be a 5 and 3 heads appear that is 5C3. So desired probability will be (5C3)/(3C3 + 4C3 + 5C3 + 6C3)
which gives 2/7.

 0 votes -- Anurag Pandey ( 8183 points)

15.6 Conditional Probability: Conditional Probability top gateoverflow.in/26475

A die is thrown 3 times and sum of 3 numbers thrown is 15. Find the chance that first thrown is 4 ?

probability conditional-probability


Selected Answer

Probability that first throw is 4 given that sum is 15

= P(first throw = 4, sum = 15)/ P(Sum = 15)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1699 of 2244

1 / 6 ×2 ×1 / 36
10/ 216
=

= 2/10 = 1/5.

Probability that sum is 15 given that first throw is 4

= P(first throw = 4, sum = 15)/ P(First throw is 4)


1 / 6 ×2 ×1 / 36
1/6
=

= 2/36 = 1/18.

 2 votes -- Arjun Suresh ( 124125 points)

15.7 Conditional Probability: random variables top gateoverflow.in/25174

Consider two independent random variables X and Y with identical distributions.The variables X and Y take blue 0, 1 and 2
with probabilities 1/2, 1/4 and 1/4 respectively. What is conditional probability P(X+Y=2/X-Y=0)???

probability conditional-probability random-variable


Selected Answer

Given X and Y random variables with identical distribution.


1

P(X = 0) = P(Y = 0) = 2

P(X = 1) = P(Y = 1) = 4

P(X = 2) = P(Y = 2) = 4

Let A = X + Y = 2

and B = X − Y = 0

X+Y=2 P(A∩B)

( )
P X−Y=0 = P(B)

Event P(A ∩ B) happen when X + Y = 2 and X − Y = 0.

this is satisfied only when X = 1 and Y = 1

1 1 1

P(A ∩ B) = 4 . 4 = 16

and P(B) happen when X − Y = 0. it occurs when X = Y

i.e. X = 0 or Y = 0

X = 1 or Y = 1

X = 2 or Y = 2

1 1 1 1 1 1

P(B) = 2 . 2 + 4 . 4 + 4 . 4

6
16
=

Now

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1700 of 2244

1
16

6
X+Y=2 P(A∩B)

P ( ) X−Y=0
= P(B)
= 16

=6

 4 votes -- Leen Sharma ( 2935 points)

15.8 Expectation: Estimate the expected number of integers with 1000 digits
that need to be selected at random to find a prime, if the probability a
number with 1000 digits is prime is approximately 1/2302. top gateoverflow.in/4628

Answer:2302

probability expectation


Selected Answer

Let X i denote the random variable for i th selection being prime.

We require expected value of sum of all X i to be 1. Linearity of expectation (refer link at bottom) says that expected value
of sum of a random variable is equal to the sum of the individual expectations.

i.e., E(∑ X i) = ∑ E(Xi)

We have X i = 1/2302 and that is the same for all i. (once we take a number that number can be repeated also and hence
events are independent)

So, E(∑ Xi) = ∑ E(Xi) = 1

=> ∑ (1/2302) = 1

as summation is from 1 to n, we get

n/2302 = 1 => n = 2302

http://www.cse.iitd.ac.in/~mohanty/col106/Resources/linearity_expectation.pdf

 1 votes -- Arjun Suresh ( 124125 points)

15.9 Expectation: then what is the expected number of games played in the
series top gateoverflow.in/41874

If two teams A and B play a best-of-five series, and if team A has a 1/4 chance of winning any game (and team B has 3/4
chance of winning any game), then what is the expected number of games played in the series. (Note that in a best-of-five
series, the teams play games until one team has won three games.)

expectation

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1701 of 2244

You need to calculate the answer approx. as I have given the equation in terms of p and q with p=1/4 (A's Chance of
winning) and q=3/4 (B's chance of winning).

 0 votes -- Ashish Gupta ( 631 points)

15.10 Expectation: Suppose that we roll a fair die until a 6 comes up or we


have rolled it 10 times. What is the expected number of times we roll the
die? top gateoverflow.in/4627

Answer is 50,700,551/10,077,696 ≈ 5.03


Do we need to take all X(R.V.): 1,2,3,4,5,6,7,8,9,10 cases or else

probability expectation


Selected Answer

1 * P(first = 6) + 2 * P(second = 6) + ... 10 *P(first nine ! = 6)

= 1 * 1/6 + 2 * 5/6*1/6 + ... + 9 * (5/6) 81/6 + 10*(5/6) 9

The first 9 terms form an Arithemtico-geometric progression and we can find the sum using the formula given here:

https://en.wikipedia.org/wiki/Arithmetico-geometric_sequence

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1702 of 2244

Or, we can sum them individually. Answer comes out to be 3.0928 and adding the last term gives 5.03

 2 votes -- Arjun Suresh ( 124125 points)

15.11 Expectation: Probability Expectation top gateoverflow.in/33590

Out of 2000 families with 4 children each how many families would you expect to have atleast one BOY..?

probability expectation


Selected Answer

This could be solved using Binomial Distribution...

Assumption :
P ( Boy Child) = P ( Girl Child ) = 1/2

Solution :

P( atleast one Boy) = 1-p(no Boys )

= C(4,0) (1/2) 0 (1/2)4

= 1- 1/16

= 15/16

Therefore Expectation of 2000 Families

E(X) = 2000* 15/16

= 1875

 2 votes -- Akhil Nadh PC ( 1967 points)

15.12 Expectation: expectation top gateoverflow.in/31072

A fair coin is tossed repeatedly till both head and tail appear atleast once. Average no of tosses required is ?

gate-ec-2014 expectation

Answer is 3

For n=2 p(x)=1/2ie HT TH)

For n=3 p(x)=1/4 ie (HHT and TTH)

So for n=k p(x)=1/2^(n-1)

Let S be E(x)

S=2*1/2+4*1/4+8*1/4......

This is agp series

Solving this we get

S=3

 0 votes -- Pooja ( 22773 points)

15.13 Expectation: What is expected value of the sum of the numbers

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1703 of 2244

appearing on two fair dice when they are rolled ... top gateoverflow.in/4629

What is expected value of the sum of the numbers appearing on two fair dice when they are rolled given that the sum of
these numbers is at least nine. That is, what is E(X|A) where X is the sum of the numbers appearing on the two dice and A
is the event that X ≥ 9?

probability expectation


Selected Answer

Given sum is at least 9. So, the possible cases are (4, 5), (5, 4), (3, 6), (6, 3), (5, 5), (4, 6), (6, 4), (5, 6), (6, 5) (6, 6)
and all of these are equally likely.

So, probability of each is 1/10

Probability of sum = 9 = 1/10 + 1/10 + 1/10 + 1/10 = 2/5


Probability of sum = 10 = 3/10
Probability of sum = 11 = 2/10 = 1/5
Probability of sum = 12 = 1/10

Therefore, expected sum = 9 * 2/5 + 10 * 3/10 + 11 * 1/5 + 12 * 1/10 = (36 + 30 + 22 + 12) / 10

= 10

 4 votes -- Arjun Suresh ( 124125 points)

15.14 Independent Events: How to identify an Independent Event top gateoverflow.in/33561

In a well shuffled deck of 52 cards


E : The card drawn is black

F: The card drawn is King

Is above Event Independent or Not . Please explain me how to find it out ?

My Understanding

Method 1 :

Independent events are events whose sample space of Happening will never overlaps

There for the there are 2 kings which are black in a deck so the above problem is NOT INDEPENDENT

Method 2

P( getting Black Card ) = 26/50 = 1/2

P( getting King ) = 4/52 = 1/13

P(Black and King)= 2/52 = 1/ 26

According to condition of independent Events


P( getting Black ) P( King ) = P( Black INSERSECTION King) = 1/2 * 1/13 = 1/26

Therefore the above problem IS INDEPENDENT

Which is Correct Approch ....? Pls Help me...

probability independent-events


Selected Answer

Method 2 is right.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1704 of 2244

Consider an example, of flipping two fair coins at two different places.

Bh : Head appeared on the coin flipped at Bangalore.

Bt : Tail appeared on the coin flipped at Bangalore.

Ph : Head appeared on the coin flipped at Pune.

Pt : Tail appeared on the coin flipped at Pune.

As the both coins being used at Pune & Bangalore are fair,

P(Bh) = P(Bt) = 1/2 and

P(Ph) = P(Pt) = 1/2.

The probability of getting head at both the places =

P(Bh ∩ Ph).

But since the result of coin flip at on location is not going to affect the result at other location, they are independent.

so P(Bh ∩ Ph) = P(Bh)xP(Ph) = (1/2)x(1/2) = 1/4.

but here it can be observed drom the diagram below that, these two events (Bh & Ph) are having overlapping sample
spaces:

Hence,

"Independent events are events whose sample space of happening never overlaps."

This is not a correct argument.

Disjoint sample spaces of the two events tells us that the events are mutually exclusive.

And if any two events are mutually exclusive then they are highly dependent because occurrence of any one event
immediately tells us the non occurrence of other event.

Also if A & B are two mutually exclusive events,

then A ∩ B = null.

so P(A ∩ B) will always be 0.

but if both P(A) & P(B) are non zero then P(A) x P(B) will never be equal to 0.

So A & B are not independent, if they are mutually exclusive and both of them having non zero probabilities.

 1 votes -- Anurag Pandey ( 8183 points)

15.15 Made Easy_test Series: FST -10 q-65 madeeasy testseries top gateoverflow.in/38337

Let X be a random variable as shown in the figure below

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1705 of 2244

If it is quantized by a two bit quantizer such that all the levels are equiprobable then the mean square value of the output of
the quantizer is ______________ V.

made-easy made-easy_test-series engineering-mathematics probability random-variable

15.16 Mode: Distribution (mean mode median) top gateoverflow.in/32425

what is positively skewed ,symmetric and negatively skewed distribution?

mean mode median distribution

mode<median<mean --- > positively skewed distribution

mode>median>mean --> Negatively skewed distribution

density of the curve is same to the left as to the right(as in case of Normal distribution) it is symmetric distribution.

https://probabilityandstats.wordpress.com/2015/05/09/the-skewness-of-a-probability-distribution/

 2 votes -- bahirNaik ( 2479 points)

15.17 Modular Arithmetic: Probability top gateoverflow.in/26754

Let X be uniformly distributed on {0, 1, 2…32}. What is probability of choosing x ∈ X such that 3x + 12 ≅ 0 (mod 33)?

probability modular-arithmetic


Selected Answer

I believe 11 should be the correct answer.

3x + 12 ≅ 0 (mod 33), where x ∈ {0, 1, 2…32}, can be written as following three equations:

3x + 12 = 33
3x + 12 = 66
3x + 12 = 99

On solving the above three equations we get x = 7, 18, 29 respectively.

So we have to calculate P x = 7 or x = 18 or x = 29 ,( )
which is same as P(x = 7) + P(x = 18) + P(x = 29).

Since random variable x is uniformly distributed over all of its 33 values, the value of P(x = 7) + P(x = 18) + P(x = 29) will be:

1 1 1
33 33 33
+ +

Hence

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1706 of 2244

(
P x ∣ 3x + 12 ≅ 0 (mod 33) )
= P(x = 7) + P(x = 18) + P(x = 29)

1
= 11

 2 votes -- Anurag Pandey ( 8183 points)

numbers which satisfy condition 3x+12congurent 0(mod33) & which are in {0,1,2,,,,,32} are {7,18,29}
Probability = 3/33 = 1/11

 2 votes -- Pinky Choudhary ( 69 points)

15.18 Pgee: Probability PGEE top gateoverflow.in/41618

What is the chance that a leap year selected at random will contain 52 Sundays?

a. 1

b. 3/7

c. 1/7

d. 2/7

pgee numerical-ability probability


Selected Answer

The question asks for "contain 52 Sundays" which means at least 52 Sunday. Any year whether leap or not will contain
365
7
= 52 Sundays. So, our answer is

1.

Now, suppose the question is exactly 52 Sundays- meaning 53 Sundays is not favorable:

A leap year has 366 days.

So, no. of complete weeks = 366/7 = 52.

No. of remaining days = 366 mod 7 = 2.

So, we have 52 Sundays for sure and have 2 extra days. As per question we dont want the 2 of them to be Sundays. We
have 7 choices for the 2 days

SM, MT, TW, WT, TF, FS, SS

All of these are equally likely (random choice of leap year) and 5 among these are favorable. So, our required probability
will be

5
7
.

A catch for my explanation:


http://math.stackexchange.com/questions/652803/what-is-the-probability-that-a-leap-year-selected-at-random-will-
contain-53-tues

 4 votes -- Arjun Suresh ( 124125 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1707 of 2244

15.19 Probability: why is it true that 3 events are pairwise independent but
not as a whole ? top gateoverflow.in/26815

Let a ball be drawn from a bag containing 4 balls ,numbered 1 to 4 and events are defined like :

E={1,2 }

F={1,3}

G={1,4}

now these 3 events are pairwise independent but as a whole P(E∩F ∩G) ≠ P(E)*P(F)*P(G)

why is this so and why even they are pairwise independent since ball no 1 is common so if I take two events say E and F
then if E occurs and I had drawn ball 1 so then will it not affect the probability of event F since now for event F to be
happening we will be left with ball 3 only so then why are these even pairwise independent ?

probability

See this
http://gateoverflow.in/33561/how-to-identify-an-independent-event#a33570

 0 votes -- Akhil Nadh PC ( 1967 points)

15.20 Probability: How to prove that none of the three events are
independent ? top gateoverflow.in/26837

If I have 3 events A,B and C such that all 3 are independent , then how to prove that P(A' ∩ B' ∩ C') is also independent , for
this

P(A' ∩ B' ∩ C') =1- P(A∪ B ∪C)

=1-[ P(A)+P(B)+P(C)- P(A∩B)-P(A∩C)-P(B∩C)+P(A∩B∩C) ]

=1- [ P(A)+P(B)+P(C)-P(A)P(B) -P(A)P(C) -P(B)P(C) +P(A)P(B)P(C) ]

=1-[P(A)+P(B)+P(C) -P(A)P(B)-P(A)P(C)-P(A')P(B)P(C) ]

=1 -[P(A)+P(C)+P(A')P(B)-P(A)P(C)-P(A')P(B)P(C) ]

=1-[P(A)+P(A')P(C)-P(A')P(B) -P(A')P(B)P(C) ]

=P(A') -P(A')P(C) +P(A')P(B) +P(A')P(B)P(C)

=P(A')P(C') +P(A')P(B)+P(A')P(B)P(C)

Now after this I am unable to get the actual result which I should be getting for proving that even this (A' ∩ B' ∩ C') is also an
independent event , so plz clarify this .

probability

if A, B, C are independent events, P(AnBnC)=P(A)P(B)P(C)

=> A',B',C' are also independent events. since P(A)'=1-P(A)

hence P(A'nB'nC')=P(A)'P(B)'P(C)'.

 0 votes -- Vikranth Inti ( 239 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1708 of 2244

15.21 Probability: How to find probability from given sample space ? gateoverflow.in/26921

top

In answering on a multiple choice test, a student either know the answer or guesses. Let p be the probability that the students knows the answer and 1-p
be the probability that the student guesses. Assume that a student who guesses at the answer will be correct with probability 1/m, where m is the number
of multiple choice alternatives. what is the probability that he answers the question correctly ?

In this ques sample space will be { KC ,GC ,GI}

K= knowing answer , C = answer is correct , G= guesses the answer , I=Incorrect answer

My confusion is that in the question P(K)=p but shouldn't it be 1/3 since we have 2 mutually exclusive events here

1. Knowing and answers correctly in one set, so P(K)=1/3

2. Guessing the answer which may be correct or incorrect , so P(G)=2/3

why is it p in the question ?

probability

"If the student guesses then he does not know the answer & if the student knows the answer then he is not going to
guess."

So yes P(K) and P(G) are mutually exclusive events, since only one of them can happen at a time.

But given P(K) and P(G) are mutually exclusive events, the only fact you can guarantee here is

P(K)⋂ P(G) = 0 and nothing more.

You can not infer the exact values of P(K) and P(G) from their mutual exclusiveness.

It would be something like:

you have two sets A & B, and it is given that

A ∪ B = 1 and A ∩ B = 0.

What can you say about sets A & B ?

From (A ∪ B) = A + B + (A ∩ B)

we can say that, A + B = 1

Clearly we can not conclude from this equation that what will be the individual values of A & B.

But one thing about which you are sure is if you know the cardinality of A(say the cardinality of A is x), then you can find
the cardinality of B(it will be (1 − x)), and vice versa.

Similarly here with the given information about P(K) and P(G) you can only say that

P(K) + P(G) = 1

Which shows that events K and G are totally exhaustive, that is the student MUST attempt the question no matter whether
his answers is correct or incorrect but he can not leave it unattempted.

Coming to the answer of the original question, Umang is right.

In your conventions,

P(KC) = p,

P(GC) = (1 − p) ⋅ m , since out of m choices only one is correct.


(m−1 )
m
P(GI) = (1 − p) ⋅ , since (m − 1) are incorrect out of m choices.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1709 of 2244

P(KC ) +P(GC )

P(C) = P(KC ) +P(GC ) +P(GI)

but P(KC) + P(GC) + P(GI) = 1

Hence the probability that he answers the question correct would be

P(C) = P(KC) + P(GC) = p + (1 − p) ⋅ m

 0 votes -- Anurag Pandey ( 8183 points)

15.22 Probability: How to solve below question on probability ? top gateoverflow.in/27611

A group consists of equal no of men and women .of this grp 20% of men and 50% of women are unemployed .If a person is
selected at random from this group ,the probability of the selected person being employed is ____________

For this I did

P(E)=P(M∩ E) +P(W∩ E) where U and E are for employed and unemployed ,Now P(M)=P(W)=1/2

Now P(E/M)= 0.8 and P(E/W)=0.5

so we get

P(E)= 1/2 * 0.8 +1/2*0.5 =13/10

where is the mistake , answer given is 65% .

probability

P(employed)=1-P(not employed)

P(not employed)=0.5*0.5+0.5*0.2=0.35

Therefore probability of selecting employed person=1-0.35=0.65

 1 votes -- Pooja ( 22773 points)

15.23 Probability: coin top gateoverflow.in/31070

A fair coin is tossed n times .find probability of difference between head and tails is n-3

probability easy

if n=2 S={HH,HT,TH,TT} difference is 0 ,2 so n-3 ie -1 not possible

if n=3 S={HHH HHT HTH HTT THH THT TTH TTT}

here difference is 3,1, and n-3 =0 not possible

for n= even n-3 is odd and difference between head and tail will be always even

for n= odd n-3 is even and difference between head and tail will always odd

so probability=0

 1 votes -- Pooja ( 22773 points)

15.24 Probability: Probability:You are given a deck of fifty two cards which
have printed on them a pair of symbols top gateoverflow.in/27919

You are given a deck of fifty two cards which have printed on them a pair of symbols: an integer between 1 and 13, followed by one of the letters “S,” “H,” “D,” or
“C,” There are 4 × 13 = 52 such possible combinations, and you may assume that you have one of each type, handed to you face down.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1710 of 2244

(a) Suppose the cards are randomly distributed and you turn them over one at a time. What is the average cost (i.e. number of cards turned over) of finding the card
[11,H]?

(b) Suppose you know that the first thirteen cards have one of the letters “H” or “D” on them, but otherwise all cards are randomly distributed. Now what is the
average cost of finding [11,H]?

probability algorithms

(a)[11,H] it is a perticular card

So, min no of turn to get it could be first turn i.e.=1

max no. of turn to get it could be the last turn i.e.=52

Here we will take avg turn i.e. 1+52/2 =26.5

(b)If first 13 cards have H in all then avg. turn will be 13+1/2=7

if first 13 cards have D in all then avg. turn will be 39+1/2 =20

 0 votes -- srestha ( 11585 points)

15.25 Probability: How to find probability of getting two heads from a set of
fair and unfair coins ? top gateoverflow.in/26923

I have 4 fair and 3 unfair coins ,now I am chosing 2 coins what is the probability of getting 2 heads ,Now I am confused
while calculating P(FU) i.e. probability that I chose 1st fair coin and then chose 2nd coin as unfair coin

According to me P(FU)= P(F)*P(F/U) = 4/7 * 3/ 6 since after I chose a fair coin , then will have remaining 6 choices , so
what's the issue in this , then using total probability I can calculate

P(HH)=P(FF∩HH) +P(FU∩HH)+P(UU∩HH)

=P(FF)*P(HH/FF) +P(FU)*P(HH/FU) +P(UU)*P(HH/UU)

P(FF)=2/7 ,P(UU)= 1/7 other things are also stated ,only issue is with this P(FU ) , even it could be P(UF) but what's the
issue since both would be same only .

probability

HERE IS THE ANSWER... let Ph and Pt be the probability of unfair coin.

then 4C2/7C2[(0.5)(0.5)]+3C2/7C2[(Ph)(Ph)]+(4C1*3C1)/7C2[(0.5)*(Ph)]

 0 votes -- Deepesh Kataria ( 1207 points)

15.26 Probability: Probability top gateoverflow.in/43127

A bag contain 4 white and 5 black balls and another bag contain 3 white and 4 black balls . A ball is taken out from the first
bag and without seeing its colour is put in second bag .A ball is taken out from the latter . Find the probability that ball
drawn is white ?

probability


Selected Answer

BAG A : 4 white and 5 black balls


BAG B : 3 white and 4 black balls

Select a Black Ball from BAG A and put it into BAG B. Now select a white Ball from BAG B. (5C1/9C1)*(3C1/8C1) = 15/72
Select a White Ball from BAG A and put it into BAG B. Now select a white Ball from BAG B. (4C1/9C1)*(4C1/8C1) = 16/72

Probability = 15/72 + 16/72 = 31/72

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1711 of 2244

 3 votes -- Digvijay Pandey ( 26245 points)

15.27 Probability: probability top gateoverflow.in/19730

a fair coin is tossed 10 times ,wt is the probability that head will come up in first two toss of coin??

probability


Selected Answer

"a fair coin is tossed 10 times ,wt is the probability that head will come up in first two toss of coin "

We do not even need to consider remaining tosses.

So Total Set of outcomes of First 2 tosses is = { HH,HT,TH,TT}

Required outcome = {HH}

Answer -> cardinality {HH} / cardinality {HH,HT,TH,TT} = 1/4 = 0.25

 1 votes -- Akash ( 26315 points)

No of way(s) to fillFirst two places = 1

Rest tosses may result Head or Tail = 2*2*2*.......2 = 2^8 = 256

Total sample space = 2*2*2.....*2 = 2^10 = 1024

P (1st two tossesresult Head) = 256/1024 = 1/4 = 0.25

 4 votes -- Digvijay Pandey ( 26245 points)

15.28 Probability: Probability top gateoverflow.in/17683

A pair of dice is rolled again and again till a total of 5 or 7 is obtained. The chance that a total of 5 comes before a total of 7
is

probability


Selected Answer

Prob of 5 = 4/36 = 1/9 Prob of 7 = 6/36 = 1/6 Prob of 5 and 7 will not occur = 1 - (1/9 + 1/6) = 13/18

and now 5 will occur before 7 is

p = 1/9 + (13/18)(1/9) + (13/18)^2(1/9) + (13/18)^3(1/9) + ...

= (1/9)[1 + 13/18 + (13/18)^2 + (13/18)^3 + ...... ]

= (1/9)/[1 -13/18] (infinite series)

= (1/9)/(5/18)

= 2/5 (ans)

 0 votes -- Pranay Datta ( 6113 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1712 of 2244

15.29 Probability: Probability top gateoverflow.in/20470

It is known that screws produced by a certain company will be defective with probability 0.01 independently of each other.
The company sells the screws in package of 10 and offers a replacement guarantee that at most 1 of the 10 screws is
defective. What proportion of packages sold must the company replace?

Answer given is 0.04

probability

The probability that a screw is defective (screwed :P) is 0.01, independently. Thus, probability of a screw not being
defective is (1 − 0.01) = 0.99

The company offers a guarantee that in any pack of 10, at most one is defective. That means, if there are more than one
defective screws in your pack, the company will replace it.

The probability that there is more than one defective piece in a pack of 10 screws can be calculated as:

P ( more than
one defective ) = 1− ((
P zero
defective ) (
+ P one
defective ))
(10 × 0.01 × 0.99 ) 9


choose 1 screw out of 10

(( )
0.01 = P(1 defective screw )

= 1− 0.9910 )+ 0.99 9 = P(9 fine screws )

≈ 1 − 0.99573

P ( more than
one defective ) ≈ 0.00427

 2 votes -- Pragy Agarwal ( 13675 points)

Packet will be returned if at-least 2 defective screws are found in the packet.

since probability of being defective does not depend on the other : This case can be solved by Binomial Distribution with
n = 10

checking a screw in the packet (check for it being defective) is a trial and we have a total of n = 10 such trials. each trial is
independent of the other.

Let, x = # of defective screws in the packet.

Then we need to calculate

where, p = probability of success(here, which is being defective, coz we have defined x like that) = 0.01

so,

and

which imply

 1 votes -- Amar Vashishth ( 17865 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1713 of 2244

15.30 Probability: Probability Distribution top gateoverflow.in/43157

A coin is tossed untill a Head appears or the Tail appear 4 time in succession . Find the probability distribution of number of
tosses ?

probability

yes Correct { H , TH , TTH, TTTH, TTTT }

P(x=1)=1/2 (p(H))

P(x=2)=1/4 p(TH)

P(x=3)=1/8 p(TTH)

P(x=4)=1/8 p(TTTH,TTTT)

∑p(x)=1

 1 votes -- Manojk ( 3365 points)

15.31 Probability: Basic Probability top gateoverflow.in/26251

out of 2n+1 tickets consecutively numbered 3 are drawn at random . Find the probability that number on them are in AP ?

probability


Selected Answer

lets take simple string n=5 : 1 2 3 4 5 6 7 8 9 10 11


Total combination = 10C3
if i select 1 as first number then total combination = 123 , 135 , 147 , 159 ,1611 = n combination
if i select 2 as first number then total combination = 234 , 246 , 258 ,2610 = n-1 combination

General way
The total number of combination (2n+1C3)

If 1 is slected total number of combination n
If 2 is slected total number of combination n-1
If 3 is slected total number of combination n-1
.
.
.
If (2n-2) is selected total number of combination 1( i.e. 2n-1 2n 2n+1)
If (2n-2) is selected total number of combination 1( i.e. 2n-2 2n-1 2n)

(n −1 ) (n −1 +1 )
2
So total number of combination = n+ n-1 + n-1 + n-2 + n-2+ ..............+ 1 + 1 = n + ∗2
So probability = n^2/(2n+1C3)

 2 votes -- Umang Raman ( 10379 points)

2n+1C3 is total selection..


number of groups (with common difference d =1) = 2n-1
number of groups (with common difference d =2) = 2n-3
number of groups (with common difference d =3) = 2n-5
....
....
number of groups (with common difference d =n) = 1

Total number of group = 1+2+3+4+5..........+(2n-1)


= sum of first n odd numbers = n*n // sum of first n odd numbers = n*n : it is Identity

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1714 of 2244

required Probability = n*n/ (2n+1C3) = 3n/(4n*n-1)


 3 votes -- Digvijay Pandey ( 26245 points)

15.32 Probability: probability top gateoverflow.in/25617

from a well shuffled pack of 52 cards. Three cards are drawn at random. Find the probability of drawing an ace, a king and a
jack,

a) 16/5525

b) 16/625

probability


Selected Answer

Number of ways of choosing an Ace=( 1 )


4

Number of ways of choosing a King=( 1 )


4

Number of ways of choosing a Jack=( 1 )


4 4 4
1
the number of ways of choosing an Ace, a King and a Jack would be=( ) *( ) * ( 1 )= 64
1

52
3
Number of ways of choosing 3 cards from a pack of 52 cards is = ( ) =22100
64 16
22100 5525
So the probability of drawing an Ace, a King and a Jack = =

Hence (a) is the Answer.

 2 votes -- Leen Sharma ( 2935 points)

15.33 Probability: Independent Events top gateoverflow.in/43096

Two cards are drawn from a well shuffled pack of 52 cards without replacement . What is probability one is red queen and
other king is of black colour ?

probability


Selected Answer

Two Black King and two Red Queens.

Now Select one Queen out of two Red Queen i.e. 2C1 ways
Select one Black King out of Two Black King i.e. 2C1 ways.

Sample Space = 52 C2

Probability = 2C1*2C1 / 52 C2 = 2/663

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1715 of 2244

 1 votes -- Digvijay Pandey ( 26245 points)

15.34 Probability: 52 cards are equally given to 4 players Find probability


that one of them has 3 spades out of remaining 5. top gateoverflow.in/31893

52 cards are equally given to 4 players a,b,c,d. a and b have together total 8 spades among them. Find probability that c
has 3 spades out of remaining 5.

In this ques , sample space reduces to 44 cards , so is the answer 5C3 * 39C10 /44C13 Correct ?

probability


Selected Answer

a and b together have 26 cards so 26 cards are left.

Since a and b together have 8 spades so 5 spades are remaining.

Now with remaining 26 cards there are 5 spaces so 21 non-spades.

For c to have exactly 3 spades,


5C
3 --> to have 3 spades of remaining 5

21C
10 --> to have other 10 non-spades

This makes a total of 13 cards

So probability is
5C 21C
3. 10
26C
13

PS: For at least 3 spades probability would be

5C 21C + 5 C4 . 21C9 + 5 C5 . 21C8


3. 10
26C
13

 3 votes -- Abhishekcs10 ( 1001 points)

15.35 Probability: Explain why incorrect? top gateoverflow.in/36487

answer = option C

but why?

what does with replacement mean? please verify

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1716 of 2244

probability engineering-mathematics


Selected Answer

By replacement we mean the same coupon once remove can be put back into the set.

For 9 to be the largest of the seven coupons the selected coupons must be between 1 and 9

so 9^7 possibilities. But this way it is also possible that 9 isnt selected even once. So out of 9^7 we need to remove all
those cases where 9 isnt present, which means the numbers are selected only between 1 and 8.

so 9^7 - 8^7 cases are favorable.

hence c is the correct one

 2 votes -- Satyandra ( 253 points)

15.36 Probability: Probability top gateoverflow.in/36272

The probability of event A occurring is 0.5 and of B occurring is 0.3. If A and B are mutually exclusive events then the
probability of neither A nor B occurring is___

Solution : 0.2
P(A' UNION B' ) = 1- P(A UNION B)
1-0.8

= 0.2

My Solution : 1

P(A' UNION B' ) = P ( A INTERSECTION B )' using demorgans law


= 1- P ( A INTERSECTION B )

= 1 - 0 ( mutually exclusive )

=1

Which is the correct approach . Please Help

probability

"neither A nor B" means "A doesn't occur AND B also doesn't occur".
ie P(A' INTERSECTION B')
=P(A UNION B)'
=1- P(A UNION B)
=1-(P(A)+P(B))
= 1-0.8 =0.2

What you have taken "P(A' UNION B' )" is "A doesn't occur OR B doesn't occur".

 0 votes -- Tehreem Ansari ( 1327 points)

15.37 Probability: probability top gateoverflow.in/42878

A police man fires four bullet on a dacoit . The probability that dacoit will be killed by one bullet is 0.6 .what is prob that
dacoit is still alive ?

probability

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1717 of 2244


Selected Answer

probability that he will not be dead by any bullet is (4/10) 4

Sample space will be MMMM = (4/10) 4

 2 votes -- srestha ( 11585 points)

0.4x0.4x0.4x0.4

 1 votes -- Amit Gupta ( 33 points)

15.38 Probability: PROBABILITY_13th King top gateoverflow.in/37236

From a well shuffled deck of 52 cards, cards are dealt. The probability that the 13 th card is the first king to be dealt is
____________ × 10–1.

probability

For 13th card to be the first king.--->


48

n(E)= ( 12 ) ∗ 4 (first 12 card are non king i.e. 12 out of 48 and 13th is 1 out of 4 kings)

52

n(S)= ( 13 )

therefore probability =n(E)/n(S)

=0.43885=4.3885 *10 −1

 2 votes -- Abhishekcs10 ( 1001 points)

15.39 Probability: probability of B's winning top gateoverflow.in/37410

A and B throwing unbiased dice alternatively.Whoever throws a number >= 5 first wins. If A throws the dice first then
probability of B's winning the game is _______.

probability

Let ~a denote the probability that player A does not throw >=5 and a denote the probability that player A throws >=5.
Consider similar notation for player B as well.

Any player wins if he gets 5 or 6. Probability of getting 5 or 6 is 2/6 = 1/3. Probability of not getting 5 or 6 = 2/3

Considering first turn is played by A, B wins if :

~a*b + ~a*~b*~a*b + ......

=2/3 * 1/3 + 2/3 * 2/3 * 2/3 * 1/3 + ....

This forms a GP and sums to be 2/5.

 1 votes -- Gaurav Sharma ( 1383 points)

15.40 Probability: Two cards are drawn together from a pack of 52 cards.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1718 of 2244

The probability that one is spade and other is king is ? top gateoverflow.in/39093

I did it from conditional probability , first case when we pick one spade first and then pick king next

so it is equal to ,probability of picking up a spade*probability of picking a king given that we have already picked up a spade so it is equal to 13/52 * 1/51

And then probability of picking up a king and a spade =probability of picking up a king *probability of picking up a spade given that we have already picked up a king
which is equal to 4/52 * 12/ 51

Now summing up both of these I get the answer

=61 / 52*51 =0.023

What is wrong in this method ?

probability


Selected Answer

13 spades

we need to select 2 cards having one spade and one king

here king can be spade also

{(12c1 * 1c1)(both the cards from spade) +(13c1 * 3c1)(king from another sets)} / 52c2

 2 votes -- Gabbar ( 469 points)

One (King (not spade)) other is Spade + One( king spade ) One more for Spade

(3C1*13C1 + 1*12C1)/52C2 =1/26

 1 votes -- Digvijay Pandey ( 26245 points)

15.41 Probability: Probability top gateoverflow.in/38303

probability

15.42 Probability: Independents Events top gateoverflow.in/43066

If A and B are 2 independents events such that P(A' ⋂ B) = 2/15 and P (A⋂B') = 1/6 . find P (B)

probability


Selected Answer

Ans 4/5 or 1/6

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1719 of 2244

 2 votes -- Manojk ( 3365 points)

15.43 Probability: Probability Distrubution top gateoverflow.in/43253

From a lot containing 25 items , 5 are defective and 4 are chosen at random . Let X be the numbers of defective found
.Obtain the probability distribution of X if item are choosen without replacement ?

probability

15.44 Probability: What is the chance that a leap year selected at random
will contain 52 Sundays? top gateoverflow.in/42317

What is the chance that a leap year selected at random will contain 52 Sundays?

probability


Selected Answer

total no of days in leap year is =366

so 366/7=52.29 which means 52 complete weaks so 52*7=364 days so last 2 days are remainingit can be

mon&tue , tue&wed, wed&thur, thur&fri, fri&sat, sat&sun , sun&mon and we want

p(52 sunday)=all pair expect those having sunday bcz we want 52 sunday/TOTAL PAIR

so ans is 5/7

 3 votes -- rajan ( 1287 points)

@srestha --- Look this

In a leap or non leap year you any ways have 52 week . so 52 week will cover will 52 sundays so prob 1 ;

In a non leap year it is ( 52*7 + 1)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1720 of 2244

In a leap year it is (52*7 + 2)

Bdw for the above answer : if they would have asked 53 sundays in a non leap year it would have been 2/7

 1 votes -- Dexter ( 1933 points)

with "contains 52 sundays" it means atleast 52 sundays.


every year (normal or leap year) contain 52 weeks therefore 52 sundays.
so probablity is 1.

 1 votes -- Arpit Tripathi ( 169 points)

15.45 Probability: How to solve below question on probability ? top gateoverflow.in/40973

probability


Selected Answer

1
6
should be the correct answer.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1721 of 2244

 4 votes -- Anurag Pandey ( 8183 points)

15.46 Probability: probability top gateoverflow.in/32531

Three numbers are chosen at random without replacement from {1, 2, 3, . . . . . , 10}. What is the probability that minimum of the
chosen numbers is 3 or their maximum is 7?

11

a. 30
11

b. 40
1

c. 7
1

d. 8

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1722 of 2244

probability engineering-mathematics


Selected Answer

Ans is (B) 11/40

it can be solved by inclusion exclusion principle.

P(A ⋃ B) = P(A) + P(B) - P(A ⋂ B)

Suppose, P(A) = probability that minimum is 3 among chosen 3 numbers.

= 7C2/10 C3

For this 3 is already taken with no choice and for remaining 7C2 is total number of ways to choose 2 numbers more than 3
(i.e. 4,5,6,7,...10) from given set.

P(B) = probability that maximum numbers is 7 among chosen 3 numbers

= 6C2/10 C3

For this 7 is already taken with no choice and for remaining 6C2 is total number of ways to choose 2 numbers less than 7
(i.e. 0,1,2,.....6) from given set.

P(A ⋂ B) = probability that minimum number is 3 and maximum is 7 among chosen 3.

= 3C1/10 C3

For this 3 & 7 is already taken with no choice and for remaining 3C1 is total number of ways to choose 1 number more
than 3 and less than 7 (i.e. 4,5,6) from given set.

Now the probability that minimum is 3 or maximum is 7 among chosen 3 numbers i.e. P(A ⋃ B) .

P(A ⋃ B) = P(A) + P(B) - P(A ⋂ B)

= 7C2/10 C3 + 6C2/10 C3 - 3C1/10 C3

= (7C2 + 6C2 - 3C1)/10 C3

= (21 + 15 - 3) / 120

= 33/120

= 11/40

 3 votes -- Sandeep Singh ( 5939 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1723 of 2244

favourable events from which we need to choose two more when 3 minimum is already chosen = {4, 5, 6, 7, 8, 9, 10}

similarly, favourable events from which we need to choose two more when 7 maximum is already chosen = {1, 2, 3, 4, 5,
6}

7 6 3

(2 ) + (2 ) − (1 )
10

required probability =
(3)
21 + 15 − 3
120
=
33
= 120
11
40
=

 1 votes -- Amar Vashishth ( 17865 points)

15.47 Probability: Probablity: A bag Contains top gateoverflow.in/32747

probability engineering-mathematics

Since the balls are put back with replacement, the probability will not change.

P(G) - probability for green ball | P(B) - probability for blue ball

P(G) = x/(x + y) | P(B) = y/(x + y)

M wins the game if either he draws in the first turn, or he draws a blue and N also draws a blue and then he draws a green
in his turn. Thus, we will get a series like this :

P(M) = P(G) + {1 - P(G)} * {1 - P(G)} * P(G) + ...

Also given, P(M) : {1 - P(M)} = 2 : 1

which gives P(M) = 2/3

Using the above values, we put in the series and we get the relation.

 2 votes -- Utk ( 1385 points)

P(M winning)=P(G)+(1-P(G)(1-P(G)P(G)+........ (infinite gp)

=x/(x+y)+y/(x+y) y/(x+y) x/(x+y).....

=x (1/1-r) where r=( y/(x+y)) 2

=x (x+y)/x 2+2xy+y2-y2

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1724 of 2244

=x+y/x+2y

it is given that is equal to 2/3

x+y/x+2y=2/3

x=y

so ans is b

 1 votes -- Pooja ( 22773 points)

15.48 Probability: Probability basics top gateoverflow.in/43810

From a pack of 52 cards , 4 cards are drawn . Find the probability that they are the 4 honours of same suit ?

probability

15.49 Probability: Find the probability top gateoverflow.in/44211

If 6 out of 10 people have their birthday in the 4 months of the year between February and May inclusive,then What is the
probability is the next person has also his or her birthday in this 4 months?

probability

Selecting 4 months out of 12 months = 4/12

Now already 6 people we have taken

Among last 4 people we have to select 1 people=1/4

So probability is 4/12*1/4=1/12

 1 votes -- srestha ( 11585 points)

15.50 Probability: Independents Events top gateoverflow.in/43077

Three cards are drawn with replaacement from a well shuffled back of cards . Find the prob that cards drawn are King queen
and jack ?

probability

here event are independents then if event are independent p(AnB)=p(A).p(B)

here also same scenerio P(KING n QUEEN n JACK)=P(king).p(queen).p(jack). bt here also card order is matter means
J,Q,K can be arranged in 6 ways

means in 3! ways so i think amswer will be

3!*(4/52*4/52*4/52) then we got 6/2197 .

 0 votes -- rajan ( 1287 points)

15.51 Probability: probability question top gateoverflow.in/25823

For the three events A, B, and C, P (exactly one of the events A or B occurs) = P (exactly one of the two events B or C
occurs) = P(exactly one of the events C or A occurs) = p and P (all the three events occur simultaneously) = p2 , where
1

0 < p < 2 . Then the probability of at least one of the three events A, B and C occuring is

probability

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1725 of 2244


Selected Answer

Let P(Ao ) denote probability of only A and similarly for B, C.

P(Ao ) + P(Bo ) = p = P(A) − P(A ∩ B) + P(B) − P(A ∩ B) = P(A) + P(B) − 2P(A ∩ B)

Similarly,

P(Bo ) + P(Co ) = P(B) + P(C) − 2P(B ∩ C) = p

P(Co ) + P(Ao ) = P(C) + P(A) − 2P(C ∩ A) = p

Also, P(A ∩ B ∩ C) = p2 .

¯
We want P(A ∪ B ∪ C)

P(A ∪ B ∪ C) = P(A) + P(B) + P(C) − P(A ∩ B) − P(B ∩ C) − P(C ∩ A) + P(A ∩ B ∩ C) = 3p/2 + p2

3p

So, required probability = 1 − 2 − p2

 2 votes -- Arjun Suresh ( 124125 points)

15.52 Probability: question on probability top gateoverflow.in/16067

Two aeroplanes I and II bomb a target in succession. The probability of I and II scoring a hit correctly are 0.3 and 0.2
respectively. The second plane will bomb only if the first misses the target.The probability that the target is hit by the
second plane ?

probability

Probability that the target is hit by the second plane means Target Hit and that bcoz of plane 2.

Target hit = 1- 0.7*0.8 = 1-0.56 = 0.44

Hit by 2nd plane = 0.2*0.7 = 0.14

So target hit by 2nd plane P = 0.14/0.44 = 0.318

 1 votes -- Digvijay Pandey ( 26245 points)

15.53 Probability: Probability top gateoverflow.in/16287

E1 and E2 are events in a probability space satisfying the following constraints p(E1)= p(E2);p(E1U E2) = 1; E1 & E2 are
independent then p(E1)=

probability

Given P(E1 U E2) = 1, P(E1) = P(E2), P(E1 intersection E2) = P(E2) * P(E2) (since E1 & E2 are independent).

Now by using inclusion exclusion principle, P(E1 U E2) = P(E1) + P(E2) - P(E1 intersection E2).

Let P(E1) = a, then P(E2) = a, and P(E1 intersection E2) = a * a. Putting all these values along with P(E1 U E2) = 1, leads
to a quadratic equation a^2 - 2a + 1.

This equation gives a = P(E1) = P(E2) = 1.

 0 votes -- Anurag Pandey ( 8183 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1726 of 2244

15.54 Probability: Suppose that the probability that x is in a list of n distinct


integers is 2/3 and that it is equally likely that x equals any element in the
list. top gateoverflow.in/4626

Suppose that the probability that x is in a list of n distinct integers is 2/3 and that it is equally likely that x equals any
element in the list. Find the average number of comparisons used by the linear search algorithm to find x or to determine
that it is not in the list.

probability


Selected Answer

(
Expected number of comparisons = ∑ni=1 number of comparison till ith entry × probability of getting the number at ith entry + 3 . n )
1

The last 3 n is for the case when x is not in the list.

Probability of x being in the list = 2/3

Since it is equally likely that x is any element in the list, probability that x is element i is 3n

So,

2 n n +1 n 2n +1

( )
Expected number of comparisons = ∑ni=1 i. 3n +3 = 3 +3 = 3

Now, there is a catch here. We have counted one comparison for one element in the linear list. But if we count the loop
exit condition and the final found or not check also as in the algorithm give here
http://www.programmingsimplified.com/c/source-code/c-program-linear-search, we get 2i + 1 comparisons for a successful
check at ith position and 2n + 2 comparisons if x is not in the list. This would give

2 (2n +2 ) 2.(n . (n +1 ) +n ) 2n +2 2n +4 2n +2 4n +6

(
Expected number of comparisons = ∑ni=1 (2i + 1). 3n
) + 3
= 3n
+ 3
= 3
+ 3
= 3

 0 votes -- Arjun Suresh ( 124125 points)

15.55 Probability: When m balls are distributed into n bins uniformly at


random, what is the probability that the first bin remains empty? top gateoverflow.in/4635

Answer: [(n − 1)/n] m

probability


Selected Answer

In the favorable case we have (n-1) choices for each of the m balls and the total number of choices for each ball is m. So,
probability

= [(n-1)/n]m

[Here first bin is fixed. Had it been any one bin being empty, answer would have been multiplied by nC1]

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1727 of 2244

 1 votes -- Arjun Suresh ( 124125 points)

15.55 Probability: A point in a circle is selected at random. Calculate


probability that point is closer to centre than circumference top gateoverflow.in/12693

probability

Favourable outcomes: The point should be nearer to center than from circumference, it means the point could be
anywhere within the radius r/2, = pie* (r/2)^2. Total possible outcomes: The point could be anywhere within the radius
r;=pie* r^2. Thus probability = area(r/2)/area(r) = 1/4.

 2 votes -- Anurag Pandey ( 8183 points)

The probability of this is simply π(r/2) 2/πr2 =1/4 = 0.25

 2 votes -- Pranay Datta ( 6113 points)

15.56 Probability: It is known that a bus will arrive at random at a certain


location sometime between 3:00 P.M. and 3:30 P.M. top gateoverflow.in/13201

It is known that a bus will arrive at random at a certain location sometime between 3:00 P.M. and 3:30 P.M. A man decides
that he will go at random to this location between these two times and will wait at most 5 minutes for the bus. If he misses
it, he will take the subway. What is the probability that he will take the subway?

probability


Selected Answer

the white area is our desire outcome and the total area is total outcome .

(0.5*25*25+30*30*0.5)/30*30=0.8472

 3 votes -- Pranay Datta ( 6113 points)

The bus and man can arrive in any time between 3:00 and 3:30.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1728 of 2244

Probability of man arriving before 3:25 = 5/6 as each 5 minute interval is equally possible for his arrival.

Probability of man arriving before 3:25 and catching the bus = 5/6 * 1/6 = 5/36 (as the probability for bus to come in any
non-overlapping 5 minute interval- 0-5, 1-6... is 1/6 as probability for bus arrival must be 1/6 for every consecutive 5
minutes out of 30 minutes).

Probability of man to come after 3:25 = 1/6

Probability of man coming after 3:25 and catching the bus = 1/6 * 1/6 *x = x/36, where x is the probability that man
comes first. Since both man and bus are equally likely to come first, x = 1/2, giving required probability = 1/72.

So, Probability that man catches the bus = 5/36 + 1/72 = 11/72.

Probability that he takes subway = 1 - 11/72 = 61/72 = 0.8472.

 3 votes -- Arjun Suresh ( 124125 points)

15.57 Probability: A player in the Powerball lottery picks five different


integers between 1 and 59, inclusive, and a sixth integer between 1 and 39
top gateoverflow.in/13425

A player in the Powerball lottery picks five different integers between 1 and 59, inclusive, and a sixth integer between 1 and
39, which may duplicate one of the earlier five integers. The player wins the jackpot if the first five numbers picked match
the first five number drawn and the sixth number matches the sixth number drawn.

a. What is the probability that a player wins the jackpot?


b. What is the probability that a player wins $200,000, which is the prize for matching the first five numbers, but not the
sixth number, drawn?
c. What is the probability that a player wins $100 by matching exactly three of the first five and the sixth numbers or four
of the first five numbers but not the sixth number?
d. What is the probability that a player wins a prize, if a prize is given when the player matches at least three of the first
five numbers or the last number.

probability combinatory

15.58 Probability: Suppose the probability that x is the ith element in a list of
n distinct integers is i/[n(n + 1)]. top gateoverflow.in/4633

Suppose the probability that x is the ith element in a list of n distinct integers is i/[n(n + 1)]. Find the average number of
comparisons used by the linear search algorithm to find x or to determine that it is not in the list.

probability


Selected Answer

Expected number of comparisons = sum((number of comparison till i th entry) * probability of getting the number at i th
entry) + n. probability that x is not in the list.
i 1

Probability that x is in the list = ∑ni=1 n . (n +1 ) = 2

So, probability of x not in the list = 2

Thus, Expected number of comparisons

i n i2 n 2n +1 n n . (n +1 ) . (2n +1 ) 5n +1

= ∑ni=1 n . (n +1 ) . i + 2 = ∑ni=1 n . (n +1 ) + 2
= 6
+ 2
∵ ∑ni=1 i2 = 6
= 6

Now, there is a catch here. We have counted one comparison for one element in the linear list. But if we count the loop
exit condition and the final found or not check also as in the algorithm give
h e r e http://www.programmingsimplified.com/c/source-code/c-program-linear-search, we get 2i + 1 comparisons for a
successful check at ith position and 2n + 2 comparisons if x is not in the list. This would give

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1729 of 2244

i 2n +2 2i 2 +i 2n +1 1 5n +4 1 10n +11

Expected number of comparisons = ∑ni=1 n . (n +1 ) . (2i + 1) + 2


= ∑ni=1 n . (n +1 ) + (n + 1) = 3
+ 2
+ (n + 1) = 3
+ 2
= 6

 1 votes -- suraj ( 3299 points)

15.59 Probability: The probability of solving a problem by three students


X,Y,Z are 1/4,3/7and 2/9 respectively. if all of them try independently then
the probability that the problem could not be solved is a)1/3 b)1/4 c)1/5 d)
2/5 e) 3/7 top gateoverflow.in/5128

Ans given is 3/7.


Mine is 1/3.
Approach: P(~X)P(~Y)P(~Z)= 3/4 * 4/7 * 7/9 = 1/3

probability

Sahil, your answer is right.

 1 votes -- Krishna Murthy ( 21 points)

15.60 Probability: February 29 occurs only in leap years. Years divisible by 4,


but not by 100, are always leap years. top gateoverflow.in/4605

February 29 occurs only in leap years. Years divisible by 4, but not by 100, are always leap years. Years divisible by 100, but
not by 400, are not leap years, but years divisible by 400 are leap years.

a) What probability distribution for birthdays should be used to reflect how often February 29 occurs?

b) Using the probability distribution from part (a), what is the probability that in a group of n people at least two have the
same birthday?

probability


Selected Answer

(a) We need to find the probability that a birthday comes on February 29. Consider a 400 year period- as leap year cycle
repeats every 400 years. Number of leap years in this = 400/4 - 4 + 1 = 97. So,

number of days in this period = 365 * 400 + 97 = 146097

In these days February 29 repeats 97 times. So, probability of birthday on February 29 = 97 / 146097

(b) Required probability = 1 - probability that every birthdays are distinct

= 1 - (probability that every birthdays are distinct with 1 birthday being feb 29) - (probability that every birthdays are
distinct with none being on February 29)

= 1 - ((365 * 364 * ... 365 - n + 2)/365 n) n (400/146097)n-1 (97/146097) - ((365 * 364 * ... 365 - n +
1)/365n) (400/146097)n

(In the second term, we are picking distinct days and probability of a birthday falling on each such day is 400/146097 for
any day other than feb 29 and 97/146097 for feb29) (n is used since birthday of any of the n person can come on feb 29)

= 1 - 365Pn-1 n (400/146097)n-1 (97/146097) - 365Pn (400/146097)n

 2 votes -- Arjun Suresh ( 124125 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1730 of 2244

15.61 Probability: Probability top gateoverflow.in/16313

A box contains 10 screws, 3 of which are defective.Two screws are drawn at random with replacement.The probability that
none of the two screws is defective will be

probability

if defect will be faliure then P(F)=3/10. Not defect(success) P(S)=7/10..

P(None is defect)=P(1st drawing not defect)*P(2nd drawing not defect)=P(S)*P(S)=7/10*7/10=49/100.

 0 votes -- Arun Gorain ( 77 points)

15.62 Probability: What is the probability that a five-card poker hand


contains a straight, that is, five cards that have consecutive kinds? top gateoverflow.in/4587

Answer is 10240/C(52,5)
My approch:
2*(4)^5/C(52,5)

probability

For counting total no of Straights =>

1 2 3 4 5 6 7 8 9 10 J Q K Ace(1)

Here we got to select 5 cards in row. So Total no of ways are 10 !

Now each card can take one of 4 suits

So total possibilites of straight = 10 * 4 5

Total ways of selecting cards i.e. Sample space = 52C5

Total Probability = 10 * 4 5 / 52C5

Correct me If I'm wrong not 100% sure here !

 1 votes -- Akash ( 26315 points)

15.62 Probability: A pair of dice is rolled again and again till a total of 5 or 7
is obtained. The chance that a total of 5 comes before a total of 7 is?? gateoverflow.in/1116

top

probability


Selected Answer

Favourable cases for 5: {(1,4), (2,3)}


Favourable cases for 7: {(1,6), (2,5), (3,4)}

(I ignored the reverse cases like (4,1) for (1,4) as this happens for both 5 and 7 and hence won't affect the probability)

So, chance that total of 5 comes before 7 = 2/5

(We can ignore all other cases, as questions asks for probability of sum = 5 compared to sum = 7)

 4 votes -- gatecse ( 9515 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1731 of 2244

1/9 is the probability of sum of 5 and 1/6 is the probability of sum of 7. Probability that neither happens = 26/36 =
13/18.

S = 1/9 + 13/18 × 1/9 + …

In words win5 +loss (5,7)win5 +....

It is a GP series with first term 1/9 and common ratio 13/18.

1/9 2
S = (1 − (13/18) = 5

 4 votes -- Bhagirathi Nayak ( 10239 points)

15.63 Probability: If two squares are chosen at random on a chess board the
probability that they have a side in common is? top gateoverflow.in/1115

a) 1/9

b) 2/7

c) 1/18

d) none

probability


Selected Answer

In each row we have 7 pairs of squares having a common side. So, totally 8*7 = 56 such squares horizontally. Similarly,
we get 56 such squares vertically. So, total number of favorable cases = 56+56=112.
Required probability = 112/64 C2
= 112*2/(64*63)

= 1/18

 3 votes -- gatecse ( 9515 points)

In 64 squares,
4 at-corner squares, each has only 2 options to select from so 4*2C1
6*4 = 24 side squares, each has only 3 options to select from so 24*3C1
6*6 = 36 inner squares , each has 4 options to select from so 36*4C1

So.

(4 * 2 + 24 *3 + 36* 4)/(64*63) = (224/4032) = 1/18

 2 votes -- praj ( 55 points)

15.64 Probability: A man visits a couple who have 2 children. one of the
children, a boy, comes into the room. top gateoverflow.in/782

A man visits a couple who have 2 children. one of the children, a boy, comes into the room. find the probability p that the

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1732 of 2244

other is also a boy.

(a)1/3

(b)2/3

(c)1/2

(d)3/4

probability normal


Selected Answer

Since, it's given that the first one is a boy, the second event is independent of the first and the probability is 1/2.(The sample space contains only the events
concerning the second child ({G, B}) . Had the question been "what's the probability of both the children coming to the room being boys given that one is
surely a boy", then the sample space will contain BB, BG and GB and probability would be 1/3)

 3 votes -- gatecse ( 9515 points)

15.64 Probability: Find the smallest number of people you need to choose at
random so that the probability that at least two of them were both born on
April 1 exceeds 1/2. top gateoverflow.in/4604

probability


Selected Answer

At least 2 out of n people born on April 1 means either all n are not born on April 1 or exactly 1 born on April 1.

So, P(X) = 1 - P(Y) - P(Z)

where P(Y) is the probability that none are born on April 1 and P(Z) is the probability that exactly 1 is born on April 1

P(Y) = 364 n/365n

P(Z) = n * 364 n-1/365n

So, P(X) = 1 - P(0) - P(1)

= 1 - 364 n-1/365n (364 - n)

P(3) = 0.016

P(50) = 0.24

P(120) = 0.517

P(119) = 0.514

P(115) = 0.502

P(114) = 0.497

So, 115 would be the answer.

 2 votes -- Arjun Suresh ( 124125 points)

15.64 Probability: What is the probability that a five-card poker hand


contains cards of five different kinds and does not contain a flush or a
straight? top gateoverflow.in/4588

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1733 of 2244

probability

15.65 Probability: 19. a) What is the probability that two people chosen at
random were born during the same month of the year? top gateoverflow.in/4603

19.

a) What is the probability that two people chosen at random were born during the same month of the year?

b) What is the probability that in a group of n people chosen at random, there are at least two born in the same month of
the year?

c) How many people chosen at random are needed to make the probability greater than 1/2 that there are at least two
people born in the same month of the year?

probability


Selected Answer

(a). Let the first person's birth month be x. Now, the second person must born in the same month (1/12 probability) to
satisfy the given condition as both their births are independent events. So, required probability is 1/12 .

(b). Birthmonth paradox :)

We have n persons and required to find if at least two of them have same birth month. So, we find the probability of none
of them have same birth month and subtract this from 1. (n <= 12 as when n = 13, surely two persons will have same
birthmonth as per pigeonhole principle)

P(X') = 12 * 11 * .. (12-n+1) / 12 n (As the first person has 12 months to choose from, second person has 11, and so on)

= 12 Pn / 12n

P(X) = 1 - P(X')

(c)

P(2) = 1 - 12*11/(12*12) = 0.083

P(3) = 1 - 12 * 11 * 10 / (12 * 12 * 12) = 0.236

P(4) = 1 - 12 * 11 * 10 * 9 / (12 * 12 * 12 * 12) = 0.427

P(5) = 1 - 12 * 11 * 10 * 9 * 8 / (12 * 12 * 12 * 12 * 12) = 0.618

So, 5 is the answer.

 1 votes -- Arjun Suresh ( 124125 points)

15.66 Random Variable: Probability top gateoverflow.in/20469

Suppose that the length of the phone calls in minutes is an exponential random variable with parameter λ = 1/10.

If someone arrives immediately ahead of you at a public telephone booth, find the probability of that you will have to wait

a) more than 10 minutes (ans 0.368)


b) between 10 and 20 minutes (ans 0.233)

probability random-variable

It can be solved by Exponential Distribution


f(x) = λe -λx if x> 0

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1734 of 2244

0 if x< 0
The cumulative distributive function F(a) of an exponential random variable is given by
F(a) = P(x≤a) = ∫ 0a λe-λx dx = 1- e -λ*a

a) P(x>10) = 1- P(x<10)
= 1- (1- F(10))
= 1 - (1- e-λ*10) = e -1 = 0.368

b) P(10<X<20) = F(20) - F(10)


= (1-e-λ20) - (1-e-λ10) = e -1 - e-2 = .233

 0 votes -- Umang Raman ( 10379 points)

15.67 Random Variable: You are asked to open one door. There is a large
prize behind one of the three doors and the other two doors are losers. top
gateoverflow.in/4619

You are asked to open one door. There is a large prize behind one of the three doors and the other two doors are losers.
After you select a door, Monty Hall opens one of the two doors you did not select that he knows is a losing door, selecting at
random if both are losing doors. Monty asks you whether you would like to switch doors. Suppose that the three doors in the
puzzle are labeled 1, 2, and 3. Let W be the random variable whose value is the number of the winning door; assume that
p(W = k) = 1/3 for k = 1, 2, 3. Let M denote the random variable whose value is the number of the door that Monty opens.
Suppose you choose door i.

Solve the following parts:


a) What is the probability that you will win the prize if the game ends without Monty asking you whether you want to change
doors?
b) Find p(M = j | W = k) for j = 1, 2, 3 and k = 1, 2, 3.
c) Use Bayes’theorem to find p(W = j | M = k) where i and j and k are distinct values.
d) Explain why the answer to part (c) tells you whether you should change doors when Monty gives you the
chance to do so.

probability random-variable


Selected Answer

(a) 1/3 as one out of 3 is the favourable case and all are equally likely

(b)
P(M=1|W=1, i = 1) = 0
P(M=2|W=1, i = 1) = 0.5
P(M=3|W=1, i = 1) = 0.5

P(M=1|W=2, i = 1) = 0
P(M=2|W=2, i = 1) = 0
P(M=3|W=2, i = 1) = 1

P(M=1|W=3, i = 1) = 0
P(M=2|W=3, i = 1) = 1
P(M=3|W=3, i = 1) = 0

Similarly we can write for i = 2, and i = 3.

(c)

(i, j, k) are distinct

P(W=1|M=2) = 2/3 (i = 3 implied by distinct values, and i=3 with probability 1/3 and Monty never selects the winning
one making the other one's probability to win 2/3)
P(W=1|M=3) = 2/3 (i = 2)
P(W=2|M=1) = 2/3 (i = 3)
P(W=2|M=3) = 2/3 (i = 1)
P(W=3|M=1) = 2/3 (i = 2)
P(W=3|M=2) = 2/3 (i = 1)

(d). The probability of my selection winning is 1/3 and probability of the remaining door winning is 2/3 => so, if I believe
in probability I should change the doors.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1735 of 2244

If you strictly want to use Bayes' theorem

http://faculty.washington.edu/tamre/BayesTheorem.pdf

 3 votes -- Arjun Suresh ( 124125 points)

D).yes the door should be changed as the probability of winning after switching the doors is 66.66%.Here it goes how? If
the prize is behind Door 1, Monty will open either Door 2 or Door 3 to reveal an empty door. You switch to the other of
Door 2 or Door 3, and in either case you switched to a door with nothing behind it (remember, the car is behind Door 1).
If the car is behind Door 2, Monty will open Door 3. This is because he always opens a door which has nothing behind it,
and he can't open Door 1 because that was your original choice. So the only door you can switch to is Door 2, which is the
door with the car behind it.'You win!' If the car is behind Door 3, Monty will open Door 2. This is because he always opens
a door which has nothing behind it.and he can't open Door 1 because that was your original choice. So the only door you
can switch to is Door 3, which again is the door with the car behind it. Ding! You win!So out of three you win two times so
probability is 66.66%.

 1 votes -- admin ( 1411 points)

15.68 Random Variable: Let X be the random variable on the set of


permutations of a set of n distinct integers {a 1 , a 2 , . . . , a n } with a1 <
a2 < · · · < an such that X(P) equals the number of comparisons used by the
bubble sort to put these integers into increasing order. top gateoverflow.in/4634

Answer the following part:


a) Show that, under the assumption that the input is equally likely to be any of the n! permutations of these
integers, the average number of comparisons used by the bubble sort equals E(X).
b) Use Example 5 in Section 3.3 to show that E(X) ≤ n(n − 1)/2.
c) Show that the sort makes at least one comparison for every inversion of two integers in the input.
d) Let I (P ) be the random variable that equals the number of inversions in the permutation P . Show that
E(X) ≥ E(I ).
e) Let I j,k be the random variable with j,k (P ) = 1 if a k precedes a j in P and I j,k = 0 otherwise. Show that

f ) Show that
g) Show that E(I j,k ) = 1/2.
h) Use parts (f) and (g) to show that E(I ) = n(n − 1)/4.
i) Conclude from parts (b), (d), and (h) that the average number of comparisons used to sort n integers is .

probability random-variable

15.69 Random Variable: probability random variables top gateoverflow.in/31010

Let X∈{0,1} and Y∈{0,1} be two random variables if P(X=0) =p and P(Y=0)=q then P(X+Y>=1) is equal to

1)pq+(1-p)(1-q)

2)pq

3)p(1-q)

4)1-pq

probability random-variable easy


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1736 of 2244

X∈{0,1} Y∈{0,1}

i.e. for P(X+Y>=1) value of X and Y can be {(0,1),(1,0),(1,1)}

So we can say , P(X+Y>=1) = 1-P(X+Y<1)

= 1- P(X=0,Y=0)

=1- {P(X=0).P(Y=0)}

=1-pq

 4 votes -- srestha ( 11585 points)

15.70 Random Variable: Random variables and distribution top gateoverflow.in/16427

If X is a continuous random variable whose probability density function is given by


f(x) ={k(5x-2x^2) , 0<= x <= 2<br /> 0 ,otherwise}
then p(x>1) is

random-variable

P(x>1)=1-p(x<1)

integrating the given function net 0 and 2 gives k(5x^2/2-2x^3/3)

Equate this to 1 to get value ok k

value of k as 3/14

P(1)=3/14*11/6

=11/28

P(x>1)=1-11/28=17/28

 1 votes -- Pooja ( 22773 points)

15.71 Random Variable: Uniform probability distribution top gateoverflow.in/16426

X is uniformly distributed random variable that takes values between 0 and 1.The value of E(X^3) will be

random-variable expectation

a=0 b=1

1/b-a=1

E(x^3)= integrate x3 from 0 to 1

Ans is 1/4

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1737 of 2244

 1 votes -- Pooja ( 22773 points)

15.72 Random Variable: random variable X 2 + Y 2 > 1 top gateoverflow.in/337

Consider two independent random variables X and Y having probability density functions uniform in the interval [ − 1, 1]. The
probability that X2 + Y2 > 1 is

1. π/4
2. 1 − π/4
3. π/2 − 1
4. Probability that X2 + Y2 < 0.5
5. None of the above.

probability random-variable


Selected Answer

Area of square denotes the total


probability, i. e, 1.
Area of circle denotes P(X 2 + Y 2 ≤ 1)
Area of shaded region denotes the required probability, i.e, P(X 2+ Y 2 >1)

Area of shaded region=Area of square -Area of Circle


=4-⊼
= 4 ( 1 - ⊼/4)

If area of square corresponds to total probability, then


4 sq.unit=1
= 1 sq.unit=1/4
= 4(1-⊼/4) sq.unit=
=1- ⊼/4
which is the required probability.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1738 of 2244

 1 votes -- Leen Sharma ( 2935 points)

(4-Pi)/4....is the answer

 2 votes -- Shaun Patel ( 5445 points)

15.73 Random Variable: uniform distribution top gateoverflow.in/31078

x1 x2 x3 are three independent random variables distributed uniformly on [0,1].Find probability that P(X1 is largest )

random-variable probability

probability is 1/3..

Solution:- there are 6 cases P(x1>x2>x3), P(x1>x3>x2), P(x2>x1>x3), P(x2>x3>x1), P(x3>x2>x1), P(x3>x1>x2).

All cases are equally likely and hence P(x1) being largest is P(x1>x2>x3) or P(x1>x3>x2).

Hence, P(x1 being largest)=2/6=1/3

 2 votes -- Ashish Gupta ( 631 points)

15.74 Random Variable: random variables top gateoverflow.in/31074

Let x1 x2 x3 be three independent and identically distribuyed random variables with uniform distrbution on (0,1) find
probability p(x1+x2<=x3)

probability random-variable

The possible cases are :

X1+X2<=X3

X1+X3<=X2

X2+X3<=X1

X2+X1>=X3

X2+X3>=X1

X3+X1>=X2

Out of these 6 possible cases only 1 is favorable . Therefore Ans is 1/6 .

 1 votes -- Riya Roy ( 4767 points)

15.75 Statistics: statistics top gateoverflow.in/29226

Q) Let x be normal variable with mean 8 and standard deviation 4 then p(X ≤ 5) is

A). Greater than zero but less than 0.5

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1739 of 2244

B). Greater than 0.75

C). Greater than 0.5 but less than 1

D). Equal to 0.5

statistics

I think the right option is A.

This is the normal distribution curve for this mean and standard deviation μ=8 and σ=4

Since the area under the curve from μ-3σ(-4 here) to μ(8) is 0.5 hence P(x≤5) will be even smaller but will not be zero.
Hence option A is correct.

 3 votes -- devarshi ( 373 points)

15.76 Testbook: TESTBOOK FLT 4 top gateoverflow.in/38984

if today is not Monday, Then I have read Don Quixote" What is the probability of given proposition having truth value "True",
If chances that I be telling truth about reading Don Quixote are 10%.
Your Answer: 0.775
Accepted answer is between: 0.22 and 0.23

probability testbook

its 1-6*0.9/7 = 0.22857142857


 0 votes -- viv696 ( 1431 points)

15.77 Variance: Variance top gateoverflow.in/6088

Variance of 1st n positive integers is

a)(n2-1)/12

b)(n+1)/6

c)(n-1)(2n+1)/3

d)n(n-1)

variance


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1740 of 2244

Sum of first n positive integers = n (n+1)/2

Mean of first n positive integers, μ = (n+1)/2

Variance = ∑ (xi - μ)2/n

= ((1-μ)2+(2-μ)2+...+(n-μ)2)/n

= (1 2 + 22+ ....+n 2)/n + μ 2 - (2μ + 4μ + 6μ +.....+2nμ)/n

= (n+1)(2n+1)/6 + (n+1) 2/4 - μ(n+1)

= (n+1)(2n+1)/6 + (n+1) 2/4 - (n+1) 2/2

= (n+1)(2n+1)/6 - (n+1) 2/4

= (2(n+1)(2n+1) - 3(n+1) 2)/12

= (n+1) [4n+2 - 3n -3]/12

= (n+1)(n-1)/12

= (n 2-1) / 12

 6 votes -- Arjun Suresh ( 124125 points)

15.78 Variance: Variance top gateoverflow.in/27524

consider the first 10 positive integers . If we multiply each number by -1 and then add 1 to each number , the variance of
the numbers so obtained is

1) 6.5

2) 8.25

3) 3.87

4) 2.87

variance


Selected Answer

Let σ be variance and μ be mean

(xi −μ )2 xi2 0 2 + ( −1 )2 + … + ( −9 )2 9 .10.19 n . (n +1 ) . (2n +1 )

σ= ∑10
i =1
n
= ∑10
i =1
n
− μ2 = 10
− ( − 4.5)2 = 6 .10
(
− 20.25 ∵ Sum of squares of first n natural numbers = 6
) = 28.5 − 20.25

 2 votes -- Arjun Suresh ( 124125 points)

15.79 Variance: VARIANCE top gateoverflow.in/27535

The mean of 100 observation is 50 and there standard deviation is 5. The sum of all squares of all the observation is

1) 50000

2) 250000

3) 252500

4) 25500

variance

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1741 of 2244


Selected Answer

All items are equally likely.

Let σ be variance and μ be the mean.

(xi −μ )2 xi2 2xiμ xi2 xi2

σ= Σni=1 n
= Σni=1 n − Σni=1 n + μ2 = Σni=1 n − 2μ2 + μ2 = Σni=1 n − μ2

So, Σni=1 xi2 = (σ + μ2 )n = (52 + 2500)100 = 252500

 2 votes -- Arjun Suresh ( 124125 points)

15.80 probability top gateoverflow.in/36549

Two Squares are chosen at random on a chess board then what is the probability that they have a side in common ??


Selected Answer

is it 1/18 ?

 1 votes -- Satyandra ( 253 points)

15.81 probability top gateoverflow.in/43199

Let expected no of flip are x

First understand for one head if first flip is head then stop but if first flip is tail then we have wasted one flip n we have to
compute x

x=1/2(1+x)+1/2(1)

X=2

Now case for 2H

If the first flip is tails, we have wasted one flip,but if we get heads on the first flip, we still have to think about what will
come next:

we get a tail,we have wasted one more flip but if we get head then stop.

So expected no of flip will be

x=(1/2)(1+x) + (1/4)(2+x) + (1/4)(2)

=6

 0 votes -- Manojk ( 3365 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1742 of 2244

15.81 A fair coin is tossed 100 times. The Probability of getting 50 heads is
close to one of the following numbers: a) 0.001 b)0.1 c)0.3 d)0.4 top gateoverflow.in/5129


Selected Answer

Assuming we need exactly 50 heads


100C 1/2 50 1/2 50 ≈ 0.1
50

 2 votes -- Arjun Suresh ( 124125 points)

15.82 probability top gateoverflow.in/42483

A computer program selects an integer in the set {k : 1 ≤ k ≤ 10,00,000} at random and prints out the result. This process
is repeated 1 million times. What is the probability that the value k = 1 appears in the printout atleast once ?

(A) 0.5 (B) 0.704 (C) 0.632121 (D) 0.68

Let n=10,00,000 (1 million)

Probability that the value k=1 appears at least once= nC1 (1/1 million)* (1-1/1million)^(n-1) + nC2 (1/1 million)^2 *(1-
1/1 million)^(n-2) +..................

which can be simplified to 1 - nC0 (1 - 1/ 1million)^n

OR

Probability=1- (No. of times 1 doesn't appear/Total no. of times process is repeated)^Total no. of times process is
repeated

=1 - (999999/1000000)^1000000

=0.632121

This fraction might seem too tedious to calculate so you may just shorten the question like finding out probability if
process is repeated 1000 times. then also the probability comes out nearly 0.632.

Moreover, you may just look at the options and eliminate the options.

Hence, C is the answer.

 3 votes -- Ashish Gupta ( 631 points)

15.83 Question: top gateoverflow.in/5130

A class of the first year B.Tech students is composed of four batches A,B,C and D, each consisting of 30 students. It is found
that the sessional marks of students in Engineering Drawing in batch C have mean 6.6 and deviation 2.3. The mean and
standard deviation of the marks for the entire class are 5.5 and 4.2 respectively. It is decided by the course instructor to
normalized the marks of the students of all batches to have the same mean and standard deviation as that of the entire
class. Due to this, the marks of a student in batch C are changed from 8.5 to
a) 6.0 b) 7.0 c) 8.0 d) 9.0

Mean of 30 marks must be reduced from 6.6 to 5.5 while SD must increase from 2.3 to 4.2.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1743 of 2244

Multiplying each number by n changes SD by n (Since SD = ∑i(xi − μ)2 ). So, we can make the SD change from 2.3 to 4.2
by multiplying each term by 4.2/2.3. This will also change the mean from 6.6 to 12.05.
∑ixi

Now, subtracting a constant from each term makes the mean reduce by that same constant. (since μ = n ). So, to reduce
the mean from 12.05 to 5.5 we should subtract 6.55 from each term. (Subtracting a constant from each term won't affect
the standard deviation as mean and each term change by the same amount and hence also won't change).

So, our given value 8.5 becomes 8.5 * 4.2 / 2.3 = 15.52 for adjusting SD, and then becomes 15.52 - 6.55 = 8.97 when
adjusted for mean.

 2 votes -- Arjun Suresh ( 124125 points)

15.84 Probability with replacement top gateoverflow.in/33584

Two cards are drawn one by one

Q1 ) With Replacement
Q2 ) Without Replacement

What is the probability that they are of different colors . Find answer in two questions

Q1]
Probability of getting red in first draw, P(R) = 26/52 = 1/2
Probability of Getting black in second draw, P(B) = 26/52 = 1/2
probability of getting different color = P(R) * P(B/R) + P(B) * P(R/B)

1 1 1 1

= 2 × 2 + 2 × 2
1

= 2

Q2]

P(Getting Different) = P(R⋂B) + P(B⋂R)


= P(R) * P(B/R) + P(B) * P (R/B)
26 26 26 26

= 52 × 51 + 52 × 51
= 0.509

 2 votes -- Sandeep Singh ( 5939 points)

15.85 Regression Lines top gateoverflow.in/6031

Please solve the following...

If y=x+1 and x=3y-7 are 2 regression lines

Q-1 Then arithmetic mean of x and y are

a)2,3 b) 2,2 c) 3,2 d)0,1

Q-2 What will be the coefficient of correlation(r)?

a) 1 b) 3 c) 2 d) 1/sqrt(3)

arithmetic mean is solving 2 two equation.. i.e. x=2, y=3


coefficient of regression = 1/root (m1*m2) // m1=1, m2=3
= 1/root3

 0 votes -- Digvijay Pandey ( 26245 points)

15.86 Bayes Theorem top gateoverflow.in/6018

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1744 of 2244


Selected Answer

Probability of Urn 3 given the balls are white and green


= P(Urn 3 and white + Urn 3 and green)/ P(white and green)
= P(Urn 3 and white + Urn 3 and green)/ [P(Urn 3 and white + Urn 3 and green) + P(Urn 2 and white + Urn 2 and green)
+ P(Urn 1 and white + Urn 1 and green)]
= 1/3 * (4/12 * 3/11 * 2C1) / [1/3 * (4/12 * 3/11 * 2C1) + 1/3 * (2/4 * 1/3 * 2C1) + 1/3 * (1/6 * 3/5 * 2C1)]
= (2/33) / (2/33 + 1/9 + 1/15)
= (2/33) / ( 30 + 55 + 33)/495
= 2 * 15/118
= 15/59

(2C1 is multiplied because the 2 balls could be drawn in 2C1 ways)

 4 votes -- Arjun Suresh ( 124125 points)

15.87 Find E(R). top gateoverflow.in/4630

Answer: p + (n − 1)p(1 − p)

A run is a maximal sequence of successes in a se-


quence of Bernoulli trials. For example, in the sequence
S, S, S, F, S, S, F, F, S, where S represents success and
F represents failure, there are three runs consisting of
three successes, two successes, and one success, respec-
tively. Let R denote the random variable on the set of se-
quences of n independent Bernoulli trials that counts the
number of runs in this sequence.

15.87 what is probability that in randomly chosen group of r people atleast 3


people have same birthday top gateoverflow.in/39370

15.88 How to solve below question of probability ? top gateoverflow.in/37703

2 friends Alice and bob have found an unfair coin ,it has 72% chance of coming up heads .Alice and bob play a game with
this coin ,If coin comes up with head and then tails,Alice wins and if its in the reverse way then bob wins .And if neither of
the two things happen then the game restarts and continues until there is a winner ,what is the probability that bob wins ?

In this how to deal with the case when we have HH or TT ?


Selected Answer

P(H)=0.72 P(T)=0.28

P(HT)=0.72 * 0.28=0.2016 say x1 , P(TH)=0.28 * 0.72=0.2016 say x2

to repeat same process....probability=1-(x1+x2)=0.5968 say y1

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1745 of 2244

ans=x1 + y1*x1 + y1* y1*x1+......

=x1(1+y1+y1*y1+...)

=x1(1/(1-y1))

=0.2016(1/(1-0.5968))

=0.5

so ans should be 0.5

 1 votes -- Gabbar ( 469 points)

15.89 probability top gateoverflow.in/38587

A fair coin is tossed until one of 2 sides occurs twice in a row . Probability that the number of toses required is even is


Selected Answer

so 1st toss is either H or T.


now HTHTHTHT......HH or THTHTHTHTH.........TT will give your event.
calculate problaiblty.
getting HT or TH is 1/2.1/2=1/4
now you may get event as TT or THTT or THTHTT or ................
so probality is 1/4 + 1/4*1/4 + 1/4*1/4*1/4 +........... = 1/4(1+1/4+1/4+.......) = 1/3

also the event has HH or HTHH or HTHTHH or ............


so here also 1/4(1+1/4.1/4+..........) = 1/3

so add all this and you get 1/3+1/3=2/3

 3 votes -- viv696 ( 1431 points)

15.90 probability top gateoverflow.in/38241

Assume that there are 6 color letters L1,L2,L3,L4,L5,L6 are to be placed in same color envelop E1,E2,E3,E4,E5,E6 (one letter
for each envelop). What is the number of possibilities to place every letter in wrong color envelop?

a) 260

b) 265

c) 270

d) 275

Derangement of 6 people :)
Answer is 265
http://mathworld.wolfram.com/Derangement.html

 2 votes -- Digvijay Pandey ( 26245 points)

15.91 probability top gateoverflow.in/37629

Please help in solving these 2 problems

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1746 of 2244

15.92 key probablity top gateoverflow.in/39116

P(Successful try) = 1/n


P(Unsuccessful try) = 1- 1/n

Success will be in nth try i.e. n-1 Unsuccessful try must be there.
P(Success in nth try) = (1-1/n)(1-1/n)(1-1/n).........n times * 1/n =((n-1)/n) n-1 *1/n

#If question is like LOCK will be opened in Atmost n try then,


1- (1-1/n)n = 1 - ((n-1)/n) n

 3 votes -- Digvijay Pandey ( 26245 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1747 of 2244

15.92 Suppose that X 1 and X 2 are independent Bernoulli trials each with
probability 1/2, and let X 3 = (X 1 + X 2 ) mod 2. a) Show that X 1 , X 2 ,
and X 3 are pairwise independent, but X 3 and X 1 + X 2 are not
independent. top gateoverflow.in/4632

15.93 What is the expected number of bins that remain empty when m balls
are distributed into n bins uniformly at random? top gateoverflow.in/4636

Answer: (n − 1)m /nm−1

Let P(X i) be the probability that bin i is empty. So,

P(Xi) = [(n-1)/n]m

E(Xi) = 1 * [(n-1)/n]m

Now, we require the expectation of ∑ X i which is equal to the summation of their individual expectation as per linearity of
expectation.

So, expected number of empty bins = ∑ E(X i)

= n E(Xi) (as summation is from 1 to n)

= n [(n-1)/n]m

http://www.cse.iitd.ac.in/~mohanty/col106/Resources/linearity_expectation.pdf

 1 votes -- Arjun Suresh ( 124125 points)

15.94 Probability top gateoverflow.in/37622

15.95 Let X n be the random variable that equals the number of tails minus

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1748 of 2244

the number of heads when n fair coins are flipped. a) What is the expected
value of X n ? b) What is the variance of X n ? top gateoverflow.in/4631

Answers:
a) 0
b) n

how did you find the Variance ??

 0 votes -- Shaun Patel ( 5445 points)

15.95 Find the probability that the first child of a family with five children is
a boy or that the last two children of the family are girls, for the condition
that the probability of boy is 0.51 ? top gateoverflow.in/12601

This is my approach .

the probability of 1 st child is boy 51/100.

the probability of last two child is girl (49/100) 2 .

the probability of 1 st child is boy and the probability of last two child is girl (51*49*49/100 3) .

so the probability of 1 st child is boy or the probability of last two child is girl = (51/100) + (49/100) 2 - (51*49*49/1003)

= 0.6276

 3 votes -- Pranay Datta ( 6113 points)

15.96 probability top gateoverflow.in/25395

a man appeared for a job interview in companies A,B,C,D . the probability of getting job in A,B,C,D are 0.6,0.5,0.5 and 0.7
. the probability that the candidate will get the job is ?


Selected Answer

Given the probability of getting job in A,B,C,D are 0.6,0.5,0.5 and 0.7

probability of not getting job in A= 1 - 0.6 = 0.4

probability of not getting job in B= 1 - 0.5 = 0.5

probability of not getting job in C= 1 - 0.5 = 0.5

probability of not getting job in D= 1 - 0.7 = 0.3

probability that the candidate will get the no job= 0.4 * 0.5 * 0.5 * 0.3 = 0.03

probability that the candidate will get the job = 1 - probability that the candidate will get the no job

=( 1 - 0.03 ) = 0.97

 4 votes -- Leen Sharma ( 2935 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1749 of 2244

15.97 probability top gateoverflow.in/25183

A and B play game in whic they toss coin 3 times.The one obtaining heads first wins the game.If A tosses coin first and if
total value of stake is Rs 20.How much should be contributed by B in order that game is fair?

I think A flips 3 time if loose then B flips three time and it continues till anyone wins.

First, calculate the probability that A does not win on his first turn. That is simply the probability that a coin flipped three
times turns up no 'heads'.
That probability is (1/2)^3 = 1/8. So, that means A has a 7/8 chance of winning on his first turn.

Assuming A doesn't win (which happens 1/8 of the time), B then flips three times.
The probability that B doesn't win these three flips is again 1/8, so the probability of B winning on his first turn (if B gets a
first turn) is 7/8,
But B only gets a first turn 1/8(if A loose first turn) of the time.
So the actual probability of B winning on his first turn is: 1/8 * 7/8 = 7/64.

The A's second turn, with the probability of winning 7/8 again, if A gets a second turn.
But the probability of getting to A's second turn is 1/8 * 1/8 = (1/8)^2. So the total probability of A winning on his second
turn is (1/8)^2 * 7/8 = 7/512.

The pattern repeats. The total probability of B winning on his second turn is (1/8)^3 * 7/8 = 7/4096.

The total probability of A winning on his third turn is (1/8)^4 * 7/8 = 7/32768.

final probability that A wins the game, we get an infinite series, which evaluates to:
Probability that A wins = 7/8 + 7/8*(1/8)^2* + 7/8*(1/8)^4 + 7/8*(1/8)^6 + ...
Probability that A wins = 7/8 * (1 + (1/8)^2* + (1/8)^4 + (1/8)^6 + ...)
Probability that A wins = 7/8 * (64/63)
Probability that A wins = 8/9

So, A wins the game with a probability of 8/9. We can then deduce that B wins the game with a probability of 1/9.
For a fair game, B must put of 1/9 of the stakes, or:
B's stakes = 1/9 * 20
B's stakes = 2.222

 0 votes -- Umang Raman ( 10379 points)

15.98 probability top gateoverflow.in/25172

Manish has to travel from A to D changing buses at stops B and C enroute.The maximum waiting time at either stop can be
8 minutes each,but any time of waiting upto 8 minutes is equally likely at both places.He can afford upto 13 minutes of
waiting time if he is to arrive at D on time,What is probability Manish will arrive late at D?

3/16 should be the correct answer.

Maximum Possible Waiting Time = 8 + 8 = 16 mins.

Minimum Possible Waiting Time = 0 + 0 = 0 mins.

Given that, at both the stations B & C, any waiting time up to 8 minute is equally likely.

So any waiting time between 0 to 16 should be equally likely.

Now the problem can be thought as "Choosing any point P randomly on real number line between 0 to 16(inclusive), what
is the probability that the point will lie between 13 to 16."

Point P will represent our total waiting time, clearly all points will be equally likely since they will be equidistant from each
other.

The Probability that P > 13 = length of line segment between 13 and 16 / length of line segment between 0 and 16

Hence the probability that total waiting time is greater than 13 minutes = (16 - 13) / (16 - 0) = 3/16

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1750 of 2244

Manish will arrive late at D if he will spend more than 13 minutes in waiting.

So the probability that Manish will arrive late at D = 3/16.

 1 votes -- Anurag Pandey ( 8183 points)

15.99 probability top gateoverflow.in/26032


India plays two matches each with West Indies and Australia. In any match, the probabili es of India ge ng, points 0, 1 and 2 are 0.45, 0.05 and 0.50
respectively. Assuming that the outcomes are independent, the probability of India getting at least 7 points is

Since there are 4 matches to be played. India can get a maximum of 8 points(2 points in each match).

Probability of getting exactly 7 points = P(Getting 2 points each of 3 matches and getting 1 point in one match)

= ( 3 ) (0.5) 3 (0.05)1 =0.025

Probability of getting exactly 8 points =P(Getting 2 points in each of 4 matches)

= ( 4 ) (0.5) 4 (0.05)0=0.0625

P(india gets at least 7 points) =P(Getting exactly 7 points) + P(Probability of getting Exactly 8 points)

= 0.025 + 0.0625

=0.0875

 2 votes -- Leen Sharma ( 2935 points)

15.99 A roulette wheel with 38 numbers is spun. What is the probability that
in five spins the wheel never lands on either 0 or 00? What is the probability
that the wheel lands on one of the first six integers on one spin, but does
not land on any of them on the next spin? top gateoverflow.in/14074

A roulette contains numbers 0, 00, 1,2..., 36. So for first question, every time, we have 36 choices out of 38. So

36

P= ()
38
5
.

6 32

In second case, P = 38 ∗ 38

 1 votes -- Happy Mittal ( 9253 points)

15.100 How can a event be neither independent nor dependent nor mutually
exclusive ? top gateoverflow.in/26812

If I am rolling two dices and following 3 events are defined such that

E1= Getting a 4 on 1st die

E2= sum of 2 dices is 6

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1751 of 2244

Now P(E 1)= 1/6 ,P(E 2)= 5/36

P(E1 ∩ E2)= 1/36

Now P(E1 ∩ E2) ≠ P(E1) * P(E2)

Now since this inequality doesn't hold true so these are not independent events , so then why are these not dependent events as well since

P(E1 ∩ E2) =P(E 1) * P(E2 / E1) using multiplication theorem

Now P(E2 / E1) =1/ 36 since there will be only 1 favourable case (4,2) ,Now even this inequality doesn't hold true , and
even E1 ∩ E2!=0 so they are not even mutually exclusive so to which category do these events belong to ?


Selected Answer

Events E1 and E2 are extremely dependent events indeed.

Suppose you got 6 on the first throw then the sum of two dices is never going to be 6, since the sum will be at least 7
.Thus we can see that they are dependent.

The out come of of the first throw will surely contribute to the sum of two dice throws, so they are not independent.
E2

You have miscalculated P[ E1 ].

1 1

It will be 6 instead of 36 .
E2

P[ E1 ] means GIVEN THAT 4 has already been occurred in the first throw, what is the chance of getting a sum of 6.

Since occurrence of 4 in the first throw is given to us we will not consider the probability of occurrence of 4 in the first
throw.We already have 4 & we need a 2 to make the sum 6, hence we will only consider the probability of getting 2 in the
1

second throw, which is clearly 6 .

E2 1

So P[ E1 ] = 6

Also P[E1] = 6
E2 1 1 1
E1 6 6 36
this will give P[E1] × P[ ]= × = .
1
36
The probability of getting a 4 in the first throw and getting sum 6 is P[E1 ∩ E2] = , as you have described.

E2

Hence P[E1 ∩ E2] = P[E1] × P[ E1 ]

And yes they are not mutually exclusive, since both of the events can occur simultaneously.

However if I change E1 to "Getting 6 on the first die." and E2 remains same then E1 and E2 will be mutually exclusive since
happening of any one of them will imply not happening of the other.

 0 votes -- Anurag Pandey ( 8183 points)

15.101 Explain what is wrong with the statement that in the Monty Hall
Three-Door Puzzle the probability that the prize is behind the first door you
select and the probability that the prize is behind the other of the two doors
that Monty does not open are both 1/2, because there are two doors left. top
gateoverflow.in/14013

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1752 of 2244

the number of bit strings of length 8 that will either start with 1 or end with 00 is?

a) 32 b) 128 c) 160 d)192

the statement is wrong . first for all the other i just explain the puzzle . the puzzle just says that there is a show in which a
candidate have to choose a door out of 3 doors. one door contain the gift let it be car and others to be goat . the host of
the show know which door contain a gift. after choosing the one door . the host not directly open the door but open one of
the remaining two door with a goat .and then the user is again given a choice to either stick to the earlier door or he can
now choose the second door.

the statement is wrong as there is equally likely probability of gift behind any door. so the probability will be 1/3 for each
door. and the probability of gift behind the door you have selected is 1/3 and the probability of gift behind the 2 doors
monty have not opened yet will be 2/3.

the answer end here . but for real life situation i u sometime get to that show somehow . the trick to win is alays change
the door . after monty opens the door with a goat . as your winning changes are still 1/3 if u stick to your door . but the
other set changes were 2/3 but now as there is only one door left in that set he probability is still 2/3 so good to go with
more probability.

 0 votes -- Ravi Singh ( 7303 points)

15.102 probability top gateoverflow.in/25170

1)Among 10000 random digits find probability P that digit 3 appears at most 950 times.(area under normal between Z=0
and Z=1.67 is 0..4525)

2)A die is tossed 180 times .using normal distribution find probability that face 4 willnturn up atleat 35 times..(area under
normal curve between Z=0 and z=1 is 0.3413)

answer for Q.1 = 0.0475


answer for Q.2 = 0.1587

1) n = 104
1

p = 10 = 0.1 so, q = 1 − 0.1 = 0.9


mean = μ = np = 104 × 0.1 = 103
the standard deviation = σ = √npq = √104 × 0.1 × 0.9 = 30
on converting it to standard normal distribution, we get :

X−μ 950 − 1000 5


σ 30 3
z= = = − = − 1.67

we are given area between z = 0 and z = 1.67

this area equals in value with the area between -1.67 and 0

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1753 of 2244

+ the area outside -1.67 and +1.67, both separated areas shown below are EQUAL, due to symmetry in bell curve.

all together makes up 1


therefore, the required area which is, the area below −1.67

1 −2 ×0.4525
2
is given as = = 0.0475

using the similar technique, for Q.2 we get:

the required area is :

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1754 of 2244

 2 votes -- Amar Vashishth ( 17865 points)

15.103 What is the probability of seat available top gateoverflow.in/16325

An airplane knows that 5 percent of the people making reservations on a certain flight will not show up. Consequently, their
policy is to sell 52 tickets for a flight that can hold only 50 passengers. What is the probability that there will be a seat
available for every passenger who shows up?


Selected Answer

1 - (Probability of 51 people coming + Probability of 52 people coming)

( )
= 1 − 0.9551 × 0.05 × 52C1 + 0.9552 = 0.74

 0 votes -- Arjun Suresh ( 124125 points)

15.104 probability dice top gateoverflow.in/18639

1.Probability of getting total of atleast once in three tosses of pair of fair dice is

a)125/136 b)91/216 c)117/216

d)99/216

2.How many dice must be thrown so that there is better than even chances of getting 6

a)4 b)5 c)6 d)7

15.105 probability top gateoverflow.in/18637

For certain binary communication channel probability transmitted 0 is received as o is 0.95 and probability that transmitted 1
is received as transmiited 1 is 0.9 If probability 0 is transmiited is 0.4 find probality that 1 was transmitted given 1 was
received?


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1755 of 2244

P(0T)= 0.4 ie probability of 0 transmitted.

P(1T) = 0.6

P(1R) = probability of receiving 1.

case 1 :if 0 is transmitted than we can receive it as 1

case 2 : if 1 is transmitted than we can receive it as 1

P(1R) = 0.4*(1-.95) + 0.6 *.90 = .56

P(1T ⋂ 1R) = 0.6*.9=.54

P(1T/1R) = .54/.56 = 0.96

 0 votes -- Riya Roy ( 4767 points)

15.106 math top gateoverflow.in/17781

A sequence of independent trails consisting consists flipping of a coin having probability p of coming up of heads is
continually performed until either a head occurs or a tital of n flips is made. Let X denote the no of time the coin is
flipped.then P(X=n) is

A)(1-p)^n

B)p(1-p)^(n-1)

C)(1-p)^(n-1)

D)np(1-p)^(n-1)

P(X=n) means we are performing the Trial n times.

So after n trials there could Success in the nth trial: in that case P(x=n)=(1-P)^n-1p

and there could be total faliure : In that case P(X=n) =(1-p)^n

So P(X=n)= Succes+faliure=(1-p)^n-1.

 0 votes -- Arun Gorain ( 77 points)

15.107 exponential distribution top gateoverflow.in/18654

Suppose a system contains certain type of component whose lifetime is T .Random variable T is modelled by exponential
distribution with mean time to failure is b=5 .Probability that given component installed on system is still working after 8
years is

1)0.16 2)0.17 3)0.18 4)0.2

In above problem if 5 of these components are installed in different systems.What is probability that atleast 2 components
are still functioning at end of 8 years?

1)0.4128 2)0.3645.3)0.3149 4)0.2627


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1756 of 2244

Cumulative distribution function of exponential distribution is given by F(x) = 1 − e −λx, where λ is the rate of occurrence of
event. (https://en.wikipedia.org/wiki/Exponential_distribution#Cumulative_distribution_function )

So for example, F(8) means component survives at most 8 years.

Here mean time of failure is 5 years i.e. rate parameter λ is 1/5 = 0.2.

(a) Probability of component working even after 8 years is 1 − F(8) = 1 − (1 − e −0.2∗ 8 ) = e −1.6 ≈ 0.20

Hence option (4) is correct.

(b) Probability that at least 2 systems are working = 1 - (prob of no system working + prob of 1 system working)

Let probability of a system working after 8 years is p, which is 0.20 as calculated earlier.

So required probability is

5 5

P =1− ( )(p) (1 − p) − ( 1 )(p) (1 − p)


0 0 5 1 4 ≈ 0.2627

Hence option (4) is correct.

 3 votes -- Happy Mittal ( 9253 points)

15.108 expectation top gateoverflow.in/18660

In a lottery there are 200 prizes of Rs 5 ,20 prizes of Rs 25 and 5 prizes of Rs 100.Assuming 10000 prizes tickets are to be
issued and sold what is the fair price to pay for ticket?

1)Rs 0.2 2)Rs 0.4 3)Rs 0.5 4)Rs 0.6


Selected Answer

Here fair price means on an average, you should not lose anything. So if you buy a ticket for Rs. x, and win Rs. 5, then
you gain net Rs. 5 − x. This gain should not be negative i.e. it has to be at least 0.

200 20 5

You win net Rs. 5 − x with probability 10000 , win Rs. 25 − x with probability 10000 , win Rs. 100 − x with probability 10000 , and
9775
10000
win Rs. −x with probability .

Last case occurs when you don't win any ticket and lose your Rs. x.

Now net expected amount you win =

0.02(5 − x) + 0.002(25 − x) + 0.0005(100 − x) + 0.9775( − x) = 0

Hence x = 0.2

So option (1) is correct.

 0 votes -- Happy Mittal ( 9253 points)

15.109 what is probability? top gateoverflow.in/20493

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1757 of 2244

15.110 probability top gateoverflow.in/18661

If 20% of bolts produced by machine are defective determine probability that out of 4 bolts choosen number of defective
bolts is less than 2

1)27/64

2)81/256

3)27/256

4)512/625


Selected Answer

20 1

Probability of item being defective = p = 100 = 5

Probability that less than 2 items are defective = Prob(no item is defective) + Prob(1 item is defective). Hence required
probability is

4 1 4 4 1 4 512

P= ( )(0
)( )
5 0 5 4
+ ( )(
1
)( )
5 1 5 3
=
625

Hence option (4) is correct.

 0 votes -- Happy Mittal ( 9253 points)

15.110 Suppose that 100 people enter a contest and that different winners
are selected at random for first, second, and third prizes. What is the
probability that Michelle wins one of these prizes if she is one of the
contestants? top gateoverflow.in/13998


Selected Answer

100

Total number of ways in which any 3 random people can be chosen from 100 is ( 3 ).
Now in our favourable cases, Michelle wins the prize, so in all favourable cases, Mitchelle is one of the 3 persons in the set
99

which is chosen for winning. Now other 2 persons can be chosen in ( 2 ) ways, so probability is

99
99 ∗ 98
(2) 2
100 100 ∗ 99 ∗ 98
3
( ) 6
P= = = 0.03

 2 votes -- Happy Mittal ( 9253 points)

15.110 What is the probability that Abby, Barry, and Sylvia win the first,
second, and third prizes, respectively, in a drawing if 200 people enter a

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1758 of 2244

contest and a) no one can win more than one prize. b) winning more than
one prize is allowed top gateoverflow.in/13997


Selected Answer

(a) P(Abby winning first prize) = 200

P(Barry winning second prize) = 199 , as Abby can't win more than one prize.

P(Sylvia winning third prize) = 198


1 1 1

So total probability = 200 ∗ 199 ∗ 198

1 1 1

(b) Now total probability = 200 ∗ 200 ∗ 200 , because everyone can win any number of prizes.

 1 votes -- Happy Mittal ( 9253 points)

15.111 probability of picking red ball top gateoverflow.in/11999

A bin contains two red balls and one white ball. The probability of picking the balls is equally likely. Two balls are taken
without replacement. What is the probability of getting two red balls.

total outcome among 3 balls to choose 2 balls 3C2.

desire outcome among 2 red balls to choose 2 balls 2C2..

probability 1/3 . (if you one after another then also the probability is going to be same , 2C11C1/ 3C12C1

 1 votes -- Pranay Datta ( 6113 points)

15.112 wts shortcut to solve this kind of question top gateoverflow.in/12140

Consider a set A = {1, 2, 3, …….., 1000}. How many members of A shall be divisible by
3 or by 5 or by both 3 and 5 ?
(A) 533 (B) 599
(C) 467 (D) 66


Selected Answer

(A U B ) = (A) + (B) - (A ∩ B)

A=1000/3 = 333 [No's divisible by 3]

B=1000/5=200 [No's divisible by 5]

A ∩ B= 1000/15=66 [No's divisible by both 3 and 5]

A U B = 333+200-66=533-66=467

 6 votes -- Pranay Datta ( 6113 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1759 of 2244

15.113 distribution top gateoverflow.in/31066

If f(x) is normal distribution with mean 8 and std deviation 1 value of f(x) for x=10 is

1)0.05

2)0.14

3)0.25

4)0.73

The probability density of the normal distribution is:

Here μ= Mean or Expectation of the distribution.

The parameter is its standard deviation with its variance then .

Given =1 and =1.


μ= 8 and x=10
After putting value in the function

f(x)=0.0540.

Hence Answer is (1)0.05.

 2 votes -- Leen Sharma ( 2935 points)

15.114 the probability of the second ball selected is red in a collection of


balls top gateoverflow.in/11013

There is an urn having r red balls, b blue balls and w white balls. There is atleast two balls are there of each color. We are
taking two balls from the urn without replacement. What is the probability that the second ball selected is red. Express in
terms of r, b and w


Selected Answer

P (RR) + P(!R R)

= r/(r+b+w) * (r-1)/(r+b+w-1)

+ (b+ w)/ (r+b+w) * r/(r+b+w-1)

 2 votes -- Arjun Suresh ( 124125 points)

15.115 Regression Lines top gateoverflow.in/10827

Q-1 If y=x+1 and x=3y-7 are 2 regression lines

Then x bar(mean for x values) and y bar(mean for y values) are respectively

a)2,3 b)2,2 c)3,2 d)0,1

Q-2 Regression equations are x=4-0.2y and y=7-0.8x then value of correlation coefficient is

a)0.4 b)-0.4 c)0.16 d)-0.16

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1760 of 2244

Q.1 Point of intersection of two regression lines is , so if we solve the two equations given, we get (2,3) as
intersection point, which is .

Q.2 , where r is correlation coefficient, and are regression coefficients of x on y and y on x


respectively. Sign outside sqrt is positive if both and are positive, negative if both are negative.

In x = 4 - 0.2y, we have = -0.2

In y = 7 - 0.8x, we have = -0.8

So r = -0.4

 2 votes -- Happy Mittal ( 9253 points)

15.116 Probability top gateoverflow.in/10768

var(X) in exponential distribution is 1/(parameter) 2 i.e 1/λ 2 here so option B

var(3X+5)

⇒3var(X) + var(5)

⇒3*1/λ2 + 0 as var(constant)=0;var(X)=1/λ 2

⇒3/λ 2

so option B

 1 votes -- Bhagirathi Nayak ( 10239 points)

15.117 Find out the probability top gateoverflow.in/32797

'X' is playing a dice game in which a dice is rolled 5 times.If a number turns up exactly 3 times then the game
is won.'X' has thrown the dice 2 times and got number 4 both times.What is the probability that 'X' will win the
game?

a) 1/216

b) 75/216

c) 80/216

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1761 of 2244

d) 90/216


Selected Answer

A dice is rolled 5 times, in first two rolls we get 4,

If A number turns exactly 3 times then game is won.

Probability that X win the game, is possible in two cases

First case:

if we get exactly one 4 in next 3 rolls,

1 5 5 5 1 5 5 5 1

= ( 6
∗6 ∗6 )(
+ 6
∗6 ∗6 )(
+ 6
∗6 ∗6 )
75

= 216

Second Case:

Exactly Same Number in next 3 rolls but not 4

5 1 1 5

= 6 ∗ 6 ∗ 6 = 216

75 5 80

So, Probability of X to win game is 216 + 216 = 216

 5 votes -- Praveen Saini ( 34299 points)

15.118 probability top gateoverflow.in/31053

two independent random variables X and Y are uniformly distributed in[-1,1] probability that max(X,Y) is less than 1/2

1)3/4

2) 9/16

3)1/4

4)2/3

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1762 of 2244

X,Y is randomly distributed between [-1,1]

So, it is distributed over point (1,1),(1,-1),(-1,-1),(-1,1)


Total area covered 2*2=4

But we have to take probability of area less than 1/2 (i.e.ABCD)

Area of ABCD=3/2*3/2

=9/4

P(max(X,Y)<1/2) =(9/4) /4 =9/16

 0 votes -- srestha ( 11585 points)

15.119 probability top gateoverflow.in/31049

car arrives at service station acc to poisson distribution with mean rate of 5 hrs.service time per car is exponential with
mean of 10 minutes.at steady state average waiting time in queue is

1)10 min

2)20 min

3)25 min

4) 50 min

15.120 Probability top gateoverflow.in/27404

A problem in mechanics is given to 3 students A,B,C whose chances of slogging it are 1/2,1/3,1/4 respectively. The
probability that the problem will be solved is..

problem will be solved only when any one of them solve it all any two of them solve them or all of them solve them. the
approach to this type of question is . if u find in the first go that there are lot of case u have to cover like. here a can solve
, or b , or c, or a and c , or b and c, or c and a or all of them . a b c. then it will be easy to go with the 1- ( probability
approach) . The problem will be solved can be written as . 1- ( no one can solve )

all will be independent events as the problem solving capability of one does not depend on other.

=1-( p(a)' ⋂ p(b)' ⋂ p(c)')

= 1-( (1-1/2) * (1-1/3) *(1-1/4))

solve and get the answer.

 0 votes -- Ravi Singh ( 7303 points)

15.120 What is the probability that a five-card poker hand contains the ace of
hearts? top gateoverflow.in/13980

51C
4 5
52C
There is only one ace of hearts. So, required probability = 5
= 52

(ace is assumed to be picked and we need to pick any 4 from remaining 51)

Can also be solved like

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1763 of 2244

Required probability = 1 - Probability that ace of heart won't be in hand


51C
5
47 5
52C
=1− 5
= 1 − 52 = 52

 0 votes -- Arjun Suresh ( 124125 points)

15.120 What is the probability that a five-card poker hand does not contain
the queen of hearts? top gateoverflow.in/13981

51C
5 47
52C
There is only 1 queen of heart. So, required probability = 5
= 52 .

 1 votes -- Arjun Suresh ( 124125 points)

15.121 die top gateoverflow.in/27414

A die is rolled 3 times. The probability that the exact one ODD number turns up among the 3 outcomes is..

out come can (1,2,2),(1,2,4),(1,2,6),(3,2,2),(3,2,4),(3,2,6),(5,2,2).(5,2,4),(5,2,6),

(1,4,2),(1,4,4),(1,4,6),(3,4,2),(3,4,4),(3,4,6),(5,4,2).(5,4,4),(5,4,6),

(1,6,2),(1,6,4),(1,6,6),(3,6,2),(3,6,4),(3,6,6),(5,6,2).(5,6,4),(5,6,6),

Now, we can put odd outcome in 2nd turn or in 3rd turn

So, probability=(3*27)/6^3=1/8

 0 votes -- srestha ( 11585 points)

15.121 if A,B and C are collectively exhaustive and mutually exhaustive. B is


twice as likely as A, C is 2.5 times as likely as B. what can be their
probabilities ? top gateoverflow.in/13772

They all together are mutually exhaustive and mutually exclusive

Means

A+B+C=1

B is twice then A so If probability of

is x then B is 2x and then C is 2.5*2x= 5x

So we can write x+2x+5x=1

Then x=.125 (A)

0.25(B) 0.625(C)

 1 votes -- Pranay Datta ( 6113 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1764 of 2244

15.122 what is the probability of a successful transmission if exactly one


station should transmit the data ? top gateoverflow.in/28989

If there are n stations and each station can send data with probability n ,Now if at any instant of time there should be
exactly one station which should transmit data then for finding the probability for this why can't I do p/np =1/n

since favourable case will be p since only 1 station will transmit and out of total cases to be np , what is wrong in this
approach ?

if a station want to successfully transmit this is the probability 1/n . it is not the maximum probability but this is true. it
can also be seen as Nc1 * p* (1-p)^(n-1). which is also equal to 1/n .

 1 votes -- Ravi Singh ( 7303 points)

15.123 probability top gateoverflow.in/28288

Explain this question . what they mean ?


A six faced die is so biased that, when thrown, it is twice as likely to show
an even number than an odd number. if it is thrown twice, what is the
probability that sum of two numbers thrown is odd
ans = 4/9


Selected Answer

P(even) = 2/3

P(odd) = 1/3

Now, sum is odd if either {even, odd} or {odd , even} occur on dices respectively , which gives

P(sum odd) = P(even) * P(odd) + P(odd) * P(even)

= 2/3 * 1/3 + 1/3 * 2/3

= 4/9

 2 votes -- Himanshu Agarwal ( 8861 points)

15.124 probability top gateoverflow.in/7594

The standard normal probability function can be approximated as

where xN = standard normal deviate. If mean and standard deviation of annual


precipitation are 102 cm and 27 cm respectively, the probability that the annual
precipitation will be between 90 cm and 102 cm is
(A) 66.7% (B) 50.0%
(C) 33.3% (D) 16.7%

plz explain ur answere...

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1765 of 2244

The answer is 16.7%

since you have mentioned that μ = 102 and σ = 27 the points 90 and 102 translate to -0.444 and 0 in standard normal
distribution x − μ/σ. To find the probability of the region between 90 and 102 (ie -0.44 and 0 in SND), F(0)=
1/(1 + exp( − 1.7255 ∗ 0))-F(-0.444)=1/(1 + exp( − 1.7255 ∗ ( − .44)(.44)0.12))

=0.5-0.339

=.16.

The shaded region shows the required region. but here Z is -0.444 and by symmetry we can have it on the other side too.

 2 votes -- Gowthaman Arumugam ( 1079 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1766 of 2244

16 Set Theory & Algebra top


16.1 Ace Test Series: Which composite function is not defined..? top gateoverflow.in/37514

I thought answer would be (C). Because, inner 'f' is outputting values 8, 9, 3, 1, 2. So, outer 'f' should take these values for
final output. But as these values are not in its domain [S], so that should be undefined.. Right?

set-theory&algebra ace-test-series

You are correct. C is correct answer, but because of same explanation, B should also be correct answer.

gof(x) = g(f(x))

On computing f(x), it gives output that belongs to the set T. This output serves as input of g(x). But the valid domain set
for g(x) is S, while it is receiving its input in domain T, hence we say that gof(x) is not defined too.

 1 votes -- Gaurav Sharma ( 1383 points)

16.2 Boolean Algebra: Boolean Algebra top gateoverflow.in/26138

Consider a Hasse Diagram for a Boolean Algebra of Order 3

What can we comment about it?


How is it successfully able to represent the Boolean Algebra System?
Is there an easy way to check for distributive lattice, or any other properties of a lattice?

Given/Know :
¯
⟨B, ∨ , ⋅ , , 0, 1⟩ is a Boolean Algebra, and for any 3 of its arbitrary elements a, b, c in B the following postulates are satisfied:

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1767 of 2244

where, ∨ is Boolean Sum


⋅ is Boolean Product
¯
is Complement

It is not expected that one should provide a complete answer to all parts of the question. Whatever one can
supply to support its answer is welcomed.

partial-order boolean-algebra lattice engineering-mathematics set-theory&algebra

It is a bounded, distributive and complemented lattice. So, it must be a boolean algebra

 0 votes -- srestha ( 11585 points)

16.3 Equivalence Classes: Determine the given relation is Equivalence

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1768 of 2244

Relation or not. top gateoverflow.in/42153

R1 ⊕ R2

I know that R1 ⊕ R2 = R1 ∪ R2 − R1 ∩ R2 , and R1 ∪ R2 is not necessarily an equivalence relation but R1 ∩ R2 is always an


equivalence relation, when we subtract what we will get? For example consider this, what will be the graph of R1 ⊕ R2 ?

relations set-theory&algebra equivalence-classes

16.4 Equivalence Classes: Which of these relations on the set of all functions
from Z to Z are equivalence relations? top gateoverflow.in/42202

Which of these relations on the set of all functions from Z to Z are equivalence relations?

(a) {(f, g) ∣ f(1) = g(1)}

(b) {(f, g) ∣ f(0) = g(0) or f(1) = g(1)}

(c) {(f, g) ∣ f(x) − g(x) = 1 for all x ∈ Z}

In this question, what does it mean by f(1) = g(1) and f(1) - g(1)? And how it satisfies all the conditions (Symmetric,
Transitive and Reflexive) of equivalence relation. Actually I cannot able to analyze when the relations defined on set of
function. If anyone describe a bit it would helpful.

set-theory&algebra relations functions equivalence-classes

(a) equivalence relation

f has one element ,say i.e. 1 . Two function (f and g) merging in one element . Relation will be (1,1)

(b) not reflexive

f has 2 elements , say i.e. 1,2 .But relation is (1,1) or (2,2) , but may not both

(c) not reflexive, not symmetric

distance between same element of f to g is 1 . But distance between g to f is -ve , which is not possible. So, it is not even
symmetric

 0 votes -- srestha ( 11585 points)

16.5 Equivalence Classes: Determining a given subset is partition or not? top


gateoverflow.in/42155

Which of these collections of subsets are partitions of the set of bit strings of length 8?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1769 of 2244

(a) the set of bit strings that end with 00, the set of bit strings that end with 01, the set of bit strings that end with 10, and
the set of bit strings that end with 11.

(b) the set of bit strings that end with 111, the set of bit strings that end with 011, and the set of bit strings that end with
00

Answer: a is a partition

Confusion is, why b is not a partition. We know that, the elements of different partition must be unique and union of all
partition should be equal to the set itself. I can't find any overlapping elements between different partition of (b) and if there
is any, then why not in (a).

relational-algebra relations equivalence-classes set-theory&algebra


Selected Answer

Disjoint Union of suset is called Partition.

In option (a) they are saying set of bit string end with 00, 01, 10, 11 .Option (a) is definitely partition of 8 bit string.
Becouse they are disjoint as well as union of all subsets givesAll bit string of length 8.

In option (b) they are saying set of bit string ends with 111, 011 , 00 . Yes these are disjoint but combination of all (i.e.
Union) is not same as Statement (all 8 bit string). So it is not partition.

 0 votes -- Digvijay Pandey ( 26245 points)

16.6 Functions: functions top gateoverflow.in/6435

Let f: A → B and E and F be subsets of A. Is below statement true or false?

S: f(E ∩ F) = f(E) ∩ f(F)

functions


Selected Answer

False :

Consider E: {1, 2, 3, 4}, F: {3, 4, 5, 6}

f(E) = {5, 6, 7, 8}

f(F) = {7, 8, 11, 6}

f(E ∩ F) = {7, 8}

where as, f(E) ∩ f(F) = {6, 7, 8}

Becomes TRUE only when f is one-one (injective).

Alternatively

f(E ∩ F) ⊆ f(E) as intersection never adds any new element to a set and a function should have a mapping for all elements in
domain.

Similarly, f(E ∩ F) ⊆ f(F)

Combining both,

f(E ∩ F) ⊆ f(E) ∩ f(F)

⊆ becomes = only when f is one-one - when the mappings are unique for each element.

 2 votes -- vishal8492 ( 245 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1770 of 2244

16.7 Functions: injection and surjection top gateoverflow.in/25897

functions


Selected Answer

Injective means one-one.

If f and g are injective then gof must be injective. So, S1 is TRUE.

gof is surjective (onto) meaning - codomain = range. So, gof maps every element in C which is its codomain set. Since gof
is surjective g must be surjective. Now g is an injection meaning it maps one-one. Thus, g becomes bijection.
g being bijective means, for every element in B there is a corresponding unique element in C and vice-versa. gof maps to
every element in C. So, it must be the case that f maps to every element in B- otherwise the corresponding element in C
won't be mapped to by g. Hence, f must be surjective.

So, C option is correct.

 2 votes -- Arjun Suresh ( 124125 points)

16.8 Functions: If f:X→Y and a, b⊆X, then top gateoverflow.in/17919

If f: X → Y and a, b ⊆ X, then
f(a ∩ b) is equal to

A. f(a)– f(b)
B. f(a) ∩ f(b)
C. a proper subset of f(a) ∩ f(b)
D. f(b)– f(a)

set-theory&algebra functions

The only requirement to answer the above question is to know the definition of function- a relation becomes a function if
every element in domain is mapped to some element in co-domain and no element is mapped to more than one element.

Now, we have a, b ⊆ X. Their intersection can be even empty set. So, lets try out options:

options a and d don't even need a check.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1771 of 2244

Lets take a case where a ∩ b = ϕ. Now, f(a ∩ b) = ϕ, but f(a) ∩ f(b) can be non empty. So, option B can be false.

Option C is always true provided "proper subset" is replaced by "subset". This is because no element in domain of a
function can be mapped to more than one element. And the subset needn't be "proper" as for a one-one mapping, we get
f(a ∩ b) = f(a) ∩ f(b).

 1 votes -- Arjun Suresh ( 124125 points)

16.9 Functions: No of surjective functions top gateoverflow.in/5596

The number of surjective functions defined from A to B where |A| = 5, |B| = 4, is _______

set-theory&algebra functions


Selected Answer

We have 4 elements in set B and 5 elements in set A and surjection means every element in B must be mapped to. So,
this problem reduces to distributing 5 distinct elements (r = 5) among 4 distinct bins (n = 4) such that no bin is empty,
which is given by n! S(r, n), where S(r, n) is Stirling's number of 2nd kind. So, here we need S(5, 4).

We have S(r+1, n) = n* S(r, n) + S(r, n-1)

1 1

1 3 1

1 7 6 1

1 15 25 10 1

So, S(5,4) = 10 and 4! = 24 giving, number of surjective functions = 24 * 10 = 240

Ref: See Theorem 9:

http://www.cse.iitm.ac.in/~theory/tcslab/mfcs98page/mfcshtml/notes1/partset.html

 5 votes -- Arjun Suresh ( 124125 points)

if no of elements in A is m and no elements in B is n then,

0) no. of functions possible from A → B is : nm

1) one-to-one (injective) functions possible : n Pm

2) surjection

if no of elements | A | = | B | then no of onto (surjective) functions are n!

i f | A | = n and | B | = m and m > n then no of onto functions from A → B is :


nm − n C1 (n − 1)m + n C2 (n − 2)m − n C3 (n − 3)m + … + ( − 1)n −1n Cn −1 1m

3) Bijection

if | A | = | B | then bijection possible. here no of bijection possible from A → B are : n!

 4 votes -- jayendra ( 5797 points)

ans 240

 2 votes -- Supromit Roy ( 483 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1772 of 2244

16.10 Functions: If F and G are Boolean functions of degree n Then, which of


the following is true ? top gateoverflow.in/41920

If F and G are Boolean functions of degree n. Then, which of the following is true ?

(A) F ≤ F + G and F G ≤ F

(B) G ≤ F + G and F G ≥ G

(C) F ≥ F + G and F G ≤ F

(D) G ≥ F + G and F G ≤ F

functions


Selected Answer

let the F & G be two boolean function of degree 1:

with degree n =2^2^n total boolean function

with degree n= 2^2^1=4 boolean function

F^1-->F & G^1-->G

F=( 4 boolean function)

G= (4 boolean function)

F+G=( 8 boolean function)

F*G= (16 boolean function)

so answer is B

 1 votes -- Tauhin Gangwar ( 509 points)

16.11 Functions: ME_Test_Series - Discrete Maths top gateoverflow.in/36193

Let f: A → B and g: B → C denote two functions. Consider the following two statements:
S1 : If both f and g are injections then the composition function gof : A → C is an injection.
S2 : If the function gof : A → C is surjection and g is an injection then the function f is a surjection.

Which of the above statements are valid?

a) S 1 only

b) S2 only

c) S 1 and S 2

d) None of these

made-easy test-series functions engineering-mathematics

16.12 Functions: functions top gateoverflow.in/35091

Suppose that f is a function from A to B.We define the function Sf from P(A) to P(B) by the rule Sf(X) = f(X) for each subset X of
A. Similarly, we define the function Sf−1 from P(B) to P(A) by the rule Sf−1 (Y) = f −1 (Y) for each subset Y of B.

Q. Suppose that f is a function from the set A to the set B. Prove that
a) if f is one-to-one, then Sf is a one-to-one function from P(A) to P(B).
b) if f is onto function, then Sf is an onto function from P(A) to P(B).
c) if f is onto function, then Sf−1 is a one-to-one function from P(B) to P(A).

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1773 of 2244

d) if f is one-to-one, then Sf−1 is an onto function from P(B) to P(A).


e) if f is a one-to-one correspondence, then Sf is a one-to-one correspondence from P(A) to P(B) and Sf−1 is a one-to-one
correspondence from P(B) to P(A).
[Hint: Use parts (a)-(d).]

functions

16.13 Generators: What are the generators for the group G having
multiplication modulo 6 as an operation? top gateoverflow.in/20639

What are the generators for the group G={1,2,3,4,5,6} having multiplication modulo 6 as an operation?

set-theory&algebra groups generators

G is not group here...

For eg 3*2 mod 6=0

0 is not in G

G is not satisfying closure property..so it is not group

 2 votes -- Pooja ( 22773 points)

If in a Group there is atleast one generator present then we can say Group is cyclic.

A Group(G,*) is called a cyclic group if there exist an element a∈G such that every element of G can be
written as an for some integer n.Then a is called generating element or generator.

Before check Group is cyclic Group or not we have to check given set is Group or not.

Simply Make composition table for check it

⊗6 1 2 3 4 5 6
1 1 2 3 4 5 0
2 2 4 0 2 4 0
3 3 0 3 0 3 0
4 4 2 0 4 2 0
5 5 4 3 2 1 0
6 0 0 0 0 0 0

Here elements 2,3,4 and 6 doesn't have inverse that is necessary to make a Group.

Alternate way check Given set is Group or not:-

To make a Group following conditions should be satisfy:

1.Closure Property

2.Associativity

3.Identity

4.Inverse

By 1st property

1 ⊗6 6 = 0 but 0 is not present in set.

given set is not a Group.

Given set can't be cyclic Group so there is no Generator present.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1774 of 2244

 1 votes -- Leen Sharma ( 2935 points)

16.14 Group: group theory top gateoverflow.in/32674

Which of the following is not a group?

Set of integer under multiplication operation.


Set of natural number under multiplication.
Set of natural number under addition.
All of the above

Why is it not group under addition?

Ans given is d.

graph-theory set-theory&algebra group

16.15 Group: Group theory top gateoverflow.in/33339

The set of matrices S =


{[ x
−x
−x
x ] }
| 0 ≠ x ∈ R forms a group under matrix multiplication operation with identity element :

a) [ ] 0
1
1
0

b)
[ 1
−1
−1
1 ]
c)
[ −1
1 −1
1
]

[ ]
1 1
2
−2
d) 1 1

−2 2

set-theory&algebra group


Selected Answer

Answer is D.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1775 of 2244

 1 votes -- Sayantan Ganguly ( 5061 points)

16.16 Groups: Which of the following statements is/are true? top gateoverflow.in/30728

Which of the following is/are True?

S1 : Set of Integers on addition operation is Monoid but not group.

S2 : Set of Integers on subtraction operation is Monoid but not group.

S3 : Set of Integers on multiplication operation is group but not Abelian group.

please elaborate on s2 statement.

set-theory&algebra groups


Selected Answer

S1: It is False

addition of Integer is closed

Addition of integer is associative ((1+2)+3)=(1+(2+3))

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1776 of 2244

Identity property also satisfied 0+1=1, here identity element is 0

Inverse of 1 is (-1), 1+(-1)=0, So, inverse also satisfied

So, Integer addition will be a group

S2: It is also false

Associativity also not satisfied

((7-2)-3) not equal with (7-(2-3))

i.e.(5-3) not equal with (7+1)

but in monoid we have to satisfy associativity and identity property

S3: Also False

As, Integer multiplication doesnot satisfy inverse property

inverse of 2 will be 1/2

which is not an integer

So, Integer multiplication cannot form a group

 0 votes -- srestha ( 11585 points)

16.17 Groups: Firstly, What is identity element for this group? top gateoverflow.in/20581

A = {0, 1, 2, 3, 4, 5, 6, …23}
a ∗ b = (a + b) mod 24
How many proper subgroups does the group G(A, ∗ ) have?

groups


Selected Answer

It is cyclic group identity of this group is 0.

According to Lagrange's theorem, the order of the subgroup divides the order of the group.

In order to find the number of proper subgroups, we need to find the proper divisors of 24

24 = 23 × 31

No of proper divisors = 4 × 2 − 2 = 6

So 6 subgroups are there.

 2 votes -- Pooja ( 22773 points)

16.18 Groups: Explain me this example on Homomorphism top gateoverflow.in/28750

Please explain following example in Detail, I'm not able to understand this explanation.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1777 of 2244

set-theory&algebra groups

16.19 Groups: maths_mocktest1_30 top gateoverflow.in/7856

Let G be a finite group. If A and B are subgroups of G with orders 4 and 5 respectively, then | A ∩ B | = ______.

set-theory&algebra groups


Selected Answer

A and B are subgroup of order 4 and 5 respectively..


Any element in A has to have order 1, 2 or 4.
Any element in B has to have order 1 or 5.

Now, common element between A and B must have same order. Only common order possible is 1..
Now find no of elements with order 1. Order 1 is special element and we call as identity element. In any group at most
and exactly 1 identity element exist.

So no of elements common in A and B is 1.

Alternative methods
Method 1:

Intersection property of two sub group of a group, states that A∩B is a subgroup of A as well as B. Now, using Lagrange's
theorem (order of subgroup must divide order of group), |A∩B| must divide |A| as well as |B|. Only common divisor for 4
and 5 is 1. So, |A∩B| = 1.

ref@http://math.stackexchange.com/questions/1364274/let-g-be-finite-group-if-
a-b-le-g-with-orders-4-5-respectively-then-a

@http://www.quora.com/Let-G-be-finite-group-if-A-and-B-are-subgroups-of-G-with-orders-4-and-5-respectively-then-A-
%E2%88%A9-B

 3 votes -- Digvijay Pandey ( 26245 points)

16.20 Hasse Diagram: Lattices | hasse-diagram top gateoverflow.in/34694

Why the following Hasse Diagram is not a lattice ...?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1778 of 2244

hasse-diagram

16.21 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1.2 QueNo-5 top gateoverflow.in/42919

Translate the given statement into propositional logic using the propositions provided.
You are eligible to be President of the U.S.A. only if you are at least 35 years old, were born in the U.S.A, or at the time of
your birth both of your parents were citizens, and you have lived at least 14 years in the country.
Express your answer in terms of
e: “You are eligible to be President of the U.S.A.,”
a: “You are at least 35 years old,”
b: “You were born in the U.S.A,” p: “At the time of your birth, both of your parents where citizens,”
and r: “You have lived at least 14 years in the U.S.A.”

kenneth-rosen descriptive set-theory&algebra

e: “You are eligible to be President of the U.S.A.,”


a: “You are at least 35 years old,”
b: “You were born in the U.S.A,” p: “At the time of your birth, both of your parents where citizens,”
and r: “You have lived at least 14 years in the U.S.A.”

SO from that here are three conditions that has to be satisfied

1.Above 35 year

2. Born in USA or Parents were in USA

3.lived above 14 years

AS they have to be satisfied together so AND operator to be used

so it is (a ^(b v p) ^r)--->e

 0 votes -- Uddipto ( 535 points)

16.22 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1.2 QueNo-6 top gateoverflow.in/42920

Translate the given statement into propositional logic using the propositions provided.
You can upgrade your operating system only if you have a 32-bit processor running at 1 GHz or faster, at least 1 GB RAM,
and 16 GB free hard disk space, or a 64-bit processor running at 2 GHz or faster, at least 2 GB RAM, and at least 32 GB free
hard disk space. Express you answer in terms of
u: “You can upgrade your operating system,”
b32: “You have a 32-bit processor,”
b64:“You have a 64-bit processor,” g1: “Your processor runs at 1 GHz or faster,”

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1779 of 2244

g2 : “Your processor runs at 2 GHz or faster,”


r1 : “Your processor has at least 1 GB RAM,”
r2 : “Your processor has at least 2 GB RAM,”
h16: “You have at least 16 GB free hard disk space,”
and h32: “You have at least 32 GB free hard disk space.”

kenneth-rosen set-theory&algebra descriptive

u  ((b 32 ⋀ g 1 ⋀ r 1 ⋀ h 16 ) ⋁ (b 64 ⋀ g 2 ⋀ r 2 ⋀ h 32 ))

 0 votes -- srestha ( 11585 points)

16.23 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1.2 QueNo-15 gateoverflow.in/42944

top

Each inhabitant of a remote village always tells the truth or always lies. A villager will give only a “Yes” or a “No” response to
a question a tourist asks. Suppose you are a tourist visiting this area and come to a fork in the road. One branch leads to
the ruins you want to visit; the other branch leads deep into the jungle. A villager is standing at the fork in the road. What
one question can you ask the villager to determine which branch to take?

kenneth-rosen set-theory&algebra descriptive difficult


Selected Answer

The answer is apparently: " If I were to ask you whether the right branch leads to the ruins, would you answer
yes?"

Explanation:

For the sake of simplicity suppose the left branch leads to the ruins whereas the right one leads you lost deep into the
jungle.

Case 1. The villager is a liar: in this case, since he knows the right branch leads to the jungle then he'd say it leads to the
ruins, but he won't tell you NOW this, so his answer here is NO.

Case 2. The villager tells the truth: he will answer NO again, 'cause he knows the right branch takes you to the jungle and
he will let you k now that.

From the above, it's clear you must choose THE other branch if the answer is NO.

 5 votes -- Rude Maverick ( 3063 points)

16.24 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1.2 QueNo-3 top gateoverflow.in/42917

Translate the given statement into propositional logic using the propositions provided.
You can graduate only if you have completed the requirements of your major and you do not owe money to the university
and you do not have an overdue library book. Express your answer in terms of
g: “You can graduate,”
m: “You owe money to the university,”
r: “You have completed the requirements of your major,”
and b: “You have an overdue library book.”

kenneth-rosen descriptive set-theory&algebra

g: “You can graduate,”


m: “You owe money to the university,”
r: “You have completed the requirements of your major,”

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1780 of 2244

and b: “You have an overdue library book.”

Now no money owe=∿m

no overdue of book=∿b

so

(r ^ (∿m )^ (∿b))---->g

 0 votes -- Uddipto ( 535 points)

16.25 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1.2 QueNo-1 top gateoverflow.in/42914

Translate the given statement into propositional logic using the propositions provided.
You cannot edit a protected Wikipedia entry unless you are an administrator.
Express your answer in terms of e: “You can edit a protected Wikipedia entry”
and a: “You are an administrator.”

kenneth-rosen set-theory&algebra descriptive

To explain this let me give an example first, Consider this statement.

"If there is a rain then I will not go to college unless there is holiday."

The propositional representation will be, let

P: There is a rain

Q: I will not go to college

R : There is a Holiday.

So, Propositional formula will be : (P ^ R) -> Q

So comes to your problem, Give statement is " You cannot edit a protected Wikipedia entry unless you are an
administrator".

Given, e: “You can edit a protected Wikipedia entry”

a: “You are an administrator.”

Then Propositional Formula will be

a -> e.

 2 votes -- Rude Maverick ( 3063 points)

16.26 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1.2 QueNo-2 top gateoverflow.in/42915

Translate the given statement into propositional logic using the propositions provided.
You can see the movie only if you are over 18 years old or you have the permission of a parent. Express your answer in
terms of
m: “You can see the movie,”
e: “You are over 18 years old,”
and p: “You have the permission of a parent.”

kenneth-rosen set-theory&algebra descriptive


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1781 of 2244

m (e⋁ p)

 1 votes -- srestha ( 11585 points)

16.27 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1.2 QueNo-7 top gateoverflow.in/42921

Express these system specifications using the propositions p “The message is scanned for viruses” and q “The message was
sent from an unknown system” together with logical connectives (including negations).

a. “The message is scanned for viruses whenever the message was sent from an unknown system.”
b. “The message was sent from an unknown system but it was not scanned for viruses.”
c. “It is necessary to scan the message for viruses whenever it was sent from an unknown system.”
d. “When a message is not sent from an unknown system it is not scanned for viruses.”

kenneth-rosen set-theory&algebra

a. “The message is scanned for viruses whenever the message was sent from an unknown system.” = Q->P (whenever ==
if)
b. “The message was sent from an unknown system but it was not scanned for viruses.”= (Q ∧ ~P) ( but == and)
c. “It is necessary to scan the message for viruses whenever it was sent from an unknown system.” = (Q ->P)
d. “When a message is not sent from an unknown system it is not scanned for viruses.” =(~Q -> ~P)

 0 votes -- Anirudh Pratap Singh ( 4091 points)

16.28 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1.2 QueNo-4 top gateoverflow.in/42918

Translate the given statement into propositional logic using the propositions provided.
To use the wireless network in the airport you must pay the daily fee unless you are a subscriber to the service. Express your
answer in terms of

w: “You can use the wireless network in the airport,”


d: “You pay the daily fee,”
and s: “You are a subscriber to the service.”

kenneth-rosen set-theory&algebra descriptive

16.29 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1.2 QueNo-12 gateoverflow.in/42927

top

Are these system specifications consistent? “If the file system is not locked, then new messages will be queued. If the file
system is not locked, then the system is functioning normally, and conversely. If new messages are not queued, then they
will be sent to the message buffer. If the file system is not locked, then new messages will be sent to the message buffer.
New messages will not be sent to the message buffer.”

kenneth-rosen set-theory&algebra mathematical-logic

This system is consistent. We use L,Q,N, and B to stand for the basic propositions here, “The filesystem is locked,” “New messages will be queued,” “The system is functioning
normally,” and “Newmessages will be sent to the message buffer,” respectively. Then the given specifications are ¬L?Q,¬L?N, ¬Q?B, ¬L?B, and ¬B. If we want consistency,
then we had better have B false in order that¬B be true. This requires that both L and Q be true, by the two conditional statements that have B falsein order that ¬B be true

 0 votes -- shekhar chauhan ( 643 points)

16.30 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1.2 QueNo-14 gateoverflow.in/42943

top

What Boolean search would you use to look for Web pages about hiking in West Virginia? What if you wanted to find Web

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1782 of 2244

pages about hiking in Virginia, but not in West Virginia?

kenneth-rosen set-theory&algebra descriptive

What Boolean search would you use to look for Web pages about hiking in West Virginia?

Answer: ("Hiking") AND ("West Virginia") : This will return all the webpages which have Keyword "Hiking" and "West
Virginia" both.

What if you wanted to find Web pages about hiking in Virginia, but not in West Virginia?

Answer: (("Hiking") AND ("Virginia")) AND (NOT(("Hiking") AND ("West Virginia"))) : This will return all the
webpages which contain "Hiking" and "Virginia", but it will neglect all the webpages which have "hiking" and "west
Virginia".

If you want to see that how its working then look at this.

 2 votes -- Rude Maverick ( 3063 points)

16.31 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1.2 QueNo-11 gateoverflow.in/42926

top

Are these system specifications consistent? “The router can send packets to the edge system only if it supports the new
address space. For the router to support the new address space it is necessary that the latest software release be installed.
The router can send packets to the edge system if the latest software release is installed, The router does not support the
new address space.”

kenneth-rosen set-theory&algebra descriptive

Consistent means that, "If All the propositional formula in the system can be true simultaneously then that
system is called Consistent."

Now Comes to the Questions, We can take,

P : The router send packets to the edge system

Q : Router supports the new address space

R : The latest software release is installed in the router.

Now we will get the following propositional formula

1) The router can send packets to the edge system only if it supports the new address space, ( Q --> P)

2) For the router to support the new address space it is necessary that the latest software release be installed. ( R-->Q )

3) The router can send packets to the edge system if the latest software release is installed. ( R-->P)

4) The router does not support the new address space. ( ~Q).

Here Take (Q = F) and (R = F), All the Formula will be True. Hence This system is Consistent.

 2 votes -- Rude Maverick ( 3063 points)

16.32 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1.2 QueNo-13 gateoverflow.in/42929

top

What Boolean search would you use to look for Web pages about beaches in New Jersey? What if you wanted to find Web
pages about beaches on the isle of Jersey (in the English Channel)?

kenneth-rosen set-theory&algebra descriptive

16.33 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1.2 QueNo-10 gateoverflow.in/42924

top

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1783 of 2244

Are these system specifications consistent? “Whenever the system software is being upgraded, users cannot access the file
system. If users can access the file system, then they can save new files. If users cannot save new files, then the system
software is not being upgraded.”

kenneth-rosen set-theory&algebra descriptive

Let the following statements be represented symbolically as shown:

u: “The software system is being upgraded.”


a: “Users can access the file system.”
s: “Users can save new files.”

Now,

a) “Whenever the system software is being upgraded, users cannot access the file system.”

u→¬a

b) “If users can access the file system, then they can save new files.”

a→s

c) “If users cannot save new files, then the system software is not being upgraded.”

¬s→¬u

d) Is the system consistent?

Yes, for example making u false, a false, and s true makes it consistent.

 2 votes -- Rude Maverick ( 3063 points)

16.34 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1.2 QueNo-9 top gateoverflow.in/42923

Are these system specifications consistent? “The system is in multi-user state if and only if it is operating normally. If the
system is operating normally, the kernel is functioning. The kernel is not functioning or the system is in interrupt mode. If
the system is not in multiuser state, then it is in interrupt mode. The system is not in interrupt mode.

kenneth-rosen set-theory&algebra descriptive

Consider,

P: System is on multi-user state

Q : System is operating normally

R: The kernel is functioning

S: System is in interrupt mode

Then We will get following Prepositional Formula,

1) The system is in multi-user state if and only if it is operating normally. ( P <--> Q)

2) If the system is operating normally, the kernel is functioning. ( Q --> R)

3) The kernel is not functioning or the system is in interrupt mode. ( ~R V S)

4) If the system is not in multi-user state, then it is in interrupt mode. ( ~P --> S)

5) The system is not in interrupt mode ( ~S)

Now,

In (5), We have to take S = F, then and only then we get (5) as True.

In (3), We have taken S = F, then we have to take ( R = F) then and only then we will get (3) as True.

In(4), Since S = F, then we have to take ( P = T), then and only then we will get (4) as True.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1784 of 2244

In(2), Since R = F, then we have to take (Q = F), then and only then we will get (2) as True.

In(1), we have P = T and Q = F, which can never generate a true value, (1) will be false.

Hence this System is not Consistent.

 2 votes -- Rude Maverick ( 3063 points)

16.35 Kenneth Rosen: Kenneth Rosen Edition7 Ch-1 Ex-1.2 QueNo-8 top gateoverflow.in/42922

Express these system specifications using the propositions p “The user enters a valid password,” q “Access is granted,” and r
“The user has paid the subscription fee” and logical connectives (including negations).

a. “The user has paid the subscription fee, but does not enter a valid password.”
b. “Access is granted whenever the user has paid the subscription fee and enters a valid password.”
c. “Access is denied if the user has not paid the subscription fee.”
d. “If the user has not entered a valid password but has paid the subscription fee, then access is granted.”

kenneth-rosen set-theory&algebra


Selected Answer

a) r ⋀~p

b)(r⋀p)q

c) ~r  ~q

d) (~p ⋀r) q

 1 votes -- srestha ( 11585 points)

16.36 Lattice: maths_mock_test4 top gateoverflow.in/7736

set-theory&algebra lattice

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1785 of 2244


Selected Answer

2 is correct answer. fig 2, b and c have {f,g} as upperbound. but for the graph to be a lattice it should have a least upper
bound. Since b and c have two upper bounds they cannot have a least upper bound<which is always unique for a pair for
vertices>. In other words we cannot say which one is least one out of the pair {f,g}. therefore it is not a join
semilattice(every pair of element should have a least upper bound). henceforth it is also not a lattice

 5 votes -- Madhur Rawat ( 2379 points)

16.36 Lattice: Does isomorphic Hasse diagrams represent two different


posets or same poset? top gateoverflow.in/3986

lattice

okay, i got the answer. :P

A Hasse diagram uniquely determines the relations in a partially ordered set, so two isomorphic Hasse diagrams represent two isomorphic posets,
provided that they are isomorphic as directed graphs.

 0 votes -- ujjwal saini ( 301 points)

16.37 Lattice: Is it lattice top gateoverflow.in/31481

Why is it not lattice?

set-theory&algebra lattice


Selected Answer

A lattice must be first a poset i.e. it should be reflexive , anti-symmetric and transitive.

Here b ≤ c & c ≤ b so, it is not antisymmetric & hence not a lattice.

 4 votes -- Himanshu Agarwal ( 8861 points)

16.38 Lattice: What are the complement pairs for the following lattice? top
gateoverflow.in/20512

What are the complement pairs for the following lattice?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1786 of 2244

set-theory&algebra lattice


Selected Answer

There are two complement pair here ->

Meet(4,3) -> 1

Join(4,3) ->12

There is another pair here -> Upper & Lower bounds are also compliments of each other.

Meet(1,12)->1

Join(1,12) ->12

 1 votes -- Akash ( 26315 points)

16.39 Madeeasy: symmetric and antisymmetric top gateoverflow.in/33693

from definitoin of antisymmetry if aRb and bRa is present then a=b.

so b should be answer,though d is right,but b is more appropriate

set-theory&algebra relations sets madeeasy

no b is not correct....

(a,b) and (b,a) makes it symmetric and not antisymmetric

for relation to be symmetric and antisymetric only self pairs are allowed

so d is ans

 3 votes -- Pooja ( 22773 points)

(a) It is not symmetric since (a,c) ∈ R but (c,a) ∉ R

(b) It is symmetric but not antisymmetric.

Its by definition only.

a binary relation R on a set X is antisymmetric

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1787 of 2244

if R(a,b) and R(b,a), then a = b,

or, equivalently,

if R(a,b) with a ≠ b, then R(b,a) must not hold.

So in option (b) (aRb) with a ≠ b and (bRa) is also holding,Thats why its not antisymmetric.

Ref : https://en.wikipedia.org/wiki/Antisymmetric_relation

(c) Its also not antisymmetric.

(d) It is satisfying both the properties.

 1 votes -- Sandeep Singh ( 5939 points)

16.40 Partial Order: Which relations are partial orders? top gateoverflow.in/38606

Argument: R2 is straight away eliminated. For R3, to satisfy Antisymmetric relation.. Say -2 and +2 satisfy it then +2 and -2
should not satisfy. But its not the case. Answer is given as C. Am I so blind that I couldn't figure out my mistake?

partial-order engineering-mathematics ace-test-series

16.41 Partial Order: Number of edges in the Hasse Diagram of a boolean


algebra with 8 elements. top gateoverflow.in/26120

partial-order


Selected Answer

there are 12 edges :

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1788 of 2244

 3 votes -- Amar Vashishth ( 17865 points)

16.42 Pigeonhole: Pigeon Hole Principle top gateoverflow.in/36222

The least num of computers required to connect 8 computers to 4 printers to guarantee 4 comp can direct]ly access 4
printer is _____

16
17
19
20
21

pigeonhole

16.43 Relations: Let R be the relation on the set of all colorings of the 2 × 2
checkerboard where each of the four squares is colored either red or blue top
gateoverflow.in/4725
Let R be the relation on the set of all colorings of the 2 × 2 checkerboard where each of the four squares is colored
either red or blue so that (C 1 , C 2 ), where C 1 and C 2 are 2 × 2 checkerboards with each of their four squares colored
blue or red, belongs to R if and only if C 2 can be obtained from C 1 either by rotating the checkerboard or by rotating it and
then reflecting it.

Solve the following:


a) Show that R is an equivalence relation.
b) What are the equivalence classes of R?

set-theory&algebra relations

16.44 Relations: The relation T is top gateoverflow.in/28299

“n/m” means that n is a factor of m, then the relation T is

(a) reflexive and symmetric

(b) transitive and symmetric

(c) reflexive, transitive and symmetric

(d) reflexive, transitive and not symmetric

Ans: option (d) But how ?

set-theory&algebra relations

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1789 of 2244

For relation to be symmetric if (m,n) belong to R then (n,m) also belongs to R ie m is factor of n and n is factor of m this
is possible only when m=n this relation is antisymmetric for eg(2,4) belongs to R but (4,2) does not belong to r so ans is
d

 0 votes -- Pooja ( 22773 points)

16.45 Relations: if R1 is irreflexive and R2 is irreflexive then is R1 union R2


reflexive ? true or false top gateoverflow.in/41737

if R1 is irreflexive and R2 is irreflexive then is R1 ∪ R2 reflexive ? true or false

set-theory&algebra relations

FALSE.

If relations R1 and R2 are irreflexive, then the relations R1 U R2, R1 ⋂ R2, R1 -1 are also Irreflexive.

 2 votes -- vamsi2376 ( 1185 points)

16.46 Relations: Determine whether the relation is reflexive, symmetric,


anti-symmetric, and/or transitive? top gateoverflow.in/41907

Determine whether the relation R on the set of all Web pages is reflexive, symmetric, antisymmetric, and/or transitive,
where (a, b) ∈ R if and only if

a) everyone who has visited Web page a has also visited Web page b.

b) there are no common links found on both Web page a and Web page b.

c) there is at least one common link on Web page a and Web page b.

d) a is taller than b.

e) a and b were born on the same day.

f) a has the same first name as b.

I have the knowledge about the reflexive, symmetric, anti-symmetric, and transitive also I can able to solve the problems
when the relations are defined in ordered pairs. But can't able to visualize this kind of relations.

set-theory&algebra relations


Selected Answer

1. a is taller than b. Looks like A>=B now it is reflexive , antisymmetric ,and transitive.

example : a= 10; b= 3 or 10 then 10>=3 true so antisymmetric

10=10 so reflexive.

2. a and b were born on the same day. Looks like A=B now it is reflexive, symmetric, transitive , anitisymmetric.

 0 votes -- Anirudh Pratap Singh ( 4091 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1790 of 2244

16.47 Relations: Relations - Set Theory top gateoverflow.in/34622

Let A = {1,2,3 }

R= {(1,1)(2,2)(3,2)(1,2)(2,3)}

S= {(1,1)(2,2)(3,3)(2,3)(3,2)}

Which of the following ARE correct Justify Each Option ( for my understanding )

R is not reflexive (3,3) is missing


R is not anti symmetric (3,3) is missing
R INTERSECTION S is an Equivalence Relation
R is an equivalence Relation where as R UNION S is Not.

1. Pls tell me one Anti-Symmetric Relation other than diagonal pairs

set-theory&algebra relations


Selected Answer

R is not reflexive ->reason given by you

R is not anti symmetric as it have (2,3)and {3,2} .R intersection S not equivalence--->as it is not reflexive(as {3,3}
missing.

R is not equivalence relation {3,3} missing

R U S not equivalence---{2,1} missing

 2 votes -- sourav anand ( 1585 points)

16.48 Relations: Let p(n) denote the number of different equivalence


relations on a set with n elements. top gateoverflow.in/4724

Solve.

a) Show that satisfies the recurrence relation and the initial condition p(0) = 1.
b) Find the number of different equivalence relations on a set with n elements, where n is a positive integer not exceeding
10

set-theory&algebra relations

number of equivalence relation =n*(n-1)/2.

you can check for any relation.

 0 votes -- sourav anand ( 1585 points)

16.49 Relations: Rosen 9.1 - 48 top gateoverflow.in/42082

How many transitive relations are there on a set with n elements if

(a) n = 1

(b) n = 2

(c) n= 3

Answer has not been given. How do I calculate number of transitive relations?

For n = 1, there will be 1 transitive relation.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1791 of 2244

For n = 2, If (a, b)εR and (b, a)εR the (a, a)εR and (b, b)εR. But how can we calculate this?

set-theory&algebra relations relational-algebra


Selected Answer


(a) take only self loops (not necessarily all at a time). 4 options.

(b) There are two interconnecting lines.for Transitive relation select any edge (but not both). For each line case (a) occurs. So 2*2 2 = 8

(c) select all self loops all interconnecting edges i.e. whole relation. 1 relation.

 1 votes -- Digvijay Pandey ( 26245 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1792 of 2244

https://en.wikipedia.org/wiki/Transitive_relation?wprov=sfla1

 2 votes -- vamsi2376 ( 1185 points)

16.50 Sets: Find the dual of boolean algebra expresion S dual: top gateoverflow.in/5265

S: (a^b) = a if a<=b
a) S* :(a^b)=a if a<=b
b) S* :(aVb)=a if a<=b
c) S* :(a^b)=a if a>=b
d) S* :(aVb)=a if a>=b

sets set-theory&algebra

I think answer is b) S* :(aVb)=a if a<=b

Dual is obtained by replacing V with ^ and vice versa.

 3 votes -- Keith Kr ( 5467 points)

16.51 Sets: how many subsets does P(A) have if A is null set? top gateoverflow.in/18518

let A={} or phi be null set.it has 0 elements and 1 subset that is itself.
P(A) represents power set of A.how many elements and subsets does P(A) has? i think P(A)={ {} } has 1 element ie {}..now P(A) should have 2 subsets.. {} null set
and P(A)(itself ie set containing null set) so P(A) should have 1 element and 2 subsets..at lot of places ans is given as 1 subset so please clarify?

sets set-theory&algebra


Selected Answer

Yes, you are right Anurag, P(A) has exactly two subsets.

A = ∅, implies |A| = 0, so number of elements in Power Set of A = 2 0 = 1.

P(A) = P(∅) = {∅}.

Now |P(A)| = 1, so cardinality of P(P(A)) = 2 |P(A)| = 2 1 = 2.

This implies the set P(A) = {∅} has exactly two subsets, namely ∅ and P(A)(= {∅}) itself.

P({∅}) = {∅, {∅}}.

If given answer is 1 for number of subsets of P(A), it must be wrong.

 3 votes -- Anurag Pandey ( 8183 points)

16.52 Sets: How many number of possible relations in a antisymmetric set?


top gateoverflow.in/19132

I just want to know how the value in the answers come like 2^n2 and 2^n^2-1 etc. Please make it clear.

sets set-theory&algebra relations

we can derive it through the defination of antisymmetric. if (x,y) and (y,x) exist x=y.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1793 of 2244

so take a set of (1,2,3) now find all relations. of a*a

total 9 ,diagonal elements like (1,1)(2.2)(3,3) should be included.

total number of choices for them is 2^n ( i.e. n elemets have 2 choices either has to come or do not appear.)

total number of choices for for lower diagonal elements will be 3.

because either the lower diagonal should come or the upper diagonal elements or non of them comes.

3^(n2-n/2) three choices for these elemnts

 0 votes -- Ravi Singh ( 7303 points)

16.52 Sets: number of equivalence relation possible with N element of set? top
gateoverflow.in/16891

sets relations


Selected Answer

u can ans this by using concept of Bell no

1 2

2 3 5

5 7 10 15

and so on for n=4 check 4th row ans will be 15

 2 votes -- Pooja ( 22773 points)

See https://en.wikipedia.org/wiki/Bell_number

 1 votes -- Happy Mittal ( 9253 points)

16.53 Sets: Determine the cardinality of the following set top gateoverflow.in/14162

Determine the cardinality of the following set:

{x ∣ x is an integer and 1/8 < x < 17/2}

set-theory&algebra sets


Selected Answer

Smallest value of x =  8  = 1

17

Largest value of x =  2  = 8

Thus 8 integer values- {1, 2, 3, 4, 5, 6, 7, 8}.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1794 of 2244

 4 votes -- Arjun Suresh ( 124125 points)

x value is between 1/8 to 17/2 ie. 0.125<x<8.5.

and x is an integer so between 0.125 to 8.5 there are 8 integers {1,2,3,4,5,6,7,8} so x can be any of these. so cardinality
of the set is 8

 2 votes -- Murali ( 153 points)

16.54 Sets: Set Theory & Algebra: how many ordered pairs top gateoverflow.in/28322

Let n(A) denotes the number of elements in set A. If n(A) = p and n(B) = q, then how many ordered pairs (a, b) are there with
a ∈ A and b ∈ B?

(a) p2

(b) p × q

(c) p + q

(d) 2pq

set-theory&algebra sets


Selected Answer

Take any two sets and try to make ordered pair..


A ={1,2,3,4,5....n}
B = {1,2,3,4,....n}
{(a,b)} = {(1,1) (1,2) (1,3)....(1,n) (2,1) (2,2)....(2,n)........(n,n)}

|{(a,b)}| = p*q

 1 votes -- Digvijay Pandey ( 26245 points)

No of ordered pairs will be pq ( every element of A can be combine with every element of q)

 2 votes -- Pooja ( 22773 points)

16.55 Summation: Find a formula when m is a positive integer? top gateoverflow.in/41906

(a)∑m
k=0 √k 
(b)∑m
k=0 √  k3

Is there any quick way to find the formula for complex expression?

functions set-theory&algebra summation

http://ramanujan.sirinudi.org/Volumes/published/ram09.pdf

check out this link.....

 0 votes -- Ritaban Basu ( 255 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1795 of 2244

16.56 Summation: What are the values of the sum? top gateoverflow.in/41904

​ ∑j ∈S 1 where S = {1, 3, 5, 7}.

if we have ∑nj=1 1 then the answer will be n. But what happens if this a set?

set-theory&algebra summation

S = {1,2,3,4,5.......n }

Sum = 0;

while ( j in S)

Sum = Sum +1

j = j + 1

Return Sum ;

Answer will be 4.

 1 votes -- Digvijay Pandey ( 26245 points)

16.57 Theory: inverse function top gateoverflow.in/35090

Q. Let f be a function from A to B. Let S and T be subsets


of B. Show that
a) f−1(S ∪ T ) = f−1(S) ∪ f−1(T ).
b) f−1(S ∩ T ) = f−1(S) ∩ f−1(T ).

sets theory

16.58 If f:X→Y and a, b⊆X, then f(a⋂b) is equal to top gateoverflow.in/35715

If f:X→Y and a, b⊆X, then f(a⋂b) is equal to


(a) f(a) – f(b) (b) f(a) ⋂ f(b)
(c) a proper subset of f(a) ⋂ f(b) (d) f(b) – f(a)

set-theory&algebra

16.59 which of the following represents R2, where R2 is R composite R? top


gateoverflow.in/35713
If R = ((1, 1), (3, 1), (2, 3), (4, 2)), then which of the following represents R2, where R2 is R composite R?
(a) ((1, 1), (3, 1), (2, 3), (4, 2)) (b) ((1, 1), (9, 1), (4, 9), (16, 4))
(c) ((1, 1), (2, 1), (4, 3), (3, 1)) (d) ((1, 1), (2, 1), (4, 3), (3, 1))

set-theory&algebra

R composite R means RoR

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1796 of 2244

for composition, if (x,y) ∈ R and (y,z) ∈ R then (x,z) ∈ RoR

In given relation R

R = ((1, 1), (3, 1), (2, 3), (4, 2))

(1,1) ∈ R and (1,1) ∈ R so (1,1) ∈ RoR

(3,1) ∈ R and (1,1) ∈ R so (3,1) ∈ RoR

(2,3) ∈ R and (3,1) ∈ R so (2,1) ∈ RoR

(4,2) ∈ R and (2,3) ∈ R so (4,3) ∈ RoR

R2= ((1, 1), (3, 1), (2, 1), (4, 3))

 0 votes -- artiagrahari ( 113 points)

16.60 Let s(w) denote the set of all the letters top gateoverflow.in/35712

Let s(w) denote the set of all the letters in w where w is an English word. Let us denote set equality, subset and union
relations by =, ⊂ and ⋃ respectively.
Which of the following is NOT true?
(a) s(ten) ⊂ s(twenty) (b) s(stored) = s(sorted)
(c) s(sixty) ⊂ (s(six) ⋃ s(twenty) (d) None of these

set-theory&algebra

16.61 How to decide whether set complementation operation is closed for a


relation or not ? top gateoverflow.in/35083

If R1 and R2 are two assymteric relations ,so assymetric relations are closed under intersection operation as well as set-
difference operation,Now

R1 - R2 =R1∩ R2 C

Now when both set-difference and intersection operation are closed then why is this complement operation not closed from
this definition .Also R1∩R2C ⊆ R1 or R2 C

And assymetric relations are closed under subset operation as well so then why is set complementation operation not closed
?

16.62 Rosen , Ch-9, Ex-1, Que. 41 top gateoverflow.in/34705

Let R1 and R2 be the “congruent modulo 3” and the


“congruent modulo 4” relations, respectively, on the set
of integers. That is, R1 = {(a, b) | a ≡ b (mod 3)} and
R2 = {(a, b) | a ≡ b (mod 4)}. Find

a) R1 ∪ R2.
b) R1 ∩ R2.
c) R1 − R2.
d) R2 − R1.
e) R1 ⊕ R2.

Can someone explain the logic?

set-theory&algebra

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1797 of 2244


Selected Answer

try this using theory of computation. finite state machines.

 2 votes -- Aspi R Osa ( 1305 points)

16.63 How to evaluate the given series ? top gateoverflow.in/35082

2/2(2)+3/2(3)+4/2(4) +.......


Selected Answer

2 3 4
2 3 4
S = 2 + 2 + 2 + − − −

1 2 3 4
2 23 24 25
∗ S = + + + − − −

Perform Substraction,

1 2 1 1 1
2 2 3 4 5
∗S= 2 + 2 + 2 + 2 + − − − − −

1 2 1 / 23
2 22 1 −1 / 2
∗S= +

1 2 1 / 23
2 22
∗S= + 1/2

1 2 1
2 2 2
∗S= 2 + 2

1 3
2 22
∗S=

3 3
2
S=2∗ 2 = 2

Note: for any such series having AP and GP in it this procedure will work.

 2 votes -- Sandeep Singh ( 5939 points)

16.63 Please suggest me a good books for discrete maths to solve more and
more problem. top gateoverflow.in/42355


Selected Answer

If you want to learn the theory as well, then Discrete Mathematics by Kenneth Rosen is good..

For problems...
First, solve all Previous GATE/TIFR Questions from GATEOverflow Book..
http://www.gatecse.in/gate-overflow-book-previous-gatenon-previous-gate-questions-answers/

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1798 of 2244

If you want even more problems, you can go for "Schuam Series".. But solve only those topics relevant to GATE..

 3 votes -- Abhilash Panicker ( 6527 points)

16.63 Why set of all functions f: (N->{0,1}) is uncountably infinite? top gateoverflow.in/36654

engineering-mathematics set-theory&algebra

there are counatbly infinte natrual numbers.

there will be countably infinite number of elemnents in mapping N->{0,1}

e.g.

ASSUME N has 5 elements then N*{0,1} has 10 ordered pair(cartesian product}

now there can be muliplte funcitions,

function is a subset of cross product (some restircions but lets forget this

now we have 10 elements and all the subset of that 2^10.

similarly here 2^ (countable infite) =uncounatble ifiinite

remeber this rule of exponential(i dont have any proof)

http://cs.stackexchange.com/questions/51319/number-of-finite-strings-over-a-countably-infinite-alphabet

 1 votes -- viv696 ( 1431 points)

16.63 the binary relation S=∅ on set A={1,2,3} is transitive and symmetric top
gateoverflow.in/40929


Selected Answer

Defintion of symmetric relation.. here X is a set and a,b are elements of X

Defintion of transitive relation.. here X is a set and a,b and c are elements of X

Now if you see given relation S=ϕ


There are no elements in the set, so it does not violate the definitions of the symmetric and transitive realtions above..
Hence it is symmetric and transitive.

Extra:
But the given relation is not reflexive...
in a reflexive relation, for every element a of set X, aRa.
but here we donot have 1R1 and 2R2 and 3R3.
So, the given relation S=ϕ is not reflexive

 3 votes -- Pooja ( 22773 points)

16.63 set of all equivalence class of set A of cardinality C top gateoverflow.in/41172

bell number.

 0 votes -- viv696 ( 1431 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1799 of 2244

16.64 Set Theory and Algebra : Let L be a lattice and let a and b be the
elements of L such that a≤b top gateoverflow.in/42045

Let L be a lattice and let a and b be the elements of L such that a≤b. The interval [a,b] is defined as the set of all x€L such
that a≤X≤b. Prove that [a,b] is a sublattice of L.

Source- Discrete Mathematical Structures- 3rd Edition-Kolman Page Number 257 question Number 7

set-theory&algebra

16.65 Which type of function it is? top gateoverflow.in/41973

Let A = {x | -1<x<1} = B. The function f(x)=x/2 from A to B is:


(A) injective
(B) surjective
(C) both injective and surjective
(D) neither injective nor surjective

this f(x) function is injective as it gives distinct values in B for each element of A. but it is not surjective because f(x)'s
range is between ( -0.5 to 0.5 ) only .

 2 votes -- Khushboo Tak ( 1961 points)

Injective as -0.5 < f (x) <0.5 and x is a real number .

It's not surjective.

 2 votes -- ekalavya ( 33 points)

16.66 How to Find inverse of this: (z,*) is a group with a*b=a+b+1 then
inverse of a is? top gateoverflow.in/39113

How to do this? (z,*) is a group with a*b=a+b+1 then inverse of a is?

engineering-mathematics set-theory&algebra


Selected Answer

Identity Element = I
a*I = I*a = a
a=a+I+1
I = -1

Inverse of a is a-1
a*a-1 = I
a + a-1 + 1 = -1
a-1 = -( a+2 )

 2 votes -- Digvijay Pandey ( 26245 points)

16.67 A partial order is defined on the set S={x,a1,a2,.....an,y} as x<=ai for


all i and ai<=y for all i,where n>=1.The number of total orders on the set S

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1800 of 2244

which contains the partial order <= is (a) n! (b) n+2 (c) n (d) 1 top gateoverflow.in/4284

GATE_1997_Discrete_Maths_Set Theory

set-theory&algebra

http://gateoverflow.in/2257/gate1997_6-1

 0 votes -- Arjun Suresh ( 124125 points)

16.67 if G is a group of even order, then top gateoverflow.in/4922

16.68 On a set of n elements, how many relations are there that are both
irreflexive and antisymmetric? top gateoverflow.in/3123

On a set of n elements, how many relations are there that are both irreflexive and antisymmetric?

Please explain how to calculate .

set-theory&algebra


Selected Answer

On a set S with n elements how many relations are there?

A relation consists of set of ordered pairs (a, b). Here a can be chosen in n ways and similarly b can be chosen in n ways.
So, totally n2 possible ordered pairs are possible for a relation. Now each of these ordered pair can either be present in the
relation or not- 2 possibilities for each of the n2 pair. So, total number of possible relations =

2
2 n .( )
Now, for a relation R to be reflexive, ordered pairs {(a, a) ∣ a ∈ S}, must be present in R. i.e.; the relation set R must have n
ordered pairs fixed. So, number of ordered pairs possible is n2 − n and hence total number of reflexive relations is equal to

2
(
2 n −n . )

Number of irreflexive relations is same as number of reflexive relations. In reflexive relations we always included n ordered
pairs for {(a, a) ∣ a ∈ S}, while in irreflexive relation we always omit those n ordered pairs. So, the number of ordered pairs
to choose for the relation is the same for both reflexive as well as irreflexive relations which is

2
(
2 n −n . )

A relation becomes symmetric, if for ordered pair (a, b) in R, ordered pair (b, a) is also present in R. So, here, the total
number of ordered pairs possible is reduced from

n + n + … + n to

n (n +1 )
2
n+n−1+n−2+…+1= .

So, total number of possible symmetric relations =


n (n + 1 )

2 ( 2
).

A relation becomes anti-symmetric if for the ordered pairs (a, b) and (b, a) in R, a = b. i.e., the pairs (a, b) and (b, a) cannot be

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1801 of 2244

simultaneously be in the relation unless a = b.

For the n pairs (a, a) in R, they can be either present in relation or absent. So, 2 possibilities for each giving 2n possible
relations.

Number of pairs (a, b) in R such that a ≠ b equals number of ways of selecting 2 numbers from n without repetition, equals
n (n −1 )
2

Now, for each of these pairs (a, b), there are 3 possibilities-

1. (a, b) and (b, a) not in R


2. (a, b) in R but (b, a) not in R
3. (a, b) not in R but (b, a) in R
n (n − 1 )

So, total number of possibilities for all such pairs = 3 ( 2


).
And total number of anti-symmetric relations on a set of n elements becomes
n (n − 1 )

2n ×3 ( 2
).

Finally, coming to your question, number of relations that are both irreflexive and anti-symmetric which will be same as
the number of relations that are both reflexive and antisymmetric is
n (n − 1 )

3 ( 2
).

We just have to always exclude n pairs being considered for (a, a) while calculating the possible relations for anti-symmetric
case.

 20 votes -- Arjun Suresh ( 124125 points)

16.69 Function top gateoverflow.in/36672

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1802 of 2244

16.70 Let R be a non-empty relation on a collection of sets defined by ARB if


and only if A∩B=ϕ top gateoverflow.in/35717

Let R be a non-empty relation on a collection of sets defined by ARB if and only if A∩B=ϕ
(a) R is reflexive and transitive (b) R is symmetric and not transitive
(c) R is an equivalence relation (d) R is not reflexive and not symmetric

set-theory&algebra

16.71 Set Theory top gateoverflow.in/33352

In a Group (G,*) the equation x ∗ a = b has a

a) unique solution b ∗ a −1

b) unique solution a −1 ∗ b
c) unique solution a −1 ∗ b −1

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1803 of 2244

d) many solutions

set-theory&algebra


Selected Answer

In a group
1] there exist a unique identity element of Group i.e G. lets call it ' e '
2] the inverse of any element in G is unique. We generally represent inverse of a element 'a' as a −1

Now the equation is x*a = b

post multiply by a −1 both side,

x*a*a −1 = b * a −1

x* e = b * a −1

x = b * a −1

∵ there always exit only unique inverse of any element in Group so solution to this equation is also unique.

Ref : https://en.wikipedia.org/wiki/Group_(mathematics)#Uniqueness_of_identity_element_and_inverses

This way answer is a) Unique Solution b * a −1

 3 votes -- Sandeep Singh ( 5939 points)

16.72 functions -which of following is false top gateoverflow.in/18337

Let A={x|x∈R and x!=2} and B={x|x∈R and x!=1} define f:A->B and g:B->A by

f(x)=x/(x-2) and g(x)=2x/(x-1) then

which of following is false?

1)f∘g=g∘f 2)f∘g=Ib Ib is identity function on set B

3)f=g-1 4) f∘g is bijection

Yes it will be option A because its a property composition of two function are not commutative.

Functions f and g fail to commute if for some x, g(f(x))≠f(g(x)). Take any f such that f(x)≠x for some x. Now
g(f(x)) can be chosen independently of g(x), and in particular it can be some element other than f(g(x)).

for example let x=2 in fog = -2 but in gof we cant even take 2 coz A={x|x∈R and x!=2}

so fog≠gof

 0 votes -- Umang Raman ( 10379 points)

16.73 functions top gateoverflow.in/18335

IF function f(x)=1+kx is its own inverse then find value of k

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1804 of 2244

Selected Answer

y= f(x) = 1 + kx

y−1

x= f −1 (y) = k

We have f(x) = f −1 (x). So,

x−1
k = 1 + kx

x − 1 = k(1 + kx)

( )
x k2 − 1 + (k + 1) = 0

(
(k + 1) x(k − 1) + 1 = 0 )

Thus,

{
−1 or,
k= x−1
x

 2 votes -- Riya Roy ( 4767 points)

16.74 Sets top gateoverflow.in/18330

IF A B C are three sets which of following statement is not true?

1)(A-B)-C=A-(C-B)

2)A-(B∪C)=(A-B)∩(A-C)

3)A-(B-C)=(A-B)-(A-C)

4)A∆(B∪C)=(A∆B)∪(A∆C)

Multiple answers here ->

1) is false.

2) is true.

3) is false.

4) is false.

Answer 1,3,4 !

 1 votes -- Akash ( 26315 points)

16.75 symmetric difference top gateoverflow.in/18328

If A and B are subsets of set X={1,2,3........100} and A∆B denotes set of all elements of X which belong to exactly one of A
or B.Then total no of subsets of X such that A∆B ={2,4,6.....100}is

a)2^50

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1805 of 2244

2)2^51

3)2^100

4)2^25


Selected Answer

2^100. Each of the odd elements of X have 2 choices, either they can be in both A & B or they can't be in both A & B, so
2^50 choices for them. Each of the even elements of the set can either be in A or be in B, so 2^50 choices for them. Thus
overall 2^100 choices

 1 votes -- Anurag Pandey ( 8183 points)

According to the question A Δ B should contain all even number of elements which in set notation can be written as :

(A − B ) ⋃ (B − A ) = {2,4,6,........100}

No of ways 50 elements can be either in A or in B is 2 50 .

Now Both set A and B either should contain any of the odd elements {1,3,5,......99} or with will not contain any of the
odd elements ie it has each of 50 odd elements have two chances either to be placed in both A and B or to be placed
outside of both A and B which can be done in 2 50 ways .

Hence the total number of subsets is : 250 * 2 50 = 2 100 .

Answer option C .

Plz correct me if am getting wrong .

 1 votes -- Riya Roy ( 4767 points)

16.76 sets top gateoverflow.in/18510

A set S has 5 elements .How many ways we can choose subset P and Q of S so that P∩Q=∅


Selected Answer

35 should be the correct answer.

Each element of S has 3 options available:

a) Either join set P & don’t join set Q.

b) Or join set Q & don’t join set P.

c) Or neither join set P nor join set Q.

But it can’t join both set P & set Q, since P & Q shares no common elements.

5 elements each having 3 choices gives 35 .

P intersection Q will be null even if both P & Q are null, so no need to treat this case differently and it will one of those 35
choices.

 3 votes -- Anurag Pandey ( 8183 points)

16.77 How to find the sum of sqrt of first n natural numbers ? top gateoverflow.in/18604

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1806 of 2244

When searching for the key value 60 in a binary search tree, nodes containing the key values 10, 20, 40, 50, 70, 80, 90 are
traversed, not necessarily in the order given. How many different orders are possible in which these key values can occur on the
search path from the root node containing the value 60?

http://ramanujan.sirinudi.org/Volumes/published/ram09.pdf

 0 votes -- Umang Raman ( 10379 points)

16.77 prove that y=cos2x+6 is not a one one and onto function. top gateoverflow.in/9780

Proving whether a function is one one or onto is totally dependent on the domain and codomain of the function. I assume
that domain and codomain are the set of all Real numbers.

Now consider x= 0° & 180 °, you will get the same y value =>Hence function is not one one

For any x; 5 <=y <=7

Therefore, there will be many values in codomain set, for which there is not any preimage in the domain set. Hence
function is not onto function.

 4 votes -- suraj ( 3299 points)

16.78 f:R->R be such that f(x)=x^3-3x^2+5x -10..prove that whether it is


one to one or onto or both.. top gateoverflow.in/10149

please give me adetail solution.basically I am getting confused how to determine onto function or not for a polynomial.please
answer me as early as possible..

set-theory&algebra


Selected Answer

f(x) = x3 − 3x2 + 5x − 10

f ′ (x) = 3x2 − 6x + 5

Now, a polynomial is bijective (one-one and onto) if and only if its derivative never changes sign.

Here, the derivative is 3x2 − 6x + 5, for any x, this is positive. So, f is one-one and onto.

Suppose f is not bijective. Then we can do as follows:

√36−60
6
f ′ (x) =0  x=6± , hence no real roots.

Now, all polynomial functions are continuous (Ref: http://www.themathpage.com/aCalc/continuous-function.htm). So,


without any maximum or minimum, the given function must be one-one.

 3 votes -- Arjun Suresh ( 124125 points)

16.79 which of the following statements about a group are true? top gateoverflow.in/19380

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1807 of 2244

1.If a group has an odd number of elements then there exists no element which is inverse of itself. 2.If a group contains even no of elements then there
exists only one element which is inverse of itself.

I am confused that if I have odd no of elements then in that case I will have one identity element and then I will be left with even no of elements,which
can be paired up so then I will be left with atleast one element which is inverse of itself so then in the case where the group has even no of elements then
can't we argue in the similar fashion .

answering what i think your doubt might be is.if i have odd elements and one will be identity element. so odd-1 = even

now we know that if we have order as even then there will be a element who will be inverse of itself. so odd also should
have a element which is inverse of itself. well it is not true because in this case u want to count the identity element twice.
the case of even also considers identity element which u have already considered it .

if u have odd elements then then remove identity element because identity element is inverse of itself.

so left with even number of elements which can be paired such that no element will remain.

but if i have even number of elements then . removing identity will make it odd number of elements now if i pair them up.
one element will definitely will be there which will don't have a inverse now we know since it is a group every element
should have a inverse.

hence it should be its own inverse.

 0 votes -- Ravi Singh ( 7303 points)

16.80 If f:X→Y and a, b⊆X, then f(a⋂b) is equal to : top gateoverflow.in/19229

I am not getting here that what is a and b are these elements of the set or two subsets of X ?

16.81 How to find Transitive Closure of any Relation ? top gateoverflow.in/10669

I want to know the best way through which we can find transitive closures of any relation ? Please let me know.

You can check Relations chapter in Keneth Rosen, Relations chapter, where you can find Closures topic. There is method
for finding transitive closure using Matrix Multiplication.

 0 votes -- Akash ( 26315 points)

16.82 If R = ((1, 1), (3, 1), (2, 3), (4, 2)), then which of the following
represents R2, where R2 is R composite R? top gateoverflow.in/17920

If R = ((1, 1), (3, 1), (2, 3), (4, 2)), then which of the following represents R2, where R2 is R
composite R?
(a) ((1,1), (3, 1), (2, 3), (4, 2))
(b) ((1, 1), (9, 1), (4, 9), (16, 4))
(c) ((1, 1), (2, 1), (4, 3), (3, 1))
how to solve.
set-theory&algebra

R = ((1, 1), (3, 1), (2, 3), (4, 2))

RoR=R2=((1, 1), (3, 1), (2, 3), (4, 2))((1, 1), (3, 1), (2, 3), (4, 2))

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1808 of 2244

=((1, 1), (3, 1), (2, 1), (4, 3))

take first set (1,1) then take second element of this subset check in the other set R is there any starting with 1 if
yes then take its second element and make a subset in R2 similarly check for all.

like (4,2) (2,3)=(4,3)in R 2

so answer will be D

 1 votes -- Umang Raman ( 10379 points)

16.83 Please explain top gateoverflow.in/12881

What is a Toset? It is poset+all elements should be comparable.

What does comparable mean

(C,<=) is a toset how?

Complex numbers are not comparable nless in a+ib c+id it is mentioned whether a<c etc.But if they are not
comparable,then how can one say c1 <=c2 implies c2<=c1 do not exist.(Since it is a poset ,anti symmetricity should hold)

set-theory&algebra

Where are you quoting it from ? I think here "<=" is general symbol for an ordering relation, not "less than equal"
relation.

 1 votes -- Happy Mittal ( 9253 points)

16.84 Can you please help me understand Antisymmetric relation top gateoverflow.in/12665

Hi ,

I am stuck with Antisymmetric relations. I know the formal definition . If A = {a,b} , If aRb ^ bRa both true then a=b for all
a,b belongs to A.

Now , while the formal definition is ok , for practical purpose I found out that diagonal elements and / or half of the diagonal
elements are anti-symmetric.

A={a,b,c}

so , relations

{ (a,a),(b,b),(c,c)} is anti-symmetric.
{(a,b),(a,c),(b,c)} or {(b,a),(c,a),(c,b)} is anti-symmetric ( as one half of the diagonal ).
{(a,b),(b,c),(c,c)} is also anti-symmetric ( one half of diagonal and (c,c) is diagonal element )

But , I can not understand how {(a,b) , (c,b)} is anti-symmetric .

set-theory&algebra


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1809 of 2244

See,

AntiSymmetric means that if aRb->bRa then a=b.Precisely if aRb exists then bRa should not exist.

Asymmetric is something which is both AntiSymmetric and irreflexive at the same time.

a b is antisymmetric because b a does not exist.

c b as b c does not exist.

 1 votes -- Sourav Roy ( 2353 points)

{(a,b) , (c,b)} this set is following the anti-symmetric properties

(A = {a,b} , If aRb ^ bRa both true then a=b for all a,b belongs to A) .

and even {(a,b)} this set is anti-symmetric .

but this is not anti-symmetric {(a,b) , (b)} it`s violating the anti-symmetric properties .

As a simple example, the divisibility order on the natural numbers is an antisymmetric relation .

 1 votes -- Pranay Datta ( 6113 points)

16.85 set top gateoverflow.in/11882

identity element for (N,+) ,(N ,*) , (Z,* ) ,(R,*) exists?

where R=real no

N =natural no

Z=integer


Selected Answer

identity element is the element in the set which when operated by a number with the operation given produces the same
element as result example

(N,*) here ) 1 is the identity element as 5(natural number) * 1 = 5

now in your question only (N,+) doesn't have an identity element rest have 1 as the identity element.

PS: 0 can be part of N or not and there is no agreement on this. See here.

 2 votes -- Bhagirathi Nayak ( 10239 points)

For (N,+), no identity exists. For all others, identity would be 1.

 1 votes -- Vivek sharma ( 1177 points)

16.86 set top gateoverflow.in/11881

set (N,*) , (Z,*) closed or not ?


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1810 of 2244

closed- what that means for every two elements from the set A when operated by the given operation give an output
which belongs to the same set A. In your question both are closed because you take any two elements and operate you
will get an element in the set.

Example:

(N,*) 5 * 2 = 10

(Z,*) -3 * 0 = 0

 4 votes -- Bhagirathi Nayak ( 10239 points)

16.86 What is the difference between diagonal relation and reflexive


relation? top gateoverflow.in/12939

set-theory&algebra

Reflexive relations -> Self loops must exists. For All a, (a,a) belongs to relation. Other elements may or may not be
present
In Diagonal Relation -> Other than diagonal elements all other elements must be 0, i.e. For all a, For all b, if a!= b, (a,b)
does not belong to relation. Diagonal elements may or may not be present.

 0 votes -- Akash ( 26315 points)

16.87 please explain top gateoverflow.in/13058

every total ordered set is distributive.


Selected Answer

Every totally ordered set is a distributive lattice.

A totally ordered set means, for every two elements of the set a and b, either a ≤ b or b ≤ a, and thus a ≤ b if and only if
a ∧ b = a (meet operation) and a ∨ b = b (join operation).

A lattice (L, ∨ , ∧ ) is distributive if the following identity holds for all x, y, and z in L:

x ∧ (y ∨ z) = (x ∧ y) ∨ (x ∧ z)

LHS = x ∧ (y ∨ z).

For a totally ordered set, this will return x, iff order of x is ≤ either y or z. Otherwise it will return the larger of y and z.

The same thing is applicable for RHS also making LHS = RHS for a totally ordered set.

 4 votes -- Arjun Suresh ( 124125 points)

16.88 cyclic group top gateoverflow.in/19164

which of the following is wrong?


A)group of order is 27 is cyclic

B)group of order is 14 is cyclic

C)group of order is 21 is cyclic

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1811 of 2244

group of order is 30 is cyclic

If group order is divisible by P 2 where P is prime then group is Non Cyclic Abelian Group.
here, 27 is 32*3 so it is not cyclic ..

 3 votes -- Pooja ( 22773 points)

16.89 functions top gateoverflow.in/17098

let f and g be two functions f :A->B and g: B->C g0f :A->C is surjection g is injection then f is

1)injection

2) surjection

3)bijection

4)none


Selected Answer

Given that gof is onto it implies that A as a whole must be able to access all the elements of C. Also A can not access C
directly, A can only access C via B. So indirectly B must have access to all the elements in C i.e. g must be onto. Now
since g is already into and it must be onto in order to make gof onto so g is bijective. Now since g is bijective so there is a
one to one correspondence between B and C.Hence in order to access C completely from A, we must have access to all the
elements of B from A which is making f a surjective function. Please let me know, am I correct sir?

 1 votes -- Anurag Pandey ( 8183 points)

16.89 If A={1,2} then P(A) INTERSECTION P(P(A)) =? where P(A) is power


set of A. top gateoverflow.in/15355

Nothing will be common in P(A) and P(P(A)). It is Phi.

 2 votes -- Digvijay Pandey ( 26245 points)

16.90 set theory top gateoverflow.in/13290

difference between {} , ∅ , {∅} ???

set-theory&algebra


Selected Answer

{} = ∅, both are equal which is empty set .

{∅} : it is set which contains ∅ as elements ..

Comparison between ∅, {∅},

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1812 of 2244

∅ is subset of every set that is why it is called Trivial SubSet of any set.
so ∅ ⊆ {∅} and ∅ ∊ {∅}.

Cardinality of ∅ is 0 and that of {∅} is 1.

 3 votes -- sonam vyas ( 6441 points)

16.91 discrete math top gateoverflow.in/25203

Give an example where distributive lattice is not complemented lattice?

Is always distributive lattice bounded?


Selected Answer

This is the Example of lattice which is Distributive Lattice but not Complemented Lattice.

In Distributive Lattice complement of element an element if exists is Unique i.e. each element has at most
one complement.

and in Complemented Lattice each element has at least one complement.

This Example satisfy the condition of Distributive Lattice but fails the condition of Complemented Lattice
because element 6 have no complement.

2. No, it is not True.Distributive Lattice might be bounded but Complemented should be bounded.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1813 of 2244

This is Unbounded Lattice and distributive too because here every element has at most one complement.it is
not complemented Lattice because first, it is unbounded and second Here complement of every element is
not present.

One alternate way to check Distributive Lattice is If

Here L 1 * and L 2* is not distributive because

L 1 *= a∨(b∧c) =(a∨b)∧(a∨c) L 2*=a∨(b∧c) =(a∨b)∧(a∨c)

(a∨x) = (y∧y) (a∨x) = (b∧y)

a≠y a≠b

if Lattice contains
a
sub
lattice which is isomorphic to one of these two then we can say Lattice is not distributive and
otherwise it is distributive.it doesn't matter Lattice bounded or not.There is no relation between Bounded Lattice
and Distributive Lattice.

 3 votes -- Leen Sharma ( 2935 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1814 of 2244

16.92 sets top gateoverflow.in/26190

Let S={1,2,3,4}.Total no of unordered pairs of disjoint subsets of S is equal to

1)25 2)34 3)42 4)41


Selected Answer

Let X and Y be two disjoint subsets of S.

Now, for each of the 4 elements of S we have 3 choices:

1. Go to X and not Y.
2. Go to Y and not X.
3. Go to neither X nor Y.

Thus we get two disjoint subsets X and Y in 34 = 81 ways. But

we need to count unordered pairs- (X = {1, 2}, Y = {3, 4}) and (X = {3, 4}, Y = {1, 2}) should not be counted separate.

We can see that every pair X, Y have two orders except (X = ∅, Y = ∅). So, to count the no. of unordered pairs we can do

81 − 1
2
+ 1 = 41.

 5 votes -- Arjun Suresh ( 124125 points)

answer = 41

http://math.stackexchange.com/questions/1223425/total-number-of-unordered-pairs-of-disjoint-subsets-of-s

 2 votes -- Amar Vashishth ( 17865 points)

16.93 If G is an infinite cyclic group then which of the following is not true?
top gateoverflow.in/5669

If G is an infinite cyclic group then which of the following is not true?

a) G has exactly 2 generators.

b) G is isomorphic to (Z,+).

c) Every proper sub group of G is finite.

ans is A:

because cyclic group is a group generate dby a single element, which is generator g. applying repeatedly group operations
to this g or its inverse we can get all the eements of group.

B & C are propertie of infinite cyclic group, which are always true.

 1 votes -- jayendra ( 5797 points)

16.94 Set Theory top gateoverflow.in/33210

From a group of 10 doctors, how many ways a committee of 5 can be formed so that atleast one of Dr A and Dr B will be
included.

set-theory&algebra

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1815 of 2244

Assuming Dr. A and Dr.B are the two special doctors in the group ,at least one of them must be included.

Required no. of groups = Total possible groups of 5 doctors - Groups in which none of Dr.A and Dr. B were selected

= 10 C5 - 8 C3 = 196

 0 votes -- Shashank Kumar ( 2029 points)

16.94 If f is one-one and g is onto.Then what can we say about gof? top gateoverflow.in/6236

GoF may or may not be onto.

GoF may or may not be one-to-one.

GoF will be everywhere defined.

 1 votes -- sameer2009 ( 1203 points)

16.94 Is set of all complex numbers with respect to multiplication operation


,a group? top gateoverflow.in/31013

yes , complex number under multiplication forms group. for example

It is closed

Associativity property satisfied for any element

identity element is 1 =w^3

inverse of 1 is 1, w is w^2, w^2 is w

So, it will be a group under multiplication

 0 votes -- srestha ( 11585 points)

16.95 Set Theory top gateoverflow.in/33344

The set G = {0, 1, 2, 3, 4, 5} under addition modulo 6 is a group. Which all subgroups of order 2 and 3 are possible?

set-theory&algebra

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1816 of 2244


Selected Answer

1 possible groups of order 2 .

(0,3)

1 possible group of order 3

(0,2,4)

 2 votes -- Sandeep Singh ( 5939 points)

16.96 set top gateoverflow.in/11879

How to check a set of (N , +) ,(N, *) , (Z, +) , (Z,*) is countable or not?

Multiplication addition on rational, integer, natural no are countable..

(Power of) is uncountable.

Operation on real, complex, irrational number are uncountable...

 0 votes -- Digvijay Pandey ( 26245 points)

16.97 math top gateoverflow.in/34398

explain how s2 statement is true.??

set-theory&algebra

16.98 Set Theory top gateoverflow.in/33426

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1817 of 2244

set-theory&algebra

16.99 Set Theory top gateoverflow.in/33422

set-theory&algebra

bro same type qs,i answered yesterday,check it.The process is right.

http://gateoverflow.in/33339/group-theory

answer is A.

 0 votes -- Sayantan Ganguly ( 5061 points)

16.100 Chromatic number top gateoverflow.in/33417

What is the chromatic number of K n - e (complete graph with an edge removed)?

engineering-mathematics set-theory&algebra


Selected Answer

look if a graph is not complete then chromatic no is dmax.means higest degree of that graph.

u can check it for k4 and others.

so if we remove an edge from kn.then chromatic no is n-1.

 1 votes -- Sayantan Ganguly ( 5061 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1818 of 2244

(n-1)

 1 votes -- bahirNaik ( 2479 points)

16.101 anti symmetric set top gateoverflow.in/7495

A relation is said to be antisymmetric if (a,b) belong to R and (b,a) belong to R implies a=b...

that means antisymmetric is reflexive?

No, reflexive means if (a,b) belongs to R, (a,a) and (b,a) should also be in R.

Anti-symmetric actually says symmetry should not be there. i.e., if (a,b), and (b,a) shouldn't be present together unless a
= b.

 0 votes -- Arjun Suresh ( 124125 points)

16.102 math top gateoverflow.in/29542

(Z- , >=)
whereZ- is the negative integers
is this woset expalin.? and also tell the least element.??

set-theory&algebra

16.103 HCF top gateoverflow.in/27416

Two numbers are such that their HCF is 16 and their sum is 144. How many such pairs of numbers are possible?


Selected Answer

Let 16x and 16y be the two numbers

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1819 of 2244

16x + 16y=144

x+y=9

(1,8), (2,7), (4,5), (7,2), (8,1) pairs (Co primes of 9 , so that HCF remains 16)

i.e 5 pairs are possible

 2 votes -- Anupoju Satish Kumar ( 219 points)

16.104 HCF top gateoverflow.in/27415

The product of the two numbers is 576 and their HCF is 4. How many such pairs of numbers are possible?

HCF is 4.

let two numbers are 4x and 4y

4x * 4y = 576

xy = 36

co prime of 36 are (1,36) ,(4,9), (9,4), (36 ,1)

Required No are (4x1,4x36),(4x4,4x9),(4x9,4x4),(4x36,4x1)

No of such pairs are 4.

[Note: We need co primes from the possible factors of 36. only bcoz HCF is fixed, nothing can be common except that.]

 2 votes -- Praveen Saini ( 34299 points)

16.105 Disjoint sets top gateoverflow.in/26461

No of unordered disjoint sets of a set with n elements?

Ans is (3^n+1)/2 but how to derive this?

 0 votes -- saurav04 ( 649 points)

16.106 group top gateoverflow.in/26239

Which of following is true?

1)A group can have only two disjoint subgroups

2)A group can have more than two disjoint subgroups

3)a group cannot have two disjoint subgroups

4)none


Selected Answer

Two Subgroup can't be disjoint. Reason is, to hold Group property each subgroup has to have Identity element. So each
Subgroup must contains Identity element.

 1 votes -- Digvijay Pandey ( 26245 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1820 of 2244

16.107 Factors top gateoverflow.in/27418

How many zeroes does the product of all factors (including itself) of 100 end in ?

http://puzzles.nigelcoldwell.co.uk/nineteen.htm

http://www.geeksforgeeks.org/count-trailing-zeroes-factorial-number/

 0 votes -- Prasanna Ranganathan ( 2045 points)

16.108 Perimeter top gateoverflow.in/27419

Find the sum of the perimeters of all the rectangles with integral sides whose area is 216 sq. units.

16.109 number of symmetric funtions top gateoverflow.in/167

A function f: {0, 1}n → {0, 1} is called symmetric if for every x1 , x2 , . . . . , xn ∈ {0, 1} and every permutation σ of {1, 2, . . . , n}, we have

( ) ( )
f x1 , x2 , . . . , xn = f xσ(1 ) , xσ(2 ) , . . . . xσ(n ) .

The number of such symmetric function is:

a. 2n +1
b. 2n
c. 22n /n!
d. 22n
e. n!

normal set-theory&algebra


Selected Answer

First we need to find different number of inputs for f given that permutations are equivalent.

Now given two binary string x, y: x is a permutation of y iff x has same number of ones and zeros as y.

So the total number of different inputs is n+1 ( namely input with zero 0's, one 0's ... n 0's)

For each of these inputs we can have either 1 or 0 as output, so two choices.

2×2×2×…×2

Therefore, number of choices is n +1 times .

So the total number of such symmetric functions is 2n +1 .

 5 votes -- Omesh Pandita ( 2209 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1821 of 2244

16.110 Set Theory and Algebra: Which of the following is NOT true? top gateoverflow.in/28381

Let s(w) denote the set of all the letters in w where w is an English word. Let us denote set equality, subset and union
relations by =, ⊂ and ⋃ respectively. Which of the following is NOT true?

(a) s(ten) ⊂ s(twenty)

(b) s(stored) = s(sorted)

(c) s(sixty) ⊂ (s(six) ⋃ s(twenty)

(d) None of these

Answer Given is (d) how?

set-theory&algebra


Selected Answer

(a) { t, e, n } ⊂ { t, w, e, n, t, y } //TRUE
(b) { s, t, o, r, e, d } = { s, o, r, t, e, d } //TRUE
(c) { s, i, x, t, y } ⊂ { s, i, x, t, w, e, n, t, y } //TRUE

All are true..

 2 votes -- Digvijay Pandey ( 26245 points)

16.111 If X and Y are two sets, then X⋂(Y⋃X) C equals top gateoverflow.in/28324

If X and Y are two sets, then X⋂(Y⋃X) C equals

(a) X (b) Y (c) ϕ (d) None of these

My attempt:

X = {1,2,3} Y = {3,4,5}

(Y⋃X) = {1,2,3,4,5}

X⋂(Y⋃X) = {1,2,3}

But the given answer is C

set-theory&algebra


Selected Answer

X ⋂ (Y ⋃ X)' = X ⋂ (Y' ⋂ X') = ϕ

 2 votes -- Digvijay Pandey ( 26245 points)

16.112 Suppose the element a,b in a group satisfies aba-1=b2 for b<>e top
gateoverflow.in/28108

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1822 of 2244

set-theory&algebra engineering-mathematics


Selected Answer

(aba-1)=b2

(aba-1)2=b4

(aba-1)(aba-1)=b4

ab(aa-1)ba-1=b4

ab 2a-1=b4

a(aba-1)a-1=b4

a2ba -2=b4

(a2ba -2)2=b8

(a2ba -2)(a2ba -2)=b8

a2b2a-2=b8

a2(aba-1)a-2=b8

a3ba -3=b8

(a3ba -3)(a3ba -3)=b16

a3b2a-3=b16

a3(aba-1)a-3=b16

a4ba -4=b16

(a4ba -4)(a4ba -4)=b32

a4b2a-4=b32

a4(aba-1)a-4=b32

a5ba -5=b32

 4 votes -- srestha ( 11585 points)

b32 = (((((b2)2)2)2)2 = ((((aba-1)2)2)2)2 = ............ //do recursively

//(aba-1)​2 = aba-1aba-1 = ab 2a-1 = a(aba -1)a-1= a 2ba -2

= a 5ba -5

 1 votes -- Digvijay Pandey ( 26245 points)

16.113 Made easy practice test-3 top gateoverflow.in/34554

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1823 of 2244

Given relation is reflexive or not.

I think it is reflexive. and equivalence relation.

made-easy test-series


Selected Answer

how it is equivalent???pls give your solve.I am clearly seeing that it is not even reflexive. x<=4,y<=4 ..

and x+y<=5

for refelxive xRx

ie,let take x=3 it is <=4

and xRx ie, x+x = 6 which is not less than 5

 2 votes -- Sayantan Ganguly ( 5061 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1824 of 2244

17 Combinatory top
17.1 Combinatory: total number of 5 digit pallindrome???? top gateoverflow.in/17022

Consider the concurrent program:

x: 1; cobegin x:= x + 3 || x := x + x + 2 coend

Reading and writing of variables is atomic, but the evaluation of an expression is not atomic.

The set of possible values of variable x at the end of the execution of the program is:

A. {4}
B. {8}
C. {4, 7, 10}
D. {4, 7, 8, 10}
E. {4, 7, 8}

mathematical-logic -combinatory

Answer should be 9*10*10 = 900. Out of the five digits, most significant three digits you can choose by your own and
remaining two digits will be fixed, based upon the choices you made. Now first digit must be a non zero digit other wise
the number will become a four digit number so, nine choices for the most significant digit, ten ten choices for second and
third digits respectively, which will give 9*10*10 choices.

 1 votes -- Anurag Pandey ( 8183 points)

17.2 Arrangement: Permutation n combination top gateoverflow.in/38069

what is the correct solution to this question??

combinatory combinatorics engineering-mathematics arrangement

first arrange boys or girls=(4-1)=3! ways


now we have 4 spaces( between every two girls if you arranged the girls first ) and we have to put 4 boys in those spaces
so chose 4 places out of 4 =4c4=1 ways now arrange them in 4! ways
total=3!*4!=144 ways

 1 votes -- gitesh ( 27 points)

17.3 Combinations: Question on rolling fair dice top gateoverflow.in/33093

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1825 of 2244

Given answer: A
Please explain

engineering-mathematics combinations


Selected Answer

Required Probability

[]
1

[ ]
1 31 3 1 1 3 3 1 3 1 1
2 2 6
P = P(2) + P(¬3 ∧ ¬5 ∧ ¬2). P(2) + P(¬3 ∧ ¬5 ∧ ¬2). P(¬3 ∧ ¬5 ∧ ¬2). P(2)… = 6 + 6 6 + 6 6
+ … = 6 1 + 6 + 6 + … = 6 1− = 6.2 = 3.

 5 votes -- Arjun Suresh ( 124125 points)

Correct answer is (B)1/3

See the explanation below

P(2) : Probability of showing up '2' in single trial.; P(2) = 1/6

P(3 or 5) : Probability of showing up '3' or '5' in single trial.; P(3 or 5) = 2/6

P'(2) = Probability of not showing up '2' in single trial.; P '(2) = 5/6.

P( 2 followed by 3 or 5 ) = P(2).P(3 or 5) + P '(2).P(2).P(3 or 5) + P '(2).P'(2).P(2).P(3 or 5) + ................upto infinite


terms

= P(2).P(3 or 5) [ 1 + P '(2) + (P '(2))2 + ................upto infinite terms.

= P(2).P(3 or 5)[1/(1-P '(2)] = P(2).P(3 or 5).1/P(2) = P(3 or 5) = 2/6 = 1/3.

 1 votes -- Shashank Kumar ( 2029 points)

17.4 Combinations: Counting number of functions which are neither 1-1 nor
onto top gateoverflow.in/33128

Let A = {1, 2, 3, 4}. Number of functions possible on A which are neither 1 − 1 nor on-to is _________.

combinations engineering-mathematics

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1826 of 2244

Selected Answer

232 (Ans)

f : A → A Function from set A to A itself.

Total Functions possible from A → A are 4 4 { ∵ Number of Functions

|A| }
from A → B are |B|

Now we have a property that if |A| = |B| , then

if function is one-one then it is onto and vice-versa.

Now Number of one-one & onto functions from A → A are 4!

∵ 1 has 4 choices

2 has 3 choices {we assigned a number to 1}

3 has 2 choices

4 has 1 choice left.

So, Total Number of Functions = 4 4 = 256

Number of functions which are one-one/ onto = 4! = 24

So, Number of functions possible on A which are neither

one-one nor onto is 256 - 24 = 232 (Ans)

 2 votes -- Himanshu Agarwal ( 8861 points)

17.5 Combinations: Question on counting number of ways scholarship can be


distributed top gateoverflow.in/33092

Given explanation of the question:

I believe that in place of last C(8,3) it should be C(7,3) because 3 people have been already chosen before that. Please check
whether I am correct or not.

combinations engineering-mathematics


Selected Answer

12600

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1827 of 2244

Choose one winner for Rs. 10,000 = 10C1 ways = 10

Choose 2 winners for Rs. 5000 = 9C2 ways = 36

Choose 3 winners for Rs. 1000 = 7C3 = 35

Total ways = 10 * 35 * 36 = 12600 (Ans)

 1 votes -- Himanshu Agarwal ( 8861 points)

17.6 Combinations: permutaions and combinations top gateoverflow.in/13257

How many bit strings contain exactly eight 0s and 10 1s if every 0 must be immediately followed by a 1?

I got answer 9C2=36.Answer given 45

combinatory combinations counting


Selected Answer

Consider the following arrangement of eight 0 ans 1.


_01_01_01_01_01_01_01_01_
Now the additional two 1's can be placed separately in 9C2 and placed together in 9 ways.
So the answer is 9C2+9=36+9=45.

 5 votes -- Mari Ganesh Kumar ( 1837 points)

the bit strings must consist of eight 01 substrings and two 1s. Thus, there
are ten total positions and choosing the two positions for the 1s determines the string.
There are
10C2=45 such strings

 1 votes -- Rohan Ghosh ( 1515 points)

17.6 Combinations: how many among the first 100,000 positive int contain
exactly one of each 3,4 and 5 in their decimal representation ? top gateoverflow.in/11001

combinations permutation

17.7 Combinations: In how many ways can the entrepreneur assign 5


different tasks to 3 employees if each should get atleast 1 task ? top gateoverflow.in/29329

For this I considered cases

1. 1 job each to 2 people and then jobs to a single person

2. 2 jobs each to 2 people and then 1 job to a single person

For the first case I did

5C1*4C3*1C1 ,Now this can be permuted in 3! ways

for the second case I did 5C2*4C2*1C1 , Again this can be permuted in 3! ways ,Now on adding these two cases I am
getting answer as 480 , what's wrong in this approach ?

combinations


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1828 of 2244

Answer is 150

U made the cases correct , but in calculation u made some error, Let's examine -

Let's take 3 employees as A,B,C

Case 1: 1 job each to 2 people and then jobs to a single person

1 job to A , 3 jobs to B, 1 Job to C = 5C1 * 4C3 * 1C1 = 20 ways

1 job to A , 1 job to B, 3 Jobs to C = 5C1 * 4C1 * 3C3 = 20 ways

3 jobs to A , 1 job to B, 1 Job to C = 5C3 * 2C1 * 1C1 =


20 ways

So, total 60 ways {20+ 20 + 20}

Note: Here u took 5C1*4C3*1C1 * 3! which would be 120 {wrong }

Case 2: 2 jobs each to 2 people and then 1 job to a single person

2 jobs to A , 2 jobs to B, 1 Job to C = 5C2 * 3C2 * 1C1 =


30 ways

2 jobs to A , 1 job to B, 2 Jobs to C = 5C2 * 3C1 * 2C2 =


30 ways

1 job to A , 2 jobs to B, 2 Jobs to C = 5C1 * 4C2 * 2C2 =


30 ways

So, total 90 ways for case 2..

Total ways = case 1 + case 2 = 60 + 90 = 150 (Ans)

 0 votes -- Himanshu Agarwal ( 8861 points)

17.8 Combinations: In how many ways this can be done? top gateoverflow.in/30998

An entrepreneur needs to assign 5 different tasks to 3 of his employees. If every employee is assigned at least 1 task, how
many ways can entrepreneur assign these tasks?

My Attempt: Though the question seems quite simple, it got me confusing because of answer mismatch.

Initially assigning 1-1 task to all gives C(5,3) * 3! Then the remaining 2 tasks can be assigned in 3(all rem tasks to 1
person) + 3(one-one task to each)... So this will give, C(5,3)*3!*(3+3) = 360 ways

In the solution, they have stated that its like onto function and directly applied number of onto functions formula to get
correct answer as 150.

What is wrong with my approach and moreover I will be thankful if somebody suggests a combinatorial method for this qstn
rather than using function defination as they did. Thanks in advance !

combinations set-theory&algebra functions


Selected Answer

In your approach you did not accounted for permutation of last two tasks if both were assigned to different people.

So in case your approach was correct the answer the answer would be 5C3*3!*(3 + (3*2!)).

But your method is counting same things more than once in different ways,

For example let set of tasks be {a, b, c, d, e} & set of employees be {x, y, z}, & consider following 2 cases:

Case - 1

From 5C3*3! we get

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1829 of 2244

a --> x

b --> y

c --> z,

that is a, b, & are assigned to x, y, & z respectively.

& then both d & e assigned to x.

Case - 2

From 5C3*3! we get

b --> y

c --> z

d --> x

& then both a & e assigned to x.

there will be many such repetitions.

It can be observed that assigning tasks in rounds (as we did here assigned 3 tasks in round one & remaining 2 in round
two) will not work we should assign all at once.

This can be done correctly by breaking set of tasks into 3 partitions & assigning each partition to one employee.

So number of ways = (number of possible 3 partitions of set "Tasks")*3!

Counting number of partitions:

we can 3 - partition the set {a, b, c, d, e} into two different ways:

1) Partition of type 3, 1, 1 : Choose any 3 elements & put them in one partition. 5C3*1*1 = 10 partitions of this type.

2) Partitions of type 2, 2, 1 : Choose any 2 elements & put them in one partition, then choose 2 out of remaining 3
elements & put them into second partition, remaining one element will go to third partition without any choice. ((5C2)*
(3C2)*1)/2 = 15 possible partitions of this type.We divided by two because all partitions of type 2, 2, 1 will be counted
twice.

For example : suppose a partition {a, b}, {c, d} {e}, this will be produced in two ways, first choose {a, b} using 5C2 &
{c, d} using 3C2 and another way choose {c, d} using 5C2 & {a, b} using 3C2.So we divided by 2.

Thus total 3 partitions possible = 10 + 15 = 25

So total number of ways possible = 25*3! = 150

 1 votes -- Anurag Pandey ( 8183 points)

17.8 Combinations: how many distinct 4-digits integers one can make from
the digits 1,3,3,7,7,8 ? Is there and method or we have to go by
enumerating the possibilites ? top gateoverflow.in/11002

combinations permutation

Number of distinct elements=1,3,7,8

1st digit:4 ways

2nd digit:4 ways

3rd digit:4 ways

4th digit :4 ways

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1830 of 2244

Tot: 4*4*4*4 ways

 0 votes -- Bhagirathi Nayak ( 10239 points)

17.9 Combinations: Counting number of functions which are neither 1-1 nor
onto top gateoverflow.in/33129

Given explaination:

Please explain I couldn't understand it.

combinations engineering-mathematics


Selected Answer

Look,the number of one to one function a set to itself is basically permutation on this set.let a set has n element,no one to
one function to itself is,n!.cause,first element has choice of n,next has n-1,next to next has n-2......thus... (n).(n-
1)......1= n!.

Now here the set has 4 elements,so the no of one to one functions are 4!.

Now,if a function is one to one to itself,it is also onto,

Ref:http://math.stackexchange.com/questions/366146/a-one-to-one-function-from-a-finite-set-to-itself-is-onto-how-to-
prove-by-indu

And basically both one to one and onto functions to the set itself are permutation of the elements of that set.

So,the number of onto functions are 4! Also.

Now as both are same ,the intersection is also 4!.

Now the number of one to one or onto functions are 4! + 4! -4! = 4!.

Now as u already know,the no of functions to itself is n^n..that is 4^4.

So required ans is , 256-24= 232

 1 votes -- Sayantan Ganguly ( 5061 points)

17.10 Combinations: Question on combinatorics top gateoverflow.in/33120

Given solution of this question:

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1831 of 2244

I think that number of 5 elements subsets with 7 should be C(n-1, 4) instead of C(n,4) as we have already fixed 7 so
number of elements left will be n-1. Please check

engineering-mathematics combinations


Selected Answer

20 (Ans)

set cardinality = n

Number of 5 element sets = nC5

Number of 5 element sets containing 7 = (n-1)C4 ∵ we have to take 7 & from

remaining n-1 elements we have to take 4 elements}.

now , given in Question


nC5

4 = (n-1)C4

n! (n −1 ) !
4 ∗ (n −5 ) ! ∗ 5 ! (n −5 ) ! ∗ 4 !
=> =

which gives n = 20 (Ans)

 3 votes -- Himanshu Agarwal ( 8861 points)

17.11 Combinations: In how many ways can 2n seats in a congress be


divided among 3 parties ? top gateoverflow.in/41489

Problem: In how many ways can 2n seats in a congress be divided among 3 parties so that the coalition of any 2 parties will ensure them of majority?

Answer: Total number of ways in which the seats can be distributed among parties such that any 2 of them combined and form a govt. is -
C(2n+2, 2) - 3 C(n+2, 2) +3

I cannot understand why we have to add 3 with the final expression. This question is similar to this except the problem considering even number of seats.

combinations set-theory&algebra functions


Selected Answer

No. of ways to divide 2n seats among 3 parties = no. of ways in which we can distribute 2n identical balls into 3 distinct
bins

= 2n +2 C2 .

Now, we have to ensure that selecting any two party will get no. of seats more than the other. So, we can take the
complement case where no party gets the majority of seats. Here, we have 2n seats and to ensure no majority one party

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1832 of 2244

needs n seats. So, remaining n seats we can distribute among 3 parties in n +2 C2 ways and the n seats can go to any one
among the 3 party and thus we get 3 × n +2 C2 ways.

But we over counted above. This happens when n seats go to say party A and n remaining seats go to party B. This case
will be repeated when initial n seats go to party B and remaining n to party A and similarly for B and C too. So, AB-BA, AC-
CA, BC-CB, 3 cases are counted extra. Excluding these our final answer will be
2n +2 C − 3 × n +2 C2 + 3.
2

 2 votes -- Arjun Suresh ( 124125 points)

2N balls ...3 baskets .....distribute balls

O.....O|O......O|....

N N ...the third basket remained empty ....ways to do that (2N+2)!/2!2N!...ie 2N+2C2...

this was general distribution without condition ...now to follow condition ..i will give N balls already to any one basket ...

now i have N balls left ..that can be distributed in same way as did with 2N balls....N+2C2 *3 ..as i could put those first N
balls in any basket ....now in this procedure ....i have counted ..O|O| ....twice ...how ..lets give N already to 1 basket
..and then to 2 ..and this will happen when N will be given already to 2nd basket first ..so need to add ...3 ..."HERE 3 are
not special cases ...these are just overcounted ways ",,,,thats why its correct

 2 votes -- Deepesh Kataria ( 1207 points)

17.12 Combinations: In how many ways can 5 chocolates be chosen from an


unlimited number of Cadbury,Five-star, and Perk chocolates? top gateoverflow.in/40752

we have to choose five chocolates,say, C1, C2, C3, C4 and C5. Now for C1 we can choose among three kinds of chocolates. Since the supply of chocolates is infinite, for C2, again we Can
choose among three kinds of chocolates. Similarly for each of C3, C4, C5, we have three options. So total number of choices =3^5=243.

Now if we have a case like CCCCP and PCCCC , so then these cases are counted distinct but they should be same , so then how to proceed from here ?

combinations

C |F |P

*** |** | HERE it means 3 CADBOURY ....2FIVE STAR and 0 PERKS ...same like that u can

divide 5 stars in any partitions .SO 7C2 is the answer ....and by formula too ..(5+3-1)C(3-1)

 1 votes -- Deepesh Kataria ( 1207 points)

17.13 Combinaton: permutation combination top gateoverflow.in/44105

permutation combinaton

12!/(3!*2!*2!*5!)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1833 of 2244

=166320

So option B is correct.

 1 votes -- Manojk ( 3365 points)

17.14 Combinatorics: combinatory top gateoverflow.in/28302

How many ways are there for a horse race with 4 horses to finish if ties are possible?(any number of horses may tie)

combinatorics engineering-mathematics


Selected Answer

Let's break it down into cases:-

1. No horses tie: In this case total number of outcomes will be 4!

2. Two Horses tie: Number of ways to choose 2 horses from four horses 4C2 = 4*3/2 = 6, Now we can consider these 2
horses as one horse since they tie for position, Number of outcome of race with 3 horses is 3!. So total number of
outcomes becomes 6*3!

3. Three horses tie: (Number of ways to select 3 horses) * (number of outcomes for 2 horse race without tie) = (4C3)*2!
= 8

4: Four horses tie: 1

5. two ties with two horses: 4C2 = 6

So answer should be 4! + 6*3! + 8 + 1 + 6

 4 votes -- Omesh Pandita ( 2209 points)

Four horses are competing in race , and any no. of ties are possible.

Let's consider race positions as:

I II III IV
st place} => # ways = 4C4 = 1
4 { Here all 4 finishing in I

3 1 # ways = 4C3 * 1C1 = 4

4C3 for selecting 3 horses for first place.

2 2 # ways = 4C2 * 2C2 = 6


st place
4C2 for selecting 2 horses for I

& 2C2 for II place

2 1 1 Similarly # ways = 4C2 * 2C1 * 1C1 = 12

1 3
# ways = 4C1 * 3C3 = 4

1 2 1
# ways = 4C1 * 3C2 * 1C1 = 12

1 1 2
# ways = 4C1 * 3C1 * 2C2 = 12

1 1 1 1
# ways = 4C1 * 3C1 * 2C1 * 1C1 = 24

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1834 of 2244

Adding up all these cases , we get

Total # ways = 1 + 4 + 6 + 12 + 4 + 12 + 12 + 24

= 75 ways..

 1 votes -- Himanshu Agarwal ( 8861 points)

17.15 Combinatorics: Combinatorics top gateoverflow.in/43837

Tk = 100 Ck ⋅ x100 −k for k = 0, 1, 2, …100

Then, what will be the value of

(T0 − T2 + T4 − … + T100 )2 + (T1 − T3 + T5 − … − T99 )2

The answer should be in terms of x

combinatorics

Is it

100C0x^200+100C1x^198+100C2x^196+100C3x^194+.............................+1

 0 votes -- Manojk ( 3365 points)

17.16 Combinatorics: Combinatorics top gateoverflow.in/28749

In how many ways 5 blue pens and 6 black pens can be distributed to 6 children?

a)97020

b)116424

c)8008

d)672

combinatorics

Here 5 Blue pens and 6 Black Pens to be distributed among 6 Children


so we can form it as combination with unlimited repeatation

x1 + x2 + x3 + x4 + x6 = 5 and x1 + x2 + x3 + x4 + x6 = 6

using formula (n-1+r)C(r)

(6-1+5)C5 * (6-1+6)C6 = 252 * 462 = 116424

 2 votes -- Umang Raman ( 10379 points)

17.17 Combinatorics: Combinatory top gateoverflow.in/32676

The number of ways 16 identical objects can be distributed among 4 persons such that each person gets atleast 2 objects is
______.

If possible kindly explain me the approach.

combinatorics engineering-mathematics

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1835 of 2244


Selected Answer

I used this formula:- the number of ways of distributing r similar balls into n numbered boxes C(n-1+r,r)
by the way above formula also belong to the number of non-negative integral solutions to X1+X2+X3+...+X n =r

now move to question:- 16 identical object distributed among 4 person and each person gets atleast 2(minimum 2)
So (2+X1)+(2+X2)+(2+X3)+(2+X4)=16
X1+X2+X3+X4=8
So C(4-1+8,8)=C(11,8)=165
hope ans is correct :)

 6 votes -- Jaikishan Apurva ( 787 points)

17.18 Combinatorics: How many 4 digit integers are there with digit 6
appearing exactly once top gateoverflow.in/33427

How many 4 digit integers are there with digit 6 appearing exactly once .

6_ _ _ 9 *8*7
_ 6 _ _ 9* 8 * 7

_ _ 6 _ 9*9*7

_ _ _ 6 9*9*8

I'm getting as 2223 .


Is my approach correct . In book I'm getting a different ans .

combinatorics


Selected Answer

6_ _ _ = 9*9*9

_ 6 _ _ = 8*9*9

_ _ 6 _ = 8*9*9

_ _ _6 = 8*9*9

total numbers = (9+8*3)*9*9 = 33*9*9 = 2673

 1 votes -- Vikram Bhat ( 587 points)

17.19 Combinatorics: How do one know permutation or combination to be


used in a question ? top gateoverflow.in/33425

Suppose if we have

6 Different English movies


8 Different Malayalam Movies
10 Different Hindi Movie

How many ways we can choose 2 movies of different languages ?

How do one know Permutation or combination is to be used in a question ?

combinatorics

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1836 of 2244


Selected Answer

2 different languages movies.

Case 1. 1 english 1 malayalam

Case 2. 1 english 1 hindi

Case 3. 1 hindi 1 malayalam

Now see in what order we choose doesn't matter, i can choose 1 english movie out of the 6 first and then 1 malayalam
movie out of 8 or 1 malayalam movie first and then choose english, both are same order doesnot matter.

Incases where order doesnt matter, it is COMBINATION, in case where order matters it is PERMUTATION.

So in this question, case 1 + case 2 + case 3 i.e 6C1 x 8C1 + 6C1 x 10C1 + 10C1 x 8C1 = 188

 1 votes -- Morphine ( 273 points)

Method 1 :

No. of choosing 2 movies from different language =

Total no of ways of choosing 2 movies - no of ways of choosing 2 movies from same language

= 24 C2 - [ 6C2 + 8C2 + 10 C2] = 188

Method 2:

No. of choosing 2 movies from different language =

= no. of ways of choosing[ (1 english movies & 1 hindi ) or (1 Malayalam movies & 1 hindi) or (1 english movies & 1
Malayalam)

= 6C1 * 10 C1 + 8C1 * 10 C1 +6C1 * 8C1 = 188

How do one know Permutation or combination is to be used in a question ?

Ans : For this just practice,practice,practice.

 1 votes -- Shashank Kumar ( 2029 points)

17.20 Combinatorics: The least number of cables required to connect 8


computers to 4 printers to guarantee that 4 computers can directly access 4
different printers. top gateoverflow.in/13553

The least number of cables required to connect 8 computers to 4 printers to guarantee that 4 computers can directly access
4 different printers.

At any given time 4 computers should be able to simultaneously access 4 printers.

I assumed this was simple bipartite graph k(8,4) , 32 connections.That seems to be wrong.

combinatorics


Selected Answer

(20) Answer Iam getting is 20..

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1837 of 2244

Since each 4 comp need direct connected with each printer.... so 16 connection + now remaining 4 computer, each connected to 4
different printers, so 4 connections=20 connections.

c1-> p1,p2,p3,p4

c2-> p1,p2,p3,p4

c3-> p1,p2,p3,p4
c4-> p1,p2,p3,p4
c5->p1
c6->p2
c7->p3

c8->p4
Now, any pick of 4 computers will have a direct connection to all the 4 printers.

 2 votes -- Amiti7 ( 153 points)

17.21 Combinatorics: How to solve such problem? top gateoverflow.in/28259

How many solution exist for x+y+z=10 with 1<=x<4 1<=y<=7 and z>1

combinatorics

Ans will be 18

for x=1, y=1, z=8


y=2 , z=7

.......................

y=7 , z=2 => Total 7 numbers


for x=2, y=1, z=7

y=2 , z=6

.......................

y=6 , z=2 => Total 6 numbers

for x=3 , y=1 , z=6

y=2, z=5

............................

y=5 , z=2 => Total 5 numbers

So, no of solutions 7+6+5=18

 1 votes -- srestha ( 11585 points)

17.22 Combinatorics: Madeeasy test series DISCRETE maths 2 top gateoverflow.in/36598

An entrepreneur needs to assign 5 different tasks to three of his employees. If every employee is assigned atleast 1 task,

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1838 of 2244

how many ways can the entrepreneur assign those tasks to his employees?

How to solve this??

test-series made-easy engineering-mathematics combinatorics

Let the tasks employees be numbered E1, E2 and E3.

As every employee is given at least 1 task, we assign them 3 out of 5 tasks. We are left with 2 tasks, name them A and B.

Now, we have to assign these 2 tasks: A and B, to 3 employees : E1, E2 and E3.

Each task can be assigned to any of the 3 employees, we don't care if an employee gets both of these 2 tasks, or gets
none of these 2, because we have already assigned 1 task to each employee and we can assign the remaining 2 tasks in
any way we wish.

So, each task can be assigned to any of 3 employees. 2 tasks can be assiged in 3*3=9 ways.

 0 votes -- Gaurav Sharma ( 1383 points)

17.23 Counting: number of function top gateoverflow.in/13128

How many functions are there from the set {1, 2, . . . , n}, where n is a positive integer, to the set {0, 1}
a) that assign 1 to exactly one of the positive integers less than n?

counting functions


Selected Answer

The domain set has n elements and co-domain set has 2 elements. So, each of the n elements from domain has 2 choices
in the function and thus we get 2n total functions.

Now, we are given a condition that exactly 1 positive integer less than n maps to 1. So, all others less than n must map to
0. We can find this number in n −1 C1 ways (all the mappings for these n − 1 elements are fixed) and n can be mapped to
either 0 or 1, thus we get 2.(n − 1) possible functions.

 2 votes -- Arjun Suresh ( 124125 points)

17.24 Counting: counting top gateoverflow.in/13129

How many bit strings of length 10 contain either five consecutive 0s or five consecutive 1s?

I got 382.Is it correct?

counting


Selected Answer

Let T(n) denote the number of but strings of length n containing 5 consecutive 0's.

Total no. of bit strings of length n = 2n

So, no. of bit strings of length n not containing 5 consecutive 0's = T(n) ′ = 2n − T(n)

Now, we can form a recurrence relation for Tn . We can for a bit string of length n containing 5 consecutive 0's in two ways:

1. from a bit string of length n − 1, containing 5 consecutive 0's by adding either 0 or 1 at end.
2. from a bit string of length n − 6, not containing 5 consecutive 0's by adding 100000 at end.

These two covers any possible bit strings containing 5 consecutive 0's. In the second case we needed "100000" and not
"00000" as "00000" would cause strings already considered in 1.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1839 of 2244

T(0) = T(1) = T(2) = T(3) = T(4) = 0, T(5) = 1

T(n) = 2T(n − 1) + T(n − 6) ′ = 2T(n − 1) + 2n −6 − T(n − 6)

We get,

T(6) = 2T(5) + 20 − T(0) = 3

T(7) = 2T(6) + 21 − T(1) = 8

T(8) = 2T(7) + 22 − T(2) = 20

T(9) = 2T(8) + 23 − T(3) = 48

T(10) = 2T(9) + 24 − T(4) = 112

The number of bit strings having 5 consecutive 1's must also be 112.

Now, we need to find the number of bit strings of length 10 containing 00000 as well as 11111. There are only 2
possibilities:

1111100000 and

0000011111

Thus no. of bit strings of length 10, having either five consecutive 0's or 5 consecutive 1's = 112 + 112 - 2 = 222

 1 votes -- Arjun Suresh ( 124125 points)

17.25 Counting: counting top gateoverflow.in/13127

How many bit strings of length eight contain either three consecutive 0s or four consecutive 1s?

answer given 147

combinatory counting


Selected Answer

Let T(n) denote the number of but strings of length n containing 3 consecutive 0's.

Total no. of bit strings of length n = 2n

So, no. of bit strings of length n not containing 3 consecutive 0's = T(n) ′ = 2n − T(n)

Now, we can form a recurrence relation for Tn . We can for a bit string of length n containing 3 consecutive 0's in two ways:

1. from a bit string of length n − 1, containing 3 consecutive 0's by adding either 0 or 1 at end.
2. from a bit string of length n − 4, not containing 3 consecutive 0's by adding 1000 at end.

These two covers any possible bit strings containing 3 consecutive 0's. In the second case we needed "1000" and not
"000" as "000" would cause strings already considered in 1.

T(0) = T(1) = T(2) = 0, T(3) = 1

T(n) = 2T(n − 1) + T(n − 4) ′ = 2T(n − 1) + 2n −4 − T(n − 4)

We get,

T(4) = 2T(3) + 20 − T(0) = 3

T(5) = 2T(4) + 21 − T(1) = 8

T(6) = 2T(5) + 22 − T(2) = 20

T(7) = 2T(6) + 23 − T(3) = 47

T(8) = 2T(7) + 24 − T(4) = 107

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1840 of 2244

Now, let M(n) denote the number of bit string having 4 consecutive 1's. We get

M(0) = M(1) = M(2) = M(3) = 0, M(4) = 1

M(n) = 2M(n − 1) + M(n − 5) ′ = 2M(n − 1) + 2n −5 − M(n − 5)

M(5) = 2M(4) + 20 − M(0) = 3

M(6) = 2M(5) + 21 − M(1) = 8

M(7) = 2M(6) + 22 − M(2) = 20

M(8) = 2M(7) + 23 − M(3) = 48

Now, we need to find the number of bit strings of length 8 containing 1111 as well as 000. We get the following 4 and
their 4 reverse strings.

11110001
11110000
01111000
11111000

Thus no. of bit strings of length 8 having either three consecutive 0's or 4 consecutive 1's = 107 + 48 - 8 = 147

 3 votes -- Arjun Suresh ( 124125 points)

17.25 Counting: Please explain this question .. Number of trivial substrings


in “GATE2013” are: A. 37 B. 35 C. 2 D. 36 top gateoverflow.in/11136

combinatory counting


Selected Answer

Trivial sub-strings are { } and { GATE2013 } only..


No of sub-strings from n distinct character string

= n(n+1)/2 + 1 // n is no of characters in string, as we have 1 sub-strings of length n, 2 of length n-1, ... n sub-
strings of length 1.

= 8*9/2 +1 = 36 + 1

= 37

Out of 35 total string, 2 are trivial so (37-2) 35 are non trivial..

 9 votes -- Digvijay Pandey ( 26245 points)

Every String has at least 2 substring one is NULL string and 2nd is the given string itself, Which are called Trivial
substring....remaining possible substring called Non-trivial substrings.

So answer is C. 2

 10 votes -- Narendra ( 121 points)

17.25 Generating Functions: what will be the coefficient of x^23 in


(1+x^5+x^9)^100? top gateoverflow.in/11972

combinatory generating-functions

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1841 of 2244


Selected Answer

In multinomial expansion of (1+x^5+x^9)^100, every term will be of form: C(100 ; m, n, p) * (1^m) * ((x^5)^n)
* ((x^9)^p), where m + n + p =100.

So, for the coefficient of x^23, (5*n + 9*p) should be equal to 23. There is only 1 pair exist for this condition to hold i.e
(1,2).

So, (m, n, p) will be (97, 1, 2). Now, put these values in the term for x^23.

C(100; 97, 1, 2) = 100!/(97! * 1! * 2!) = 485100. This will be the coefficient of x^23.

 2 votes -- Vivek sharma ( 1177 points)

17.26 Made Easy_test Series: Combinatory top gateoverflow.in/38233

Number of solutions are there of x+y+z=17 in positive integers are_________

Here in this do we have to take constraints of x>=1,y>=1,z>=1?

combinatorics engineering-mathematics easy made-easy_test-series

17.27 Permutation: No. of ways in which 2n white and 2n black balls can be
arranged such that no consecutive n white balls are together top gateoverflow.in/41638

The number of ways in which 2n white and 2n black balls can be arranged such that no consecutive n white balls are together,
is

A. 2n +1 C2 + 4n C2n
B. 2n +1 C2 − 2n +1 C1 . 3n Cn ( − 1)n + 4n C2n
C. 2n +1 C2 + ( − 1)n . 2n +1 C1 . 3n Cn + 4n C2n
D. 2n +1 C2 + ( − 1)n . 3n Cn . 2n +1 C1

combinatory permutation

Without any restriction we have a permutation of 4n objects where 2n each are identical. So, 4n C2n .

Now we have to subtract the cases where n white balls are consecutive. We can choose the starting position for these n
balls in 3n + 1 ways. Remaining 3n balls would give 3n Cn . So, our answer should be

4n C − (3n + 1)3n Cn .
2n

But this counts repeatedly the n consecutive case- waiting for correct solution.

 0 votes -- Arjun Suresh ( 124125 points)

17.28 Permutation: Different possible integer solutions for the given function
top gateoverflow.in/35600

How many integer solutions exist for the given equation x + y + z = 15 subject to the constraint that 0 ≤ x, y, z ≤ 10?

I tried the brute force method and listed the possible solution sets for the above equation, given the variable constraints as
follows :

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1842 of 2244

[]
2 3 10
2 4 9
2 5 8
3 6 6
3 4 8
3 5 7
4 5 6
4 7 4
4 10 1
4 11 0
6 7 2
6 8 1
6 9 0
5 9 1
5 10 0
7 8 0

Here, each row will denote the possible values for the three variables. I tried to eliminate any duplicate values, and listed
only the unique combinations of integer values. Then, the number of possible solutions should be one of the permutations of
the above values only, right? So, that should be 16 * 6 = 96 possible solutions. The answer given was 3666, derived using
Generating functions. Please explain.

permutation normal


Selected Answer

This problem can be reduced to balls in bins problem. x, y and z are 3 distinct bins and we have 15 identical balls to fill
them. Now, the problem reduces to all the possible permutations of 15 + (3-1) (3-1 separations split 15 items to 3 bins)
items, with 15 identical balls and another 2 identical separations. So,

17!
15!2!
= 136.

Now, we have to eliminate the cases where x, y, z > 10.

So, let x = 11, now we have y + z = 4, which has 5 possible cases (calculated as above). Similarly for y = 11 and z = 11 we get
5 more cases each totaling 15 cases.

Similarly for 12, 13, 14, 15 we get 3.4, 3.3, , 3.2, 3.1 cases totaling 15 + 12 + 9 + 6 + 3 = 45 possible cases.

So, our answer should be 136 − 45 = 91.

 1 votes -- Arjun Suresh ( 124125 points)

17.29 Permutation: Permutation1.1 top gateoverflow.in/37190

If there are 9 students in a class and each team contain 3 students then how many number of ways 9 students can be
partitioned into 3 teams?

Why is this not 9C3*6C3*3C3?

permutation

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1843 of 2244


Selected Answer

To make #1 group having 9C3 ways and #2 group having 6C3 ways and last #3 group have 1 way to make a group
with remain students.
With ordered group total ways are 9C3 * 6C3 * 3C3.
But for unordered group 9C3 * 6C3 * 3C3 divided by 3!.

 2 votes -- Avdhesh Singh Rana ( 1509 points)

17.30 Permutation: In how many ways can 2n+1 seats in a congress be


divided among 3 parties ? top gateoverflow.in/38063

In how many ways can 2n + 1 seats in a congress be divided among 3 parties so that coalition of any 2 parties will ensure
them majority?

permutation counting


Selected Answer

This problem corresponds to the problem of non negative integral solutions to the equation

P1 + P2 + P3 = 2n + 1 where we have to distribute 2n + 1 seats(identical) among 3 parties(distinct) P1, P2, P3.

The solution will be n −1 +rCr having n = 3 and r = 2n + 1. This comes as 2n +3 C2n +1 which further reduces to 2n +3 C2 = A. (say).

EDIT :

The constraint the the coalition of 2 parties must form a govt can be dealt with as follows-

We have to also ensure that govt must be formed by coalition so we have to eliminate the case where a single party gets
a majority i.e. n + 1 votes. That corresponds to non negative integral solutions to the eqn

P1 + P2 + P3 = n

solution will be 3 C1 × n +2 Cn which reduces to 3 × n +2 C2 = B.

Hence the final answer will be A − B i.e., 2n +3 C2 − 3 × n +2 C2 .

 1 votes -- devarshi ( 373 points)

17.31 Permutation: Question on permutation and combination top gateoverflow.in/34283

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1844 of 2244

Given answer: B, Please explain me how to solve it.

engineering-mathematics combinatory permutation


Selected Answer

Ans : (B)

Let x1,x2,x3,x4 represents 3 different triangles 1,2,3,4.

Hence this problem is identical to distributing 8 balls among x1,x2,x3,x4 such that each will get alt least one ball

i.e x1+x2+x3 +x4 = 8 where x1 ≥ 1; x2 ≥ 1;x3 ≥ 1;x4 ≥ 1;

= > (x1-1) + (x2-1) + (x3-1) +(x4 -1) = 4

Now let p = x1-1; q= x2-1;r= x3-1;s=x4-1;

Hence given eqn reduces to : p+q+r+s = 4 where p,q,r,s ≥ 0

solution to this problem = (n+r-1)Cr = (4+4 - 1) C4 = 7C4 = 35

 3 votes -- Shashank Kumar ( 2029 points)

let x1 x2 x3 x4 be no of balls in triangle 1,2,3,4

x1+x2+x3+x4=8

now its given x1>=1 x2>=1 x3>=1 x4>=1

so we get 4+4-1C4=35

option b

 2 votes -- Pooja ( 22773 points)

17.32 Permutation: permutation and combination top gateoverflow.in/28250

in how many ways 10 identical blue marbles and 5 identical green marbles be arranged in a row so that no two green
marbles are together??

combinatory permutation

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1845 of 2244


Selected Answer

First we place the 10 blue balls in 1 way because they are all identical :

__B1__ B2__B3__B4__B5__B6__B7__B8__B9__B10__

Since no 2 green balls are together only place we have is to place the green balls in between blue balls . There are 11
available places to place the green balls : Therefore we can select any 5 places as 11C5 . Then we arrange the 5 balls in 1
way because they are identical .

Therefore the answer is 11C5 = 462.

 2 votes -- Riya Roy ( 4767 points)

17.33 Permutation: How many ways are there to choose a dozen donuts from
20 varieties top gateoverflow.in/4579

How many ways are there to choose a dozen donuts from 20 varieties

a. if all donuts are of the same variety?


b. if there are at least two varieties among the dozen donuts chosen?
c. if there must be at least six blueberry-filled donuts?
d. if there can be no more than six blueberry-filled donuts?

counting permutation


Selected Answer

a) Here a dozen items must come from a single variety. And we have 20 varieties possible. H ence the no of ways of
selecting a dozen of same variety donut = 20.

b) For this part lets find out no of ways in which the 12 donuts can be chosen from 20 varieties

x1 + x2 + … + x20 = 12

No ways of solving this is (20+12−1 ) C19 = 141, 120, 525 (Explained at end). In the question they have asked that there are at
least 2 varieties of donuts. Hence we need to negate the ans of part a(i.e, the no of ways in which the same variety can
be chosen ) from the total no of ways of choosing the donuts = 141, 120, 525 − 20 = 141, 120, 505

c) It is given that at least 6 donuts of blueberry variety should be there. Here we can assume that 6 donuts are already
chosen. Hence now the solution is (20+6 −1 ) C19( ie., no ways of solving x1 + x2 + … + x20 = 6) = 177, 100.

d) Here the condition is no more than 6 blue berry are selected. To solve this find the no of ways in which at least 7 blue
berry will be chosen an in part c which is (20+5 −1 ) C19 = 42505. Now negate this from total no of possibilities to get the
required ans = 141, 120, 525 − 42, 505 = 141, 078, 021.

We have x1 + x2 + … + x20 = 12.

So, this problem is equivalent to dividing 12 identical balls into 20 distinct bins without any further restrictions. So, lets
use | for the separation between bins and 0 for the balls. For example the below configuration shows all 12 balls in the
first bin.

0 0 0 0 0 0 0 0 0 0 0 0 | | | | | | | | | | | | | | | | | | |

So, now our required answer will be all possible permutations of the above. We have 12 balls and (20-1) separations.
Further 12 balls are identical and 19 separations are also identical (bins are distinct but separations are identical as two
separations together means a bin in empty and their order doesn't matter). So, no. of possible permutations

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1846 of 2244

(12+19) !

= 12!19! = 31C19.

This can be extended for n bins and k balls as n +k−1 Cn −1

Ref: http://www.cse.iitm.ac.in/~theory/tcslab/mfcs98page/mfcshtml/notes1/thperset.html

 2 votes -- Mari Ganesh Kumar ( 1837 points)

17.34 Permutation: How many 4-permutations of the positive integers not


exceeding 100 contain three consecutive integers k, k + 1, k + 2, top gateoverflow.in/12326

How many 4-permutations of the positive integers not exceeding 100 contain three consecutive integers k, k + 1, k + 2, in
the correct order

a) where these consecutive integers can perhaps be separated by other integers in the permutation?

b) where they are in consecutive positions in the permutation?

combinatory permutation


Selected Answer

a) In this part the permutation 5,6,32,7, for example, is to be counted. since it contains the consecutive
numbers 5, 6, and 7 in their correct order (even though separated by the 32). In order to specify such a
4-permutation, we first need to choose the 3 consecutive integers. They can be anything from {I, 2, 3} to
{98, 99, 100}; thus there are 98 possibilities. Next we need to decide which slot is to contain a number not
in this set; there are 4 possibilities. Finally, we need to decide which of the 97 other positive integers not
exceeding 100 is to fill this slot, and there are of course 97 choices. Thus our first attempt at an answer gives
us, by the product rule, 98· 4 . 97.
Unfortunately, this answer is not correct, because we have counted some 4-permutations more than once.
Consider the 4-permutation 4. 5. 6. 7, for example. We cannot tell whether it arose from choosing 4, 5, and 6
as the consecutive numbers, or from choosing 5, 6, and 7. (These are the only two ways it could have arisen.)
In fact, every 4-permutation consisting of 4 consecutive numbers. in order, has been double counted. Therefore
to correct our count, we need to subtract the number of such 4-permutations. Clearly there are 97 of them
(they can begin with any number from 1 to 97). Further thought shows that every other 4-permutation in our
collection arises in a unique way (in other words, there is a unique subsequence of three consecutive integers).
Thus our final answer is 98·4·97 - 97 = 37.927.
b) In this part we are insisting that the consecutive numbers be consecutive in the 4-permutation as well.
The analysis in part (a) works here, except that there are only 2 places to put the fourth number-in slot 1
or in slot 4. Therefore the answer is 98·2·97 - 97 = 18,915.

 3 votes -- Anurag Pandey ( 8183 points)

17.35 Pigeonhole: pigeonhole top gateoverflow.in/13186

Prove that at a party where there are at least two people, there are two people who know the same number of other people
there.

combinatory counting pigeonhole


Selected Answer

http://math.stackexchange.com/questions/445487/prove-that-at-a-party-with-at-least-two-people-there-are-two-people-
who-know-th

 1 votes -- Rohan Ghosh ( 1515 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1847 of 2244

17.36 Pigeonhole: pigeonhole top gateoverflow.in/13180

Assume that in a group of six people, each pair of individuals consists of two friends or two enemies. Show that there are
either three mutual friends or three mutual enemies in the group.

combinatory counting pigeonhole

let the group be labeled as A;B;C;D;E and F. Consider now the person labeled as
A. The remaining five people can be grouped into friends or enemies of A. Of the five other people
(other than A), there are either three or more who are friends of A, or three or more than are enemies
of A. Indeed, when a set of 5 objects (persons) is divided into two groups (friends or enemies) there
are at least d5=2e = 3 elements in one of these groups. Consider first the group of friends of A. Call
them B;C or D. If any of these three individuals are friends, then these two and A form the group
of three mutual friends. Otherwise, B, C and D form a set of three mutual enemies. The proof in the
case of three enemies of A proceeds in a similar manner.

 1 votes -- Rohan Ghosh ( 1515 points)

17.37 Pigeonhole: application of pigeonhole principle top gateoverflow.in/13170

During a month with 30 days, a baseball team plays at least one game a day, but no more than 45 games. Show that there
must be a period of some number of consecutive days during which the team must play exactly 14 games

combinatory counting pigeonhole


Selected Answer

Let a1 be the number of games played until day 1, and so on, ai be the no games played until i.
Consider a sequence like a1 , a2 , …a30 where 1 ≤ ai ≤ 45, ∀ai.
Add 14 to each elements of the sequence we get a new sequence a1 + 14, a2 + 14, …a30 + 14 where 15 ≤ ai + 14 ≤ 59, ∀ai.
Now we have two sequences

1. a1 , a2 , …, a30 and
2. a1 + 14, a2 + 14, …, a30 + 14

having 60 elements in total with each elements taking a value ≤ 59.

So according to pigeon hole principle there must be at least two elements taking a same value ≤ 59 i.e., ai = aj + 14 for
some i and j.
There for there exists at least a period such as aj to ai, in which 14 matches are played.

 3 votes -- Mari Ganesh Kumar ( 1837 points)

17.38 Pigeonhole: pigeonhole top gateoverflow.in/13185

Show that there are at least six people in California (population: 37 million) with the same three initials who were born on
the same day of the year (but not necessarily in the same year). Assume that everyone has three initials.

pigeonhole counting combinatory


Selected Answer

This question is straight application of pigeon hole principle.


Ans= ⎾37*10^6/(26^3*365)⏋=6

 2 votes -- Mari Ganesh Kumar ( 1837 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1848 of 2244

17.39 Pigeonhole: pigeonhole top gateoverflow.in/13184

Show that in a group of 10 people (where any two people are either friends or enemies), there are either three mutual
friends or four mutual enemies, and there are either three mutual enemies or four mutual friends.

combinatory counting pigeonhole


Selected Answer

Take a single person A out of the 10 people. The remaining 9 people has to be either friends or enemy with A. Therefore
acc to pigeon hole principle there atleast⎾9/2⏋(i.e., 5) friends or enemy of A. Lets assume that A has five friends.Now, if
at least two of these are friends then there are three mutual friends if not then there are five mutual enemies(which also
implies that there are four mutual enemies). similarly we can prove that there are either three mutual enemies or four
mutual friends by assuming A has 5 enemies.

 2 votes -- Mari Ganesh Kumar ( 1837 points)

17.40 Pigeonhole: pigeonhole top gateoverflow.in/13183

Show that in a group of five people (where any two people are either friends or enemies), there are not necessarily three
mutual friends or three mutual enemies.

combinatory counting pigeonhole


Selected Answer

https://www.google.co.in/url?
sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0CB4QFjAAahUKEwiGsbLmwODGAhXDW44KHYbdD5A&url=http%3A%
3-2-06.pdf&ei=NBaoVYbHBsO3uQSGu7-ACQ&usg=AFQjCNGVQAfyFu-
7NoEMpP0RK9QhCv2Sfg&sig2=PggJgcHYJoK3003ypov3Pg

 1 votes -- Rohan Ghosh ( 1515 points)

17.40 Placement Questions: In how many ways a rook can go from SouthEast
to northwest corner of 8×8 chess board if travels only upwards or left? top
gateoverflow.in/42390

combinatory recurrence dynamic-programming placement-questions


Selected Answer

This is an example of Permutation with repeated characters.

To go to from (0,0) (consider, southeast corner) to (8,8) (consider northwest corner) we need to take 7 Up turn and 7
right turn. It means that its a forming a string like UUUUUUURRRRRRR (Whatever the way you go, you have to take 7 Up
and 7 right to reach (8,8)). Now our job is it find the how many permutation can be formed from this string. Which is a
very simple task.

Total Number of permutation will be : ( factorial(14) / (factorial(7) * factorial(7))). Which is equivalent to 14C7.

Hence option B is correct.

 4 votes -- Rude Maverick ( 3063 points)

17.41 Probability: Probability question on a pair of dice top gateoverflow.in/33136

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1849 of 2244

I think the ans should be C, but the given answer is A. Anyone can explain please?

engineering-mathematics probability

Ans will be (C)

A pair of dice rolled 3 times, like (a,b) ,(c,d) , (e,f)

So, total 6 throws

Now if sum of a pair is 10

that pair of throws could be (5,5) , (4,6) , (6,4)

Now, it is given among 3 pair of throws only one pair will show 10

Now, that pair we can choose among any one of (5,5),(4,6),(6,4)= so 3C 1 ways (say (a,b) =3C1)

Now for other two pairs ( say (c,d) , (e,f) ) we cannot choose among that previous three pairs

So, that can be (say (c,d))

For 1 in one dice ,other dice can be 1,2,3,4,5,6 = 6 choice..................i

For 2 " " " " " " " 1,2,3,4,5,6 = 6 choice.................ii

For 3 " " " " " " " 1,2,3,4,5,6 = 6 choice..................iii

For 4 " " " " " " " 1,2,3,4,5 = 5 choice.....................iv

For 5 " " " " " " " 1,2,3,4,6 = 5 choice......................v

For 6 " " " " " " " 1,2,3,5,6 = 5 choice.....................vi

So, adding from (i) to (vi) we get 33 choices

So, for 1 pair we have 33 choices

Finally we can say for 3 pairs we have

3C (3C *33*33) / (36 * 36 * 36 )


1* 1

=121 / 576

 3 votes -- srestha ( 11585 points)

17.42 Probability: combinatory top gateoverflow.in/7507

A parking lot has 16 spaces in a row. Twelve cars arrive, each of which requires one parking space, and their drivers chose
spaces at random from among the available spaces. Auntie Em then arrives in her SUV, which requires 2 adjacent spaces.
What is the probability that she is able to park?

11 4 81 17

(A) 20 (B) 7 (C) 140 (D) 28

probability

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1850 of 2244


Selected Answer

12 cars will take 12 places and we are left with 4 places. So, we need to find the probability that at least 2 of them are
adjacent. This will be equal to 1 - Probability that none of them are adjacent.

Let the cars be represented by C and vacant space by V.

C C C C C C C C C C C C V V V V taking 16 places.

We have 16 places to choose the 4 V's giving 16 C4 ways.

If we want no two V's to be adjacent, we must place the V's around the 12 C's in 13 places- 12 after each C and 1 before
the first C. i.e.; we have 13 C4 ways where no vacant places are adjacent.

So, our required probability = 1 - 13 C4/16 C4 = 1 - (13 * 12 * 11 * 10 / 16 * 15 * 14 * 13)


= 1 - 11 / 28
= 17 / 28

 5 votes -- Arjun Suresh ( 124125 points)

17.43 Probability: In a round-robin tournament with m players, every two


players play one game in which one player wins and the other loses. gateoverflow.in/4607

top

In a round-robin tournament with m players, every two players play one game in which one player wins and the other loses.
We want to find conditions on positive integers m and k with k < m such that it is possible for the outcomes of the
tournament to have the property that for every set of k players, there is a player who beats every member in this set. So
that we can use probabilistic reasoning to draw conclusions about round-robin tournaments, we assume that when two
players compete it is equally likely that either player wins the game and we assume that the outcomes of different games
are independent. Let E be the event that for every set S with k players, where k is a positive integer less than m, there is a
player who has beaten all k players in S.

a) Show that where F j is the event that there is no player who beats all k players from the
j th set in a list of the mk sets of k players.
b) Show that the probability of Fj is (1−2 −k ) m−k
c) Conclude from parts (a) and (b) that C(m,k)(1−2 −k ) m−k and, therefore, that there must
be a tournament with the described property if C(m,k)(1−2 −k ) m−k <1
d) Use part (c) to find values of m such that there is a tournament with m players such that for every set S
of two players, there is a player who has beaten both players in S. Repeat for sets of three players.

combinatory probability

This is not a gate oriented qus.however the things that are asked to be proved can be remembered to answer mcq

 0 votes -- Rohan Ghosh ( 1515 points)

17.44 Recurrence: recurrence relation top gateoverflow.in/28373

1. Find recurrence relation for ternary string of length n that do not contain two consecutive zeros or two consecutive 1s?
2. Find recurrence relation for ternary string that contain either two consecutive or two consecutive 1s?
3. Find recurrence relation for no of ternary strings of length n that do not contain two consecutive symbols same?
4. Find recurrence relation for ternary strings of length n that contain two consecutive symbols same?

Also write initial conditions.

combinatory recurrence

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1851 of 2244

1. Let an be the no. of ternary strings not containing "00" or "11" of length n. Let a0 be the no. of ternary strings not
n
containing "00" or "11" of length n and ending in '0' and similarly we define a1 and a2 . So,
n n

an = a0 + a1 + a2
n n n

(
= a1 + a2
n− 1 n− 1 ) (
+ a0 + a2
n− 1 n− 1
+ a0 + a1 + a2
n− 1 n− 1 n− 1 ) ( )
(
= 2. a0 + a1 + a2
n− 1 n− 1 n− 1
+ a2
n− 1 )
= 2.an −1 + an −2 .

For initial condition, a1 = 3, a2 = 7.(All two length strings except 11 and 00).

2. We can get this as

bn = 3n − an .

where an is as in 1. Solving, we get

bn = 3n − 2.an −1 − an −2

(
= 3n − 2. 3n −1 − bn −1 − 3n −2 + bn −2)
[ ]
= 3n −2 32 − 2.3 − 1 + 2.bn −1 + bn −2

(
= 2. 3n −2 + bn −1 + bn −2 )
Initial condition, b1 = 0, b2 = 2.

3. Similar to 1, we can write

an = a0n + a1 + a2
n n

= a1 + a2 + a0 + a2 + a0 + a1
n− 1 n− 1 n− 1 n− 1 n− 1 n− 1

= 2.an −1 .

Initial condition a1 = 3, a2 = 6.

4.

bn = 3n − an

where an = 2.an −1 as shown in 3. Solving we get,

bn = 3n − 2.an −1

(
= 3n − 2. 3n −1 − bn −1 . )
Initial condition b1 = 0, b2 = 3.

 2 votes -- Arjun Suresh ( 124125 points)

17.45 Recurrence: Recurrance Relation top gateoverflow.in/36230

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1852 of 2244

an = an-1 + n , n>=1

a0=2

Find a 100... ?

Solution

I actually wanted to know what is wrong with this method .


Could you pls help Whats wrong here .

T(n) = T(n-1)+n
and back substitute

T(n)= T(n-k) + nk

putting n-k = 0

T(n) = 2+ n* n

So T(100) = 2+100*100

Actual answer is 5052

recurrence algorithms


Selected Answer

t(n)=t(n-1)+n

=t(n-2)+n+n-1

=t(n-3)+n+n-1+n-2

=t(n-k)+n+n-1+n-2+.....1

k=n

=t(0)+n(n+1)/2

=2+100(101)/2

=5052

 1 votes -- shivanisrivarshini ( 2067 points)

a0 =2

a1=a0+1 =2+1

a2=a1+2=2+1+2

a3=a2+3=2+1+2+3

a4=a3+4=2+1+2+3+4

a100=2+1+2+3+ .........+100

=2+5050=5052

 1 votes -- shivanisrivarshini ( 2067 points)

17.46 Recurrence: How to solve this recurrence relation? top gateoverflow.in/27775

Solve the equation:

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1853 of 2244

an = 5an / 3 + 7, a1 = 5

Note: a0 is not given.

recurrence


Selected Answer

( )
T(n) = 5 ⋅ T n/31 + 7

( ( )
= 5 × 5 ⋅ T n/32 + 7 + 7 )
( )
= 52 ⋅ T n/32 + 51 ⋅ 7 + 7

( ( )
= 52 × 5 ⋅ T n/33 + 7 + 51 + 7 )
( )
= 53 ⋅ T n/33 + 52 ⋅ 7 + 51 ⋅ 7 + 7


k−1

( )
= 5k ⋅ T n/3k + 7 ⋅ i =0 5i

When k = log3 n, we have:

(log 3 n ) −1


T(n) = 5log3 n ⋅ T(1) + 7 ⋅ i =0 5i

51 + (log3 n −1 ) − 1
= 5log3 n ⋅ T(1) + 7 ×
( 5−1
)
It is given that T(1) = 5, hence, we get:

T(n) =
4
(
⋅ (4 ⋅ 5 + 7) ⋅ 5log3 n − 7 )
1

=
4
(
⋅ 27 ⋅ nlog3 5 − 7 )
1


4
(
⋅ 27 ⋅ n1.465 − 7 )

 1 votes -- Pragy Agarwal ( 13675 points)

17.47 Recurrence Eqation: How to find particular solution of a recurrence


equation ? How to use Shift Operator top gateoverflow.in/33463

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1854 of 2244

Solve the Recurrence Equation

T(2k ) = 3T ( 2 k-1 )+1


T(1) = 1

recurrence-eqation engineering-mathematics

As other than the recursion function , any function of K is not added , this equation is equivalent to T(k) = 3T(k-1) + 1 ,
T(0) = 1

Using repeated substitution we can observe that T(k) = 1 + 3^1 + 3^2 ... + 3^k .

Using geometric series summation T(n) = (3^(k+1) - 1)/2

 0 votes -- Vikram Bhat ( 587 points)

17.47 Suppose that S is a set with n elements. How many ordered pairs (A,
B) are there such that A and B are subsets of S with A ⊆ B? top gateoverflow.in/4580


Selected Answer

A set with n elements has 2 n subsets. Now, from the given set we can have
n subsets and a subset of subset will be a subset of a set)
nCn subsets of size n (which will have 2

n-1 subsets which are also subsets of original set)


nCn-1 subsets of size n-1 (which will have 2

n-2 subsets which are also subsets of original set)


nCn-2 subsets of size n-2 (which will have 2

....

nC1 subsets of size 1

nC0 subsets of size 0.

So, total number of ordered pairs satisfying the subset order will be

2n nCn + 2 n-1 nCn-1 + 2 n-2 nCn-2 + .... 20 nC0

= (x + 1) n where x = 2,

= 3n

 6 votes -- Arjun Suresh ( 124125 points)

17.48 Madeeasy test series DISCRETE maths 1 top gateoverflow.in/36596

5 member commities are to be formed out of 10 people. The names are written in chits of paper and put into 6 boxes.
Atleast _______ chits go into the same box.

test-series made-easy engineering-mathematics

17.49 Made Easy Test Series top gateoverflow.in/34499

5 member commities are to be formed out of 10 people. The names are written in chits of paper and put into 6 boxes.
Atleast _______ chits go into the same box.

combinatory made-easy test-series

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1855 of 2244


Selected Answer

we can choosw 5 people out of 10 people 10C5 = 252

now let there is atleast x cheets of papaer in each box.

they are distributed 6 boxes.

x = floor(252/6) = 42 . (floor i used as atleast mentioned)

 1 votes -- Sayantan Ganguly ( 5061 points)

17.50 Find Sum of four digit Number top gateoverflow.in/33518

Find the sum of all four digit numbers that can be formed by the digits {0,1,2,3,4}?

a)183450

b)259980

c)266640

d)6600

combinatory


Selected Answer

Option (b) is correct.

Method 1(Using Expectation):

No. of 4 digit no possible using {0,1,2,3,4} = 4*4*3*2 = 96

Now expected value of first digit in any given no. = (1 +2 +3 +4)/4 = 5/2

Now sum of all digits : 0 +1 + 2 +3 + 4 = 10

= sum of all five expected digits = E[1st digit] + 4* E[other digit except 1st] = 5/2 + 4*E[other digit except 1st]

Hence ,4*E[other digit except 1st] = 10 - 5/2 = 15/2 => E[other digit except 1st] = 15/8

Now since there are 96 numbers, Hence total sum = 96*[5/2 *10 3 + 15/8 * 10 2 + 15/8 * 10 1 + 15/8 * 10 0] = 259980

Method 2:

First let us assume number can start with '0' also. Total no of such no : 5*4*3*2 =120.

Frequency of each digit at unit or tens or hundred or thousand place = 120/5 = 24.

Total sum of digits at unit place = 24[0+1+2+3+4] = 240

Total sum of all digits = 240[

So, total sum = 24*[103 + 102 + 10 1 + 100 ] = 266640

In this sum ,we have included those no's also which starts with '0'.so we have to deduct those sum.

No. of no starting with '0' = 4*3*2 = 24

Hence frequency of each digit {1,2,3,4} at unit ,tens ,hundred place = 24/4 =6

sum of digits at unit place = 6*[1+2+3+4]= 60.

Total sum of no starting with '0' = 60*[ 102 + 10 1 + 100 ] = 6660

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1856 of 2244

Hence required sum is = 266640 - 6660 = 259980

 1 votes -- Shashank Kumar ( 2029 points)

17.51 permutation top gateoverflow.in/33502

for aaaabbbcccdde find no of permutation such that

1)no two c are together

2)no 3 c are consecutive


Selected Answer

1) no two 'c' are together.

X : represents places where we can put 'c'.

X a X a X a X a X b X b X b X d X d X e X

Required no.of ways = no.of arranging 4 a's , 3b's ,2 d's and 1 e's and then selecting 3 places out of 11 places and
putting 3 c's there.

= ((10!) /( 4! * 3! * 2! )) * ( 11 C3 * 3!/3! ) = 2079000

2) Here required no of ways = Total no of ways of arranging 13 letters - No of ways in which all 3 c's are together(i.e
consider all 3 c's as one unit ,thus arrange 11 letters and finally arrange 3 c's among themselves

= ((13!) /( 4! * 3! * 3! * 2! )) - ((11!)/( 4! * 3! * 2! )) * (3!/3!) = 3603600 - 138600 = 3465000

 0 votes -- Shashank Kumar ( 2029 points)

17.52 how many no. of integers can be formed top gateoverflow.in/33471

17.53 Suppose that when an enzyme that breaks RNA chains after each G
link is applied to a 12-link chain top gateoverflow.in/4582

Suppose that when an enzyme that breaks RNA chains after each G link is applied to a 12-link chain, the fragments obtained
are G, CCG, AAAG, and UCCG, and when an enzyme that breaks RNA chains after each C or U link is applied, the fragments
obtained are C, C, C, C, GGU, and GAAAG. Can you determine the entire 12-link RNA chain from these two sets of
fragments? If so, what is this RNA chain?

combinatory

17.54 Calculating number of possible strings top gateoverflow.in/36649

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1857 of 2244

Couldn't understand the method they have used to find the answer. Please explain

combinatory


Selected Answer

0 length string (null) = 1


1 length string (a,b,c,d) = 4
2 length string (combination of 2) = 42
1 length string (combination of 3) = 4 3

Add all 3 you will get 85


 2 votes -- Digvijay Pandey ( 26245 points)

17.55 numbers top gateoverflow.in/35661

find number of 7 digit number with sum of digits equal to 11 and formed using digits 1 ,2 ,3

Sum is 11 = (3,3,1,1,1,1,1) , ( 3,2,2,1,1,1,1) , (2,2,2,2,1,1,1)

No of combinations : 7!/2!5! + 7!/2!4! + 7!/3!4!

 1 votes -- Somnath Paul ( 53 points)

17.55 A professor writes 20 multiple-choice questions, each with the


possible answer a, b, c, or d, for a discrete mathematics test. If the number
of questions with a, b, c, and d as their answer is 8, 3, 4, and 5, respectively,
how many different answer keys are possible, if the questions can be placed
in any order? top gateoverflow.in/4581


Selected Answer

We have to arrange 8 a's, 3 b's, 4 c's and 5 d's.. i.e Permutation to find possible number of answer keys that are
possible= 20! but the all a's are identical, b's are identical , c's are identical and d's are identical, therefore Answer is =
20!/(8! . 3! . 4! . 5!)= 3491888400

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1858 of 2244

 7 votes -- Prateeksha Keshari ( 1619 points)

17.56 total possible 4 digit numbers from given 6 digits top gateoverflow.in/34777

total possible 4 digit numbers from 2,3,5,6,7,9 without repetition? total numbers possible less than 500?

360, 130 360, 100 240, 120 none

combinatory

4 Digit Numbers Possible = 6C4 * 4! =15*24=360


Numbers less than 500= Starting with 2,3 * 5C3 *3!

=2* 20 * 6

= 120

 2 votes -- Hareesh Kumar ( 43 points)

17.56 In how many ways 5 blue pens and 6 black pens can be distributed to
6 children? top gateoverflow.in/36291

5+6-1C * 6+6-1C = 116424


5 6

http://gateoverflow.in/3286/gate2008-it_25

Similar question

 0 votes -- kanahanin ( 53 points)

17.57 How many cards must be chosen from a standard deck of 52 cards to
guarantee that there are at least two cards of the same kind? top gateoverflow.in/4577

The answer is 14.


But there are four kind of cards.(spades,heart,diamond,chidi)
So there must be 5 pick up to ensure the same kind condition.


Selected Answer

yes. 5 should be the answer. 14 would be the answer for "at least 2 cards of different kind".

 3 votes -- Arjun Suresh ( 124125 points)

17.58 circular arrangement top gateoverflow.in/43163

how many ways are there to arrange 6 girls and 15 boys in a circle such that there are atleast two boys between two
adjacent girls?

combinatory

For every girl there are 2 boys one at left and other at right. so for 6 girls, 12 boys can be chosen in 15P12 ways.Now
every girl and 2 boys are considered as group remaining 3 boys(15-12 boys) are also consider as groups.so we have total
9 group in total and this can be arrange in circular in (9-1)!=8!ways. Number of permutation satisfy the conditions equals
15P12*8!

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1859 of 2244

 1 votes -- Nishant Arora ( 213 points)

17.59 There are six runners in the 100-yard dash. How many ways are there
for three medals to be awarded if ties are possible? top gateoverflow.in/4508

There are six runners in the 100-yard dash. How many ways are there for three medals to be awarded if ties are possible?
(The runner or runners who finish with the fastest time receive gold medals, the runner or runners who finish with exactly
one runner ahead receive silver medals, and the runner or runners who finish with exactly two runners ahead receive bronze
medals.)

combinatory


Selected Answer

How many ways are there for 3 TYPES of medals? (no ties)
Any of the 6 runners can finish 1st
Any of the remaining 5 runners can finish 2nd
Any of the remaining 4 runners can finish 3rd

6 * 5 * 4 = = 120

How many ways are there for 3 TYPES of medals? (ties possible)

6 gold -----> C(6,6) = 1


5 gold -----> C(6,5) = 6
4 gold -----> C(6,4) = 15
3 gold -----> C(6,3) = 20
2 gold, 4 bronze ----> C(6,2) * C(4,4) = 15
2 gold, 3 bronze ----> C(6,2) * C(4,3) = 60
2 gold, 2 bronze ----> C(6,2) * C(4,2) = 90
2 gold, 1 bronze ----> C(6,2) * C(4,1) = 60
1 gold, 5 silver ----> C(6,1) * C(5,5) = 6
1 gold, 4 silver ----> C(6,1) * C(5,4) = 30
1 gold, 3 silver ----> C(6,1) * C(5,3) = 60
1 gold, 2 silver ----> C(6,1) * C(5,2) = 60
1 gold, 1 silver, 4 bronze ----> C(6,1) * C(5,1) * C(4,4) = 30
1 gold, 1 silver, 3 bronze ----> C(6,1) * C(5,1) * C(4,3) = 120
1 gold, 1 silver, 2 bronze ----> C(6,1) * C(5,1) * C(4,2) = 180
1 gold, 1 silver, 1 bronze ----> C(6,1) * C(5,1) * C(4,1) = 120

1 + 6 + 15 + 20 + 15 + 60 + 90 + 60 + 6 + 30 + 60 + 60 + 30 + 120 + 180 + 120 = 873

 2 votes -- yallasrikanthreddy ( 279 points)

17.60 Prove the hockeystick identity using a combinatorial argument. gateoverflow.in/4542

top

Here's Hockey Stick Identity:

what is Hockey Stick Identity means and Where it is used in Practical Application?
Also Prove Suitable Explanation of the combinatorial argument.

17.61 Combinatorics top gateoverflow.in/43173

Consider a sequence of 10 A's and 8 B's placed in a Row. By a run we mean one or more letters of the same type placed side
by side. Here is a arrangement of 10 A's and 8 B's which contains 4 runs of A and 4 runs of B:
AAA BB A BBB AA B AAAA BB
In how many ways can 10 A's and 8 B's be arranged in a row so that there are 4 runs of A and 4 runs of B.
a) 2*(9c3)(7c3)
b) (9c3)(7c3)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1860 of 2244

c) (10c4)(8c4)
d) (10c5)(8c5)

C) (10c4)(8c4)

 0 votes -- jarul.mehta30 ( 13 points)

17.61 What are the number of ways to colour a rainbow with 7 colours
provided no two adjacent stripes has the same colour? top gateoverflow.in/43790

i think , No of ways it can be done is 7(6)^6

first place can be fill by 7 ways

second colour can be fill by 6

And same goes on till seventh place ..

Consider an example of RGB as colours

And you need to apply above question

1) First colour will be filled by 3 ways : R or G or B

Let us say we select R

2) Second Colour will be filled by 2 ways ( G and B ) say G

3) Thrd colour will be filled by 2 ways ( R and B ) say R or even say B

so you can have RGB or RGR --Look no 2 adj layers have same colours .

Hence No of ways it can be coloured is 7!(6!)^6 ways

 0 votes -- Dexter ( 1933 points)

17.62 The English alphabet contains 21 consonants and five vowels. How
many strings of six lowercase letters of the English alphabet contain a)
exactly one vowel? b) exactly two vowels? c) at least one vowel? d) at least
two vowels? top gateoverflow.in/4503

Hi Answer to each option is given as:

a) 122,523,030
b) 72,930,375
c) 223,149,655
d) 100,626,625
And I used the following approach to each option but answers don't match.
a) C(5,1)*C(21,5)*6!
b) C(5,2)*C(21,4)*6!
c) P(26,6)-P(21,6)
d) [C(5,2)*C(21,4)+C(5,3)*C(21,3)+C(5,4)*C(21,2)+C(5,5)*C(21,1)]*6!
Please check.


Selected Answer

(a) Six letters with one vowel. We can place the vowel in any of the 6 positions in 5 * 6 ways and the remaining 5
positions can be filled in in 215 ways by the consonants as they can be repeated also. So, total number of words possible

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1861 of 2244

= 215 * 5 * 6 = 122,523,030

(b) Two vowels will give (vowels can also be repeated)

214 * 5 * 5 * 6C2 = 72,930,375

(c) 266 - 216 = 223,149,655

(d) (c) - (a) = 100,626,625

@Sahil-gupta All your answers are correct if letters were not allowed to be repeated.

 4 votes -- Arjun Suresh ( 124125 points)

17.62 How many ways are there for a horse race with four horses to finish if
ties are possible? [Note: Any number of the four horses may tie.) top gateoverflow.in/4505


Selected Answer

Result can be like this: A, B, C, D are horses and 1-4 are the final positions.

1 2 3 4 - 4! = 24 ways
1 2 3 3 - 4!/2! = 12 ways
1 2 2 3 - 4!/2! = 12 ways
1 2 2 2 - 4!/3! = 4 ways
1 1 2 3 - 12 ways
1 1 2 2 - 4!/2!2! = 6 ways
1 1 1 2 - 4 ways
1 1 1 1 - 1 way

So, total = 75 ways

 3 votes -- Arjun Suresh ( 124125 points)

17.63 Find the coefficient of x7 in expansion of (1+3x-2x3)10. top gateoverflow.in/41380

Find the coefficient of x7 in expansion of (1+3x-2x 3)10.


How to apply multinomial theorem to solve this types of problems?

17.64 How many bit strings with length not exceeding n, where n is a
positive integer, consist entirely of 1's ? top gateoverflow.in/41036

why do we count here empty string also , it has no 1's , so what's the reason for counting this ?


Selected Answer

Empty string does not violate the given condition. But usually we don't count that when we count the no. of strings. To
avoid confusion they usually say non-empty string.

 1 votes -- Arjun Suresh ( 124125 points)

17.65 Even number top gateoverflow.in/38318

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1862 of 2244

How many 4 digit even number are possible with each digit distinct ?

engineering-mathematics


Selected Answer

Number of Numbers ending with 0


= 9*8*7*1 = 504
(rightmost position 0 i.e. one choice, rest of the 3 places with 9*8*7 ways..)

Number of Number ending with 2,4,6,8


= 8*8*7*4 = 1792
(rightmost position one out of four(2,4,6,8) number, 1st position from left is one out of eight (Except 0 and rightmost bit
number) number, rest of the two choices can be any number i.e. 8*7 choices..)

Total = 1792 + 504 = 2296

 1 votes -- Digvijay Pandey ( 26245 points)

17.65 How many strings of length 10 over the alphabet {a, b, c} have either
exactly three a's or exactly four b's? top gateoverflow.in/4576


Selected Answer

There are 10 places to be filled.

Case 1: Exactly 3 a's: We fill 3 places with 3 a's in 3C3 * 10C3 ways. Now, remaining 7 places can be filled using b or c in
27 ways.

Case 2: Exactly 4 b's: We fill 4 places with 4 b's in 4C4 * 10C4 ways. Remaining 6 places can be filled using a or c in
26 ways.

Case 3: Exactly 3 a's and exactly 4 b's: 10C3 * 7C4 * 1 3 = 4200

So, number of strings possible = Case 1 + Case 2 - Case 3 = 10C3 * 128 + 10C4 * 64 - 4200 = 24,600

 4 votes -- Arjun Suresh ( 124125 points)

17.66 palindrome top gateoverflow.in/38171

How many seven length palindrome possible using English alphabet.?


Selected Answer

#Palindrome of even length n = 26 n/2

#Palindrome of odd length n = 26 (n+1)/2

Answer is 26 4

 1 votes -- prathams ( 1141 points)

17.67 combinations top gateoverflow.in/39207

A, B are two 8-bit numbers such that A+B < 2^8. The number of possible combinations of A and B are

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1863 of 2244


Selected Answer

lets suppose A+B<4

then A B= 0,0 0,1 0,2 0,3

1,0 1,1 1,2

2,0 2,1

3,0

4 + 3+ 2 + 1= sum of 4 natural numbers =n(n+1)/2=4(5)/2=10

similarly ....sum of 256 natural numbers= 256(257)/2=32896

 3 votes -- Deepesh Kataria ( 1207 points)

17.68 Circular Permutation top gateoverflow.in/40369

A class is composed of 2 brothers and 6 other boys. In how many ways can all the boys be
seated at a round table so that the two brothers are not seated together?

a. 3000

b.3600

c. 2050

d. 2600

4320

 0 votes -- Rahul Singla ( 187 points)

17.69 33. How many different strings can be made from the letters in
ORONO, using some or all of the letters? top gateoverflow.in/4575

The answer is 63.


But I got 57.
Approch:
1 letters: = O,R,N(=3)
2 letters: = OO,OR,ON,NR(1+2+2+2=7)
3 Letters: = OOO,OOR,OON,ORN(1+3+3+6 = 13)
4 Letters : OOOR,OOON,OORN(4+4+6 = 14)
5 Letters: = OOORN(20)
So Total words = 3+7+13+14+20 = 57
Please check.


Selected Answer

1 letters: = O,R,N(=3)
2 letters: = OO,OR,ON,NR(1+2+2+2=7)
3 Letters: = OOO,OOR,OON,ORN(1+3+3+6 = 13)
4 Letters : OOOR,OOON,OORN (4+4+4!/2! = 8 + 12 = 20)
5 Letters: = OOORN(5!/3! = 120/6 = 20)
So Total words = 3 + 7 + 13 + 20 + 20 = 63

 4 votes -- Arjun Suresh ( 124125 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1864 of 2244

17.70 permutations top gateoverflow.in/40371

The number of ways in which 6 rings can be worn on the four fingers of one hand is:

a. 360

b. 4^6

c. 6C4

d. 6^4


Selected Answer

Ans B) option, you can put one ring in any of 4 fingers so it becomes 4*4*4*4*4*4.

 1 votes -- UK ( 1341 points)

17.71 How many cards must be chosen from a standard deck of 52 cards to
guarantee that there are at least two cards of each of two different kinds? top
gateoverflow.in/4578
The answer given is 17.


Selected Answer

I guess question is "at least two cards each of two different kinds".

We can only have 13 cards of one kind. So, in the worst case we pick these 13 cards all of same kind. Now, if we pick the
next card of a different kind, we can do like this only 3 more times- as there are only 4 different kinds. The fourth time we
do, we must repeat a kind. So, 13+4 = 17 is the answer.

 2 votes -- Arjun Suresh ( 124125 points)

17.71 i am not getting confidence in combinatric. Please suggest some


resources. Thanks in Advance. top gateoverflow.in/6651


Selected Answer

You can see the below problems. Also see this link:

http://www.cse.iitm.ac.in/~theory/tcslab/mfcs98page/mfcshtml/notes1/thperset.html

http://gateoverflow.in/tag/combinatory

 2 votes -- Arjun Suresh ( 124125 points)

17.72 From 2,3,4,4,5,how many numbers can be formed such that even digits
are at odd places ? top gateoverflow.in/26144

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1865 of 2244

Now I have 2 even positions and 2 odd positions and I have 3 even numbers 2 ,4 ,4 and 2 odd numbers so one odd position will be occupied by an even number but
then even no can't be at odd position so then how to approach this question ?


Selected Answer

It is a five digit no.

So, 1st,3rd,5th place can be occupied by even digit like 2,4,4

They can be arranged 3!/2!=3 ways

2nd and 4th place can be arranged by 3,5 in 2! ways

So, total 3*2!=6 numbers

 0 votes -- srestha ( 11585 points)

17.73 Find out the recurrence relation for the given problem top gateoverflow.in/20381

If an is number of ternary sequences of length n with even number of 0's, then the recurrence relation for an is?

Also find the value of a8 .

engineering-mathematics combinatory

an = No of ternary string containing even no of zeros.

= 2 × an −1 + (3n −1 − an −1 )

= an −1 + 3n −1


The last symbol that is nth symbol may be 1 or 2 and this wont effect the even no of zeros which will also be present in the
string of size an −1 . Therefore twice of an −1 is used.

Now, if the nth symbol is 0 we can count all strings with "odd" number of 0's of length n − 1 which is given by
an′ −1 = 3n −1 − an −1 .

Let a0 = 1
a1 = 2 because {1, 2} have 0 no of zeros which are valid.
a2 = a1 + 31 = 5 the possible 2 length string with even no of zeros {00,11,12,21,22}
a3 = a2 + 32 = 14
a4 = a3 + 33 = 41
a5 = a4 + 34 = 122
a6 = a5 + 35 = 365
a7 = a6 + 36 = 1094
a8 = a7 + 36 = 3281.

 0 votes -- Riya Roy ( 4767 points)

17.74 Use generating function to solve question top gateoverflow.in/20376

Use generating function to determine the number of different ways 10 identical

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1866 of 2244

balloons can be given to 4 children if each children receives at least 2 balloons.

All balloons are identical, and we're distributing it among 4 children, it is clearly a case of combination with repetition.

The given constraint is that each of the child receives at least 2 balloons. Mathematically we can write:

c1 + c2 + c3 + c4 = 10, where ci ≥ 2

(ci is the number of balloons the ith child got)

From, ci ≥ 2  ci − 2 ≥ 0

Let, ci − 2 = bi ≥ 0

Now, we can rewrite the equation c1 + c2 + c3 + c4 = 10 as follows

b1 + b2 + b3 + b4 = 2, where bi ≥ 0

So, the answer to the question is the number of solutions possible for the above equation, which is

4+2−1 5

( 2
) = ( 2 ) = 10
 1 votes -- Sujit Kumar Muduli ( 169 points)

17.74 how many ways 10 persons can be divided into 5 teams of 2 each ? top
gateoverflow.in/26165

Suppose teams are labelled like A, B, C, D, E:

So, no. of ways = 10C2 × 8 C2 × 6 C2 × 4 C2 × 2 C2 = 113400

10!
5
We can also do as 2 = 113400

Now, if the teams are unlabeled, we have to divide the answer by 5! = 120 as each of the permutation is the same.

113400
120
So, required answer = = 945.

 1 votes -- Arjun Suresh ( 124125 points)

Notice that teams here do not have separate identities. They are just teams (so obviously you cannot distinguish among
two teams). So, if you include Boy1, Boy2 in one team then do not include them in any other team because they both are
already counted as a team (doesn't matter which team). So whatever permuatations you make, if the sequence aleady
has X,X,boy1,boy2,X,X,X,X,X,X then no need to include boy1,boy2,X,X,X,X,X,X,X,X again. 10!/(2! 2! 2! 2! 2! * 5!) = 945
ways

 1 votes -- Tushar Shinde ( 1523 points)

17.75 From the word ASSASSINATION ,now in how many ways can we form
4 letter word from it ? top gateoverflow.in/26200

My confusion is how to deal with the case when I have 2 same and 2 different ,now since I have 3A's ,4 S so why can't I chose 2A's like 3C2 , what 's the problem

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1867 of 2244

in this ?


Selected Answer

A S S A S S I N A T I O N

Now, we want 4 letter words from these letters.

Any 4 letter word is given by 13P4 .

But these include words being repeated like

AAAS
AAAS
AAAS

as we have given importance to the position of each 'A' but in a word when they come together, the words are the same.

So, we have to do the hard way.

3 A's
4 S's
2 I
2 N

Case 1: All four letters are different


6P = 360 (6 distinct characters)
4

Case 2: Only 2 letters are same


4!
4C 5C 2!
1. 2. = 480 (for repetition we can choose any one from A, S, N, I and then permute the 4 with 2 repetitions)

Case 3: 2 letters are repeated twice (like AASS)

4!
4C 2 !.2 !
2. = 36

Case 4: Only 3 letters are same


2C 5C
1. 1. 4 = 40

Case 5: All 4 letters are same

1 (only SSSS)

So, in total 360 + 480 + 36 + 40 + 1 = 917

 0 votes -- Arjun Suresh ( 124125 points)

17.76 Combinatorics top gateoverflow.in/27915

Every Sunday, Bill makes lunches for Carolyn. Lunch consists of a sandwich, a fruit, and a desert. Sandwich is either ham
and cheese, peanut butter and jelly, egg salad, or tuna fish. Fruit is either an apple, an orange, or a coconut. Desert is either
pretzels, a brownie, or an apple pie.

(a) How many different lunches can Bill make for Carolyn?

(b) If Carolyn does not like to have egg salad with apple pie, or tuna fish with an apple, then how many lunches can Bill
make for Carolyn.

combinatory

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1868 of 2244


Selected Answer

basically this is a simple one. there are four choices for sandwich , 3 for fruit and 3 for desert, so he can choose anything
for the lunch.

part one

4c1*3c1*3c1=4*3*3=36

second part.

now this all combination contains all the combinations like . sandwich - egg salad , desert -apple pie. Now she does not
like this combination . so all such combinations will be 3, because i can arrange this pair with every fruit one by one. as
there are 3 fruits . 3 pairs will be there. similarly for second case i can choose the fruit in 3 ways . so total combination we
don't have to include is 3+3=6

total - not wanted =36-6 =30

 2 votes -- Ravi Singh ( 7303 points)

17.77 how many ways can we form a team of 2 men and 2 women such that
no couple is a part of team ? top gateoverflow.in/26213

There are 10 couples at party .In this question I have only doubt that if I chose 2 husbands first ,now for wives remaining
choice will be 8 so it will be 10C2 *8C2 ,Now I could have done it other way around like first chosing 2 wives and then
removing their corresponding husbands so again no of ways in which team can be formed is 10C2*8C2 ,now why can't we
add these two cases ?

17.78 counting top gateoverflow.in/18541

Find the number of ways of forming a committee of 9 people drawn from 3 different parties so that no party has absolute
majority in committee?


Selected Answer

4 ways : {1,4,4}, {4,1,4], {4,4,1}, {3,3,3}

 1 votes -- Happy Mittal ( 9253 points)

17.79 counting top gateoverflow.in/18540

In an experiment 4 different colored dice are thrown simultaneously and numbers are added find number of distinct
experiments such that total is 18?

We require the no of solution of the equation X1+X2+X3+X4=18 where 1<=X1,X2,X3,X4<=6.


You have form all non increasing solution of the above eq and permuate them.

Non increasing order of No of permutation possible for this


solution solution
6 6 5 1 12
6 6 4 2 12
6 6 3 3 6
6 5 4 3 24

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1869 of 2244

6 5 2 5 12
6 4 4 4 4
5 5 4 4 6
5 5 5 3 4
Total 80

This method is brute force method and its highly prone to careless mistake.
For ans verification you can write a simple programe(https://ideone.com/E9Vym3)

 0 votes -- Mari Ganesh Kumar ( 1837 points)

17.80 p and c top gateoverflow.in/18511

1)How many 4 digit no are there with 6 appearing exactly once?

2)How many integers in set{,2,3,---1,00,000} contains exactlu one 3 one 4 one 5 in their decimal representation?

1) starting with 6 so remaining 9 digit can be placed at these position

6 012345789 012345789 012345789

9 9 9 combination = 9*9*9

ending with 6 at first place we can place other 0 any number

12345789 012345789 012345789 6

8 9 9 9 combination = 8*9*9

similarly we can place 6 at second or second last

so total combination for not starting with 6 = 3*8*9*9

therefore total combination with exactly one 6= 3*8*9*9 + 9*9*9 = 2673 i guess its the answer

 0 votes -- Umang Raman ( 10379 points)

17.81 Combination of 4 Letter in MATHEMATICS? top gateoverflow.in/18375

The given word is MATHEMATICS which can be arranged in different ways by taking some or all the letters used in the word.

the number of words that can be formed by taking 4 letters at a time out of the letters of the given word.

combinatory


Selected Answer

There are 8 distinct letters: M-A-T-H-E-I-C-S. 3 letters M, A, and T are represented twice (double letter). Selected 4
letters can have following 3 patterns:

1. abcd - all 4 letters are different: 8P4=1680 (choosing 4 distinct letters out of 8, when order matters) or 8C4∗4!=1680
(choosing 4 distinct letters out of 8 when order does not matter and multiplying by 4! to get different arrangement of
these 4 distinct letters);

2. aabb - from 4 letters 2 are the same and other 2 are also the same: 3C2∗4!2!2!=18 - 3C2 choosing which two double
letter will provide two letters (out of 3 double letter - MAT), multiplying by 4!2!2! to get different arrangements (for
example MMAA can be arranged in 4!2!2! # of ways);

3. aabc - from 4 letters 2 are the same and other 2 are different: 3C1∗7C2∗4!2!=756 - 3C1 choosing which letter will
proved with 2 letters (out of 3 double letter - MAT), 7C2 choosing third and fourth letters out of 7 distinct letters left and

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1870 of 2244

multiplying by 4!2! to get different arrangements (for example MMIC can be arranged in 4!2! # of ways).

1680+18+756=2454

 0 votes -- Ravi Singh ( 7303 points)

17.82 math top gateoverflow.in/17757

A computer net network consists of 6 computers.Each computer is directly connected to 0 or more computers.Based on
pegion hole principle which one of the following is true?

1) There is atleast 5 computer in the network that is directly connected to same no of other computers

2) There is atleast 4 computer in the network that is directly connected to same no of other computers

3) There is atleast 3 computer in the network that is directly connected to same no of other computers

4) There is atleast 2 computer in the network that is directly connected to same no of other computers


Selected Answer

Correct answer should be Option D.

It would be better to view this computer network as a simple undirected graph of 6 vertices, where degree of each vertex
is greater than or equal to zero.

In this graph we have to find out at least how many vertices must have same degree.

Degree of a vertex can be any one element from the set D = {0, 1, 2, 3, 4, 5} (since number of vertices are 6 in the
graph & the graph is simple so multiple edges & self loops are not allowed & thus each vertex can have a maximum of 5
degree).

Now if we are assigning a DISTINCT DEGREE to each of the 6 vertices then, we have to assign a distict element of D to
each of the nodes & 0, 1, 2, 3, 4, 5 will be assigned to six nodes.

But we know that sum of degree of all the vertices of a graph must be an even number.

& here it can be observed that 0 + 1 + 2 + 3 + 4 + 5 = 15 which is of course odd.

So it is clear that we can’t assign a different degree to each of the vertices.

Also it can be observed that this ODD DEGREE PROBLEM can be solved by replacing any of assigned odd degree {1, 3, 5}
with any of the even degrees {0, 2, 4} then this problem can be solved, & such a graph will be a valid graph.

For example choose degrees (0, 1, 2, 3, 4, 4) or (0, 1, 2, 2, 4, 5) or (0, 0, 2, 3, 4, 5) and so on, sum of degrees in all this
case will be even.

Thus we have tried our best to assign as much distinct degree as possible to the six vertices along with keeping the
graph valid, & found that at least 2 of the vertices MUST have a common degree.

So the correct option would be option D.

Moreover we can also guarantee that the repeating degree must even, it can’t be odd.

 0 votes -- Anurag Pandey ( 8183 points)

17.83 combination top gateoverflow.in/18523

How many binary sequences of length 10 are possible with exactly 4 zeros and no two zeros are consecutive?

Its given exactly 4 zero it means we have 6 1's which can be arranged in any order therefore 1! (since all 1 are identical)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1871 of 2244

1 1 1 1 1 1 since no two 0 should be consecutive we have total 7 space between each 1 we can place one 0

so select 7 places for 4 0's(all 0 are identical so we use the combination rather than permutation for arrangement) = 7C4

Therefore total binary string = 1! *7C4 =35

 0 votes -- Umang Raman ( 10379 points)

17.84 counting top gateoverflow.in/18524

How many 5 digit number are possible so that in each of these number every digit is greater than digit on its right?

i solved like this

first lets take number from 1 to 9 then we can select any 5 numbers in 9C5 ways but we can arrange them only in one
way.

now including 0 we can place it at only last position since at any other position it would not satisfy the condition.

so remaining place will be filled by all 9 digits that is 9C4

so total combination = 9C5 + 9C4 = 252.

 0 votes -- Umang Raman ( 10379 points)

17.85 combination top gateoverflow.in/18528

Suppose 10 persons are in canteen whoch offers coffee,tea,pepsi How many ways they can order their drinks as a group if
each persin wants one of the 3 drinks ?


Selected Answer

We have to divide 10 persons into 3 groups (corresponding to three drinks) such that a group may be empty. This is stars
and bars problem Theorem 2(https://en.wikipedia.org/wiki/Stars_and_bars_%28combinatorics%29), and solution is given
10+3 −1 12

by ( 3 −1 ) ( 2 ) = 66 ways.
=

 0 votes -- Happy Mittal ( 9253 points)

17.86 no of non negative solution top gateoverflow.in/18525

number of non negative integer solution for

1)x1+x2+x3+x4+x5<=10<br />
2)x1+x2+x3+x4+x5<10


Selected Answer

1. Any solution of the equation can be seen as partitioning 10 (or less) indistinguishible objects into 5 groups
(corresponding to x1,x2,x3,x4,x5), where each group may be empty (because solution is non-negative integer).

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1872 of 2244

This can be solved by stars and bars (Theorem 2 on


https://en.wikipedia.org/wiki/Stars_and_bars_%28combinatorics%29), in which number of stars is 10 (or less) here, and
number of bars is 5.

n +k−1

For a particular number of n stars and k bars, solution is given by ( k−1 ).


n +5 −1

Here n varies from 0 to 10, and k is 5 So total number of ways is ∑10


n =0 (
5 −1
).

2. This is same as 1st, except that n varies from 0 to 9.

 0 votes -- Happy Mittal ( 9253 points)

17.87 How many possible outcomes are there when 5 similar dices are rolled
? top gateoverflow.in/28201

In this question If I consider first total no of outcomes as 6^5 , then I divided it be 6C5 *5! since there are 5 similar dices so
the outcome (1 2 3 4 5 ) will be similar to (5 4 3 2 1) .

Now what's wrong with this approach ?


Selected Answer

6C 6C 5C 6C 4C 6C 5C 6C 5C 6C 5C
5 1. 3 2. 1 1. 2 1. 1 1. 1
     
5 different outcomes + only 1 outcome appearing twice + 2 outcomes appearing twice + one outcome appearing thrice + one outcome appearing thrice and 1 outcome appearing twice + one item appearing 4 tim

 1 votes -- Arjun Suresh ( 124125 points)

for every dice we have 6 possibility which are independent of any other dice, Hence total possible outcomes if 5 similar dices are rolled, given
that each outcome for a dice is equally likely is given by : 65

 1 votes -- Amar Vashishth ( 17865 points)

17.88 Q:Suppose that a computer science laboratory has 15 workstations


and 10 servers. top gateoverflow.in/4461

Suppose that a computer science laboratory has 15 workstations and 10 servers. A cable can be used to directly connect a
workstation to a server. For each server, only one direct connection to that server can be active at any time. We want to
guarantee that at any time any set of 10 or fewer workstations can simultaneously access different servers via direct
connections. Although we could do this by connecting every workstation directly to every server (using 150 connections),
what is the minimum number of direct connections needed to achieve this goal? Please explain the answer with explanation.

combinatory


Selected Answer

What we have to guarantee is at any point up to 10 workstations must be directly connected to servers. And we have 15
workstations in total.

We connect 10 workstations to 10 servers using 10 direct connections.


But 10 workstation at any time can come from any of the 15, and direct connections are available only from a select 10.
So, we must now guarantee that whichever 5 workstations are coming extra (we have 10 workstations connected and 5
are the left out ones) they must have direct connections to all the 10 servers- as we don't know which out of those 10 is

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1873 of 2244

free we must guarantee a connection to each of them. So, this means for the remaining 5 workstations we need 5 ⨯ 10 =
50 direct connections. So, minimum, 10 + 50 = 60 direct connections are required.

So, we directly connect 5 workstations to all the servers

 4 votes -- Arjun Suresh ( 124125 points)

17.89 permutation and combination top gateoverflow.in/7737

combinatory


Selected Answer

Solution: B

This problem is a special case of permutiation called Dearrangement. where the permutation dose have any element occur
in their original place.

so D(n)=265 ,
dearrangement(n) =

therefore , D(6) =

ref@ http://math.stackexchange.com/questions/83380/i-have-a-problem-understanding-the-proof-of-rencontres-
numbers-derangements/83472#83472

 3 votes -- Gowthaman Arumugam ( 1079 points)

17.90 counting function top gateoverflow.in/33001

How many function are there from the set{1,2,3,........n} where n is positive integer ,to the set {0,1}.

a) that assigns 0 to both 1 and n?

b)that assign 1 to exactly one of positive integer less than n?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1874 of 2244

a) 0 is mapped to both 1 & n. Hence for remaining (n-2) elements, we have two choices {0,1} for mapping of each
element.

Hence no of function possible = 2*2*2*..........(n-2)terms = 2 (n-2)

b) Here in this case, '1' is assigned to exactly one integer less than 'n' i.e any one of '1' to 'n-1'. So for remaining (n-1)
element ,we have only one choice of mapping all of them to '0'

Hence no of functions = n-1C1*(1*1*1 ...........n-1 times) = (n-1)

 0 votes -- Shashank Kumar ( 2029 points)

17.91 How many seven digits number are there such that Digits are distinct
integers taken from {1, 2, ..., 9} and Digits 5 and 6 do not appear together
(consecutively) top gateoverflow.in/10011

1. How many seven digits number are there such that


1. Digits are distinct integers taken from {1, 2, ..., 9} and
2. Digits 5 and 6 do not appear together (consecutively)


Selected Answer

Case 1: 5 and 6 appear together. Here, it can be 56 or 65. So, 2 ways and remaining we have 5 digits to chose from 7 and
6! ways (5 digits plus 56 or 65) to arrange them. This gives 2! * 7C5 * 6! = 42 * 720

Total possible numbers = 9 P 7 = 7! * 36

So, our required answer = 7! * 36 - 42 * 720 = 151,200

 3 votes -- Arjun Suresh ( 124125 points)

17.91 How many ternary strings of length 4 have exactly one 1? top gateoverflow.in/7500


Selected Answer

4 * 23 = 32

Of length 4, one we take for 1. Remaining 3 characters can be filled with 2 symbols in 2 3 = 8 ways. Now, the one can be
placed in 4 ways between the 3 characters giving 4 * 8 = 32 strings.

 5 votes -- Arjun Suresh ( 124125 points)

17.91 The maximum number of distinct subwords of the word


"AXIOMATIZABLE" is: a)183 b) 111 c)92 d)88 top gateoverflow.in/5302

combinatory


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1875 of 2244

Subwords means letters must be consecutive as in the word. Since, the given word has 13 letters we can have

13 subwords of 1 letter

12 subwords of 2 letters

11 subwords of 3 letters

....
1 subword of 13 letters

So, total number of subwords = 13 + 12 + ... + 1 = 13 * 7 = 91

No two consecutive letters are repeating in the given word. But there are 3 A's, and 2 I's. So, 3 subwords of length 1 are
counted extra. So, total number of distinct subwords = 91 - 3 = 88.

 7 votes -- gatecse ( 9515 points)

17.92 Suppose that when an enzyme that breaks RNA chains after each G
link is applied to a 12-link chain top gateoverflow.in/4583

Suppose that when an enzyme that breaks RNA chains after each G link is applied to a 12-link chain, the fragments obtained
are AC, UG, and ACG and when an enzyme that breaks RNA chains after each C or U link is applied, the fragments obtained
are U, GAC, and GAC. Can you determine the entire RNA chain from these two sets of fragments? If so, what is this RNA
chain?

combinatory

17.93 Commitee. top gateoverflow.in/33401

Find number of ways of selecting a commitee of 10 members out of 6 men and 7 women of which atleast 4 women are
included.

a)231 b)25200 c)325 d)286

combinatory


Selected Answer

Ans will be (D)

No of ways we can select the committee 7 C4 * 6 C 6 + 7 C5 *6 C5 + 7C6 * 6 C4 + 7 C7 * 6C3

=35+126+105+20 =286

 1 votes -- srestha ( 11585 points)

17.94 how many distinct question paper can be set with 10 questions which
have four choices and there is only one correct answer per questions. gateoverflow.in/11014

top

how many distinct question paper can be set with 10 questions which have four choices and there is only one correct answer
per questions.

10!*4^10

 2 votes -- Koushikgate ( 31 points)

17.95 Combinatory top gateoverflow.in/30163

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1876 of 2244

. A, B are two 8-bit numbers such that A+B < 28 . The number of possible combinations of A and B

17.96 log question top gateoverflow.in/13142

if (x lg x)=4608 , then how to calculate value of x ?

Base is 2


Selected Answer

Just try substituting, 9. 29 = 4608, x = 512

 2 votes -- Arjun Suresh ( 124125 points)

17.97 permutation top gateoverflow.in/28281

How many ways are there to seat six people around circular table where two seatings are considered same when everyone
has same two neighbors without regard to whether they are left or right neighbors?

Answer is same as number of even permutation of nelements. I.e. (n-1)!/2.

 0 votes -- Digvijay Pandey ( 26245 points)

17.98 permutation top gateoverflow.in/28800

An entrepreneur needs to assign 5 different tasks to three of his employees. If every employee is assigned atleast one task,
how many ways can the entrepreneur assign those tasks to his employees?

jobs are 5 and persons are 3. so first i can choose 3 jobs out of 5 in 5c3 ways because it is given that atleast one should
be assigned . and now these jobs can also be arranged in 3! ways . and after that 2 jobs are remaining and 1 can be
choose in 2c1 ways and can be assigned in 3 ways . and similarly last job can be assigned in 3 ways . so i think answer
should be

5c3*3! *2c1*3*3= 1080 ways.

 0 votes -- Ravi Singh ( 7303 points)

17.99 Permutation and Combination top gateoverflow.in/29043

A mint prepares metallic calendars specifying months , dates and days in the form of monthly sheets (one plate for each
month ) . how many type of feburary calendars should be prepare to serve all the possibilities in the future year ?

combinatory


Selected Answer

Yes, 14 will be the right answer.

Any February month will have 2 choices.

1) First day of the Feb will have 7 choices from the set {Mon, Tue, Wed, Thu, Fri, Sat, Sun}.

2) Total number of days in the month will have 2 choices from the set {28, 29}.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1877 of 2244

so total 7x2 = 14 choices for any February month.

We can enumerate all the 14 possibilities using an ordered pair (x, y) where x represents the first day of that particular
February month and y represents total number days in that particular February month.

For Example:

(Mon, 28) represents a Feb month whose first day (i.e. 1 Feb) is Monday, & the month has total 28 days.

Similarly (Tue, 28), (Wed, 28).......(Sat, 29), (Sun, 29).

 3 votes -- Anurag Pandey ( 8183 points)

The month of February has either 28 days (non-Leap Year) or 29 days(Leap Year).Thus there are 2 possibility for the
number of days in February. Also the first day of the month can be any of the 7 days In a week.

So Total number of February colander = 2 * 7 =14

 1 votes -- Leen Sharma ( 2935 points)

17.100 Combination top gateoverflow.in/30160

For a game in which 2 partners oppose 2 other partners, six men are available. If every possible pair must play against every
other pair, the number of games to be played is

9a) 36 (b) 45 (c) 42 (d) 90

45 is correct.

Steps :

1) Choose 4 players who will play in Game = 6C4 = 15 ways

2) Now, suppose we have 4 players {A,B,C,D} & we have to form two teams of 2.

means partition of 4 in 2,2

=> (AB - CD) , (AC - BD) , (AD - BC) = 3 ways

Total 15 * 3 = 45 ways (Ans)

 3 votes -- Himanshu Agarwal ( 8861 points)

17.100 How many integers are there between 1 and 10^6 such that sum of
digits is 12 ? top gateoverflow.in/29381


Selected Answer

Finding 12 as sum of digits between the numbers 1 and 1,000,000 is like finding coefficient of x^12 between 1 and 999,999 (as the digits of course of
1,000,000 don't sum up to 12).

Now all the numbers a1+a2+a3+a4+a5+a6 (number of digits in 999,999) should be between 0 and 9.

So, this is equivalent to finding coefficient of x 12 in (x0 + x 1 + x 2 +...... +x9)6

this simplifies to x 12 in [(1-x 10 )/(1-x)]6 sum of GP series

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1878 of 2244

= coefficient of x 12 in (1-x 10 )6 . (1-x) -6

=coefficient of x 12 in [(1-x)-6 - 6C1 x 10 (1-x)-6 + ...............] Binomial expansion

=12+6-1C 6-1 - 6. [coefficient of x 2 in (1-x) -6]

=17C5 - 6. 7C5

=6188 - 126

=6062

 2 votes -- Ashish Gupta ( 631 points)

17.100 How many ways 10 persons can be divided into 5 teams of 2 each top
gateoverflow.in/33438


Selected Answer

Notice that teams here do not have separate identities. They are just teams (so obviously you cannot distinguish among
two teams). So, if you include Boy1, Boy2 in one team then do not include them in any other team because they both are
already counted as a team (doesn't matter which team).

So whatever permuatations you make, if the sequence aleady has X,X,boy1,boy2,X,X,X,X,X,X then no need to include
boy1,boy2,X,X,X,X,X,X,X,X again.

10!/(2! 2! 2! 2! 2! * 5!) = 945 ways

 2 votes -- Tushar Shinde ( 1523 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1879 of 2244

18 Graph Theory top


18.1 Ace Test Series: Graph Theory: True/False top gateoverflow.in/35694

How to PROVE S2 is correct??

Consider the statements

S1 ) In any simple graph with more than one vertex, there must exist at-least 2 vetices of the same degree

S2 ) A graph with 13 vertices, 31 edges, 3 vertices of degree 5 and 7 vertices of degree 4 does not exist.

Q) Which of the following is true?

A). S1 and S2 are true

B). S1 is true and S2 is false

C). S1 is false and S2 is true

D). Both S1 and S2 are true

graph-theory engineering-mathematics ace-test-series

s1 is true

2 vertices have same degree(use pigeonhole princliple)

for s2 apply handshaking theorem

let x be degree of no of vertices

15+28+3x=62

x=19/3

this is not poosible

x being degree need to be whole no

so d is ans

x=

 2 votes -- Pooja ( 22773 points)

18.2 Ace Test Series: Minimum edges in graph so that it is not connected top
gateoverflow.in/37527

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1880 of 2244

I think the explanation is for edges for which graph is always connected.

graph-theory ace-test-series


Selected Answer

Let a SIMPLE graph with n nodes .


max no of edges possible are nC2.

if we want to disconnect graph then do one thing just partition original graph in two portion with 1 and n-1 nodes
respectively.
now find number of edges in each component.

with 1 node : no edge


with n-1 nodes : n-1C2 edges.

Total edges are n-1C2..

 3 votes -- Digvijay Pandey ( 26245 points)

18.3 Bfs: True / False (Graphs) top gateoverflow.in/38607

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1881 of 2244

(A). When a recurrence relation has a cyclic dependency, it is impossible to use that recurrence relation (unmodified) in a
correct dynamic program.

(B). Given a connected graph G(V, E) if a vertex v ϵ V is visited during level K of a breadth first search from source vertex s
\epsilon V, then every path from s to v has length at most k

(C). Every sorting Network with n inputs has depth \omega(n)

(D). Both (A) & (B)

Which of the following statement is TRUE?

Argument: I dont have much idea about A, but it seems to be true. For B, with BFS tree we get the shortest path possible
from source vertex. So, every other possible path should have the length of atleast 'k'. Given wording is 'atmost'. So, B
should be wrong.

Given answer is D.

ace-test-series asymptotic-notations bfs graph-theory

18.4 Graph Coloring: graph coloring top gateoverflow.in/11992

What is the minimum number of colors needed to color a graph with five vertices. The graph contain a cycle also

graph-theory graph-coloring


Selected Answer

If you say minimum then it should be 2 ( a cyclic graph with even vertices required 2 colours and for odd 3 ) and we can
form a cyclic graph with 4 vertices and 5th vertex will connect any one of that cyclic vertices with one edge (of course :D )
. peace

 4 votes -- Pranay Datta ( 6113 points)

If Graph contains cycle,either its odd cycle or even cycle

case 1:odd cycle :3

case 2:even cycle :2

we should take best solution in worst case so it will be 3 colors.

 1 votes -- Anurag Semwal ( 4775 points)

if there is cycle of 4 verticces then 2 colour required if there is cycle of 5 vertices then 3 colors are required

 1 votes -- akash ( 735 points)

18.5 Graph Isomorphism: Given no of vertex & edges how to find no of Non

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1882 of 2244

Isomorphic graphs possible ? top gateoverflow.in/28955

Assume that ‘e’ is the number of edges and n is the number of vertices. The number of non-isomorphic graphs possible with
n-vertices such that graph is 3-regular graph and e = 2n – 3 are ______.

------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------

Here I got as No of vertexes = 6

No of Edges = 9

From here on, Given no of vertex & edges how to find no of Non Isomorphic graphs possible ? , this is real question ! Is there
any algorithm for this ?

From Made Easy FLT 6-Practice Test 14

graph-theory graph-isomorphism

since it is regular graph so max no. of edge

3n= 2e

as we know e = 2n – 3

equat both

3n/2 = 2n -4

n= 6 // no. of vertex

so no. of edges= 2n-3= 2*6-3= 12-3= 9

so using 6 vertex and 9 edges with every vertex has tree degree only two graph possible. one is k3,3

 1 votes -- Anirudh Pratap Singh ( 4091 points)

18.6 Graph Isomorphism: Whether the given pair of graphs is isomorphic?Pls


provide a rigorous argument. top gateoverflow.in/12483

graph-isomorphism

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1883 of 2244

Two graph r isomorphic iff they have :

1. Same no of edges

2. Same no of vertices

3. Same no of particular length (i.e. 3 length , 4 length,.....) cycle..

 1 votes -- Digvijay Pandey ( 26245 points)

18.7 Graph Matching: VIRTUALGATE II Q.14 top gateoverflow.in/37974

Find the matching number for the given graph-

virtualgate graph-matching graph-theory

Matching it means that no 2 edges are adjacent simply a vertex with degree 1

if we have a vertex with degree 0 we say not matched

In the above graph if we start with G we have 2 edges for G In matching we consider 1 edge since if both are considered
we get degree of G as 2 so if we consider G-A edge then node 2 is alone and has degree 0 it makes graph to be not
matched so we consider G-2 edge , A-0 edge T has edges with 0 and 1 since A-0 edge is present if we consider 0 then
degree of 0 is 2 so we don't consider

we have T-1 edge then we are left with edge E-6

Totally we get (G-2),(A-0),(T-1),(E-6) so matching number is 4

 1 votes -- shivanisrivarshini ( 2067 points)

18.8 Graph Matching: Finding matching number of graph top gateoverflow.in/36597

Given explanation:

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1884 of 2244

In the above explanation, it is written that matching number is 4 but I am getting matching number as 3 for this
graph(choosing edges 1-2, 3-4 and 6-7). Please check where I am going wrong

graph-theory graph-matching

In Matching graph no 2 edges are adjacent it means the degree of vertex is 1

So we find such vertices and edges

Let us start with 2 then we get (2-1),(3-8),(4-7),(5-6) these edges are matching so the matched number is 4

Even these edges (2-3),(1-8),(4-5),(7-6) are matching so the matched number is 4

These edges (2-5),(3-4),(1-6),(8-7) are matching so the matched number is 4

By choosing these edges we could have vertices with 1 degree

 0 votes -- shivanisrivarshini ( 2067 points)

18.9 Graph Matching: no of perfect matching in complete graph top gateoverflow.in/4788

Is there a way to find no of perfect matchings in a complete graph K n where n could be either even or odd..?

graph-matching


Selected Answer

if n is odd then perfect matching 0. because in perfect matching degree of each vertex must be 1, which is not possible if
n is odd.

and if n is even then num of perfect matching in K2n=( 2n! ) / ( 2^n * n! )

 3 votes -- jayendra ( 5797 points)

For Kn

if n is odd , then there is no perfect matching.

n is even then you can count it like ->

(n-1) (n-3) (n-5)...1 (This will end in 1 as n is even).

 1 votes -- Akash ( 26315 points)

18.10 Graph Planarity: condition for planar graph?? top gateoverflow.in/27428

what is the sufficient condition so that we say given graph is planar or not???

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1885 of 2244

graph-planarity

no. of (vertices-edges+faces) of a connected planar graph =2

 0 votes -- Vikranth Inti ( 239 points)

18.11 Graph Planarity: planar graphs top gateoverflow.in/5181

Is there any subgraph homoemorphic to K5 present in G1 for the following question?

Which one of the following graphs is NOT planar?


(A) G1 (B) G2 (C) G3 (D) G4

In this question planar drawings( no 2 edges intersect) for G2, G3 and G4 exists, thats why answer should be G1

But I couldn't find any subgraph homoemorphic to K5 in G1 as a graph is non planar iff it contains a subgraph homoemorphic
to K5 or K 3,3...

graph-theory graph-planarity

The graph G1 is isomorphic to K3,3. And K3,3 is not a planar graph.

 0 votes -- Swatish Satheesan ( 39 points)

18.12 Haming Distance: Haming Distance and Chromatic Number top gateoverflow.in/38185

Consider the undirected graph G defined as follows. The vertices are bit string of length 5. We have an edge between vertex
“a” and vertex “b” iff “a” and “b” differ only in one bit possible (i.e., hamming distance1). What is the ratio of chromatic
number of G to the diameter of G?

engineering-mathematics algorithms haming-distance chromatic-number


Selected Answer

apply the given condition of connectivity to 2 bits..00==>01==>11==>10==>00

for 3 bits..image in comment box

ACTUALLY IT IS A N CUBE...

vertex of n cube=n;

degree of n cube=n;

edges of n cube=n*2^(n-1)
chromatic number=2(ALWAYS)
hence chromatic number of the graph=2

now diameter of graph=number of bits =5

thus ratio =2/5

 4 votes -- sourav anand ( 1585 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1886 of 2244

18.13 Recurrence: recurrence relation top gateoverflow.in/29121

the solution to the recurrence relation T(n)= T(n-1) +n, T(0)=2 is..

what is approach to solve it??

recurrence


Selected Answer

Use substitution method to solve such type of ques

T(n)=T(n-1)+n

T(n-1)=T(n-2)+n-1

Substituting value of T(n-1) we get

T(n)=T(n-2)+n-1+n

Now substituting value of T(n-2) and so on we get

T(n)=T(n-k)+(n-k+1)+.........n-k+n

Put n=k

T(n)=T(0)+1+2..........+n

T(n)=2+n(n+1)/2

So T(n)=O(n^2)

 1 votes -- Pooja ( 22773 points)

18.14 Recurrence: recurrence relation top gateoverflow.in/29134

for the recurrence relation a n=6an-1-9an-2 + F n , what will be the particular solution

if case 1; F n = 3 n 5n+1

case 2; F n = 2 n 5n+1

recurrence

18.15 Which of the following is true regarding minimum cut edges for a pair
of vertices in a graph? top gateoverflow.in/30713

Let G be an undirected graph. For a pair (x,y) of distinct vertices of G, let mincut(x,y) be the least number of edges that
should be deleted from G so that the resulting graph has no x-y path. Let a,b,c be three vertices in G such that mincut(a,b)
<= mincut(b,c) <= mincut(c,a). Consider the following possibilities.

{I) mincut(a,b) < mincut(b,c) < mincut(c,a)

(iI) mincut(a,b) = mincut(b,c) < mincut(c,a)

(iiI) mincut(a,b) < mincut(b,c) = mincut(c,a)

(Iv) mincut(a,b) = mincut(b,c) = mincut(c,a)

Which of the following is true ?

(a) All of I.iI.iiI.iv are possible.

(b) I, iI, iiI are possible but not iv

(c) I and iv are possible but neither iI nor iiI

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1887 of 2244

(d) iI and iv are possible but neither I nor iiI

(e) Iii and iv are possible but neither i nor iI

tifr2016

The answer is d. Consider a path a->c->b , then mincut(a,b) >= min(mincut(b,c),mincut(a,c)) . So if considering this
condition to be always true , option i and iii violate the conditions.

 0 votes -- Vikram Bhat ( 587 points)

18.16 graph theory top gateoverflow.in/31658

graph-theory


Selected Answer

Don't panic bro . We are here to help .

this is just an example of bipirated graph. . one set contains printer and one contain 8 computers. no edge can be
between the same set. as it is said to guarentee atleast 4 access different printers. so take one computer connect with all
printer . 4 cables. now take one more , and connect with 4 . similarly connect 4 computer with all the 4 printers. 4*4 = 16
cables are consumed and we have satisfied the condition. now just connect remaining 4 computer with the minimum no of
connection i.e 1 .which will lead to 4 . so 16+4 =20 .

 6 votes -- Ravi Singh ( 7303 points)

18.17 Graph Coloring top gateoverflow.in/30708

An undirected graph G=(V,E) is said to be k-colourable if there exists a mapping

c: V → { 1, 2, ...,k) such that for every edge {u,v) ∈ E we have c(u) ≠ c(v).

Which of the following statement is FALSE

1. G is |V| colorable.

2. G is 2-colorable iff there are no odd cycles in G.

3. G is (∆ + 1)- colorable where ∆ is the maximum degree in G.

4. There is a polynomial time algorithm to check if G is 2-colorable.

5. If G has no triangle then it is 3-colorable.

graph-theory

1 - definitely u can colour every vertex with unique colour.

2- If graph is 2 colourable then it is bipirated graph . and a graph is bipirated if and only if every cycle is of even length in
it.

3- the condition is not give same colour to adjacent vertexes. so if it has a degree k then u need k+1 colour. one for itself
and other need k. so try this u can easily say that this is the upper limit.

4- yes. check for bipirated graph. or every cycle is of even lenght or not. from point 2

5-if a graph has a cycle graph in itself . suppose it has cn ( cycle graph with 3 vertices. i.e a triangle ) then it requires

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1888 of 2244

atleast 3 colours, we can't say it always will

 0 votes -- Ravi Singh ( 7303 points)

18.18 How to find no of paths of length 2 in the below graph ? top gateoverflow.in/28489

Determine the number of paths of length 2 in the following graph

I couldn't get this logic .

graph-theory

There are only 3 possible paths of length 2, which passes through vertex v1. they are

v4 v1 v2

v3 v1 v2

v4 v1 v3

This can be done by selecting two of the adjacent vertices of v1 , hence C(3,2)

Similarly, it follows for other vertices.

 2 votes -- Epsilon ( 31 points)

this can be solved using adjacency matrix . and i also can't get the logic. still i have an hard way.

make the adjacency lets call it a . now . A2 means it is stating all paths of from length 2 from any vertex i to vertex j .
where i is the any row and j is any column No need to solve full just solve half. as the other half will be stating the same
thing. and don't consider the diagonal. now count . it will give 19..

 1 votes -- Ravi Singh ( 7303 points)

18.19 how to draw the graph for this problem?? top gateoverflow.in/27507

how many numbers of edges if the degree of sequence is 5,2,2,2,2,1.... how can we draw the graph for this problem???

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1889 of 2244

there is any formula for such type of problem???

sum of degree = 14 = 2* edges

no of edge = 7

 1 votes -- Sayantan Ganguly ( 5061 points)

18.19 how to cheak given grpah is complet bipertee graph top gateoverflow.in/27505

18.20 ?? top gateoverflow.in/27527

How many nonisomorphic simple graphs are there with n


vertices,

18.21 how to find path of length 3 in below graph including V5 ? top gateoverflow.in/31790

what is the issue in the given approach ?

Since the path should pass through v5 I am assuming we only include the path in which v5 can be intermediate vertex.
And path visited in reverse order is not counted as distinct.

Let us consider that vertex v5 is in position 2. Actually it doesn't matter whether vertex v2 is in position 2 or 3 because v2 comes at position 3 in reverse order.

_ v5 _ _

For First vertex we can have four choices. ie v1,v2,v3 and v4

Let us calculate all the possibilities with v1 as first vertex.

We have v1 v5 _ _

For third vertex we can have 3 choices. In this case we can have v2, v3 or v4 as third vertex

When we have v2 as third vertex we have only one choice that is v3.
When we have v3 as third vertex we have 2 choices that is v2 or v4.
When we have v4 as third vertex we have only one choice that is v3

So we have four choices when we start with vertex v1.

For all the four choices for the first vertex we can have total of 16 choices.

This gives total paths possible as 16.

But answer given is 4C3 .

graph-theory

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1890 of 2244

This is a combinatory qs basically. There are 5 vertices ,in which V5 is fixed,cause it must remain in the path. Now for
path of length 3,we need 4 vertices. V5 is already fixed,so we are left with 3 more vertices,which can be chosen from out
of 4 vertices.so the no of paths are 4C3 = 4.

 0 votes -- Sayantan Ganguly ( 5061 points)

18.22 Non planarity top gateoverflow.in/28925

Kuratowski's second graph is not planar then why it dont contradict for following inequality for checking planarity :

e<=3n-6

=>(e=9)<=3*(n=6)-6

=>9<=12 , which is true

K3,3 has 6 vertices and 9 edges, and it is true that 9 ≤ (3 × 6) - 6 = 12. So we cannot use this Corollary to prove that
K3,3 is non-planar. We have another Corollary

Let G be a connected planar simple graph with n vertices and e edges, and no triangles. Then e ≤ 2n - 4.

For graph G with f faces, it follows from the handshaking lemma for planar graph that 2e ≥ 3r because the degree of each
2

face of a simple graph is at least 3), so r ≤ 3 * e

For graph G with f faces, it follows from the handshaking lemma for planar graphs that 2e ≥ 4r (because the degree of
1

each face of a simple graph without triangles is at least 4), so that r ≤ 2 e.

Proof : Since n - e + r = 2 (Euler's formula)


=> e -n + 2 = r
e - n + 2 ≤ 1/2e
Hence e ≤ 2n - 4

 3 votes -- Umang Raman ( 10379 points)

18.23 maximum no of vertices explain plz top gateoverflow.in/29042

Q1. Assume that G is a simple graph of 20 edges, 6 vertices of degree 4 and other nodes have degrees more than 5, then
the maximum no of vertices of G is______

Q2. all thread must wait whenever any critical section is occupied----how this is false?


Selected Answer

1) 6*4 +xy = 2* 20 [where y>5, y is degree of vertices and x = no of vertices]

=>xy=40-24

=>x=16/8 = 2 [where y=8]

=>x=2

So, Max. no of vertices 2+6=8

2)All threads maynot be wait when critical section is occupied

Say, for Reader-Writer, More than one reader is allowed in critical section at the same time.

So, no reader have to wait for other reader

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1891 of 2244

 2 votes -- srestha ( 11585 points)

18.24 check the question top gateoverflow.in/34066

k5 : the regular graph of degree 4

L(k5) : the line graph of graph k5

1. the line graph L(k5) is a regular graph of degree_______ and edges ________

graph-theory

You can have the adjacency matrix of the line graph of the K5 regular graph by considering the edges as the columns and
the rows. You will have to fill the matrix from the graph then, with an entry in a cell a ij if edge e i and e j are adjacent to
each other in the K5 graph. You will observe that every row (or column) will have exactly six entry, so we can say that the
degree of the graph is 6. Also, since this is an undirected graph, so every vertex ( or the edge pair ) will be counted twice,
one time for filling up the entry for edge ei and other time for filling up the entry for e j. Now, since every row (or column)
have six entry and there are ten rows (or columns) and every actual vertex (of the K5 regular graph) is counted twice, we
have : (6 * 10) / 2 = 30 edges.

 1 votes -- Utk ( 1385 points)

18.25 Number of ISOMORPHISMs of a cycle graph? top gateoverflow.in/37183

How many different isomorphisms are there from one cycle on n-vertices to another cycle on n-vertices.


Selected Answer

Must be 2n.

We can map first vertex of first graph with any of the n vertices of the second graph, so there are n ways. But after
choosing that vertex, we may traverse either in clockwise or counter-clockwise direction. So, we have 2 ways to choose
the direction. After choosing the vertex and direction, the remaining vertices of the cycle will be mapped automatically.

Hence, we have 2n number of ways.

 2 votes -- Gaurav Sharma ( 1383 points)

18.25 minimum number of vertices of planner graph of edges e top gateoverflow.in/37140

From Kurtowski's test

e<=3*n-6 (if graph is connected planar simple graph)

=> n>=(e+6)/3

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1892 of 2244

 1 votes -- Abhishekcs10 ( 1001 points)

18.26 subgraphs top gateoverflow.in/37558

number of subgraph for K3 is

graph-theory

18

Subgraph of a graph is a graph whose vertex set is a subset of vertex set of the graph and edge set is a subset of the
edge set of the graph

1)no vertex,no edge : 1

2)one vertex : 3C1=3

3)two vertices(edge present/not present) : 3C2*2

4)three vertices , no edge : 1

5)3 vertices 1 edge : 3C1=3

6)3 vertices 2 edges : 3C2=3

7)3 vertices 3 edges : 1

Adding these up : 18

 1 votes -- Sourasekhar Banerjee ( 179 points)

18.27 Made easy top gateoverflow.in/37914

graph-theory

suppose this is the graph

now if we remove edges AE,BE,BF and CE

the graph becomes this-->

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1893 of 2244

So now ,to make it disconnected you only need to remove only two more edges..

so by removing any two edges the graph becomes disconnected.

Hence the answer is 6.

 0 votes -- Saumik Sarkar ( 157 points)

18.28 The number of colors needed to edge color a simple graph with
maximum degree Δ is? top gateoverflow.in/38675

The number of colors needed to edge color a simple graph with maximum degree Δ is?

Is this there in portion?


Selected Answer

edge colouring can be anything between maximum degree or maximum degree -1 depending on the instance of the
graph/.

 1 votes -- Ravi Singh ( 7303 points)

Hi I would like to explain this :)

This question is related to Graph Colouring . In Graph colouring , No adjacent nodes ( 2 nodes connected by a edges )
must not have some colour . So here if they say when a degree of a node ( say A ) is n , it mean A is attached to n nodes
by an edges .

Say if a degree of a node B is 3 then it is adjacent to node D E F ( D E f may or may not be adjacent . But that is not our
concern for now ) by an edge connecting them . So we know that no 2 adjacent nodes will have single colour .

so if i give node b =red colour Node D = blue colur node E = balck Node F = purple So if you see for since node b has
degree 3 . To do proper graph colouring technique , we need have 4 colours so that no adjacent nodes have same colour .

So by stating above example I can conclude that in general if a node has a degree n , then it adajcent to n nodes . And so
for a proper graph colouring you need to colour with n+1 colours .

I hope it help you :)

 1 votes -- Dexter ( 1933 points)

https://en.wikipedia.org/wiki/Vizing%27s_theorem

 1 votes -- tdk93 ( 151 points)

18.29 graph top gateoverflow.in/38362

Assume G is connected planar graph that has 14 vertices and 20 regions . All interior regions are bounded by a cycle of
length 3(i.e. 3 edges). The no of edges bounded the interior region is ?

TOTAL NO OF INTERIOR REGION=19

TOTAL NO OF OUTER REGION=1

IN THE CONNECTED PLANAR GRAPH TOTAL NO OF REGION IS GIVEN BY:

R=E-V+2

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1894 of 2244

Total no of edges:

E=20+14-2=32

We know that sum of all the edges in the graph=2e

Also ,Inner region*Degree of each vertex+Outer region*Degree of each vertex=2e

Thus, 19*3+1*x=64,x=7

Exactly 7 edges in outer region. Thus Inner region is bounded by 7 edges.

 1 votes -- Ankesh Gautam ( 665 points)

18.30 Counting number of articulation points top gateoverflow.in/36027

Given answer is 2, I think it should be 3: F,A, and G are articulation points. Please check

graph-theory engineering-mathematics


Selected Answer

F, A and G are articulation points.

 3 votes -- Monanshi Jain ( 5827 points)

18.31 Question on graphs top gateoverflow.in/35752

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1895 of 2244

Given explanation:

I couldn't understand why S1 is false. Please explain

engineering-mathematics graph-theory


Selected Answer

both are true

1st one :for any graph with n vertices maxdegree of vertex is n-1

so accto pigeonhole principle atleast two vertices have same degree

2nd one:

there are even no of odd vertices in any grpah

here 3 vertices of odd degree given not possible

 2 votes -- Pooja ( 22773 points)

18.32 Sum of all intercepts of inverse of a function? top gateoverflow.in/33815

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1896 of 2244

engineering-mathematics aptitude

18.33 How many strongly connected component are there in the above graph
top gateoverflow.in/32839

Consider the following graph (G):

How many strongly connected components are there in the above graph?

graph-theory


Selected Answer

Answer is 5. A directed graph is strongly connected if there is a path between all pair of vertices.

A-B-F-C

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1897 of 2244

H so totally 5

 6 votes -- priyavssut ( 411 points)

18.33 What is Maximal Independent Set (MIS) ? How to calulate size of it ? top
gateoverflow.in/33938


Selected Answer

https://www.youtube.com/watch?v=03PUwWef2Dg

 1 votes -- Akhil Nadh PC ( 1967 points)

18.34 Question on graph theory top gateoverflow.in/34021

Please explain how did they get that equation in E and V.

graph-theory engineering-mathematics


Selected Answer

connected planar graph with no cycle of length less than 4 means that no circuit of length 3 .so we have theorem in this
case:e<=2n-4
where n=15 given put and get the answer.
e<=30-4

e<=26
so 26 edges needed in connected planar graph(CPG)

in all other cases we have to take e<=3n-6

 1 votes -- kunal chalotra ( 3567 points)

18.35 Find maximum edges in Graph top gateoverflow.in/34289

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1898 of 2244

graph-theory


Selected Answer

maximum no. Of edges 26

In a connected planner graph with v vertices e edges r regions or faces and min. Degree of region =k (no c ycle of length
less than 4 means no region can have degree less than 4)

The following property should satisfy

1 v-e+r=2

2 k.r≤2e

3 e ≤ k(v-2)/(k-2)

Here k=4 v=15

maximum no. Of edges

e ≤ 2v-4

Max no. Of edges= 2*15-4= 26

 3 votes -- Khushboo Tak ( 1961 points)

e<=2v --4

so e<=2*15-4

e<=26

 1 votes -- Pooja ( 22773 points)

18.36 any one eplain me..... top gateoverflow.in/27391

is there is any difference between isolated vertex and null graph???

both are same or not???

18.37 graph theory top gateoverflow.in/32520

How many non isomorphic directed simple graph are there with n vertices?

graph-theory

Ans : 3n(n-1)/2 possible if(Graph is unlabelled simple directed graph)

4 n(n-1)/2 possible if(Graph is labelled simple directed graph)

Case I: If Graph is unlabelled simple directed:

Consider n vertices V1,V2......Vn.Assume edge between any two vertices is say edge slot.So for each edge slot between
two vertices say V1 and V2,we have following 3 choices of putting edge

1)V1->V2 or V2-> V1

2)V1->V2 & V2->V1 since graph is directed,we can put two edges between two vertices.

3)No edge.

We know that total no. of such edge slots is nC2 = n(n-1)/2

hence total no of simple directed graphs possible are :

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1899 of 2244

3 X 3 X 3 X............n(n-1)/2 times i.e 3 n(n-1)/2

Case I: If Graph is labelled simple directed:

So for each edge slot between two vertices say V1 and V2,we have following 4 choices of putting edge

1)V1->V2

2)V2-> V1 since vertices are labelled,V1->V2 & V2->V1would give different results.

3)V1->V2 & V2->V1 since graph is directed,we can put two edges between two vertices.

4)No edge.

We know that total no. of such edge slots is nC2 = n(n-1)/2

hence total no of simple directed graphs possible are :

4 X 4 X 4 X............n(n-1)/2 times i.e 4 n(n-1)/2

Please verify it as i have considered only total graphs but i am not able to filter-out isomorphic graphs.

 2 votes -- Shashank Kumar ( 2029 points)

18.38 no of connected component top gateoverflow.in/25233

if G and G* are isomorphic graphs , then no of connected components of G* if G has connected components, are

Vertex are also known as "nodes"

Edges are also known as "links"

For two graphs to be isomorphic (same) they must have the following properties:

The same number of vertices


The same number of edges
The same degrees for corresponding vertices
The same number of connected components
The same number of loops.
The same number of parallel edges.
Both graphs are connected or both graphs are not connected,
Pairs of connected vertices must have the corresponding pair of vertices connected.

Example of Isomorphic graphs:

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1900 of 2244

 0 votes -- ibia ( 577 points)

18.39 Number of distinct graphs top gateoverflow.in/6256

Number of distinct graphs with p vertices and q edges ( p not equal to q) is always equal to

a) p

b) q

c)min(p,q)

d)max (p,q)

e) none of this

graph-theory


Selected Answer

I think, None of this should be answer for this question. total no of distinct graphs will be
p(p-1)/2 C q

 3 votes -- Manu Thakur ( 5261 points)

18.40 Considers an undirected random graph of eight vertices. The


Probability that there is an egde between a pair of vertices is 1/2. What is
the expected numbers of unordered of cycles length three. top gateoverflow.in/5293

a) 1/8
b) 1
c) 7
d) 8
approach?

if itsAnswer option C) 7

There will be c(8,3) = 56 cycles.Probability of existence of a particular cycle is 1/2*1/2*1/2 =1/8.So no of cycles =
1/8*56 = 7.

 2 votes -- pratikb ( 323 points)

Ans c

A cycle of length 3 can be formed with 3 vertices.

So number of ways we can form a cycle of length 3=3C3=1

Number of ways to pick 3 vertices from 8 vertices=8C3=56

Total ways=56*1=56

The probability that there is an edge between two vertices is 1/2.

Probability of existence of a particular cycle = 1/2*1/2*1/2

So expected number of unordered cycles of length 3 = 56*(1/2)^3 = 7

 1 votes -- Anu ( 6731 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1901 of 2244

18.40 Prove that maximam number of edges in a planer graph with n


vertices is 3n-6 top gateoverflow.in/5291

http://mathoverflow.net/questions/124116/maximum-number-of-edges-in-a-planar-graph

 2 votes -- suraj ( 3299 points)

18.41 What is the no of ways to divide 'n' nodes into three graphs g1,g2 and
g3? top gateoverflow.in/7497

What command is used to change contents of one database using the


contents of another database by linking them on a common key field?
a)Replace

b)join

c)change

d)update

The three graph will be 3 connected components of some disconnected graph with n nodes.Now The no of possible way
will be no of possible solution of the equation g1+g2+g3=n.

and it will be n+2Cn

 0 votes -- Arun Gorain ( 77 points)

18.41 no of spanning trees with n nodes for a graph? top gateoverflow.in/7498


Selected Answer

It depends on kind of Graph !

Disconnected Graph -> 0 spanning Tree

Complete Graph Kn -> n ^ n-2

Bipartite Graph, Km,n => m n-1nm-1

Does not fit in all cases -> Use https://en.wikipedia.org/wiki/Kirchhoff's_theorem this theorem

 2 votes -- Akash ( 26315 points)

maximum spanning trees for vertices V is given by V(V-2) .

3 vertices = 3 (3-2) =3

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1902 of 2244

5 vertices = 5 (5-2)= 53 = 125 and so on

 1 votes -- KingSAJ ( 97 points)

18.42 How to approach for calculating the number of paths of length n


between 2 different vertices for a complete graph K4? top gateoverflow.in/8510

If I have any complete graph given then what is the approach to be followed up for calculating the number of paths of length
n because for large value of n ,computation would be tricky ,so how to proceed with such questions.

M = Adjacency Matrix

MN = M x M x M ...n times.

MN [i][j] = P means there are P paths of length N from vertex i to vertex j.

 1 votes -- sameer2009 ( 1203 points)

18.43 any relation between planar graphs and connected or disconnected


graph top gateoverflow.in/8445

I just wanted to confirm that if I have a disconnected graph ,then I can call it planar .so for a graph to be planar do I need to
check whether it is connected or disconnected.

planar graph need not to be connected .... this should follow only condition is no edge must cross each other
they will specify for connected planar graph in question.

 2 votes -- Anoop Sonkar ( 4167 points)

18.44 maths_mock_test2 top gateoverflow.in/7734

graph-theory


Selected Answer

Every element in an equivalent partition is related to each other- so the subgraph of an equivalent partition must be
complete. So, for each partition we get a clique and all these cliques are mutually disconnected.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1903 of 2244

 2 votes -- Arjun Suresh ( 124125 points)

18.45 Consider the following set : {1,2,3,.....n}. Now consider all possible
subset. Two subset S1 and S2 are having edge between them only if their
intersection has two common elements. top gateoverflow.in/5286

Consider the following set : {1,2,3,.....n}. Now consider all possible subset. Two subset S1 and S2 are having edge between
them only if their intersection has two common elements.

Find:
a) Number of isolated vertices.
b) Number of components
c) Highest degree possible.

Answers:
a) n+1
b) n+2
c) 3*2n-3

I have problem in c) part answer.


My answer is 2n - n - 2
My Approach:
I believe Highest degree should be of subset: {1,2,3....n} itself.
as it will be connected to every other vertices across.
It only not connected with single element set, phi and itself.
So its degree is 2n - n - 2 which must be highest.
Please suggest suitable approach to it.

graph-theory combinatory

Your solution seems correct. But

"intersection has two common elements"

Is it exactly two or at least two?

 0 votes -- Arjun Suresh ( 124125 points)

18.46 Eccentricity of a vertex in graph top gateoverflow.in/4988

Suppose there is a graph with self loop on vertices, has multiple edges and has loops. Then what would be eccentricity of a
vertex containing self loop? Also what would be the eccentricity of vertex in a cycle( i.e if a cycle contains that vertex)..and
eccentricity of a vertex in multiple edges(multiple edge start or end at that vertex)...?

18.47 trees top gateoverflow.in/4719

Number of trees possible with 5 or fewer vertices is A) 5 B) 8 C) 7 D) 10 Ans is b . Please explain

No of graphs with 1 vertex - 1

No of graphs with 2 vertices - 1

No of graphs with 3 vertices -1

No of graphs with 4 vertices 2

No of graphs with 5 vertices - 3

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1904 of 2244

So total 8 graphs

 1 votes -- pratikb ( 323 points)

18.48 Matching in graph theory top gateoverflow.in/4718

Can anone please explain what is a perfect matching in graph theory?

See , a perfect matching, every vertex of the graph is incident to exactly one edge of the matching. A perfect matching is therefore a matching of a graph containing edges, the largest
possible, meaning perfect matchings are only possible on graphs with an even number of vertices. A perfect matching is sometimes called a complete matching or 1-factor.

The nine perfect matchings of the cubical graph are illustrated above.

Note that rather confusingly, the class of graphs known as perfect graphs are distinct from the class of graphs with perfect
matchings.

A graph has a perfect matching iff its matching number satisfies

where is the vertex count of .

 1 votes -- Vikas Sharma ( 65 points)

18.49 When is complete bipartite graph regular..? top gateoverflow.in/4649

Complete bipartite graph Km,n is regular when

a) m= 1

b) n=1

c) both a) and b)

d) none

Answer is c....but whenever m=n , complete bipartite graph is regular.

So why there is a condition of m=n=1.....?????

Plz explain........................

It is used for this question only actually whenever m=n the complete bipartite graph is regular. here they want to just test
the concept whether we know this or not and how patiently we go through all options.

 2 votes -- jayendra ( 5797 points)

18.50 Isomorphic graphs top gateoverflow.in/4740

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1905 of 2244

Ans is a)

Can anyone plz explain how G1 and G2 are isomorphic?

I dont think that they are. here we have G2 we have 3 cycle of degree 2 and in G1 we have only two.

 3 votes -- Arpit Dhuriya ( 1791 points)

18.51 Max no of edges in disconnected graph top gateoverflow.in/4757

In a simple undirected graph with n vertices what is maximum no of edges that you can have keeping the graph
disconnected?

A) nC2 -1

B) nC2

C) n-1C2

D n-1C2 - 1

Ans is C) ....Please explain how?


Selected Answer

Maximum number of edges in a complete graph = nC2

Since we have to find a disconnected graph with maximum number of edges with n vertices. Therefore our disconnected
graph will have only two partions because as number of partition increases number of edges will decrease.

Now assume that First partition has x vertices and second partition has (n-x) vertices.

total number of edges = xC2 +(n-x)C2

=1/2*(2x2 -2nx + n 2 -n), where , 1<= x <= n-1

It would be maximum at both extreme(at x=1 or x= n-1).

Therefore, total number of edges = nC2 - (n-1) = n-1C2

 4 votes -- suraj ( 3299 points)

18.52 Path and Circuit top gateoverflow.in/4835

Which of the following statements are false?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1906 of 2244

a) A closed path of length n has distinct vertices and n distinct edges.

b) A circuit may have repeated vertices other than its end points

c) 2 paths are vertex disjoint if they do not share a common vertex

A) c only B) a only C) a) and c) d) None

Ans is none....but as per me a) is F as closed path don't have distinct vertices (initial and final vertices are same).....

"has distinct vertices" I guess number of distinct vertices or "all distinct" should be mentioned here,

 1 votes -- Arjun Suresh ( 124125 points)

18.53 no of vertices in a graph top gateoverflow.in/4782

The no of vertices in a graph containing 21 edges, 3 vertices of degree 4 and other vertices of degree 3 are:

a) 10

b) 13

c) 11

d) None

Sum of degrees of vertices= 2*no of edges

Let no of vertices=n

4*3+(n-3)*3= 42

n=13

But answer is given as 10..Plz explain how the answer is 10


Selected Answer

13 is correct answer by the logic you have produced. Be confident, sometimes given answers are not correct!!

 3 votes -- Prateeksha Keshari ( 1619 points)

18.54 2013 graph theory top gateoverflow.in/9380

The line graph L(G) of a simple graph G as follows.

(1)There is exactly one vertex v(e)in L(G) for edge e in G

(2)For any two edges e and e' in G , L(G) has an edge between v(e) and v(e'), if and only if e and e' are incident with the
same vertex in G

Which one of the following is true?

(P) The line graph of a cycle is a cycle

(Q) The line graph of a clique is a clique

(R) The line graph of a planar graph is planar

(S) The line graph of a tree is a tree

(A) P only

(B) P and R

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1907 of 2244

(C) R only

(D) P,Q,S

i think

(A) P only

because by taking a simple graph of 4 vertices(i.e planar graph)(take a 2 regular graph) and we can some to know it's
planar : option C eliminated ,

but tree for tree is not possible as it seems to be a cycle : option D eliminated.

also planar doesn't seem possible ,

hence possible answer is option A.

 1 votes -- sumit kumar singh dixit ( 1625 points)

18.55 graphs - bipartite top gateoverflow.in/9524

Q) For what value of n K n can be bipartite

a)2

b)3

c)4

d) 5

graph-theory


Selected Answer

Let G be a complete graph and G' is corresponding bipartite graph..


in bipartite graph der are two group of vertices. let call that group as group A, B respectively..
let a random edge 'e' connecting two vertices V1, V2.
Bipartite property says der is no edge 'e' for which V1 and V2 belongs to same group of vertices i.e. no edge in graph for
which both V1 and V2 belongs to A or both belongs to B..

obviously in complete graph der is an edge which connect every pair of vertices..

so a complete graph is bipartite only if it is complete graph of two vertices..

 6 votes -- Digvijay Pandey ( 26245 points)

18.55 no of different rooted labeled trees with n vertices ? top gateoverflow.in/25231

No of Labelled Trees => n n-2

https://en.wikipedia.org/wiki/Cayley's_formula

Then set each of tree node to be root, in each tree there are n ways to choose the root

Total No of rooted labeled trees => n n-2 * n => n n-1

Reference Graph Theory, Narsing Deo, Chapter on counting trees.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1908 of 2244

 1 votes -- Akash ( 26315 points)

18.56 math top gateoverflow.in/25204

Draw a eular graph which is not hamiltonian


Selected Answer

http://www.personal.kent.edu/~rmuhamma/GraphTheory/MyGraphTheory/eulerGraph.htm

 3 votes -- Leen Sharma ( 2935 points)

18.57 Graph top gateoverflow.in/20137

Find Maximum and Minimum no of edges in a graph G with n vertices if G has 3 component with 2 non acyclic and 1 acyclic
component?

18.57 minimum no of spanning tree in a connected tress with n nodes? top


gateoverflow.in/25232

18.58 The number of distinct simple graphs with up to three nodes are gateoverflow.in/285

top

The number of distinct simple graphs with up to three nodes are

A)15

B)10

C)7

D)9

graph-theory normal


Selected Answer

The number of max edges a simple graph can have is n × (n − 1)/2.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1909 of 2244

So, for a graph with 3 nodes the max number of edges is 3.

Now there can be 0 edges, 1 edge, 2 edges or 3 edges in a 3 node simple graph.

So the total number of unlabled simple graphs on 3 nodes will be 4.

Similarly for two node graph we have option of 0 or 1 edge.

So the total number of simple graphs upto three nodes are:

4+2+1=7

 3 votes -- Omesh Pandita ( 2209 points)

A graph is an ordered pair (V,E). So, given a set V, graph will be different if E is different. Lets see how many different E
we can get when |V| = 3.

For |V| = 3, we can have |E| = 0, 1, 2 or 3. So, 4 possible graphs.

Now, the question asks for |V| upto 3. So, we have to consider |V| = 2 and |V| = 1 also. When |V| = 2, we can have |E|
= 1 or 0, so 2 possibilities. For |V| = 1, |E| can be only 0 and hence only one possibility. So, total number of possibilities
is

4+2+1=7

 3 votes -- gatecse ( 9515 points)

ans should be 11:

here they said upto three three nodes means we have |V|=1, or |V|=2, or |V|=3

here total possible graph are 11

 1 votes -- jayendra ( 5797 points)

18.59 No. of nodes top gateoverflow.in/26614

If a tree has two vertices of degree 3, then no of vertices of degree 1 is

1. Exactly 4
2. At least 4
3. Atmost 4
4. None

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1910 of 2244

this may helps u ..

if only degree 3 and 1 allowed then answer should be EXACTLY 4 otherwise ATLEAST 4.

 4 votes -- Digvijay Pandey ( 26245 points)

18.60 why is it that edge connectivity is less than or equal to minimum


degree of a vertex in graph ? top gateoverflow.in/26307

why is the edge connectivity less than or equal to minimal degree of the vertex , since if we remove the no of edges equal to the minimum degree then the graph will become disconnected so
then why is it that we put a less than or equal to condition on edge connectivity ?

i dont know why u r confuse even though u already explained concept..

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1911 of 2244

see Edge connectivity is minimum number of edges removed in order to disconnect a graph. now we have to delete
minimum number of edges then try for those vertices which is associated with minimum number of edges i.e. degree of
that vertex should be minimum.

Note : a bridge in graph results edge connectivity to 1, which is less than minimum degree of any vertex.

 1 votes -- Digvijay Pandey ( 26245 points)

18.61 How many nonisomorphic simple graphs are there with n vertices,
when n is a) 2? b) 3? c) 4? top gateoverflow.in/19594

I am unable to get this logic since in both of these algorithms we need to have a record of future requirement of the
processes so then why is it that resource allocation graph algorithm is more efficient ?

18.61 How many subgraphs with at least one vertex does K3 have? top gateoverflow.in/19070

graph-theory

I think it should be 17 (with at least one vertex)

And asked about exactly with 3 vertices then 2n (n −1 ) / 2 = 8

But here at least 1 vertex so

3 subgraph as consider single - vertices ( question does not mention about distinct so we will consider all cases )
3 subgraph consider 2 vertices
1 subgraph consider 3 vertices
3 subgraph consider 2 vertices, one edge
3 subgraph consider 3 vertices, 2 edges
3 subgraph consider 3 vertices, 1 edge
1 subgraph consider 3 vertices, 3 edges

So, total 17

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1912 of 2244

 1 votes -- sonam vyas ( 6441 points)

Therefore there are 7 subgraphs possible in case of unlabeled vertex in k3 having atleast one vertex.

 1 votes -- Riya Roy ( 4767 points)

18.62 explain top gateoverflow.in/12063

How many edges are there in a forest of t-trees containing a total of n vertices ?

(A) n + t (B) n – t (C) n ∗ t (D) n^t


Selected Answer

In each tree we have k-1 edges for k vertices. So, for t trees with total n vertices (all trees are disconnected in a forest)
we would have n-t edges.

 7 votes -- Arjun Suresh ( 124125 points)

18.63 maximum number of edges in a graph with components top gateoverflow.in/11993

A graph G have 9 vertices and two components. What is the maximum number of edges possible in this graph?

graph-theory

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1913 of 2244


Selected Answer

A simple graph with n vertices and k


components has at most (n-k)*(n-k+1)/2 edges. So the given graph can have at most (9-2)*(9-2+1)/2=28 edges under
the assumption that it is a simple graph.

 7 votes -- Anurag Pandey ( 8183 points)

The maximum no of edges possible in a graph is n*(n-1)/2

consider 8 and 1 then it is 28

 1 votes -- Hai Hai ( 115 points)

max edge possible when a graph is complete , and there is 2 component

so by splitting it 1 vertex in one component and in other 8 vertices in other component we can have max edges .

in 8 vertices component it must be complete so it can have max edge ,

so max edge 8C2 = 28 edges

 1 votes -- Pranay Datta ( 6113 points)

18.64 Properties of Planar graph top gateoverflow.in/10563

Can anyone explain a connected planar graph with n vertices and e edges has e-n+2 regions??

graph-theory


Selected Answer

This should be enough with 20 proofs :)

http://www.ics.uci.edu/~eppstein/junkyard/euler/

The below link is also good one.

http://www.personal.kent.edu/~rmuhamma/GraphTheory/MyGraphTheory/planarity.htm

 0 votes -- Arjun Suresh ( 124125 points)

18.65 how to find without edge? top gateoverflow.in/12207

A certain tree has two vertices of degree 4, one vertex of degree 3 and one vertex of
degree 2. If the other vertices have degree 1, how many vertices are there in the graph ?
(A) 5 (B) n – 3
(C) 20 (D) 11

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1914 of 2244


Selected Answer

Ans:(D)

Given that the graph is a TREE

so if there are n vertices in tree then tree contains exactly n-1 edges

so apply sum of degrees=2|E| formula

(2*4)+(1*3)+(1*2)+(p*1)=2(p+4-1)

here p+4 is the total no.of vertices

By solving above eq you will get p=7

total vertices are 11

 3 votes -- supraja ( 525 points)

18.66 graph coloring top gateoverflow.in/16471

7 var occurs in a loop of computer programm.The variable nd step during which they must be stored are

t: step 1 through 6;u:step2;:steps 2 through 4 ;w:step 1 ,3 and 5;x:step 1 and 6;y:step3 through 6; nd z:step 4 nd 5. How
many different index registers are needed to store these variables during execution?

register allocation is application of graph coloring

steps variables
1 t x w
2 t u v
3 t v w y
4 t v y z
5 t w y z
6 t x y

here vertices represent variables

there is edge between variables if they are reqd at same time.

t v w y x z u
6 5 5 5 4 4 2
c1 c2 c3 c4 c2 c4 c3

5 registers are required

 0 votes -- Pooja ( 22773 points)

18.67 How many edges are there in a forest with v vertices and k
components? top gateoverflow.in/18112

How many edges are there in a forest with v vertices and k components?

a)(v+1) - k

b)(v+1)/2 - k

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1915 of 2244

c)v - k

d)v + k

Forest is nothing but disjoint union of trees.

So no of edges in 'k' components of 'v' vertices is nothing but

No of Edges = Summation of i=1 to k {v(i) -1} ........(1)

Summation of i=1 to k {v(i)} = V .........(2)

From (1) & (2)

No of Edges = v-k

 0 votes -- Digvijay Pandey ( 26245 points)

18.68 Graph theory top gateoverflow.in/17058

Vertices are labeled as 1,2,3,......n. Now for each path 1st vertex will be 1 and the last vertex will be n.So the remaining
n-2( labeled 2,3,....n-1) vertcies could be internal vertices of the path.

Now the number of choices of the internal vertices these could be the number of subsets of the set(2,3,....n-1).

So the answer will be 2^n-2. So B

 0 votes -- Arun Gorain ( 77 points)

18.69 didn't get how to solve it top gateoverflow.in/27279

The degree sequence of a simple graph is the sequence of the degrees of the nodes in the graph in decreasing order. Which of the
following sequences can not be the degree sequence of any graph?
I. 7, 6, 5, 4, 4, 3, 2, 1
II. 6, 6, 6, 6, 3, 3, 2, 2
III. 7, 6, 6, 4, 4, 3, 2, 2
IV. 8, 7, 7, 6, 4, 2, 1, 1


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1916 of 2244

use havel hakami thoerm.

http://coddicted.com/the-havel-hakimi-algorithm/

better one time go through this.

 2 votes -- Anirudh Pratap Singh ( 4091 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1917 of 2244

19 Linear Algebra top


19.1 Complex Number: Value of a^2+b^2 ? top gateoverflow.in/9169

complex-number


Selected Answer

Given equation is

(√ 8 + i)50 = 349(a + ib)

take the conjugate on both sides

(√ 8 − i)50 = 349(a − ib)

After multiplying both equations we will get,

950 = 398(a2 + b2 )

(a2 + b2 ) = 9

 4 votes -- suraj ( 3299 points)

19.2 Eigen Value: Eigen values top gateoverflow.in/32529

The possible set of eigen values of a 4 ∗ 4 skew symmetric; orthogonal real matrix is

A). ±i

B), ( ± i, ± 1)

C). ±1

D). (0, ± i)

eigen-value engineering-mathematics linear-algebra

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1918 of 2244

Option (B) is correct.

To solve this question, we use two properties of eigen value of skew-symmetrical matrix of order 'n'

1) If n=odd,eigen value is 0.

2) if n = even,eigen values are pure imaginary.

Here n = 4(even),hence eigen values are +i,-i

Now for orthogonal matrix,eigen value is either 1 or -1.

Hence option is (B).

 2 votes -- Shashank Kumar ( 2029 points)

19.3 Eigen Value: different independent eigen vectors top gateoverflow.in/33163

In A = (a ij)nxn where aij = 1 ∀ i,j then number of different independent Eigen Vectors of A are _________ .

(a) 1

(b) n-1

(c) 2

(d) n

eigen-value linear-algebra engineering-mathematics

Answer will be 2

one eigen value is real no.

others are 0

So no. of different independent eigen vector also be 2 ( one for real no, other for 0)

because it will depend on eigen value

 2 votes -- srestha ( 11585 points)

19.4 Eigen Value: Eigen Values of special matrices top gateoverflow.in/33298

A) what are the eigen values of Orthogonal matrix ? Describe general properties.

B) what are the Eigen value of skew-symmetric matrix ? Describe general properties.

C) Are there any speciality in Eigen values of Symmetric, Hermitian, Skew- Hermitian, Unitary . If there , describe them also.

engineering-mathematics eigen-value linear-algebra

19.5 Eigen Value: ISRO-2013-33 top gateoverflow.in/43968

What is the matrix transformation which takes the independent vectors ( ) ( )


1
2
and
2
5
and transforms them to ( )
1
1
and

( )
3
2
respectively?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1919 of 2244

A.
( )
1
1
−1
0

B. ( )
0.5
0
0.5
0

C.
( )
−1
1
0
1

D.
( )
−1
1
1
0

isro2013 linear-algebra eigen-value

19.6 Eigen Value: eigen values top gateoverflow.in/37653

[ ]
The linear operation L(x) is defined by the cross product L(x) = b × x, where b = [010]T and x = x1 x2 x3 T are three dimensional
vectors. The 3 × 3 matrix M of this operation satisfies

[]
x1
L(x) = M x2
x3

Then the eigenvalues of M are

a. 0, + 1, − 1
b. 1, − 1, 1
c. i, − i, 1
d. i, − i, 0

linear-algebra eigen-value engineering-mathematics

L(x) = b x X = [x3 0 -x1] T (Using definition of Cross Prod. from wikipedia ;) See comment below for details )

L(x) = M(3x3) x [x1 x2 x3] T

Now, what should M do with X? :D :D

Exchange the top and bottom rows, place sign, nullify middle row.

That can be achieved with M:

[0 0 1
0 0 0
-1 0 0]

Its Eigenvalues turn out to be: 0, +i. -i (A)

 0 votes -- Arindam Sarkar ( 621 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1920 of 2244

19.7 Eigen Value: 1. if V1 and V2 are eigenvectors that correspond to the


distinct eigenvalues then they are linearly independent. top gateoverflow.in/20476

TRUE/FALSE :

1. if V1 and V2 are eigenvectors that correspond to the distinct eigenvalues then they are linearly independent.

2. if V1 and V2 are linearly independent eigenvectors then they correspond to distinct eigen values.

plz explain or provide some references thanks

linear-algebra eigen-value

We can conclude second option with an example,

[ ]
2 −2 1
−1 3 −1
2 −4 3

Skipping the calculation step of eigen values. Eigenvalues are λ1 = 1,λ2 = 1,λ3 = 6,

Eigen Vectors corresponding to eigen value, λ1 = 1,

Eigen vector you will get in terms of two linearly independent variable, I have taken k1 and k2 and the vector will be,

(2k1-k2,k1,k2) i.e k1 ( 2,1,0)+k2(-1,0,1)

[] [ ]
2 −1
Now you will see that these two vectors 1 & 0 corresponding to one eigen value,λ1 = 1.
0 1

Both will satisfy the characteristic equation, (A − λI)X = 0

[]
2
Checking for 1 ,
0

[ ][]
2−1 −2 1 2
−1 3−1 − 1 * 1
2 −4 3−1 0

[ ][]
1 −2 1 2
= − 1 2 − 1 * 1
2 −4 2 0

[ ]
2 ∗ 1 + ( − 2) ∗ 1 + 1 ∗ 0
= ( − 1) ∗ 2 + 2 ∗ 1 + ( − 1) ∗ 0
2 ∗ 2 + ( − 4) ∗ 1 + 2 ∗ 0

[]
0
= 0
0

[]
−1
Checking for 0 ,
1

[ ][ ]
2−1 −2 1 −1
−1 3−1 −1 * 0
2 −4 3−1 1

[ ][ ]
1 −2 1 −1
= − 1 2 − 1 * 0
2 −4 2 1

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1921 of 2244

[ ]
1 ∗ ( − 1) + ( − 2) ∗ 0 + 1 ∗ 1
= ( − 1) ∗ ( − 1) + 2 ∗ 0 + ( − 1) ∗ 1
2 ∗ ( − 1) + ( − 4) ∗ 0 + 2 ∗ 1

[]
0
= 0
0

Moreover these vectors are linearly Independent,

[] [ ]
2 −1
C1* 1 +C2* 0 =0
0 1

The above equation are only possible for C1 = C2 = 0, So both vectors are linearly independent as well.

So its not always the case that if V1 and V2 are two linearly independent eigen vectors then they correspond to distinct eigen values.

 1 votes -- Sandeep Singh ( 5939 points)

19.8 Eigen Value: eigen value top gateoverflow.in/31052

[ ]
2 7 10
Eigenvalue of matrix A , 5 2 25 is −9.33
1 6 5

other eigenvalue is

1) 18.33

2) −18.33

3) 18.33 − 9.33i

4) 18.33 + 9.33i

engineering-mathematics eigen-value


Selected Answer

Ans will be (A)

trace of matrix = sum of eigen values

say here are 3 eigen values are -9.33, X,Y

2+2+5 = -9.33+X+Y

or, X+Y= 18.33....................(i)

Now, determinant of matrix= product of eigen values

determinant of matrix =2(10-150) - 7(25-25) + 10(30-2) =0

product of eigen values = -9.33 .X.Y

or, -9.33.X.Y=0

or, X.Y=0

So, we can say one of the eigen value is 0, say, X=0

then from equation (i) we can say Y=18.33

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1922 of 2244

 9 votes -- srestha ( 11585 points)

Let x and y be other two eigen value


sum of eigen value = sum of diagonals
x + y +(-9.33)=2+2+5
x+y=18.33
x=18.33-y

product of eigen value = determinant of matrix


xyz = 0
(18.33-y)y(-9.33) =0
so y=0 or 18.33

1)18.33 is the answer.


 5 votes -- Umang Raman ( 10379 points)

19.9 Eigen Vector: Orthogonal set of vectors in R top gateoverflow.in/38916

What is R in this question? How to solve this?

Q).Let A be a real n ∗ n matrix ,then which of the following statements are true?

I). A is orthogonal iff the row vectors form an orthgonal set of vectors in R4 .

II). A is orthogonal iff the columns vectors form an orthogonal set of vectors in R4 .

(A) Only I

(B) Only II

(C) Both I and II

(D) None of these

The correct answer is C.

linear-algebra eigen-vector engineering-mathematics


Selected Answer

Here R represents real number space and 4 represents the dimensionality (number of coordinates to represent a point in space) of the real

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1923 of 2244

number space . Consider the following 2 diagrams

Dimensions

Each vertex of a cube is represented by 3 coordinates x, y, z . Since there are 3 coordinates to represent each point on a cube so the cube is
in three dimensional space. In case of this question there will be 4 coordinates to represent a point

Orthogonal Matrices:

Orthogonal matrices have two special properties

1. Each column has norm one, and each row has norm one.

2. Each column is orthogonal to every other column, and each row is orthogonal to every other row

Since there are no numerical values for a matrix given so your answer is simply C

 2 votes -- ibia ( 577 points)

19.10 Eigen Vector: Count linearly independent eigen vectors top gateoverflow.in/38609

Answer should be A. But they gave D. Their Explanation: Corresponding to each distinct eigen value, we have atleast one
independent eigen vector.

linear-algebra eigen-vector ace-test-series


Selected Answer

It is not true that when u have distinct eigen values then u will have that much linearly independent vectors , take a 2*2
identity matrix , it has same eigen values but it has 2 different linearly independent vectors (1,0) and (0,1) .

How many linearly independent vectors we will have also depends on the rank of matrix , so if u have 2 distinct eigen
values then there may be a case that u have repeated similar values which may be producing distinct linearly independent
vectors ,therefore , u can only say that it will have atleast 2 distinct linearly independent vectors, option A is not always
right .

Take A =

1 0 0

0 2 1

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1924 of 2244

0 1 2
has eigenvalues 1 , 1 and 3.
The eigenvector for lambda=3 is [0 1 1] , and the repeated eigen value
lambda=1 has linearly independent eigen vectors [1 0 0] and [0 -1 1].

 1 votes -- radha gogia ( 4369 points)

19.11 Eigen Vector: Eigen vectors of linear equation defined by cross product
top gateoverflow.in/38908

How to solve this question?

linear-algebra eigen-vector engineering-mathematics

19.12 Lu Decomposition: GEEK_MOCK_QUETION_30 top gateoverflow.in/37894

( )4
6
3
3

What is the sum of all the elements of the L and U matrices as obtained in the L U decomposition?

a. 16
b. 10
c. 9
d. 6

geek-mock-2016 lu-decomposition

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1925 of 2244

Selected Answer

Answer is 9

 2 votes -- Akhil Nadh PC ( 1967 points)

[ ] [
4
6
3
3
=
l11
l21
0
l22 ][ u11
0
u12
u22 ] We get following equations :l11 ∗ u11 + 0 ∗ 0 = 4l11 ∗ u12 + 0 ∗ u22 = 3l21 ∗ u11 + l22 ∗ 0 = 6l21 ∗ u12 + l22 ∗ u22 = 3After solvi

 1 votes -- prathams ( 1141 points)

19.13 Matrices: Why is the value of the determinant of adjoint of a matrix


not equal to 1 ? top gateoverflow.in/20820

What is the value of determinant of adjoint( A). What I am not getting in this is that since AA −1 = In .Now if I take determinant on both sides I will get
∣A ∣∣ A −1 ∣= In = 1 ,now ∣A −1 ∣= 1/ ∣ A∣ ,then ∣A −1 ∣=∣ AdjointA ∣ / ∣ A∣. By substituting the above value I get ∣AdjA ∣= 1. What is wrong in this statement ? since value of
det(adj(A)) = det(A)n −1

matrices linear-algebra


Selected Answer

A A -1 = I n

A (adj A) = |A| I n

take determinants Both side

| A (adj A) | = | |A| I n |

==>We know that if A be an n-rowed square matrix and ' k' be any scalar then

| K A | = K n |A|

Now

| A | | adj A| = | A | n | In |

| A | | adj A| = | A | n

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1926 of 2244

| adj A| = | A |n-1

 1 votes -- Leen Sharma ( 2935 points)

19.13 Matrices: why row rank of a matrix is equal to column rank of the
matrix ? top gateoverflow.in/15574

matrices linear-algebra

if k row of a matrix with n row is linearly independent then we say the rank of a matrix is k.

we know that if we take the transpose of a matrix the rank does nt changes so by taking the transpose row rank remains
k =>so column rank is also k.(as now row and column is interchanged in the new matrix).

in simple word,by interchanging the row and column the linear dependency is not going to change.

 0 votes -- Saurav Kumar Gupta ( 1455 points)

19.14 Matrices: symmetric matrix top gateoverflow.in/20228

Let A = [ ]
P
R
Q
Q
. If P, Q, R and S are symmetric , What can you say about A?

matrices

A is not Symmetric.

 0 votes -- Monanshi Jain ( 5827 points)

19.15 Matrices: A is a 4-square matrix and A 5 = 0. Then top gateoverflow.in/15461

A is a 4-square matrix and A_5 (a raised to the power of 5) = 0. Then A_4 =

a) I

b) -I

c) 0

d) A

matrices linear-algebra

Question does not have any notion of existing of inverse or related to rank. Therefore considering Zero matrix as A would
satisfy all the constraints.

Therefore, (c) is the answer.

 0 votes -- suraj ( 3299 points)

19.16 Matrices: How to prove Rank(AB) <= min(Rank(A),Rank(B)) ? gateoverflow.in/17668

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1927 of 2244

top

Given A and B are matrices such that they can be multiplied.

How to prove Rank(AB) ≤ min(Rank(A),Rank(B)) ?

matrices linear-algebra

Proved, how Rank(AB) ≤ min(Rank(A),Rank(B))


refer--> http://math.stackexchange.com/questions/48989/how-to-prove-textrankab-leq-min-textranka-textrankb .

 0 votes -- Vinay Yadav ( 1739 points)

19.17 Matrices: How to calculate LU decomposition of a 2*2 matrix ? gateoverflow.in/16640

top

I need to calculate determinant of a 2*2 matrix such as

[ ]
2
4
2
9

I proceeded by making it a upper triangular matrix and then using the negetives of the multipliers to get the lower triangular
matrix.

U was obtained by doing R2->-2R2+R1 which is equal to [ ]


2
0
2
5

When I used to negative of the multiplier ,i.e. 2 to get the lower triangular matrix,
[ ]
1
2
0
1
.

But the product of L and U is not coming out to be equal to the orig matrix. What am I doing wrong ?

linear-algebra matrices

process is correct and even the product of L and U matrix is coming out as the original matrix. Calculate once again
properly.

L and U matrix can also be founded by LU-decomposition method.

Let A=L.U

L= [ 1
L21
0
1 ]
U=
[ U11
0
U12
U22 ]
From here lower and upper matrix can be evaluated.

 0 votes -- nitin.nilesh ( 109 points)

19.18 Matrices: A is an upper triangular with all diagonal entries zero, then
I+A is top gateoverflow.in/15458

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1928 of 2244

A is an upper triangular with all diagonal entries zero, then I+A is

(a) invertible (b) idempotent


(c) singular (d) nilpotent

linear-algebra matrices


Selected Answer

A is an upper triangular matrix with diagonal elements zero. If we add I i.e. identity matrix to A then it will become an
upper triangular matrix with all diagonal entries are 1.

That means all eigenvalues A + I are non zero (eigenvalues of triangular matrix is nothing but diagonal elements), so
determinant will never be zero and matrix will be invertible for sure.

 1 votes -- Digvijay Pandey ( 26245 points)

19.19 Matrices: matrix top gateoverflow.in/33730

how to solve??

matrices linear-algebra


Selected Answer

Label the matrix as a,b,c,d on row wise and column

From the given matrix we can get (a,b) , (b,c) ,(c,d)

Now apply transitive property so we get (a,c) (b,d) and (a,d)

so add 1 in the corresponding positions we get C as Ans

 0 votes -- Prabhanjan R ( 747 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1929 of 2244

19.20 Matrices: A be a n-square matrix with integer entries and B = A + 12 I.


Then top gateoverflow.in/15459

A be a n-square matrix with integer entries and B = A + 12 I. Then

(a) B is idempotent (b) B inverse exist


(c) B is nilpotent (d) B inverse is idempotent

linear-algebra matrices

option B

 0 votes -- shabi ( 317 points)

19.21 Matrices: Matrix multiplication 1 top gateoverflow.in/33958

I want to ask about the equation i hv marked a question mark.

(p-1qp)n=p-1qnp how??

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1930 of 2244

Why is there no power on matrix p ?

matrices linear-algebra


Selected Answer

(p-1qp)n=p-1qnp

To understand why is so happening,

lets take value of n = 2

(p-1qp)2 =(p-1qp) (p-1qp)

= p-1 q p p-1 q p ∵ ( AB)C = A ( BC)

= p-1 q I n q p ∵ AA-1 = In

= p-1 q q p

= p-1 q2 p

Similarly you can check and assure yourself with other values of n.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1931 of 2244

So (p-1qp)n=p-1qnp

PS : One of the most important use of matrix diagonalization is calculating higher powers of a square matrix.

Ref
: http://www.maths.lse.ac.uk/personal/martin/fme4a.pdf and https://en.wikipedia.org/wiki/Diagonalizable_matrix#An_application

 2 votes -- Sandeep Singh ( 5939 points)

19.22 Matrices: Let Mn×n be the set of all n-square symmetric matrices and
the characteristics polynomial of each A∈Mn×n is... top gateoverflow.in/15457

linear-algebra matrices


Selected Answer

This question is wrong, it could be a typo mistake. First I will explain why this question is wrong and then I will correct the
question and explain the solution. Just so you know, trace of a matrix is the sum of the diagonal elements of a matrix,
and also the sum of eigen values of that matrix.

Here Matrix M is a symmetric matrix with characteristic equation as given in the question. For a characteristic equation we
know that coefficient of tn-1 is the trace of Matrix (check eqn (6) of this link). Here in question the coefficient of tn-1 is
0, which means trace of M is 0 (Tr(M) = 0).

Now coefficient of tn-2 can be represented as (Tr(M)2 - Tr(M2))/2 = -Tr(M2)/2 (as Tr(M) = 0) (check eqn(17) in this
class note. Look for eqn c 2 = ... ).
Coefficient of tn-2 given in question is 1, that means Tr(M2) = -2, but it could never be negative for a symmetric matrix.
The reason for Tr(M2) to be non-negative can be explained in different ways. One way is as follows:
A symmetric matrix A has all real eigen values, and eigen values of A2 is the square of eigen values of A , hence trace
of A2 is sum of squares of real numbers, which makes it non-negative. Hence such a matrix doesn't exist.

My guess the correct characteristic equation is:


tn + a n-2tn-2 + a n-3tn-3 + ...+a 1t + a 0
Now, this characteristic equation puts the constraint that Tr(M) = 0.

Now jumping into main question. The dimension of the matrix. All square matrices of size n can be considered as a linear
space of dimension n2, as every element corresponds to a matrix with that element 1 and all others 0. We could also think
dimension as the freedom of filling this matrix. We can we fill whole of n2 with no restrictions. But in this question we have
two restrictions:
1) Matrix should be symmetric.
2) Matrix should have trace 0.
So for symmetric matrix, while filling one side of diagonal (say upper triangle), corresponding elements in the other side is
already determined. Which makes it (n2 - n)/2. Diagonals can be anything so dimension is updated with +n. But now to
have trace 0, last element in the diagonal has to be the -1 times sum of rest of elements in the diagonal, making the
updation +(n-1). So the dimension at the end is:
(n2-n)/2 +n-1 = (n-1)(n+2)/2. which is option (c)

 0 votes -- Saneem Ahmed ( 91 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1932 of 2244

19.23 Matrices: matrix top gateoverflow.in/33731

tell me the approach..in details..

matrices linear-algebra


Selected Answer

Given -1 and 1 are two eigen values of matrix A

and 18 is the eigen value of A^2 + 3A

so other eigen values of A^2 + 3A are 4 , -2

and other eigen value of A is 3 ( 3^2 + 3 )

Eigen value of A is -1 ,1, 3 and A^2 + 3A is 4,-2,18

No eigen value is 0 so both are invertible

 1 votes -- Prabhanjan R ( 747 points)

19.24 Number Series: Series Convergence top gateoverflow.in/15347

I'm having hard time understanding how following series converges ;

1 + 2/5 + 3/5^2 + 4/5^3 + 5/5^4 + ............ infinity

number-series


Selected Answer

S = 1 + 2/5 + 3/5^2 + 4/5^3 + 5/5^4 + ............ infinity

S/5 = 1/5 + 2/5^2 + 3/5^3 + 4/5^4 + 5/5^5 + ............ infinity

S-S/5 = 1 + 1/5 + 1/5^2 + 1/5^3 ........... infinity

4S/5 = 1/(1-1/5)= 5/4

S= 25/16

 3 votes -- Digvijay Pandey ( 26245 points)

19.25 Polynomials: Factor of determinant with identical row top gateoverflow.in/4824

How the following fact applies to determinants (I came across it while solving problems):

Consider A is a n × n matrix, the elements of which are real (or complex) polynomials in x. If r rows of the
determinant become identical when x = a, then the determinant has a factor of order < r.

The only additional information I found in the solutions key is that

(x-a)r−1 is a factor of det. A.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1933 of 2244

Can I know how logically connected is collapsing of rows of matrix (into one row) with order of its factors.

Am I missing some stupid fact here?

matrices linear-algebra polynomials

Elements of A are polynomial in X, so the determinant(A)(let's say f(x)) would also be polynomial in x.

Now consider the case when r=2 and x=a, so it'll produce the two identical rows in A and determinant of A would be 0.

(Let's assume that ith and jth rows are identical with x=a, so if we replace the ith row with ith row -jth row, determinant
would be same. But now new ith row would be zero with x=a, it states that (x-a) is one of the factor of ith row)

f(a) = 0 => (x -a) would be factor of f(x).

Similarly, when r=3, (x-a) 2 would be factor of f(x).

and to generalize this you can say that, (x-a) r-1 would be factor of f(x).

PS: It's a bit tricky when r>2, but if you are not convinced I can prove that also.

 0 votes -- suraj ( 3299 points)

19.26 which of the statements are true for a 5*5 matrix whose all entries are
1 ? top gateoverflow.in/37477

1. A is not diagonalizable

2.The minimal polynomial and the characteristic polynomial of A are not equal

19.27 Math Linear Algebra top gateoverflow.in/37097

If A and B are real symmetric matrices of size n*n. Then, which one of the following is true?

a) AA^t = I

b) A = A^-1

c) AB =BA

d) (AB)^t = BA

engineering-mathematics linear-algebra


Selected Answer

Correct option is D.

By various theorems and properties,

(A. B)t = Bt. At = B. A

[As A and B are symmetric matrices, At = A and Bt = B. ]

 2 votes -- Gaurav Sharma ( 1383 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1934 of 2244

19.28 which of the statements are true for a 5*5 matrix whose all entries are
1 ? top gateoverflow.in/37476

1. A is not diagonalizable

2.The minimal polynomial and the characteristic polynomial of A are not equal

19.29 Virtual Gate 2 top gateoverflow.in/38710

Let A be a 4 × 4 matrix with real entries such that -1, 1, 2, -2 are its eigen values. If B = A 4 - 5A2 + 5I where I denotes 4 ×
4 identity matrix, then which of the following is correct? (det(X) represents determinant of X)

(A) det(A + B) = 0

(B) det(B) = 1

(C) trace of A + B is 4

(D) all of these

Eigen Values of A : <-1, 1, 2, -2>


Eigen Values of B :
<(-1)4 -5*(-1)2 +5, (1)4 -5*(1)2 +5, (1)4 -5*(-1)2 +5, (2)4 -5*(-2)2 +5, (-2)4 -5*(-2)2 +5> = <1, 1, 1, 1>

All options are true.


 0 votes -- Digvijay Pandey ( 26245 points)

19.29 A be a n-squared matrix with integer entries and B=A +12I then how
to conclude that B inverse exists ? top gateoverflow.in/37484

for Inverse there is one and only condition that determinant exist and it should be NON ZERO ..

 0 votes -- Digvijay Pandey ( 26245 points)

19.30 The product of the non zero eigen values of the matrix is: top gateoverflow.in/5139

Matrix:

Is there any way shorter, than solving traditionally(lambda subtraction from diagonal)?

http://gateoverflow.in/2013/gate2014-2_47?show=7485#a7485

 0 votes -- Arjun Suresh ( 124125 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1935 of 2244

19.31 A set of r vectors with r < n elements are always Linearly Independent
How? top gateoverflow.in/39184

Let r = No. of Vectors and n = No. of elements in each vector


A set of r vectors with r < n elements are always Linearly Independent, provided the vectors should not be in the same direction.
Can anyone please explain How?

19.32 if V1 and V2 are 4-dimensional subspaces of a 6-dimensional vector


space V top gateoverflow.in/39472

if V1 and V2 are 4-dimensional subspaces of a 6-dimensional vector space V, then the smallest possible dimension of
Intersection of V1 and V2 is ?

2 is the correct answer.

Rigorous explanations can be found here

Intuitively this question is similar to the following one,

A huge bag contains chocolates of 6 different types, say A, B, C, D, E, and F.Two people, say Ramesh &
Suresh, were asked to pick 4 different types of chocolates from the bag.

At least, how many types of chocolates they must have in common?

Assume that the bag is never gonna run out of chocolates of a particular type.

The answer to this new question is 2 as they have to pick 8 chocolates in total & they have only 6 varieties.

For example,

Suppose Ramesh picks 4 chocolates of types A, B, C and D & Suresh picks 2 chocolates of type E and F.

Now Suresh has to pick 2 more chocolate which should not be of types E and F as he already has chocolates of type E and
F, so the remaining 2 chocolates of Suresh must be of any two types from the set {A, B, C, D}.

but since Ramesh already have chocolates of types A, B, C and D, hence both of them will have at least two types in
common.

Now suppose if both of them picked up chocolates of type A, B, D & F, in this case, then they will have all four types in
common but having four types in common might not be the case always.

Analogies:

Bag - A 6 Dimensional Space,

A, B, C, D, E, F - (Six) Dimensions of the Space,

Ramesh and Suresh - The Subspaces V1 and V2.

PS: Any Space and its subspaces are similar entities, however in the analogy above they may appear quite different as
Space was analogous to a bag & its subspaces were analogous to people.I did this to keep the things simple.If it is
troubling you then you can assume that Ramesh & Suresh contain a bag & they are trying to fill them up with 4 different
types of chocolates from the original bag.

 0 votes -- Anurag Pandey ( 8183 points)

19.33 The eigen vectors corresponding to different eigen values of a real


symmetric matrix are always orthogonal ? top gateoverflow.in/39405

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1936 of 2244

What is the meaning by this statement - >


The eigen vectors corresponding to different eigen values of a real symmetric matrix are always orthogonal.
Can anyone please explain with the help of an example?

19.34 subspaces top gateoverflow.in/40573

is subspaces in gate cse 2016 syllabus?

19.34 Write a non-deterministic algorithm to find the sum of first n natural


numbers.. top gateoverflow.in/42379

n . (n +1 )
2
Just output .

Non-deterministic algorithm includes deterministic ones too.

 2 votes -- Arjun Suresh ( 124125 points)

19.35 Understanding Singularity, Triviality, consistency, uniqueness of


solutions of linear system top gateoverflow.in/4947

I was solving problems on deciding whether the given system of linear equations with three unknowns have trivial unique
solution, non trivial unique solution, non trivial infinite solutions or no solution, determinant of the coefficient matrix.

Firstly I saw this video. I am able to prepare following table:

I did understood most facts from the video and put it in the table but not quite sure about the things in red color, since I
have guessed it from my observations and from reading text books:

Q1. Need confirmation about if slope is different then it means that the coefficient matrix is always non singular and if slope
is same then it means that the coefficient matrix is alwayssingular.

Q2. (3rd row, 2nd column) If the slope is different and same y intercept then, whether system is inconsistent or whether
such system cannot exist only?

Q3. If system is in the form Ax = b (b is non zero) i.e. non-homogeneous, does it implies equations always have different y
intercepts and vice versa and also if it is in the for Ax = 0i.e. homogeneous, does it implies equations always have same y
intercepts and vice-versa?

The video explains the system with two unknowns. I was trying to prepare similar for table with three unknowns. But not
able to comprehend similar things for three unknown variable systems. More importantly above table doesnt
talk anything about triviality of the solutions, but there are some facts that dictates triviality of the solutions as
below which I want to incorporate in above table.

1. If matrix is non singular, then Ax = 0 has only the trivial solution

2. If system is homogeneous i.e. Ax = 0, then there are only two possibilities:

It has only trivial solutions

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1937 of 2244

It has infinitely many solutions in addition to the trivial solution

3. A homogeneous system is assured of having nontrivial solutions—namely, whenever the system involves more
unknowns than equations.

Also while reading from many sources I found below facts, which I believe are correct (correct me if they are not):

1. For non singular matrix A, Ax = b have unique solution.

2. For singular matrix A, Ax = b have no solution.

3. For singular matrix A, Ax = 0 have non trivial solution.

I prepared following table:

But there are some doubts:

Q1. However I found that these two tables do not map well. The red cells corresponding to Ax = 0 in above table do not map
with the corresponding ones in the first table

Q2. Also am not able to decide on the facts in red font in above table.:

For non singular A, is unique solution for Ax = b a non trivial one?


For singular A, can Ax = b have infinite solutions?
For singular A, are there infinite non-trivial solutions or unique non-trivial solution?

Gilbert Starnf video lec 1 - lec8 http://ocw.mit.edu/courses/mathematics/18-06-linear-algebra-spring-2010/video-


lectures/

will be useful to clear yout doubt ....

You are basically intrepeting Row picture for system of linear Equation, which is a line for two variables , and a planne for
3 variablers, and much more complex for higher variable...... So a column picture/explanation becomes much more
handy.....

In your second table, All your answer depends on actually A matrix , cofficient matricx, if A is singular square matrix, then
there will always be unqiue solution and Non trival solution offcourse ( Ofccourse plays a role here!!!)

No soution imples inconsisent solution ... I think U need to get the mainig of follwing terminology right :-

1) Non-trival Solution

1) Inconsistent and consistent solution

 0 votes -- durgesh ( 155 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1938 of 2244

19.36 How to find how many linearly independent eigen vectors are possible
of a matrix? top gateoverflow.in/39404

How to find how many linearly independent eigen vectors are possible of a matrix?


Selected Answer

To find out the no of linearly independent vectors , first find the rank of the matrix , so no of linearly independent
vectors=n-r where n is the no of unknowns and r is the rank of the matrix .

Now for calculating the value of unknowns u should first try converting the matrix to echelon form and then try calculating
the unknowns.

 0 votes -- radha gogia ( 4369 points)

19.37 Nullity of matrix is defined only for square matrices rank(A) +


nullity(A) = order of matrix ? top gateoverflow.in/39341

Nullity of matrix is defined only for square matrices


rank(A) + nullity(A) = order of matrix ?

since ,nullity =order of matrix -rank of matrix ....yes we can defined like that..

 0 votes -- shashi shekhar ( 327 points)

19.37 trace of matrix A^3-3A^2 top gateoverflow.in/39027

IF THIS IS MATRIX IN CHARACTERSTIC EQUATION FORM then

a3 - 3a2 =0 roots are 0,0,3 and then traceof(A)=sum of roots = 3

 2 votes -- Deepesh Kataria ( 1207 points)

19.38 In a m*n order Matrix, How many submatrices are possible? top gateoverflow.in/39092

In a m*n order Matrix, How many submatrices are possible?


Selected Answer

To form a Sub-matrix , we have a choice for each row & column - to take or not to take.

So, total we have 2 m * 2n choices ,

But we have to exclude matrix having 0 rows & 0 columns - which can be formed when we delete all rows OR All
Columns , which correspond to 2m + 2n - 1 ways.

Let's see with an example -

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1939 of 2244

 0 votes -- Himanshu Agarwal ( 8861 points)

19.39 Math Linear Algebra top gateoverflow.in/37079

If a,b and c are constants, which of the following is a linear inequality?

a) ax + bcy = 0

b) ax^2 + cy = 21

c) abx + a^2y >= 15

d) xy + ax >= 20

engineering-mathematics linear-algebra

19.40 A set of r vectors with r > n elements are always Linearly Dependent
How? top gateoverflow.in/39185

Let r = No. of Vectors and n = No. of elements in each vector A set of r vectors with r > n elements are always Linearly
Dependent, Can anyone please explain How?

Consider

r = no. of vector equations or rows of a matrix

n = no. of variables in vector equations or columns of a matrix

Now in your case r > n . Such types of systems where number of rows or equations are greater than the number of
columns or variables are known as OVER-DETERMINED system.

In general over determined system are inconsistent and have NO solutions.however there are some cases where solution
exist

the system of equations have linearly dependent equations e.g. y = x + 1 is linearly dependent to 2y = 2x + 2 so if such
equations exists then after removing linearly dependent equations the number of equations becomes less then the
number of variables we have infinite solutions.
Next if after removing linearly dependent equations the number of equations is equal to the number of number of
variables we have exactly one solution.

So the only cases where the statement in your question is true , is when the system of equations (vectors) have linearly
dependent equations

 0 votes -- ibia ( 577 points)

19.41 Maths: LA Non Homogeneous Equation top gateoverflow.in/38879

Given the following set of equations:

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1940 of 2244

X - y - z = 0

x + y + z = 46

x - 2y +z = 16

-x - y + 2z = -7

which of the following is true ?

a) no solution

b) infinite many solution

c) exactly one solution

d) exactly one solution and atleast one of the x,y,z is negative

linear-algebra

Unique solution. And the solution is x=23 , y=10 , z=13.

 0 votes -- Sreyas S ( 1353 points)

19.42 Consider the series Xn+1 = Xn / 2 + 98 Xn, X0 = 0.5 obtained from the
Newton-Raphson method. The series converges to top gateoverflow.in/7159

Can any1 solve this pls

options:

A)1.5 B)

sqrt(2)

C)1.6

D)1.4

There is a printing mistake in the question,

Consider the series xn+1=xn/2+9/8xn,x0=0.5 obtained from the Newton-Raphson method. The series converges to
(A) 1.5 (B) √ 2(C) 1.6 (D) 1.4

Sol : Let us see which function's root is found using given series. We know that, according to Newton-Raphson method,

xn+1=xn−f(xn)/f′(xn)

So we try to bring given equation in above form. Given equation is :

xn+1=xn/2+9/8xn=xn−xn/2+9/8xn=xn−(4xn^2−9)/8xn

So clearly f(x)=4x^2−9. We know its roots are ±3/2=±1.5, but if we start from x0=0.5, according to equation, we cannot
get negative value at any time, so answer is 1.5 i.e. option (A) is correct.

 0 votes -- Tejas Jaiswal ( 461 points)

19.43 Which of the following statement is incorrect ? top gateoverflow.in/17177

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1941 of 2244

linear-algebra


Selected Answer

adj (A)
| A|
A −1 =

| A | ⋅ A −1 = adj(A)

Multiplying by A (from right) on both sides, we get

| A | ⋅ I = adj(A) ⋅ A

Taking determinant, we get

| A | n = | adj(A) | ⋅ | A |

| adj(A) | = | A | n −1

So, option (a) is INcorrect.

 1 votes -- Pooja ( 22773 points)

19.44 What is the number of linearly independent solutions of a set of


vectors taken from identity matrix? top gateoverflow.in/20961

If I have 3 sets of vectors X=(1,0,0) , Y= (0,1,0) and Z=(0,0,1) then these all form a linearly independent set of vectors ,so K(X)+P(Y)+Q(Z) =0 , so we get
K=P=Q=0 , but my confusion is what is the no of independent solutions in this , since rank of matrix formed from these vectors will be 3 and according to
the formula No of independent solutions =no of unknowns- rank of matrix , we get no of independent solutions =0 , so how can it be 0 here ?


Selected Answer

A set of vectors is said to be linearly dependent if one of the vectors in the set can be defined as a linear combination of the other vectors.

K1X1+K2X2+K3X3=0

X1 = - K2/K1 X2 - K3/K1 X3

and If no vector in the set can be written in this way, then the vectors are said to be
linearly independent.

K1X1 + K2X2 + K3X3=0

implies K1=K2=K3=0

Given

X(1,0,0) Y(0,1,0) Z(0,0,1)

K1(1,0,0) +K2(0,1,0) + K3(0,0,1)=(0,0,0)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1942 of 2244

(K1,0,0) +(0,K2,0) + (0,0,K3)=(0,0,0)

i.e. K1=K2=K3=0

So vectors are linearly independent.

Here Rank =3

So and number of linearly independent. solution = no of variables - Rank of the matrix

= 3-3 =0

So there There is no linearly independent.

zero Solution will be the only solution which is Trivial.

 0 votes -- Leen Sharma ( 2935 points)

19.45 If rank of a matrix is n-1 then how is it that adjoint of matrix is not
equal to zero ? top gateoverflow.in/20968

Clearly |A|=0 ,so A*adj A=0 now since A is not null therefore Adj A can be anything , is may or may not be null so how can we say directly that adj A is not equal to 0

If the Rank of matrix A is n-1 then there is atleast one minor present of order n-1 of the matrix A is not equal to
zero.Therefore the matrix Adj A will be a non zero matrix and thus the Rank of the matrix Adj A will be greater than
zero.

Now

Rank of matrix A is n-1 Therefore | A | =0

Therefore A ( Adj A) will be a Zero matrix.

and we know

If the Rank of matrix A is n-1 then there is atleast one minor present of order n-1 of the matrix A is not equal to zero.

Hence we can say directly Adj A will not be Zero.

 0 votes -- Leen Sharma ( 2935 points)

19.46 If we apply different elementary row transformation so does the


unique solution vary ? top gateoverflow.in/21025

If the rank of a matrix is equal to the rank of augmented matrix then we get a unique solution , Now my ques is that I
applied a different row transformation and got the values to be x=7/3 , y=-1/3 and z=7 for a set of equations :

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1943 of 2244

x+y+z=9 , 2x+5y+7z=52 , 2x+y-z=0

But some other answer is given for this ques so that means they must have applied some other row transformation so how
can it be unique ?

Yes , You can apply Different row or column transformation on a given equations, but this will not effect the
answer .

Your answer seems incorrect as it is not satisfying equation-2 and equation-3.

--> Solving by equation not by row transformation .

From equation-3 we get --> z = 2x + y --(3') (putting this value in equation-1 and 2 we get).

--> 3x + 2y = 9 --(1') & 16x + 12y = 52 --(2')

(Multiplying equation-1' by 6 and then subracting it with equation-2').

We get --> x = 1 & y = 3 (putting these values in equation 3')

Answer --> x = 1 , y = 3 , z = 5 .

 0 votes -- Vinay Yadav ( 1739 points)

19.47 For what value of a, if any, will the following system of equations in x,
y and z have a solution? top gateoverflow.in/15503

For what value of a, if any, will the following system of equations in x, y and z have a
solution?
2x + 3y = 4, x + y + z = 4, x + 2y – z = a
(a) Any real number (b) 0
(c) 1 (d) There is no such value

linear-algebra

2x + 3y = 4 ........................(1)
x + y + z = 4 .....................(2)
x + 2y – z = a ...................(3)

add (2) and (3),


x + y + z + x + 2y – z = 4 + a
2x + 3y = 4 + a ..................(4)

from (1) and (4),


value of a must be 0 otherwise no solution..

u may use matrix rank method for this ..

 2 votes -- Digvijay Pandey ( 26245 points)

19.48 Null Matrix top gateoverflow.in/14729

X and Y are non zero square matrices of order n × n, such that XY = O

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1944 of 2244

Then, which of the following options is correct?

1. |X| = 0 and | Y | ≠ 0
2. |X| ≠ 0 and | Y | = 0
3. |X| = 0 and | Y | = 0
4. |X| ≠ 0 and | Y | ≠ 0

0option C

 0 votes -- shabi ( 317 points)

19.49 M is a 2-square matrix of rank 1, then M is (a) diagonalizable and non-


singular (b) diagonalizable and nilpotent (c) neither diagonalizable nor
nilpotent (d) either diagonalizable or nilpotent top gateoverflow.in/11228

explain plz .... ans given (d)

matrix can be in form of a b (or) a 0 (or) 0 a

0 0 0 0 0 0

in first and 2nd case matrix is diagonalizable .....as there are two distinct eigen values

in 3rd case it is nilportent

but it is not possible both diagonalizable and nilpotent at the same time

 1 votes -- amkrj ( 327 points)

19.50 math top gateoverflow.in/13387


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1945 of 2244

Answer - A

For a function to be continuous at a point the value at that point and the values of LHL ( LEFT HAND LIMIT ) AND RHL (
RIGHT HAND LIMIT) must be same.Here at x=1, F(x)=0

at x=1 - f(x)= 1

and at x=1 + f(x)=0 therefore the function is discontinuous at X=1.

 1 votes -- shreshtha5 ( 1227 points)

19.51 Matrices top gateoverflow.in/14710

If AB=BA then which of following are true?

1)(A+B)(A-B)=A^2-B^2

2)(AB)^n=A^n B^n

3)AB^n=B^n A

4)A=I or B=I

AB = BA
AB^n = ABBBBBBBBBB........ //n times B

= (AB)BBBBBBBB........

= BABBBBBBBBBB....... // replace AB by BA

= B(AB)BBBBBBBB....... repeat untill A reaches Rightmost possition..

AB^n = B^nA

 1 votes -- Digvijay Pandey ( 26245 points)

19.52 Diagonal Matrices top gateoverflow.in/14711

If diagonal matrix is commutative with every matrix of same order then it is necessarily

1)scalar matrix

2)unit matrix

3)symmetric matrix

4)zero matrix

Scalar..
even Identity & Null are also true but these are just a condition of Scalar matrix where K = 1 and 0 respectively ..

 1 votes -- Digvijay Pandey ( 26245 points)

19.53 Rank top gateoverflow.in/9805

IF A is square matrix of order 'n' and rank(A)=n-2 then Rank(adj(A))=?


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1946 of 2244

rank of the adjoint matrix is :


n if r(A)=n
1 if r(A)=n-1
0 if r(A)<n-1

 3 votes -- Digvijay Pandey ( 26245 points)

19.54 If a matrix is non-zero then is it possible that Adj A is zero matrix ? top
gateoverflow.in/21005

For this matrix although A is non-zero but adjoint matrix is zero , so is it true that Adj of a matrix need not be always non-
zero for a non-zero matrix ?


Selected Answer

Yes,It is true. Adj


of
a
non
zero
matrix
need
not
be
non-zero
or
Zero
always.

[ ]
1 1 1
A= 1 1 1
1 1 1

For this example A is non Zero but Adj


A
is Zero

Take one more Example

B=
[ ]1
3
2
4

For this Example B is non Zero and Adj


B is Non Zero

Hence,
Adj
of
a
non
zero
matrix
need
not
be
non-zero
or
Zero
always.

 0 votes -- Leen Sharma ( 2935 points)

19.55 Eigen vectors top gateoverflow.in/9806

if the matrix A (3∗3) has 3 distinct eigen values then the no.of linearly independent eigen vectors for A=

a)1

b)2

c)3

d)infinite

Let e1 , e2 , e3 be three eigenvalues and let x1 , x2 , x3 be three eigenvectors corresponding to them.

Suppose x1 , x2 , x3 are linearly independent, then

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1947 of 2244

α1 x1 + α2 x2 + α3 x3 = 0 ⇒ α1 = α2 = α3 = 0

So we have

α1 x1 + α2 x2 + α3 x3 = 0 --- (1)

Multiplying both sides by matrix A, we get

α1 (Ax1 ) + α2 (Ax2 ) + α3 (Ax3 ) = 0

⇒ α1 (e1 x1 ) + α2 (e2 x2 ) + α3 (e3 x3 ) = 0 --- (2)

Multiplying equation (1) by e1 , we get

α1 (e1 x1 ) + α2 (e1 x2 ) + α3 (e1 x3 ) = 0 --- (3)

Now subtracting equation (3) from (2), we get

α2 (e2 − e1 )x2 + α3 (e3 − e1 )x3 = 0

⇒ α2 β21x2 + α3 β31x3 = 0 --- (4)

where β21 = (e2 − e1 ), β31 = (e3 − e1 )

So we have eliminated x1 in equation (4).

We can repeat same procedure i.e. multiplying equation (4) by A to get

α2 β21(Ax2 ) + α3 β31(Ax3 ) = 0

⇒ α2 β21(e2 x2 ) + α3 β31(e3 x3 ) = 0 -- (5)

and multiplying equation (4) by e2

α2 β21(e2 x2 ) + α3 β31(e2 x3 ) = 0 -- (6)

and subtracting equation (6) from (5) to eliminate x2 ,

α3 β31(e3 − e2 )x3 = 0

Now Since all eigenvalues are distinct, β31, (e3 − e2 ) ≠ 0, so α3 = 0.

Similarly, we can show that α1 , α2 = 0, hence x1 , x2 , x3 are linearly independent.

In fact, we can show this for any dimension, thus having n distinct eigenvalues implies n eigenvectors are linearly
independent.

Note : We can't have more than 3 linearly independent eigenvectors because 4th eigenvector must correspond to any one
of eigenvalue e1 , e2 , e3 , and thus it becomes linearly dependent on any one of x1 , x2 , x3 .

 0 votes -- Happy Mittal ( 9253 points)

19.56 Determinant top gateoverflow.in/6302

Let D denote the determinant of n*n matrix. If any line of the determinant is passed over m parallel lines which is true?

a) The resultant determinant will change its sign.

b) The resultant determinant will not change its sign.

c) Data insufficient

d) none

Plz explain...

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1948 of 2244

19.57 Linear Algebra Doubt top gateoverflow.in/33784

while solving linear equations, there comes a case where rank < number of varibles,

then we say there are n-r linearly independent solution.

What exactly does it mean ?

engineering-mathematics linear-algebra


Selected Answer

Rank<n (no of vars)

Am considering homogeneous case,

Same applies in nonhomogeneous when r(a) =r(a:b) <n

Linearly dependent equations eg x+y=2 and 2x+2y=4

We have two equations but they r linearly dependent

So actually they r equivalent to one equation. (here

Also you ll hv to put x=k and get y value corresponding to it so 1 linearly independent soln ie x and y linearly dependent
on x)

In homogeneous,

Infinite soln coz rank <no of vars

unique soln not possible (coz fr solving n vars we need n linearly independent equations)

No of linearly lndependent solutions =n-r

Rank= no of linearly independent equations

coz n-r vars cannot be solved uniquely u hv to assign sm consts k, l.. Note k, l are not linearly dependent (no of such vars
is n-r)

. For other vars u ll get values in terms of l and k eg k+l, l/2 etc.(these are linearly dependent on k, l)

 1 votes -- Anurag Semwal ( 4775 points)

19.58 Eigenvalues and Eigenvectors top gateoverflow.in/34544

Here answer is B.

Can anyone explain this? I am confused with option A and B.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1949 of 2244


Selected Answer

Option B is correct.

A + I is given in question , which gives A =

Now, it's Eigen Values are 0, -1, -1 . We have to find Eigen Vector for λ = -1

So, [A - λ I ] X = 0 , which gives

this gives, from first row , x - 2z = 0 => x = 2z

let , z = t , y = s => x = 2t

so, Eigen Vector is , Option B (Ans).

 2 votes -- Himanshu Agarwal ( 8861 points)

19.59 LA:Minimal polynomials and characteristic polynomials top gateoverflow.in/33145

What is the Difference Between Minimal polynomials and characteristic polynomials ? With some example ?

linear-algebra engineering-mathematics

Please refer to my explanation,i tried to make it short and simple as far as possible,though this topic contains lot of
things..

Just download the image for clear view...

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1950 of 2244

 0 votes -- Shashank Kumar ( 2029 points)

19.60 is there any short cut to find the determinant of the matrix top gateoverflow.in/9803

1 0 0 0 0 2

0 1 0 0 2 0

0 0 1 2 0 0

0 0 2 1 0 0

0 2 0 0 1 0

2 0 0 0 0 1

use LU decomposition method .... then this will convert the matrix into a lower triangular matrix. whose determinant
(which is also the determinant of original matrix) can be calculated by multiplying the all diagonal elements of the matrix.

 0 votes -- suraj ( 3299 points)

19.61 Is it true that singular matrix is always triangular matrix whether


upper or lower triangular ? top gateoverflow.in/21241

What is the value of the following limit?

d sin2 x
lim
x→a dx x

a. 0
b. 2
c. 1
1

d. 2
e. None of the above

No. Matrix A is not triangular, but is singular.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1951 of 2244

A=
[ ]
1
1
1
1

|A| = | |
1
1
1
1
=0

 2 votes -- Pragy Agarwal ( 13675 points)

19.62 Is it true that if eigen value exists then we will always have a non-zero
linearly independent vector ? top gateoverflow.in/25154

For a 3*3 identity matrix , we have eigen value as 1 but there is no linearly independent vector for it since if they are 3 unknowns then we shall have x=y=z=0 so then how is it true that
whenever we have an eigen value existing then we have a non-zero linearly independent vector for it ?

19.63 system of equations top gateoverflow.in/31051

value of k for which system of equations x+2y+kz=1 2x+ky+8z=3 has no solution

1)0

2)2

3)4

4) 8


Selected Answer

x+2y+kz=1 ..............(i)
2x+ky+8z=3 ...............(ii)

here two line have to be parallel for getting no solution

Now if k=4

(i) will give x+2y+4z=1 i.e. 2x+4y+8z=2..........(iii)

(ii) will give 2x+4y+8z=3................(iv)

Now (iii) and (iv) are parallel. So have no solution

Ans k=4

 3 votes -- srestha ( 11585 points)

19.64 linear equation top gateoverflow.in/31068

consider following set of equations

x1 + x2 + x3 = 6

2x1 + 2x2 + 3x3 = 14

3x1 + x2 + 2x3 = 14

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1952 of 2244

Solution for this set exists when value of x2 is

engineering-mathematics


Selected Answer

X2 will be 1

X3=2, X1=3

x1+x2+x3=6 or,2x1+2x2+2x3=12.............(i)

2x1+2x2+3x3=14.....................(ii)

solving (i) and (ii) we get X3=2

Now, from (i) x1+x2+x3=6 or, x1+x2=4...........(iii)

and 3x1+x2+2x3=14 or 3x1+x2=10.........(iv)

solving (iii) and (iv) we get x1=3

then from equation (i) we get x2=1


 3 votes -- srestha ( 11585 points)

19.65 what is the determinant of this matrix? top gateoverflow.in/36250

( )
−4 −1 −1 −1
−1 2 −1 0
Find the Determinant of .
−1 −1 3 −1
−1 0 −1 3

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1953 of 2244

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1954 of 2244

20 Calculus top
20.1 Complex Number: How to solve below equation ? top gateoverflow.in/27025

(1 −i √3 )30

The value of (1 +i )
60
(i = √−1 ) is ______.
A. 1
B. 0
C. -1
D. 2

calculus complex-number


Selected Answer

(1 −i √3 )30 (1 −2i √3 −3 )15 ( −2 −2i √3 )15 ( −2 )15 (1 +i √3 )15 ( −1 )15 (2 )15 (1 +i √3 )15 (1 +3i √3 −9 −3i √3 )5 ( −8 )5
(1 +i )60 (1 +2i −1 )30 (2i )30 (2i )30 ( −1 ) (2 )30 2 15 15
= = = = = = 2 = −1

 4 votes -- srestha ( 11585 points)

20.2 Integration: Integration in Sinx and Cosx top gateoverflow.in/35120

My answer is coming 0. Please explain.

integration calculus


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1955 of 2244

ans 8

 5 votes -- Pyuri sahu ( 1237 points)

20.3 Limits: Calculate the limit top gateoverflow.in/14377

cos(x) − log(1 + x) − 1 + x
lim
x→0 sin2 x =?

Please explain the steps also

calculus limits


Selected Answer

Answer is 0.

Apply L'Hospital's rule


1
cos (x) −log (1 +x) −1 +x −sin (x) − 1 + x +1
sin2 x 2sin xcos x
limx→0 = limx→0

−1 x
2cos (x) 2sin xcos x
= limx→0 + =0

 5 votes -- Happy Mittal ( 9253 points)

20.4 Limits: Please find the value of this limit top gateoverflow.in/17179

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1956 of 2244

I have applied L'Hospital here. And result came up like this :

1 1

2 2
1 − (y2 + y) − (2y + 1)

Then after applying limit value , result came as −∞.

Am I wrong ?

Please correct me.

limits

You can't apply L'Hôpital's rule everywhere!


∞ 0

It can be applied only when the problem has the form ∞ or 0 . This question is clearly not in that form. (it is in the form
∞ − ∞)

The correct answer is − 2

Multiply the numerator and denominator by y + (y2 + y)1 / 2 and simplify it, and you will get the answer.

 2 votes -- Saurav Kumar Gupta ( 1455 points)

20.5 Limits: Limit top gateoverflow.in/20804

Is the following statement correct? If yes, prove it.

lim
x→0 + logx = −∞

limits


Selected Answer

limx→a f(x) = L means that f(x) can be made as close to L as desired, by making x close enough (but not equal) to a.
limx→a + f(x) = L means that f(x) can be made as close to L as desired, by making x close enough (but not equal) to a
from the right side on the number line.
limx→a + f(x) = − ∞ means that f(x) can be made as largely negative as desired, by making x close enough (but not
equal) to a from the right side of the number line.

To Prove: For any given number M, there exists a value of x sufficiently close to 0, such that the value logx is smaller
(more largely negative) than −M. That is,

logx < − M

Exponentiating both sides, we get:

elog x < e −M

 x < e −M

Since e −M > 0 for any M ∈ R, we can choose our x such that 0 < x < e −M.

Thus, we have shown that no matter how largely negative − M is, logx can be made more negative than − M by
making x sufficiently close to 0 + .

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1957 of 2244

And that is exactly what limx→0 + logx = − ∞ means.

 0 votes -- Pragy Agarwal ( 13675 points)

20.6 Limits: Limits top gateoverflow.in/34122

Please give the answer with full solution.

calculus limits


Selected Answer

x2 x −x

limx→0 1 −cos x

It forms 0 , Apply L' Hospital's Rule

x2 xlog 2 +2 x −1
0 +sin x
limx→0

Again 0 , Apply L'Hospital's rule one more time

(x2 xlog 2 +2 x )log 2 +2 xlog 2 −0


cos x
limx→0

= 2log2 = log22 = log4

 5 votes -- Praveen Saini ( 34299 points)

20.7 Limits: calculate limit top gateoverflow.in/12980

( )
1 1
x2 sin2 x
limx→0 −

calculus limits


Selected Answer

sin2 x−x2

( ) ( )
1 1
x2 sin2 x x2sin2 x
limx→0 − = limx→0

Now when x --> 0, then x2 ≈ 0, and sin2 x ≈ 0, so x2 sin2 x ≈ x4 . So

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1958 of 2244

sin2 x−x2 sin2 x−x2

limx→0
( )x2sin2 x
= limx→0
( ) x4

Now applying L'Hospital's rule, we get

sin2 x−x2

( ) ( ) ( )
2sin xcos x−2x sin 2x−2x
x4 4x3 4x3
limx→0 = limx→0 = limx→0

Again applying L'Hospital's rule, we get

( ) ( ) ( )
sin 2x−2x 2cos 2x−2 1 −cos 2x
4x3 12x2 12x2
limx→0 = limx→0 = limx→0 − 2

2sin2 x

( )
−1
12x2
= limx→0 − 2 = 3

Last equality comes by applying limit.

 1 votes -- Happy Mittal ( 9253 points)

20.8 Limits: select correct option for limit top gateoverflow.in/12982

limx→0 sin x ()
(a) 1

(b) 0

(c) does not exist

(d) none of these

calculus limits


Selected Answer

RHL= limx→0 + sin(1/x) put x → 0 + h then, RHL= limh →0 sin(1/h)

it gives positive value {-1 to 1}

LHL = limx→0 − sin(1/x) put x → 0 − h then ,LHL= limh →0 sin( − 1/h) = limh →0 − sin(1/h) it gives negative value [-1 to 1]

so LHL !=RHL so limit doesnot exist

 3 votes -- saket nandan ( 1853 points)

(c) option

lt x--->0 {sin(1/x)/(1/X)}*(1/x)

blue term give 1 when after that we will apply limit to(1/x)

so lt x-->0(1/x)

which gives not defined...

 2 votes -- kunal chalotra ( 3567 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1959 of 2244

20.9 Limits: The value of a and b such that top gateoverflow.in/33276

asin 2x+blog (cosx) 1


x4
limx→0 = 2

a) - 1, -2 b) 1, 2

c) -1,2 d) 1,-2

calculus limits


Selected Answer

Option (A) is correct.

limx->0 (asin2x + b log(cosx))/x4 = 1/2 [0/0 form] ,applying L'Hospital rule ,we get

= > limx->0 (2a*sinx*cosx - (b /cosx)*sinx)/ 4x 3 = 1/2 => lim x->0 (a*sin2x - b*tanx)/ 4x 3 = 1/2 [0/0 form],

applying L'Hospital rule again ,we get,

= > lim x->0 (2a*cos2x - b*sec2x) / 12x 2 = 1/2

For above limit to exist,Numerator must be zero so that we get [0/0 form] & we can further proceed.

Hence 2a - b =0 => 2a = b ------(A)

limx->0 (b*cos2x - b*sec2x) / 12x 2 = 1/2 [0/0 form], applying L'Hospital rule again ,we get,

= > limx->0 b*(-2sin2x - 2secx*secx.tanx) / 24x = 1/2 => lim x->0 2b*[-sin2x - (1+tan 2x)tanx] / 24x = 1/2

[0/0 form], applying L'Hospital rule again ,we get,

limx->0 2b*[-2cos2x - (sec2x+3tan2x*sec2x)] / 24 = 1/2 = > 2b[-2 -1] / 24 = 1/2 => -6b/24 = 1/2 => b = -2

from (A), we have , 2a = b => 2a = -2 => a = -1

Hence a =-1 & b = -2

Hence option (A) is correct.

 2 votes -- Shashank Kumar ( 2029 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1960 of 2244

so, we can say

-4a-b=6

So ans will be (A) only

 2 votes -- srestha ( 11585 points)

20.10 Limits: solve calculate the limit top gateoverflow.in/33267

1 1 1

[
limn →∞ (1 +n ) + (2 +n ) + − − − − − + (n +n ) ]
a) log2 b) 2

c) 2 d) Π/4

limits

Summation of this series(1+1/2+1/3+.....+1/K) =logK

similary for given series it will be log(n+n)=log(2n)

which can be further splitted as log2 and log n now apply the limit and we have the ans as log2

 0 votes -- Aditi Tiwari ( 683 points)

20.11 Limits: limit top gateoverflow.in/35658

x2sin () x

sin x
Value of limx→0 is

limits


Selected Answer

()
sin x

1 () x

()
limx→ 0 sin y
x
x2sin y
sin x limy→ ∞
x
sin x limx→ 0 1
limx→0 = = = 0( ∵ siny ≤ 1, y → ∞).

 2 votes -- Arjun Suresh ( 124125 points)

20.12 Limits: Solve : calculate the limit top gateoverflow.in/31798

Calculate the limit

lim
3
x→1 −
√x + 1 ln(x + 1)
(A) 1

(B) 0

(C) 2

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1961 of 2244

(D) Does not exist

limits

answer = none of these

lim lim
3 3
x→1 −
√x + 1ln(x + 1) = h →0 √1 − h + 1ln(1 − h + 1)
3
= √2ln(2)

 3 votes -- Amar Vashishth ( 17865 points)

20.13 Limits: Limits indeterminate form top gateoverflow.in/32997

x+4

limx→∞ x+3
( ) x+1

calculus limits


Selected Answer

We know that lim f(x) g(x) = lim e g(x)[f(x) -1] if f(x)->1 and g(x) -> ∞ .Actually this is applicable in [1 ∞ form]

Hence we have,

limx ->∞ [(x + 4)/(x + 3) ] x+1 = limx ->∞ e (x+1)[ (x+4)/(x+3) - 1] since for x->∞ (x+4)/(x+3) ->1 & x+1 -> ∞ . Hence [1∞ form]

= limx ->∞ e (x+1)[ (x+4-x-3)/(x+3)] = limx ->∞ e (x+1)[ 1/(x+3)] = e 1 since for x->∞ ,(x+1)/(x+3) -> 1

= e

 4 votes -- Shashank Kumar ( 2029 points)

20.14 Limits: limits top gateoverflow.in/36369

Find the value of:

lim
θ→π / 2 (1 − 5cotθ)tan θ

A. e5

B. e −5

C. e1 / 5

D. e −1 / 5

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1962 of 2244

limits


Selected Answer

Since it is 0/0 form L'Hôpital's rule can be used.

lim
Let y = θ→π / 2 (1 − 5cotθ)tan θ

Take log.

lim
(
logy = log θ→π / 2 (1 − 5cotθ)tan θ )
lim
(
= θ→π / 2 log(1 − 5cotθ)tan θ ) { log of lim = lim of log
provided the limit exists.

lim
= θ→π / 2 tanθ ⋅ log(1 − 5cotθ) {log (x ) = y ⋅ logx
y

Now, since tan(π/2) = ∞ and log(1 − 5cotπ/2) = 0, we have a ∞ ⋅ 0 form. We need to convert this to a 0/0 form to apply the
L'Hôpital's rule.

log(1 − 5cotθ)
lim
cotθ
logy = θ→π / 2

−5 ⋅ ( − csc2 θ)
lim
(1 − 5cotθ)( − csc2 θ)
= θ→π / 2 {L'Hôpital's rule

−5
lim
= θ→π / 2 1 − 5cotθ

logy = − 5

 y = e −5

 4 votes -- Riya Roy ( 4767 points)

whenever u have to calculate a limit like Limit x-->a f(x)= 1 and limit x-->a g(x)=infinity , and if u have to calculate limit x--
g(x) , so it actually reduces to 1 infinity form
>af(x)

then u can apply this e limit x-->a g(x) (f(x)-1)

So here likewise will see g(x)=tanx and f(x)= 1-5cotx

 1 votes -- radha gogia ( 4369 points)

20.15 Limits: Limits 1raise to infinite top gateoverflow.in/33039

x2 +5x+3
2
limx→∞ x +x+2
( ) x

limits calculus

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1963 of 2244


Selected Answer

Ans is e^4

 6 votes -- Sayantan Ganguly ( 5061 points)

It is in 1 ∞ form,so we can write,

limx - > ∞ [(x2+5x+3)/(x2+x+2)]x = limx - > ∞ e x[(x^2 +5x+3)/(x^2+x+2) -1] = limx - > ∞ e x[(4x+1)/(x^2+x+2)] = limx->∞
(4x^2 +1)/(x^2+x+2) = e 4 (since x-> ∞, taking only highest power in both numerator and denominator.
e

 3 votes -- Shashank Kumar ( 2029 points)

20.16 Limits: Limits Indeterminate forms top gateoverflow.in/33011

1
ln x
limx→0 + x

limits calculus

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1964 of 2244


Selected Answer

Let y = limx→0 + x1 / ln x

Take log of both side at base as e

lny = limx→0 + ln x lnx

lny = 1

 y = e1

 5 votes -- Sandeep Singh ( 5939 points)

limx->0+ x(1/lnx) = limx->o+ (e(1/lnx)*lnx (since a b = e b log a)

= limx->o+ (e(lnx/lnx) = limx->o+ (e(1/x)/(1/x) [applying L'hospital rule since power was in ∞/∞ form]

= e1 = e

 1 votes -- Shashank Kumar ( 2029 points)

20.17 Limits: calculate limit top gateoverflow.in/12979

1 −cos θ

limθ→0 θsin θ

calculus limits


Selected Answer

limit =1/2.

 3 votes -- shreshtha5 ( 1227 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1965 of 2244

limx->0 (1-cosx)/xsinx applying L'Hospital rule

=limx->0 sinx/(sinx+xcosx)

=limx->0 ((sinx/x)*x)/[((sinx/x)*x)+xcosx]

=limx->0 x/(x+xcosx)

=limx->0 1/(1+cosx) putting x=0

=1/1+1

=1/2

 2 votes -- Amit Kumar ( 179 points)

20.18 Limits: calculate limit top gateoverflow.in/12981

sin x ∘

limx→0 x

calculus limits


Selected Answer

180 ∘ = π then 1 ∘ = π/180

∴ x ∘ = πx/180

sin (πx/ 180 )

limx→0 (πx/ 180 ) (180 / π ) = π/180

 6 votes -- saket nandan ( 1853 points)

20.19 Limits: calculate limit top gateoverflow.in/12978

ex −esin x

limx→0 x−sin x

calculus limits


Selected Answer

(ex −1 ) − (esin x −1 )
x−sin x
limx→0

[( ) ] [( ) ]
ex − 1 esin x − 1 )
x sin x
x − sin x

x−sin x
= limx→0

[( ) ] [( ) ]
ex − 1 esin x − 1 )
x sin x
limx→ 0 x − limsin x→ 0 sin x

x−sin x
= limx→0

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1966 of 2244

(x−sin x)

= limx→0 (x−sin x) = 1

 5 votes -- Amit Kumar ( 179 points)

ex − sinx ex −sin x − 1

Given x →0
lim
x − sinx
lim
= x →0 esin x ⋅
[ x − sinx
]
ex −sin x − 1
lim lim
So x →0 esin x × x →0 x − sinx =1×1=1

ey − 1
lim
y
Above we have used y →0 = 1, Bcz above when x → 0

Then (x − sinx) → 0

 1 votes -- Jagdish Singh ( 287 points)

20.20 Limits: calculate limit top gateoverflow.in/12968

π
limx→ 4 (tanx)tan 2x

calculus limits


Selected Answer

lim
π
lim
x→ 4 (tanx)tan (2x) = x→π / 4 etan 2xln (tan x)

Now,

sin 2xsec2 x
tan x
sin 2xln (tan x) 0 +2cos 2x.ln tan x 2

( )
π π π
cos 2x 0 −2sin 2x
limx→ 4 tan(2x)ln(tanx) = limx→ 4 form = limx→ 4 (L'Hospital's rule) = −2 = − 1

So,

1
lim
u → −1 eu = e , where u = tan(2x)ln(tanx)

 3 votes -- Salman ( 615 points)

limit= e ^-1/2

 1 votes -- shreshtha5 ( 1227 points)

20.21 Limits: How to solve this using logarithms on both sides? top gateoverflow.in/39015

How to use log and solve this qn?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1967 of 2244

engineering-mathematics calculus limits

[(1-1/n)^n]^2

and since we know

lim x->inf(1-1/x)^x=e^-1

using this

(e^-1)^2=e^-2

 3 votes -- Tauhin Gangwar ( 509 points)

20.22 Limits: Limits top gateoverflow.in/9313

1
x
What is limx→0 (1 − x) ? Also please explain the result?

calculus limits


Selected Answer

1
x
limx→0 (1 − x)

1
x
= limx→0 eln (1 −x)

ln (1 − x)
x
= limx→0 e

ln (1 − x)
x
= e limx→ 0 ∵ e is a constant

This limit is 0 form and we can apply L'Hôpital's rule which gives limit
1
−1
=e = e −1 .

 4 votes -- Arjun Suresh ( 124125 points)

20.23 Limits: How to find this type of limits ? Pls do tell me how to proceed

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1968 of 2244

further top gateoverflow.in/34213

Question limx− >0 xsinx

Solution

put y= limx− >0 xsinx

log y = limx− >0 sinxlogx ( 0. infinity form)


sinx
1
(logx)
= limx− >0

cosx
−1 1
(logx)2
∗x
= limx− >0 ( using LH rule )

= how to proceed further ?

limits

log y=lim x->0 sinx log x

log y=lim x->0 log x/cosec x

log y =lim x->0 1/x/-cosec x cot x

logy =lim x->0 -tanx

log y=0 (as tan 0 is 0)

so y=e^0=1

 1 votes -- Pooja ( 22773 points)

20.24 Limits: How to solve this integration? Virtual Gate top gateoverflow.in/39034

How to solve this?

engineering-mathematics calculus limits

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1969 of 2244


Selected Answer

option B

now i rectifed the typo and solved i.e x-> 1- to x->-1

let x+1=z now when x-> -1 then z->0 so we can re write it in this way lim z->0 ln z /z^-3 its an indeterminate form we
can apply LH rule

lim z->0 1/z * 3z^2

lim z->0 3z

=0

 2 votes -- Bhagirathi Nayak ( 10239 points)

20.25 Limits: calculate limit top gateoverflow.in/12969

( )
a x +b x x

2
limx→0

calculus limits


Selected Answer

Answer = ab
1

( )
a x +b x x
2
Let y = limx→0

taking log on both sides


1

( )
a x +b x x
2
logy = limx→0 log

ax + bx
2
log
x
= limx→0

This is of the form 0 and so applying L'Hôpital's rule

1
x x
logy = limx→0 a +b . axloga + bxlogb ( )
1

= 2 . (loga + logb)

= log√ ab

So, y = √ab.
 1 votes -- shreshtha5 ( 1227 points)

limx→0 ((ax + bx)/2)1 / x gives 1∞ form so we apply standard form

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1970 of 2244

e limx→ 0 ( (f (x) −1 ) ∗ (g (x) ) )

here in this question f(x) = ((ax + bx)/2) and g(x)=1/x


x x
so we apply standard form e limx→ 0 ( (a +b ) / 2 ) −1 ) ∗ 1 / x

now we calculate forlim x→0 ((ax + bx)/2) − 1) ∗ 1/x which is 0/0 form now we apply l hospital rule that gives

(ax lna+bxlnb)/2 =1/2*(lnab)=ln (ab) 1/2

∴ eln e√ab = √ab


 3 votes -- saket nandan ( 1853 points)

20.26 Limits: calculate limit top gateoverflow.in/12967

π
limx→ 2 (sinx)tan x

calculus limits


Selected Answer

cos x

sin x. ln (sin x) 0 sin x sin x + ln (sin x) . cos x


π π π

limx→ 2 sinxtan x = limx→ 2 etan x.ln (sin x) e limx→ 2 tan x.ln (sin x) = e limx→ 2
π
cos x
( 0
form, applying L'Hospital's rule )=e π
limx→ 2 − sin x
= e0 = 1

 3 votes -- Salman ( 615 points)

20.27 Limits: calculate limit top gateoverflow.in/12975

6 x −2 x −3 x +1
x2
limx→0

calculus limits


Selected Answer

(6 x −2 x −3 x +1 ) [ (2.3)x −2 x −3 x +1 ] [ (3 x −1 ) (2 x −1 ) ] 3 x −1 2 x −1
x2 x2 x2 x
limx→0 = limx→0 = limx→0 = limx→0 × limx→0 x = ln3. ln2.

 3 votes -- saket nandan ( 1853 points)

20.28 Limits: calculate limit top gateoverflow.in/12976

xx −1

limx→0 x

calculus limits


Selected Answer

xx −1 0
x
limx→0 (00 = 1 and this is of 0 form)

We apply l'hopital's rule to get

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1971 of 2244

d
dx
(x ) x

1
limx→0

To calculate limx→0 dx (xx), put y = xx

Taking log both sides,

lny = xlnx(1/y)(dy/dx) = (1 + lnx)dy = xx(1 + lnx)dx

now applying limit we get,

limx→0 dx
(x ) = lim
x x
x→0 x (1 + lnx) = 1.(1 + ln0) = 1 + ln0 = ln0Hence, undefined

 2 votes -- saket nandan ( 1853 points)

20.29 Limits: calculate limit top gateoverflow.in/12977

sin x

limx→∞ x

calculus limits


Selected Answer

sin x

sinx value is bounded from -1 to 1. So as x tends to ∞, x must be 0.

 3 votes -- Arjun Suresh ( 124125 points)

remember this as a standard formula .as it always give answer as 0

 1 votes -- kunal chalotra ( 3567 points)

20.30 Limits: calculate limit top gateoverflow.in/12974

1 x +2 x +3 x + … +n x −n
x
limx→0

calculus limits


Selected Answer

n −n 0

if we put limit value in given equation then it gives 0 = 0 which is indeterminate form so we apply l'hopital's rule which
gives

1 xln 1 +2 xln 2 + … +n xln n −0


1
limx→0 = ln(1.2.3.......n) = ln(n!)

 4 votes -- saket nandan ( 1853 points)

20.31 Limits: calculate limit top gateoverflow.in/12973

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1972 of 2244

limx→∞ 4x + 5x (
1/x
)
calculus limits


Selected Answer

1
4 1

(( ))
1
x

limx→∞(4x + 5x) = limx→∞ 5x ( 5 )x + 1
x
= limx→∞5 × () (the term inside () ranges between 1 and 2) = 5 × ()0 = 5 × 1 = 5

 3 votes -- Salman ( 615 points)

very easy

lt->inf (4^x+5^x)^1/x

lt->inf 5^x*1/x[(4/5)^x +1]^1/x

ans will be 5

since 4/5 will give <1 no. and its to the power inf will results 0

 1 votes -- anmolgate ( 253 points)

20.32 Limits: calculate limit top gateoverflow.in/12971

limx→∞xme −x where m is +ve integer

calculus limits


Selected Answer

xm
x
We have limx→∞xme −x = limx→∞ e

Now we can apply L'Hopital's rule here i.e. differentiate numerator and denominator, we get

xm mxm− 1
ex x
limx→∞ = limx→∞ e

We can keep applying L'Hopital rule to get

mxm− 1 m(m−1 )xm− 2 m!x0 m!


ex ex x x
limx→∞ = limx→∞ = … = limx→∞ e = limx→∞ e = 0

So answer is 0.

 4 votes -- Happy Mittal ( 9253 points)

20.33 Maxima Minima: maxima-minima query top gateoverflow.in/30954

consider the following function f(x) = x 3 /3+ x2 /2 -6x+1000

find the intervals on which f is increasing.

Is my solution right approach for this kind of numerical??

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1973 of 2244

Caption

maxima-minima engineering-mathematics calculus

For finding the interval in which given function is increasing or decreasing ,there is no need to calculate maxima or
minima.

Just differentiate the function and find roots of f'(x), and then check where sign of f(x) is positive or negative.

here f'(x) = x^2 + x -6 = 0 => x = -3 , 2

for x ∈ (-∞,-3] ∪ [2 ,∞) , f'(x) >= 0 ,hence slope of function is increasing in this interval.Hence f(x) is increasing.

I hope you can find unnecessary steps in your solution.

 2 votes -- Shashank Kumar ( 2029 points)

20.34 Maxima Minima: Find absolute minimum top gateoverflow.in/29413

maxima-minima calculus


Selected Answer

Absolute Minimum will be at x = 3 and x = − 3.

Absolute minimum of f(x) is the minimum possible value that f(x) can ever attain.

Since a square root never spits out a −ve value, the minimum value that f(x) can attain is 0.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1974 of 2244

( )
Now to make f(x) = 0, 36 − 4x2 must be equal to 0.

( )
On solving 36 − 4x2 = 0, we get x = 3 & x = − 3.

So at x = 3 & x = − 3 the function f(x) will be at its absolute minimum.

that is, f(3) = f( − 3) = 0.

Also the domain of f(x) is [ − 3, 3] & the range is [0, 6]

 2 votes -- Anurag Pandey ( 8183 points)

f(x)=√(36-4x 2)

=2 √(9-x2)

For getting absolute minimum f(x) should be 0

So, 9-x 2 =0

x=3,-3

 1 votes -- srestha ( 11585 points)

20.35 Maxima Minima: ISRO-2013-49 top gateoverflow.in/44161

What is the least value of the function f(x) = 2x2 − 8x − 3 in the interval [0, 5]?

A. −15
B. 7
C. −11
D. −3

isro2013 maxima-minima


Selected Answer

Answer -11

f(x) = 2x 2 -8x -3

f'(x)=4x-8

f''(x)=4 , then it has minimal value at the point x=2

minimum value is 2⨉(2) 2 -8⨉(2) -3= -11

 2 votes -- srestha ( 11585 points)

Answer is -11

Substutue all the value of x from 1 to 5

in case of 0 it is -3

in case of 1 you will get -9

in case of 2 you will get -11

in case of 3 you will get -9

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1975 of 2244

incase of 4 you will get -3

incase of 5 you will get 7

so the least value is -11 -->option c

 2 votes -- Dexter ( 1933 points)

20.36 Maxima Minima: Solve top gateoverflow.in/31799

sin t
t
At t = 0, the function f(t) = has

(A) a minimum

(B) a discontinuity

(C) a point of inflection

(D) a maximum

maxima-minima


Selected Answer

sint cost 0
lim lim
t →0 t t →0 1 0
= ;using L'Hospital's Rule for form
=1
sin x
x
visually we can see clearly for the plot y =

that data is about the neighbourhood of function at x = 0

function is not defined at x=0 so, this means we are talking about the point which is not in the function domain hence, we
cannot say anything about it.

 2 votes -- Amar Vashishth ( 17865 points)

20.36 e sin x
e cos x
Maxima Minima: What is the maximum value of where x is a real
number? top gateoverflow.in/27705

calculus maxima-minima

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1976 of 2244


Selected Answer

e√2 will be the highest value of the given expression.

esin x
ecos x
can be written as esin x−cos x.

e is a famous irrational constant that is used as base of natural logarithms, and its approximate value is 2.7183, (which is of
course greater than 1).

So now we just have to maximize (sinx − cosx) to find the maximum value of given expression.

Clearly sinx and cosx are differentiable functions, hence their difference (sinx − cosx) is also differentiable.

So we can differentiate sinx − cosx to find its maximum value.


d

Solution of the equation dx (sinx − cosx) = 0 will give us the points where sinx − cosx will attain its maximum value.

On differentiating (sinx − cosx) with respect to x, we get cosx + sinx.

Putting cosx + sinx = 0 and simplifying we get

tanx = − 1

This equation has infinitely many solutions.


3π 3π

One of them is x = 4 x = 4 radians or 135 degrees .

3π 1 3π −1

sin
( ) 4
=
√2
and cos
( )
4
=
√2
.

Putting these values in esin x−cos x, we get e√2 or e1.414.

 7 votes -- Anurag Pandey ( 8183 points)

20.37 Mocktest: What will be the minimum value within a given range?
GATEFORUM_MOCKS top gateoverflow.in/38373

Which of the following is the right Procedure to get the minimum for f(x)?

Procedure 1: This is a closed interval, so we will have to calculate the value including and between [0,π/2].

To get critical points we do f'(x)=0. But here on f'(x) we get: -e-x-sin(x)=0, ie, there are no critical point and derivative
exists everywhere? So we will calculate the points where derivatives will be 0. Exponential will never be zero, so consider sin,
it will be zero only at point nπ/2.(here n=1)

Hence answer is π/2.

Procedure 2: If f'(x)<0, then it is minimum at that point. Here we are getting f'(x)<0 for [0,π/2] and inbetween points. So
are we supposed to substitute each value in f(x) from options to check which gives the minimum?

Which Procedure is right?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1977 of 2244

calculus maxima-minima engineering-mathematics mocktest

To find maxima or minima we need to equation differential to zero but the differential is never satisfied by any value in
[0,pi/2] so we only need to check if slope is positive or negative to find the maxima , it is always negative in [0,pi/2] so
the value at pi/2 is the minimum.

 0 votes -- Vikram Bhat ( 587 points)

20.38 Parabola: Volume generated by parabola about line [Gate 94] top gateoverflow.in/34714

The volume generated by revolving the area bounded by parabola y^2 = 8x and the line x = 2 about y-axis is....

A) 128π/5

B) 5/128π

C) 127/5π

D) None

EDIT: Following is the area we have to revolve. And answer is given as (A). And kindly explain the methodology to solve
such volumetric qstns if you get the answer. Thanx in advance :)

calculus integration parabola


Selected Answer

I think I get it correct

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1978 of 2244

 3 votes -- Praveen Saini ( 34299 points)

20.39 Study Resources: Which book is best for calculus? top gateoverflow.in/30147

Between Higher engineering mathematics and Gilbert Strang which one is more appropriate for GATE?

study-resources

I think Gilbert Strang's book is better..

You may also try reading I.A Maron book.

 0 votes -- Shashank Kumar ( 2029 points)

20.40 Virtualgate: Function f(x)=ax+b is strictly increasing iff? Virtual Gate


top gateoverflow.in/39017

The function f(x) = ax + b is strictly increasing iff

(A) a > 0

(B) a < 0

(C) a ≥ 0

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1979 of 2244

(D) a ≤ 0

Why not C? a>=0?

engineering-mathematics calculus virtualgate


Selected Answer

for strictly increasing f'(x)>0

f'(x)=a

so a>0

 4 votes -- Pooja ( 22773 points)

20.41 Virtualgate: For the function e^-x the linear approximation at aroung
x=2 is? Virtual Gate top gateoverflow.in/39026

How to solve this?

calculus engineering-mathematics virtualgate


Selected Answer

L(x)=f(a)+f '(a)(x-a) at x=a

=f(2)+f '(2)(x-2)

f(x)=e^-2

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1980 of 2244

f ' (x)= -e^-2

put values

e^-2 -e^-2(x-2)

e^-2[1-x+2]

e^-2[3-x]

 1 votes -- Tauhin Gangwar ( 509 points)

20.42 funtion top gateoverflow.in/38705

suppose a set A= { x/x ∈ N and X< 9 } and set B ={ x/x+5 = 8 and X∈ N }

1) how many one to one funtions are possible from set B to A

2) how many on to funtions are possible from set A to B

calculus


Selected Answer

A= { x/x ∈ N and X< 9 } |A| = 8


B ={ x/x+5 = 8 and X∈ N } |B| = 1

number of element in B = 1
number of element in A = 8

let B = {3}
A = { 1,2,3,4,5,6,7}
One One Functions From B ----> A are :
1. {(3,1)}
2. {(3,2)}
3. {(3,3)}
4. {(3,4)}
5. {(3,5)}
6. {(3,6)}
7. {(3,8)}
8. {(3,8)}

Onto Function : From A ---- > B


1. {(1,3) (2,3) (3,3) (4,3) (5,3) (6,3) (7,3) (8,3)}

Number of ONE ONE function from B---->A = 8


Number of ONTO function from A--->B = 1

 3 votes -- Digvijay Pandey ( 26245 points)

20.43 Given that α ≥ 0 and value of integral at α = 0 is 0. The value of gateoverflow.in/37766

top

Given that α ≥ 0 and value of integral at α = 0 is 0. The value of

xα −1

∫10 logx dx

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1981 of 2244

calculus

I = ∫( X^a -1)/log(x) dx

Use Leibnitz theorem

dI/da =∫ (X^a) log(x)/log(x)=∫ (X^a)=(X^a+1)/a+1

put the limit and get the ans as 1/a+1

 0 votes -- saurav04 ( 649 points)

20.44 Is the function differentiable at x=1 top gateoverflow.in/38763

The question is f(x) = | x-1 | + | x+1 | is differentiable at x=1 or not .

Now ,

when x<1 , the first part becomes : -(x-1) , i.e 1-x

and why should we not change the sign of second part ,i.e (x+1) ?

calculus


Selected Answer

Let us rewrite the function as :

{
−(x − 1) − (1 + x), if x ≤ − 1
f(x) = −(x − 1) + (1 + x), if −1 < x ≤ 1
+(x − 1) + (1 + x), if 1 < x

Hope it clears your doubt. If not, then take a value for each of the three intervals, put in the formula and convince
yourself that it is correct.

 2 votes -- Gaurav Sharma ( 1383 points)

Because it it addition? o.O How will you change the sign? from (x+1) to +(1+x)?

we are not changing the sign bcz x-1 is less than 1. we are changing it bcoz say, x=0.9999, then 0.9999-1=-0.00001,
which is a -ve value. after coming out of mod, it will be +ve.

 1 votes -- Tehreem Ansari ( 1327 points)

20.45 A function is defined over an open interval atleast at one point in this
interval, dy/dx is exactly?GATE_2013-EC,EE,IN top gateoverflow.in/39070

A function y= 5x^2+ 10x is defined over an open interval x = (1,2). Atleast at one point in this interval, dy/dx is exactly

(A) 20 (B) 25 (C) 30 (D) 35

calculus engineering-mathematics

Use lagrange mean value thm

F'(c)=f(b)-f(a)/b-a

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1982 of 2244

F(2)=40

F(1)=15

So there exist point c where derivative is 25

 3 votes -- Pooja ( 22773 points)

dy/dx = 10x + 10

x is in (1,2) i.e. x is NOT 1, NOT 2 but it is inbetween 1 and 2.

Put = 1/2 u will get dy/dx = 25

 2 votes -- Digvijay Pandey ( 26245 points)

20.46 Integration top gateoverflow.in/36673

calculus

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1983 of 2244

http://gateoverflow.in/37766/given-that-%CE%B1-%E2%89%A5-0-and-value-of-integral-at-%CE%B1-0-is-0-the-value-of

 0 votes -- Pyuri sahu ( 1237 points)

20.47 How to solve below integral ? top gateoverflow.in/36567

I=

On applying property that ∫ a f(x) dx=∫f(a-x) dx

I=

Now issue is that on LHS also I have I and on RHS also I have I after evaluating the above expression so how to resolve this
issue ?

20.48 Differentiate top gateoverflow.in/35669

20.49 Find the integral top gateoverflow.in/36270

∫5−5 ∣ x + 1 ∣ dx is ____

Solution Given : 26

My Solution : 25

Splitting the integral from -5 to 0 and 0 to 5

Please correct my mistake.

calculus


Selected Answer

∫5−5 | x + 1 | dx

= ∫ −1 5
−5 − (x + 1) dx + ∫ −1 (x + 1) dx

([ ] [ ] )
(x+1 )2 −1 (x+1 )2 5
2 2
= − +
−5 −1

( )( )
( −4 )2 62
2 2
= − 0− + −0

= 8 + 18

= 26

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1984 of 2244

 5 votes -- Praveen Saini ( 34299 points)

20.50 continuity top gateoverflow.in/36410

how to solve it


Selected Answer

at -1: x= -1 while x^4=1.

LHL != RHL.

Hence. Not continuous.

Not continuous=>not differentiable.

 1 votes -- Aspi R Osa ( 1305 points)

For continuity check following conditions:

Function y = f(x) is continuous at point x = a if the following three conditions are satisfied

1. f(a) is defined
2. lim x → a, f(x) exists (i.e., is finite)
3. lim x → a, f(x) = f(a)

Now according to question f(x) = x4 . When x = − 1, left lim=1, right lim = -1. lhl not equal to rhl and so not continuous. Not
continuous implies not differentiable.

 3 votes -- Khushboo Mishra ( 41 points)

20.51 f(x) continuous / differentiable ? top gateoverflow.in/35487

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1985 of 2244

calculus engineering-mathematics

At x = 0, the function takes 0/0 form. So, the function is not continuous at x = 0.

By mentioning f(x) = 1 at x = 0, an attempt has been made to make the function continuous. So, let us check whether at
lim x → 0, the function value equals 1 ?

1 +ex
x
Using L'Hospital's rule, it becomes x+e and putting x = 0, it is 2.

So, even after adding f(0) = 1, the function couldn't be made continuous.

Hence, the function is not differentiable too.

Answer is d.

 0 votes -- Gaurav Sharma ( 1383 points)

20.52 max no of saddle point.. explain top gateoverflow.in/28848

A n × n matrix is given and an element aij is called saddle point if all the element in the ith row are less than aij and all the
element in jth column are greater than aij. How many maximum no of saddle point are possible.

a. 2
b. 3
c. n
d. 1

engineering-mathematics

Just take the matrix. for 2 point to be saddler the conditions specified will say this. suppose u have two points of a column
as saddler point i.e. q and p .

if u consider 1 as saddler point then it's u must be saying that q>p

while if u have to say 2 also sadller point q<p . only one can happen at a time . make other case yourself and u wll get
this .

5 4 3

6 3 2

7 2 1

only 5 is sadler point as considering 6 should say that 6 should be least but 5 is least .

 0 votes -- Ravi Singh ( 7303 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1986 of 2244

20.53 Integration top gateoverflow.in/10432

value of integral in (1,2) is zero. that means interval (1,x) and (x,2) having area with different sign..

atleast one crossing.


atleast one real root..

 1 votes -- Digvijay Pandey ( 26245 points)

20.54 limit top gateoverflow.in/13609

limx->0 (cot x)1/logx ?

ans: 0(m getting 1/e)

1 1 ln (cot (x) ) 1
ln (x) ln (x)
ln (x)
limx→0 cot(x) = limx→0 e ×ln (cot (x) ) limx→0 = − 1 limu → −1 eu = e −1 = e

 0 votes -- Salman ( 615 points)

20.55 Calculus top gateoverflow.in/19778

http://gateoverflow.in/?qa=blob&qa_blobid=11477564903327944491

20.56 calculus top gateoverflow.in/25328

Differentiate with respect to x

1)sin-1(sin x) x∈[0,2π]

2)cos-1(cos x) x∈[0,2π]

3)tan-1(tan x) x∈[0,π]-{π/2}

Also find pts where function is not differentiable...


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1987 of 2244

The graphs for the 3 functions will be as follows:

Now we can precisely define and differentiate the functions in the given intervals using the above graphs as follow:

sin-1(sinx) = {
x when x ∈ [0, π/2]

π - x when x ∈ [π/2, 3π/2]

x - 2π when x ∈ [3π/2, 2π].

It can be seen from the graph of sin -1(sinx) that it is not smooth at x = π/2 and x = 3π/2.

Hence it is continuous but not differentiable at x = π/2 and x = 3π/2.

At all other points the function can be easily differentiated using the above definitions and we will get

1 when x ∈ [0, π/2) ⋃ (3π/2, 2π] and

-1 when x ∈ (π/2, 3π/2).

cos-1(cosx) = {

x when x ∈ [0, π]

2π - x when x ∈ [π, 2π]

It can be seen from the graph of cos -1(cosx) that it is not smooth at x = 0, x = π and x = 2π.

Hence it is continuous but not differentiable at x = 0, x = π and x = 2π.

At all other points the function can be differentiated using the above definitions and we will get

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1988 of 2244

1 when x ∈ (0, π) and

-1 when x ∈ (π, 2π).

tan-1(tanx) = {

x when x ∈ [0, π/2)

x - π when x ∈ (π/2, π]

The value of this function is not defined at x = π/2.

It can be seen from the graph of tan -1(tanx) that it is not continuous at x = π/2.

Hence it is neither continuous nor differentiable at x = π/2.

At all other points the function can be differentiated and we will get

1 when x ∈ [0, π/2) ⋃ (π/2, π].

How to draw the graphs?

for example consider sin -1(sinx)

1. Domain of this function will be the domain of (sinx) i.e. the set of all real numbers.

2. Range of this function will be the range of sin -1x i.e. [-π/2, π/2].

3. The function is bonded between [-π/2, π/2].

4. The inner function i.e. sinx of this composite function is a periodic function so the composition could be a periodic
function with same period.

5. Since both sin(x) and sin -1(x) are odd fuctions the composition should be an odd function.

6. sin -1 and sin are inverse of each other so intutively at least in some part of the graph, they should cancel the effect of
each other leaving behind only x.

7. Checking the value of function at various values of x.

All these ideas can be combined to get a rough idea about the graph of this functions, similarly for the other two functions
too.

 1 votes -- Anurag Pandey ( 8183 points)

20.57 CALCULUS top gateoverflow.in/9681

1/(2+e^(1/(x-3))) Is it continuous? where 2<e<3

discontinuous at x=3..
LHL = 1/2
RHL = 0
Value function = 0
LHL != RHL= value of function.

 1 votes -- Digvijay Pandey ( 26245 points)

20.58 Limits top gateoverflow.in/9340

Find lim x->infinity[5th root(2 5-24)-x]

a)-1/5

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1989 of 2244

b)1/5

c)π/4

d)None

20.59 2007 maths top gateoverflow.in/7596

Evaluate

20.60 Is the integral of second half i.e [π , 2π] being subtracted from that of
the first[0, π] ? Is it right to do so? top gateoverflow.in/7795



If 0 | x sinx | dx = kπ, then the value of k is equal to ______.

Integral is actually not subtracted. It is added. Just that the integrated value is negative. You can read the explanation.

http://gateoverflow.in/2040/gate2014-3_6?show=8807#a8807

 0 votes -- Arjun Suresh ( 124125 points)

20.61 maths_mocktest1_12 top gateoverflow.in/7854

A. 1

B. 2

C. 3

D. 4

calculus

I'm getting 2√ 5 . What's the correct answer?

 0 votes -- Salman ( 615 points)

20.62 integration top gateoverflow.in/25397

Please solve the following integration problem

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1990 of 2244

1
2
∫∞ −y3dx
0y e

I want full explanation. please help me ?

Take y 3/2 =t so that 3/2 y 1/2 dy=dt ,Also reverse the limit values from infinity to zero and place a negative sign Now ur
integration becomes as per this link , Now when u will evaluate it u will get the answer as 4/3

http://www.hostmath.com/Show.aspx?Code=-
2%2F3%5Cint_%7B%5Cinfty%7D%5E%7B0%7D1%2Fe%5Csurd%20t%20%20%20dt%0A%5CRightarrow%20%0A%0At%3Dx%5E%7
4%2F3%5Cint_%7B%5Cinfty%7D%5E%7B0%7Dxe%5E%7B-x%7Ddx%20

 0 votes -- radha gogia ( 4369 points)

20.63 integral top gateoverflow.in/25409

http://gateforum.com/wp-content/uploads/2013/01/EC-2005.pdf

question 35 .....

1
2
Here graph of function f(x) is something like f(x) = 1 + x (Even Function. )

2x
(1 + x2 )2
So we get f ′ (x) = − (odd function. )

So It is Symmetrical about opposite quadrant.

So by drawing graph of f ′ (x) , we get (C) Option.

 0 votes -- Jagdish Singh ( 287 points)

20.64 improper integral top gateoverflow.in/29063

http://www.questionpapers.net.in/Question%20Papers/gate-question-papers-download/gate-question-papers-download-
civil-engineering-2007.pdf

question 25....plz give it proper solution

e −ax sin(bx)
∞ x ∞ b
I(a, b) = ∫ 0 dx = ∫ 0 ∫ 0 e −ax cos(yx)dydx

e −ax

[ ]

b ∞ −ax ∞ a2 + y2 (ysin(yx) − acos(yx))
I(a, b) = ∫∫ 0 0
e cos(yx)dxdy = ∫ 0
dy
0

a b
I(a, b) = ∫
b y2
0
+ a2 dy = tan −1 a
()
sinx 1 π

I(0, 1) = ∫

0
x
dx = tan −1 ()
0
= tan −1 (∞) =
2

 0 votes -- Jagdish Singh ( 287 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1991 of 2244

20.65 bijection, surjection please confirm the ans top gateoverflow.in/29855

20.66 Made Easy FLT Advande Q 64 top gateoverflow.in/31564

Q.64

A function f (x) is differentiated twice such that its differential equation λ 2f (x) – 2λf ′(x) + f ′′(x) = 0 provides two equal
value of λ for all x. It f (0) = 1, f′(0) = 2, then f(x) at x = 1 will be _________.

Given ans ->

7.39 (7.00 - 7.80)

made-easy calculus

Go through my above solution...

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1992 of 2244

 1 votes -- Shashank Kumar ( 2029 points)

20.67 order and degree top gateoverflow.in/7592

The order and degree of the differential equation

(A) 3 and 2 (B) 2 and 3


(C) 3 and 3 (D) 3 and 1

Order is 3 and degree is 1.

Order of a differential equation is defined as the order of the highest order derivative of the dependent variable with
respect to the independent variable.

Degree is the highest power (positive integral index) of the highest order derivative involved in the given differential
equation.

REFERENCE

 0 votes -- Gowthaman Arumugam ( 1079 points)

20.68 Limit top gateoverflow.in/28567

is ans 1 ? solve plz

limx->∞ (1/sinx - 1/tanx)

=limx->∞ ((1-cosx)/sinx)

=limx->∞ (2sin2(x/2) / 2sin(x/2)cos(x/2))

=limx->∞ tan x/2

=tan ∞

= undefined

 1 votes -- srestha ( 11585 points)

20.69 integration 10[IN] top gateoverflow.in/25411

http://gateforum.com/wp-content/uploads/2013/01/IN-2010.pdf

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1993 of 2244

Question 21

The integral ∫∞ 6
−∞δ(t − )6sin(t)dt evaluates to

(A).6

(B).3

(c).1.5

(D).0

gate-2010-maths

Delta function is defined as

Note:its integral at x=0 is 1 also

Now as per ques ∫ δ(t-π/6) 6sin(t) dt=6sin(π/6)=3

 0 votes -- saurav04 ( 649 points)

20.70 definite integral top gateoverflow.in/25412

http://www.gate.iisc.ernet.in/gate-ques-2015/CE%20SET_2_GATE_2015.pdf

question 3

i m confusing about last few step

plz help me

eix=cos x + i sin x

e-ix=cos x - i sin x

given integral can be written as I= ∫eix/e-ix dx =∫e2ix dx

I=e2ix /2i

putting value 0 and π/2

we get e^π-e^0/2 i=(cos π+sin π-cos 0-i sin 0)/2i

=-2/2i

=-1/i

=i

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1994 of 2244

 1 votes -- Pooja ( 22773 points)

answer is i.

 1 votes -- Sayantan Ganguly ( 5061 points)

20.71 limit top gateoverflow.in/28564


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1995 of 2244

answer = option D

at large value of x the value of sinx will always be between −1, 1 while x will keep growing which is a denominator hence,

sinx
lim
x→∞ x
=0

 2 votes -- Amar Vashishth ( 17865 points)

20.72 area top gateoverflow.in/34543

Find Volume under surface z(x,y)=x+y and above the triangle defined in x-y plane by 0<=y<=x and 0<=x<=12


Selected Answer


Volume is calculate as V f(x, y) dy dx

so, ∫12 x
0 ∫0 z(x, y) dy dx

= ∫12 x
0 ∫0 (x + y) dy dx

y2

= ∫12
0 (xy + 2 ) | x0 dx

x2

= ∫12
0 (x
2 + 2 ) dx

= 2 ∫12 2
0 x dx

( )
3 x3
2 3 12
= |0

= 864

 2 votes -- Praveen Saini ( 34299 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1996 of 2244

21 Programming top
21.1 Ace Test Series: C recursive program top gateoverflow.in/35417

I am getting no option correct.. Am I missing something??

programming-in-c ace-test-series


Selected Answer

--n in every function call will decrease the value of n in the local scope of the function also.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1997 of 2244

 4 votes -- Utk ( 1385 points)

21.2 Ace Test Series: output of c program top gateoverflow.in/38971

programming-in-c ace-test-series


Selected Answer

when a number is preceded by 0 , it represents an octal number so %d will print the decimal equivalent of an octal
number like (40)8=32 in decimal so op is 32 ,

For hexadecimal we use 0x , then it would have been like (40) 16 = 64 .

 4 votes -- radha gogia ( 4369 points)

21.3 Ace Test Series: Bit shift C program top gateoverflow.in/37258

Ans is given as (D). But I am not getting it. If we consider HEX format, then it is giving me (A) and in normal format it is
giving 2240. Where's the problem??

programming-in-c ace-test-series

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1998 of 2244

0570 is in octal so in binary its 101111000 (In C language any numeral starting with 0 is octal and starting with 0x is
hexa)

when we do the first shift(>>4) it becomes 10111

now the next shift(<<6) makes it 10111000000

which is the octal equivalent of 2700

 0 votes -- Utsab ( 31 points)

21.4 Array Of Pointers: C Code with array of pointers top gateoverflow.in/37261

I am getting 'cd' , but answer is given as 'gh' . How come ??

programming-in-c array-of-pointers pointers ace-test-series

Its 'cd' only. With a compiler having int size of 4, it is giving 'gh'. So, with 2 bytes of size , it should give 'cd'.

 1 votes -- Tushar Shinde ( 1523 points)

21.5 Arrays: PDS: Two Dimensional Arrays top gateoverflow.in/34994

Consider the following program:


main (){
int i, j;
int A[p][q] = { {1, 3, 5}, {2, 4, 6} };
for (i = 0; i < m; i++)
for (j = 0; j < n; j++)
printf("%d", * (A[j] + i));
}

Assume m is number of rows and n is number of columns.

Find the OUTPUT printed by the above program.

a. 123456
b. 135246
c. 456456
d. 456789

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 1999 of 2244

programming-in-c arrays

21.6 Arrays: what is the starting address of A[49] ? top gateoverflow.in/9757

A one dimensional array A has indices 1....75.Each element is a string and takes up three memory words. The array is stored starting at location 1120
decimal. The starting address of A[49] is

A. 1167 B. 1164
C. 1264 D. 1169

I think the location of A[49] will be 1264 because location of A[49] is 1264= (1120+(48*3))as it takes three memory words.is this correct answer?Does each
memory word represents a single character? or am i doing something wrong?

arrays programming


Selected Answer

yes you are right ans is 1264

 3 votes -- supraja ( 525 points)

21.7 Arrays: Array implementation of matrix top gateoverflow.in/34919

If tthere are two lower triangular matrix A and B.A and transpose B are stored in C. by storing only non zero elements.what
should be the dimension of C.

And A[i][j]= C[i][j]

B[i][j]= C[i][j+1]

is also written in notes i dont know its a part of ques. or solution

I m not getting it what is actually asked here?

data-structure arrays

21.8 Arrays: What will be the O/P of the following C code? Virtual gate top
gateoverflow.in/38868

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2000 of 2244

algorithms arrays programming-in-c


Selected Answer

You will get a compile time error, because i is not defined. As there is no option for compile time error, hence option D

 3 votes -- Gaurav Sharma ( 1383 points)

21.9 Avl Tree: Drawing AVL tree top gateoverflow.in/36191

I am stuck after JAN. It is not getting balanced even after 2 rotations. Can somebody help?

avl-tree data-structure ace-test-series

Answer is (c) Mar, try assigning numbers in place of months that will make it easy to solve and find result.

 1 votes -- Gaurav Rawat ( 55 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2001 of 2244

21.10 Avl Tree: VIRTUALGATE II Q.18 Find the root of the AVL tree. ? gateoverflow.in/37975

top

virtualgate data-structure avl-tree

Answer will be 27. Here is the explanation.

 2 votes -- Rude Maverick ( 3063 points)

27...

 1 votes -- Deepesh Kataria ( 1207 points)

21.11 Avl Tree: Insert elements in AVL tree so that it doesn't have any
rotation top gateoverflow.in/36534

The number of ways we can insert elements { 1, 2, 3, .... 7 } to make an AVL tree, so that it does not have any rotation are
_______ ?

avl-tree data-structure made-easy

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2002 of 2244

with 3 as root we are able to create 8 trees which are balanced BST. With 4 as root we can create just one balanced BST
and with 5 as root we can create again 8 BST. Hence 17 BST should be the answer

 1 votes -- ROHIT CHANDRA ( 47 points)

with 3 as root we can insert in 8 different combinations of avls as {3} {2,6}{1,5,7}{4} ;

{3}{1,6}{2,5,7}{4};

{3}{2,5}{1,4,6}{7} ;

{3}{1,5}{2,4,6}{7};

{3}{2,6}{1,4,7}{5};

{3}{1,6}{2,4,7}{5};

{3}{2,5}{1,4,7}{6};

{3}{1,5}{2,4,7}{6};

where each of the combination permute in 2!*3! =12 ways

this gives total of 12*8 i.e. 96 insertion sequence s with 3 as root

with 4 as root, balanced avl only kind of AVL is created and sequences is {4}{2,6}{1,3,5,7} which gives 48 permutations

with 5 as root we have 8 insertion sequence with 12 permutations in each {same as 3 as root} i.e. total of 12*8 i.e 96
sequence.

So total ways to insert keys in AVL without rotation is 48 +2*96 i.e 48+ 192 i.e. 240..................

 1 votes -- Abhishekcs10 ( 1001 points)

21.12 B Tree: B+tree top gateoverflow.in/44099

26 . A / B+ tree index is to be built on the name attribute of the relation STUDENT. Assume that all students names are of
length 8 bytes, disk block are of size 512 bytes and index pointers are of size 4 bytes. Given this scenario what would be the
best choice of the degree (i.e. the number of pointers per node) of the B+ tree ? (A) 16 (B) 42 (C) 43 (D) 44

data-structure b-tree

(p-1)K+p*Bp<=Block Size

(p-1)8+ P*4=512

12p=520

p=43

 0 votes -- Manojk ( 3365 points)

21.13 Barc2016: Output of c program top gateoverflow.in/41330

void fun(int *p)

int q = 10;

p = &q;

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2003 of 2244

int main()

int r = 20;

int *p = &r;

fun(p);

printf("%d", *p);

return 0;

programming-in-c barc2016 pointers


Selected Answer

The answer is 20.

because the pointer p in main and pointer p in function are different having different addresses... the p in function is local
to the func()

you can refer this:-

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2004 of 2244

 3 votes -- Nishu ( 433 points)

21.14 Binary Tree: Binary Search Tree top gateoverflow.in/15802

A set of n-distinct element and unlabelled binary tree with n nodes is given. In how many ways we can populate the tree
with given set so that it become BST

A 1

B 0

c n!

D 2ncn/(n+1)

binary-tree

Just the simple logic is that we have 2nCn/(n+1) unlabelled trees , now each unlabelled tree will always correspond to one
BST , consider 1,2,3 now say you draw a right skewed unlabelled tree , now u can label it only in one way 1 2 3 to form a
BST , if say u draw a left skewed unlabelled tree , then u can label it as 3 2 1 , to form BST therefore each unlabelled tree
gives rise to only 1 BST.

But in the question it is already given that we are provided with one unlabelled tree therefore there is only 1 way in which
we can populate it to form a BST therefore answer is option A .

 0 votes -- radha gogia ( 4369 points)

21.15 Bst: Binary Search tree top gateoverflow.in/37418

A binary search tree was constructed by inserting following elements into an initially empty binary tree.
50, 27, 16, 88, 34, 65, 52, 77, 93, 4, 12, 29, 44, 92
Preorder and postorder traversals of the resultant binary search tree were stored in arrays A and B respectively. The length of LCS present in these to array A and B ___________.

Everything is ok here,, But not getting how length of LCS is calculated here.

data-structure bst


Selected Answer

Preorder : 50 27 16 4 12 34 29 44 88 65 52 77 93 92

Postorder : 12 4 16 29 44 34 27 52 77 65 52 93 88 50

The LCS will be 16 29 44 52 77 93

 0 votes -- Shuvam Bosana ( 91 points)

21.16 Compiler Tokenization: How is escape sequence tokenised in c


compiler. top gateoverflow.in/19846

How tokens are assigned for a string having escape sequence in C lexical phase

Eg..

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2005 of 2244

printf ("this\" is a string\"");

and what for

printf ("this is""a string");

compiler-tokenization


Selected Answer

Token 1: this" is a string"

Token 2: this isa string

Adjacent string constants are concatenated.

 0 votes -- Arjun Suresh ( 124125 points)

21.17 Confusing: doubly linklist top gateoverflow.in/40491

N items are stored in a sorted doubly linked list. For a delete operation, a pointer is provided to the record to be deleted. For a decrease-key
operation, a pointer is provided to the record on which the operation is to be performed. An algorithm performs the following operations on the
list in this order:
Θ(N) delete, O(log N) insert, O(log N) find, and Θ(N) decrease-key
What is the time complexity of all these operations put together

(A) O(Log2 N)
(B) O(N)
(C) O(N2 )
(D) Θ(N2 Log N)

compexity should be O(N+logN+logN+N) = O(N) but ans is C.please explain??

linked-lists time-complexity confusing

time taken to delete N elements is N^2 and time taken insert N elements is NlogN lly for all operation

so time complexity for all operation together is O( N^2)...............

 0 votes -- khamer ( 385 points)

21.18 Divide And Conquer: ISICAL MTech 2014 CS top gateoverflow.in/27885

How many asterisks ( ∗ ) in terms of k will be printed by the following C function, when called as count(m) where m = 3k ? Justify
your answer.

Assume that 4 bytes are used to store an integer in C and k is such that 3k can be stored in 4 bytes.

void count(int n){


printf("*");
if(n>1){
count(n/3);
count(n/3);
count(n/3);
}
}

programming-in-c recursion divide-and-conquer isi-2014

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2006 of 2244


Selected Answer

I tried it for 3 5 ,

in every call it print "*" one time

and each function call 3 functions for n/3 recursively till get 1 at each node . it becomes a ternary tree

call for 3 5 -----------------------1 = 30

call for 3 4 -----------------------3 = 31

call for 3 3 ---------------------9 = 32

call for 3 2 --------------------27 =33

call for 3 1 ---------------------81 = 34

call for 3 0 --------------------243 = 35

so one "*" print at each function call

no of "*" printed = 3 0 +31 +32 +......3k [ that makes GP series ]

= 1 * (1 - 3 k+1 )/(1-3)

= (3k+1 -1 )/2

[ Note : I am not sure about it , feel free for edit ]

 2 votes -- Praveen Saini ( 34299 points)

21.19 Functions: What will be the output, Please explain? top gateoverflow.in/43006

void f(int n){


if(n <= 1){
printf("%d", n);
}
else{
f(n/2);
printf("%d", n%2);
}
}

programming-in-c functions


Selected Answer

This will print Binary equivalent of number n. It will keep dividing by two, the number until it will reach to 1 or 0. Then
it start printing in reverse.

The reverse order comes from the fact that its a head Recursion (A recursion is called head recursion when function get
called before print statement).

For example if we call this f(10) then it will print 1010.

 3 votes -- Rude Maverick ( 3063 points)

21.20 Geeks: Which of these programs are possible in C++/Java without the
use of File I/O ? top gateoverflow.in/41311

P1: A program can print its source code once.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2007 of 2244

P2: A program can print its source code twice.


P3: A program takes an input n and prints its source code n number of times.

Which of these programs are possible in C++/Java without the use of File I/O ?

Options:

A. P1 possible
B. P1 and P2 possible.
C. None Possible.
D. All are possible

Option can be different

barc2016 programming others geeks

First you should notice that File Input/Output is not allowed. If its allowed then option (D) would be the correct answer.
But as its not allowed hence it will not be the answer.

Correct answer is (B). Here is the explanation. A computer program which print it's own source code is called quine.

A quine is a non-empty computer program which takes no input and produces a copy of its own source code as its only output. The standard terms for
these programs in the computability theory and computer science literature are "self-replicating programs", "self-reproducing programs", and "self-
copying programs".

It can print twice or thrice. But number of times should be fixed. It can not take input from user. Hence P3 will not be possible.

 2 votes -- Rude Maverick ( 3063 points)

21.21 Graph Algorithms: leaf constrained minimum spanning tree top gateoverflow.in/40516

what is the suitable algorithm for the construction of leaf constrined minimum spanning tree .

graph-algorithms

21.22 Hashing: Quadratic probing top gateoverflow.in/34505

Consider a hashing function that resolves collision by quadratic probing .Assume the address space is indexed from 1 to 6.
Which of the following locations will never be probed if a collision occurs at position 5 ?

A). 4

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2008 of 2244

B). 5

C). 8

D). 6

Ans:

Ans Explanation:

f(key) = key % 6 + 1 → it locates from 1 to 6 collision

Quadratic probing → (5 + 12 )%6 + 1 = 1

→ (5 + 22 )%6 + 1 = 4

→ (5 + 32 )%6 + 1 = 3

→ (5 + 42 )%6 + 1 = 4

→ (5 + 52 )%6 + 1 = 1

→ (5 + 62 )%6 + 1 = 6

→ (5 + 72 )%6 + 1 = 1

→ (5 + 82 )%6 + 1 = 4

→ (5 + 92 )%6 + 1 = 3

so the 5th location is never probed

Here why we are adding 1 to find f(key)?

data-structure hashing

Because address space is indexed from 1 to 6. If you get 0 after some modulus operation and you don't have zero as any
location. Therefore, 1 is added.

 2 votes -- Monanshi Jain ( 5827 points)

21.23 Heap Sort: heap sort top gateoverflow.in/40684

The number of elements that can be sorted in O(logn) time using heap sort is


(A)

(B) (C) (d)

Answer: (C)

please explain why??

heap-sort algorithms sorting


Selected Answer

Option c:Time taken to sort logn/loglogn elements

=logn/loglogn * log(logn/loglogn )

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2009 of 2244

=logn *loglogn-logn*logloglogn /(loglogn)

=logn - logn*logloglogn /(loglogn)

second term is (logn*(logy /y)) where y=loglogn and logy/y <<1 so second term is <<logn, second term can be
ignored

=O(logn)

 0 votes -- Anurag Semwal ( 4775 points)

21.24 Identify Function: What will be the output of right shift? top gateoverflow.in/37315

Consider the C function func shown below:

int func(int num) {


int count = 0;
while (num) {
count++;
num>>= 1;
}
return (count);
}

The value returned by func(0235) is ________

functions identify-function


Selected Answer

In C language an integer constant starting with a 0 is treated as octal. So, 0235 = 157 in decimal. Now, the code is giving
the position of the most significant bit in the binary representation of the number. 157 = (10011101)2 , so, MSB is at position
8.

 4 votes -- Arjun Suresh ( 124125 points)

21.25 Linked Lists: which statement is true about doubly linked list? top gateoverflow.in/10256

linked-lists


Selected Answer

Double linked list may contains a cycle of length less than n where n is no of nodes .. that linked list neither linear nor
circular..
Extra space required for Back Pointer storage..

 3 votes -- Digvijay Pandey ( 26245 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2010 of 2244

21.26 Linked Lists: linked list top gateoverflow.in/37057

What does the following function do for a given Linked List with first node ashead?

void fun1(struct node* head)


{
if(head == NULL)
return;

fun1(head->next);
printf("%d ", head->data);
}

will it print 5-4-3-2-1 or 4-3-2-1 if i/p is 1-2-3-4-5?Will the last 5 get printed or not ,
due to return;

linked-lists

21.27 Linked Lists: Linked list top gateoverflow.in/38802

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2011 of 2244

linked-lists

P1 ----> P1 --> Next


P2 ---> P2 --> Next --> Next

Everytime when P1 cross 1 element, P 2 will cross 2 element.


P2 will be null then P 1 will be at position (length of LINKED LIST)/2 i.e. Middle of the list.

 1 votes -- Digvijay Pandey ( 26245 points)

21.28 Loop: programing top gateoverflow.in/42098


int main(){
int a;
a = 1;
while(a-- >= 1)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2012 of 2244

while(a-- >= 0);


printf("%d", a);
}

programming-in-c loop


Selected Answer

intially a=1 then due to inside while loop use post decrement operator which means firstly assign the value then
decrement so firstly

while(1==1)true the decrement 'a' by 1 then a become 0 then while(0=0) true then 'a' decrement by 1 by which a=-1
then go inner while loop while(-1=0) false then decrement then a=-2 then go outer while loop again condition false and
finally 'a' become -3

so answer is a=-3

 3 votes -- rajan ( 1287 points)

21.29 Loop: What is return value of BSR Routine ? top gateoverflow.in/28973

Consider the following function.

Assume that the array contains list of all the numbers from 1 to k –1. What is the return value of function BSR?

Sum of all numbers


Repeated number in the list
Average of all the numbers
None of these

------------------------------------------------------------------------------------------------------------------------------------------------
-----------------

Here I think answer should Be D, None of these, as as per me this program will add up all no from 1 to k-1. i.e. (k-1 * k ) /2
in value & substracting last from it which is also (k-1*k) /2 . So it will always return 0.

Q 37

Made Easy FLT 6-Practice Test 14

programming loop functions

Assume that the array contains list of all the numbers from 1 to k –1. // main line

i.e. we have two take all no. form 1- k-1 when no. of values are k.

take random input

k= 7

1,2,3,4,5,6,6

now For loop find sum of all array element= 27

now last = 7(6)/2= 21

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2013 of 2244

return = 27-21= 6

so 6 is repeated.

 1 votes -- Anirudh Pratap Singh ( 4091 points)

21.30 Memory Management: why is there a difference in the execution gateoverflow.in/4011

top

i am doing strcpy from a larger string into a relatively smaller string using two ways.According to me
both the methods allocate space statically(as i am not using any malloc or calloc in either of my cases).
but still method1 gives me segementation fault(in ubuntu) or just cracshes the exe generated (in
windows),i.e i am trying to access area out of my way, while method2 doesn't . why?

method 1:

char *a = "hi";
char *b = "hisi";
try
{
strcpy(a, b);
cout << "all ok";
}
catch (exception e)
{
cout << "error";
}

method2:

char a[3] = "hi";


char b[5] = "hisi";
try
{
strcpy(a, b);
cout << "all ok";
}
catch (exception e)
{
cout << "error";
}

programming-in-c programming memory-management


Selected Answer

char *a = "hi";

Here you are declaring a pointer a, and assigning a value to it which is the address of "hi". "hi" is a string literal here
meaning it is nothing but a constant. So, compiler stores this string in a READ ONLY (RO data segment) region as string
literals are not meant to be modified. So, if we try to modify this memory region (by strcpy or any other means), OS won't
allow it.

char a[3] = "hi";

Here variable a is allotted memory for storing 3 characters and the characters 'h', 'i' and '\0' are stored to it. Since scope
of a is "auto", this allocation happens in stack and programmer is free to modify this memory location with in the function.
But there is memory for only 3 characters. If using strcpy more than 3 characters are assigned, behaviour is undefined-
sometimes it might work if there are some unused memory given by the compiler, sometimes it might crash due to
memory corruption by writing to unallocated memory or sometimes program might give wrong output by modification of
unintended memory locations.

 2 votes -- Arjun Suresh ( 124125 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2014 of 2244

21.31 Minimum Spanning Trees: MSTs the graph have? top gateoverflow.in/39013

minimum-spanning-trees graph-theory


Selected Answer

Among E, Band C, you can choose exactly two edges, because choosing less than 2 edges will make the tree disconnected
and choosing 3 edges will add a cycle to the tree. Hence, there are 3 C2 = 3 ways. Similarly, there are 3 ways to choose
edges from A, Dand E. So, total possible ways = 3 ∗ 3 = 9.

 3 votes -- Gaurav Sharma ( 1383 points)

21.32 Output: What is the output of the program ? top gateoverflow.in/42322

#include<stdio.h>
int main()
{
7 printf("%c\n", ["IndiaBIX"]);
0 return ;
}
Please explain how the output is X ? I know while counting in Array will make X . But how this CODE works.........>>?

programming-in-c output


Selected Answer

working like
char a[]="IndiaBIX";
printf("%c\n", 7[a]);

here 7[a]=a[7]

 3 votes -- Manojk ( 3365 points)

Well in C, a[i] always gets translated to *(a + i)

so *(a + i) = *(i+ a)

a[i] = i[a]

hope you get it :)

 1 votes -- Neelay Upadhyaya ( 49 points)

21.33 Parameter Passing: Find the value of Z top gateoverflow.in/26757

P(X:integer,Y:integer) {

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2015 of 2244

X = 6;
A = 8;
return ( X + Y )
}

if the function P were invoked by the following program fragment.



k = 1;
L = 1;
Z = (K, L);

Then the value of Z would be?

where X=call by reference and Y=pass by value

programming parameter-passing

21.34 Parameter Passing: What will be the second value printed by the
program if parameter passing mechanism is call by reference? top gateoverflow.in/4481

What will be the second value printed by the program if parameter passing mechanism is call by reference?

int b=10 //global


begin
procedure func(int x,int y)
begin
print(b)
x=x+b
y=y+b
end
int a=10;
int b=20;
func(a,a);
print(a);
end

programming parameter-passing


Selected Answer

Static scoping: Here if a variable is not in local scope, it is looked in global scope.

So, b in func() is the global b. So, 10 is printed. a is incremented by 10 when x = x + b, (due to pass by reference) and a
is again incremented by 10 when y = y + b. So, print(a) will print 30.

Dynamic scoping: Here if a variable is not in local scope, it is looked in the function which called the current one.

So, b in func() is the b from main. So, 20 is printed and a is incremented two times by 20 and final print(a) will print 10 +
20 + 20 = 50.

 0 votes -- Arjun Suresh ( 124125 points)

21.35 Parameter Passing: Consider the following program top gateoverflow.in/4992

int i = 1;
int main()
{
int a[]= { 0,1, 2} ;
f(a[i], i);
printf("%d", a[i]);
}
void f(int x, int y)
{
y++;
x=5*i;
}

In above function f() uses " call by name" technique, what is the output printed?

a) 2 b) 10 c) 5 d) 1

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2016 of 2244

programming parameter-passing


Selected Answer

Using a C style creates confusion for call by name. The scope of variables comes from the function where it is called
(dynamic scoping) in call by name.

y++; i becomes 2

x = 5*i; a[2] becomes 10.

So, 10 should be printed.

 5 votes -- Arjun Suresh ( 124125 points)

The output printed is 1 i.e., option d). The function f() doesn't return any value neither does it make changes in the
original value of a[i] and hence no matter what goes inside the body of f(), the output will be the initial value of a[i] i.e.,
1.

 2 votes -- Shyam Singh ( 1357 points)

D should be the answer. this is call by value so a[i] is unchanged.

 1 votes -- venus22 ( 27 points)

option b .

as per concept of macro implementation in c,

http://www.cs.rit.edu/~rpj/courses/plc/lab4/lab47.html#Q12

 1 votes -- sumit kumar singh dixit ( 1625 points)

21.36 Parameter Passing: Consider the following code top gateoverflow.in/4993

void main()
{
int x=10, y=5;
swap(x,y);
print(x,y);
}
void swap(int a, int b)
{
int c, x=0;
c=a;
a=b;
b=c;
}

what is output using call by text?

a) 5 0

b) 5 10

c) 10 0

d) 10 10

programming parameter-passing

according to the concept of inline functions... that is how we represent the the concept of call by text or call by name in c

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2017 of 2244

++

answer should be:

option A: 5 0

but as per the concept of macros in c i am still not clear for the correct answer for this.

here is a link for anyone who wanna go through the details of this:

http://www.cs.rit.edu/~rpj/courses/plc/lab4/lab47.html#Q12

 0 votes -- sumit kumar singh dixit ( 1625 points)

21.37 Pointers: C program top gateoverflow.in/30772

why this function not do swapping


#include <stdio.h>
void swap(char *str1, char *str2) {
char *temp = str1;
str1 = str2;
str2 = temp;
}
int main() {
char *str1 = "Gate";
char *str2 = "Overflow";
swap(str1, str2);
printf("str1 is %s, str2 is %s", str1, str2);
return 0;
}

Output :
str1 is Gate, str2 is Overflow

programming-in-c pointers


Selected Answer

In this function whatever the exchange you are doing, is local only since str1, str2 and temp char pointers are local to
swap() function.That is the reason your swap function is not working.

 2 votes -- Sandeep Singh ( 5939 points)

21.38 Pointers: Find the output of the following c code - top gateoverflow.in/15319

find the output of the following c code-

main()
{
char *ptr="gatebuddy";
*(ptr)++;
ptr++;
printf("%s\n",ptr);
}

programming-in-c pointers


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2018 of 2244

char *ptr="gatebuddy"; // ptr is a pointer variable pointing to a string literal 'gatebuddy'. C by default adds a null
character (\0) at the end of any string literal.

*(ptr)++; // ptr point 2nd element of string literal 'gatebuddy' as postincrement has higher precedence than
indirection.

Ref: http://en.cppreference.com/w/c/language/operator_precedence

ptr++; // ptr point 3rd element of string literal 'gatebuddy'

printf("%s\n",ptr); //it ll print all character of string from 3rd element to that index where null character is stored.

i.e. it will print tebuddy

 4 votes -- Digvijay Pandey ( 26245 points)

21.39 Pointers: Pointers top gateoverflow.in/10902

Now I suppose if i have a statement like *P++ then it is broken down as first (P++) and then *p

(because both are unary operator and associtivity is right to left )

and if we have statement like a=*p++ then it is broken down into a=*p and then p is incremented !!

Am i right ?

pointers programming-in-c

Postfix operator having higher priority than dereferencing operator.

so P++ (dont increment P, use P value as it is . after whole operation increment it).

Then a = *P

Now P++..

Postfix is left to right associative while * is right to left.

 2 votes -- Digvijay Pandey ( 26245 points)

Case 1:

int a,b ;
int *p =&b;
b=9;
printf("%d",*p++);

Case 2:

a=*p++;
printf("%d",a);

Both are giving op 9 only

 1 votes -- radha gogia ( 4369 points)

21.40 Pointers: What is ouput will be printed in array , if following code


performed top gateoverflow.in/27917

Main () {
int a [3] [4] = $\begin{pmatrix}
1&2&3&4 \\
5&6&7&8 \\
9&10&11&12 \\
\end{pmatrix}$
printf ("\n% u% u% u", a[0]+1, * (a[0] + 1),

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2019 of 2244

*(*(a + 0)+1));
}

What is the output of the above program? Assume array begin at address 10.

arrays pointers

12, 2 , 2

first will print address of 1st row 2st column element which is 10 +2= 12

second will print value at that address i.e. 2

Third is same as second i.e. different expression = 2

 1 votes -- Anirudh Pratap Singh ( 4091 points)

21.41 Pointers: Output and please explain top gateoverflow.in/40728

#include<stdio.h>

int main()

char *s = "Geeks Quiz";

int n = 7;

printf("%.*s", n, s);

return 0;

programming-in-c pointers arrays

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2020 of 2244


Selected Answer

OUTPUT: Geeks Q

EXPLANATION

char *s = "Geeks Quiz";

Store the string "Geeks Quiz" in memory and stores the base address in pointer s.

printf("%.*s",n,s);

1. .number: Its a precision which specifies the minimum number of character/digits to be printed.
2. .*: The precision is not specified in the format string, but as an additional integer value argument preceding the
argument that has to be formatted.
3. Therefore, the above line will print 7 characters (as specified by n) of string s.

SOURCE: Tutorials Point (Click on link to read more about formatting in printf)

Ouput after executing the above code on Ideoneis here.

 3 votes -- Prateek Dwivedi ( 845 points)

21.42 Pointers: what will be the output? top gateoverflow.in/340

#include<stdio.h>
#include<stdlib.h>
int main()
{
struct xx
{
int x;
char s;
};
struct xx *t;
t->x=5;
t->s='a';
printf("%d %c\n", t->x, t->s);
}

pointers easy


Selected Answer

struct xx *t;
//Here t is a pointer to struct xx
t->x=5;
Assigns 5 to the int part of struct xx object pointed to by t. But t is not assigned any struct xx object to point to. So, this is doing invalid memory access and
should result in segmentation fault.

(similar to int *p; *p = 5;)

 1 votes -- gatecse ( 9515 points)

21.43 Pointers: consider following code segment in c top gateoverflow.in/20152

consider following code segment in c

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2021 of 2244

main()

char * z="abc";

z[0]='x';

printf("%s",z);

what will be behavior of the program

a>compiler error b>runtime error c>no error prints xbc

d>no error prints abc

programming-in-c pointers

If contents of string constant is modified, the behavior is undefined in C.

 0 votes -- Monanshi Jain ( 5827 points)

21.44 Pointers: I have been struggling with pointers in multi-dimensional


arrays. Please help me with this code :- top gateoverflow.in/100

Explain the output :-

int b[3][4] = {{1,2,3,4}, {5,6,7,8}, {9,10,11,12}};


int** p;
p = (int**)b;
cout << (long)*p << "\t" << (long)(*p+1) << "\t" << (long)(*p+2);

//long is used to print the output in decimal format instead of hex

programming programming-in-c pointers non-gate


Selected Answer

Here, b is a 2D array and it contains 3*4 = 12 elements. Suppose address of b starts from 1000. Now the elements will be
stored as:

1000-3: 1
1004-7: 2
1008-11: 3
1012-15: 4
1016-19: 5
....
1045-48: 12

Now, we declare p as int** and initialize it to 1000, the base address of b.

So, *p will have 1. (assuming a 32 bit architecture, on 64 bit architecture *p will be 8 bytes and the array element being
int is only 4 bytes)

Now, *p+1, is pointer arithmetic. It will add 1 *sizeof(int) to *p. So, *p+1 will give 1 + 4 = 5. (This 5 is not the element
5 in the array)

Similarly, *p+2, will add 2*sizeof(int) = 2*4 = 8 to *p. So, *p+2 will give 1+8 = 9.

These are all valid only on a 32 bit compiler. On a 64 bit compiler, if we use

(long)*p

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2022 of 2244

It will try to read 8 bytes from the start of the array.


Since,
1000-3: 1
1004-7: 2

From 1000, the content of memory will be (assuming a little endian machine)
0000 0001 0000 0000 0000 0000 0000 0000 | 0000 0010 0000 0000 0000 0000 0000 0000

This value in binary will be


0000 0010 0000 0000 0000 0000 0000 0000 0000 0001
= 233 + 1
= 8589934593

So, the output will be 8589934593, 8589934597 and 8589934601

This output is entirely implementation dependent as it depends on the sizeof (int) and sizeof pointer and also depends on the endianness of the machine(if sizeof
(int) is different from sizeof pointer) .

For more details about pointer arithmetic you can see here:
http://gatecse.in/wiki/Chapter_3:_Pointers#Pointer_Arithmetic

 4 votes -- Arjun Suresh ( 124125 points)

21.45 Pointers: ISRO_A 2015/72 top gateoverflow.in/19444

Consider the following declaration:

int a, *b=&a, **c=&b;

The following program fragment

a=4; **c=5;

a) does not change the value of a

b) assigns address of c to a

c) assigns the value of b to a

d) assigns 5 to a

pointers programming-in-c


Selected Answer

answer = option D

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2023 of 2244

 3 votes -- Amar Vashishth ( 17865 points)

21.46 Pointers: C pointer doubt top gateoverflow.in/41390

What is the difference when I write in program



mynode * head;
add_node(&head,10);

add_node( struct node ** head, into value);

To this

mynode *head;
add_node (head,10);
add_node( struct node* head, into value)

Which is the correct way of writing?

programming-in-c pointers


Selected Answer

Both can be used, Although first is considered better due to certain flexibility available inside the function to change where
head will point.

In first case , you are sending a double pointer(address of head pointer) to function as argument, so you can change
value of head pointer(where head is pointing) using

void test_Func(struct Node **head) //Func Definition


{
*head=sm addr;
}
test_Func(&head); //Func Call

In second case, directly changing head inside function is not possible as it's the value of head pointer itself that you are
passing so you cannot access its address to change it(head is just a local var containing address pointed by head and not
address of head itself) . To change it you can return new head value (an address essentially) at end and at the place of
fun call reassign to head pointer.
struct Node * test_Func(struct Node *head) //Func Definition
{
head=sm addr;
return head;
}
head= test_Func(head); //Func Call

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2024 of 2244

 3 votes -- Anurag Semwal ( 4775 points)

add_node( struct node ** head, into value)

is correct way.double pointer will help you to directly modify conents of head pointer in main function.

FOR SIMPLICITY ASSUME *head as some variable of type int.

so now you are passing address of this variable to the function,

add_node( struct node* head, into value) is wrong.to make this correct you should reuturn new address that your function
modified and assign this address as a new head.

head = add_node( struct node* head, into value)

 1 votes -- viv696 ( 1431 points)

21.47 Programming In C: solve it top gateoverflow.in/14933

int main()
{
int a;
char *x;
x = (char *) &a;
a = 512;
x[0] = 1;
x[1] = 2;
printf("%d\n",a);
return 0;
}

output?
A. M/C dependent
B. 513
C. 258
D. compiler error

programming-in-c non-gate


Selected Answer

A. Machine dependent.

x = (char *) &a;
a = 512;
x[0] = 1;
x[1] = 2;

Here, we modify the first and second bytes from the starting location of a. So, this modification depends on whether the
machine is little endian (LSB stored at lowest address) or big endian (MSB stored at lowest address).

Assuming Little endian and 4 bytes for int, we would be getting:

Initial content of a

0 0x02 0 0

Final content of a

0x01 0x02 0 0 = 2 * 256 + 1 = 513

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2025 of 2244

Assuming Big endian and 4 bytes for int, we would be getting:

Initial content of a

0 0 0x02 0

Final content of a:

0x01 0x02 0x02 0

(Here MSB is on left)

= 1*256^3 + 2*256^2 + 2*256 = 16, 908, 800

 1 votes -- Arjun Suresh ( 124125 points)

21.48 Programming In C: What is the output of the following C code? gateoverflow.in/18864

top

int main (){ int a=5,b=3; printf("%d", a+++++b); // 5 +'s }

Please Explain.

programming-in-c

see this code :


#include<stdio.h> int main (){ int a=5,b=3; printf("%d", a++++); // 5 +'s }

Now here see the analysis first we have a++ ,no issue we got a=5 ,now what I did is 5++ which is blunder since post-
increment returns rvalue and for any further operation I need lvalue for it ,therefore it is an error post-increment .

Also you can see that when we write a++ it is evaluated as a=a+1 ,but when we write 5++ it makes no sense since it
would be 5=5+1 ,which is invalid ,hence lvalue required

please refer to this link once .

http://stackoverflow.com/questions/17440117/confused-with-pre-and-post-increment-operator

 0 votes -- radha gogia ( 4369 points)

21.49 Programming In C: What is the output of the program ? top gateoverflow.in/18577

int main(){ char *ptr = "gateexam"; printf("%c\n", *&*&*ptr); return 0; }

(a) Compiler Error


(b) Garbage Value
(c) Runtime Error
(d) g

*please explain it.

programming-in-c


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2026 of 2244

∗ is used for de-referencing and the operator & is used to get the address.

These operators cancel effect of each other when used one after another. We can apply them alternatively, any number of
times.

For example,

∗ ptr gives us ‘‘g " (It points to the first address).


& ∗ ptr gives the address of g since & gives address.
∗ & ∗ ptr again gives us ‘‘g " .
& ∗ & ∗ ptr gives the address of g, and finally,
∗ & ∗ & ∗ ptr gives ‘‘g "

 1 votes -- Umang Raman ( 10379 points)

21.50 Programming In C: Scoping and Call by Need evaluation top gateoverflow.in/18631

Find the output of the below program in case of Dynamic Scoping with call by need evaluation method

int x=10,y=10;

main()

int x=2;

int y=3;

fun1(x+y,5);

printf("x");

fun1(int z,int k)

k=z+k;

programming-in-c

Output --> x , for call by need , Refer--> http://stackoverflow.com/questions/8701834/call-by-need-vs-call-by-


name & Call by need --> https://en.wikipedia.org/wiki/Evaluation_strategy

 0 votes -- Vinay Yadav ( 1739 points)

21.51 Programming In C: Difference in printing the address using %d and


%u format specifier ? top gateoverflow.in/15318

I went through this article but couldn't get one point where it says that

"It only makes a difference if the integer is negative (for signed inputs) or between INT_MAX+1 and UINT_MAX (e.g. between 231 and 232-1). In that
case, if you use the %d specifier, you'll get a negative number, whereas if you use %u , you'll get a large positive number."

I am not getting how can an address value be negative ?

http://stackoverflow.com/questions/5208641/difference-between-printing-a-memory-address-using-u-and-d-in-c

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2027 of 2244

programming-in-c

I'm explaining assuming int is of size 4, but only the minimum size of 2 is guaranteed by C standard. Still, in all real C
compilers, 4 is the default now.

With 4 bytes we have 32 bits for int. Now, if we have only unsigned integers, this corresponds to 0 − 23 2 − 1.

Number Signed Unsigned


0x7fff
2^31 - 1 2^31-1
ffff
0x ffff -1 or depends on the negative
2^32 - 1
ffff representation used

As shown in the above table as long as the most significant bit is 0, the number is positive and signed and unsigned
representation is the same. When we use "%d", the parameter is assumed to be in "signed representation" and when
we give "%u", the parameter is assumed to be in "unsigned representation". Since both representations are same as
long as the most significant bit is 0, we are safe to use both format specifiers for these range of values. But depending on
the type being passed to print, compiler might produce warnings.

NB: Format specifiers never do any type conversion. They simply assume the parameter as whichever type the format
tells. So, giving "%d" and passing a float value or vice versa produces unexpected result and not the int value of the
float.

 0 votes -- Arjun Suresh ( 124125 points)

21.52 Programming In C: what is the default return type of a function ? top


gateoverflow.in/14892

#include <stdio.h>
func(a,b);
void main(){
printf("hello");
return 0;
}

here the code runs although it shows warning , so how is it that although func has no return type mentioned,it works .

Also the return type of main is void but I am returning a value 0 , so then why is there no error here ?

programming-in-c

First of all everything that is not correct is not ERROR in C. C language has evolved from 1970s and C89 (ANSI) was the
first standard followed by C99 and now C11. These standards were introduced based on current architectures to ensure
best performance for C code. But backward compatibility is always an issue and no one wants an old code just not
compiling.

Return type of a function is assumed to be "int" in C. But this assumption is removed from C99 standard on wards.
Compiler might not show error for this, but you can tell compiler to do this. See the compiler warnings for the above code:

gcc func.c
func.c:2:1: warning: data definition has no type or storage class
func(a,b);
^
func.c:2:1: warning: parameter names (without types) in function declaration
func.c: In function ‘main’:
func.c:6:1: warning: ‘return’ with a value, in function returning void
return 0;
^

Just giving "-Werror" option to gcc

gcc -Werror func.c


func.c:2:1: error: data definition has no type or storage class [-Werror]
func(a,b);
^
func.c:2:1: error: parameter names (without types) in function declaration [-Werror]
func.c: In function ‘main’:
func.c:6:1: error: ‘return’ with a value, in function returning void [-Werror]
return 0;
^

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2028 of 2244

cc1: all warnings being treated as errors

All warnings became error.

Now, as per standard, main must always return "int".

 0 votes -- Arjun Suresh ( 124125 points)

21.53 Programming In C: How to explicitly initialize a pointer variable ? top


gateoverflow.in/15260
int *ptr;

ptr=9 ; // this is an error

so to rectify it we write :

int *ptr=(void*)9;

why is this stmt true , what happens on type casting this 9 to a void pointer type since 9 is an integer constant .

programming-in-c


Selected Answer

ptr = 9;

This is not an error. But it is not recommended to directly assign values to pointers as we cannot be sure of dereferencing
them as actual memory address using * operator.

int *ptr=(void*)9;

This also does the same job as above. Only difference is we explicitly typecast 9 as an address which would avoid compiler
warning.

So, both would work but both are to be avoided in good programming. If we need to use one, use the second one.

NB: These kind of questions are way out of GATE scope. You can see previous GATE questions here (see the ones with
GATEXXXX tags).

 1 votes -- Arjun Suresh ( 124125 points)

21.54 Programming In C: what is o/p top gateoverflow.in/25034

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2029 of 2244

programming-in-c

Try to solve taking a list having loop in the list otherwise it will give true whether it is even or odd no of nodes in the list.
Now It will return false when loop is detected because pointer B runs twice fast than pointer A. So after sometime pointer
A will catch pointer B and B!=A become faulty and return false because there is B==null condition always faulty.Since
there is loop in the list then B can't have null.

 0 votes -- Avdhesh Singh Rana ( 1509 points)

21.55 Programming In C: ISRO_A 2015/68 top gateoverflow.in/19445

Consider the following program fragment



if(a > b) if(b > c) s1; else s2;

s2 will be executed if

a)a <= b

b)b > c

c)b >= c and a <= b

d)a > b and b <= c

isro2015 programming programming-in-c

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2030 of 2244

Point here to be noted is that when I write if (a >b) now after this I haven't written any braces so anything written within
it would be considered as a single statement hence it is equivalent to if(a>b){ if (b < c) {s1 ;} else {s2 ;}

therefore clearly if s2 has to execute then we must have the condition a>b to be true simultaneously with b<=c , so
option D is correct .

 0 votes -- radha gogia ( 4369 points)

21.56 Programming In C: why does the ternary operator evaluates to a


garbage value in the below code ? top gateoverflow.in/14275

#include<stdio.h>
int main(){
int test=0;
float a = 3424.34;
printf("hello \n %d",(test? a: 3));
return 0;
}

It is giving output as hello 0 ,I am unable to understand the logic for this so plz clarify this .

programming-in-c


Selected Answer

In ternary operator of type (x ? y : z), type of expression is type of y and z. If y and z don't have common type, then one
is converted to other (according to standard conversion rules) to make type same.

Now in your question, type of a is float, and type of 3 is int, so 3 is converted to float i.e. to 3.0, but you are printing a
float value with %d format specifier, which is undefined behavior, and hence the garbage value. Try %f instead if %d, it
will print correct value.

 3 votes -- Happy Mittal ( 9253 points)

21.57 Programming In C: Find the output_ISRO_2015 QN 28 top gateoverflow.in/37955

Consider the following statements

#define hypotenuse (a, b) sqrt (a*a+b*b);

The macro call hypotenuse(a+2,b+3);

(a) Finds the hypotenuse of a triangle with sides a+2 and b+3
(b) Finds the square root of (a+2)2 and (b+3) 2
(c) Is invalid
(d) Find the square root of 3 *a+4*b+5

programming-in-c algorithms isro2015


Selected Answer

#define hypotenuse (a, b) sqrt (a*a+b*b);

hypotenuse(a+2,b+3)

after macro expansion it will become sqrt(a+2*a+2+b+3*b+3)

Now after evaluating you will get D.

 2 votes -- Sumit1311 ( 641 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2031 of 2244

21.58 Programming In C: How to assign the address of 2-D array into a


pointer variable ? top gateoverflow.in/14402

int B[2][3];
int *p = B; // why this is wrong?
int (*p)[3] = B; // why this is correct?

programming-in-c

When you write B, then it is address of first element of B, Now first element of B is whole 1D array of 3 int, so address of
first element can be stored in pointer which points to whole 1D array of 3 int, which is int (*p)[3], not int *p.

 2 votes -- Happy Mittal ( 9253 points)

21.59 Programming In C: why is the below code compile time error and not
run time error ? top gateoverflow.in/14746

#include<stdio.h>
int f();
int main()
{
f();
return 0;
}

programming-in-c

Your 2nd line is just function declaration .When gcc compiles these , it'd reference to actual function definition.

Which is absent , so unknown reference'd be encountered.

 0 votes -- vishal8492 ( 245 points)

21.60 Programming In C: Arithmetics in C top gateoverflow.in/37338

In C programming language x – = y + 1 ; means


(1)x= x-y+1
(2)x=-x-y-1
(3)x=-x+y+1
(4)x= x-y-1

programming-in-c


Selected Answer

4- x-y-1

 1 votes -- Richa ( 131 points)

21.61 Programming In C: when the function f returns a value then why is it


not getting printed ? top gateoverflow.in/14747

#include<stdio.h>

int f();
int main(){
printf("hello");

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2032 of 2244

int a=f();
printf("%d",a);
return 0;
}
int f(){
main();
return 8;
}

Why is 8 not printed here? I am a bit confused that afterf returns, it returns 8, so a must be assigned 8. Then how come it is not getting printed?

programming-in-c

Because the print statement will never be executed. Until the stack overflow there will be call from main to function f and
vice-versa.

 1 votes -- Lord_Krishna ( 665 points)

21.62 Programming In C: Why does the below code produces error when one
of its parameters have no data type associated with it ? top gateoverflow.in/14786

CASE A:

CASE A:
​#​include​<stdio.h>
int divide( int a, b)
{ return 7; }
int main() {
int a=divide(8,3);
printf("%d",a);
return 0;
}

CASE B :

CASE B :
#include<stdio.h>
int divide( a, b)
{ return 7;
}
int main()
{ int a=divide(8,3);
printf("%d",a);
return 0; }

why is CASE A an error and CASE B error free , in CASE B acc to c99 standard it assumes the variables to be of type int but
then why not in case A , why is the type of b not considered to be of type int ?

why is CASE A an error and CASE B error free ,

in CASE B acc to c99 standard it assumes the variables to be of type int but then why not in case A , why is the type of b not
considered to be of type int ?

programming-in-c

One of the major changes in C99 standard is the removal of implicit 'int' and 'implicit function declaration'.

Ref: http://stackoverflow.com/questions/8220463/c-function-calls-understanding-the-implicit-int-rule

Try compiling your code with two standards as follows

gcc -Wall -std=c99 code.c

gcc -Wall -std=c89 code.c

I could not get the exact rule for implicit int, but the following isn't the place where 'implicit' works as clear from the error.
Why worry about some stuff outdated in 1999? Currently we have to write declaration for all identifiers in C.
int divide( int a, b)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2033 of 2244

 0 votes -- Arjun Suresh ( 124125 points)

21.63 Programming In C: What is the output of the following C program? top


gateoverflow.in/15906

#include<stdio.h>
void main(void){
int shifty;
shifty=0570;
shifty=shifty>>4;
shifty=shifty<<6;
printf("the value of shifty is %o \n",shifty);
}

a) 15c0 b) 4300

c) 5700 d) 2700

programming-in-c


Selected Answer

Ans is D) 2700

If an integer constant starts with 0, it is considered an octal constant. So 0570 = 101 111 000 in binary as each octal digit
can be directly converted to 3 bits. Now, >>4 (right shift 4) gives 010 111 and <<6 (left shift 6) gives 010 111 000 000 =
2700 in octal. If we use "%d" in printf, this would be 1024+64*7 = 1472.

 1 votes -- Pranay Datta ( 6113 points)

21.64 Programming In C: Fill the blanks top gateoverflow.in/37273

C problem takes a circular linked list as an input argument. It modifies the list by deleting the front node.

programming-in-c

After performing the operations before blank1 and blank2, you have to perform two finalizing tasks/operations :

free() the node that is supposed to be deleted, and


Update the head to point the new head.

The statements, in the order are:

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2034 of 2244

1. *head = temp->next
2. free(temp);

You can have other sequence for these two tasks/operations.

 1 votes -- Gaurav Sharma ( 1383 points)

21.65 Programming In C: How can a value of a constant be varied through a


pointer ? top gateoverflow.in/17679

I went through these two links and found that this behaviour is undefined , but the only issue which I have is that in one
sense we say that since local variables live on stack , hence they cannot be located on read only memory region but if this is
so then if I try to alter the value of the constant directly through assignment then why does it show error if it is not located
in the read only memory region :

#include

#include int main() { const int a=12; int *ptr ; ptr=&a; *ptr=8; // no error a=45; // error printf("\n %d", a); return 0; }

http://stackoverflow.com/questions/3801557/can-we-change-the-value-of-a-constant-through-pointers

programming-in-c

auto variables are in stack and there is no RO section inside stack, But compiler can do constant propagation and a constant variable might not have a
memory. This can throw a compile error or unexpected result.

Go through this Link

http://www.geeksforgeeks.org/const-qualifier-in-c/

 0 votes -- sonu ( 1267 points)

21.66 Programming In C: What will be the output? top gateoverflow.in/17723

#include <stdio.h>
char str1[100];
char *fun(char str[]) {
static int i = 0;
if (*str)
{
fun(str+1);
str1[i] = *str;
i++;
}
return str1;
}
int main() {
char str[] = "GATE CS 2015 Mock Test";
printf("%s", fun(str));
return 0;
}

A)GATE CS 2015 Mock Test

B)tseT kcoM 5102 SC ETAG

C)Nothing is printed on screen

D)Segmentation Fault

i think answer should be option C.But the answer given as B.please explation how.

programming programming-in-c

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2035 of 2244


Selected Answer

if (*str) {
fun(str+1); // Keeps calling fun with next character as argument
str1[i] = *str;
i++;
}

As long as we have a non-NUL character in *str, code keeps calling fun with (pointer to) next character as argument (and
nothing changes due to these callings).

When *str becomes NUL character, function returns str1 and ends, and now control goes to previously called instance of
fun(), which assigns character *str to str1[i]. Here *str is last character of string.

So str1 will eventually contain reverse string of str.

Note that, code doesn't insert NUL character explicitly in str1, but since str1 is global variable and so all characters are
zero, so str1 is printed correctly.

So option (B) is correct.

 1 votes -- Happy Mittal ( 9253 points)

21.67 Programming In C: Made Easy FLT Q 43 top gateoverflow.in/31562

Q.43

Consider the following C program.

Which of the following represent the output of above program?

4,500
4,501
5,500
3,500

made-easy programming-in-c

Ans is 3402.

None of the above.

http://codepad.org/7cUKSeRR

Copy code from above snippet & run it !

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2036 of 2244

 1 votes -- Akash ( 26315 points)

None of the above! The answer is 3 402.

 1 votes -- Rohit Mallik ( 131 points)

21.68 Programming In C: How is the below expression in a linked list


evaluated ? top gateoverflow.in/17555

say I have a single linked list of 6 elements and I do some operation like

temp->link->link->link->link=p , Now assume that p is a pointer holding the address of third node whose data part is 3 and
link part is pointing to 4 th node , and let's assume that it has the base address of 300 .

Now assume that this entire LHS operation evaluates to the base address of 600 which is of the 6th node ,now my confusion
is that after this expression evaluates ,scene would be like

600 = p ,so now how come through this expression the link part of the 6th node starts pointing to the address held by the
pointer variable p ,i.e. how come this link points to 3rd variable ,plz clarify this .

programming-in-c

You could have asked the question in an easier way :)

Now to explain more I assume C language and sizeof int 4 and size of pointer 8.

Node 1 Node 2 Node 3 Node 4 Node 5


Address Value Address Value Address Value Address Value Address Value
data (int) 1024 1 2000 2 0214 3 5000 4 0600 5
link (*) 1028 2000 2004 0214 0218 5000 5004 0600 0604 0 (null)

Now, as per the question we have

0600 = p.

And this is works just like a normal assignment but changes the structure of the list as shown in bottom table.

This is actually not correct. we'll have something like

node5->next = p;

because in C language first operand of "=" operator must be an lvalue- 600 is not an lvalue but a constant. An lvalue can
be a non-const variable or a pointer but never a constant.

Now, it doesn't end here. I suppose no one will think above this during B.Tech. unless one makes a compiler himself. For
this reason Prof. Srikant Sir in IISc. still makes everyone of his course students make a compiler himself for taking
compiler course in IISc.

The thing to the last statement is p has an address as well as value. By definition of "=" in C language, the value of p is
copied to node5->next and not address. i.e., the value of right operand (rvalue) is copied to the address of left operand
(lvalue)- making it a necessity that left operand must have an address. This is all there to l and rvalues.

Now p has the value 0214 (third node address as given in question). So, the final list will be

Node 1 Node 2 Node 3 Node 4 Node 5


Address Value Address Value Address Value Address Value Address Value
data (int) 1024 1 2000 2 0214 3 5000 4 0600 5
0214
link (*) 1028 2000 2004 0214 0218 5000 5004 0600 0604

Making a loop inside the list. Now the list looks like a smoking pipe as shown below (assume the bend is complete).

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2037 of 2244

 0 votes -- Arjun Suresh ( 124125 points)

21.69 Programming In C: How is 2D array passed to a function having formal


parameter as a pointer to a array of elements ? top gateoverflow.in/17518

when I am passing a 2D array and function is declared like


func(int a[][6]) //This implies that a is going to an array of 6 columns ,rght now we don't know the rows fine ,but it is pointing to a 2D array .
but if I declare the function like
func(int (*a)[6]) //Now how is this notation correct for a to point to a 2D array since it implies that a is a pointer to an array of 6 elements so that implies that it
would be pointing to a 1D array .Although we can increment it and get to another row of 2D array ,but still I am a bit confused with this notation .
I am unable to get the exact way in this pointer a would be pointing to the 2D array .

programming-in-c

func(int a[][6]) // This implies that a is going to an array of 6 columns ,right now we don't know the rows
fine ,but it is pointing to a 2D array .

I hope you are fine with this declaration. Here a will be having the address of first element a[0][0].

func(int (*a)[6]) //Now how is this notation correct for a to point to a 2D array since it implies that a is a
pointer to an array of 6 elements so that implies that it would be pointing to a 1D array .I am unable to get
the exact way in this pointer a would be pointing to the 2D array .

As you know passing an array is just sending Base address.
Now in given declaration "int (*a)[6]", as you have mentioned you can access the each row of 6 integers base
address.Once you will do (a+1) it will increment to next row base address and so on.
To access the each element of that row you have to just do like below

int *t;
t = a; // As you know a is a pointer to an array of 6 elements.
// It means it can have address to such array of 6 elements.
// we are assigning that base address to a integer pointer.
// Since integer pointer can hold the address of integer element.
// (i.e. first element of first array)
int i;
for( i =0;i<6;i++)
printf("%d", *(t+i);

This way you can access each elements of the 2-D array.

 0 votes -- IgnitorSandeep ( 425 points)

21.70 Programming In C: Find the output of a program top gateoverflow.in/37208

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2038 of 2244

Find the output of a program, address of x is 2000(in decimal) and an integer requires 4 bytes of memory.

#include<stdio.h>
int main ()
{
unsigned int x[4][3]={{1,2,3},{4,5,6},{7,8,9},{10,11,12}};
printf("%u, %u, %u", x+3, *(x+3), *(x+2)+3);
}

a)2036, 2036, 2036

b)2012, 4, 2204

c)2036, 10, 10

d)2012, 4, 6

programming-in-c

21.71 Programming In C: How does comma acts , as an operator or as a


separator during initialization of a variable ? top gateoverflow.in/14220

when I write this statement

int i=1,2,3 then why is this an error , how does comma acts here as a separator ,

while in this case

i=1,2,3 it acts an operator

programming-in-c


Selected Answer

That is how C grammar is written. In declaration and function argument list comma acts as separator but in expressions it
acts as comma operator.

 3 votes -- Arjun Suresh ( 124125 points)

21.72 Programming In C: why is the size of the array declared with a


garbage value in negative ? top gateoverflow.in/16751

Say I declare an array like

int abc ;

int arr[abc] ;

printf("%d",sizeof(arr));

Now this abc holds some garbage value so then how come the size of the array is negative value , does it means that the
array arr is not allocated any memory space ?

programming-in-c

I executed same on unix machine and output is : 1504931616 . I am using 64bit unix O.S , gcc compile to run the
program .

U are getting negative it could be due randomness of the garbage values. That's why it's called garbage as there is no
such pattern which is followed in displaying values.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2039 of 2244

And moreover negative does not mean that address space is not allocated , negative may mean that the way variable are
stored .They could be stored in unsinged form.

 0 votes -- zatin ( 11 points)

21.73 Programming In C: Modulus operator in C top gateoverflow.in/20697

How C will behave with negative operands with modulus operator?

programming-in-c

In c sign of numerator is always prefixed before the remainder

i.e Remainder will always carry the sign of numerator

 1 votes -- admin ( 1411 points)

21.74 Programming In C: what is the output of the following c code? gateoverflow.in/18079

top

what is the output of the following c code?

#include<stdio.h>
void main()
{
int index;
for(index=1;index<=5;index++)
{
printf("%d",index);
if(index==3)
continue;
}
}

a)1245

b)12345

c)12245

d)12354

programming-in-c

12345

 0 votes -- Sunny ( 477 points)

21.75 Programming In C: why can't we access the node of a structure by


simply incrementing the pointer variable ? top gateoverflow.in/17549

int main() {
int a;
struct node *new=(struct node*) malloc(sizeof(struct node));
//printf("%p",new->link);
new->i=1;
new->link=NULL;
struct node *new1=(struct node*) malloc(sizeof(struct node));
new1->i=2;
new1->link=new;
struct node *new2=(struct node*) malloc(sizeof(struct node));
new2->i=3;
new2->link=new1;
struct node *temp;
temp=new2;
temp++;

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2040 of 2244

printf("%d",temp->i);
return 0;
}

I am not getting that why is the op not 2 ,why is it showing some garbage value ?

programming-in-c


Selected Answer

It's because the way you are doing is wrong. You cannot get next value by incrementing like this.

Because Array provide contiguous memory allocation so there we can take advantage of storage organization and get next
object value by incrementing.

Since all the node new, new1 and new2 are not contiguously stored in memory so you can not get address of node which
is being pointed by incrementing the current node.

Actually the program output is correct, here once you are trying to increment to temp then its pointing to next memory
location with an increment of sizeof(struct node) but that is garbage because you have not initialized it.

You can get the value as 2

by changing

temp++

to

temp = temp->link;

you can have a look at this

http://ideone.com/7qf0cV

 1 votes -- IgnitorSandeep ( 425 points)

21.76 Programming In C: output? top gateoverflow.in/18261

#define int char

main(){

int i=66;

printf("%d",sizeof(i));

programming programming-in-c

output will be 1.(size of i ) since pre processor is used as #define int char which change the int to char .

in most of the system char size is 1 byte that is why.

 0 votes -- Umang Raman ( 10379 points)

21.77 Programming In C: what would the program print? top gateoverflow.in/15917

#include<stdio.h>
#include<math.h>
int main() {
double pi=3.1415926535;

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2041 of 2244

int a=1;
int i;
for(i=0;i<3;i++)
if(a=cos(pi*i/2))
printf("%d",1);
else
printf("%d",0);
}

a. 0 0 0
b. 0 1 0
c. 1 0 1
d. 1 1 1

programming-in-c non-gate

if (a= something) means 'something' assigned to 'a' and it will return 'a' value (i.e. something) to if condition.

For i=0, if (a = cos pi*0/2) = if (a = 1) = if (a) = if (1) i.e. true

For i=1, if (a = cos pi*1/2) = if (a = 0) = if (a) = if (0) i.e false

For i=2, if (a = cos pi*2/2) = if (a = -1) = if (a) = if (-1) i.e. true

It will print 101.

 0 votes -- Digvijay Pandey ( 26245 points)

21.78 Programming In C: what is the output of the following program code?


top gateoverflow.in/15951

void myfunc(int X){


if(X > 0)
myfunc( --X );
printf("%d", X);
}
int main(){
myfunc(5);
return 0;
}

A. 0,0,1,2,3,4
B. 4,3,2,1,0
C. 4,3,2,1,0,0
D. 0,1,2,3,4

programming-in-c

It's tail recursion problem..

so the output is 0,0,1,2,3,4

 0 votes -- Sunny ( 477 points)

21.79 Programming In C: Why do we get a segmentation fault in the below


code ? top gateoverflow.in/16398

char getstr(){
static char s[] = "GATE2016";
return s;
}
int main(){
printf("%s", getstr());
return 0;
}

Although I know I am returning an address using a character return type , and the return type must be char* getstr(); but
still if I do like this only then I am getting null on GCC compiler and segmentation fault on another compiler so what is the

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2042 of 2244

reason for this .

programming-in-c


Selected Answer

Here is the assembly code (inside main) for the correct version with "char *"

movl $0, %eax


call getstr
movq %rax, %rsi
movl $.LC0, %edi
movl $0, %eax
call printf

Here is the assembly code (inside main) when "char *" is replaced with "char"

movl $0, %eax


call getstr
movsbl %al, %eax
movl %eax, %esi
movl $.LC0, %edi
movl $0, %eax
call printf

As we can see and as mentioned din the question, the change is that, due to the prototype of getstr being char, in the
second case, the returned value is truncated to just 8 bits. Now this 8 bits with higher bits padded with 0's or 1's (due to
sign extension and x64 calling convention) will be used as an address in the second case and that causes segmentation
fault.

i.e., suppose address of s in first case is 0x 4F A1 23 43, in second case this becomes 0x 00 00 00 43.

Even the above is not a strict guarantee as we are using a char (integer) as an address and there might be alignment
issue.

If we keep it simple, answer is undefined behaviour :)

 0 votes -- Arjun Suresh ( 124125 points)

21.80 Programming In C: Programming top gateoverflow.in/36757

Consider following program

int A(int &a,int b)

b=b-1;

if(b==0) return 1;

a=a+1;

return a+A(a,b);

Note that first parameter is passed by reference and second by value. What is the return value by A(x,x) where the value of
x is 5.

Confusion is that in C there is no order of evaluation of operands of a operator. So here, will the a value is calculated first or
is the function called...As per the ans they have used the modified value of a...is there a logic for this resolution of
operands...??

programming-in-c

21.81 Programming In C: Let a, b be two positive integers, which of the

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2043 of 2244

following options correctly relates / and %? top gateoverflow.in/18568

Let a, b be two positive integers, which of the following options correctly relates / and %?

(a) b= (a/b) * b + a%b

(b) b= (a%b) * b + a/b

(c) a= (a/b) * b + a%b

(d) a= (a%b) * b + a/b

* I am getting answer as c but the answer given is b. Please tell me which one is correct.

programming programming-in-c

Answer is option C only since it is the basic law of division

Dividend =quotient * Divisor + Remainder

 2 votes -- radha gogia ( 4369 points)

Yes, it seems like you are right.

Option C should be the correct Answer.

Check for

1) b = 1

2) a = b.

All the options except C) are dead on at least one of the above substitutions.

 1 votes -- Anurag Pandey ( 8183 points)

21.82 Programming In C: Output of following code top gateoverflow.in/26931

Given answer: 1990


Please explain

programming-in-c algorithms

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2044 of 2244


Selected Answer

The answer can be found at these links:


http://stackoverflow.com/questions/13182949/psuedo-global-variable-in-c

http://stackoverflow.com/questions/17721778/what-is-the-meaning-of-ax-1000-in-the-following-c-program

 1 votes -- Shikhar Vashishth ( 3439 points)

21.83 Programming In C: Output top gateoverflow.in/28063

#include ​<stdio.h>
int main(){
int i = 4;
i = printf(" %d ", ++i) + printf(" %d ", i--);
printf(" %d ", i);
}

programming-in-c programming

Undefined behavior (not in GATE syllabus)


http://gatecse.in/wiki/Undefined_Value
https://en.m.wikipedia.org/wiki/Undefined_behavior

 3 votes -- Digvijay Pandey ( 26245 points)

21.84 Programming In C: Char pointer to access an int top gateoverflow.in/4273

main()
{
int i =300;
char *ptr=&i;
*++ptr=2;
printf("%d",i);
}

programming-in-c


Selected Answer

Here, we are modifying an integer variable using a char pointer. The modification happens to the second byte (from the
left of the starting location) and it is changed to 2.

i.e., 300 will be stored as (lower address on left) on a big endian machine

0 * 224 0 * 216 1 * 28 44 * 20

and as

44 * 20 1 * 28 0 * 216 0 *224

on a little endian machine.

In both the cases using the char pointer we point to the starting byte. And we are incrementing the starting byte by 2.

Ao, after the increment we have

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2045 of 2244

0 * 224 2 * 216 1 * 28 44 * 20

on big endian architectures and

44 * 20 2 * 28 0 * 216 0 *224

on little endian architectures.

The respective values are 131372 and 556.

(This is the most common method of checking if an architecture is little endian or big endian)

 6 votes -- Arjun Suresh ( 124125 points)

21.85 Programming In C: what's the error here?? top gateoverflow.in/341

#include<stdio.h>
#define decode(s,t,a,m,p,e,d)m##s##u##t
#define begin decode(a,n,i,m,a,t,e)
int begin()
{
printf("hello");
}

programming programming-in-c

There is no error. ## does string concatenation in a macro. So, macro will expand as follows:

begin -> decode(a,n,i,m,a,t,e) -> m##a##i##n -> main

So, the function name becomes main and program prints "hello"

 1 votes -- gatecse ( 9515 points)

21.86 Programming In C: Program top gateoverflow.in/28184

Explain the line :


t = (p += sizeof(int))[-1];

in following program :
#include <stdio.h>
void f(char**);
int main()
{
char *argv[] = { "ab", "cd", "ef", "gh", "ij", "kl" };
f(argv);
return 0;
}
void f(char **p)
{
char *t;
t = (p += sizeof(int))[-1];
printf("%s\n", t);
}

programming-in-c


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2046 of 2244

sizeof(int) is compiler dependent ..

if sizeof(int) = 2
then

t = (p += sizeof(int))[-1]
t = (p = p + 2)[-1]
t = *(p + 2 -1) = *(p+1) = address of second element i.e. 'cd'

if sizeof(int) = 4
then

t = (p += sizeof(int))[-1]
t = (p = p + 4)[-1]
t = *(p + 4 -1) = *(p+3) = address of forth element i.e. 'gh'.

 3 votes -- Digvijay Pandey ( 26245 points)

21.87 Programming In C: Given a string,in which anything except digits are


treated as separators top gateoverflow.in/10422

Given a string,in which anything except digits are treated as separators, and between each set of separators,there is some
substring. count number of separators and substrings and return it with only 1 return statement

programming-in-c

#include <ctype.h>
int count (char * string)
{
int ret = 0;
if(string[0] != '\0')
{
if(!isdigit(string[0]))
{
ret = 1 + count(string[1]);
}
}
return ret;
}

This returns the number of separators, number of sub strings will be one plus the number of separators. Guess this is
what is meant in question.

 0 votes -- Arjun Suresh ( 124125 points)

21.88 Programming In C: try to print this in one loop itself. top gateoverflow.in/3998

try to print this in one loop itself.i have already done this in two loops(one nested into another).so please try to do in one
loop itself.

1
2 4
3 6 9
4 8 12 16
5 10 15 20 25

programming programming-in-c


Selected Answer

#include <stdio.h>
int main(int argc, char * argv[])
{
int i, j=1, k=1, n=atoi(argv[1]);
for(i = 1; j <= n; k++)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2047 of 2244

{
printf("%d ",i);
if(k == j)
{
k = 0; i = ++j;
printf("\n");
}
else i += j;
}
}

 2 votes -- Arjun Suresh ( 124125 points)

pattern(1,row*row); pattern(i,n)
{
if(i*i>n)
return;
else
{
for(k=i;k<=i*i;k=k+i)
print("%d",k);
print("/n");
pattern(i+1,n);
}
}

 2 votes -- Bhagirathi Nayak ( 10239 points)

#include<stdio.h>
#include<conio.h>
int main()
{
int j=1;
for(int i =1; i<=5;i++)
{
if(i*j<=i*i)
{
printf("%d \t",i*j);
i--;
j=j+1;
}
else
{
printf("\n");
j=1;
}
}
getch();
return 0;
}

 2 votes -- Palash Nandi ( 1373 points)

21.88 Programming In C: is there any error in statement *a++ ; // a is an


integer pointer. If not please explain what will happen.. if a=a+1 happens at
1st step then we are left with *a; now what is the meaning of this ? would it
give error regarding l-value? top gateoverflow.in/4758

programming programming-in-c

*a++;

will be parsed as

*(a++);

as ++ has higher precedence than *. (http://en.cppreference.com/w/c/language/operator_precedence)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2048 of 2244

Now a++, returns the content of a (which is an address to integer variable) and then increments a to hold the next
address (increments by sizeof(int))

So, *(a++) will return the content at the address contained in a. (since, a is pointer to int, this will return 4 bytes of data
from a assuming sizeof(int) is 4)

So, we can do
int *p, *a, b[2] = {1, 2}, c, d;
a = (int*) &b;
c = *a++;
d = *a;

Here c will get the value 1 and d will get the value 2.

If a is an integer pointer, we can also do (*a)++, which returns the value at the memory location in a and also increments
it.

 1 votes -- Arjun Suresh ( 124125 points)

21.89 Programming In C: Why are constant variables considered to be as


lvalue ? top gateoverflow.in/40628

when constant type variables cannot be modified then why do we consider them as lvalues , why not only r-values ?

programming-in-c


Selected Answer

Const type variables - examples "const int a" - are variables and they do have a memory location which makes them
lvalues.

Constants- examples 2, 2.4 - are rvalues.

String literals- example "hello world" - are lvalues as they have a memory location (stored in RO data segment).

 1 votes -- Arjun Suresh ( 124125 points)

21.90 Programming In C: Why cant an uninitialized pointer be explicitly


assigned a value ?Why does it lead to segmentation fault ? top gateoverflow.in/14158

int * p(void)
{
int *x;
*x=10;
return (x);
}

We create *x, and dereference it before assigning anything to it (x). Most likely, when we are declaring something on the stack, it will have a
random value. The assignment - *x = 10 will try to write the value 10 to whichever address the pointer is pointing to (i.e. the value of x itself)
, so then what's the issue i.e. when we can assign a value 10 at some random location pointed by x so then why does this result in
segmentation fault ?

programming-in-c

Good one. You told everything perfectly and the only question remaining is "why can't we write to some random location
in memory?". Well, that is due to OS protection. Suppose we write to a random location and changes the memory content
of some other process, that can crash rt? So, OS allows a process to modify only the memory allowed by it- in Segmented
memory managed systems, a process can only access the memory in its assigned segments and when it accesses a
memory outside that it gets segmentation fault.

In a uniprocess system this protection is not needed. One of the main uses of virtual memory in addition to extension of
memory address space is this memory protection.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2049 of 2244

 2 votes -- Arjun Suresh ( 124125 points)

21.91 Programming In C: c program top gateoverflow.in/28484

how statement "printf("%s ", cpp[-1][-1]+1);" works plz explain

#include <stdio.h>
char *c[] = {"GatsQuiz", "MCQ", "TEST", "QUIZ"};
char **cp[] = {c+3, c+2, c+1, c};
char ***cpp = cp;
int main()
{
printf("%s ", **++cpp);
printf("%s ", *--*++cpp+3);
printf("%s ", *cpp[-2]+3);
printf("%s ", cpp[-1][-1]+1);
return 0;
}

o/p TEST sQuiz Z CQ

programming-in-c

Before cpp[-1][-1] + 1, cpp points to 'c+1'. Now question is how cpp[-1][-1]+1executes.

cpp[-1][-1] = *(*(address of c+1 -1) -1) +1

= *(c+2 -1) +1) = *(c +1) +1 = (address of MCQ) + 1

i.e.from string 'MCQ' leave 1 character and print untill null encountered.

CQ will be printed.

 0 votes -- Digvijay Pandey ( 26245 points)

21.92 Programming In C: please explain the reason for the "weird" false
condition coming out from for conditional checking. top gateoverflow.in/5531

In this program the TOTAL_ELEMENTS calculates properly when not used in for loop. And the first printf prints properly.

But why the 2nd printf is not working even if the condition in the loop is true. TOTAL_ELEMENTS returns 7.

And -1<7-2 i.e -1<5 is true. So what is wrong here?

#include<stdio.h>

#define TOTAL_ELEMENTS (sizeof(array) / sizeof(array[0]))


int array[] = {23,34,12,17,204,99,16};

int main()
{
int d;
printf("Total= %d\n", TOTAL_ELEMENTS);
for(d=-1;d <= (TOTAL_ELEMENTS-2);d++)
printf("%d\n",array[d+1]);
return 0;
}

programming programming-in-c


Selected Answer

Due to implicit type casting.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2050 of 2244

When we operate on two different data types, the smaller one is implicitly casted to bigger one. And between signed and
unsigned, unsigned is ranked higher.

http://gatecse.in/wiki/Chapter_2:_Data_Types_and_Operators_in_C#Implicit_Type_Conversion

In the definition of TOTAL_ELEMENTS, sizeof, returns unsigned int, and unsigned int divided by unsigned int returns
unsigned int. When compared with d, an integer, d is promoted to unsigned and becomes 2 n-1, where n is the number of
bits used for storing an int. So, the comparison here returns false.

 5 votes -- Arjun Suresh ( 124125 points)

21.93 Programming In C: What is the problem with this code? top gateoverflow.in/43281

#include<stdio.h>
int main()
{
char arr[10];
memset(arr,0,sizeof(arr));
gets(arr);
printf("\n The buffer entered is [%s]\n",arr);

return 0;
}

programming-in-c


Selected Answer

I do not think there is any problem in the code. Except gets() function does not check the size of array, for which it taking
the data. Hence that may create some problem. Other than that it will work fine.

 2 votes -- Rude Maverick ( 3063 points)

21.94 Programming In C: what is difference between deep binding and


shallow binding? Explain with this code. top gateoverflow.in/4979

int x=5;
void f()
{
x = x+50;
}
void g(h())
{
int x=10;
h();
print(x);
}
void main()
{
g(f());
print(x);
}

1) what is output if code uses deep binding?

2)what is the output if code uses shallow binding?

programming programming-in-c

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2051 of 2244


Selected Answer

Deep/shallow binding makes sense only when a procedure can be passed as an argument to a function.

Deep binding binds the environment at the time a procedure is passed as an argument.
Shallow binding binds the environment at the time a procedure is actually called.

1. Deep binding.

f() gets the environment of main, since f() is passed as an argument in main. At the time of passing, x in main (the global
x) is 5. So, f changes the global x to 55, and g prints the local x as 10.

2. Shallow binding.

f() gets the environment of g at the time it is called. So, f changes the x in g to 10+50 = 60, and g prints the value 60.

 4 votes -- Arjun Suresh ( 124125 points)

21.95 Programming In C: What is the problem with this program? top gateoverflow.in/43282

The following program seg-faults (crashes) when user supplies input as ‘freeze’ while it works fine with input ‘zebra’. Why?

#include<stdio.h>
int main(int argc, char *argv[])
{
char *ptr = (char*)malloc(10);
if(NULL == ptr)
{
printf("\n Malloc failed \n");
return -1;
}
else if(argc == 1)
{
printf("\n Usage \n");
}
else
{
memset(ptr, 0, 10);
strncpy(ptr, argv[1], 9);
while(*ptr != 'z')
{
if(*ptr == '')
break;
else
ptr++;
}
if(*ptr == 'z')
{
printf("\n String contains 'z'\n");
// Do some more processing
}
free(ptr);
}
return 0;
}

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2052 of 2244

programming-in-c


Selected Answer

The problem here is that the code changes the address in ‘ptr’ (by incrementing the ‘ptr’) inside the while loop. Now when
‘zebra’ is supplied as input, the while loop terminates before executing even once and so the argument passed to free() is
the same address as given by malloc(). But in case of ‘freeze’ the address held by ptr is updated inside the while loop and
hence incorrect address is passed to free() which causes the seg-fault or crash.

This question and solution is available at internet. before posting any questions please search on the google first. If you
could not get solution or if you could not understand the solution or if you think its really good questions then and only
then post. By the way it was a good que Thx.

 3 votes -- Rude Maverick ( 3063 points)

21.96 Programming In C: Valid pointer operation top gateoverflow.in/42970

The valid pointer operation is assigning or comparing to zero in C


Can anyone explain this statement?

programming-in-c programming

21.97 Programming In C: What is subarray and its example? top gateoverflow.in/29283

Whats is subarray ? Can you explain with example?!

programming-in-c data-structure

21.98 Programming In C: Identify syntax error top gateoverflow.in/33320

Find the C statement which has a syntax error.

1. If (z)
2. For (a, b, c)
3. While (a, b)
4. None of these.

programming-in-c


Selected Answer

D) None Of these .

As C language is case sensitive, it treats them as function declaration or function calling [depending where those used].

 3 votes -- pramod ( 2071 points)

Actually c language is case sensitive so answer is option (d)

But this question has a typo with first letter as capital in each options then option is (b) because both option a and c has

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2053 of 2244

no syntax error.

a) if(z) ' if ' can accepts integer identifier as well in place of logical expression.

c) comma is operator so it can result into either a or b depending on their values.

See these references : http://www.geeksforgeeks.org/a-comma-operator-question/ and http://ideone.com/KB8Beo

b) This option is wrong because for(a,b,c) is not a correct syntax because for accepts semicolon ' ; ' not comma ' , '.

 2 votes -- Sandeep Singh ( 5939 points)

21.99 Programming In C: garbage collection top gateoverflow.in/42162

Why C language does not provide heap or garbage collection ?? Is there any higher level mechanism??

programming-in-c

Let me answer one by one.

Why C does not provide Heap or Garbage Collection?

==> We all know the phrase "necessity is mother of invention". The Concept of Garbage Collection was first
introduced by Games Gosling, when he developed the Java Language. Many don't know but the most important reason
behind the java development was Memory leaks problem. When James Gosling was working on a projects (named Green
Project and He was using C++ as Language) then he got frustrated by Memory leaks problem hence he thought to solve
this. And there is only one way to solve this memory leaks problem is to write another programming language. Hence
Garbage collection comes to reality. Most people think that Platform Independency was the most important reason behind
Java Development, but It was not the first thought when James Gosling was developing Java. Platform Independecy was
second thought. First Thought was Memory leaks.

Is there any higher level of Mechanism?

==> No. C still does not provide any kind of Garbage Collection.

A quote from Bjarne Stroustrup himself:

I had hoped that a garbage collector which could be optionally enabled would be part of C++0x, but there were enough technical problems that I
have to make do with just a detailed specification of how such a collector integrates with the rest of the language, if provided. As is the case with
essentially all C++0x features, an experimental implementation exists.

Please see the above link for a more detailed discussion on why GC is hard.

There is also a good discussion of the topic here.

 5 votes -- Rude Maverick ( 3063 points)

21.100 Programming In C: What is the output, explain top gateoverflow.in/5197

int main(void) {
char p[20];
char *s = "Gate015";
int length = strlen(s);
int i=0;
for(i=0;i<length;i++)
p[i]=s[length-i];
printf("%s",p);
return 0;
}

programming-in-c


Selected Answer

printf("%s",p);

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2054 of 2244

%s prints all characters from the start address given by p till the first occurrence of '\0'; But p[0] = s[length - 0] = '\0';
So, nothing will be printed.

The code can be corrected by

for(i=0;i<length;i++)
p[i]=s[length-i-1];

 4 votes -- Arjun Suresh ( 124125 points)

21.101 Programming In C: output of this program is top gateoverflow.in/39268

int main(){
int n=1,sum =0;
while(n<=10){
sum += n++*n++;
}
printf("Sum = %d\n",sum);
return 0
}

ans is 165 . i got 190.please explain??

programming-in-c


Selected Answer

sum += n++*n++;

Here, the variable 'n' is modified more than once without an intermediate sequence point. So, the output comes under
"undefined behaviour" part and whatever code the compiler generate, we cannot say it is wrong. i.e., even if the program
outputs "0" compiler is correct and programmer is wrong.

Before writing C code one must know the rules of C. But people even write C book without knowing the rules of C :)

 3 votes -- Arjun Suresh ( 124125 points)

21.102 Programming In C: String Swapping top gateoverflow.in/39280

void swap(char **str_1,char **str_2){


char *temp = *str_1;
*str_1 = *str_2;
*str_2 = temp;

int main(){

char str1[20] = "india";

char str2[20] = "is great";

swap(&str1,&str2);

printf("%s",str1);

printf("%s",str2);

if we replace str1[20] and str2[20] by *str1 and *str2. then string is swapped.but not in this case why?? please explain..

programming-in-c

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2055 of 2244

21.103 Programming In C: Question on C programming lanuage top gateoverflow.in/26933

Why 'count' variable value doesn't set to 0 on every call to 'incr' function?

algorithms programming-in-c


Selected Answer

here static int count= 0 means memory create for count for compile time only ..ans will be 15 only

at cal(0)= 0

at cal(1)= 1

at cal(2)=3

at cal(3)= 6

at cal(4)= 10

at cal(5)=15

What ur talking about constant int count= 0.

 4 votes -- Anirudh Pratap Singh ( 4091 points)

Count is a static variable which allocates its memory in data segment unlike the usual stack . Therefore when a function is
called again the value still remains stored and it refers to the old location in data segment every time. Had count been a
local variable (int count =0 )it would be stored in stack and then every time function is called count would be allocated
different memory locations in stack since the activation records are different for each call of the function. Then what you
asked would have been true and j value would be 5.

 1 votes -- Riya Roy ( 4767 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2056 of 2244

21.104 Programming In C: functions top gateoverflow.in/39267

1 int main() {
int b;
b = f(20,30);
printf("%d",b);

return 0;
}
int f(int a,int b){
int z;
z= a + b;
return z;

this program compile fine and o/p is 50

2 int main() {
int b;
b = f(20,'a');
printf("%d",b);

return 0;
}
int f(int a,char b){
int z;
z= a + b;
return z;

this give compilation error. I don't know why??Please explain

programming-in-c


Selected Answer

You are writing the function f() after main without declaring its prototype. Before main write int f(int,char); or write the
entire function f() before main(), in that case no prototype declaration is needed.

 1 votes -- chat28 ( 495 points)

21.105 Programming In C: ISRO(2015) top gateoverflow.in/19791

Which of the following has the compilation error in C?

(a) int n = 17;

(b) char c = 99;

(c) float f = (float)99.32;

(d) #include <stdio.h>

programming-in-c


Selected Answer

None of them not even giving any compiler warning even with strict C standard.

 0 votes -- Arjun Suresh ( 124125 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2057 of 2244

21.105 Programming In C: What is the best way to study C programming for


GATE 2015? top gateoverflow.in/3735

programming-in-c


Selected Answer

If you know C programming you don't need to study that for GATE :)

That is the same for all topics. I was good in C basics as I had done all my btech lab exercises in C and had tried to
understand any C question I found anywhere. So, never had any problem with C questions in GATE.

Now, if you are not comfortable with C, then again GATE is the best exam for you. Because there won't be any syntax
based questions in GATE. They have included C and not any other programming language because C covers most of the
"program language" techniques- pointers, parameter passing, scope, lifetime and data types. I guess most C questions
come from these portions. Understand these things from any standard book
(http://gatecse.in/wiki/Best_books_for_CSE#Programming_.26_Data_Structures) or from good online resource (not some
unauthorized blogs). And I believe previous year questions from GATE almost cover all the ares (not all the possible
questions- don't think studying all questions is any useful in GATE, but covering topics of questions is usually enough). You
can see previous questions in below link:

http://gateoverflow.in/tag/programming-in-c

 2 votes -- Arjun Suresh ( 124125 points)

21.106 Programming In C: What is the output of the following C program? top


gateoverflow.in/26759

void abc(int x, int y){


pf("%d%d", x, y);
}
void main(){
int a;
a = 12;
abc(++a, a++);
pf("%d", a);
}

A. 14,12,14
B. 13,12,13
C. 11,12,12
D. 14,14,14

programming-in-c

In C language abc(++a, a++) is Undefined Behavior & it is out of GATE scope.

 2 votes -- Digvijay Pandey ( 26245 points)

21.107 Programming In C: Unary operator expression evaluation c top gateoverflow.in/35569

After executing the program, I am getting 10 as the answer.

Please explain and give the postfix for the expression [ z=x++-y*b/a ].

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2058 of 2244

programming-in-c

z =x++-y*b/a

= 5-(-10)*2/4

= 5-(-20)/4

= 5 - (-5) =10

o/p is 10 and finally x = 6

 0 votes -- indrajeet ( 191 points)

21.108 Programming In C: Predict Output top gateoverflow.in/38393

What is the output of folowing C codes . Justify


for(i=0;i<10;i++)
printf("%d",i>>1);

for(i=0;i<10;i++)
printf("%d",i&1);

for(i=0;i<10;i++)
printf("%d",i&&1);

for(i=0;i>0;i--);
print("%d",i)

int i = 5;
i = (i, ++i, 1) + 1;
printf("%d\n", i);

OUTPUT

0011223344
0101010101
0111111111
i was trying to make a wrap around question . failed . output 0
2

programming-in-c


Selected Answer

1.
for (i=0;i<10;i++) printf ("%d",i>>1);
i = 0, Shift i value one bit right. so it will print 0.
i = 1, Shift i value one bit right. so it will print 0.
i = 2, Shift i value one bit right. so it will print 1.
i = 3, Shift i value one bit right. so it will print 1.
Do same for all i values..

2. for(i=0;i<10;i++) printf ("%d",i&1);


Bitwise AND : C code used to check number is odd or not .. for each Odd number it will print 1 and for each even it will
print 0.

3. for(i=0;i<10;i++) printf("%d",i&&1);
Used to Check i is NON zero or not. for Non zero i value it will print 1 and for i=0 it will print ).

4. for(i=0;i>0;i--); print ("%d",i)


for i = 0, i>0 condition failed so it will not execute print statement .. for all value after --i same condition will return false.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2059 of 2244

even after i value become large (i Range exceeded) again i value reset to 0 and it will take forever i.e. Stackoverflow.

5. int i = 5; i = (i, ++i, 1) + 1; printf("%d\n", i);


here i = (i, ++i, 1) value of i initialised to 1.
so finally i = (i, ++i, 1) + 1 will print 2.
(Still i am in doubt it may gives UNDEFINED BEHAVIOR bcoz i value modified more than once in i = (i, ++i, 1) + 1)

 2 votes -- Digvijay Pandey ( 26245 points)

0011223344

here shift operator shifts the data by k bits (here 1 bit)

in binary shifting by 2 means divison by 2.

so ,for i=0;i/2=0

for i=1,i/2=0

for i=2,i/2=1

for i=3,i/2=1

for i=4,i/2=2 i=00000100 -> i>>1 -> 00000010 i.e. 2

i=10 i=00001010 i>>1 00000101 i.er 5.

for 2nd ,

i &1 ANDS 00000000 AND 00000001 so answer is 00000000

here there is bitwise AND.

so for any i whose LSB is 1 will be anded as XXXXXXX1 AND 00000001

and give o/p 1.

for

printf("%d",i&&1);

you get 011111111 and output where you check if first operand of AND is zero or not.so this is not a bitwise AND.

always remeber bitwise shift never ever modifies your orignal data

 1 votes -- viv696 ( 1431 points)

21.109 Programming In C: How does a pointer declared with const keyword


considered as a pointer to a constant ? top gateoverflow.in/13925

#include<stdio.h>
int main()
{
int x=3;
int const *ptr =&x;
printf("%d",++x);
printf("\n %d",++*ptr);
return 0;
}

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2060 of 2244

I am unable to get that when x is a variable not a constant then how come the error is that the since ptr is a pointer to a
constant hence we cannot change its value, although ++x works fine, whats the logic behind this ?

programming-in-c non-gate


Selected Answer

Type of ptr is pointer to const int, hence it is an error for compiler if we try to change the value it is pointing to.

 1 votes -- Happy Mittal ( 9253 points)

We must value the type of any data type.

x is an integer and hence we can always modify it.

ptr is a pointer to a constant integer and hence we are not supposed to modify the pointed to value of ptr. This is
particularly useful when passing a pointer to a function and we want to ensure no modification to the pointed value
happens.

 2 votes -- Arjun Suresh ( 124125 points)

21.110 Programming In C: c output top gateoverflow.in/38421

Consider the following C program segment:

#include <stdio.h>
main()
{
static char*s[] = {"black","white","yellow","violet"};
char **ptr[]={s+3,s+2,s+1,s},***p;
p=ptr;
++P;
printf("%s",*--*++p+3);
}

What will be printed by the program?

et
ite
ck
yellow

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2061 of 2244

programming-in-c


Selected Answer

++ p means p points to S+2


*(--(*(++P)))+3

++P : address of S+1


*(++P) : S+1
--(*(++P)) : S
*(--(*(++P))) : Address of 1st element of array i.e. Address of 'b'
*(--(*(++P))) + 3 : address of 'c'

now Print string starting from 'c' i.e. 'ck'


 3 votes -- Digvijay Pandey ( 26245 points)

21.111 Programming In C: C Que top gateoverflow.in/13407

main()
{
unsigned i = 3;
if(i > -1)
printf("Hell");
else
printf("Heaven");
}

Here since i is unsigned type....-1 should be converted to unsigned type for comparison..What would -1 be in unsigned ....or
with what value should i be compared in if(i > -1).....?

Plz explain...

programming-in-c

In C language unsigned int data type is ranked higher than signed and whenever two operands are of different ranks, they
are converted to the rank of the highest ranked type operand.

The relevant statements from C standard (Pg. 51, http://port70.net/~nsz/c/c11/n1570.pdf)

When a value with integer type is converted to another integer type other than _Bool,

1. if the value can be represented by the new type, it is unchanged.


2. Otherwise, if the new type is unsigned, the value is converted by repeatedly adding or subtracting one more than the
maximum value that can be represented in the new type until the value is in the range of the new type

So, here -1 is converted as per condition 2 above as follows (assuming 32 bit integers)

-1 + 2^32 -1 + 1 = 2^32 -1 which is the maximum unsigned value.

So, the comparison returns false. The only unsigned value for which the comparison (> changed to >=) returns true is
UINT_MAX.
#include<stdio.h>
#include<limits.h>
int main()
{
unsigned i = UINT_MAX;
if(i >= -1)
printf("Hell");
else
printf("Heaven");
return 0;
}

But, it is a real stupidity to compare a signed integer with an unsigned integer. This shows the programmer doesn't know
how to use data types.

 1 votes -- Arjun Suresh ( 124125 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2062 of 2244

21.112 Programming In C: what is output of program top gateoverflow.in/39010

int f(int);
int main() {
int b;
b = f(20);
printf("%d",b);
return 0;
}
int f(int a){
a>10 ?return(20):return 10;
}

programming-in-c


Selected Answer

ANS IS ERROR : EXPECTED EXPRESSION BEFORE RETURN.

See the syntax of a ternary operator is

expr1 ? expr2: expr3;

where expr1 , expr2 , expr3 are expressions;

The operator ?: works as follows expr1 is evaluated first if it is true expr2 is evaluated otherwise expr3 is evaluated.

hence in expressions the return statement can not be used in C-language

[ RETURN IS STATEMENT NOT EXPRESSION SO IT IS NOT USE HERE ]

 2 votes -- Ankit Chourasiya ( 289 points)

According to K&R C, " Return statement can not be used in conditional operator".

Instead of

a > 10 ? return(20) : return(10);

It is advisable to use

return( a>10 ? 20 : 10);

It will work fine. (Y)

 5 votes -- Rude Maverick ( 3063 points)

21.113 Programming In C: if-else condition based question top gateoverflow.in/3974

What's the "condition" so that the following code


snippet prints both HelloWorld !
if "condition"
printf ("Hello");
else
printf ("World");

programming-in-c


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2063 of 2244

Condition can be printf("Hello") != 5

So code snippet becomes,

if(printf("Hello") != 5)
printf("Hello");
else
printf("World");

 7 votes -- prathams ( 1141 points)

21.114 Programming In C: operator precedence top gateoverflow.in/39169

int main(){
int a = 4,b = 5,c = 6;
int k = ++a || ++b && c++;
printf("%d %d %d %d",a,b,c,k);
return 0;
}

o/p 5 5 6 1

Above code will not increment b and c why??even the precedence of logical And is more than logical Or

programming-in-c


Selected Answer

Just try to imagine it with parentheses:

++a || ++b && ++c;


equals

(++a) || (++b && ++c);


which is evaluated from left to right and || being the logical AND, if the first operand is non-zero, second operand won't be
evaluated due to short circuit rule in C.

if && and || would have the same precedence, it would look like

(++a || ++b) && (++c);

Here, the second operand won't be evaluated if the first operand returns 0.

PS: Precedence just give the operands for operations (like giving paratheses). Actual execution order is not specified here
and depends on the language semantics.

 3 votes -- Rude Maverick ( 3063 points)

21.115 Programming In C: How to do this program? top gateoverflow.in/12773

int main() {
int i = 255;
char *p;
p = &i;
printf("%d", *p);
return 0;
}

programming-in-c programming non-gate


Selected Answer

*p is passed to printf and only inside the printf "%d" comes in to play. So, if we pass only a byte for 'char' and we try to

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2064 of 2244

print 4 bytes for 'int' (assuming 32 bit int), we might think result is undefined.

But, C standard says that char is indeed passed as int (as most architecture feature revolve around the size of int). And
while converting from char to int, sign extension is used- meaning sign bit is used for all higher order bits. Thus 255 here
would be passed to printf as 2^32 - 1 (all 1's). Now, %d gives -1, %u gives 2^32 -1 and %c would give the character
corresponding to (2^32 - 1) mod 256 = 255. (actually %c considers just the lower 8 bits and hence mod 256).

But we shouldn't use '%f' and it will give neither the int value converted to float nor the floating point representation
corresponding to that value. It'll just give garbage value on most occasion as printf would then be using floating point
register to read the value. C standard clearly says this- if the format specifiers are not matching with passed arguments,
behaviour is undefined. But character and integer are an exception, as in C character is just a 8 bit integer.

Also, here little endian and big endian would give same result.

(An advise- if you are learning C stuffs by running code, never use online compilers).

 2 votes -- Arjun Suresh ( 124125 points)

The answ depends on the arcitecture u are using and most probably it will output -1 now the logic is see that when u see
the type of the pointer is character hence it specifies that the pointer must access 8 bits of a particular location now those
8 bits on little endian actually shows the last 8 bits since representation of 255 would be (0...8 time ) (0...8 time ) (0...8
time ) (1...8 time ) now the pointer will point to these last 8 bits now since they all are 1's and we are using %d format
specifer hence it would be treated as signed now signed means MSB here is 1 hence negative now for calculating its
magintude complement all bits and then add 1 to it the magnitude would be 1 hence op would be -1 ,

It may give compile time error on some compilers and warning on some compilers.

 1 votes -- radha gogia ( 4369 points)

21.116 Programming In C: Find output top gateoverflow.in/13004

printf("xy","ab","mn") will print

a)xy b)xy ab mn c)garbage value d) error

programming-in-c non-gate


Selected Answer

It should print

xy

The first argument to printf is a pointer to character. printf now starts reading all characters from that pointer address
until '\0' is encountered. Before this if it finds any format specifier it reads further arguments and interprets them as per
the format specifier. Here, no format specifiers are given and so the last 2 arguments will be simply ignored.

 4 votes -- Arjun Suresh ( 124125 points)

21.117 Programming In C: what is the o/p please explain every step top gateoverflow.in/13205

#define square(x) x*x

main()

int i;

i=64/square(4);

printf("%d",i);

programming-in-c

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2065 of 2244


Selected Answer

The output will be 64 .

see whenever you define anything it will return exact form of it .

in this case : i=64/square(4) evaluate like this : i=64/4*4 ( because square(x) = x*x )

 4 votes -- Pranay Datta ( 6113 points)

o/p will be 64

=> 64/square (4)

=> (64/4) *4

=> 64

 1 votes -- shabi ( 317 points)

21.118 Recurrence Equation: Asymptotic bounds top gateoverflow.in/37289

how to solve the recurrence relation T(n)=16T(n/4)+n^2+nlogn

recurrence-equation asymptotic-notations

n^2 logn

as the leading term of n^2+n*logn polynomial is n^2 ...and it will be some special case of masters theorem ...

 1 votes -- Deepesh Kataria ( 1207 points)

http://cse.unl.edu/~choueiry/S06-235/files/MasterTheorem.pdf

 1 votes -- Banti Arya ( 185 points)

21.119 Recursion: recursion top gateoverflow.in/38316

Let P be a procedure that for some inputs call itself (i.e. recursive). If P is guaranteed to terminate, which of
the following must be true?
1. P has local variable
2. P has an execution path where it does not call itself
3. P either refers to a global variable or has atleast one parameter

1 only
2 only
1 and 2 only
2 and 3 only

recursion

P has an execution path where it does not call itself

that is true prvoided this path excutes some time in future.

P either refers to a global variable or has atleast one parameter.


it needs to refer to some external variable which will help to activate a path mentioed in step 2.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2066 of 2244

but the thing garuntes is confusing since. a bad coder like me may go into infite loop with improper implemantion of aqbove
condition

 0 votes -- viv696 ( 1431 points)

21.120 Recursion: Output of this code top gateoverflow.in/36225

Output of this program -



int rec(int x)
{
static int f;
if(x == 1)
return(1);
else __Y__ ;
return f ;
}

What is the value returned by rec(5)
​a) when Y is f = f * 1 + rec(x-1) ;
b) when Y is f = f * x + rec(x-1) ;

What is proper way to solve this ?

programming-in-c recursion

int rec(int x)
{
static int f;
if(x == 1)
return(1);
else
f = f * 1 + rec(x-1) ;
return f ;
}

in this
f = f * 1 + rec(x-1) ;
is equal to writing f=f+rec(x-1) so f has to be computed when rec(x-1) value is returned to function
Since f is declared as static so it will be initialized to 0

so rec(5)=8
f=f+rec(4)=4+4
f=f+rec(3)=2+2
f=f+rec(2)=1+1
f=f+rec(1)=0+1 return (rec(1))=1

2)

int rec(int x)
{
static int f;
if(x == 1)
return(1);
else
f = f * x + rec(x-1) ;
return f ;
}

in this
f = f * x + rec(x-1) ;
here multiplication will be done first and then function will be called ,so returning value of function will not change the result
and thus changed value of f will not reflect.
Since f is declared as static so it will be initialized to 0

so rec(5)=1
f=f*x+rec(4)=0+1

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2067 of 2244

f=f*x+rec(3)=0+1
f=f*x+rec(2)=0+1
f=f*x+rec(1)=0+1 return (rec(1))=1


 2 votes -- Anirudh Pandey ( 343 points)

21.121 Recursion: What is the output? top gateoverflow.in/13661

#include<stdio.h>
int fun(int n)
{
int x=1,k;
if (n==1) {
return 1;
}
for (k=1;k<n;++k) {
x=x+fun(k)*fun(n-k);
} return x ;
}

int main()
{
int b,j;
b=5;
j=fun(b);
printf("%d",j);
return 0;
}

algorithms recursion


Selected Answer

http://gateoverflow.in/8060/gate2015-2_11

 0 votes -- Arjun Suresh ( 124125 points)

21.122 Recursion: Ds.. top gateoverflow.in/35347

Consider the following function:


void f(int a)
{
if(a <= 0)
return ;
else{
printf("%d ",a);
f(a-2);
printf("%d ",a);
f(a-3);
}
}

The sum of all values printed by f(6) is _____ .

recursion recurrence


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2068 of 2244

f(0) does not print anything.

f(1) prints 1 and 1.

f(n) prints n, f(n-2), again n and then f(n-3).

So, we can have the recurrence relation for the sum of values being printed as

P(n) = 2n + P(n − 2) + P(n − 3), P(n ≤ 0) = 0.

P(1) = 2, P(2) = 4, P(3) = 8, P(4) = 14

P(6) = 2 × 6 + P(4) + P(3) = 12 + 14 + 8 = 34.

 2 votes -- Arjun Suresh ( 124125 points)

21.123 Recursion: How to solve recursion problem in less time? top gateoverflow.in/16814

I'm solving questions of recursion. But those problems are hard to debug in few minutes? Have you any such method that
solve recursive problem in less time? I have written problem below: please help me in this problem:
int fun(int n){
int x=1,k;
if(n==1) return x;
for(k=1; k<n;
x=x+fun(k)*fun(n-k);
return;
}

The return value of fun(5) is ________.

How to solve this problem in less time? Please help me.

recursion


Selected Answer

Calculate the value of the function for smaller values first, then calculate for the next larger value, and so on.

For example, in this question, calculate in the sequence f(1) → f(2) → f(3) → f(4) → f(5)

If you try to calculate from top to bottom, you will end up evaluating the function for an exponential number of times.

So,

f(1) = 1
f(2) = 2
f(3) = 5
f(4) = 15
f(5) = 51

 1 votes -- Saurav Kumar Gupta ( 1455 points)

21.124 Recursion: returned value top gateoverflow.in/33198

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2069 of 2244

programming recursion


Selected Answer

I am getting 240.

rec(5) => rec(4) =>rec(3) => rec(2) => rec(1) => 1

Note that f is static, so its value will not change at each call and initialized to 0.

Now, backtrack:
since, f = f + x*rec(x-1)
rec(1)=>1
rec(2)=>f=0+2*1=2
rec(3)=>f=2+3*2=8
rec(4)=>f=8+4*8=40
rec(5)=>f=40+5*40=240

 4 votes -- Monanshi Jain ( 5827 points)

21.125 Recursion: what is the output of foo(10)? top gateoverflow.in/5040

int foo(unsigned int n)


{
int c,x=0;
while(n!=0)
{
if(n&01) x++;
n>>=1;
}
return c;
}

programming recursion

10 / 2 = 5

5 / 2 = 2, now x will be increments to 1 as the lower bit in n is now 1.

2 / 2 = 1, now x will be incremented to 2.

1/2 = 0. loop terminates.

c which is not modified anywhere will be returned. It is garbage as auto variables are not initialized in C.

 1 votes -- Arjun Suresh ( 124125 points)

21.126 Scope: Scope top gateoverflow.in/32403

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2070 of 2244

What is the difference between Static and Dynamic Scoping ?


Please explain with a suitable program.

scope programming-in-c

You can find lots of those here: http://gateoverflow.in/tag/variable-binding. But this portion is not there for GATE 2016.

 2 votes -- Arjun Suresh ( 124125 points)

21.127 Sorting: Sorting array with elements in reverse order top gateoverflow.in/36647

Please explain how heapsort will give us best results?

sorting algorithms time-complexity


Selected Answer

Asymptotically both MERGE as well as HEAP sort both are correct.


but Constants involved in MERGE SORT (i.e. C*nlogn, C is constant ) is much much larger than Constant involved in HEAP
SORT..
Practically HEAP SORT overcome MERGE SORT for very large array.

 1 votes -- Digvijay Pandey ( 26245 points)

21.128 Sorting: If we have two sorted array of size 'a' and 'b' and "one array
smallest element is greater than largest element of other one".Then in the
merge procedure, what will be its time complexity? top gateoverflow.in/14157

P.S. Applied conditions given in " " is applicable on any(as per choice)

algorithms sorting

then the complexity will be O(a+b) because merge procedure isnt in place . And the comparisons required is min of a,b .

 2 votes -- Pranay Datta ( 6113 points)

21.129 Sorting: sorting analysis top gateoverflow.in/40683


Given an unsorted array. The array has this property that every element in array is at most k distance from its position in sorted array where k is
a positive integer smaller than size of array. Which sorting algorithm can be easily modified for sorting this array and what is the obtainable time
complexity?

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2071 of 2244

(A) Insertion Sort with time complexity O(kn)


(B) Heap Sort with time complexity O(nLogk)
(C) Quick Sort with time complexity O(kLogk)
(D) Merge Sort with time complexity O(kLogk)

Answer: (B)

please explain how ??

algorithms sorting

Since elements are stored in an array..

We have a heap..

To sort the given array,, we only have to convert that heap to either max heap or min heap...

Now,,

Elements are atmost k spaces apart we need logk time to move one element to its sorted place..

So for n elements,,

Required time is n times log k..

In nlogk time we have obtained a max heap..

To get a sorted array from a max heap required time is order of n..

Hence total time= O(nlogk)+O(n)= O(n logk)

 0 votes -- rakson ( 11 points)

21.130 Stack: Infix expression evaluation complexity top gateoverflow.in/30446

What is the complexity of evaluating an infix expression having n operators?

stack algorithms time-complexity

It will be O(n) only.

Method 1 :

It takes O(n) time to convert a infix expression into the postfix expression and only one left to right scan is enough to
compute the value of the expression which will take O(n) again.

So totally its O(n).

Reference :

1] http://geeksquiz.com/stack-set-2-infix-to-postfix/ & http://geeksquiz.com/stack-set-4-evaluation-postfix-expression/

2] http://faculty.cs.niu.edu/~hutchins/csci241/eval.htm

Method 2 :

Alternative to method 1, you can also go for evaluation using two stacks, Operator stack & Operand stack.

Check this for more reference : http://stackoverflow.com/questions/13421424/how-to-evaluate-an-infix-expression-in-


just-one-scan-using-stacks

 0 votes -- Sandeep Singh ( 5939 points)

21.131 Stack: check the question top gateoverflow.in/36150

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2072 of 2244

consider the following infix expression which is to be converted to postfix expression using stack.

(((P+Q)*(R+S))/T)+(A*(B+C))

The sum of all unique possible heights of stack when converting infix to postfix is______

ans given:15

but i am getting 19.is this correct?

stack

Hight of stack is 6

 0 votes -- Sunny ( 477 points)

21.132 Storage Classes In C: what is the storage class of a global variable ?


top gateoverflow.in/14755

If I write

#include<stdio.h>
int a;
main()
{
//code
}

then since a is a global variable so what is the storage class of it , is it extern ?

programming-in-c storage-classes-in-c


Selected Answer

No, it is of static storage class because you have also defined variable here.

If you have written extern int a;, then it would have been of extern storage class.

Ref: http://www.lix.polytechnique.fr/~liberti/public/computing/prog/c/C/CONCEPT/storage_class.html

 2 votes -- Happy Mittal ( 9253 points)

21.133 Structures: C Programming doubt top gateoverflow.in/41861

What is the difference between struct node* head= NULL and struct node* head= (struct node*)NULL ?

programming-in-c structures pointers

As NULL in C is #defined as

#define NULL ( (void *) 0)

Andas c supports implicit type conversion so in case of struct node* head= NULL, from the (#define ) mentioned above
NULL will automatically be type-casted into (struct node*) NULL.

Which in the next case you are doing manually.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2073 of 2244

 1 votes -- souravpunoriyar ( 33 points)

21.134 Syllabus: What all subtopics in Programming in C is required for Gate


2017? top gateoverflow.in/41830

In the syllabus given by IISC, it just says Programming in C. But it doesn't mention about the subtopics.
As there are many topics are there in c like :
C - Overview
C - Environment Setup
C - Program Structure
C - Basic Syntax
C - Data Types
C - Variables
C - Constants
C - Storage Classes
C - Operators
C - Decision Making
C - Loops
C - Functions
C - Scope Rules
C - Arrays
C - Pointers
C - Strings
C - Structures
C - Unions
C - Bit Fields
C - Typedef
C - Input & Output
C - File I/O
C - Preprocessors
C - Header Files
C - Type Casting
C - Error Handling
C - Recursion
C - Variable Arguments
C - Memory Management
C - Command Line Arguments

But I don't know which of the above is enough for gate.

syllabus

Divide the syllabus into 4 categories:

1.Basics (data types,variables,constants,operators,storage class)

2.Control statements & functions (along with recursion)

3.Advanced topics(Array,string,pointers,structure,union)

4.Miscellaneous (bit operations,preprocessors,etc.)

 1 votes -- Vivek Srivastava ( 283 points)

I guess Arrays and Pointers...That should do it


Mainly question will be from these two topics..
Rest all the Topics are pretty straightforward..

 1 votes -- saif ahmed ( 931 points)

21.135 Time Complexity: Iterative complexity. top gateoverflow.in/35647

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2074 of 2244

time-complexity


Selected Answer

complexity will be n+n/2+...1(logn terms)

Solve using Geometric Progression

Ans will be O(n)

 2 votes -- Pooja ( 22773 points)

21.136 Time Complexity: What is the time complexity ? top gateoverflow.in/250

What is the time complexity?

main()
{
n=2^2^k, k>0
for(i = 1 to n)
{
j=2
while(j ≤ n)
{
j=j^2
}
}
}

programming time-complexity


Selected Answer

I assume 2^2^k is evaluated as 2^(2^k)


In each iteration of while loop j is becomeing 2^2^l (where l is the loop iteration count) and loop terminates when j =
2^2^k. So, l must be equal to k when loop terminates. So, complexity of while loop is Θ(k). Now, the outher for loop runs
for n iterations and hence the complexity of the entire code is

Θ(nk) = Θ(nloglogn)

 2 votes -- Arjun Suresh ( 124125 points)

21.137 Time Complexity: Comparing Iteration computation. top gateoverflow.in/35962

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2075 of 2244

time-complexity algorithms

21.137 Variable Binding: What is the difference between static scoping and
dynamic scoping? top gateoverflow.in/19381

programming variable-binding


Selected Answer

STATIC SCOPING
by default C is static scoping in this scoping firstly the value which going to be printed is looked in local scope if it is
present than the values will be printed if it is not present than the values will searched in STATIA AREA(i,e int a=10,b=2)
also when the program will complie the memory will be allocated to static area and these values will remain till the
program did not end .here is small example :

int a=10,b=2;
main()

int t=6;

printf(a,b,t); // here a=10 , b=2 ,t=6 will be printed becoz firstly it try to look within this red scope if it find these
values ,than these value will be printed but here it did n't find so it will print the static variables
( i,e nt a=10,b=2)

}
DYNAMIC SCOPING :

main()
{

int a=10,h=567;

d();

printf(a,h); // here a=10 ,h=567 will be printed

}
d()

int p=90;

printf(h,p); // p=9 will be printed and wt for h?? h is not present in the local scope so it will look in previous local
scope from where this d() is being called so here h will be printed as 567.

}
now if in above dynamic program if the int p=90 is not present than it will be looked in static area in case of STATIC
SCOPING but IN DYNAMIC SCOPING it will be looked up in the previous local scope from where the function is being
called..

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2076 of 2244

 0 votes -- kunal chalotra ( 3567 points)

21.138 How to find the number of height balanced nodes in a tree in O(n)
time ? top gateoverflow.in/42251

A node is height balanced if difference between height of left subtree and right subtree is either -1 , 0 or 1 , so how to count
such nodes , without maintaining any extra field in the node except for left and right child pointers .


Selected Answer

Do a post order traversal of the tree.

First we traverse the left subtree - let it return the height of it - say n1.

Traverse the right subtree - let it return its height - say n2.

Now, if |n1 - n2| <= 1 increment a global counter.

Tree traversal is O(n) and so we are done.

 3 votes -- Arjun Suresh ( 124125 points)

21.139 sorting top gateoverflow.in/42941


Selected Answer

Radix sort takes linear time so ans is B.

 0 votes -- Manojk ( 3365 points)

21.140 prgming top gateoverflow.in/42099

explanation pls

void main(){
float a;
a=6.7;
if(a==6.7)
printf("A");
else
printf("B");
}

Print B

here float is compared with long double condition become false.So B is Printed .

To get rid of problem make

(i) make a long double

or

(ii) type cast a to a float

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2077 of 2244

 2 votes -- Manojk ( 3365 points)

21.140 what is stackoverflow? top gateoverflow.in/41972

stack overflow occurs if the call stack pointer exceeds the stack bound. the program uses to store information during a
function call about where to return to. Each time you call a function, the CPU saves the location of what's currently
executing onto the stack, then jumps to the new function. When the function is done, it pops that location off the stack
and returns there. This is what makes recursion possible.

When a program attempts to use more space than is available on the call stack, typically resulting in a program crash.
Possible causes are Infinite recursion, Very deep recursion or Very large stack variables.

The actual size of the stack is completely platform-dependent. Many operating systems tend to limit the size of the stack
to a few megabytes, but allow that size to be changed. If the system runs out of virtual memory, this can also limit the
stack size. Some (much) older CPUs have a fixed-size stack (the Intel 8008 only has 7 stack entries).

If we run this program, compiler will print "Stack Overflow" until stack overflows.

#include​<stdio.h>
int main()
{
printf("Stack Overflow");
main();
}

 0 votes -- vamsi2376 ( 1185 points)

21.141 output top gateoverflow.in/33200

programming


Selected Answer

should be d

p is pointer to constant int

so u cant modify value

 4 votes -- Pooja ( 22773 points)

21.142 total possible BST with n nodes top gateoverflow.in/33634

total possible binary search trees with 3 nodes is:

14 15 6 none

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2078 of 2244

2nCn/n+1

=6C3/4

 2 votes -- Anurag Semwal ( 4775 points)

21.143 Complexity top gateoverflow.in/33490

in c option
it says f(n)<=2n+10
here f(n)=2n-4
means
2n-4 <=2n+10
2n * 2-4 <=2n * 210

2-4 <=C * 210

where c is constant for c>0


there fore c option is true..

similarly for (a) option there exist a positive constant for which this function is theta of n hence true
also we can both are asymptotically equal so (a) option is true.

(b) option

f(n)>=n1000
2n-4 >=n1000
asymptotically we can say :2
n >=n1000

apply log both side


n * log 2 >=C * (10000log n)
clearly LHS is bigger so this option also true
so (d) answer..

correct me if any mistake thanks...


 1 votes -- kunal chalotra ( 3567 points)

21.144 Pointers top gateoverflow.in/32969

Main()

int a[2][3][2]={{{2,4},{7,8},{3,4}},{{2,2},{2,3},{3,4}}};

Printf("%u",a);

Printf("%u",*a);

Printf("%u",**a);

Printf("%u",***a);

Printf("%u",a+1);

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2079 of 2244

Printf("%u",*a+1);

Printf("%u",**a+1);

Printf("%u",***a+1);


Selected Answer

int a[2][3][2];

a can be taken as * to int[3][2];

sizeof(*a) = 3*2*4 = 24 (assuming sizeof(int) = 4)

Printf("%u",a); //address of a

Printf("%u",*a); //Address of a (a[0] = *(a+0))

Printf("%u",**a); ADDRESS of a (a[0][0] = *(*(a+0)+0))

Printf("%u",***a); 2 (a[0][0][0] = *(*(*a+0)+0)+0))

Printf("%u",a+1); address of a + sizeof(*a) = address of a +24

Printf("%u",*a+1); address of *a + sizeof(**a) = address of a + 8

Printf("%u",**a+1); address of **a + sizeof(***a) = address of a + 4

Printf("%u",***a+1); 2+1 = 3.

 5 votes -- Arjun Suresh ( 124125 points)

21.145 DataStructure top gateoverflow.in/32051

Which of the following data structures would programmer be least likely to use to implement an abstract data type that must
include an efficient implementation of the operation " find the maximum"?

a. Ordered array.
b. Binary search.
c. Heap.
d. Ordered linked list.

the answer should be d. ordered linked list.(if ordering is done in ascending order then it will take O(n) time to retrieve
max value as it need to traverse the link list)

the question is asking least likely to be used not most likely.

 5 votes -- Abhishekcs10 ( 1001 points)

21.146 Why this is not working? top gateoverflow.in/44251

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2080 of 2244

//First Case
char *p, q[100];
p = "Hello"; //1
q = "Hello"; //2
//Second Case
char *p, q[100];
scanf("%s",p); //1
scanf("%s",q); //2

In the first case, 1st works but 2nd does not work. why?

In the second case, 1st does not work while 2nd work. why?


Selected Answer

//First Case
char *p, q[100];
p = "Hello"; //1
q = "Hello"; //2

//1 : Here compiler, allocates memory location for "Hello" in the memory and assigned base address of that memory
location to pointer p.

//2 : Here also compiler allocates memory for "Hello", But when it tries to assigned the base address to pointer q, then
compiler rejects that, because q is a constant pointer pointing to the array of size 100. Read any array chapter of any C
book, you will get the concepts.
//Second Case
char *p, q[100];
scanf("%s",p); //1
scanf("%s",q); //2

//1 : Here In this case compiler receives a string, but when it goes for memory location to put that string then it does not
get that memory location, hence it give error. To make it working we have to do the following.
char *p;
p = (char *) malloc(100*sizeof(char));
scanf("%s",p); //1

Now this will work.

//2 : Its is perfectly Ok. No problem here.

 2 votes -- Rude Maverick ( 3063 points)

21.147 stack top gateoverflow.in/31438

We want to reverse elements of stack using a queue. Suppose stack operations push and pop take 1 unit of time each and
queue operations insert and delete take 2 units of time each. Assume n elements are there in the stack .The minimum time
to reverse the stack is a) 4n units a) 6n units a) 8n units a) 9n units


Selected Answer

Let there be 5 element is the stack -> 1 2 3 4 5 we want to reverse it as 5 4 3 2 1

1. POP 1 element from stack i.e 1 unit of time & Enqueue in the queue i.e 2 unit of time
repeat five times till stack is empty So total time till here (1+2)* 5 = 15 unit time
2 Dequeue from queue i.e 2 unit of time and push into stack i.e 1 unit of time
repeat five times till queue is empty So total time till here (1+2)* 5 = 15 unit time

so total time = 15 + 15 = 30 = 6*5

so for n element 6*n

 3 votes -- Umang Raman ( 10379 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2081 of 2244

21.148 What will be output top gateoverflow.in/32730

#include<stdio.h>

int main()

{ char *x;

x = (char *) &a;

a = 512;

x[0] = 1;

x[1] = 2;

printf("%d\n",a);

return 0;

What is the output of above program? (a) Machine dependent (b) 513 (c) 258 (d) Compiler Error

Ans. d) Compiler Error

you are using a without declaring a

x = (char *) &a;

See here : http://ideone.com/iXIzZ4

you are trying to get the address of a identifier which have not declared and defined. Once you define a variable then only
compiler will allocate memory space to it and once you will have a memory allocated to it then only you can get the
address of that memory.

Once you are declaring 'a' output of program will be dependent on which machine you are running this program whether
its Big Endian/Little Endian.

Lets assume that you are using a machine which stores data in Little Endian format and integer is of size 4 bytes. So once
you are defining variable like below

int a;

It will allocate a 4 bytes to it. So for you have not assigned a value to it, this integer will contain a garbage value. Suppose
memory is byte addressable and memory allocated to int is starts with memory location 2012 - 2015 where location
2012th byte contain least significant bit of the 4 byte integer. (Here i have assumed little endian format. Check it for more
detail : http://williams.comp.ncat.edu/Endian.htm)

x = (char *) &a;

This way &a will represent the starting address of integer i.e. 2012 and once you are type casting it into char pointer still
char pointer x will hold the address 2012.

a = 512

It will assign the value to the integer as 512. Bit at 2012 to 2015 will look like

00000000 00000000 00000010 00000000


2015 2014 2013 2012

X[0] = 1

it will put 1 at the location (x+0) i.e. 2012 th byte will be changed to 00000001

x[1] = 2

it will put 2 at the location (x+1) i.e. 2013 th byte will be changed to 00000010

Now the complete memory from 2012 to 2015 will be look like

00000000 00000000 00000010 00000001

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2082 of 2244

2015 2014 2013 2012

Its decimal equivalent will be 513.

** That's what you have got. In case you would have using a machine which uses Big Endian format to store binary
numbers.
Then the value of 'a' would have become (00000000 00000010 00000010 00000001)2 = (131585) 10 .

 2 votes -- Sandeep Singh ( 5939 points)

21.149 What is the output for this program?? top gateoverflow.in/32746

#include<stdio.h>

#include<stdio.h>

#include<stdlib.h>

void fun(char** str_ref)

str_ref++; }

int main()

char *str = (void *)malloc(100*sizeof(char));

strcpy(str, "ravindras");

fun(&str);

puts(str);

free(str);

return 0; }

21.150 data structure top gateoverflow.in/44098

data-structure

Abstract data type option B

Data structures can implement one or more particular abstract data types(ADT), which specify the operations that can be
performed on a data structure . A data structure is a concrete implementation of the specification provided by an ADT.

 0 votes -- Manojk ( 3365 points)

21.151 program top gateoverflow.in/34117


What will be the output of the following program assuming that parameter passing is
i. call by value

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2083 of 2244

procedure P{a, b, c};


begin a:=b:=3;
b:b+1; c: a+a
end;
begin
main
P(a+b, a, a);
Print(a)
end.

answer is 3 ?

 1 votes -- sonali gupta ( 27 points)

21.152 maths top gateoverflow.in/44102

No of non-negative integral solutions for x1 +x2 + x3 +.......x n = r where x1,x2,...x n >=0 is C(n+r-1,r).

Here first convert given equation in above form as:

x1+x2+x3 = 11 => (x1-1) + (x2-2) +(x3-3) = 5 => Y1 + Y2 +Y3 = 5 where Y1 = x1-1;Y2 = x2-2;Y3 = x3-3

So our equation reduces to: Y1 + Y2 +Y3 = 5 where Y1,Y2,Y3 >=0;

hence no of solution = C(3+5-1,5) = C(7,5) =>option (D) is correct.

 0 votes -- Shashank Kumar ( 2029 points)

21.153 ugc net top gateoverflow.in/43698

20. The correct way to round off a floating


number x to an integer value is
(A) y = (int) (x + 0.5)
(B) y = int (x + 0.5)
(C) y = (int) x + 0.5
(D) y = (int) ((int)x + 0.5)

Option C is correct

Option a is wrong -- Since you are rouding off the whole result of addition and not x

Option B is error you cant do this

option d is -- You are converting an x into integer first then after adding with 0.5 you will again get a result as floating
value .

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2084 of 2244

and then you are converting this into integer

But they have asked to convert x into integer so option c is correct

 0 votes -- Dexter ( 1933 points)

21.154 about c language top gateoverflow.in/41339

what is function in c pragramming to take mod of number in c ie. |-15|=15


Selected Answer

abs function

SYNOPSIS
#include <stdlib.h>
int abs(int j);
long int labs(long int j);
long long int llabs(long long int j);

 7 votes -- Arjun Suresh ( 124125 points)

You can always design your own,

int mod(int num){


if(num<0) return -num;
else return num;
}

 3 votes -- Rude Maverick ( 3063 points)

21.155 daa top gateoverflow.in/38511

the height of tree is the length of the longest of the longest root to leaf path in it.the max and min no of
nodes of height 5 are_________


Selected Answer

max number of nodes at height h : 2^(h+1)-1 ; tree has to be completely full

so at h=5 ; n=2^6-1=63

min no of nodes at height 5 : 6 (skewed tree)

 1 votes -- Sourasekhar Banerjee ( 179 points)

21.155 a polynomial P (x) satisfies the following P (1)=P (3)=P (5)=1 P


(2)=P (4)=1 top gateoverflow.in/38531

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2085 of 2244

21.156 optimal binary serch tree top gateoverflow.in/38659

The cost of optimal binary serch tree for the identifier set (a1,a2,a3) = (do , if , while ) with p(1) =0.3,p(2) =0.2, p(3) =
0.15, q(0) = 0.05,q(1) = 0.15,q(2) =0.1,q(3) =0.05 is ?

21.157 column major top gateoverflow.in/38489

Consider a three dimensional array A[50][20][30] stored in linear array in column major order . If the base address starts at
1000, the location of A[20][10][10] is ..? (assume first element is stored at A[1][1][1])

1000 + 19*20*30 + 9*20 + 9

 0 votes -- vijaycs07 ( 263 points)

21.158 stack top gateoverflow.in/31437

Five nodes labeled 1,2,3,4,5 are used to construct different binary trees. How many such binary trees can
be constructed whose preorder traversal is 1,2,3,4,5?

Ans given is 42 but how??


Selected Answer

number of tree with unlabeled node=2nCn/n+1

number of tree with labeled node=(2nCn/n+1)*n!(each number can arrange themself in n! ways that is why we are
multiplying with n!)

so with 5 unlabeled node total 42 Binary trees are possible

that means with 5 unlabeled node we have 42 different structures possible

now if you label each structure then total 5! different trees are possible in each structure

But there will be only one tree which will produce preorder as 1,2,3,4,5

that means from each structure you will get only one tree which has preorder as 1,2,3,4,5

So total such structure is 42

therefore total possible is 42

you try to draw a structure then you will get a clear idea

 5 votes -- Sandip Shaw ( 755 points)

21.159 check the question top gateoverflow.in/36133

A simple undirected graph 'X' has 10 vertices.If 'X' has 5 equally sized connected components, the maximum no of edges in
the graph 'X' is_____

graph-theory

ans is 5.

bz component of equal size then no of vertices in each componet =n/k=10/5=2

no of egdes=k*(n/k-1)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2086 of 2244

 0 votes -- govind ( 255 points)

21.160 Asympotic notations top gateoverflow.in/37116

T(n)=16T(n/4)+n!

how to take k value for master therom by using n!???


Selected Answer

For Master theorem, a = 16, b = 4, nlogb a = nlog4 16 = n2 . Now, n2 is having a polynomial time difference with n!? yes, because
n3 = O(n!). So, we can say f(n) = n! = Ω nlogb a +ϵ . ( )
Now, this is Case 3 of Master theorem. But we need to show the regularity condition also for Case 3. i.e.,

n
af b
() ≤ cf(n).

for some c < 1 and all sufficiently large n.


n n n

Here, we get af
() ()
b
= 16f 4
= 16 4 !.

1
16
This should be less than cf(n) = cn!. Here, it is easy, take c = and we are done.

So, answer is T(n) = Θ(n!).

Actually we need not do all these in exam if we understand Master theorem properly. The case 1 of Master theorem is
saying the recurrence is mainly dependent on the recursive call but not on f. Case 2 is when the recurrence is dependent
on both. Case 3 is when the recurrence is dependent on f only. So, if we see that f is abnormally large like n!, we can
straight away write the complexity.

http://www.csd.uwo.ca/~moreno/CS433-CS9624/Resources/master.pdf

 3 votes -- Arjun Suresh ( 124125 points)

21.161 Max Number of edges top gateoverflow.in/37274

A simple undirected graph ‘X’ has 10 vertices. If ‘X’ has 5 equally sized connected components, the maximum number of edges
in graph ‘X’ is _________.

data-structure

21.162 madeeasy P_DS Basic Level top gateoverflow.in/38711

Consider the following program:


# define Rec(a) a + a * a
int a;
a = 20 + Rec(a) * Rec(a + 1);
printf(“%d”, a)
return 0;
}
The output of above program for a = 3 is ________.

made-easy test-series programming

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2087 of 2244

Selected Answer

#define is a Macro. What is the meaning of Macro is that, it will replace the value at compile time. It means that

If we have defined

#define FIVE 5

then in this for loop,

for(int i=0; i<FIVE; i++)

When compiler compile the above line then it will replace FIVE with 5. The point I want to make here that Program replaces
Macro before starting the execution of the program.
Now comes to Question.
#define Rec(a) a + a * a

At compile time expression a = 20 + Rec(a) * Rec(a + 1); will be replaced as


a = 20 + a + a * a * a + 1 + a + 1 * a + 1; (lets evaluate it)
a = 20 + 3 + 27 + 1 + 3 + 3 + 1;
a = 58.

Hence Program will print 58.


 6 votes -- Rude Maverick ( 3063 points)

Rec(a)=a+a*a

Rec(a+1)=a+1+a+1*a+1
After compilation this line a = 20 + Rec(a) * Rec(a + 1); become convert into this:-
a=20+a+a*a * a+1+a+1*a+1
for a=3
value of a will be printed 58.

 1 votes -- Avdhesh Singh Rana ( 1509 points)

21.163 check this top gateoverflow.in/39119

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2088 of 2244


Selected Answer

Function add all digits of parameter and then return f(sum of digits)
If sum of digit is 9 then it will return 1 else 0.

after 1st function call Sum = 58


then F(58 ) will be called..
next is f(13)
next is f(4)
Finally 0 returned .

 1 votes -- Digvijay Pandey ( 26245 points)

21.164 regarding pointers top gateoverflow.in/35193

What does this mean?

int *(*func())[]

According to me , it means that its an array of pointers to functions which returns pointers of type int. Am I correct?


Selected Answer

For these type of complicated declarations, you can follow Clockwise/Spiral rule : http://c-
faq.com/decl/spiral.anderson.html

By that rule, func is a function taking no arguments and returning a pointer to an array of pointers to int.

 3 votes -- Happy Mittal ( 9253 points)

func is a function returning pointers to array of pointers to int

 1 votes -- Shashank Chavan ( 2439 points)

21.165 c array top gateoverflow.in/41331

Under which of the following conditions, the size of an one-dimensional array need to be specified ?

a) when initialization is a part of definition

b) when it is a declaration

c) when it is a formal parameter or actual parameter

d) none of the above

option d

 2 votes -- Manojk ( 3365 points)

Option (b) When it is a declaration. is correct.

Because,

When Initialization is a part of declaration then we do not need the size.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2089 of 2244

Similarly when we use that as formal and actual parameter, we do not have to give the size. Compiler figure that out
automatically.

 2 votes -- Rude Maverick ( 3063 points)

b) when it is a declaration

 1 votes -- Anurag Semwal ( 4775 points)

21.166 find the output top gateoverflow.in/36128

21.167 array top gateoverflow.in/41164

Q1:

If the array is 1-ordered, it means that It is an array of ascending order. This is the only chance that it can be of 1-
ordered.

It means that if array has 2N element and 1-ordered then its element can be of [1,2,3,4,5,...........,2N-1,2N].

Now an array can be 2-ordered only when its odd position is 1-ordered with odd position and even position is 1-ordered
with even position element. So it can be arranged like this. [N+1,1,N+2,2,N+3,3,N+4,4,N+5,5,..........,N-2,2N-2,N-1,2N-
1,N,2N].

So the maximum number of position difference can be N. ( See the First Element of both the array).

So, Option (e) is correct.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2090 of 2244

Q2:

The first element has to be <= the 3rd, 5th, ... elements by the 2-orderedness and <= the 4th,6th,... elements by the 3-
orderedness and the 2-orderedness combined. So it has to be in either the 1st or 2nd position.
Suppose that the first element (if any) not in its usual position is the kth element. Then it has to be in position k+1 by a
similar argument.
Now consider what must be in position k - it has to be k+1. If not it is bigger than k+1 and comes at least 2 before k+1 in
the list, acontradiction.
So at worst k,k+1 have swapped places. Then the first k+1 places can not effect the remainder of the list (as
they must all be less than any element in the remainder of the list) so we can repeat the same argument further on. Thus
the answer must be (d) i.e.1.
So the answer is (d).

 2 votes -- Rude Maverick ( 3063 points)

21.168 Java top gateoverflow.in/40007

Why c is faster than java.

programming

Actually this is very long topic to discuss about!


If you want to dig deep, check this out http://stackoverflow.com/questions/418914/why-is-c-so-fast-and-why-arent-
other-languages-as-fast-or-faster

Also there are many posts/blogs are there about it.


Few reasons :
Java is purely High level language while C is kind of Middle level language,
Java uses byte code and Just in time compilation, C programs executes directly.
Java(bytecode) needs to be cross platform, C is not that kind of portable
Java supports garbage collector and its own GUI(Like swing and FX),C does not.
and so on.
Even most of the part of Java and many HLL languages are written in C ;)

 0 votes -- Shashank Chavan ( 2439 points)

21.168 Data structure used in TSP top gateoverflow.in/39258

data-structure

One of the ways of solving Travelling Salesman Problem is by Dynamic Programming using Held-Karp algorithm.

For that only a 2-D array is used to store the values in a table for memoization.

 0 votes -- Sourav Mishra ( 221 points)

21.169 static and dynamic scoping top gateoverflow.in/39333

How to calculate the static and dynamic value for the given program

21.170 infix to postfix notation under customized operator precedence gateoverflow.in/34206

top

A designed a language with following features:

+ precedes /

/ precedes -

- precedes *

* at same level with ^

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2091 of 2244

+ and * right to left asscociativity.

Then correct stack priorities for +,*,^, / for correctly converting infix to postfix form?

5,1,2,4 4,1,5,2 3,1,1,2 none

21.171 The number of possible ordered trees with 3 nodes A,B,C top gateoverflow.in/19903

amount of time it would take to send 500 packets using 6-packet size window and without sliding window will be, when the
time to send in one direction is 5 ms

31000, 5000

4600, 21600

5000, 30000

30000, 5000.......... pls explain the logic behind?

No. of BST = 2nCn/n+1 = 6C3/4 = 5


No. of Binary tree = (2nCn/(n+1))n! = (6C3/4)*3!= 30

 0 votes -- Umang Raman ( 10379 points)

21.172 Which of the following is illegal statement in C? top gateoverflow.in/12264

a) int (**p) [ ];

b) int *(*p) ( );

c)int (*f( ) ) [ ];

d)int *f( ) [ ];


Selected Answer

Option D is invalid .

Option a p is a pointer of a pointer of an arr

Option b p is a pointer of a function which return a int type pointer

Option c f is a function which return a pointer of an array

 2 votes -- Pranay Datta ( 6113 points)

21.173 overloaded mean use same operator in multiple form basic mean shd
same then how a is ans shd b ans na top gateoverflow.in/12130

When a programming Language has the capacity to produce new datatype, it is called as

(A) Overloaded Language


(B) Extensible Language
(C) Encapsulated Language
(D) Abstraction Language

programming

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2092 of 2244

Extensible Language

 1 votes -- Rohan Ghosh ( 1515 points)

21.174 program top gateoverflow.in/12674

void main()

float a=55555;

printf("%.2E %.2e\n",a);

a)5.56E+004 8.12e+268

b)compilation error

c) runtime error

d)555.55E+002

answer is A) 5.56E+004 8.12e+268

e Scientific notation (mantissa/exponent), lowercase


E Scientific notation (mantissa/exponent), uppercase

 0 votes -- Pranay Datta ( 6113 points)

21.175 program top gateoverflow.in/12675

void main()

int i=12345,j=0xabcd9,k=077777;

printf("\n%08d %#8x %#8o"i,j,k);

I think ( i`m not sure )

the output will be :

00012345 0xabcd9 077777

its actually

Please see this link it will even more clear your doubts : http://codingfox.com/4-2-formatting-output-using-printf/

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2093 of 2244

 1 votes -- Pranay Datta ( 6113 points)

21.176 program top gateoverflow.in/12686

main()
{
char line[80];
scanf("%[^,]s",line);
printf("\n%s",line);
}

if input is:Dear students


then output is?


Selected Answer

scanf("%[^,]s", line);

This reads every character till the first "," is given. So, if just "Dear students" is given the program will continue waiting
for input.

PS: These questions are not relevant for GATE. Format specifiers of printf is not in GATE syllabus.

 2 votes -- Arjun Suresh ( 124125 points)

21.177 program top gateoverflow.in/12014

void fun(int *p)


{
int q = 10;
p = &q;
}

int main()
{
int r = 20;
int *p = &r;
fun(p);
printf("%d", *p);
return 0;
}
a>10
b>20
c>Compiler error
d>Runtime Error


Selected Answer

in fun() p is the copy of the main functions pointer p..hence any change in the pointer p in fun()...does not affect the
pointer p in main fun()...thus when fun() returns to the main fun()..that copy of the local variables and pointers gets
deleted..hence the pointer p keeps on pointing to r whose value is 20. Always remember-if we want to change a local
pointer of one function inside another function, then we must pass pointer to the pointer. By passing the pointer to the
pointer, we can change pointer to point to something else.

Hence option B is correct.

 4 votes -- debanjan sarkar ( 775 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2094 of 2244

21.178 Code for Merging for an array top gateoverflow.in/11012

There are two arrays A and B having N/2 elements. The elements are stored in ascending order already . Merge these
arrays and create a new array C of size N . A code fragement is given. fill the missing part in it. the index variables have
initial value as zero

if(...........)

C[] =.......... ;

else

C[]=...........;

 1 votes -- Bhagirathi Nayak ( 10239 points)

21.179 C-programming top gateoverflow.in/10433

On running this code I am getting illegal initialization ..please explain...

Also in following link ans is given as d)....(Q-9)

http://gpl4you.com/viewquestype.php?type=3&company=VIRTUSA

static variables are assigned memory during compile time. Hence they cannot be initialized with the result of a function
call- only compile time constants can be used to initialize them. So, invalid initialization.

Of the choices given, the most apt would be 'B' rvalue required. The error I got with gcc is

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2095 of 2244

"error: initializer element is not constant"

 0 votes -- Arjun Suresh ( 124125 points)

21.180 please provide proper explanation..! top gateoverflow.in/10747

what is the output of pro..??

#ifndef include<stdio.h>

void main()

#endif

printf("%d",900*90/90);

Supposing include is not defined during compilation, the code should produce compile warning/error.

1. Extra tokens at end of ifdef

2. return type of main must be int

3. printf used without declaration

NB: These type of questions won't be asked for GATE

 2 votes -- Arjun Suresh ( 124125 points)

since #include<stdio.h> is not defined here, so the (#ifndef ...) statement will be true and whatever that is there inside
the #ifndef.....#endif construct, gets executed !

The program will be as follows after preprocessing -

void main()

printf("%d", 900*90/90);

This will produce the output as 900 in some compilers.

 1 votes -- ravi_ssj4 ( 29 points)

21.180 What is the output ? int x=8; x-=--x-x--; printf("%d",x); top gateoverflow.in/10942

programming


Selected Answer

There is a rule called "sequence point rule" in C. We are not allowed to modify a memory location more than once or read
and write the same location (reading other than for the purpose of getting a value to write) between two sequence points.
If we do this, the result is "Undefined".

Reference: http://gatecse.in/wiki/Undefined_Value

 4 votes -- Arjun Suresh ( 124125 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2096 of 2244

21.181 Code for stack push top gateoverflow.in/11011

A stack is implemented as an array Stack of size N. TOS points to the current top of the stack . The initial value of TOS is -1.
The code for push operation for a value in stack is given. fill EMPTY BOX 1 and EMPTY BOX 2

if( EMPTY BOX 1)

Stack[EMPTY BOX 2] = value;


Selected Answer

if (TOS < N)

Stack[++TOS] = value;

 2 votes -- Arjun Suresh ( 124125 points)

21.181 is prolog a strongly typed langue? top gateoverflow.in/12753

programming

NO.PROLOG IS NOT A STRONGLY TYPED LANGUAGE.NOT NECESSARY FOR GATE.

 0 votes -- Rohan Ghosh ( 1515 points)

21.182 C-Programming top gateoverflow.in/12797

Find output

main()

int i=0;

for(;i++;printf("%d",i));

printf("%d",i);

A)0 B)01 C)1 D)11

Plz explain

In condition part of for loop, i++ evaluates to 0, and thus control doesn't go into for loop.

So it goes out of for loop and prints value of i, which is 1 now.

So answer is (C) 1.

 5 votes -- Happy Mittal ( 9253 points)

21.183 How to print the enter key character which gets stored inside the
buffer during scanning of a value into a variable ? top gateoverflow.in/13671

char ch;

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2097 of 2244

scanf("%c",&ch) // after I do scanning of this variable then after I press enter key then it gets stored inside the buffer so can
we print this enter key .Since during the next call to scanf function the enter key gets stored inside the variable .

Do one more

scanf("%c", &ch)

Now, ch will have Enter. So, do

printf("c", ch);

 0 votes -- Arjun Suresh ( 124125 points)

21.184 How does concatenation of 2 circular linked lists takes constant time
? top gateoverflow.in/13746

I am not getting that when head pointer has no information regarding the tail pointer then how is it that circular linked list
will have a constant time for its concatenation with another circular linked list , wouldn't it take same time if we perform
concatenation on a single or double linked list .

data-structure

You can easily concatenate two lists in O(1) time using either a single linked list or a doubly linked list, provided that you
have a pointer to the last node in at least one of the lists. (And, of course, pointers to the list heads.)

You can't do it with an array implementation, because you end up having to allocate more memory and copy the new
resulting list to it. Even if the array already has memory allocated, you still have to copy all of the new items to it. So it's
either O(m+n) or O(n) (where m and n are the lengths of the individual lists, respectively).

With a circularly linked list, you can easily concatenate them in O(1) time. It's just a matter of breaking a link in both lists,
and then hooking them together. This assumes, of course, that the order of items isn't especially important.

ref:http://stackoverflow.com/questions/25938499/linked-list-concatenation-in-o1-time

 1 votes -- Rohan Ghosh ( 1515 points)

21.185 why is the time complexity of operations like isempty, isfull, size,
delete stack takes constant time ? top gateoverflow.in/13748

According to me when we perform the above operations we have to traverse the entire list so then why does it all take
constant time ?

data-structure

For all the standard stack operations (push, pop, isEmpty, size), the worst-case run-time complexity can be O(1). We say
can and not is because it is always possible to implement stacks with an underlying representation that is inefficient.
However, with the representations we have looked at (static array and a reasonable linked list) these operations take
constant time. It's obvious that size and isEmpty constant-time operations. push and pop are also O(1) because they only
work with one end of the data structure - the top of the stack. The upshot of all this is that stacks can and should be
implemented easily and efficiently.

ref:http://pages.cs.wisc.edu/~siff/CS367/Notes/stacks.html

 2 votes -- Rohan Ghosh ( 1515 points)

stack data structure be like :1)STACK 2)STACK POINTER (points to top of stack) let's say stack starts from address AA1
and ends in KK1.initially stack pointer points to address (AA1-001)... ok now lets come to the operation isempty() if stack
pointer points to (AA1-001) isfull() if stack pointer points to KK1 size() STACK POINTER - AA1 delete() pop STACK[STACK
POINTER] and free[STACK POINTER] all of these operations take constant time

 1 votes -- Bhagirathi Nayak ( 10239 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2098 of 2244

21.186 How does the for loop works wherein in all test condition and update
expression we have function calls ? top gateoverflow.in/13931


#include<stdio.h>
int fun()
{
static int num = 16;
return num--;
}
int main()
{
for(fun(); fun(); fun())
printf("%d ", fun());
return 0;
}

The three parts of for loop (separated by semicolon) are required to be expressions (technically, first part can be a
declaration, but that distinction is not required here)

First part is executed once. It evaluates to 16 (since num-- has postfix decrement operator, not prefix), and side-effect is
num becomes 15.

Second part is condition part, which, if non-zero, is true, otherwise false. Again fun() is called, and value of this condition
expression is 15 (and num becomes 14), which is non-zero and thus control goes into loop body.

In loop body, again fun() is called, which evaluates to 14 and 14 is printed, and num becomes 13.

In third part of for loop, fun() is called again, which evaluates to 13, and num becomes 12. The value 13 is ignored, and
then again condition part is checked. This continues and prints 11, 8 ,5, 2.

When 2 is printed, num becomes 1, then in third part of for loop, num becomes 0, and then condition part evaluates to 0,
and loop breaks.

So it prints 14 11 8 5 2

 1 votes -- Happy Mittal ( 9253 points)

21.187 tree traversal top gateoverflow.in/13513

when is it possible in binary search tree that (preorder,inorder) ,(postorder,inorder),and (preorder,postorder) are
equal.please explain

AND what about binary tree

see ,BST inorder will be always ascending order and If you have just preorder or postorder its enough to create a unique
BST .

incase of binary tree you need (preorder,inorder) ,(postorder,inorder) to create a unique binary tree . If we restrict 1 rule
that tree node will have either 0 or 2 children then for these 3 cases (preorder,inorder) ,(postorder,inorder),and
(preorder,postorder) it will give unique binary tree .

 0 votes -- Pranay Datta ( 6113 points)

21.188 scoping in c top gateoverflow.in/13508

how static scoping and dynamic scoping works in c language.please explain every point which is helpfull for gate

C language is completely statically scoped. Dynamic scoping is not there in C but in GATE syllabus though not asked
recently. These are the previously asked question from this:

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2099 of 2244

http://gateoverflow.in/tag/variable-binding

 0 votes -- Arjun Suresh ( 124125 points)

21.189 Find output of following C program top gateoverflow.in/12809

main(){

int a[2][3][2]={ { {1,2},{9,8},{3,7} },{ {2,3},{1,4},{5,4} } };

printf("%d %d %d", a[1]-a[0],a[1][0]-a[0][0],a[1][0][0]-a[0][0][0]);

A) 3 3 1

B) 3 6 1

C) 6 6 1

D) 1 1 1

Plz explain

a[1][0][0]-a[0][0][0]=2-1=1
a[1][0]-a[0][0]=(address of a[1][0][0]- address of a[0][0][0])/size(int)=6*sizeof(int)/sizeof(int)=6;
(note: here a[1][0] is of type int *(i.e, starting address of 1D array or Integer pointer ) hence we divide by sizeof(int) )
a[1]-[0]=(address of a[1]-address of a[0])/ sizeof(int[2])=6*sizeof(int)/sizeof(int[2])=3
(note: here a[1] is of type int (*)[2](i.e, starting address of 2D array or pointer to a Integer array int[2]) hence we divide
by sizeof(int [2]) )
Hence the answer is B

 3 votes -- Mari Ganesh Kumar ( 1837 points)

21.190 How to implement stack using a queue ? top gateoverflow.in/13158

I am unable to understand the implementation of stack using queue , I understood queue implementation using stack but
not this one , I searched for a video lecture too but found for implementation of queue only , so plz help in making me this
understand .

data-structure

http://www.geeksforgeeks.org/implement-stack-using-queue/

 1 votes -- Rohan Ghosh ( 1515 points)

21.191 Suppose we have numbers between 1 and 1000 in a binary search


tree and we are searching for 360. Which of the following sequence could
not be sequence of nodes examined? top gateoverflow.in/13215

1. 2, 252, 401, 398, 330, 344, 350, 360

2. 924, 220, 911, 244, 898, 258, 362, 360

3. 925, 202, 911, 240, 950, 245, 360

4. 2, 399, 387, 219, 266, 382, 381, 278, 360


Selected Answer

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2100 of 2244

In binary search after each comparison

1. if value > x, the numbers greater than x are avoided


2. if value < x, the numbers lower than x are avoided

These avoided numbers won't come again in any comparison.

If we see the 3rd sequence given. 911 > 360 and after this 950 came. So, this is an invalid sequence.

 2 votes -- Arjun Suresh ( 124125 points)

21.192 What is wrong with the following code? top gateoverflow.in/13350

int *x=(int*) malloc(100*sizeof(int));

x=(int*)realloc(x,sizeof(int)*200);

a) If realloc fails then original memory is lost.

b) Nothing realloc is guaranteed to succeed(by returning the original pointer)

c) realloc might throw null pointer exception if malloc fails to allocate memory.

d) calloc should have been used instead of malloc.

a) If realloc fails, then the original memory is lost

ithink the qus is wrong it should be

int * x = (int *) malloc(100 * sizeof(int));


x = realloc(x, sizeof(int) * 200);

 1 votes -- Rohan Ghosh ( 1515 points)

21.192 pint= (int*)p; what is use of this statement. top gateoverflow.in/10363

first clarify this statement.


here
what is pint? Is it variable or not?
and what type of variable is p? Is it pointer variable or simply integer or float variable?

 0 votes -- Avdhesh Singh Rana ( 1509 points)

21.193 pointer arithmatic top gateoverflow.in/10123

#include <stdio.h>

int main(void) {

static char s[25]="TheCocaine Man";
int i=0;
char ch;
ch=s[++i];

printf("%c",ch);
ch=s[i++];
printf("%c \n",ch);
ch=i++[s];
printf("%c\n",ch);
ch=++i[s];

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2101 of 2244

printf("%c ",ch);
return 0;

how last ch print D?is ++i[s] incremet index or value?

1) S[i] = *(S+i) = *(i+S) =i[S]

2) ++S[i] = ++*(S+i) = ++*(i+S) = ++i[S]

In second case --> ++i[S] is expanded to ++*(i+S) by the preprocessor. * and ++ both are unary operators and priority
are same for both. So they will go for Right to Left associativity. So first *(i+S) will be computed which equals "C" and
then is incremented to D

 1 votes -- aayushranjan01 ( 325 points)

21.194 what is the output? top gateoverflow.in/4995

void strfind( char dest[], char src[] )

int i=0;

while ((dest [i] = src[i]) != '\0')

i++;

printf("%s, %s", dest, src);

main()

char A[] = {'g', 'a', 't', 'e', '\0' };

char B[] = {'e', 'x', 'a', 'm', '1' };

strfind (B, A);

21.195 what is output? top gateoverflow.in/4996

main()

int i= 1, j=2;

j= j++ && i++ || i--;

printf("%d, %d", i, j);

programming

j =1 and i = 2.

 2 votes -- Gate Keeda ( 16619 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2102 of 2244

21.196 Consider the following C code top gateoverflow.in/4997

main()
{
int x, y= 100;
float *P;
P=&y;
x=*P;
printf("%d", x);
}

what is output?

a) 100

b) 1

c) 0

d) none

programming non-gate

x = *P; //this line is problematic as it converts an integer (assuming it is a float) to float and then converts that float to
integer.

100 has storage in memory as

(Assuming little endian)

00100100 01000000 00000000 00000000

Now *P will return a float value (the content of the memory location of P will be treated as in IEEE single precision
format).
0 01001000 10000000000000000000000
[sign exponent mantissa]

So, this value will be 1.1 * 2^(72-127) which is a very small value close to 0 (127 is bias in IEEE repr.). When assigned to
an integer, it becomes 0 due to rounding.

http://steve.hollasch.net/cgindex/coding/ieeefloat.html

 2 votes -- Arjun Suresh ( 124125 points)

21.197 Consider the following C code: top gateoverflow.in/4998

char A[20];

A="gate";

which of the following is correct?

a) '\0' is automatically appended at the end of "gate".

b) '\0' is not stored at the end of "gate" in array A.

c) error produced by compiler

d) none of these

programming

a) '\0' is automatically appended at the end of "gate".

 1 votes -- sumit kumar singh dixit ( 1625 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2103 of 2244

21.198 what does b=(int *)**c contain address or integer value? top gateoverflow.in/4928

Pls explain the o/p of this code:

O/p:2,2

main(void) {

char a,*b=&a,**c=&b;
a=2;
**c=2;
b=(int *)**c;
printf("%d %d",a,b);
return 0;
}

programming

char a,*b=&a,**c=&b;
a=2;
**c=2;

b=(int *)**c;

Let address of a be 1000 and b be 1001 and c be 1009.

b = &a; b now contains 1000. (Don't get confused with * as it is part of char * and there is no dereferencing here)

c = &b; So, c now contains 1001.

a = 2; 2 is copied to memory location 1000.

**c = 2; //c contains 1001 and 1001 memory location now contains 1000. Since there is **, we go to memory location
1000, and because c is char**, a byte of memory storing 2 is copied to memory location 1000. (which makes a = 2)

b = (int *) **c;

**c returns 2 due to previous assignment. Now (int *) does a type conversion which makes 2 an address (nothing
happens here, compiler just treats 2 as an address). So, now b contains 2.

So, printf a,b, prints 2,2. But assigning integer values to pointers is a bad because dereferencing that location using *,
should result in segmentation fault as that shouldn't be a valid memory location.

 2 votes -- Arjun Suresh ( 124125 points)

21.198 \r in c top gateoverflow.in/4683

'\r' is no more useful in C. It is supposed to take the output to the beginning of a line (useful in typewriters), but C just
outputs this character to the terminal. Now, the terminal must decide what to do with this. Most current terminals just
ignore this.

 0 votes -- Arjun Suresh ( 124125 points)

21.199 What does the function brian return? top gateoverflow.in/193

def brian(n):
count = 0
while ( n != 0 )
n = n & ( n-1 )
count = count + 1
return count

Here n is meant to be an unsigned integer. The operator & considers its arguments in binary and computes their bit wise
AND. For example, 22 & 15 gives 6, because the binary (say 8-bit) representation of 22 is 00010110 and the binary
representation of 15 is 00001111, and the bit-wise AND of these binary strings is 00000110, which is the binary

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2104 of 2244

representation of 6. What does the function brian return?

programming normal


Selected Answer

Each time we & a number n with (n − 1) the 1 at the least significant bit position of the binary representation of the number
changes to 0.

This is because when we subtract a 1, the least significant bit always changes. If it was 1, it changes to 0 and if it was 0, it
changes to 1. If the change is 1 -> 0, no other bits are affected. So, the result of (n & (n-1)) will be n with its last bit as 0.
Now, if the change is 0 -> 1, this would mean all the bits to the left till the next 1 are complemented for n − 1 (consider 8
and 7 whose binary representations are 1000 and 0111). So, when we do (n & (n-1)), all the bits towards right from the
least significant 1 in the number become 0. So, in both the cases when we do (n & (n-1)), the least significant 1 changes
to 0.

Thus, the above code is doing nothing other than counting the number of 1's in the binary representation of the given
number. This is an efficient way as the loop runs only for O(k) where k is the number of 1's in the given number as
compared to O(d) where d is the number of bits in the given number for a normal code doing the same purpose.

 1 votes -- Arjun Suresh ( 124125 points)

21.200 Parameter passing technique top gateoverflow.in/270

Various parameter passing mechanisms have been in used in different programming languages. Which of the following
statements is true?
(a) Call by value result is used in language Ada
(b) Call by value result is the same as call by name.
(c) Call by value is the most robust.
(d) Call by reference is the same as call by name.
(e) Call by name is the most effi​cient.


Selected Answer

(a) is true. Ada supports in-out parameter passing, which is nothing other than call by value result (but Ada in GATE
syllabus?)
(b) Not true.
(c) Most robust? I don't know what is meant by robust here.
(d) Not true.
(e) Not true. Because in call by name, the parameter is re-evaluated at every occurrence of the formal paramater and
hence efficiency will only be less.

Reference:
http://courses.cs.washington.edu/courses/cse341/03wi/imperative/parameters.html

 1 votes -- gatecse ( 9515 points)

21.201 Unrestricted use of goto statement is harmful top gateoverflow.in/283

An unrestricted use of the “goto” statement is harmful because


(a) it makes it more difficult to verify programs
(b) it increases the running time of the programs
(c) it increases the memory required for the programs
(d) it results in the compiler generating longer machine code

programming easy


Selected Answer

(a) it makes it more difficult to verify programs


goto in no way can increase the running time or memory requirement of the program. It also doesn't contribute to longer machine code. But the use of goto can

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2105 of 2244

result in unstructured code and there can be blocks with multiple entry and exit points which can cause a nightmare for program verification.

 4 votes -- gatecse ( 9515 points)

21.202 How to represent int a=7 in little endian architecture computer. gateoverflow.in/297

top

I saw on http://www.cquestions.com/2009/06/memory-representation-of-int-data-type.html but it seems wrong to me.


Please clarify.

That is correct except for one extra 1 which seems to be a typo.

00000111000000000000000000000000

This will be the representation of int a = 7, assuming sizeof int is 4 bytes and a little endian machine (start address of
memory is from the left).

Why is there a confusion?

 1 votes -- gatecse ( 9515 points)

21.203 consider the program: top gateoverflow.in/5044

programming

str = "Gate2015";

In memory

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2106 of 2244

1000: G
1001: a
....
1007: 5
1008: \0

Now, str has the value 1000.


In the function, while loop terminates when P1 points to '\0' (which has integer value 0). So, P1 = 1008. And P1-P2
returns (1008-1000)/1 = 8 as size of char is 1 in C.

 3 votes -- Arjun Suresh ( 124125 points)

21.204 use of unions in c top gateoverflow.in/5087

what are the reasons to use unions or not to use unions in C?why unions in ada are better than C implementation ?


Selected Answer

Use unions to save memory. Currently when we have so much of memory space in systems, there is no point in using a
union. But it is still useful in embedded systems.

Ada has better implementation for union? That can't be true. Because C doesn't specify how a union must be
implemented. And being so simple and close to hardware language is C, no language other than Assembly, written by
some really really great programmer can outperform a C code compiled by a decent C compiler. So, "better than C" can
mean ease to use, not "better in performance".

 2 votes -- Arjun Suresh ( 124125 points)

21.205 ++k + k++ + + k top gateoverflow.in/9153

class Codechef {

public static void main (String[] args)


{ int k=1;
System.out.println(++k + k++ + + k);
}
}
I think the steps are like this ( increment postfix has precedence over
prefix):

1. k++ returns 1 to use, then increments k, so k now is 2.
++k + 1 + + k; // k is 2
2.unary operator && prefix have same precedence ,so associativity is from

right to left...so
++k + 1 + 2;

3 ++k increments k and uses that value (++2) returning 3 3 + 1 + 2; //k
is 3
4.now, go left to right: so, 3 + 1 + 2 = 6
BUT, according to the book, the expression is "parsed as ( (++k) +

(k++) ) + (+k) which yields 2 + 2 + 3 = 7

int k=1;

System.out.println(++k + k++ + + k);

Applying operator precedence in Java

(((++k) + (k++)) + (+k)); //++k has the highest priority and hence () put over that, then (k++) and (+k). Arithmetic + has the
least priority here and it's associativity is from left to right.

Precedence just groups the operands to operator and it is not telling the evaluation order of operations. Evaluation order
depends on language semantics and varies from language to language. In Java, evaluation order is strictly from left to right

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2107 of 2244

where as in C, it depends on the operator and defined sequence points. (The same statement in C produces undefined
behaviour).

++k, returns 2
k++ returns 2
+k returns 3

So, 2 + 2 + 3 = 7.

 2 votes -- Arjun Suresh ( 124125 points)

When associativity computed, the value is not evaluated (in compiler phases). In compiler phase the associativity is
computed based on the grammar parsed in syntax analysis.

Step1: Operating precedence table helps to compute the precedence relation and based on those relations associativity
assigned as follows before converting into three address translation.

assume statement in printf consider as : x = ++k+k++++k;

x= (++k) + (k++) + (+k); // this is only possible way to give associativity based on precedence rules and syntax rules.

Note: Do not try to evaluate the expression because still this code is in high level.

Step2: Now convert this code into three address code as follows:

Find number of pre-increments and post increments: one preicrement and one post increment.

k= k+1;

t1=k+k;

t2=t1+k; // this instuction and above instuction is similar to t2 = k + k + k where k is already incremented once.

k=k+1 // Post increment once after the given instruction is executed

Step 3: Above instructions are result of 3-Address code. Now evaluate run time using assembly instructions, you will get
answer 7 when k=1 initially.

 1 votes -- mallesham ( 63 points)

21.206 Find output of following c program top gateoverflow.in/9420

What is the output of the following C code segment?

# define product (a, b) a * b


main()
{
int x=5, y=2;
print f("%d", product{x+4, y-3});
}

a. 10
b. −9
c. 15
d. Error.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2108 of 2244

because MACRO product expands like this -

product(x+4,y-3) expands to x + 4 * y - 3 => 5 + 4 * 2 - 3 => 5 + 8 - 3 =>10 (ANS)

 3 votes -- lokesh kumar ( 69 points)

follow the operator precedence rules . you will get ans 10. Product(x+4,y-3) expands to x + 4 * y - 3 => 5 + (4 * 2) - 3
=> (5 + 8) - 3 =10.
Instead of macro if you had used normal function like this
int product(int a, int b)
{
return a*b;
}
then the answer will be -9

 2 votes -- GATE_2016 ( 373 points)

21.207 RMo and CMO top gateoverflow.in/9734

Does any one know the formula for Row major order and column major order of symmetric square band matrix

Wait i need to reconsider my solution . I will solve and give :)

 0 votes -- spriti1991 ( 1127 points)

21.208 c programming top gateoverflow.in/10088

What will be output of following program?

#include<stdio.h>

int main(){

int a = 320;

char *ptr;

ptr =( char *)&a;

printf("%d ",*ptr);

return 0;

(A) 2

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2109 of 2244

(B) 320

(C) 64

(D) Compilation error

(E) None of above

320 will be stored in memory as

1000 -->01000000

1001 -->00000001

Since typecasting is done and ptr is a char pointer hence it will display only 1 Byte data i.e. data at loc 1000

so here the answer would be 64.

 2 votes -- aayushranjan01 ( 325 points)

21.209 if a lower triangular matrix is to be sorted in 1D array , A then aij


could be mapped to which of the following index of A top gateoverflow.in/8964

a) 0.5 * i(i+1)j

b)i+j

c) i(i+1)j

http://gateoverflow.in/2452/gate1994_1-11

 1 votes -- Arjun Suresh ( 124125 points)

21.210 If memory for the run-time stack is only 150 cells (words) how big
can N be in Factorial(N) before encountering Stack overflow? top gateoverflow.in/8962

options are:

a)24

b)15

c)66

d)50

Not enough data to answer :) Still a try:

In the best case, we need to pass a parameter to a function and we need to save the return address. Assuming sizeof (int)
takes word size, this would mean, 2 words. And in factorial (N) there will be N-1 recursive calls so for say N = 76, surely
there will be stack overflow.

But to realize how stupid my explanation is and also the question, please see here:

http://www.tenouk.com/Bufferoverflowc/Bufferoverflow2a.html

 1 votes -- Arjun Suresh ( 124125 points)

21.211 What will be the output for f(p,p), if p is initialized to 4. top gateoverflow.in/5198

int f(int &x, int c)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2110 of 2244

{
c=c-1;
if(c==0) return 1;
x=x+1;
return f(x,c) * x;
}
What will be the output for f(p,p), if p is initialized to 4.

http://gateoverflow.in/60/gate2013_42

 0 votes -- Arjun Suresh ( 124125 points)

21.212 number of v's that are pushed more than once in a dfs? top gateoverflow.in/5296

I start from vertex 6 , so vertex 6 is pushed onto stack. After that by DFS , we can have two options either vertex 3 or
vertex 8 . Let's say we choose vertex 3 , so vertex 3 is pushed onto the stack. then vertex 1 is pushed ( I choose vertex 1
over vertex 7 ). Then vertex 2 is pushed.Now , I can choose either vertex 4 or vertex 5. Say I choose vertex 5. Now ,
vertex 8 is chosen.

Now , from vertex 8 , I can choose either vertex 4 or vertex 7 .If I choose vertex 4 , then already vertex 2 is selected. So ,
I need to backtrack.

So , at max 1 vertex will be pushed in the stack more than once.

 0 votes -- Shounak Kundu ( 3757 points)

21.213 C Programming top gateoverflow.in/7331

let's see this one by one...

A> is not the answer cause let's say y = 14.

then for first expression it is (3*(14-8))/9 = 18/9 = 2 (integer division)

then for second expression it is ((14-8)/9)*3 = (6/9)*3 = 0*3 (integer division 6/9 is zero.) = 0

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2111 of 2244

B> is not the answer cause let's say y = 15.

then for first expression it is (3*(15-8))/9 = 21/9 = 2 (integer division)

then for second expression it is ((15-8)/9)*3 = (7/9)*2 = 0*3 (integer division 7/9 is zero.) = 0

C> is the answer cause let's say (y-8) = 9K (K belongs to integer).

then for first expression it is (3*9K)/9 = 27K/9 = 3K(integer division)

then for second expression it is ((9K)/9)*3 = K*3 = 3K

D> is not the answer cause let's say (y-8) = 3K (K belongs to integer).

then for first expression it is (3*3K)/9 = 9K/9 = K(integer division)

then for second expression it is ((3K)/9)*3 = (K/3)*3 not equal to K for say (k=5 in integer division)

 0 votes -- Tamojit Chatterjee ( 1925 points)

21.214 c programming top gateoverflow.in/7634

Let S be a stack k of size n > 1. Starting with the empty stack, suppose we push the
first n natural numbers in sequence, and then perform n pop operations. Assume
that Push and Pop operation take X seconds each , and Y seconds elapse between
the end of the one such stack operation and the start of the next operation. For
m > 1, define the stack-life of mcs the time elapsed from the end or Push (m) to
the start of the pop operation that removes m from S . The average stack-life of
an element of this stack is
(A) n(X+Y) (B) 3Y+2X
(C) n(X+Y)-X (D) Y+ 2X

here numbers are entered in natural order from 1,2,---------n these are coming in AP so simply do this.... first first
element 1... n-1 nelements has to push and n-1 elements has to pop so total time=2(n-1)X and b/w each y sec elapse so
total elapse=[2(n-1)+1]Y.

now for last element just y unit elapse...so total time=2(n-1)x+2(n-1)y+y+[y]/2=n(x+y)-x

 0 votes -- Sharma_vijay ( 29 points)

21.215 Which of the the above functions are likely to cause problem with
pointers? top gateoverflow.in/13940

int *f1(void){

int x=10;

return (&x);

int *f2(void){

int *ptr;

*ptr=10;

return ptr;

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2112 of 2244

int *f3(void)

int *ptr;

ptr=(int*)malloc(sizeof(int));

return ptr;

Which of the above 3 functions is/are likely to cause problem with pointers?

a) Only f3 b)Only f1 and f3 c)Only f1 and f2 d)f1,f2,f3

Only f1 and f2.

f1 can cause problem because it is returning address of local variable x. After the function call, memory location of x get
free and accessing that memory location can crash the program.

In f2, ptr is a wild pointer and dereferencing a wild pointer can crash the program.

f3 is fine.

 0 votes -- Happy Mittal ( 9253 points)

21.216 what is the utility of variables declared using extern keyowrd ? gateoverflow.in/13962

top

Case A :
​#include <stdio.h>
extern int i; //extern variable
int main(){
printf("%d",i);
return 0;
}

This gives compilation error since variable i is just declared .

Case B :
#include <stdio.h>
int i; //By default it is extern variable
int main(){
printf("%d",i);
return 0;
}

Here in this case I get output as 0

Now my ques is that what is the utility of just declaring a variable when in any of the functions we can neither modify it or
access it .

Also one more confusion is that when we declare any variable with storage class extern then it is initialized to 0 but here in
Case A , we have simply declared the variable using extern no memory allocation has been done so then how come that it
gets initialized to 0 , its only the case when I dnt use extern implicitly that the variable gets the value 0 so then whats the
utility , except for the case when I have actually initalized it like extern int y=90 ;

extern int a; // a is having memory in some other file (global variable in some other file) and that might be known only at
link time.

int a; // when we declare like this in global scope, a is given a memory and by default all global and static int variables are
initialized to 0. This global variable is also visible to other compilation units (they must use extern to access it).

So, extern is a way for a compilation unit to access a global variable in another unit. Both are related.

So, now what is the use of static? - If we want to declare something in the global scope and not want other compilation
units to use it using extern, then we use static.

extern- something outside

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2113 of 2244

global- anyone can access

static- has full life scope as global, but visible only in the current compilation unit (usually a file).

Use
gcc -c file.c -o file.o

to compile a C file without linking. This way different parts of a program can be compiled separately. Finally

gcc file.o file2.o -o file.exe

produces the executable.

 0 votes -- Arjun Suresh ( 124125 points)

21.217 C program top gateoverflow.in/28096

Output of following program?


#include <stdio.h>
int fun(int n, int *f_p)
{
int t, f;
if (n ≤ 1)
{
*f_p = 1;
return 1;
}
t = fun(n- 1,f_p);
f = t + * f_p;
*f_p = t;
return f;
}
int main()
{
int x = 15;
3
printf (" %d \n", fun(5, &x));
return 0;
}
(a) 6 (b) 8
(c) 14 (d) 15

getting ans 61

http://gateoverflow.in/1310/gate2009_18

 0 votes -- Digvijay Pandey ( 26245 points)

21.218 c program top gateoverflow.in/28106

Explain how to evaluate it

how to evaluate recursion within loop


Consider the following C function:
int fun (int n)
{
int x=1, k;
if (n= =1) return x;
for (k=1; k < n; ++k)
x = x + fun(k) * fun(n – k);
}
The return value of fun(5) is __________.
(a) 0 (b) 26
(c) 51 (d) 71

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2114 of 2244

21.219 pointer array top gateoverflow.in/28444

What it means ?

int (*p)[R][C];

Declare p as pointer to array of R elements of the array C elements of integer type.

 1 votes -- Anirudh Pratap Singh ( 4091 points)

21.220 C program top gateoverflow.in/28479

Explain the array representation used here

#include <stdio.h>
int main()
{
int a[][3] = {1, 2, 3, 4, 5, 6};
int (*ptr)[3] = a;
printf("%d %d ", (*ptr)[1], (*ptr)[2]);
++ptr;
printf("%d %d\n", (*ptr)[1], (*ptr)[2]);
return 0;
}

op=2 3 5 6

ptr pointing to address of array a i.e. 1000

(*ptr)[0]=1

(*ptr)[1]=2

(*ptr)[2] =3

ptr is pointer to an array of 3 integers i.e. 6 bytes(1000-1005)

++ptr is next location of ptr i.e.1006

now ptr pointing to 1006

so,

(*ptr)[0]=4

(*ptr)[1]=5

(*ptr)[2] =6

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2115 of 2244

 1 votes -- srestha ( 11585 points)

21.221 C programming top gateoverflow.in/28091

Consider the C function given below. Assume that the array listA contains n (> 0) elements, sorted in ascending
order.
int ProcessArray(int *listA, int x, int n)
{
int i, j, k;
i = 0;
j = n-1;
do
{
k = (i+j)/2;
if (x ≤ listA[k])
j = k-1;
if (listA[k] ≤ x)
i = k+1;
}
while (i ≤ j);
if (listA[k] = = x)
return(k);
else
return -1;
}

Which one of the following statements about the function ProcessArray is CORRECT?
(a) It will run into an infinite loop when x is not in listA.
(b) It is an implementation of binary search.
(c) It will always find the maximum element in listA.
(d) It will return −1 even when x is present in listA

http://gateoverflow.in/2076/gate2014-3_42

 0 votes -- Digvijay Pandey ( 26245 points)

21.222 C programming top gateoverflow.in/28090

what does the following c expression do?

x = x & (x-1)

This will reset the rightmost bit.

 0 votes -- Monanshi Jain ( 5827 points)

21.223 which is correct... top gateoverflow.in/26147

what is the significance of the value in the integer pointed to by j when the function completes..

<a>.it points to the last element in the list

<b>.it points to the first element in the list

<c>.it points to the first and last element in the list

<d>.all of the above

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2116 of 2244

21.224 o/p==? top gateoverflow.in/26415

http://gateoverflow.in/?qa=blob&qa_blobid=15647475923541120156

21.225 DFA design with java top gateoverflow.in/26993

How can i solve a DFA which is divisible by 3 with the states ( like - state q0 ,return q1 ) in java programming language.

take any string or number if it is multple of 3 then use control structure .

if it is multiple of 3 return Q0

ELSE Q1; this is logic and more if you have knowledge string handling in java it is simpler.

 0 votes -- Manojk ( 3365 points)

21.226 ans please top gateoverflow.in/27302

We are given a set of n distinct elements and an unlabeled binary tree with n nodes. In how many ways can we populate the tree with
the given set so that it becomes a binary search tree?
A) 0
B) 1
C) n!
D) (1/(n+1)).2nCn

21.227 c program top gateoverflow.in/28481

what function fun() does here

#include <string.h>
#include <stdio.h>
#include <stdlib.h>
void fun(char** str_ref)
{
str_ref++;
}
int main()
{
char *str = (void *)malloc(100*sizeof(char));
strcpy(str, "gate2016");
fun(&str);
puts(str);
free(str);
return 0;
}

op gate2016

21.228 C program top gateoverflow.in/28637

as i is initialized with 5 in main then how it becomes 0

please explain ?

int main()
{
static int i=5;
if(--i)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2117 of 2244

{
main();
printf("%d ",i);
}

op = 0000


Selected Answer

int main()
{
static int i=5; // only one time memory declare use same remaining time.
if(--i) //start decreasing value of i by 1 at a time

{
main(); this happen before printing function means when i becomes 0 then all printf will start printing
printf("%d ",i);
}

 1 votes -- Anirudh Pratap Singh ( 4091 points)

As all printf prints after i becomes 0, so output will be 0000

 1 votes -- srestha ( 11585 points)

21.229 ptr top gateoverflow.in/31031

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2118 of 2244

I think output will be c) 2 5

Reason is :

int *ptr = (int *) (&a+1);

If I assume size of integer is 4 Byte , then this above line will increment the pointer to

(base address + ( number of elements in array * size of integer ))+1 .

So , we need to decrement by 1 to get the last element.

so , if we do *(ptr-1) it will print 5.

Note , please do not confuse , (&a)+1 and (&a+1) .

(&a)+1 will be simple - it will point to next entry in array from the base address.

You can refer to this snippet if you want to play around various test cases regarding this problem

http://code.geeksforgeeks.org/4rzf87

 2 votes -- Shounak Kundu ( 3757 points)

21.230 Pointer top gateoverflow.in/31034

C.Garbage Value
Printf returns the number of characters written on console successfully.
Here, without variable printf will pull any random data from the stack. Thus if condition will become true and loop will halt!

http://ideone.com/06HF02
http://stackoverflow.com/questions/437816/behaviour-of-printf-when-printing-a-d-without-supplying-variable-name

 0 votes -- Shashank Chavan ( 2439 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2119 of 2244

21.231 Please explain top gateoverflow.in/31201

Consider the following program fragment: char c= ‘a’ while (c++ ≤ ‘z’) putchar (xxx);

if the required output is abcdefghijklmnopqrstuvwxyz then xxx should be

: (a) c (b) c++ (c) c–1 (d) –c

It will be (c) c-1

first c pointing to 'a'

Now c++ update the pointer and pointing to the next location, i.e. location of 'b'

So, if we print here with c it will print bcd.........................

to print the previous value , we decrement pointer by '1' , so ans c-1

 1 votes -- srestha ( 11585 points)

21.232 Probability top gateoverflow.in/31425

In a hash table of size 6 currently the locations 0,2,4 and 5 are occupied. The probability of a new record going into location
1 with a hash function resolving collisions by linear probing is (assume uniform hashing)
a)2/3
b)1/3
c)1
d) 1/6


Selected Answer

OPTION A

With uniform probability 1/6 ,it may go to any of the slot numbered 1 , 0 , 4, 5 {In any of these case it will end up in slot
1 , with linear probing.}
1 1 1 1 4 2

So, total probability = 6 + 6 + 6 + 6 = 6 = 3

 3 votes -- Himanshu Agarwal ( 8861 points)

Maximum path it can visit is 4,5,0,1

So, prob of new record goes to location 1 is 4/6 =2/3

 2 votes -- srestha ( 11585 points)

21.233 Heap to be taken as ADT or as usual binary tree ? top gateoverflow.in/30979

I got HEAP DS as a ADT(abstract data type). Means i can perform few operations on it like getMin(),getMax(),deleteRoot()
etc.

So if i have to get 2nd smallest in min heap then it will be in 2nd level definitely. so should i approach it as make a level
order traversal and get it in O(1) time. or i should take it as standard way like delete root, hepify ,getRoot() ,insert() deleted
item=O(2Logn) ?

I found a prev. gate question as find 7th min in min heap, and all answers are O(1).

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2120 of 2244

in a heap only getmin() or getmax(), insertion can be performed. if u are doing any other operation , then the ds cannot
be treated as heap. so you should use only getmin() 7 times to get 7th minimum element

 0 votes -- sachin pandey ( 33 points)

21.234 Find the error in program top gateoverflow.in/30792

the given ans is (d) but it will run forever as ch is character type and can have max value 255 and then it will be reset. also
char would be implicitly typecasted to int so comparison is valid. why would it give compilation error


Selected Answer

Semicolon after 'char ch = 1' Is missing.

 4 votes -- Monanshi Jain ( 5827 points)

21.235 C program top gateoverflow.in/28644

how it is compiler error

int main()
{
extern int i;
printf("%d ", i);
{
int i = 10;
printf("%d ", i);
}
}
(a) 0 10 (b) Compiler Error
(c) 0 0 (d) 10 10

ans b

http://www.geeksforgeeks.org/understanding-extern-keyword-in-c/

first understand the extern keyword

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2121 of 2244

int main()
{
extern int i;// here compiler has expecting that 'i' is already defined in some file but is has not defined thats why we are
getting compiler Error
printf("%d ", i);
{
int i = 10;
printf("%d ", i);
}
}

answer is option B

 1 votes -- Sandip Shaw ( 755 points)

int main()
{
extern int i;
printf("%d ", i);
{ // what is this thats y compiler error.
int i = 10;
printf("%d ", i);
}
}

 1 votes -- Anirudh Pratap Singh ( 4091 points)

21.236 Meaning of declaration. top gateoverflow.in/29698

x is array of 20 pointer to function passing a pointer 'a' to integer returning pointer to float.
For more info you can go this url
http://unixwiz.net/techtips/reading-cdecl.html

 3 votes -- Avdhesh Singh Rana ( 1509 points)

21.237 Static Scoping | Dynamic Scoping: GATE 1989 top gateoverflow.in/30266

Indicate results of the following program if the language uses


i)Static scope rule and
ii) Dynamic scope rules (GATE-1989)
var x,y:integer;
procedure A(var z:integer);
var x:integer;
begin
x:=1;
B;
z:=x;
end;
procedure B;

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2122 of 2244

begin
x:=x+1;
end;
begin
x:=5;
A(y);
write(y)
end;

In static scoping value will be 6,And in Dynamic scoping value will be 2

 1 votes -- srestha ( 11585 points)

21.238 programming top gateoverflow.in/30572

int x=0,i;

for(i=0;i<10;i++)

if(i%2&&x++)

x=+2;

what is the value of x.

x should be equal to 13.


when i=0; x++ and if would not get executed.
when i=1; x++ gets executed, but value of x would increment after that statement so the if would not get evaluated.
So,

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2123 of 2244

i=0 x=0
i=1 x=1
i=3 x=4
i=5 x=7
i=7 x=10
i=9 x=13
when i is even i%2 is false.
x=13 is the answer.

 3 votes -- Monanshi Jain ( 5827 points)

21.239 What is the output of following code: top gateoverflow.in/25468

The following code fragment:

int x, y= 2, z, a;

x= (y* =2) + (z= a =y);

printf(“%d”, x);

(a) prints 8

(b) prints 6

(c) prints 6 or 8 depending on the compiler implementation

(d) is syntactically wrong

Compiler Scans from left to right and generate token.


so first (y* =2); = y = y*2 this will be computed and y value will change to 4
then (z= a =y); so z= 4
finally x = 4+4 = 8

 1 votes -- Umang Raman ( 10379 points)

21.240 adding vertex to spanning tree top gateoverflow.in/19754

Suppose graph G has minimum spanning tree computed.How quickly can we update minimum spanning tree if we add new
vertex and incident edges to G?

Adding vertex and incident edges to minimum.spanning tree we get a graph.Check for cycles in graph and remove max
edge from each cycle..this will give new spanning tree

 0 votes -- Pooja ( 22773 points)

21.241 How to evaluate the remainder when we have a negative divisor? top
gateoverflow.in/15986

main( ){ int i=-4, j, num=10; j = i % -3; j = j?0: num*num; printf(“j = %d”, j); }

I tried with the formula Dividend = (Quotient × Divisor) + Remainder, but got confused.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2124 of 2244

the right answer is according to c99 specification the whenever we do % operation this thing holds. that is
(a/b)*b+a%b should be equal to a . so here

-4/-3=1

1*(-3)+ a%b=-4

a%b=-4+3=-1 which is the answer .

 0 votes -- Ravi Singh ( 7303 points)

21.242 Fill up the blank in the following code for retrieving the element top
gateoverflow.in/16211

A matrix X of order (N × N) is stored in an array indexed from 0 to 2N − 2, by first storing the diagonal, followed by anti
diagonal.

Fill up the blank in the following code for retrieving the element.

if(i==j) return A[i-1]; else if(i+j == N+1) return __________

a) A[N + i]

b) A[i − 1]

c) A[N + i − 1]

d) A[N − i + 1]

Question is nothing but store all diagonal(principal as well as anti diagonal) element in an array. So total n diagonal + n-1
anti diagonal element. we have to store total 2n-1element. Array size should be 2n-1 but starting from 0 It will go upto
2n-1. Final array is something like A[0.1.2........2n-2].

now question,

If (i==j) return (A[i-1]) ...... //Principal diagonal

Else if (i+j == n+1) return A[n+i-1] //Anti-digonal

 0 votes -- Digvijay Pandey ( 26245 points)

21.243 Doubt Regarding String Constant top gateoverflow.in/16618

int main(void) { char *p = "arjun"; *(p+3) = 'a'; char arr[] = "arjun"; arr[3] = 'a'; printf("%c",arr[3]); printf("%c",*(

I am trying to modify a string. It works fine when string is declared via array but it is giving runtime error when string is
declared via pointer. Reason ??

In the question it is mentioned "string constant" and that is the reason. A constant cannot be modified.
char *p = "arjun";

Here, "arjun" is a string constant which is usually stored in Read Only Data section and p contains the address of its start.
So, trying to modify the content of "arjun" causes segmentation fault- writing to a segment which is RO- (an example of a
segmentation fault which can occur even with a TLB hit). Other string constants like "%c" used in the above code are also
stored in RO data section.

Now,
char arr[] = "arjun";

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2125 of 2244

Here also "arjun" is a string constant, but arr[] is an array and the initialization causes 6 bytes to be allocated for arr, each
containing the characters 'a', 'r', 'j', 'u', 'n' and '\0' ('\0' is added at end of all string literals by the compiler). So, here we
are free to modify the contents of arr.

 0 votes -- Arjun Suresh ( 124125 points)

21.244 The minimum number of temporary variables needed to swap the


contents of two variables? top gateoverflow.in/16796

The minimum number of temporary variables needed to swap the contents of two variables is:

(a) 1 (b) 2

(c) 3 (d) 0

programming


Selected Answer

var a ,b;

a=a+b;

b=a-b;

a=a-b;

or

a=a*b;

b=a/b;

a=a/b;
no temporary variables is needed

 0 votes -- Saurav Kumar Gupta ( 1455 points)

21.245 How to calculate the sum of money in the below question ? top gateoverflow.in/15415

The sum of money in kept in a bank amounts to 1240 in 4 yrs and Rs 1600 in 10 yrs at Simple interst . then how to find sum
?

I formed an AP

1240= a+(4-1)d

1600= a+(10-1) d

but I am nt getting the answ where is my mistake ?

21.246 the variable should be declared as top gateoverflow.in/15033

If only one memory location is to be reserved for a class variable, no matter how many objects are instantiated, then the
variable should be declared as (a) extern (b) static ( c) volatile (d) const

the answer is b . Static memebers of a class share same memory by all the object. if u want to check just make a class
and define a variable static in it . else if u don't want to type here u go . check this post . http://www.learncpp.com/cpp-
tutorial/811-static-member-variables/

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2126 of 2244

 1 votes -- Ravi Singh ( 7303 points)

21.247 How does the function return in the below code ? top gateoverflow.in/14065

#include <stdio.h>
void e(int);
int main()
{
int a = 3;
e(a);
putchar('\n');
return 0; }
void e(int n)
{
if (n > 0)
{
e(--n);
printf("%d ", n);
e(--n);
}
}

I am not getting here that when e(0) is called how is the code executed ?

when e(0) is called, if condition becomes false, and control doesn't go into if block, and simply returned from e() function.

 1 votes -- Happy Mittal ( 9253 points)

21.248 How is the comma operator evaluated in the below code ? top gateoverflow.in/14066

#include<stdio.h>
int main()
{
int a = 2;
if(a == (1,2))
printf("Hello");
if(a == 1,2)
printf("World");
return 0;
}

I am having just one confusion in this that why is it that World is getting printed here when a=2 and when the second
comma operator executes since the precedence of == is greater and its associativity is from left to right so then a==1
,condition false hence World should not be printed then why is it getting printed here ?

You are right, In second "if", a==1 evaluates to false, which is 0. So if(a==1,2) becomes if(0,2).

Now 0,2 evaluates to 2, so condition in "if" becomes true, and "world" is printed.

Also note that here associativity plays role only when operators are of equal precedence, here == has higher precedence
than comma operator, so (a==1,2) is binded as ((a==1),2).

 2 votes -- Happy Mittal ( 9253 points)

21.249 How many stacks are required for converting an infix expression to
postfix expression involving inbuilt functions ? top gateoverflow.in/14156

If any infix expression has embedded function calls in it then how many stacks will it require for computing postfix expression , does it depend on the number of
function calls in it +1 for computing other operands ?

Why do you need extra stack for function calls. For example, if infix expression is f() + g(), then we can simply write it as
f()g()+ in postfix notation using just one stack, as normally done.

 0 votes -- Happy Mittal ( 9253 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2127 of 2244

21.250 Is the size of a struct variable always equal to the size of its data
members ? top gateoverflow.in/14259

1. VALID

2.Can't say

According to me it's always true , is it so ?


Selected Answer

No, it is not true. We can't say. See here : http://www.c-faq.com/struct/padding.html

It explains very well about padding bits.

 1 votes -- Happy Mittal ( 9253 points)

21.251 which is not represented in a subroutine's activation record frame for


a stack-based programming language? top gateoverflow.in/17221

which of the following is not represented in a subroutine's activation record frame for a stack-based programming language?

a)Values of local variables

b)Return address

c)Heap area

d)Information needed to access non local variables

Answer is Heap Area since even if u dynamically allocate a memory region inside a function still that memory area won't
be created inside the stack frame of that segment , it would be created in the heap region so even if u exit from the
function without freeing the dynamically created node , it would be still persisting in the heap memory region .

 0 votes -- radha gogia ( 4369 points)

21.252 which of the following class of statement usually produces no


executable code when compiled? top gateoverflow.in/17249

which of the following class of statement usually produces no executable code when compiled?

a)declaration

b)assignment statements

c)input and output statements

d)structural statements

After compilation of the program, we could not identify the structure of the program. Since, after intermediate code
generation we lost the structure of the program (you could not identify where the loop is? or other similar stuffs). So,
correct option must be D.

 0 votes -- Monanshi Jain ( 5827 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2128 of 2244

21.253 float top gateoverflow.in/19001

following statment

printf("%f",9/5);

prints

answer is 2.0 can any one explain plzzzzz


Selected Answer

The reason is pretty simple. Any integer constant is considered as "int" in C and when we operate on "int" we get only "int"
(even when we divide). So, 9/5 returns "int". This return value 1 (See behaviour of integer division ). But there is another
significant issue with the code - "%f" is used and an integer is passed to the function- which causes "undefined behaviour"
in C (integer value won't be promoted to float). So, output can be anything.

pl.c:4:2: warning: format ‘%f’ expects argument of type ‘double’, but argument 2 has type ‘int’ [-Wformat=]
arjun@parambara:~/dump$ ./a.out 0.000000

 0 votes -- Arjun Suresh ( 124125 points)

21.254 ISRO_A 2015/69 top gateoverflow.in/19372

if n has the value 3,then the statement a[++n]=n++;

a)assigns 3 to a[5]

b)assigns 4 to a[5]

c)assigns 4 to a[4]

d)what is assigned is compiler dependent


Selected Answer

It is an undefined behaviour since between two sequence points which is here ; at the end of this statement and the other
; which would be present above this statement in the actual code we cannot modify the value of a variable more than once
therefore here u r trying to modify the value of n two times so it depends on compiler wither it will evaluate ++n inside
array subscript or assign ++n to array index .

 1 votes -- radha gogia ( 4369 points)

21.255 ISRO_A 2015/75 top gateoverflow.in/19441

What does the following for loop print?

for(i=0; i<10; ++i) printf("%d", i&1);</pre> a) 0101010101


b) 0111111111
c) 0000000000

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2129 of 2244

d) 1111111111

Answer is A.the loop runs from 0 to 9 and i&1 MEANS BITWISE AND WITH THE BINARY FORMS OF 0 TO 9 WITH 1.SO THE
NUMBERS HAVING LAST BIT AS 0 GIVES OUTPUT 0 AND NUMBERS HAVING LAST BIT AS 1 GIVES OUTPUT 1.

 1 votes -- Rohan Ghosh ( 1515 points)

21.256 infix to prefix top gateoverflow.in/19580

Convert following infix to prefix expression

e^d-a*b^f/g+h*c/i+j-k

Explain each step


Selected Answer

Precedence rule : ^ > ( / = * ) > (+ = -)

Step 1 : ^ed - a* ^bf /g + h*c / i + j - k

Step 2 : ^ed -/ *a^bfg + h*c /i +j -k (Since * , / has same precedence we go by the associativity that is left to right .)

Step 3 : ^ed - / *a ^ bfg + /* hci + j-k

Step 4 : -^ed / *a ^bfg + / *hci + j-k

Step 5: + - ^ed /*a^bfg/*hci + j-k

Step 6 : ++-^ed/*a^bfg/*hcij-k

Step 7 : -++-^ed/*a^bfg/*hcijk

 0 votes -- Riya Roy ( 4767 points)

21.257 Why is the output of these two programs different in C? top gateoverflow.in/18349

#include
int main(){
float x = 0.1;
if (x == 0.1)
printf("IF");
else if (x == 0.1f)
printf("ELSE IF");
else
printf("ELSE");
return 0;
}

#include
int main{
float x = 0.5;
if (x == 0.5)
printf("IF");
else if (x == 0.5f)
printf("ELSE IF")
else
printf("ELSE");
return 0;
}

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2130 of 2244

First program Output: ELSE IF


Second program Output: IF

Both programs are similar.But outputs are different.Why?

I tried the following code segment to get the exact representation of 0.1 & 0.5 being used by my machine:

#include<stdio.h>
int main(void)
{
float a = 0.1;
float b = 0.5;
printf("%x\n",*(int*)&a); /*Prints the value of 0.1 as stored by computer in hexadecimal format.*/
printf("%x\n",*(int*)&b); /*Prints the value of 0.5 as stored by computer in hexadecimal format.*/
return 0;
}

& got the following out put

-----------------------------------------

3dcccccf

3f000000

--------------------------------

It means that it stores 0.1 as 3dcccccf and 0.5 as 3f000000.

On converting this values back to the float using IEEE Floating Point Representation 754 I got 0.09999999404 & 0.5.

It means that 0.1 can not be EXACTLY represented using 32 bit floating point, but 0.5 can be represented.

So output for 0.1 should be ELSE IF &

output for 0.5 should be IF.

 0 votes -- Anurag Pandey ( 8183 points)

21.258 find first repeated element.. top gateoverflow.in/18144

given an array of n element, what will be the time complexity to find 1st repeated element when array have
more than one repeated elements??

From a theoretical point of view, it will take O(nlogn) time in the worst case. It can be done by sorting the array and
then sequentially searching for any adjacent elements that are equal.

Note: The problem doesn't mention any bound on the elements of the array. The elements can be as large as wanted,
and need not be integers! Assuming that the elements are bounded (as in Saurav's answer) or that the elements hash to
unique locations (as in Sonu's answer) completely changes the problem.

Practically, you will always have a bound on the elements. If the bound is sufficiently small ( < 32 bits, for example),
Saurav's answer will be efficient (if the n ≫ 232). Or you could have a hash function that provides unique hashes for all
practical purposes. Then Sonu's answer would be the better way to go.

 0 votes -- Pragy Agarwal ( 13675 points)

21.259 which of the following is true with respect to Reference? top gateoverflow.in/17420

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2131 of 2244

which of the following is true with respect to Reference?

a)A reference can never be NULL

b)A reference needs an explicit dereferencing mechanism

c)A reference can be reassigned after it is established

d)A reference and pointer are synonymous

A) References cannot be null,every reference refers to some object, although it may or may not be valid.

B) Reference doesn't need an explicit dereferencing mechanism

C) Once a reference is created, it cannot be later made to reference another object.

D) They are entirely different concept. Pointer stores the address whereas Reference is an alias of some variable.

https://en.wikipedia.org/wiki/Reference_(C%2B%2B)

 1 votes -- Aditya Gaurav ( 1831 points)

21.260 What is the approach to find preorder from given inorder? top gateoverflow.in/17582

The in-order traversal of a tree resulted in FBGADCE. Then pre-order traversal would result in.

a)FGBDECA

b)ABFGCDE

C)BFGCDEA

d)AFGBDEC

data-structure

If we are given preorder and inorder then we can generate a unique binary tree. But in question we are given only in
order.

So, what we do now - we take inorder & options one by one (as preorder) and try to make unique binary tree from them.

We will observe that options A & C will fail.

Only B & D can generate unique trees. so, options (B) & (D) are correct

Trees will look like this as given by Pranay Datta 1

 0 votes -- Himanshu Agarwal ( 8861 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2132 of 2244

21.261 How to solve below question on trees ? top gateoverflow.in/17763

I am geting confused with the term maximum of p sons , otherwise I was applying handshaking lemma but this maximum
word is where I am getting stucked , so plz clarify this .


Selected Answer

maximum of p sons means a node can have maximum p children and therefore p pointer fields are allocated in each node.
Now total number of nodes is q, so total number of fields allocated is pq. Every node in the tree must be pointed by its
parent (except root), so q − 1 fields must point to some node. So fields which are NULL = pq − (q − 1) = q(p − 1) + 1

 1 votes -- Happy Mittal ( 9253 points)

21.262 What is the no. of nodes in the tree that has exactly one child? gateoverflow.in/17825

top

In a binary tree with n nodes every node has an odd no. of descendants. Every node is considered to be its own descendant.
What is the no. of nodes in the tree that has exactly one child?

(a) 0

(b) 1

(c) (n-1)/ 2

(d) n-1

data-structure


Selected Answer

It is mentioned that each node has odd number of descendants including node itself, so all nodes must have even number
of descendants 0, 2, 4 so on. Which means each node should have either 0 or 2 children. So there will be no node with 1
child. Hence 0 is answer.

 1 votes -- Umang Raman ( 10379 points)

21.263 Stack top gateoverflow.in/31427

In a stack (index from 1 to n) the command to access ith element from the top pf the stack S will be known as Peep(S,i).
What is the condition to check for underflow on Peep.
A)S[Top-i] <= 0
B)S[Top+i] <= 0
C)S[Top-i+1] <= 0
D)NONE

I think it should be c) S[Top-i+1] <=0

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2133 of 2244

6
5
4
3
2
1
0

Let's say , I pass Peep(S,i) as i=3 , so i should check the element at the 4th index ( I assume bottom of the element at
index 0 and so on).

so , it will be (6-3+1) = 4

 0 votes -- Shounak Kundu ( 3757 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2134 of 2244

22 DS top
22.1 Arrays: ISRO-2013-9 top gateoverflow.in/43767

In an array of 2N elements that is both 2-ordered and 3-ordered, what is the maximum number of positions that an element
can be from its position if the array were 1-ordered?

A. 1
B. 2
C. N/2
D. 2N − 1

isro2013 arrays

An array A [ 1 … n] is said to be k-ordered if


A [i - k] < A [ i ] < A [i + k]
for each i such that k < i < n – k.

For example, the array 1 4 2 6 3 7 5 8 is 2- ordered.

Now come to question

array is both 2 ordered and 3 ordered.i.e.

1 2 3 4 5 6 7 8

Now if the array were 1-ordered

then array will be 1 2 3 4 5 6 7 8

maximum number of positions that an element can be from its position=1

So i think option A is correct.

 0 votes -- Manojk ( 3365 points)

22.2 Arrays: ISRO-2013-1 top gateoverflow.in/43751

Let A(1: 8, − 5: 5, − 10: 5) be a three dimensional array. How many elements are there in the array A?

A. 1200
B. 1408
C. 33
D. 1050

isro2013 arrays


Selected Answer

I am just attempting it not sure

Here i think they have specified the size

So 1:8 mean 8 elements ( both are inclusive )

(-5 : 5 ) mean 11 elements

(-10 : 5 ) mean 16 elements

So no of elements will be ( just like Multidimensional array will be ) 8*11*16=1408

so option b

 4 votes -- Dexter ( 1933 points)

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2135 of 2244

22.3 Arrays: Finding the address of element in 2D array top gateoverflow.in/26690

Please solve the above problem. Given answer: D

data-structure arrays


Selected Answer

given ans is incorrect

it will be 200+((j-5)*(20-5+1)+(i-5))*1=115+16j+i

 4 votes -- srestha ( 11585 points)

22.4 Arrays: Find address of element in 3d array top gateoverflow.in/29361

A is an array [2.....6, 2.....8, 2.......10] of elements. The starting location is 500. The location of an element A(5, 5, 5) using column
major order is __________.

data-structure arrays algorithms


Selected Answer

A[x][y][z] = A[6-2+1][8-2+1][10-2+1]. So A[5][7][9] is our 3-D array.

It contains 2-D arrays (comprises of 5 rows and 7 columns) arranged in 9 layers making it a 3-D array.

In total we have 5 rows({2,3,4,5,6}) in the similar way we have 7 columns({2,3,4,5,6,7,8}) and 9


layers({2,3,4,5,6,7,8,9,10}).

So in the layer 1 ({ 2,3,4,5,6,7,8,9,10}) we have 7 Columns * 5 Rows = 35 Elements. In the similar way each of the
remaining layers also contain 35 elements.

Here we have to use column major Order to find the address of A[5][5][5]. Base Address is 500.

Here the index of z is 5. so we can have the required element in the 4 th layer({2,3,4, 5,6,7,8,9,10}). Upto 3
layers({2,3,4,5,6,7,8,9,10}) we will have (3 layers *35 elements) 105 elements.

Now in the 4th layer we can find the number in 4th column({2,3,4,5,6,7,8}) in 4th row({2,3,4, 5,6}). As we have to
look in column major order upto 3rd column ({2,3,4,5,6,7,8}) we will have (3 columns * 5 rows) 15 elements.

Then in the 4th column upto 4 rows we have 4 elements.

Let us consider the size of each element is of 1 Byte.

So the address of the element in the location A[5][5][5] is Base Address + (Total Number of elements) * Size of each
element

LOCATION(A[5][5][5]) = 500 + (105 + 15 + 4)*1 = 624.

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2136 of 2244

 1 votes -- vamsi2376 ( 1185 points)

I considered the above as 9*(7x5) 2D arrays in that case to reach A[5], we need to cross 4*(7x5) 2D arrays ie. 140.

After that add 4*7 iterations + 4 to reach A[5][5] , this makes it- 28+4=32

So adding to the base address I got 500+172=672.

 1 votes -- UK ( 1341 points)

22.5 Asymptotic Notations: f(n)=log n! ,g(n)=n logn what is the relationship


between them? top gateoverflow.in/38827

asymptotic-notations


Selected Answer

https://www.youtube.com/watch?v=gS4Z-fBiOU4

also search for stirling approximaiton

 4 votes -- viv696 ( 1431 points)

22.6 Avl Tree: Facts about AVL tree top gateoverflow.in/43865

Which of the following is false?


A. Maximum height of an AVL tree of n nodes is 1.44 log2n

​B. Insertion of an element into an AVL tree requires at most a double rotation

C. Deletion of an element may require O(log n) rotation

D. None of these

data-structure avl-tree


Selected Answer

Answer is d

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2137 of 2244

All the statement are correct

Option a :

The height of an AVL is bound by 1.44log n

option b )

If it is LL and RR then it would have 1 rotation only

But if LR and RL then it would have 2 rotation .

So atmost 2 rotation would required if AVL tree are not balanced .

Option c

AVL is favourable over skewed tress have complexity of O(N) for deletion

But AVL are balanced tree so it would require logn for deletion

:) You can see this also

http://www.geeksforgeeks.org/avl-tree-set-1-insertion/

 0 votes -- Dexter ( 1933 points)

22.7 Avl Tree: AVL Tree insertion top gateoverflow.in/43457

The tree given is as follows:



40
/ \
35 53
/ \
20 60

How many rotations are required for insertion of elements 30,55,45,65,42 in above tree.
(A) 2
(B) 3
(C) 4
(D) None of these

data-structure avl-tree


Selected Answer

Option D None of these

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2138 of 2244

 0 votes -- shivanisrivarshini ( 2067 points)

22.8 Avl Tree: ISRO-2013-2 top gateoverflow.in/43752

The number of rotations required to insert a sequence of elements 9, 6, 5, 8, 7, 10 into an empty AVL tree is?

A. 0
B. 1
C. 2
D. 3

isro2013 avl-tree

Number of rotation = 3

Following are the roatation

1. LL

2 LL

3.RR

 1 votes -- Dexter ( 1933 points)

22.9 B Tree: questions top gateoverflow.in/5611

b-tree

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2139 of 2244

start inserting from 1 to 10 in a b-tree you will end up splitting it 5 times

1st split :while inserting 4

2nd split :while inserting 6

3rd split:while inserting 8

4th and 5th split :while inserting 10

 1 votes -- Bhagirathi Nayak ( 10239 points)

22.10 Binary Heap: Number of nodes in heap of height 'h' top gateoverflow.in/36667

The number of nodes of height h in any n-element heap is ________.

A. h
B. 2h

[]
n
h
C. ceil 2

[ ]
n
2h + 1
D. ceil

Answer is given as D, But I think it should be C. Because, even if you take height=1 then possible nodes are 3 and 2.

data-structure binary-tree binary-heap


Selected Answer

Answer shd be C.

We can prove it by taking random example.

if we take n=9 and required h=3(e.g.) then according to option d it will produce answer as (9/16=1(ceil))..and thats not
correct..

If we consider option C--

(9/8=2) which is correct.

 0 votes -- Nilam dhatrak ( 301 points)

22.11 Binary Search: [ME Test Series] When searching for the key value 50

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2140 of 2244

in a binary search tree, node containing the top gateoverflow.in/32671

When searching for the key value 50 in a binary search tree, node containing the key values 10, 30, 40, 70, 90, 120, 150,
175 are traversed, in any order. The number of different orders passing in which these keys values can occur on the search
path from the root to node containing the value 50 are ________.

data-structure binary-search made-easy test-series


Selected Answer

8!
3 !.5 !
= 56.

Ref: http://gateoverflow.in/3462/gate2007-it_29

 2 votes -- Arjun Suresh ( 124125 points)

22.12 Binary Search: Linked list top gateoverflow.in/42112

Why linked list not suitable for binary search?

binary-search

There is no way to index the elements in the linked list which makes it unsuitable for binary search.

 1 votes -- Vivek Srivastava ( 283 points)

22.13 Binary Search Tree: No of BST ? top gateoverflow.in/25640

binary-search-tree

No of possible orders=8C3=56

 0 votes -- Pooja ( 22773 points)

22.14 Binary Tree: Is it option A ? top gateoverflow.in/4221

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2141 of 2244

data-structure binary-tree

Yes It is an inorder traversal of bst..the trick we used here is making the whichnode static to increase it one by one and
get our desired node..

 4 votes -- Bhagirathi Nayak ( 10239 points)

22.15 Binary Tree: How to form a recurrence for finding the height of a
weight balanced binary tree? top gateoverflow.in/35078

A weight balanced tree is a binary tree in which for each node, the no. of nodes in the left subtree is atleast half and at most twice the no. of nodes in the
right sub tree. So how to approach for forming a recurrence for finding the height of this weight balanced binary tree ?

binary-tree data-structure

22.16 Binary Tree: What is the level number of an element present in an


array of n integers interpreted as a complete binary tree? top gateoverflow.in/18003

If I am given an array X of n distinct integers which is interpreted as a complete binary tree, so if the parent is at index i,
then it's left child would be at index 2i and it's right child would be at index 2i + 1. If root is considered to be at level 0, then
how can we find the level of an element X[i]?

I followed the approach of first considering the fact that at a level k, I would be having 2k nodes. So I just considered that in
the array starting from certain index a up to b, I have all the numbers at the same level k. That is, in a particular portion I
have 2k nodes inclusive of a and b.

Thus, before a the total no of nodes is 20 + 21 + 22 + … + 2k−1 , since index a is at level k, and before it there would be k − 1
levels.

Now I am stuck while calculating the value of b.

Please guide about how to calculate the value of b?

binary-tree data-structure

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2142 of 2244


Selected Answer

Simply take the log! So,

level = log2(index) 

The root (index = 1) is at level log2 1 = 0

The elements at index 2, 3 are both at level log22  = log23  = 1


The elements at index 4, 5, 6, 7 are all at level log2 4  = log2 5  = log2 6  = log2 7  = 2
And so on.

If you wish to continue with your approach:

Let both a and b be at the level k.

Number of nodes before a can be given as: 20 + 21 + 22 + … + 2k−1 . This huge sum is just the sum of a Geometric
Progression, and is equal to 2k − 1.

So, a, the first element at level k is infact the 2kth element of the tree! (This is a nice property of complete trees)

Since b is the last element of level k, the index of b is simply 2k+1 − 1.

Now, let us assume that the element X[i] is on the level L.

( )
Since the indices of the first and last elements on the level L are 2L and 2L+1 − 1 respectively, we know that i must be
within that range. So,

2L ≤ i ≤ 2L+1 − 1

Taking log2 , we get:

L ≤ log2 i ≤ L+1−ε

ε is a small error which was introduced when we ignored the −1 while taking log of 2L+1 − 1

So, we have:

L= log2i 
 2 votes -- Pragy Agarwal ( 13675 points)

22.17 Binary Tree: Inorder traversal of BST if it contain two identical


elements. top gateoverflow.in/13626

if two identical elements are present in BST then how inorder can give sorted array as output ?
for ex. if 50,30,45,35,56,58,74,50,15 are inserted to make BST.

binary-tree


Selected Answer

Most specify left children as <= and right children as >. Practically speaking, a BST which allows either of the right or left children to be equal to the
root node, will require extra computational steps to finish a search where duplicate nodes are allowed.

please see this link also -

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2143 of 2244

REF : http://stackoverflow.com/questions/300935/are-duplicate-keys-allowed-in-the-definition-of-binary-search-trees

 1 votes -- Pranay Datta ( 6113 points)

22.18 Binary Tree: ISRO-2013-32 top gateoverflow.in/43967

Which of the following number of nodes can form a full binary tree?

A. 8
B. 15
C. 14
D. 13

isro2013 binary-tree


Selected Answer

option B

 2 votes -- Praveen Saini ( 34299 points)

22.19 Binary Tree: Data Structures Binary Tree top gateoverflow.in/38446

Q). Find the number of trees that are possible .If we construct a binary search tree by successively inserting 5 distinct items
int an initially empty tree.

a). 4

b). 10

c). 14

d). 20

I used the formula 2n!/(n+1)!*n!. Is it right ? also the ans given is 14,but I am getting 7.

binary-tree made-easy easy data-structure

no of BST=2nCn/n+1

© Copyright GATE Overflow. All rights reserved.


GATE Overflow April 2016 2144 of 2244

=10C5/6

=42

 2 votes -- Pooja ( 22773 points)

22.20 Binary Tree: number of comparision in searching in BST top gateoverflow.in/11447

Consider the following Binary Search Tree

10
/ \
5 20
/ / \
4 15 30
/
11

If we randomly search one of the keys present in above BST, what would be the expected number of comparisons?

(A) 2.75
(B) 2.25
(C) 2.57
(D) 3.25

data-structure binary-tree


Selected Answer

Expected number of comparisons will be the sum of the product of probability of an item being the searched value and the
no. of comparisons for the same. We are given that search key is chosen randomly from one of the keys present in the
1

tree. So, the probability for each item being the searched key = n , where n is the total no. of keys in the tree.

In a BST, if an item matches at level h, we would have done h comparisons.


1 1 1 2 2 3 3 3 4 18

So, Expected no. of comparisons = ∑ni=1 hi × n where hi is the level of node i = ∑7i =1 hi × 7 = 7 + 7 + 7 + 7 + 7 + 7 + 7 = 7 = 2.57.

 7 votes -- Digvijay Pandey ( 26245 points)

22.21 Bst: Postorder traversal after creating AVL tree top gateoverflow.in/43473

The tree given is as follows:



30
/ \
12 45
\

S-ar putea să vă placă și