UGC NET · Computer Science

Data Structures Previous Year Questions

57 Data Structures (Computer Science) questions asked in UGC NET previous year papers, each with the correct answer and explanation. Read them free on UTpaper, or attempt the full papers as timed online tests.

  • 57 questions
  • Official answer key
  • Free

Other Computer Science topics

Q1UGC NET Computer Science, June 2014 (Paper II & III, Selected Questions)
Consider a complete bipartite graph kₘ,ₙ. For which values of m and n does this, complete graph have a Hamilton circuit
  1. Am = 3, n = 2
  2. Bm = 2, n = 3
  3. Cm = n ≥ 2
  4. Dm = n ≥ 3
Show answerHide answer

Correct answer: (C) m = n ≥ 2

Explanation

Kₘ,ₙ is Hamilton circuit if and only if m = n ≥ 2, (Circuit is a path similar to a cycle that starts and ends at the same vertex) and Kₘ,ₙ is a Hamilton circuit if m = n ≥ 2, so the correct answer is (c).

Q2UGC NET Computer Science, June 2014 (Paper II & III, Selected Questions)
Mergesort makes two recursive calls. Which statement is true after these two recursive calls finish, but before the merge step?
  1. AThe array elements form a heap.
  2. BElements in each half of the array are sorted amongst themselves.
  3. CElements in the first half of the array are less than or equal to elements in second half of the array.
  4. DAll of the above
Show answerHide answer

Correct answer: (B) Elements in each half of the array are sorted amongst themselves.

Explanation

After the two recursive calls in Mergesort complete, but before the merge step, elements in each half of the array are sorted amongst themselves because, Mergesort is possible when two arrays are sorted. If two unsorted arrays are submitted to Mergesort algorithm. It will sort each of them first before merging them, because Mergesort is a divide and conquer algorithm, Hence the answer is option (b).

Q3UGC NET Computer Science, June 2014 (Paper II & III, Selected Questions)
When we pass an array as an argument to a function, what actually gets passed?
  1. AAddress of the array
  2. BValues of the elements of the array
  3. CBase address of the array
  4. DNumber of elements of the array
Show answerHide answer

Correct answer: (C) Base address of the array

Explanation

Base address of an array is the starting address of an array. One can easily access to all the cells of an array if information about this can be achieved.

Q4UGC NET Computer Science, June 2014 (Paper II & III, Selected Questions)
Which of the following suffices to convert an arbitrary CFG to an LL(1) grammar?
  1. ARemoving left recursion alone
  2. BRemoving the grammar alone
  3. CRemoving left recursion and factoring the grammar
  4. DNone of the above
Show answerHide answer

Correct answer: (D) None of the above

Explanation

Removing left recursion and left factoring the grammar do not suffice to convert an arbitrary CFG to an LL(1) grammar. LL(1) parsing is top-down; for it the grammar must also be unambiguous and deterministic (e.g. an ambiguous grammar stays non-LL(1)), besides being free from left recursion.

Q5UGC NET Computer Science, June 2014 (Paper II & III, Selected Questions)
–––––––– is used in game trees to reduce the number of branches of the search tree to be traversed without affecting the solution.
  1. ABest first search
  2. BGoal stack planning
  3. CAlpha-beta pruning procedure
  4. DMin-max search
Show answerHide answer

Correct answer: (C) Alpha-beta pruning procedure

Explanation

It is a search algorithm that seeks to decrease the number nodes that are evaluated by the Min-max algorithm in its search tree. It is an adversial search algorithm used commonly for machine playing of two-player games.

Q6UGC NET Computer Science, June 2014 (Paper II & III, Selected Questions)
Suppose that the splits at every level of quicksort are in the proportion (1 − α) to α, where 0 < α ≤ 1/2 is a constant. The minimum depth of a leaf in the recursion tree is approximately given by
  1. A−lg n / lg(1 − α)
  2. B−lg(1 − α) / lg n
  3. C−lg n / lg α
  4. D−lg α / lg n
Show answerHide answer

Correct answer: (C) −lg n / lg α

Explanation

In Quicksort, the depth of a leaf depends on how the input size reduces at each level. If the split is always in the ratio (1 − α) to α, the minimum depth corresponds to the path where the recursion always follows the smaller partition, i.e. of size αn. At each level the size becomes n, αn, α²n, α³n, … We stop when the size becomes 1: αᵏn = 1 ⇒ k log α + log n = 0 ⇒ k = −lg n / lg α. Hence the answer is (c).

Q7UGC NET Computer Science, June 2014 (Paper II & III, Selected Questions)
Consider f (N) = g(N) + h(N) Where function g is a measure of the cost of getting from the start node to the current node N and h is an estimate of additional cost of getting from the current node N to the goal node. Then f(N) = h(N) is used in which one of the following algorithms?
  1. AA* algorithm
  2. BAO* algorithm
  3. CGreedy best first search algorithm
  4. DIterative A* algorithm
Show answerHide answer

Correct answer: (C) Greedy best first search algorithm

Explanation

The greedy algorithm work in a way that it has same estimate (called a heuristic) of how for from the goal any vertex is. Instead of selecting the vertex closet to the starting point, it selects the vertex closet to the goal, so the answer is (c).

Q8UGC NET Computer Science, June 2014 (Paper II & III, Selected Questions)
Match the following with respect to I/O classes in object oriented programming : List-I (A) fopen() (B) fclose() (C) ferror() (D) feof() List-II (i) returns end of file (ii) return for any problem report (iii) returns 0 (iv) returns a file pointer Codes : A B C D
  1. Aiv i ii iii
  2. Biii i iv ii
  3. Cii iii iv i
  4. Div iii i ii
Show answerHide answer

Correct answer: (A) iv i ii iii

Explanation

Fopen() : creates a file or opens an existing file and returns a file pointer, e.g. FILE ∗fp; fp = fopen("<file-name>", "<mode>"); fclose() : closes a file; returns 0 on success and EOF otherwise. ferror() : checks the error indicator for the given file stream, returning non-zero if set and 0 otherwise. feof() : checks the end-of-file indicator for the given file stream, returning non-zero if set and 0 otherwise.

Q9UGC NET Computer Science, December 2014 (Paper II & III, Selected Questions)
How many PUSH and POP operations will be needed to evaluate the following expression by reverse polish notation in a stack machine (A × B) + (C × D/E)?
  1. A4 PUSH and 3 POP instructions
  2. B5 PUSH and 4 POP instructions
  3. C6 PUSH and 2 POP instructions
  4. D5 PUSH and 3 POP instructions
Show answerHide answer

Correct answer: (B) 5 PUSH and 4 POP instructions

Explanation

The postfix form of the expression is AB*CD*E/+. Counting a PUSH for each of the 5 operands and a POP for each of the 4 operators (ignoring the pushes of intermediate results), the evaluation needs 5 PUSH and 4 POP instructions.

Q10UGC NET Computer Science, December 2014 (Paper II & III, Selected Questions)
Consider an array A[20, 10], assume 4 words per memory cell and the base address of array A is 100. What is the address of A [11, 5]? Assume row major storage.
  1. A560
  2. B565
  3. C570
  4. D575
Show answerHide answer

Correct answer: (A) 560

Explanation

Each cell needs 4 words. In row-major order, rows 0 to 10 contain 11 × 10 = 110 elements, and A[11][0] to A[11][4] add 5 more, so 115 elements precede A[11][5]. Address = 100 + 4 × 115 = 560.

Q11UGC NET Computer Science, December 2014 (Paper II & III, Selected Questions)
A full binary tree with n leaves contains
  1. An nodes
  2. Blog₂ nodes
  3. C2n – 1 nodes
  4. D2ⁿ nodes
Show answerHide answer

Correct answer: (C) 2n – 1 nodes

Explanation

A full binary tree with n leaves contains n – 1 internal nodes, so total nodes = internal nodes + leaves = (n – 1) + n = 2n – 1.

Q12UGC NET Computer Science, December 2014 (Paper II & III, Selected Questions)
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?
  1. A1135 K
  2. B335 K
  3. C1065 K
  4. D320 K
Show answerHide answer

Correct answer: (B) 335 K

Explanation

The program text is shared, so it is not multiplied by 5. As given in the book, total memory = 200 + 15 + 50 + 70 = 335 K.

Q13UGC NET Computer Science, December 2014 (Paper II & III, Selected Questions)
Which one of the following is used to compute cyclomatic complexity?
  1. AThe number of regions–1
  2. BE – N + 1 , where E is the number of flow graph edges and N is the number of flow graph nodes
  3. CP – 1, where P is the number of predicate nodes in the flow graph G.
  4. DP + 1, where P is the number of predicate nodes in the flow graph G.
Show answerHide answer

Correct answer: (D) P + 1, where P is the number of predicate nodes in the flow graph G.

Explanation

Cyclomatic complexity measures the logical complexity of a program (the number of independent paths). It can be computed as: (1) the number of regions of the flow graph; (2) V(G) = E – N + 2, where E is the number of edges and N the number of nodes; (3) V(G) = P + 1, where P is the number of predicate nodes in the flow graph G.

Q14UGC NET Computer Science, December 2014 (Paper II & III, Selected Questions)
Any decision tree that sorts n elements has height
  1. AΩ(n)
  2. BΩ(lg n)
  3. CΩ(n lg n)
  4. DΩ(n²)
Show answerHide answer

Correct answer: (C) Ω(n lg n)

Explanation

For any comparison-based sort the decision tree has at least n! leaves, so its height is at least lg(n!) = Ω(n lg n).

Q15UGC NET Computer Science, June 2015 (Paper II & III, Selected Questions)
The in order and preorder Traversal of binary tree are dbeafcg and abdecfg respectively. The post-order Traversal is ..........
  1. Adbefacg
  2. Bdebfagc
  3. Cdbefcga
  4. Ddebfgca
Show answerHide answer

Correct answer: (D) debfgca

Explanation

Take the first node in preorder traversal a will be the root. Now we construct the binary tree Therefore, postorder is - debfgca

Q16UGC NET Computer Science, June 2015 (Paper II & III, Selected Questions)
Level order Traversal of a rooted Tree can be done by starting from root and performing :
  1. ABreadth first search
  2. BDepth first search
  3. CRoot search
  4. DDeep search
Show answerHide answer

Correct answer: (A) Breadth first search

Explanation

Level order traversal is similar to breadth first search, whereas preorder traversal is similar to depth first search. So the answer is (a).

Q17UGC NET Computer Science, June 2015 (Paper II & III, Selected Questions)
The average case occurs in the Linear search Algorithm when
  1. AThe item to be searched is in some where middle of the array
  2. BThe item to be searched is not in the array
  3. CThe item to be searched is in the last of the array
  4. DThe item to be searcher is either in the last or not in the array
Show answerHide answer

Correct answer: (A) The item to be searched is in some where middle of the array

Explanation

Linear search runs in at worst linear time and make at most n comparisons, where n is the length of the list. If each element is equally likely to be searched then the linear search has an average case of (n/2) comparisons, but the average case can be affected if the search probability for each element vary.

Q18UGC NET Computer Science, June 2015 (Paper II & III, Selected Questions)
Consider the given graph (edge : weight) : 1–6 : 10, 1–2 : 28, 2–7 : 14, 2–3 : 16, 6–5 : 25, 5–7 : 24, 7–4 : 18, 5–4 : 22, 4–3 : 12 Its Minimum cost spanning tree is ..........
  1. AEdges 1–2 (28), 2–3 (16), 3–4 (12), 4–5 (22), 5–6 (25), 6–7
  2. BEdges 1–6 (10), 6–5 (25), 5–4 (22), 4–3 (12), 3–2 (16), 2–7 (14)
  3. CEdges 1–2 (28), 2–3 (16), 3–4 (12), 4–5 (22), 5–6 (25), 5–7 (24)
  4. DEdges 1–6 (10), 1–2 (28), 2–3 (16), 3–4 (12), 4–7 (18), 4–5 (22)
Show answerHide answer

Correct answer: (B) Edges 1–6 (10), 6–5 (25), 5–4 (22), 4–3 (12), 3–2 (16), 2–7 (14)

Explanation

Using Kruskal's algorithm: take 10 (1–6), 12 (3–4), 14 (2–7), 16 (2–3); skip 18 (4–7, cycle); take 22 (4–5); skip 24 (5–7, cycle); take 25 (5–6). Total = 10 + 12 + 14 + 16 + 22 + 25 = 99, which is option (b).

Q19UGC NET Computer Science, December 2015 (Paper II & III, Selected Questions)
Floyd–Warshall algorithm utilizes ............. to solve the all-pairs shortest paths problem on a directed graph in .............. time.
  1. AGreedy algorithm, Θ(V³)
  2. BGreedy algorithm, Θ log n(V²lgn)
  3. CDynamic programming, Θ(V³)
  4. DDynamic programming, Θ log n(V² lgn)
Show answerHide answer

Correct answer: (C) Dynamic programming, Θ(V³)

Explanation

The Floyd–Warshall algorithm uses dynamic programming and compares all possible paths through the graph between each pair of vertices. It does this with Θ(|V|³) comparisons.

Q20UGC NET Computer Science, December 2015 (Paper II & III, Selected Questions)
Which of the following statements are true with reference to the way of describing XML data? (1) XML uses DTD to describe the data (2) XML uses XSL to describe the data (3) XML uses a description node to describe the data Codes :
  1. A(1) only
  2. B(2) only
  3. C(1) and (2)
  4. D(1) and (3)
Show answerHide answer

Correct answer: (D) (1) and (3)

Explanation

XML data is described using a DTD (or schema) and description nodes; XSL is used to transform/present XML, not to describe it. The correct statements are (1) and (3). Hence the answer is option (d).

Q21UGC NET Computer Science, June 2016 (Paper II & III, Selected Questions)
A clique in a simple undirected graph is a complete subgraph that is not contained in any larger complete subgraph. How many cliques are there in the graph shown below? Vertices: a, b, c, d, e, f, g Edges: a-b, b-c, a-d, d-e, e-f, c-f, b-e, a-g, b-g, d-g, e-g, b-f, c-e (In the figure a, b, c are on the top row, d, e, f on the bottom row, g is where the diagonals a-e and b-d cross; the diagonals b-f and c-e cross without a vertex.)
  1. A2
  2. B4
  3. C5
  4. D6
Show answerHide answer

Correct answer: (C) 5

Explanation

A clique is a maximal complete subgraph (every vertex connected to all other vertices in the subgraph). Such subgraphs are: (i) {b, c, e, f} (ii) {a, d, g} (iii) {a, b, g} (iv) {b, e, g} (v) {d, e, g}. There are 5 cliques.

Q22UGC NET Computer Science, June 2016 (Paper II & III, Selected Questions)
Consider the following operations performed on a stack of size 5: Push (a); Pop ( ); Push (b); Push (c); Pop ( ); Push (d); Pop ( ); Pop ( ); Push (e) Which of the following statements is correct?
  1. AUnderflow occurs
  2. BStack operations are performed smoothly
  3. COverflow occurs
  4. DNone of the above
Show answerHide answer

Correct answer: (B) Stack operations are performed smoothly

Explanation

Since the given stack size is 5 and at most two elements are on the stack at any time, and no Pop is done on an empty stack, there is no overflow or underflow. The stack operations are performed smoothly.

Q23UGC NET Computer Science, June 2016 (Paper II & III, Selected Questions)
Suppose you are given a binary tree with n nodes, such that each node has exactly either zero or two children. The maximum height of the tree will be n − n + 1 1
  1. An/2 – 1
  2. Bn/2 + 1
  3. C(n – 1)/2
  4. D(n + 1)/2
Show answerHide answer

Correct answer: (C) (n – 1)/2

Explanation

In a full binary tree (each node has 0 or 2 children) with n nodes, the number of internal nodes is I = (n – 1)/2. When the tree is skewed (each internal node has one leaf child), every internal node adds one level, so the maximum height is also (n – 1)/2.

Q24UGC NET Computer Science, June 2016 (Paper II & III, Selected Questions)
Consider the following binary search tree: Root: 24 24 → left child 12, right child 26 12 → left child 11, right child 16 16 → left child 13 If we remove the root node, which of the node from the left subtree will be the new root?
  1. A11
  2. B12
  3. C13
  4. D16
Show answerHide answer

Correct answer: (D) 16

Explanation

If we delete the root node of a binary search tree, it can be replaced by its inorder successor or inorder predecessor. The inorder predecessor of 24 (largest node in the left subtree) is 16 and the inorder successor is 26. So, from the left subtree, 16 will be the new root.

Q25UGC NET Computer Science, June 2016 (Paper II & III, Selected Questions)
The number of different spanning trees in complete graph, K₄ and bipartite graph, K₂,₂ have _________ and _________ respectively.
  1. A14, 14
  2. B16, 14
  3. C16, 4
  4. D14, 4
Show answerHide answer

Correct answer: (C) 16, 4

Explanation

The number of spanning trees in a complete graph with n vertices = nⁿ⁻² = 4⁴⁻² = 16. A complete bipartite graph Kₘ,ₙ has mⁿ⁻¹ × nᵐ⁻¹ spanning trees = 2¹ × 2¹ = 4.

Q26UGC NET Computer Science, June 2016 (Paper II & III, Selected Questions)
The following statement in 'C' int (*f( ))[ ]; declares
  1. Aa function returning a pointer to an array of integers.
  2. Ba function returning an array of pointers to integers.
  3. Carray of functions returning pointers to integers.
  4. Dan illegal statement.
Show answerHide answer

Correct answer: (A) a function returning a pointer to an array of integers.

Explanation

In 'C', int (*f( ))[ ]; declares f as a function returning a pointer to an array of integers.

Q27UGC NET Computer Science, June 2016 (Paper II & III, Selected Questions)
Suppose that we have numbers between 1 and 1,000 in a binary search tree and want to search for the number 364. Which of the following sequences could not be the sequence of nodes examined?
  1. A925, 221, 912, 245, 899, 259, 363, 364
  2. B3, 400, 388, 220, 267, 383, 382, 279, 364
  3. C926, 203, 912, 241, 913, 246, 364
  4. D3, 253, 402, 399, 331, 345, 398, 364
Show answerHide answer

Correct answer: (C) 926, 203, 912, 241, 913, 246, 364

Explanation

In sequence (c), after visiting 912 (912 > 364) the search moves to the left subtree of 912, so every later node must be less than 912. 913 cannot appear after 912. So, the answer is (c).

Q28UGC NET Computer Science, June 2016 (Paper II & III, Selected Questions)
Consider the following game tree in which root is a maximizing node and children are visited left to right. What nodes will be pruned by the alpha-beta pruning? A (MAX) has children B and C (MIN nodes). B has leaf children D = 3, E = 12, F = 8. C has leaf children G = 2, H = 15, I = 6.
  1. AI
  2. BHI
  3. CCHI
  4. DGHI
Show answerHide answer

Correct answer: (B) HI

Explanation

B is a MIN node: min(3, 12, 8) = 3, so A (MAX) gets α = 3. At C, the first leaf G = 2 gives C a value ≤ 2, which is less than α = 3. Whatever H and I produce, C cannot be chosen by A, so H and I are pruned. Option (b) is correct.

Q29UGC NET Computer Science, June 2016 (Paper II & III, Selected Questions)
Which one of the following array represents a binary max-heap?
  1. A[26, 13, 17, 14, 11, 9, 15]
  2. B[26, 15, 14, 17, 11, 9, 13]
  3. C[26, 15, 17, 14, 11, 9, 13]
  4. D[26, 15, 13, 14, 11, 9, 17]
Show answerHide answer

Correct answer: (C) [26, 15, 17, 14, 11, 9, 13]

Explanation

Properties of Max Heap: Must be complete binary tree. All levels are completely filled except possibly the last level. The last level is filled from Left to Right. Each parent node has a value greater than or equal to its children. Option (a) Not fulfill the property of Max Heap. Option (b) Not fulfill the property of Max Heap. Option (c) Fulfill the property of Max Heap. Option (d) Not fulfill the property of Max Heap. So, the correct option is (c). (xii) Divide and Conquer

Q30UGC NET Computer Science, June 2016 (Paper II & III, Selected Questions)
Match the following types of variables with the corresponding programming language: A. Static variables B. Stack dynamic C. Explicit heap dynamic D. implicit heap dynamic i. Local variables in Pascal ii. All variables in APL iii. Fortran 77 iv. All objects in JAVA Code: A B C D
  1. A(i) (iii) (iv) (ii)
  2. B(iv) (i) (iii) (ii)
  3. C(iii) (i) (iv) (ii)
  4. D(ii) (i) (iii) (iv)
Show answerHide answer

Correct answer: (C) (iii) (i) (iv) (ii)

Explanation

FORTRAN I, II & IV contain only static variables. All objects in Java are explicit heap dynamic variable & are destroyed by "Garbage Collector" Languages Such as APL, ALGOL 68, & LISP Use implicit heap dynamic variables. So, a-iii, b-i, c-iv, d-ii Hence, correct option is (c).

Q31UGC NET Computer Science, August 2016 (Paper II & III, Selected Questions)
Consider the following statements : S₁ : A queue can be implemented using two stacks. S₂ : A stack can be implemented using two queues. Which of the following is correct?
  1. AS₁ is correct and S₂ is not correct
  2. BS₁ is not correct and S₂ is correct
  3. CBoth S₁ and S₂ are correct
  4. DBoth S₁ and S₂ are not correct
Show answerHide answer

Correct answer: (C) Both S₁ and S₂ are correct

Explanation

A queue can be implemented using two stacks S1 and S2: enqueue pushes onto S1; for dequeue, if S2 is not empty pop from it, otherwise first pop all elements of S1 and push them into S2, then pop from S2. So S₁ is correct. Similarly, a stack can be implemented using two queues, so S₂ is also correct. Hence, the answer is option (c).

Q32UGC NET Computer Science, August 2016 (Paper II & III, Selected Questions)
Consider an implementation of unsorted single linked list. Suppose it has its representation with a head and a tail pointer (i.e. pointers to the first and last nodes of the linked list). Given the representation, which of the following operation can not be implemented in O(1) time?
  1. AInsertion at the front of the linked list
  2. BInsertion at the end of the linked list
  3. CDeletion of the front node of the linked list
  4. DDeletion of the last node of the linked list
Show answerHide answer

Correct answer: (D) Deletion of the last node of the linked list

Explanation

Although we have a tail pointer, it is of no use for deletion because there is no previous pointer. To delete the last node we need a pointer to the second-last node so that it can become the new last node; finding it requires traversing the whole list, which takes O(n) time.

Q33UGC NET Computer Science, August 2016 (Paper II & III, Selected Questions)
Let us assume that you construct ordered tree to represent the compound proposition (~(p ∧ q)) ↔ (~p ∧ ~ q). Then, the prefix expression and post-fix expression determined using this ordered tree are given as ............ and ............. respectively.
  1. A↔~∧pq∨~~pq, pq∧~p~q~∨↔
  2. B↔~∧pq∧~p~q, pq∧~p~q~∧↔
  3. C↔∧pq∨~~pq, pq∧~p~~q∧↔
  4. D↔~∧pq∧~p~q, pq∧~p~~q∧↔
Show answerHide answer

Correct answer: (B) ↔~∧pq∧~p~q, pq∧~p~q~∧↔

Explanation

The root is ↔, its left subtree is ~(p ∧ q) and its right subtree is (~p ∧ ~q). Prefix: ↔~∧pq∧~p~q Postfix: pq∧~p~q~∧↔ Option (b) is the answer.

Q34UGC NET Computer Science, August 2016 (Paper II & III, Selected Questions)
The run time for traversing all the nodes of a binary search tree with n nodes and printing them in an order is :
  1. AO (lg n)
  2. BO(n lg n)
  3. CO(n)
  4. DO(n²)
Show answerHide answer

Correct answer: (C) O(n)

Explanation

Printing the elements in order means printing them in sorted order; inorder traversal of a BST gives the sorted order and visits each node once, taking O(n) time. For a balanced BST T(n) = 2T(n/2) + c and for a skewed tree T(n) = T(n – 1) + c; both solve to O(n).

Q35UGC NET Computer Science, August 2016 (Paper II & III, Selected Questions)
Five jobs A, B, C, D and E are waiting in Ready Queue. Their expected runtimes are 9, 6, 3, 5 are x respectively. All jobs entered in Ready queue at time zero. They must run in ......... order to minimize average response time if 3 < x < 5.
  1. AB, A, D, E, C
  2. BC, E, D, B, A
  3. CE, D, C, B, A
  4. DC, B, A, E, D
Show answerHide answer

Correct answer: (B) C, E, D, B, A

Explanation

To minimize average response time the jobs must run in shortest-job-first order: C(3), E(3 < x < 5), D(5), B(6), A(9).

Q36UGC NET Computer Science, August 2016 (Paper II & III, Selected Questions)
Let G = (V, T, S, P) be a context-free grammar such that every one of its productions is of the form A → v, with |v| = k > 1. The derivation tree for any string W ∈ L(G) has a height such that
  1. Ah < (|W| – 1)/(K – 1)
  2. Blogₖ |W| ≤ h
  3. Clogₖ |W| < h < (|W| – 1)/(K – 1)
  4. Dlogₖ |W| ≤ h ≤ (|W| – 1)/(K – 1)
Show answerHide answer

Correct answer: (D) logₖ |W| ≤ h ≤ (|W| – 1)/(K – 1)

Explanation

Each internal node of the derivation tree has exactly k children. The tree is shortest when it is complete, giving h ≥ logₖ |W|, and tallest when each level has only one internal node, giving h ≤ (|W| – 1)/(k – 1). So logₖ |W| ≤ h ≤ (|W| – 1)/(k – 1).

Q37UGC NET Computer Science, June 2017 (Paper II & III, Selected Questions)
Consider a Hamiltonian Graph G with loops or parallel edges and with |V(G)| = n ≥ 3. Then which of the following is true?
  1. Adeg(v) ≥ n/2 for each vertex v.
  2. B|E(G)| ≥ (1/2)(n – 1)(n – 2) + 2
  3. Cdeg(v) + deg(w) ≥ n whenever v and w are not connected by an edge.
  4. DAll of the above
Show answerHide answer

Correct answer: (D) All of the above

Explanation

By Dirac's theorem, deg(v) ≥ n/2 for every vertex; by Ore's theorem, deg(v) + deg(w) ≥ n for every pair of non-adjacent vertices v and w; and a graph with |E(G)| ≥ (1/2)(n – 1)(n – 2) + 2 edges is Hamiltonian. So all of the above.

Q38UGC NET Computer Science, June 2017 (Paper II & III, Selected Questions)
Which of the following statements is false? (A) Optimal binary search tree construction can be performed efficiently using dynamic programming. (B) Breadth-first search cannot be used to find connected components of a graph. (C) Given the prefix and postfix walks of a binary tree, the tree cannot be re-constructed uniquely. (D) Depth-first-search can be used to find the connected components of a graph.
  1. AA
  2. BB
  3. CC
  4. DD
Show answerHide answer

Correct answer: (B) B

Explanation

Statement B is false: breadth-first search can be used to find the connected components of a graph, just like depth-first search. Optimal binary search tree construction is a well-known dynamic programming application, and given only the prefix and postfix walks of a binary tree, the tree cannot be reconstructed uniquely.

Q39UGC NET Computer Science, June 2017 (Paper II & III, Selected Questions)
Which of the following is true for computation time in insertion, deletion and finding maximum and minimum element in a sorted array?
  1. AInsertion – O(1), Deletion – O(1), Maximum – O(1), Minimum – O(1)
  2. BInsertion – O(1), Deletion – O(1), Maximum – O(n), Minimum – O(n)
  3. CInsertion – O(n), Deletion – O(n), Maximum – O(1), Minimum – O(1)
  4. DInsertion – O(n), Deletion – O(n), Maximum – O(n), Minimum – O(n)
Show answerHide answer

Correct answer: (C) Insertion – O(n), Deletion – O(n), Maximum – O(1), Minimum – O(1)

Explanation

In a sorted array, insertion and deletion take O(n) in the worst case (elements must be shifted), while the minimum and maximum are always at the two ends, so finding them takes O(1).

Q40UGC NET Computer Science, June 2017 (Paper II & III, Selected Questions)
The order of a leaf in a B+ tree is the maximum number of children it can have. Suppose that block size is 1 kilobyte, the child pointer takes 7 bytes long and search field value takes 14 bytes long. The order of the leaf node is ..........
  1. A16
  2. B63
  3. C64
  4. D65
Show answerHide answer

Correct answer: (A) 16

Explanation

Data pointer = child pointer + search field value = 7 + 14 = 21 bytes. Maximum number of entries = 1 KB/21 bytes = 1024/21 ≈ 48.76. The book picks 16 since all other options are greater than 48.

Q41UGC NET Computer Science, June 2017 (Paper II & III, Selected Questions)
Which of the following is a valid heap? (Each tree is a complete binary tree given in level order, left to right.) (A) 16, 14, 10, 4, 7, 9, 3, 2, 8, 1 (root 16; children of 16: 14, 10; children of 14: 4, 7; children of 10: 9, 3; children of 4: 2, 8; child of 7: 1) (B) 16, 14, 10, 8, 7, 9, 3, 2, 4, 1 (root 16; children of 16: 14, 10; children of 14: 8, 7; children of 10: 9, 3; children of 8: 2, 4; child of 7: 1) (C) 16, 14, 10, 8, 1, 9, 3, 2, 4, 7 (root 16; children of 16: 14, 10; children of 14: 8, 1; children of 10: 9, 3; children of 8: 2, 4; child of 1: 7) (D) 16, 14, 3, 4, 1, 9, 10, 8, 2, 7 (root 16; children of 16: 14, 3; children of 14: 4, 1; children of 3: 9, 10; children of 4: 8, 2; child of 1: 7)
  1. AA
  2. BB
  3. CC
  4. DD
Show answerHide answer

Correct answer: (B) B

Explanation

(A) fails the max-heap property (4 has child 8). (B) is a valid max heap because every parent ≥ its children. (C) fails (1 has child 7). (D) fails (3 has children 9 and 10; 4 has child 8; 1 has child 7).

Q42UGC NET Computer Science, June 2017 (Paper II & III, Selected Questions)
Which of the following cannot be passed to a function in C++?
  1. AConstant
  2. BStructure
  3. CArray
  4. DHeader file
Show answerHide answer

Correct answer: (D) Header file

Explanation

A header file cannot be passed to a function in C++, while a constant, a structure and an array can be passed to a function.

Q43UGC NET Computer Science, June 2017 (Paper II & III, Selected Questions)
Any decision tree that sorts n elements has height ..............
  1. AΩ(lg n)
  2. BΩ(n)
  3. CΩ(n lg n)
  4. DΩ (n²)
Show answerHide answer

Correct answer: (C) Ω(n lg n)

Explanation

A binary tree of height h has at most 2ʰ leaves. Sorting n elements requires at least n! leaves, so n! ≤ 2ʰ, giving h ≥ lg(n!) ≥ (n/2) lg(n/2) = Ω(n lg n).

Q44UGC NET Computer Science, June 2017 (Paper II & III, Selected Questions)
Red–black trees are one of many search tree schemes that are "balanced" in order to guarantee that basic dynamic-set operations take .............. time in the worst case.
  1. AO(1)
  2. BO(lg n)
  3. CO(n)
  4. DO(n lg n)
Show answerHide answer

Correct answer: (B) O(lg n)

Explanation

Red-black trees are one of many search tree schemes that are 'balanced' in order to guarantee that basic dynamic-set operations take O(lg n) time in the worst case.

Q45UGC NET Computer Science, June 2017 (Paper II & III, Selected Questions)
Given the array of integers 'array' shown below : 13 7 27 2 18 33 9 11 22 8 What is the output of the following Java statements? int [ ] p = new int [10]; int [ ] q = new int [10]; for (ink k = 0; k < 10; k++) p[k] = array [k]; q = p; p[4] = 20; System out. println (array [4]+ "." + q[4]);
  1. A20 : 20
  2. B18 : 18
  3. C18 : 20
  4. D20 : 18
Show answerHide answer

Correct answer: (C) 18 : 20

Explanation

The loop copies all values of 'array' into p. After q = p, q refers to the same array object as p, so p[4] = 20 also makes q[4] = 20. 'array' itself is unchanged, so array[4] = 18. The output is 18 : 20.

Q46UGC NET Computer Science, June 2017 (Paper II & III, Selected Questions)
In Artificial Intelligence (AI), what is present in the planning graph?
  1. ASequence of levels
  2. BLiterals
  3. CVariables
  4. DHeuristic estimates
Show answerHide answer

Correct answer: (A) Sequence of levels

Explanation

A planning graph consists of a sequence of levels that correspond to time steps in the plan; level 0 is the initial state. Each level contains a set of literals (all that could be true at that time step) and a set of actions (all whose preconditions could be satisfied at that step). It is used to obtain heuristic estimates, and a solution can be extracted using GRAPHPLAN.

Q47UGC NET Computer Science, June 2017 (Paper II & III, Selected Questions)
Which of the following pairs have different expressive power?
  1. ASingle-tape-turing machine and multi-dimensional turing machine
  2. BMulti-tape turing machine and multi-dimensional turing machine
  3. CDeterministic push down automata and non-deterministic pushdown automata.
  4. DDeterministic finite automata and Non-deterministic finite automata
Show answerHide answer

Correct answer: (C) Deterministic push down automata and non-deterministic pushdown automata.

Explanation

Deterministic and non-deterministic pushdown automata have different expressive power (NPDA accept all context-free languages, DPDA only deterministic CFLs). DFA and NFA are equivalent, and all the Turing machine variants are equivalent.

Q48UGC NET Computer Science, November 2017 (Paper II & III, Selected Questions)
Post order traversal of a given binary search tree T produces following sequence of keys : Which one of the following sequences of keys can be the result of an in-order traversal of the tree T?
  1. A3, 4, 5, 7, 9, 14, 20, 18, 17, 16, 15
  2. B20, 18, 17, 16, 15, 14, 3, 4, 5, 7, 9
  3. C20, 18, 17, 16, 15, 14, 9, 7, 5, 4, 3
  4. D3, 4, 5, 7, 9, 14, 15, 16, 17, 18, 20
Show answerHide answer

Correct answer: (D) 3, 4, 5, 7, 9, 14, 15, 16, 17, 18, 20

Explanation

An in-order traversal of a binary search tree always gives the keys in ascending order, so the in-order sequence is 3, 4, 5, 7, 9, 14, 15, 16, 17, 18, 20.

Q49UGC NET Computer Science, November 2017 (Paper II & III, Selected Questions)
The following numbers are inserted into an empty binary search tree in the given order : 10, 1, 3, 5, 15, 12, 16. What is the height of the binary search tree?
  1. A3
  2. B4
  3. C5
  4. D6
Show answerHide answer

Correct answer: (A) 3

Explanation

Inserting 10, 1, 3, 5, 15, 12, 16: 10 is the root; 1 is its left child, 3 is the right child of 1 and 5 is the right child of 3; 15 is the right child of 10 with children 12 and 16. The longest root-to-leaf path is 10-1-3-5 with 3 edges, so the height is 3.

Q50UGC NET Computer Science, November 2017 (Paper II & III, Selected Questions)
Consider the graph given below (edges with weights): A-C = 6, A-E = 4, A-D = 2, A-G = 3, C-G = 2, C-F = 5, C-B = 4, D-E = 5, D-G = 4, D-B = 4, G-B = 3, B-F = 4 Use Kruskal's algorithm to find a minimal spanning tree for the graph. The list of edges of the tree in the order in which they are choosen it?
  1. AAD, AE, AG, GC, GB, BF
  2. BGC, GB, BF, GA, AD, AE
  3. CGC, AD, GB, GA, BF, AE
  4. DAD, AG, GC, AE, GB, BF
Show answerHide answer

Correct answer: (C) GC, AD, GB, GA, BF, AE

Explanation

Kruskal's algorithm picks edges in increasing order of weight while avoiding cycles: GC = 2, AD = 2, GB = 3, GA = 3, then BF = 4 and AE = 4. So the order is GC, AD, GB, GA, BF, AE. Note: more than one order is possible since edge weights are repeated.

How to use these UGC NET Computer Science questions

Every question here was asked in a real UGC NET paper; the paper and shift are shown on the card, and the number opens the question on its own page. Try each one before tapping Show answer, then attempt the full UGC NET papers as timed tests to check your speed under exam conditions.