GATE-CS-2005
Question 1 |
int ( * f) (int * ) ;
A function that takes an integer pointer as argument and returns an integer. | |
A function that takes an integer as argument and returns an integer pointer. | |
A pointer to a function that takes an integer pointer as argument and returns an integer. | |
A function that takes an integer pointer as argument and returns a function pointer
|
Discuss it
int ( * f) (int * )Since there is no innermost bracket, so first we take declaration name f, so print “f” and then go to the right, since there is nothing to parse, so go to the left. There is * at the left side, so print “*”.Come out of parenthesis. Hence postfix notation of given declaration can be written as follows:
f * (int * ) intMeaning: f is a pointer to function (which takes one argument of int pointer type) returning int . Refer http://www.geeksforgeeks.org/complicated-declarations-in-c/ This solution is contributed by Nirmal Bharadwaj.
Question 2 |
An Abstract Data Type (ADT) is:
Same as an abstract class | |
A data type that cannot be instantiated | |
A data type for which only the operations defined on it can be used, but none else | |
All of the above |
Discuss it
Question 3 |
both are procedural languages | |
both are based on λ-calculus | |
both are declarative | |
both use Horn-clauses |
Discuss it
Question 4 |
Which one of the following are essential features of an object-oriented programming language? (GATE CS 2005) (i) Abstraction and encapsulation (ii) Strictly-typedness (iii) Type-safe property coupled with sub-type rule (iv) Polymorphism in the presence of inheritance
(i) and (ii) only | |
(i) and (iv) only | |
(i), (ii) and (iv) only | |
(i), (iii) and (iv) only |
Discuss it
Abstraction, Encapsulation, Polymorphism and Inheritance are the essential features of a OOP Language.
Question 5 |
An array of 50 numbers | |
An array of 100 numbers | |
An array of 500 numbers | |
A dynamically allocated array of 550 numbers |
Discuss it
Question 6 |
Graph G has no minimum spanning tree (MST) | |
Graph G has a unique MST of cost n-1 | |
Graph G has multiple distinct MSTs, each of cost n-1 | |
Graph G has multiple spanning trees of different costs |
Discuss it
Question 7 |
O (n) | |
O (n log n) | |
O(n3/2) | |
O(n3) |
Discuss it
Question 8 |
X = Y | |
X ⊂ Y | |
Y ⊂ X | |
none of these |
Discuss it
Question 9 |
not a lattice | |
a lattice but not a distributive lattice | |
a distributive lattice but not a Boolean algebra | |
a Boolean algebra |
Discuss it
It is a lattice but not a distributive lattice. Table for Join Operation of above Hesse diagram V |a b c d e ________________ a |a a a a a b |a b a a b c |a a c a c d |a a a d d e |a b c d e Table for Meet Operation of above Hesse diagram ^ |a b c d e _______________ a |a b c d e b |b b e e e c |c e c e e d |d e e d e e |e e e e e Therefore for any two element p, q in the lattice (A,<=) p <= p V q ; p^q <= p This satisfies for all element (a,b,c,d,e). which has 'a' as unique least upper bound and 'e' as unique greatest lower bound. The given lattice doesn't obey distributive law, so it is not distributive lattice, Note that for b,c,d we have distributive law b^(cVd) = (b^c) V (b^d). From the diagram / tables given above we can verify as follows, (i) L.H.S. = b ^ (c V d) = b ^ a = b (ii) R.H.S. = (b^c) V (b^d) = e v e = e b != e which contradict the distributive law. Hence it is not distributive lattice. so, option (B) is correct.
Question 10 |
Let G be a simple connected planar graph with 13 vertices and 19 edges. Then, the number of faces in the planar embedding of the graph is
6 | |
8 | |
9 | |
13 |
Discuss it
An undirected graph is called a planar graph if it can be drawn on a paper without having two edges cross and such a drawing is called Planar Embedding. We say that a graph can be embedded in the plane, if it planar. A planar graph divides the plane into regions (bounded by the edges), called faces. Graph K4 is planar graph, because it has a planar embedding as shown in figure below.
Euler's Formula : For any polyhedron that doesn't intersect itself (Connected Planar Graph),the
• Number of Faces(F)
• plus the Number of Vertices (corner points) (V)
• minus the Number of Edges(E),
always equals 2. This can be written: F + V − E = 2.
Solution:
Here as given, F=?,V=13 and E=19
-> F+13-19=2
-> F=8
So Answer is (B).
This solution is contributed by Nirmal Bharadwaj
We can apply Euler's Formula of planar graphs. The formula is v − e + f = 2.