Help needed in kruskals algorithm with bfs and dfs included

I am trying to solve a question. it asked me to perform 3 things BFS,DFS and kruskals algorithm in the same question . i am able to only 2 out of it and now i am confused how to write the kruskals algo. using the medthod i stored my data.

below is the link of what i wrote, or the code that i have written so far.

https://pastebin.com/b63AJYWJ

here i am providing you the pic of the question

if guys can help me in any way plz. tell

Can you tell question ?

As you know Kruskal’s algorithm choose minimum cost edge and keep tracking cycle formation and repeats for (nodes-1) times.
You can create min heap from adjacency list and each node in min heap contains cost of edge, starting and ending point of node you can do this using structure.
After creation of heap start deleting elements from heap and add that element into another 2d array [nnodes-1][2] which contains starting and position of nodes.And keep doing for (nnodes-1) times and you will get minimum cost spanning tree.
Time Complexity
Creation of heap : O((V+E)logn)
Deleting from heap : O(logn)
And loop repeats for (n-1) times and each time deletion from heap takes place means O((n-1)logn)

Overall Time Complexity: O((V+E)logn).

Please let me know if I am wrong anywhere.

Thanks

this will help you https://github.com/sourabhb77/Algorithms/blob/master/kruskalsAlgoWithSomeChanges.cpp

can you provide some kind of pseudo code… i am confused

Code for Kruskal’s Algorithm

In it random graph is generated based on number of nodes and number of edges as input from user.

[https://pastebin.com/fR4j5PgP]

If there is any error or bug please let me know.

Thanks

thanks for it, i did it the other way around :sweat_smile: :sweat_smile:

here ,

https://pastebin.com/9ZhFUeYn