GATECS2005
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

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/complicateddeclarationsinc/ 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 
Explanation:
The correct answer is (C) A data type for which only the operations defined on it can be used, but none else.
An Abstract Data Type (ADT) is a highlevel description of a data type that defines a set of operations on the data and their behavior, without specifying the implementation details. It provides an abstraction and encapsulation of the data, allowing users to interact with the data through a defined set of operations.
Option (A) "Same as an abstract class" is not correct. While abstract classes in objectoriented programming languages can be used to define ADTs, not all ADTs are implemented using abstract classes. ADTs can be implemented in various ways, including using interfaces, data structures, or other language constructs.
Option (B) "A data type that cannot be instantiated" is also not entirely accurate. ADTs can be instantiated or used to create objects, but they typically restrict the direct access to the underlying data and enforce the use of operations defined on the ADT to manipulate and interact with the data. The key point is that an ADT provides a welldefined interface and hides the internal representation and implementation details.
Therefore, the correct answer is (C) A data type for which only the operations defined on it can be used, but none else.
Question 3 
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 Hornclauses 
Explanation:
The correct answer is (C) both are declarative.
Both logic programming languages and functional languages share the characteristic of being declarative languages. Declarative programming focuses on specifying what needs to be done rather than how to do it. In both logic programming and functional programming, the programmer describes the desired result or the properties of the solution without explicitly defining the steps or the order of execution.
In logic programming languages, such as Prolog, programs are built on a set of logical rules and facts. The programmer defines relationships between entities and the logic engine determines the appropriate answers by performing logical inference.
Functional programming languages, on the other hand, are based on the concept of functions as firstclass entities. Programs are constructed by composing functions and applying them to data. Functional languages emphasize immutability and avoid side effects, allowing for a more declarative and concise programming style.
While options (A) and (B) are not true for both logic programming and functional programming languages, option (D) is partially correct. Logic programming languages, such as Prolog, commonly use Horn clauses as a way to express logical rules. However, not all functional languages use Horn clauses. Therefore, the most accurate answer is (C) both are declarative.
Quiz of this Question
Question 4 
Which one of the following are essential features of an objectoriented programming language? (GATE CS 2005) (i) Abstraction and encapsulation (ii) Strictlytypedness (iii) Typesafe property coupled with subtype 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 
Abstraction, Encapsulation, Polymorphism and Inheritance are the essential features of a OOP Language.
Question 5 
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 
Explanation:
The program needs to store the frequency of each score above 50, which means it only needs to track the frequencies for scores ranging from 51 to 100. Since the scores are in the range [0..100], and the program is only interested in scores above 50, the possible scores to consider are from 51 to 100.
Given that the scores range from 51 to 100, there are 50 possible scores in this range. Therefore, using an array of 50 numbers is sufficient to store the frequencies for each score. Each element in the array can correspond to a specific score, where the index represents the score itself, and the value at that index represents the frequency.
For example, index 0 of the array can represent score 51, index 1 can represent score 52, and so on, up to index 49 representing score 100. By using an array of 50 numbers, the program can directly access the frequency for each score by its corresponding index.
Using an array of 50 numbers is a compact and efficient way to store the frequencies since it precisely matches the number of distinct scores above 50. It avoids unnecessary memory allocation and provides a direct mapping between scores and frequencies.
Therefore, the correct explanation is that option (A) An array of 50 numbers is the best way for the program P to store the frequencies of scores above 50.
See Question 1 of https://www.geeksforgeeks.org/datastructuresandalgorithmsset22/
Question 6 
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) nondiagonal 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 n1  
Graph G has multiple distinct MSTs, each of cost n1  
Graph G has multiple spanning trees of different costs 
Explanation:
The correct answer is (C).
An MST is a tree that connects all the vertices of a graph with the minimum possible total edge weight. An MST does not contain any cycles.
The adjacency matrix of an undirected graph shows which vertices are connected by edges. In this case, the adjacency matrix is given by an n × n square matrix whose diagonal elements are 0's and nondiagonal elements are 1's. This means that every vertex is connected to every other vertex by an edge.
Since every vertex is connected to every other vertex, there are multiple MSTs for this graph. Each MST will have n1 edges, because there are n vertices and an MST cannot have any cycles. The cost of each MST will be n1, because the cost of an edge is 1.
Therefore, the answer is (C).
https://www.geeksforgeeks.org/datastructuresandalgorithmsset22/
See Question 2 of
Question 7 
The time complexity of computing the transitive closure of a binary relation on a set of n elements is known to be
O (n)  
O (n log n)  
O(n^{3/2})  
O(n^{3}) 
Answer : (D)
Explanation:
The correct answer is (D), O(n3).
The transitive closure of a binary relation on a set of n elements can be computed using the Floyd–Warshall algorithm. This algorithm has a time complexity of O(n3).
The other options are incorrect. Option (A), O(n), is the time complexity of simply iterating over the set of n elements. Option (B), O(n log n), is the time complexity of sorting the set of n elements. Option (C), O(n3/2), is not a valid time complexity. https://www.geeksforgeeks.org/datastructuresandalgorithmsset22/
See question 3 of
Question 8 
Let A, B and C be nonempty 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 
Answer : (A)
Explanation:
The correct answer is (A), X = Y.
Let's take a look at the sets X and Y again.
 X = (A  B)  C
 This means that X is the set of elements that are in A but not in B, and also not in C.
 Y = (A  C)  (B  C)
 This means that Y is the set of elements that are in A but not in C, and also not in the set of elements that are in B but not in C.
In other words, X is the set of elements that are in A but not in B and C, and Y is the set of elements that are in A but not in the set of elements that are in B but not in C.
Since X and Y are both the set of elements that are in A but not in B and C, then X = Y.
Therefore, the answer is (A).
We can solve it by making
Question 9 
not a lattice  
a lattice but not a distributive lattice  
a distributive lattice but not a Boolean algebra  
a Boolean algebra 
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 
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+1319=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.
Please Login to comment...