Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8892793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:05:48+00:00 2026-06-14T23:05:48+00:00

I am using an adjacency matrix, priority queue is the data structure. By my

  • 0

I am using an adjacency matrix, priority queue is the data structure.

By my calculation, complexity is V^3 log V:

  • While loop: V
  • Checking adjacent Vertices: V
  • Checking the queue if the entry is already present, and updating the same: V log v

But, I read everywhere that the complexity is V^2

Please explain.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T23:05:49+00:00Added an answer on June 14, 2026 at 11:05 pm

    If you use a Fibonacci heap, then extracting the min is O(lg V) amortized cost and updating an entry in it is O(1) amortized.

    If we use this pseudo code

    while priorityQueue not empty
        u = priorityQueue.exractMin()
        for each v in u.adjacencies
            if priorityQueue.contains(v) and needsWeightReduction(u, v)
                priorityQueue.updateKeyWeight(u, v)
    

    Assume that the implementation has constant time for both priorityQueue.contains(v) and needsWeightReduction(u, v).

    Something to note is that you can bound slightly tighter for checking adjacencies. While the outer loop runs V times, and checking the adjacencies of any single node is at worst V operations, you can use aggregate analysis to realize that you will never check for more than E adjacencies(because theres only E edges). And E <= V^2, so this is a slightly better bound.

    So, you have the outer loop V times, and the inner loop E times. Extracting the min runs V times, and updating an entry in the heap runs E times.

      V*lgV + E*1
    = O(V lgV + E)
    

    Again, since E <= V^2 you could use this fact to substitute and get

      O(V lgV + V^2)
    = O(V^2)
    

    But this is a looser bound when considering sparse graphs(although correct).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using adjacency matrix to represent all the vertex of my weighted unidirectional
On matlab, I have an adjacency matrix and using a function, I would like
I am using a QTableWidget to display and edit a data matrix. For validation
I'm trying to implement Ford-Fulkerson/Edmonds-Karp only using adjacency matrix'. The only thing I'm not
I have implemented the Kruskal algorithm in C using an adjacency matrix graph representation,
Can someone explain to me why is Prim's Algorithm using adjacent matrix result in
I have a table with data stored hierarchicaly using adjacency list like in the
I am trying to implement depth first search algorithm using adjacency list representation of
I'm trying to program a graph class using an adjacent list from an example
I noticed that when using a FragmentPagerAdapter the Fragments that are non-adjacent to the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.