DSSSB TGT / PGT · Computer Science

Data Structures Previous Year Questions (page 2)

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

  • 144 questions
  • Official answer key
  • Free

Other Computer Science topics

Q51DSSSB PGT Computer Science (Technical), 11 Jul 2021
The numbers 70, 50, 10, 80, 30, 60, 100, 90, 40, 20 are inserted in the given order in to a binary search tree. What is the in-order traversal sequence of the resultant binary search tree?
  1. A70, 50, 10, 80, 30, 60, 100, 90, 40, 20
  2. B100, 90, 80, 70, 60, 50, 40, 30, 20, 10
  3. C10, 30, 50, 70, 90, 20, 40, 60, 80, 100
  4. D10, 20, 30, 40, 50, 60, 70, 80, 90, 100
Show answerHide answer

Correct answer: (D) 10, 20, 30, 40, 50, 60, 70, 80, 90, 100

Explanation

In-order traversal of any binary search tree visits the keys in ascending sorted order: 10, 20, ..., 100.

Q52DSSSB PGT Computer Science (Technical), 11 Jul 2021
What is balance factor of an AVL tree?
  1. A|h(TL)| ≤ 1
  2. B|h(TR)| ≤ 1
  3. C|h(TL) − h(TR)| ≤ 1
  4. D|h(TL) + h(TR)| ≤ 1
Show answerHide answer

Correct answer: (C) |h(TL) − h(TR)| ≤ 1

Explanation

In an AVL tree, the heights of the left and right subtrees of every node differ by at most 1: |h(TL) − h(TR)| ≤ 1.

Q53DSSSB PGT Computer Science (Technical), 11 Jul 2021
Consider a sorted array of 10,00,000 elements. What is the maximum number of comparison required to find the location an item using binary search?
  1. A20
  2. B6
  3. C31
  4. D7
Show answerHide answer

Correct answer: (A) 20

Explanation

Binary search needs at most ⌈log₂(n+1)⌉ comparisons. 2²⁰ = 1,048,576 ≥ 10,00,000, so the maximum is 20.

Q54DSSSB PGT Computer Science (Technical), 11 Jul 2021
Consider an array A[2 : 8, −4 : 1, 6 : 10]. Base address of array A is = 400 and size of each element = 2 word per memory cell. What is the address of A[5, −1, 8] in row major form?
  1. A628
  2. B614
  3. C630
  4. D626
Show answerHide answer

Correct answer: (A) 628

Explanation

Note: DSSSB allowed option (a) as correct (the computed value 614 does not match the official key).

Q55DSSSB PGT Computer Science (Technical), 11 Jul 2021
Inorder and postorder traversal of a binary tree are given. In: E, I, C, F, B, G, D, J, H, K Post: I, E, F, C, G, J, K, H, D, B What is the preorder traversal of the binary tree?
  1. AB, C, E, I, F, D, G, H, J, K
  2. BB, F, I, E, C, D, G, H, J, K
  3. CB, C, E, I, F, D, G, H, K, J
  4. DB, C, E, F, G, H, K, D, J, I
Show answerHide answer

Correct answer: (A) B, C, E, I, F, D, G, H, J, K

Explanation

The root is B (last in postorder). Left subtree {E,I,C,F} has root C, with E (right child I) and F. Right subtree {G,D,J,H,K} has root D, with left G and right H (J, K). Preorder: B, C, E, I, F, D, G, H, J, K.

Q56DSSSB PGT Computer Science (Technical), 11 Jul 2021
If complete graph have 'n' nodes, then it will have how many edges?
  1. An(n − 1)/2
  2. B(n − 1)/2
  3. Cn/2
  4. Dn(n − 1)/4
Show answerHide answer

Correct answer: (A) n(n − 1)/2

Explanation

Each of the n nodes connects to the other n − 1. Each edge is then counted twice, so there are n(n − 1)/2 edges.

Q57DSSSB PGT Computer Science (Technical), 11 Jul 2021
Which of the following statement is false about a B-tree of order M?
  1. AThe root has at least two child nodes and at most M child nodes.
  2. BThe internal nodes except the root have at least ceil(M/2) child nodes.
  3. CLeaf nodes are not at the same level.
  4. DA node is full if it has (M − 1) keys.
Show answerHide answer

Correct answer: (C) Leaf nodes are not at the same level.

Explanation

In a B-tree all leaves are at the same level, so statement (C) is false. The others are standard B-tree properties.

Q58DSSSB PGT Computer Science (Technical), 11 Jul 2021
The number of vertices in undirected graph with odd degree is always ________.
  1. AOdd number
  2. BEven number
  3. CZero
  4. DPrime number
Show answerHide answer

Correct answer: (B) Even number

Explanation

By the handshaking lemma the sum of degrees is 2|E|, which is even, so the number of odd-degree vertices must be even.

Q59DSSSB PGT Computer Science (Technical), 11 Jul 2021
Which of the following statement(s) is/are correct about red-black binary tree? I. Every node is either red or black. II. Every leaf node is red. III. When a node is red and both its children are black.
  1. AI and II
  2. BI, II and III
  3. CI and III
  4. DIII and II
Show answerHide answer

Correct answer: (C) I and III

Explanation

In a red-black tree every node is red or black, and a red node's children must be black. Leaves (NIL nodes) are black, not red, so II is false.

Q60DSSSB PGT Computer Science (Technical), 11 Jul 2021
Consider a max heap, represented by the array: 23, 17, 14, 6, 13, 10, 1, 5 If a value 20 is inserted into this heap, then what will be the new max heap
  1. A23, 17, 4, 6, 13, 10, 1, 5, 20
  2. B23, 20, 14, 17, 13, 10, 1, 5, 6
  3. C23, 20, 17, 14, 13, 10, 6, 5, 1
  4. D23, 17, 20, 14, 13, 10, 6, 51
Show answerHide answer

Correct answer: (B) 23, 20, 14, 17, 13, 10, 1, 5, 6

Explanation

Add 20 at position 9 as the child of 6, then swap it with 6. Its parent is now 17, so swap again. The parent 23 is larger, so it stops: 23, 20, 14, 17, 13, 10, 1, 5, 6.

Q61DSSSB PGT Computer Science (Technical), 11 Jul 2021
Consider the following graph. Vertices P, Q, R, S, T with edges (weight): P–Q (30), Q–R (5), Q–S (20), Q–T (15), P–S (40), S–T (10), R–T (25). What is the weight of minimum spanning tree?
  1. A50
  2. B60
  3. C70
  4. D80
Show answerHide answer

Correct answer: (B) 60

Explanation

Kruskal: take Q–R (5), S–T (10), Q–T (15); skip Q–S (20) and R–T (25), which would form cycles; take P–Q (30). Weight = 5 + 10 + 15 + 30 = 60.

Q62DSSSB TGT Computer Science (Technical), 8 Aug 2021, Shift 2
What is the total number of elements in a array E[-4: 1, 6: 10]?
  1. A30
  2. B20
  3. C9
  4. D11
Show answerHide answer

Correct answer: (A) 30

Explanation

Rows run from −4 to 1, which is 1 − (−4) + 1 = 6 rows. Columns run from 6 to 10, which is 10 − 6 + 1 = 5 columns. Total elements = 6 × 5 = 30.

Q63DSSSB TGT Computer Science (Technical), 8 Aug 2021, Shift 2
Which data structure is used to indicate that the order of the processing of data must be postponed until other conditions are fulfilled?
  1. AArray
  2. BLinked list
  3. CTrees
  4. DStack
Show answerHide answer

Correct answer: (D) Stack

Explanation

A stack holds pending work in LIFO order. The postponed items wait on the stack and are processed only after the current conditions are met, as in recursion or backtracking.

Q64DSSSB TGT Computer Science (Technical), 8 Aug 2021, Shift 2
Consider the following new-order strategy for traversing a given tree. I. Visit the right subtree of a Node using new-order II. Visit the Node III. Visit the left subtree of a Node using new-order The tree: P is the root. P has left child Q and right child V. Q has left child R and right child S; S has left child T; T has right child U. V has left child W and right child Z; W has right child X; X has right child Y. What is the new-order traversal of the given tree?
  1. AZ, V, Y,X, W,P, S, U, T,Q, R
  2. BR, Q, T, U, S, P, W,X, Y, V, Z
  3. CP, W, X, Y, V,Z,R, Q, T, U, S
  4. DS, U, T,Q,R, Z, V, Y,X, W, P
Show answerHide answer

Correct answer: (A) Z, V, Y,X, W,P, S, U, T,Q, R

Explanation

This new-order is right, node, left, which is reverse in-order. The right subtree of P gives Z, V, Y, X, W. Then comes P. The left subtree gives S, U, T, Q, R.

Q65DSSSB TGT Computer Science (Technical), 8 Aug 2021, Shift 2
Consider a binary search tree given below. Root 14 has left child 10 and right child 16. 10 has left child 7 and right child 13; 13 has left child 11. 16 has right child 20; 20 has left child 18 and right child 25; 25 has left child 22. What is the pre-order traversal of the binary search tree after 14 is deleted?
  1. A7, 10, 11, 13, 16, 18, 20, 22, 25
  2. B16, 10, 7, 13, 11, 20, 18, 25, 22
  3. C16, 7, 10, 13, 11, 18, 22, 20, 25
  4. D25, 20, 22, 18, 11, 13, 10, 16, 7
Show answerHide answer

Correct answer: (B) 16, 10, 7, 13, 11, 20, 18, 25, 22

Explanation

14 has two children, so it is replaced by its in-order successor 16, the smallest key in its right subtree. 16's right child 20 moves up. Pre-order is then 16, 10, 7, 13, 11, 20, 18, 25, 22.

Q66DSSSB TGT Computer Science (Technical), 8 Aug 2021, Shift 2
Which of the following can be the valid balance factor of any node in an AVL tree?
  1. A1
  2. B2
  3. C3
  4. D4
Show answerHide answer

Correct answer: (A) 1

Explanation

An AVL tree allows each node a balance factor (left height minus right height) of only −1, 0 or +1. So 1 is valid, while 2, 3 and 4 would need a rebalancing rotation.

Q67DSSSB TGT Computer Science (Technical), 8 Aug 2021, Shift 2
The vertex in graph with degree one is known as
  1. AIsolated vertex
  2. BLoop vertex
  3. CPendant vertex
  4. DExternal vertex
Show answerHide answer

Correct answer: (C) Pendant vertex

Explanation

A pendant vertex has degree exactly one. An isolated vertex has degree zero.

Q68DSSSB TGT Computer Science (Technical), 8 Aug 2021, Shift 2
For the given graph, what does the following matrix represent? Graph: vertices V1, V2, V3, V4 with edges e1 = V1–V3, e2 = V3–V4, e3 = V2–V3, e4 = V2–V4, e5 = V1–V4. Matrix (rows and columns v1, v2, v3, v4): [ 0 0 1 1 ] [ 0 0 1 1 ] [ 1 1 0 1 ] [ 1 1 1 0 ]
  1. AAdjacency matrix
  2. BIncidence matrix
  3. CCircuit matrix
  4. DCut-set matrix
Show answerHide answer

Correct answer: (A) Adjacency matrix

Explanation

The matrix is square, vertex by vertex, and entry (i, j) = 1 exactly when vi and vj are joined by an edge. For example, V1 is joined to V3 and V4. So it is the adjacency matrix. An incidence matrix would be vertex by edge.

Q69DSSSB TGT Computer Science (Technical), 7 Aug 2021, Shift 3
The operator in C++, which is used to access a value referred by a pointer is known as ________.
  1. AIndirect operator
  2. BDirect operator
  3. CIndirection operator
  4. DInsertion operator
Show answerHide answer

Correct answer: (C) Indirection operator

Explanation

The unary * operator, which gives the value a pointer points to, is called the indirection (dereference) operator.

Q70DSSSB TGT Computer Science (Technical), 7 Aug 2021, Shift 3
Which traversal of binary search tree is in ascending order? I. Preorder traversal II. Postorder traversal III. Inorder traversal
  1. AOnly II
  2. BI and III
  3. COnly III
  4. DII and III
Show answerHide answer

Correct answer: (C) Only III

Explanation

An in-order traversal (Left, Node, Right) of a BST visits the keys in ascending order. Pre-order and post-order do not.

Q71DSSSB TGT Computer Science (Technical), 7 Aug 2021, Shift 3
Which rotations in an AVL tree is known as double rotation?
  1. ALL and RR
  2. BLR and LL
  3. CRL and RR
  4. DLR and RL
Show answerHide answer

Correct answer: (D) LR and RL

Explanation

LR and RL cases each need two single rotations, so they are called double rotations. LL and RR need only one.

Q72DSSSB TGT Computer Science (Technical), 7 Aug 2021, Shift 3
Consider the following arrays of elements 289, 219, 250, 217, 212, 215, 22, 25, 27, 211, 26, 29, 300. What is the minimum number of interchanges needed to convert it into max-heap?
  1. A4
  2. B5
  3. C2
  4. D3
Show answerHide answer

Correct answer: (D) 3

Explanation

Bottom-up heapify: 215 swaps with 300, 250 swaps with 300, then 289 swaps with 300. No other node violates the heap, so 3 interchanges.

Q73DSSSB TGT Computer Science (Technical), 7 Aug 2021, Shift 2
Which of the following statement(s) is/are true about binary search algorithm? I. It is implemented on sorted array. II. One must have direct access to the middle element in any sub-list. III. It is implemented on sorted linked list.
  1. AII and III
  2. BI and III
  3. CI and II
  4. DI, II and III
Show answerHide answer

Correct answer: (C) I and II

Explanation

Binary search needs a sorted list with direct (random) access to the middle element, which an array provides. A linked list has no direct access to the middle, so III is false.

Q74DSSSB TGT Computer Science (Technical), 7 Aug 2021, Shift 2
2 Dimensional array (Matrices) with relatively high proportion of zero entries are called ________ while with low proportion of zero entries are called ________.
  1. ARegular matrix; Non-Regular matrix
  2. BSparse Matrix; Dense matrix
  3. CTranspose Matrix; Inverse Matrix
  4. DSquare Matrix; Dense Matrix
Show answerHide answer

Correct answer: (B) Sparse Matrix; Dense matrix

Explanation

A matrix with a high proportion of zero entries is a sparse matrix; one with few zeros is a dense matrix.

Q75DSSSB TGT Computer Science (Technical), 7 Aug 2021, Shift 2
The height of a tree is the length of the longest path from root to leaf. What is the maximum and minimum number of nodes in a binary tree of height 'n'?
  1. A2ⁿ⁺¹ − 1, n + 1
  2. B2ⁿ − 1, n
  3. C2ⁿ, n + 1
  4. D2ⁿ⁻¹ − 1, n
Show answerHide answer

Correct answer: (A) 2ⁿ⁺¹ − 1, n + 1

Explanation

A binary tree of height n has at most 1 + 2 + ... + 2ⁿ = 2ⁿ⁺¹ − 1 nodes (completely full) and at least n + 1 nodes (one node per level, a chain).

Q76DSSSB TGT Computer Science (Technical), 7 Aug 2021, Shift 2
Assume two binary operators '^' and 'v'. '^' has higher precedence than 'v'. Operator '^' is right associative while operator 'v' is left associative. Which of the following represents the expression tree for the given expression? (9 v 3 ^ 4 v 2)
  1. ARoot v with left child ^ and right child 2; the ^ node has left child 9 and right child v, whose children are 3 and 4.
  2. BRoot v with left child v and right child 2; the inner v has left child 9 and right child ^, whose children are 3 and 4.
  3. CRoot v with left child v and right child 2; the inner v has left child ^ (children 3 and 4) and right child 9.
  4. DRoot v with left child 2 and right child v; the inner v has left child 9 and right child ^, whose children are 3 and 4.
Show answerHide answer

Correct answer: (B) Root v with left child v and right child 2; the inner v has left child 9 and right child ^, whose children are 3 and 4.

Explanation

^ binds tighter, so 3 ^ 4 is grouped first: 9 v (3 ^ 4) v 2. v is left associative, so it is (9 v (3 ^ 4)) v 2: root v with left child the inner v and right child 2.

Q77DSSSB TGT Computer Science (Technical), 7 Aug 2021, Shift 2
Which of the following is not collision resolution technique of hashing?
  1. ADouble hashing
  2. BQuadratic probing
  3. CChaining
  4. DFolding
Show answerHide answer

Correct answer: (D) Folding

Explanation

Double hashing, quadratic probing and chaining resolve collisions. Folding is a method of computing a hash function, not a collision resolution technique.

Q78DSSSB TGT Computer Science (Technical), 7 Aug 2021, Shift 2
Which of the following is stable sort?
  1. ASelection sort
  2. BQuick sort
  3. CHeap sort
  4. DMerge sort
Show answerHide answer

Correct answer: (D) Merge sort

Explanation

Merge sort is stable: equal keys keep their original order. Selection, quick and heap sort are not stable in their usual forms.

Q79DSSSB TGT Computer Science (Technical), 7 Aug 2021, Shift 2
Post-order Binary tree traversal is ________.
  1. ALeft, Node, Right
  2. BLeft, Right, Node
  3. CNode, Left, Node
  4. DRight, Left, Node
Show answerHide answer

Correct answer: (B) Left, Right, Node

Explanation

Post-order traversal visits the left subtree, then the right subtree, then the node (Left, Right, Node).

Q80DSSSB TGT Computer Science (Technical), 7 Aug 2021, Shift 2
What will be the balancing factor of node 14 in an AVL tree when a node 13 is deleted from it? Tree: root 14 has left child 1 and right child 64. Node 1 has right child 13. Node 64 has left child 26 and right child 98. Node 98 has left child 85 and right child 110.
  1. ABF(14) = −1
  2. BBF(14) = −2
  3. CBF(14) = 2
  4. DBF(14) = 1
Show answerHide answer

Correct answer: (B) BF(14) = −2

Explanation

After deleting 13, the left subtree of 14 is just node 1 (height 1). The right subtree 64 → 98 → 85 has height 3. BF = 1 − 3 = −2.

Q81DSSSB TGT Computer Science (Technical), 7 Aug 2021, Shift 2
Consider a max heap, represented by the array 400, 300, 200, 100, 150, 160, 170, 80, 40. Which will be the new heap after insertion of 350?
  1. A400, 300, 200, 100, 150, 160, 170, 80, 40, 350
  2. B400, 350, 200, 100, 300, 160, 170, 80, 40, 150
  3. C400, 300, 200, 100, 350, 160, 170, 80, 40, 150
  4. D400, 350, 200, 100, 150, 160, 170, 80, 40, 300
Show answerHide answer

Correct answer: (B) 400, 350, 200, 100, 300, 160, 170, 80, 40, 150

Explanation

Insert 350 at the end (position 10). Its parent 150 is smaller, so swap. The new parent 300 is smaller, so swap again. 400 is larger, so stop: 400, 350, 200, 100, 300, 160, 170, 80, 40, 150.

Q82DSSSB TGT Computer Science (Technical), 1 Aug 2021, Shift 3
Consider the following New-order strategy for traversing a binary tree. I. Visit the right subtree of node using new-order II. Visit the left subtree of node using new-order III. Visit the node Tree: root A has left child B and right child E. B has right child C; C has left child D. E has left child F and right child I; F has children G (left) and H (right); I has right child J; J has right child K. What is the new-order traversal of the given tree?
  1. AK, J, I, H, G, F, E, D, C, B, A
  2. BA, B, C, D, E, F, G, H, I, J, K
  3. CB, D, C, A, G, F, H, E, I, J, K
  4. DA, B, C, D, K, J, I, H, G, F, E
Show answerHide answer

Correct answer: (A) K, J, I, H, G, F, E, D, C, B, A

Explanation

Right-left-node is the exact reverse of preorder (node-left-right). The preorder is A, B, C, D, E, F, G, H, I, J, K, so the new-order is K, J, I, H, G, F, E, D, C, B, A.

Q83DSSSB TGT Computer Science (Technical), 1 Aug 2021, Shift 3
Which statement is correct regarding binary search tree? I. The value at node N is less than every value in the left subtree of node. II. The value at node N is greater than or equal to every value in the right subtree of N.
  1. AOnly I
  2. BOnly II
  3. CBoth I and II
  4. DNeither I nor II
Show answerHide answer

Correct answer: (D) Neither I nor II

Explanation

In a BST, the value at N is greater than every value in its left subtree and less than (or equal to) every value in its right subtree. Both statements reverse this, so neither is correct.

Q84DSSSB TGT Computer Science (Technical), 1 Aug 2021, Shift 3
Which of the following statement(s) is/are correct regarding the undirected graph? I. Number of odd degree vertices is even. II. Sum of degrees of all vertices is even.
  1. AOnly I
  2. BOnly II
  3. CBoth I and II
  4. DNeither I nor II
Show answerHide answer

Correct answer: (C) Both I and II

Explanation

Each edge adds 2 to the total degree, so the sum of degrees is even (handshaking lemma), and hence the number of odd-degree vertices must also be even.

Q85DSSSB TGT Computer Science (Technical), 1 Aug 2021, Shift 3
Which statement(s) is/are correct regarding node N deletion in binary search tree? I. If node N has no children then just replace location of N in the parent node by the null pointer. II. If node N has two children, then replace it by preorder successor.
  1. AOnly I
  2. BOnly II
  3. CBoth I and II
  4. DNeither I nor II
Show answerHide answer

Correct answer: (A) Only I

Explanation

A leaf node is removed by setting its parent's pointer to null (I correct). A node with two children is replaced by its inorder successor (or predecessor), not its preorder successor, so II is wrong.

Q86DSSSB TGT Computer Science (Technical), 1 Aug 2021, Shift 1
What is the condition for binary search of be unsuccessful where Beg is the beginning and End is ending location of sorted array?
  1. AEnd > Beg
  2. BEnd == Beg
  3. CEnd < Beg
  4. DEnd != Beg
Show answerHide answer

Correct answer: (C) End < Beg

Explanation

Binary search keeps narrowing Beg..End; when Beg passes End (End < Beg) the search range is empty, so the element is not present.

Q87DSSSB TGT Computer Science (Technical), 1 Aug 2021, Shift 1
While inserting the elements 71, 56, 48, 96, 76, 82, 98 in an empty binary search tree in the sequence shown, which element will come in the lowest level?
  1. A96
  2. B98
  3. C71
  4. D82
Show answerHide answer

Correct answer: (D) 82

Explanation

71 is the root; 56 and 48 go left; 96 goes right; 76 becomes the left child of 96; 82 goes right of 76 (level 4); 98 is the right child of 96. So 82 is at the deepest level.

Q88DSSSB TGT Computer Science (Technical), 1 Aug 2021, Shift 1
What is the other name of Data Flow Diagram (DFD)?
  1. AFlow chart
  2. BPictorial graph
  3. CBubble chart
  4. DDi graph
Show answerHide answer

Correct answer: (C) Bubble chart

Explanation

A DFD is also called a bubble chart because processes are drawn as circles (bubbles).

Q89DSSSB TGT Computer Science (Technical), 1 Aug 2021, Shift 1
N is the number of nodes of the control graph and E is the number of edges in the control flow graph. What is Mc Cabe's cyclomatic complexity V(G)?
  1. AV(G) = E + N + 2
  2. BV(G) = E − N + 2
  3. CV(G) = E + N − 2
  4. DV(G) = E − N − 2
Show answerHide answer

Correct answer: (B) V(G) = E − N + 2

Explanation

McCabe's cyclomatic complexity for a connected control flow graph is V(G) = E − N + 2 (or number of decisions + 1).

Q90DSSSB TGT Computer Science (Technical), 1 Aug 2021, Shift 1
Which of the following is a max-heap?
  1. ARoot 100; children 80 and 60; 80 has child 40; 60 has children 50 and 30; 50 has child 20.
  2. BRoot 100; children 80 and 60; 80 has children 40 and 50; 60 has children 20 and 30.
  3. CRoot 100; children 80 and 60; 80 has children 40 and 50; 60 has right child 30; 30 has child 20.
  4. DRoot 100; children 50 and 60; 50 has children 40 and 80; 60 has children 20 and 30.
Show answerHide answer

Correct answer: (B) Root 100; children 80 and 60; 80 has children 40 and 50; 60 has children 20 and 30.

Explanation

A max-heap must be a complete binary tree with every parent ≥ its children. Option B satisfies both. A and C are not complete trees, and in D the node 50 has a larger child 80.

Q91DSSSB TGT Computer Science (Technical), 1 Aug 2021, Shift 1
Which rotations in AVL trees are known as single rotations?
  1. ALL and RR
  2. BLL and LR
  3. CRR and RL
  4. DLR and RL
Show answerHide answer

Correct answer: (A) LL and RR

Explanation

LL and RR imbalances are fixed by one rotation (single rotations). LR and RL need two rotations, so they are double rotations.

Q92DSSSB TGT Computer Science (Technical), 1 Aug 2021, Shift 1
What is the at most height of red-black tree with n internal node?
  1. An
  2. Blog₂n
  3. C2log₂(n + 1)
  4. Dlog₂(2n + 1)
Show answerHide answer

Correct answer: (C) 2log₂(n + 1)

Explanation

A red-black tree with n internal nodes has height at most 2log₂(n + 1), since the black height is at least half the height.

Q93DSSSB TGT Computer Science (Technical), 1 Aug 2021, Shift 1
Consider the following AVL tree. Root 38; left child 14, right child 56. 14 has children 8 and 23; 23 has left child 18. 56 has children 45 and 82; 82 has left child 70. What will be the resultant AVL tree after insertion of node with value 20?
  1. ARoot 38; 14 (children 8, 23); 23 has left child 18; 18 has right child 20; 56 (children 45, 82); 82 has left child 70.
  2. BRoot 38; 14 (children 8, 20); 20 has children 18 and 23; 56 (children 45, 82); 82 has left child 70.
  3. CRoot 38; 14 (children 8, 23); 23 has left child 20; 20 has left child 18; 56 (children 45, 82); 82 has left child 70.
  4. DRoot 38; 14 (children 8, 18); 18 has right child 20; 20 has right child 23; 56 (children 45, 82); 82 has left child 70.
Show answerHide answer

Correct answer: (B) Root 38; 14 (children 8, 20); 20 has children 18 and 23; 56 (children 45, 82); 82 has left child 70.

Explanation

20 goes to the right of 18, making 23 unbalanced (left height 2, right 0) with a left-right pattern. An LR double rotation makes 20 the subtree root with 18 and 23 as children, as in option B.

Q94DSSSB TGT Computer Science (Technical), 1 Aug 2021, Shift 1
Preorder traversal of binary search tree is 38, 14, 8, 23, 18, 20, 56, 45, 82, 70. What is the postorder traversal of binary search tree?
  1. A23, 20, 18, 14, 8, 38, 45, 56, 70, 82
  2. B8, 18, 20, 23, 14, 45, 70, 82, 56, 38
  3. C8, 20, 18, 23, 14, 45, 70, 82, 56, 38
  4. D82, 70, 56, 45, 38, 23, 20, 18, 14, 8
Show answerHide answer

Correct answer: (C) 8, 20, 18, 23, 14, 45, 70, 82, 56, 38

Explanation

The BST is 38 with left subtree 14 (8, and 23 with left child 18 whose right child is 20) and right subtree 56 (45, and 82 with left child 70). Postorder: 8, 20, 18, 23, 14, 45, 70, 82, 56, 38.

Q95DSSSB TGT Computer Science (Technical), 13 Sep 2025, Shift 3 (5:00 PM)
Which declaration is valid for a 2D array in C?
  1. Aint arr[2][2] = {1,2,3,4};
  2. Bint arr[2,2] = {{1,2}, {3,4}};
  3. Cint arr[][] = {{1,2}, {3,4}};
  4. Dint arr[][] = {1,2,3,4};
Show answerHide answer

Correct answer: (A) int arr[2][2] = {1,2,3,4};

Explanation

A 2D array can be initialised with a flat list when both sizes are given: {1,2,3,4} fills row by row. [2,2] is not C syntax, and only the first dimension may be left empty.

Q96DSSSB TGT Computer Science (Technical), 13 Sep 2025, Shift 3 (5:00 PM)
Given a 3-dimensional array C[3][4][5] stored in row-major order, with each element occupying 1 byte, and the base address 3000, what is the address of C[2][3][4]?
  1. A3057
  2. B3059
  3. C3124
  4. D3171
Show answerHide answer

Correct answer: (B) 3059

Explanation

Offset = i × (4 × 5) + j × 5 + k = 2 × 20 + 3 × 5 + 4 = 59, so the address is 3000 + 59 = 3059.

Q97DSSSB TGT Computer Science (Technical), 13 Sep 2025, Shift 3 (5:00 PM)
What is required to write a recursive function?
  1. AOnly a recursive call
  2. BA loop and a return statement
  3. CA pointer variable
  4. DA base condition and a recursive call
Show answerHide answer

Correct answer: (D) A base condition and a recursive call

Explanation

A recursive function needs a base condition to stop and a recursive call that moves toward that base case. Without a base case the recursion never ends.

Q98DSSSB TGT Computer Science (Technical), 13 Sep 2025, Shift 3 (5:00 PM)
Suppose there are n elements in an array A[ ]. If we want to insert a new element at position i in array A[ ], 1 ≤ i ≤ n, causing elements numbered i, i+1, …, n to become numbered:
  1. Ai−1, i, i+1, i+2, i+3, …, n+1
  2. Bi+1, i+2, i+3, …, n+1
  3. Ci−1, i+1, i+2, i+3, …, n+1
  4. Di+2, i+3, …, n+1
Show answerHide answer

Correct answer: (B) i+1, i+2, i+3, …, n+1

Explanation

To insert at position i, elements i to n each move one place to the right, so they become i+1, i+2, ..., n+1.

Q99DSSSB TGT Computer Science (Technical), 13 Sep 2025, Shift 3 (5:00 PM)
If the recursive approach of linear search is used to search a key in a linked list of n elements, then what are the time and space complexity to search an element in a linked list?
  1. ATime Complexity = O(n), Space Complexity = O(1)
  2. BTime Complexity = O(1), Space Complexity = O(1)
  3. CTime Complexity = O(1), Space Complexity = O(n)
  4. DTime Complexity = O(n), Space Complexity = O(n)
Show answerHide answer

Correct answer: (D) Time Complexity = O(n), Space Complexity = O(n)

Explanation

Recursive search makes up to n calls, so the time is O(n). Each pending call uses a stack frame, so the space is also O(n).

Q100DSSSB TGT Computer Science (Technical), 13 Sep 2025, Shift 3 (5:00 PM)
In a 2D array, how are elements stored in memory?
  1. AIn separate blocks for each row
  2. BIn separate blocks for each column
  3. CContiguously in a single block
  4. DNot stored in memory
Show answerHide answer

Correct answer: (C) Contiguously in a single block

Explanation

C stores 2D arrays contiguously in one block, row after row (row-major order).

How to use these DSSSB TGT / PGT Computer Science questions

Every question here was asked in a real DSSSB TGT / PGT 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 DSSSB TGT / PGT papers as timed tests to check your speed under exam conditions.

More DSSSB TGT / PGT subjects