44 Data Structures (Computer Science) questions asked in BPSC TRE previous year papers, each with the correct answer and explanation. Read them free on UTpaper, or attempt the full papers as timed online tests.
Which of the following statements is true about the new and malloc?
I. The 'new' is a type of operator while 'malloc' is a kind of function.
II. The 'new' invokes a constructor, whereas 'malloc' does not invoke the constructor.
III. The 'malloc' returns void pointer and also needed to typecast whereas 'new' returns required pointer.
AOnly I
BBoth I and II
CBoth II and III
DMore than one of the above
ENone of the above
Show answerHide answer
Correct answer: (D) More than one of the above
Explanation
All three statements are true (new is an operator that calls constructors; malloc is a function returning void*), so more than one option, i.e. (D), is correct.
Which one of the following is the overflow condition if linear queue is implemented using an array with a size MAX_SIZE?
Arear = MAX_SIZE–1
Brear = MAX_SIZE
Crear = front+1
DMore than one of the above
ENone of the above
Show answerHide answer
Correct answer: (D) More than one of the above
Explanation
Depending on whether rear points at the last used slot or one past it, both rear = MAX_SIZE-1 and rear = MAX_SIZE are accepted overflow conditions, so more than one is correct.
Which of the following is a divide-and-conquer algorithm?
AMerge sort
BHeap sort
CBubble sort
DMore than one of the above
ENone of the above
Show answerHide answer
Correct answer: (A) Merge sort
Explanation
Merge sort splits the list in halves, sorts them and merges, which is divide and conquer.
Q21BPSC TRE 3.0 (2024) Computer Science Class 11-12
What is a PLA?
AProgrammable Logic Application
BProgrammable Logic Array
CProgrammable Logic Architecture
DMore than one of the above
ENone of the above
Show answerHide answer
Correct answer: (B) Programmable Logic Array
Explanation
PLA stands for Programmable Logic Array, a device with a programmable AND array followed by a programmable OR array.
Q22BPSC TRE 3.0 (2024) Computer Science Class 11-12
Which of the following data structures stores elements in a non-linear relationship?
AStack
BQueue
CArray
DMore than one of the above
ENone of the above
Show answerHide answer
Correct answer: (E) None of the above
Explanation
Stack, queue and array are all linear data structures. Trees and graphs are non-linear, and neither is listed.
Q23BPSC TRE 3.0 (2024) Computer Science Class 11-12
In a binary search tree, which subtree of a node contains elements that are greater than the node’s value?
ALeft subtree
BRight subtree
CBoth subtrees
DMore than one of the above
ENone of the above
Show answerHide answer
Correct answer: (B) Right subtree
Explanation
In a BST, keys smaller than a node go in its left subtree and larger keys in its right subtree.
Q24BPSC TRE 3.0 (2024) Computer Science Class 11-12
In a balanced binary tree, the height of two sub-trees of every node can not differ by more than
A2
B1
C0
DMore than one of the above
ENone of the above
Show answerHide answer
Correct answer: (B) 1
Explanation
In a height-balanced (AVL) binary tree, the heights of the left and right subtrees of every node differ by at most 1.
Q25BPSC TRE 3.0 (2024) Computer Science Class 11-12
A queue has configuration a, b, c, d. If you want to get the configuration d, c, b, a, you need a minimum of _______.
A2 deletions and 3 additions
B3 deletions and 3 additions
C4 deletions and 4 additions
DMore than one of the above
ENone of the above
Show answerHide answer
Correct answer: (B) 3 deletions and 3 additions
Explanation
The front element d must stay in place. Delete a, b and c (3 deletions) and add them back as c, b, a (3 additions), giving d, c, b, a.
Q26BPSC TRE 3.0 (2024) Computer Science Class 11-12
The preorder traversal of a binary search tree is 15, 10, 12, 11,20, 18, 16, 19. Which one of the following is the postorder traversal of the tree?
A20, 19, 18, 16, 15, 12, 11,10
B11, 12, 10, 16,19,18,20,15
C19, 16, 18,20,11,12,10,15
DMore than one of the above
ENone of the above
Show answerHide answer
Correct answer: (B) 11, 12, 10, 16,19,18,20,15
Explanation
Root 15. The left subtree from 10, 12, 11 is 10 with right child 12, whose left child is 11. The right subtree is 20 with left child 18, whose children are 16 and 19. Postorder: 11, 12, 10, 16, 19, 18, 20, 15.
Q27BPSC TRE 3.0 (2024) Computer Science Class 11-12
How many edges does a spanning tree of a graph with N vertices have?
AN
BN − 1
CN(N − 1)/2
DMore than one of the above
ENone of the above
Show answerHide answer
Correct answer: (B) N − 1
Explanation
A spanning tree connects all N vertices with no cycle, so it has exactly N − 1 edges.
Q28BPSC TRE 3.0 (2024) Computer Science Class 11-12
Which of the following is NOT a graph traversal algorithm?
AGreedy
BDivide and Conquer
CDynamic Programming
DMore than one of the above
ENone of the above
Show answerHide answer
Correct answer: (D) More than one of the above
Explanation
Greedy, Divide and Conquer and Dynamic Programming are algorithm design paradigms, not graph traversal algorithms (BFS and DFS are), so more than one option is correct.
Q29BPSC TRE 3.0 (2024) Computer Science Class 11-12
Which of the following is a supervised learning algorithm?
ADecision Tree
BK-means Clustering
CReinforcement Learning
DMore than one of the above
ENone of the above
Show answerHide answer
Correct answer: (A) Decision Tree
Explanation
A decision tree learns from labelled training data, so it is supervised learning. K-means is unsupervised, and reinforcement learning is a separate paradigm.
Q30BPSC TRE 1.0 (2023) Computer Science Class 11-12
Which of the following correctly declares an array in C++?
Aarray{10};
Bint array;
Cint array[10];
DMore than one of the above
ENone of the above
Show answerHide answer
Correct answer: (C) int array[10];
Explanation
int array[10]; declares an array of 10 integers by giving the type, the name and the size in square brackets.
Q31BPSC TRE 1.0 (2023) Computer Science Class 11-12
Which data structure is mainly used for implementing the recursive algorithm?
AQueue
BStack
CBinary tree
DMore than one of the above
ENone of the above
Show answerHide answer
Correct answer: (B) Stack
Explanation
Recursion uses a stack. Each call pushes an activation record, and the record is popped when the call returns.
Q32BPSC TRE 1.0 (2023) Computer Science Class 11-12
Which one of the following is not the type of queue?
ALinear queue
BCircular queue
CDouble-ended queue
DMore than one of the above
ENone of the above
Show answerHide answer
Correct answer: (E) None of the above
Explanation
Linear, circular and double-ended queues (deques) are all real types of queue, so none of the options is wrong.
Q33BPSC TRE 1.0 (2023) Computer Science Class 11-12
The necessary condition to be checked before deletion from the queue is
Aoverflow
Bunderflow
Crear value
DMore than one of the above
ENone of the above
Show answerHide answer
Correct answer: (B) underflow
Explanation
Before deleting, check for underflow (an empty queue). Overflow is checked before inserting.
Q34BPSC TRE 1.0 (2023) Computer Science Class 11-12
A linear data structure in which insertion and deletion operations can be performed from both the ends is
Aqueue
Bcircular queue
Cdeque
DMore than one of the above
ENone of the above
Show answerHide answer
Correct answer: (C) deque
Explanation
A deque (double-ended queue) allows insertion and deletion at both the front and the rear.
Q35BPSC TRE 1.0 (2023) Computer Science Class 11-12
Which one of the following techniques is not used in the binary tree?
ARandomized traversal
BPreorder traversal
CPostorder traversal
DMore than one of the above
ENone of the above
Show answerHide answer
Correct answer: (A) Randomized traversal
Explanation
Binary trees are traversed in preorder, inorder, postorder or level order. Randomized traversal is not a standard binary tree technique.
Q36BPSC TRE 1.0 (2023) Computer Science Class 11-12
Which of the following statements is not true about the doubly linked list?
AWe can traverse in both the directions.
BIt requires extra space.
CImplementation of doubly linked list is easier than the singly linked list.
DMore than one of the above
ENone of the above
Show answerHide answer
Correct answer: (C) Implementation of doubly linked list is easier than the singly linked list.
Explanation
A doubly linked list allows traversal in both directions but needs extra space for the previous pointer. It is harder to implement than a singly linked list, not easier.
Q37BPSC TRE 1.0 (2023) Computer Science Class 11-12
Which of the following options is not true about the binary search tree?
AThe value of the left child should be less than the root node.
BThe value of the right child should be greater than the root node.
CThe left and right subtrees should also be a binary search tree.
DMore than one of the above
ENone of the above
Show answerHide answer
Correct answer: (E) None of the above
Explanation
All three statements are true properties of a binary search tree, so none of them is false.
Q38BPSC TRE 1.0 (2023) Computer Science Class 11-12
The correct statement for a function that takes pointer to a float, a pointer to a pointer to a char and returns a pointer to a pointer to an integer is
Aint **fun(float **, char **)
Bint *fun(float *, char *)
Cint **fun(float *, char **)
DMore than one of the above
ENone of the above
Show answerHide answer
Correct answer: (C) int **fun(float *, char **)
Explanation
The function takes a float* and a char** and returns an int**, so the correct declaration is int **fun(float *, char **).
Q39BPSC TRE 1.0 (2023) Computer Science Class 11-12
Which one of the following is the correct definition of “is_array( );” function in C++?
AIt checks that the specified variable is of the array or not
BIt checks that the specified array is of single dimension or not
CIt checks that the specified array is of multi-dimension or not
DMore than one of the above
ENone of the above
Show answerHide answer
Correct answer: (A) It checks that the specified variable is of the array or not
Explanation
std::is_array<T> (in <type_traits>) checks whether a given type is an array type, returning true or false.
Q40BPSC TRE 2.0 (2023) Computer Science Class 11-12
Which data structure is used to convert infix notation to postfix notation?
AStack
BQueue
CTree
DMore than one of the above
ENone of the above
Show answerHide answer
Correct answer: (A) Stack
Explanation
Infix-to-postfix conversion pushes operators and parentheses onto a stack. It pops them according to precedence and associativity.
Q41BPSC TRE 2.0 (2023) Computer Science Class 11-12
The data structure in which data are added at the rear and deleted from front is called
Astack
Bqueue
Clinked list
DMore than one of the above
ENone of the above
Show answerHide answer
Correct answer: (B) queue
Explanation
A queue is FIFO (first in, first out). Elements are added at the rear and removed from the front.
Q42BPSC TRE 2.0 (2023) Computer Science Class 11-12
Queue data structure uses
AFIFO
BLIFO
CLILO
DMore than one of the above
ENone of the above
Show answerHide answer
Correct answer: (A) FIFO
Explanation
A queue works on FIFO (first in, first out), so the element inserted first is removed first.
Q43BPSC TRE 2.0 (2023) Computer Science Class 11-12
Stack data structure uses
AFIFO
BLIFO
CLILO
DMore than one of the above
ENone of the above
Show answerHide answer
Correct answer: (B) LIFO
Explanation
A stack works on LIFO (last in, first out). Push and pop both happen at the top.
Q44BPSC TRE 2.0 (2023) Computer Science Class 11-12
In C++, what does a class hold?
AArray
BData
CData and functions
DMore than one of the above
ENone of the above
Show answerHide answer
Correct answer: (C) Data and functions
Explanation
A C++ class bundles data members and member functions together into one unit, which is encapsulation.
How to use these BPSC TRE Computer Science questions
Every question here was asked in a real BPSC TRE 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 BPSC TRE papers as timed tests to check your speed under exam conditions.