25 Algorithms (Computer Science) questions asked in UGC NET previous year papers, each with the correct answer and explanation. Read them free on UTpaper, or attempt the full papers as timed online tests.
Q1UGC NET Computer Science, June 2014 (Paper II & III, Selected Questions)
An algorithm is made up of 2 modules M₁ and M₂. If time complexity of modules M₁ and M₂ are h(n) and g(n) respectively, the time complexity of the algorithm is
Amin (h(n), g(n))
Bmax (h(n), g(n))
Ch(n) + g(n)
Dh(n) ∗ g(n)
Show answerHide answer
Correct answer: (B) max (h(n), g(n))
Explanation
When the two modules run one after the other, the total time is h(n) + g(n), which is O(max(h(n), g(n))) because the larger term dominates and lower-order terms are ignored. Hence the answer is (b).
Q2UGC NET Computer Science, June 2014 (Paper II & III, Selected Questions)
Big-O estimates for the factorial function and the logarithm of the factorial function i.e. n! and log n! is given by
AO(n!) and O(n log n)
BO(nⁿ) and O(n log n)
CO(n!) and O(log n!)
DO(nⁿ) and O(log n!)
Show answerHide answer
Correct answer: (B) O(nⁿ) and O(n log n)
Explanation
N! < nⁿ for all n ≥ 1, so n! is O(nⁿ). Using Stirling's approximation, log(n!) ≈ n log n − n + O(log n), so log n! is O(n log n). Therefore, the correct answer is (b) O(nⁿ) and O(n log n).
Q3UGC NET Computer Science, June 2014 (Paper II & III, Selected Questions)
In function point analysis, the number of complexity adjustment factors is
A10
B12
C14
D20
Show answerHide answer
Correct answer: (C) 14
Explanation
There are 14 relative complexity adjustment factor are (1) Requirement for reliable backup and recovery (2) Require for data communication (3) Extent of distributing processing (4) Performance requirement (5) Expected operational environment (6) Extent of online data entries (7) Extent of multi-operation online data input. (8) Extent of online updating of master files. (9) Extent of complex inputs, outputs. (10) Extent of complex data processing. (11) Extent of currently developed code can be designed for reuse. (12) Extent of conversion and installation in the design. (13) Extent of multiple installation in an organization. (14) Extent of change and focus on ease of use.
Q4UGC NET Computer Science, June 2014 (Paper II & III, Selected Questions)
Consider the fractional knapsack instance n = 4, (p₁, p₂, p₃, p₄) = (10, 10, 12, 18), (w₁, w₂, w₃, w₄) = (2, 4, 6, 9) and M = 15. The maximum profit is given by (Assume p and w denotes profit and weight of objects respectively)
A40
B38
C32
D30
Show answerHide answer
Correct answer: (B) 38
Explanation
P₁/w₁ = 5, p₂/w₂ = 2.5, p₃/w₃ = 2, p₄/w₄ = 2. Select object 1 (profit 10), then object 2 (profit 10). Objects 3 and 4 have the same ratio, but object 4 gives more profit and fits exactly: total weight = 2 + 4 + 9 = 15. Maximum profit = 10 + 10 + 18 = 38. So the answer is (b).
Q5UGC NET Computer Science, December 2014 (Paper II & III, Selected Questions)
You have to sort a list L. consisting of a sorted list followed by a few 'random' elements. Which of the following sorting method would be most suitable for such a task?
ABubble sort
BSelection sort
CQuick sort
DInsertion sort
Show answerHide answer
Correct answer: (D) Insertion sort
Explanation
For a sorted list followed by a few random elements: bubble sort and selection sort take O(n²) time, quick sort degrades to its O(n²) worst case on nearly sorted input, while insertion sort takes close to O(n) time. Hence insertion sort is most suitable.
Q6UGC NET Computer Science, December 2014 (Paper II & III, Selected Questions)
How many distinct stages are there in DES algorithm, which is parameterized by a 56-bit key?
A16
B17
C18
D19
Show answerHide answer
Correct answer: (D) 19
Explanation
The DES algorithm works with a 64-bit block size, employs 16 processing rounds, and is driven by a 56-bit key (with 8 additional parity bits), making up a total of 19 distinct stages.
Q7UGC NET Computer Science, December 2014 (Paper II & III, Selected Questions)
Which of the following algorithms is not a broadcast routing algorithm?
AFlooding
BMulti destination routing
CReverse path forwarding
DAll of the above
Show answerHide answer
Correct answer: (D) All of the above
Explanation
Note: Flooding, multi-destination routing and reverse path forwarding are all broadcast routing algorithms, so none of them is 'not' a broadcast routing algorithm; the book keys (d). Flooding generates too many packets and consumes too much bandwidth but can be used for broadcasting. In multi-destination routing each packet contains a list of destinations, and reverse path forwarding approximates spanning-tree broadcast even when routers know nothing about the spanning tree.
Q8UGC NET Computer Science, December 2014 (Paper II & III, Selected Questions)
Dijkstra algorithm, which solves the single-source shortest-paths problem, is a ................, and the Floyd-Warshall algorithm, which finds shortest paths between all pairs of vertices, is a............
Dijkstra's algorithm for the single-source shortest-paths problem is a greedy algorithm, and the Floyd-Warshall algorithm for all-pairs shortest paths is a dynamic programming algorithm.
Q9UGC NET Computer Science, June 2015 (Paper II & III, Selected Questions)
To determine the efficiency of an algorithm the time factor is measured by:
ACounting micro seconds
BCounting number of key operations
CCounting number of statements
DCounting kilobytes of algorithm
Show answerHide answer
Correct answer: (B) Counting number of key operations
Explanation
The complexity is commonly estimated by counting the number of elementary operations performed by the algorithm, where an elementary operation takes a fixed amount of time to perform. Thus the amount of time taken and the number of elementary operations performed by the algorithm differ by at most a constant factor.
Q10UGC NET Computer Science, June 2015 (Paper II & III, Selected Questions)
Which of the following algorithms sort n integers, having the range 0 to (n² – 1), in ascending order in O(n) time?
ASelection sort
BBubble sort
CRadix sort
DInsertion sort
Show answerHide answer
Correct answer: (C) Radix sort
Explanation
Radix sort because it sorts in integers in range 0 … (n² – 1) in O(n) time using base-n representation.
Q11UGC NET Computer Science, June 2015 (Paper II & III, Selected Questions)
A disk drive has 100 cylinders, numbered 0 to 99. Disk requests come to the disk driver for cylinders 12, 26, 24, 4, 42, 8 and 50 in that order. The driver is currently serving a request at cylinder 24. A seek takes 6 msec per cylinder moved. How much seek time is needed for shortest seek time first (SSTF) algorithm?
Q12UGC NET Computer Science, June 2015 (Paper II & III, Selected Questions)
Match the following :
List - I
(A) Size-oriented metrics
(B) Function-oriented metrics
(C) Extended function point metrics
(D) Function point
List - II
(i) Uses number of external interfaces as one of the measurement parameter
(ii) Originally designed to be applied to business information system
(iii) Derived by normalizing quality and/or productivity measures by considering the size of the software
(iv) uses algorithm characteristics as one of the measurement parameter
Codes : A B C D
A(iii) (iv) (i) (ii)
B(ii) (i) (iv) (iii)
C(iv) (ii) (iii) (i)
D(iii) (i) (iv) (ii)
Show answerHide answer
Correct answer: (D) (iii) (i) (iv) (ii)
Explanation
(a) Size oriented metrics is directly implied with (iii) (b) Function oriented metrics is number of user inputs, number of user outputs, number of files, number of external interfaces. So it satisfies (i) (c) Extended function point metrics is a superset of the function point measure that can be applied to system. It uses algorithm characteristics as one of the measurement parameter. (d) Function point is a "unit of measurement" to express the amount of business functionality an information provides to a user.
Q13UGC NET Computer Science, June 2015 (Paper II & III, Selected Questions)
An all-pairs shortest-paths problem is efficiently solved using :
ADijkstra' algorithm
BBellman-Ford algorithm
CKruskal algorithm
DFloyd-Warshall algorithm
Show answerHide answer
Correct answer: (D) Floyd-Warshall algorithm
Explanation
The Floyd-Warshall algorithm solves the all-pairs shortest-paths problem efficiently in O(n³) time using dynamic programming.
Q14UGC NET Computer Science, June 2015 (Paper II & III, Selected Questions)
The travelling salesman problem can be solved in :
APolynomial time using dynamic programming algorithm
BPolynomial time using branch-and-bound algorithm
CExponential time using dynamic programming algorithm or branch-and-bound algorithm
DPolynomial time using backtracking algorithm
Show answerHide answer
Correct answer: (C) Exponential time using dynamic programming algorithm or branch-and-bound algorithm
Explanation
It will be solved by using branch and bound technique. The travelling salesman problem is NP- complete problem. It can also be solved by- one of the earliest application of dynamic programming is the Held-Karp algorithm to solve TSP in time O(n².2ⁿ).
Q15UGC NET Computer Science, June 2015 (Paper II & III, Selected Questions)
Which of the following statements is true for branch - and - bound search?
AUnderestimates of remaining distance may cause deviation from optimal path
BOverestimates can't cause right path to be overlooked.
CDynamic programming principle can be used to discard redundant partial paths.
DAll of the above
Show answerHide answer
Correct answer: (C) Dynamic programming principle can be used to discard redundant partial paths.
Explanation
Branch and bound is an algorithm design paradigm for discrete and combinatorial optimization problems; it systematically enumerates candidate solutions by state space search. In branch and bound, the dynamic programming principle can be used to discard redundant partial paths.
Q16UGC NET Computer Science, December 2015 (Paper II & III, Selected Questions)
In general, in a recursive and non-recursive implementation of problem (program) :
ABoth time and space complexities are better in recursive than in non-recursive program
BBoth time and space complexities are better in non-recursive than in recursive program
CTime complexity is better in recursive version but space complexity is better in non-recursive version of the program
DSpace complexity is better in recursive version but time complexity is better in non-recursive version of the program
Show answerHide answer
Correct answer: (B) Both time and space complexities are better in non-recursive than in recursive program
Explanation
Recursion does not offer better space or time complexity; it only makes the program compact and simpler to write and understand than a non-recursive implementation. The non-recursive version avoids function-call overhead and stack space.
Q17UGC NET Computer Science, December 2015 (Paper II & III, Selected Questions)
An ideal sort is an in-place-sort whose additional space requirement is.............
AO (log₂ n)
BO (nlog₂ n)
CO (1)
DO (n)
Show answerHide answer
Correct answer: (C) O (1)
Explanation
In-place sorts do not need extra space beyond the input array; any extra space they use is a constant, O(1).
Q18UGC NET Computer Science, December 2015 (Paper II & III, Selected Questions)
If there are n integers to sort, each integer has d digits and each digit is in the set {1, 2, ......, k}, radix sort can sort the numbers in :
AO (d n k)
BO (d nᵏ)
CO((d + n)k)
DO(d(n + k))
Show answerHide answer
Correct answer: (D) O(d(n + k))
Explanation
Consider k buckets. For each digit: (1) place each number in the appropriate bin – O(n); (2) append all the k bins sequentially – O(k). With d digits, the total is O(d(n + k)).
Q19UGC NET Computer Science, June 2016 (Paper II & III, Selected Questions)
Consider the reference string: 0 1 2 3 0 1 4 0 1 2 3 4 If FIFO page replacement algorithm is used, then the number of page faults with three page frames and four page frames are _______ and _______ respectively.
A10, 9
B9, 9
C10, 10
D9, 10
Show answerHide answer
Correct answer: (D) 9, 10
Explanation
Given reference string: 0, 1, 2, 3, 0, 1, 4, 0, 1, 2, 3, 4.
(i) FIFO with 3 page frames: faults occur at 0, 1, 2, 3, 0, 1, 4, 2, 3 (hits at the 2nd 0 and 1 after 4). Total page faults = 9.
(ii) FIFO with 4 page frames: faults occur at 0, 1, 2, 3, 4, 0, 1, 2, 3, 4 (hits at 0 and 1 before 4 is loaded). Total page faults = 10.
This is Belady's anomaly.
Q20UGC NET Computer Science, June 2016 (Paper II & III, Selected Questions)
Match the following:
A. Huffman codes
B. Optimal polygon triangulation
C. Activity selection problem
D. Quicksort
i. O(n²)
ii. θ(n³)
iii. O(nlogn)
iv. θ(n)
Code: A B C D
Q21UGC NET Computer Science, June 2016 (Paper II & III, Selected Questions)
Match the software maintenance activities in List-I to its meaning in List-II
List-I
i. Corrective
ii. Adaptive
iii. Perfective
iv. Preventive
List-II
A. Concerned with performing activities to reduce the software complexity thereby improving program understandability and increasing software maintainability
B. Concerned with fixing errors that are observed when the software is in use.
C. Concerned with the change in the software that takes place to make the software adaptable to new environment (both hardware and software)
D. Concerned with the change in the software that takes place to make the software adaptable to changing user requirements.
Code: (i) (ii) (iii) (iv)
A(B) (D) (C) (A)
B(B) (C) (D) (A)
C(C) (B) (D) (A)
D(A) (D) (B) (C)
Show answerHide answer
Correct answer: (B) (B) (C) (D) (A)
Explanation
(i) Corrective maintenance fixes errors observed when the software is in use – (B). (ii) Adaptive maintenance changes the software to make it adaptable to a new environment – (C). (iii) Perfective maintenance implements new or changed user requirements – (D). (iv) Preventive maintenance performs activities to reduce complexity and prevent future errors – (A).
Q22UGC NET Computer Science, August 2016 (Paper II & III, Selected Questions)
If there are n integers to sort, each integer has d digits, and each digit is in the set {1, 2, .... k}, radix sort can sort the numbers in:
AO(k(n + d))
BO(d(n + k))
CO((n + k) lg d)
DO((n + d) lg k)
Show answerHide answer
Correct answer: (B) O(d(n + k))
Explanation
Radix sort performs one stable counting sort per digit; each pass takes O(n + k) time and there are d digits. So n integers of d digits, each digit in {1, 2, ..., k}, are sorted in O(d(n + k)) time.
Q23UGC NET Computer Science, June 2017 (Paper II & III, Selected Questions)
Dijkstra's algorithm is based on
ADivide and conquer paradigm
BDynamic programming
CGreedy Approach
DBacktracking paradigm
Show answerHide answer
Correct answer: (C) Greedy Approach
Explanation
Dijkstra's algorithm always chooses the closest vertex in V – S to add to the set S, where S is the set of vertices whose final shortest-path weights from the source are known. So it is a greedy algorithm.
Q24UGC NET Computer Science, June 2017 (Paper II & III, Selected Questions)
What is the best method to go for the game playing problem?
AOptimal search
BRandom search
CHeuristic search
DStratified search
Show answerHide answer
Correct answer: (C) Heuristic search
Explanation
Game playing uses heuristic search, since brute-force computation over hundreds of thousands of positions is not practical.
Q25UGC NET Computer Science, November 2017 (Paper II & III, Selected Questions)
A list of n strings, each of length n, is sorted into lexicographic order using merge - sort algorithm. The worst case running time of this computation is :
AO(n log n)
BO(n² log n)
CO(n² + log n)
DO(n³)
Show answerHide answer
Correct answer: (B) O(n² log n)
Explanation
Merge sort performs O(n log n) comparisons, and comparing two strings of length n takes O(n) time in the worst case. So the worst-case running time is O(n · n log n) = O(n² log n).
How to use these UGC NET Computer Science questions
Every question here was asked in a real UGC NET 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 UGC NET papers as timed tests to check your speed under exam conditions.