I want the complexity of code which is taught in class, not from the internet where code might be different!
What is the complexity of the code written in the tutorial?
Time complexity of the code written in the video is O(V^2) .
We are iterating over all the vertex, and for each vertex we are trying to find vertex with min weight(that take O(V) time) after that we iterating over all the neighbors of the min vertex. So we have O(V*(V+V)) time complexity, that is same as , O(V^2).
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.