What does the following C-statement declare? [1 mark]
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
Question 1 Explanation:
The steps to read complicated declarations : 1)Convert C declaration to postfix format and read from left to right. 2)To convert expression to postfix, start from innermost parenthesis, If innermost parenthesis is not present then start from declarations name and go right first. When first ending parenthesis encounters then go left. Once the whole parenthesis is parsed then come out from parenthesis. 3)Continue until complete declaration has been parsed. At First, we convert the following given declaration into postfix:
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.
An Abstract Data Type (ADT) is:
Same as an abstract class
A data type that cannot be instantiated
A data type type for which only the operations defined on it can be used, but none else
All of the above
Question 2 Explanation:
A common property of logic programming languages and functional languages is:
both are procedural languages
both are based on λ-calculus
both are declarative
both use Horn-clauses
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 Answer (b) Abstraction, Encapsulation, Polymorphism and Inheritance are the essential features of a OOP Language (See the Wiki page for OOP).
(i) and (ii) only
(i) and (iv) only
(i), (ii) and (iv) only
(i), (iii) and (iv) only
Question 4 Explanation:
Abstraction, Encapsulation, Polymorphism and Inheritance are the essential features of a OOP Language (See the Wiki page for OOP).
A program P reads in 500 integers in the range [0..100] representing the scores of 500 students. It then prints the frequency of each score above 50. What would be the best way for P to store the frequencies?
An array of 50 numbers
An array of 100 numbers
An array of 500 numbers
A dynamically allocated array of 550 numbers
Question 5 Explanation:
See question 1 of http://www.geeksforgeeks.org/data-structures-and-algorithms-set-22/
An undirected graph C 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 l's. Which one of the following is TRUE?
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
Question 6 Explanation:
See Question 2 of http://www.geeksforgeeks.org/data-structures-and-algorithms-set-22/
The time complexity of computing the transitive closure of a binary relation on a set of n elements is known to be
O (n log n)
Question 7 Explanation:
See question 3 of http://www.geeksforgeeks.org/data-structures-and-algorithms-set-22/
Let A, B and C be non-empty sets and let X = (A - B) - C and Y = (A - C) - (B - C). Which one of the following is TRUE?
X = Y
X ⊂ Y
Y ⊂ X
none of these
Question 8 Explanation:
We can solve it by making Venn diagram
not a lattice
a lattice but not a distributive lattice
a distributive lattice but not a Boolean algebra
a Boolean algebra
Question 9 Explanation:
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.
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
Question 10 Explanation:
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 palanar 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.
There are 90 questions to complete.