MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

DATA STRUCTURES

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
What is the space complexity for DFT?
A
O(v)
B
O(v + e)
C
O(e)
D
O(v*e)
Explanation: 

Detailed explanation-1: -Complexity. The time complexity of DFS is O(V + E) where V is the number of vertices and E is the number of edges. This is because the algorithm explores each vertex and edge exactly once. The space complexity of DFS is O(V).

Detailed explanation-2: -Space complexity of O(n) means that for each input element there may be up to a fixed number of k bytes allocated, i.e. the amount of memory needed to run the algorithm grows no faster than linearly at k*N.

Detailed explanation-3: -O(1) – constant complexity – takes the same amount of space regardless of the input size. O(log n) – logarithmic complexity – takes space proportional to the log of the input size. O(n) – linear complexity – takes space directly proportional to the input size.

There is 1 question to complete.