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 NOT the application of Divide and Conquer?
ABinary Search
BAll Pairs Shortest Path Problem
CQuick Sort
DStrassen's Matrix Multiplication
Show answerHide answer
Correct answer: (B) All Pairs Shortest Path Problem
Explanation
All-pairs shortest path (Floyd-Warshall) is solved by dynamic programming. Binary search, quick sort and Strassen's multiplication are divide and conquer algorithms.
Bsearch for a specific pattern from a specified file and display those lines containing the pattern
Ccut the columns fields of a specified file
Dredirect the output of one command to another command
Show answerHide answer
Correct answer: (B) search for a specific pattern from a specified file and display those lines containing the pattern
Explanation
grep (global regular expression print) searches files for a pattern and prints the matching lines. tr changes case, cut extracts columns, and a pipe redirects output.
Which of these is NOT a parameter upon which the influence of lightning is based?
ALight Source
BPosition of Observer
CRendering Algorithm
DSurface
Show answerHide answer
Correct answer: (C) Rendering Algorithm
Explanation
The effect of lighting depends on the light source, the surface's properties and the observer's position. The rendering algorithm is a technique for drawing the scene, not a lighting parameter.
An algorithm that always runs in polynomial time but possibly returns erroneous answers is called a/an ______.
Aapproximation algorithm
BMonte Carlo algorithm
CAtlantic City algorithm
DLas Vegas algorithm
Show answerHide answer
Correct answer: (B) Monte Carlo algorithm
Explanation
A Monte Carlo algorithm has a fixed (polynomial) running time but may give a wrong answer with small probability. A Las Vegas algorithm is always correct, but its running time varies.
What is the best case and worst-case complexity of selection sort?
AO(n log n)
BO(n)
CO(n²)
DO(log n)
Show answerHide answer
Correct answer: (C) O(n²)
Explanation
Selection sort always scans the whole unsorted part to find the minimum, making about n(n−1)/2 comparisons whatever the input order. So both its best and worst cases are O(n²).
What is the average case time complexity of merge sort?
AO(n log n)
BO(n)
CO(1)
DO(n² log n)
Show answerHide answer
Correct answer: (A) O(n log n)
Explanation
Merge sort always halves the array (log n levels) and does O(n) merging work at each level. So its best, average and worst case are all O(n log n).
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.