GATE Exam  >  GATE Questions  >   In Prim's algorithm, we use decrease key ope... Start Learning for Free
In Prim's algorithm, we use decrease key operation. What is the time complexity of this decrease key operation in case of Prim's Algorithm :
  • a)
    O(n)
  • b)
    O(nlogn)
  • c)
    O(logn)
  • d)
    O(n2)
Correct answer is option 'C'. Can you explain this answer?
Verified Answer
In Prim's algorithm, we use decrease key operation. What is the time ...
In Prim's algorithm, heaps of vertices are created and decrease key operation is performed on the heap elements which takes O(logn) time. Decrease key operation is performed to change the value of distance in every iteration.
View all questions of this test
Most Upvoted Answer
In Prim's algorithm, we use decrease key operation. What is the time ...
Time Complexity of Decrease Key Operation in Prim's Algorithm

To understand the time complexity of the decrease key operation in Prim's algorithm, let's first understand the algorithm itself.

Prim's Algorithm:
Prim's algorithm is a greedy algorithm used to find the minimum spanning tree (MST) of a connected weighted graph. It starts with an initial vertex and grows the MST by adding the minimum weight edge at each step until all vertices are included in the MST.

The decrease key operation is used in Prim's algorithm to update the key (weight) of a vertex in the priority queue. This is done when a shorter path to a vertex is found, and it needs to be updated in the priority queue.

Time Complexity of Decrease Key Operation:
The time complexity of the decrease key operation depends on the data structure used to implement the priority queue.

In Prim's algorithm, a binary heap is commonly used as the data structure for the priority queue. In a binary heap, the decrease key operation takes O(logn) time complexity. This is because the operation involves percolating up the updated key to its correct position in the heap, which takes logarithmic time.

Therefore, the correct answer is option 'C' - O(logn).

It's worth mentioning that other data structures, such as Fibonacci heap, can also be used to implement the priority queue in Prim's algorithm. The Fibonacci heap has a better time complexity of O(1) for decrease key operation. However, it has a higher constant factor and is more complex to implement compared to a binary heap.

In conclusion, the time complexity of the decrease key operation in Prim's algorithm is O(logn) when using a binary heap as the data structure for the priority queue.
Explore Courses for GATE exam
In Prim's algorithm, we use decrease key operation. What is the time complexity of this decrease key operation in case of Prim's Algorithm :a)O(n)b)O(nlogn)c)O(logn)d)O(n2)Correct answer is option 'C'. Can you explain this answer?
Question Description
In Prim's algorithm, we use decrease key operation. What is the time complexity of this decrease key operation in case of Prim's Algorithm :a)O(n)b)O(nlogn)c)O(logn)d)O(n2)Correct answer is option 'C'. Can you explain this answer? for GATE 2024 is part of GATE preparation. The Question and answers have been prepared according to the GATE exam syllabus. Information about In Prim's algorithm, we use decrease key operation. What is the time complexity of this decrease key operation in case of Prim's Algorithm :a)O(n)b)O(nlogn)c)O(logn)d)O(n2)Correct answer is option 'C'. Can you explain this answer? covers all topics & solutions for GATE 2024 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for In Prim's algorithm, we use decrease key operation. What is the time complexity of this decrease key operation in case of Prim's Algorithm :a)O(n)b)O(nlogn)c)O(logn)d)O(n2)Correct answer is option 'C'. Can you explain this answer?.
Solutions for In Prim's algorithm, we use decrease key operation. What is the time complexity of this decrease key operation in case of Prim's Algorithm :a)O(n)b)O(nlogn)c)O(logn)d)O(n2)Correct answer is option 'C'. Can you explain this answer? in English & in Hindi are available as part of our courses for GATE. Download more important topics, notes, lectures and mock test series for GATE Exam by signing up for free.
Here you can find the meaning of In Prim's algorithm, we use decrease key operation. What is the time complexity of this decrease key operation in case of Prim's Algorithm :a)O(n)b)O(nlogn)c)O(logn)d)O(n2)Correct answer is option 'C'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of In Prim's algorithm, we use decrease key operation. What is the time complexity of this decrease key operation in case of Prim's Algorithm :a)O(n)b)O(nlogn)c)O(logn)d)O(n2)Correct answer is option 'C'. Can you explain this answer?, a detailed solution for In Prim's algorithm, we use decrease key operation. What is the time complexity of this decrease key operation in case of Prim's Algorithm :a)O(n)b)O(nlogn)c)O(logn)d)O(n2)Correct answer is option 'C'. Can you explain this answer? has been provided alongside types of In Prim's algorithm, we use decrease key operation. What is the time complexity of this decrease key operation in case of Prim's Algorithm :a)O(n)b)O(nlogn)c)O(logn)d)O(n2)Correct answer is option 'C'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice In Prim's algorithm, we use decrease key operation. What is the time complexity of this decrease key operation in case of Prim's Algorithm :a)O(n)b)O(nlogn)c)O(logn)d)O(n2)Correct answer is option 'C'. Can you explain this answer? tests, examples and also practice GATE tests.
Explore Courses for GATE exam
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev