BPSC TRE · Computer Science

Data Structures Previous Year Questions

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.

  • 44 questions
  • Official answer key
  • Free

Other Computer Science topics

Q1BPSC TRE 2.0 (2023) Computer Class 9-10
What is the difference between delete and delete[ ] in C++?
  1. ADelete is syntactically correct but delete[ ] is wrong and hence will give an error if used in any case
  2. BDelete is used to delete normal objects whereas delete[ ] is used to delete pointer objects
  3. CDelete is used to delete single object whereas delete[ ] is used to delete multiple (array/pointer of) objects
  4. DMore than one of the above
  5. ENone of the above
Show answerHide answer

Correct answer: (C) Delete is used to delete single object whereas delete[ ] is used to delete multiple (array/pointer of) objects

Explanation

delete frees a single object, while delete[] frees an array of objects (and calls each destructor).

Q2BPSC TRE 2.0 (2023) Computer Class 9-10
Which of the following gives the nth element of the Array?
  1. Aarray[n];
  2. Barray[n–1];
  3. Carray[n+1];
  4. DMore than one of the above
  5. ENone of the above
Show answerHide answer

Correct answer: (B) array[n–1];

Explanation

Array indices start at 0, so the nth element is array[n-1].

Q3BPSC TRE 2.0 (2023) Computer Class 9-10
How many types of the array are there in the C++ programming language?
  1. AThere are three types of arrays
  2. BThere are four types of arrays
  3. CThere are two types of arrays
  4. DMore than one of the above
  5. ENone of the above
Show answerHide answer

Correct answer: (C) There are two types of arrays

Explanation

C++ arrays are classified as one-dimensional and multi-dimensional, i.e. two types, as the official key accepts.

Q4BPSC TRE 2.0 (2023) Computer Class 9-10
In C++, for what purpose the "rank()" is used?
  1. AIt returns the size of each dimension
  2. BIt returns the maximum number of elements that can be stored in the array
  3. CIt returns the dimension of the specified array
  4. DMore than one of the above
  5. ENone of the above
Show answerHide answer

Correct answer: (C) It returns the dimension of the specified array

Explanation

rank() reports the number of dimensions of an array type.

Q5BPSC TRE 2.0 (2023) Computer Class 9-10
Which one of the following is the correct definition of the "is_array();" function in C++?
  1. AIt checks that the specified variable is of the array or not
  2. BIt checks that the specified array is of single dimension or not
  3. CIt checks that the array specified is of multi-dimension or not
  4. DMore than one of the above
  5. ENone of the above
Show answerHide answer

Correct answer: (A) It checks that the specified variable is of the array or not

Explanation

is_array checks whether the given type or variable is an array.

Q6BPSC TRE 2.0 (2023) Computer Class 9-10
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.
  1. AOnly I
  2. BBoth I and II
  3. CBoth II and III
  4. DMore than one of the above
  5. 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.

Q7BPSC TRE 2.0 (2023) Computer Class 9-10
Which one of the following is not the application of the stack data structure?
  1. AAsynchronous data transfer
  2. BString reversal
  3. CBacktracking
  4. DMore than one of the above
  5. ENone of the above
Show answerHide answer

Correct answer: (A) Asynchronous data transfer

Explanation

Stacks are used for string reversal and backtracking; asynchronous data transfer is handled with queues (buffers), so it is not a stack application.

Q8BPSC TRE 2.0 (2023) Computer Class 9-10
Which data structure is required to convert the infix to prefix notation?
  1. AQueue
  2. BStack
  3. CLinked list
  4. DMore than one of the above
  5. ENone of the above
Show answerHide answer

Correct answer: (B) Stack

Explanation

The conversion holds operators on a stack while scanning the expression, so a stack is needed.

Q9BPSC TRE 2.0 (2023) Computer Class 9-10
The necessary condition to be checked before deletion from the queue is
  1. Afront value
  2. Bunderflow
  3. Coverflow
  4. DMore than one of the above
  5. ENone of the above
Show answerHide answer

Correct answer: (B) underflow

Explanation

Before dequeuing, one must check that the queue is not empty, i.e. underflow.

Q10BPSC TRE 2.0 (2023) Computer Class 9-10
Which one of the following is not the application of the queue data structure?
  1. AData is transferred asynchronously
  2. BResource is shared between various systems
  3. CBalancing of symbols
  4. DMore than one of the above
  5. ENone of the above
Show answerHide answer

Correct answer: (C) Balancing of symbols

Explanation

Balancing of symbols (parentheses) is done with a stack, not a queue.

Q11BPSC TRE 2.0 (2023) Computer Class 9-10
Which one of the following techniques is not used in the binary tree?
  1. APreorder traversal
  2. BInorder traversal
  3. CPostorder traversal
  4. DMore than one of the above
  5. ENone of the above
Show answerHide answer

Correct answer: (E) None of the above

Explanation

Preorder, inorder and postorder are all binary-tree traversals, so none of A-C is the odd one out.

Q12BPSC TRE 2.0 (2023) Computer Class 9-10
How can we describe an array in the best possible way?
  1. AArrays are immutable
  2. BContainer that stores the elements of similar types
  3. CThe array is not a data structure
  4. DMore than one of the above
  5. ENone of the above
Show answerHide answer

Correct answer: (B) Container that stores the elements of similar types

Explanation

An array is a container that stores elements of the same type.

Q13BPSC TRE 2.0 (2023) Computer Class 9-10
What is another name for the circular queue among the following options?
  1. ARectangle buffer
  2. BSquare buffer
  3. CRing buffer
  4. DMore than one of the above
  5. ENone of the above
Show answerHide answer

Correct answer: (C) Ring buffer

Explanation

A circular queue is also called a ring buffer.

Q14BPSC TRE 2.0 (2023) Computer Class 9-10
Which of the following determines the need for the circular queue?
  1. AAccess the queue using priority
  2. BAvoid wastage of memory
  3. CFollow the FIFO principle
  4. DMore than one of the above
  5. ENone of the above
Show answerHide answer

Correct answer: (B) Avoid wastage of memory

Explanation

A circular queue reuses the freed slots at the front, which avoids wasting memory.

Q15BPSC TRE 2.0 (2023) Computer Class 9-10
Which data structure is the best for implementing a priority queue?
  1. ALinked list
  2. BArray
  3. CBinary heap
  4. DMore than one of the above
  5. ENone of the above
Show answerHide answer

Correct answer: (C) Binary heap

Explanation

A binary heap gives O(log n) insertion and removal of the highest-priority item, better than a list or array.

Q16BPSC TRE 2.0 (2023) Computer Class 9-10
Which of the following data structures finds its use in recursion?
  1. AStack
  2. BLinked list
  3. CArray
  4. DMore than one of the above
  5. ENone of the above
Show answerHide answer

Correct answer: (A) Stack

Explanation

Recursive calls are kept in the call stack, so the stack is used.

Q17BPSC TRE 2.0 (2023) Computer Class 9-10
Which of the following satisfies the property of the red-black tree?
  1. ABlack, if the new node is a root node
  2. BRed, if the new node is not a root node
  3. CBlack, if the new node is not a root node
  4. DMore than one of the above
  5. ENone of the above
Show answerHide answer

Correct answer: (D) More than one of the above

Explanation

In a red-black tree the root is black and a newly inserted non-root node is coloured red, so both A and B hold (more than one).

Q18BPSC TRE 2.0 (2023) Computer Class 9-10
In the deque implementation, using singly linked list, what would be the time complexity of deleting an element from the rear end?
  1. AO(1)
  2. BO(N log N)
  3. CO(N)
  4. DMore than one of the above
  5. ENone of the above
Show answerHide answer

Correct answer: (C) O(N)

Explanation

In a singly linked list the node before the tail must be found by traversing the whole list, so deleting from the rear takes O(N).

Q19BPSC TRE 2.0 (2023) Computer Class 9-10
Which one of the following is the overflow condition if linear queue is implemented using an array with a size MAX_SIZE?
  1. Arear = MAX_SIZE–1
  2. Brear = MAX_SIZE
  3. Crear = front+1
  4. DMore than one of the above
  5. 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.

Q20BPSC TRE 2.0 (2023) Computer Class 9-10
Which of the following is a divide-and-conquer algorithm?
  1. AMerge sort
  2. BHeap sort
  3. CBubble sort
  4. DMore than one of the above
  5. 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?
  1. AProgrammable Logic Application
  2. BProgrammable Logic Array
  3. CProgrammable Logic Architecture
  4. DMore than one of the above
  5. 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?
  1. AStack
  2. BQueue
  3. CArray
  4. DMore than one of the above
  5. 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?
  1. ALeft subtree
  2. BRight subtree
  3. CBoth subtrees
  4. DMore than one of the above
  5. 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
  1. A2
  2. B1
  3. C0
  4. DMore than one of the above
  5. 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 _______.
  1. A2 deletions and 3 additions
  2. B3 deletions and 3 additions
  3. C4 deletions and 4 additions
  4. DMore than one of the above
  5. 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?
  1. A20, 19, 18, 16, 15, 12, 11,10
  2. B11, 12, 10, 16,19,18,20,15
  3. C19, 16, 18,20,11,12,10,15
  4. DMore than one of the above
  5. 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?
  1. AN
  2. BN − 1
  3. CN(N − 1)/2
  4. DMore than one of the above
  5. 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?
  1. AGreedy
  2. BDivide and Conquer
  3. CDynamic Programming
  4. DMore than one of the above
  5. 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?
  1. ADecision Tree
  2. BK-means Clustering
  3. CReinforcement Learning
  4. DMore than one of the above
  5. 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++?
  1. Aarray{10};
  2. Bint array;
  3. Cint array[10];
  4. DMore than one of the above
  5. 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?
  1. AQueue
  2. BStack
  3. CBinary tree
  4. DMore than one of the above
  5. 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?
  1. ALinear queue
  2. BCircular queue
  3. CDouble-ended queue
  4. DMore than one of the above
  5. 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
  1. Aoverflow
  2. Bunderflow
  3. Crear value
  4. DMore than one of the above
  5. 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
  1. Aqueue
  2. Bcircular queue
  3. Cdeque
  4. DMore than one of the above
  5. 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?
  1. ARandomized traversal
  2. BPreorder traversal
  3. CPostorder traversal
  4. DMore than one of the above
  5. 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?
  1. AWe can traverse in both the directions.
  2. BIt requires extra space.
  3. CImplementation of doubly linked list is easier than the singly linked list.
  4. DMore than one of the above
  5. 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?
  1. AThe value of the left child should be less than the root node.
  2. BThe value of the right child should be greater than the root node.
  3. CThe left and right subtrees should also be a binary search tree.
  4. DMore than one of the above
  5. 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
  1. Aint **fun(float **, char **)
  2. Bint *fun(float *, char *)
  3. Cint **fun(float *, char **)
  4. DMore than one of the above
  5. 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++?
  1. AIt checks that the specified variable is of the array or not
  2. BIt checks that the specified array is of single dimension or not
  3. CIt checks that the specified array is of multi-dimension or not
  4. DMore than one of the above
  5. 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?
  1. AStack
  2. BQueue
  3. CTree
  4. DMore than one of the above
  5. 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
  1. Astack
  2. Bqueue
  3. Clinked list
  4. DMore than one of the above
  5. 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
  1. AFIFO
  2. BLIFO
  3. CLILO
  4. DMore than one of the above
  5. 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
  1. AFIFO
  2. BLIFO
  3. CLILO
  4. DMore than one of the above
  5. 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?
  1. AArray
  2. BData
  3. CData and functions
  4. DMore than one of the above
  5. 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.

More BPSC TRE subjects