65 Algorithms (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.
Which of the following is the correct order of Problem Solving steps?
(A) Algorithm Development
(B) Coding
(C) Analysis of problem
(D) Testing & Debugging
A(A), (B), (C), (D)
B(C), (A), (D), (B)
C(A), (C), (B), (D)
D(C), (A), (B), (D)
Show answerHide answer
Correct answer: (D) (C), (A), (B), (D)
Explanation
First analyse the problem, then develop an algorithm, code it, and finally test and debug it: (C), (A), (B), (D).
Which of the following algorithms solves the all-pairs shortest path problem?
ADijkstra's algorithm
BFloyd's algorithm
CPrim's algorithm
DWarshall's algorithm
Show answerHide answer
Correct answer: (B) Floyd's algorithm
Explanation
Floyd's (Floyd-Warshall) algorithm finds shortest paths between every pair of vertices in O(V³). Dijkstra is single-source, Prim builds an MST, and Warshall finds transitive closure.
How many page faults occur in LRU page replacement algorithm for the given reference string, with four page frames.
7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1
A6
B8
C7
D9
Show answerHide answer
Correct answer: (C) 7
Explanation
With LRU and 4 frames: 7, 0, 1, 2 are 4 faults; 3 replaces 7; 4 replaces 1; then 1 replaces 4. All other references are hits, so there are 7 page faults.
Consider the following statements about searching algorithms and choose the correct option.
ASequential search requires the list to be ordered, while there is no such constraint for Binary search.
BBinary search has time complexity of O(log₂ n), while sequential search has time complexity of O(n). Here, n is the number of elements in the list.
CLink list is a suitable data structure for storing a list, and performing Binary search.
DThe best case in Binary search is, when the key element exists in the begining of the list.
Show answerHide answer
Correct answer: (B) Binary search has time complexity of O(log₂ n), while sequential search has time complexity of O(n). Here, n is the number of elements in the list.
Explanation
Corrected: the book's key says (c), but (b) is the true statement. Binary search needs random access, so a linked list is unsuitable for it.
The maximum number of comparisons for a particular record among 32 sorted records through Binary Search method will be :
A2
B16
C8
D5
Show answerHide answer
Correct answer: (D) 5
Explanation
Binary search halves the list at each step, and 32 = 2⁵, so it takes about log₂32 = 5 comparisons. Strictly, the worst case is ⌊log₂32⌋ + 1 = 6, but 6 is not an option, so the intended answer is 5.
The best suited hidden surface algorithm to deal with non-polygonal, non-planar surface patches is
AZ-buffer algorithm
BRay tracing algorithm
CPainter's algorithm
DScan line algorithm
Show answerHide answer
Correct answer: (A) Z-buffer algorithm
Explanation
The z-buffer method stores a depth value for every pixel, so it can handle any surface for which depth can be computed at each pixel, including non-polygonal and non-planar patches, with no sorting needed.
Two way merge sort algorithm is used to sort the following elements in ascending order.
200, 470, 150, 80, 90, 40, 400, 300, 120, 70.
What is the order of these elements after second pass of the merge sort algorithm?
Which of the following statement(s) is/are correct regarding <title> tag in HTML?
I. This tag always goes outside to the <head> tag.
II. This tag is used to indicate the title of the webpage.
III. It is also used by search engines.
AI and II
BII and III
COnly II
DI, II and III
Show answerHide answer
Correct answer: (B) II and III
Explanation
<title> must be placed inside <head>, not outside it. It sets the page title shown in the browser tab, and search engines use it.
Which of the following statement(s) is/are true regarding cryptography?
I. Cipher text is encrypted text transformed from plain text using an encryption algorithm.
II. According to Kerchoff's principle, all algorithms must be private and only the keys are secret.
AOnly I
BOnly II
CBoth I and II
DNeither I nor II
Show answerHide answer
Correct answer: (A) Only I
Explanation
Ciphertext is plaintext transformed by an encryption algorithm. Kerckhoffs's principle says the algorithm should be public and only the key secret, so II is false.
Which of the following Pre – number concept(s) can be developed in children during the pre school years?
I. Matching
II. Sorting
III. Comparing
AI and III
BI and II
COnly I
DI, II, and III
Show answerHide answer
Correct answer: (D) I, II, and III
Explanation
Matching, sorting/classifying, comparing and seriation are pre-number concepts developed in the preschool years.
Q19DSSSB TGT Computer Science (Technical), 8 Aug 2021, Shift 2
What is the worst case running time of quick sort algorithm?
Aθ(x)
Bθ(x²)
Cθ(x log₂x)
Dθ(x log₂x²)
Show answerHide answer
Correct answer: (B) θ(x²)
Explanation
Quick sort's worst case happens when the pivot is always the smallest or largest element, for example on already sorted input. Each partition then removes only one element, giving Θ(n²).
Q20DSSSB TGT Computer Science (Technical), 7 Aug 2021, Shift 3
Sort the following elements using Bubble sort in ascending order. What is the intermediate sequence of 37, 54, 21, 85, 68, 12, 9, 57 after second pass?
A21, 37, 12, 9, 54, 57, 68, 85
B37, 21, 54, 68, 12, 9, 57, 85
C21, 37, 54, 12, 9, 57, 68, 85
D21, 12, 9, 37, 54, 57, 68, 85
Show answerHide answer
Correct answer: (C) 21, 37, 54, 12, 9, 57, 68, 85
Explanation
Pass 1 moves 85 to the end: 37, 21, 54, 68, 12, 9, 57, 85. Pass 2 moves 68 to its place: 21, 37, 54, 12, 9, 57, 68, 85.
Q21DSSSB TGT Computer Science (Technical), 7 Aug 2021, Shift 3
Sort the following list using Radix sort algorithm.
329, 457, 839, 436, 720, 355, 657
What is the output of the algorithm after 2nd pass?
Q22DSSSB TGT Computer Science (Technical), 7 Aug 2021, Shift 3
Sort the following list using selection sort algorithm
H, V, A, T, L, N, K
What is the output of the algorithm after 3rd pass?
AA, V, H, T, L, N, K
BA, H, K, T, L, N, V
CA, V, T, H, L, N, K
DA, T, H, K, L, N, V
Show answerHide answer
Correct answer: (B) A, H, K, T, L, N, V
Explanation
Pass 1 swaps A with H: A, V, H, T, L, N, K. Pass 2 swaps H with V: A, H, V, T, L, N, K. Pass 3 swaps K with V: A, H, K, T, L, N, V.
Q23DSSSB TGT Computer Science (Technical), 7 Aug 2021, Shift 3
Which of the following asymptotic notation is used to provide lower boundary constraints?
AO
Bθ
CΩ
D×
Show answerHide answer
Correct answer: (C) Ω
Explanation
Big-Omega (Ω) gives an asymptotic lower bound. Big-O gives an upper bound and Theta (θ) a tight bound.
Q24DSSSB TGT Computer Science (Technical), 7 Aug 2021, Shift 3
Pictorial representation of a program is known as ________.
AFlowchart
BPseudo code
CCode
DAlgorithm
Show answerHide answer
Correct answer: (A) Flowchart
Explanation
A flowchart is a pictorial representation of a program's logic. Pseudo code and algorithms are written in text.
Q25DSSSB TGT Computer Science (Technical), 7 Aug 2021, Shift 2
What is COHESION in software design?
ACohesion is a measure of complexity of module of a software
BCohesion is a measure of functional strength of a module of a software
CCohesion is a measure of functional weakness of a module of a software
DCohesion is a measure of efficiency of a module of a software
Show answerHide answer
Correct answer: (B) Cohesion is a measure of functional strength of a module of a software
Explanation
Cohesion measures the functional strength of a module, i.e. how closely the elements inside one module work toward a single task. High cohesion is desirable.
Q26DSSSB TGT Computer Science (Technical), 7 Aug 2021, Shift 2
Match the following.
A. Longest common subsequence — i. Divide and conquer
B. Huffman code — ii. Linear programming
C. Quick sort — iii. Greedy algorithm
D. Simplex algorithm — iv. Dynamic programming
AA-iv, B-i, C-ii, D-iii
BA-iii, B-ii, C-iv, D-i
CA-iv, B-iii, C-i, D-ii
DA-iii, B-iv, C-ii, D-i
Show answerHide answer
Correct answer: (C) A-iv, B-iii, C-i, D-ii
Explanation
LCS is solved by dynamic programming, Huffman coding by a greedy algorithm, quick sort by divide and conquer, and the simplex method is for linear programming.
Q27DSSSB TGT Computer Science (Technical), 7 Aug 2021, Shift 2
Efficiency of an algorithm is measured in terms of ________.
AMemory and processor speed
BTime and space
CResponse time and completion time
DData and space
Show answerHide answer
Correct answer: (B) Time and space
Explanation
Algorithm efficiency is measured by time complexity (running time) and space complexity (memory used).
Q28DSSSB TGT Computer Science (Technical), 7 Aug 2021, Shift 2
Which of the following statement(s) is/are true about Algorithm?
I. It is step by step solution of problem
II. It is difficult to debug
III. It is not dependent on the programming language
AI and II
BII and III
CI and III
DI, II and III
Show answerHide answer
Correct answer: (C) I and III
Explanation
An algorithm is a step-by-step procedure that is independent of any programming language (I and III). It is actually easy to debug, so II is false.
Q29DSSSB TGT Computer Science (Technical), 1 Aug 2021, Shift 3
What is the maximum running time of binary search algorithm, when n = 12,000?
A12
B13
C14
D15
Show answerHide answer
Correct answer: (C) 14
Explanation
Binary search needs at most ⌊log₂n⌋ + 1 comparisons. 2¹³ = 8192 ≤ 12000 < 16384 = 2¹⁴, so ⌊log₂12000⌋ = 13 and the maximum is 14.
Q30DSSSB TGT Computer Science (Technical), 1 Aug 2021, Shift 3
What is the worst case time complexity of bubble sort?
AO(x)
BO(log₂x)
CO(x²)
DO(x log₂x)
Show answerHide answer
Correct answer: (C) O(x²)
Explanation
In the worst case (reverse-sorted input) bubble sort makes n(n−1)/2 comparisons and swaps, so it is O(x²) with x elements.
Q31DSSSB TGT Computer Science (Technical), 1 Aug 2021, Shift 3
How many interchanges will happen when the sequence of letters of "SORTED" is sorted using bubble sort?
A36
B11
C18
D6
Show answerHide answer
Correct answer: (B) 11
Explanation
Bubble sort makes one swap per inversion. In S O R T E D (order D < E < O < R < S < T), the inversions are S:4, O:2, R:2, T:2, E:1, totalling 11 interchanges.
Q32DSSSB TGT Computer Science (Technical), 1 Aug 2021, Shift 3
Which page replacement algorithm has Belady's anomaly?
AOptimal page replacement
BFIFO page replacement
CLeast recent used page replacement
DNot recently used page replacement
Show answerHide answer
Correct answer: (B) FIFO page replacement
Explanation
In FIFO, increasing the number of frames can increase page faults for some reference strings (Belady's anomaly). Optimal and LRU are stack algorithms and do not suffer from it.
Q33DSSSB TGT Computer Science (Technical), 1 Aug 2021, Shift 1
Arrange the following in ascending order of their average case complexity.
Selection-sort, Quick-sort, Linear search, Binary search
AQuick-Sort, Selection-sort, Binary search, Linear search
A sorting algorithm in which the two or more elements with equal key values appear in the
same order in sorted output as they appear in the input data set is known as a/an:
Ainternal sorting algorithm
Bexternal sorting algorithm
Cstable sorting algorithm
Dunstable sorting algorithm
Show answerHide answer
Correct answer: (C) stable sorting algorithm
Explanation
A stable sort keeps records with equal keys in their original relative order. Insertion sort and merge sort are stable.
Consider the pseudocode of the function given below.
abc(int n)
{
int i, j, k = 0;
for (i = n/2; i <= n; i++)
for (j = 2; j <= n; j = j * 2)
k = k + n/2;
return k;
}
what will the time complexity of the function abc() be?
AO(n²)
BO(n)
CO(n log n)
DO(log n)
Show answerHide answer
Correct answer: (C) O(n log n)
Explanation
The outer loop runs about n/2 times, and the inner loop doubles j, so it runs about log₂ n times. That gives O(n log n).
Consider the following pseudo code.
exponentiate(int x, int n)
{
int m=n; power= 1; z= x;
while(m>0)
{
while(m%2 ==0)
{ m= m/2; z= z*z ;
}
m=m-1; power = power*z;
}
return power;
}
What will the time complexity of function exponentiate() be?
AΘ(n²)
BΘ(log n)
CΘ(n log n)
DΘ(n)
Show answerHide answer
Correct answer: (B) Θ(log n)
Explanation
This is exponentiation by squaring: each inner step halves m, and each outer step subtracts 1 from an odd m, making it even. So m reaches 0 in about 2 log₂ n steps, giving Θ(log n).
Which of the following options is INCORRECT about randomised algorithms?
ARandomised algorithms that always produce the same(correct)output for the same
input is known as Las Vegas Algorithms.
BRandomised algorithms whose output differs from run to run for the same inputs is
known as Monte Carlo Algorithms.
CThe execution time of Las Vegas Algorithm does not depend on the output of the
randomiser.
DA randomised algorithm is an algorithm in which some of the decisions made in the
algorithm depend on the output of the randomiser.
Show answerHide answer
Correct answer: (C) The execution time of Las Vegas Algorithm does not depend on the output of the
randomiser.
Explanation
Statement C is incorrect: a Las Vegas algorithm always gives the correct answer, but its running time depends on the random choices. A Monte Carlo algorithm has bounded time, but its output may vary or be wrong.
Which of the following is NOT a property of any algorithms?
ASome of the algorithms may not produce even single quantity as an output.
BEvery algorithm must produce at least one quantity as an output.
CEach instruction of the algorithm must be clear and unambiguous.
DFor all cases, the algorithm must terminate after finite number of instructions.
Show answerHide answer
Correct answer: (A) Some of the algorithms may not produce even single quantity as an output.
Explanation
Every algorithm must produce at least one output, have clear and unambiguous steps and terminate after finitely many steps. So "may not produce any output" is not a property of an algorithm.
How does the Best Fit algorithm impact system performance?
AIt improves system performance by reducing memory wastage.
BIt may reduce system performance due to increased search time for free blocks.
CIt always improves system performance.
DIt improves system performance by reducing external fragmentation.
Show answerHide answer
Correct answer: (B) It may reduce system performance due to increased search time for free blocks.
Explanation
Best Fit must search the whole free list (or keep it sorted) to find the smallest hole that fits, so allocation takes longer. It also leaves many tiny unusable holes, so it does not guarantee less wastage or better performance.
Which of the following asymptotic notation gives asymptotically tight upper bound as well as
asymptotically tight lower bound?
AOmega (Ω)
BBig Oh (O)
CTheta (Θ)
DSmall Omega (ω)
Show answerHide answer
Correct answer: (C) Theta (Θ)
Explanation
Theta notation bounds a function both from above and below by constant multiples of g(n), giving an asymptotically tight bound. Big O gives only an upper bound and Omega only a lower bound.
Which of the following cases DOES NOT exist when one computes the time complexity of an
algorithm?
AAverage case
BWorst case
CTest Case
DBest Case
Show answerHide answer
Correct answer: (C) Test Case
Explanation
Time complexity is analysed for the best, average and worst cases. A "test case" is an input used in software testing, not a case of complexity analysis.
In Cohen Sutherland Line clipping algorithm, if a line ______ the clipping window, then the line is required to clip as it is considered partially visible.
Afalls inside
Bfalls outside
Cintersects
Dfalls on
Show answerHide answer
Correct answer: (C) intersects
Explanation
In Cohen-Sutherland clipping, a line that crosses (intersects) the window boundary is partially visible and must be clipped. Lines fully inside are accepted and lines fully outside are rejected.
Which of the following is a Microsoft ActiveX control that will sort through a data file, extrapolate the necessary information and produce that information in specified areas on the web page?
ADialog Bars
BTabular Data Control
CControl Bars
DDialog Boxes
Show answerHide answer
Correct answer: (B) Tabular Data Control
Explanation
The Tabular Data Control (TDC) is a Microsoft ActiveX control that reads a delimited data file and shows the data in chosen areas of a web page.
Which of the following refers to the kind of problems that require the identification of the best solution to a search problem from a given set of solutions?
ATraining
BOptimisation
CCounting
DDecision
Show answerHide answer
Correct answer: (B) Optimisation
Explanation
Optimisation problems ask for the best solution from a set of feasible solutions. Decision problems only need a yes/no answer.
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.