UGC NET · Computer Science

Algorithms Previous Year Questions

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.

  • 25 questions
  • Official answer key
  • Free

Other Computer Science topics

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
  1. Amin (h(n), g(n))
  2. Bmax (h(n), g(n))
  3. Ch(n) + g(n)
  4. 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
  1. AO(n!) and O(n log n)
  2. BO(nⁿ) and O(n log n)
  3. CO(n!) and O(log n!)
  4. 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
  1. A10
  2. B12
  3. C14
  4. 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)
  1. A40
  2. B38
  3. C32
  4. 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?
  1. ABubble sort
  2. BSelection sort
  3. CQuick sort
  4. 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?
  1. A16
  2. B17
  3. C18
  4. 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?
  1. AFlooding
  2. BMulti destination routing
  3. CReverse path forwarding
  4. 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............
  1. AGreedy algorithm, Divide-conquer algorithm
  2. BDivide-conquer algorithm, Greedy algorithm
  3. CGreedy algorithm, Dynamic programming algorithm
  4. DDynamic programming algorithm, Greedy algorithm
Show answerHide answer

Correct answer: (C) Greedy algorithm, Dynamic programming algorithm

Explanation

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:
  1. ACounting micro seconds
  2. BCounting number of key operations
  3. CCounting number of statements
  4. 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?
  1. ASelection sort
  2. BBubble sort
  3. CRadix sort
  4. 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?
  1. A0.984 sec
  2. B0.396 sec
  3. C0.738 sec
  4. D0.42 sec
Show answerHide answer

Correct answer: (D) 0.42 sec

Explanation

SSTF from cylinder 24: 24 → 26 (2) → 12 (14) → 8 (4) → 4 (4) → 42 (38) → 50 (8). Total distance = 70 cylinders. Seek time = 70 × 6 msec = 420 msec = 0.42 sec.

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
  1. A(iii) (iv) (i) (ii)
  2. B(ii) (i) (iv) (iii)
  3. C(iv) (ii) (iii) (i)
  4. 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 :
  1. ADijkstra' algorithm
  2. BBellman-Ford algorithm
  3. CKruskal algorithm
  4. 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 :
  1. APolynomial time using dynamic programming algorithm
  2. BPolynomial time using branch-and-bound algorithm
  3. CExponential time using dynamic programming algorithm or branch-and-bound algorithm
  4. 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?
  1. AUnderestimates of remaining distance may cause deviation from optimal path
  2. BOverestimates can't cause right path to be overlooked.
  3. CDynamic programming principle can be used to discard redundant partial paths.
  4. 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) :
  1. ABoth time and space complexities are better in recursive than in non-recursive program
  2. BBoth time and space complexities are better in non-recursive than in recursive program
  3. CTime complexity is better in recursive version but space complexity is better in non-recursive version of the program
  4. 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.............
  1. AO (log₂ n)
  2. BO (nlog₂ n)
  3. CO (1)
  4. 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 :
  1. AO (d n k)
  2. BO (d nᵏ)
  3. CO((d + n)k)
  4. 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.
  1. A10, 9
  2. B9, 9
  3. C10, 10
  4. 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
  1. A(i) (ii) (iv) (iii)
  2. B(i) (iv) (ii) (iii)
  3. C(iii) (ii) (iv) (i)
  4. D(iii) (iv) (ii) (i)
Show answerHide answer

Correct answer: (C) (iii) (ii) (iv) (i)

Explanation

Correct matching: Huffman codes – O(nlogn); Optimal polygon triangulation – θ(n³); Activity selection problem – θ(n); Quicksort – O(n²).

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)
  1. A(B) (D) (C) (A)
  2. B(B) (C) (D) (A)
  3. C(C) (B) (D) (A)
  4. 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:
  1. AO(k(n + d))
  2. BO(d(n + k))
  3. CO((n + k) lg d)
  4. 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
  1. ADivide and conquer paradigm
  2. BDynamic programming
  3. CGreedy Approach
  4. 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?
  1. AOptimal search
  2. BRandom search
  3. CHeuristic search
  4. 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 :
  1. AO(n log n)
  2. BO(n² log n)
  3. CO(n² + log n)
  4. 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.