Interview Questions

  • View all interview questions
  • blank
  • Find minimum spanning tree using Prim's algorithm
    A minimum spanning tree of a graph is a subgraph that connects all vertices in the graph with a minimum total weight for the edges. Each edge between the vertices has a weight corresponding to it and your goal is to connect every vertex while minimizing the total edge weight. Graphs can have more than one minimum spanning tree. Below is an example of a graph with 5 vertices and weighted edges that we will be running Prim's algorithm on.

    Example graph with edge weights




    You need to be a premium member to see the rest of this question and code.

    Become a Premium Member

    With our large collection of challengs, tutorials, and solutions, we make it easy for you to become a better coder, prepare for interviews, and learn new skills from more experienced coders.

    “Also important to try coding in nonstructured or semistructured environments to see if you like it. Coderbyte really helped me.“ ― Jeff Ruder
    • 200+ Coding Challenges
    • Mock Interview Questions
    • 500,000+ Code Solutions
    • Algorithm Tutorials
    • Interview Prep Courses
    mrdaniel published this on 11/30/15 | array, matrix, search, graph, greedy, Microsoft
    Comments
    Login to submit a comment