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

  • SEARCH
  • Home
  • 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 740741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:33:03+00:00 2026-05-14T08:33:03+00:00

Currently am developing a program that solves (if possible) any given labyrinth of dimensions

  • 0

Currently am developing a program that solves (if possible) any given labyrinth of dimensions from 3X4 to 26×30. I represent the graph using both adj matrix (sparse) and adj list. I would like to know how to output the total time taken by the DFS to find the solution using one and then the other method. Programatically, how could i produce such benchmark?

  • 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-05-14T08:33:03+00:00Added an answer on May 14, 2026 at 8:33 am

    An useful table to work out with various graphs implementations:

    OPERATION               EDGE LIST      ADJ LIST             ADJ MATRIX
    
    degree(v)                 O(m)         O(d(v))                O(n)
    incidentEdges(v)          O(m)         O(d(v))                O(n)
    areAdjacent(v1,v2)        O(m)         O(min(d(v1),d(v2))     O(1)
    addVertex(v)              O(1)         O(1)                   O(n²)
    addEdge(v)                O(1)         O(1)                   O(1)
    removeVertex(v)           O(m)         O(m)                   O(n²)
    removeEdge(e)             O(m)         O(d(v1)+d(v2))         O(1)
    
    memory                    O(m+n)       O(m+n)                 O(n²)
    

    where m is the number of edges, n is the number of vertices and d(vertex) is the number of elements in the vertex adjacency list.. adj matrix implementation has an O(n²) to add and remove vertices because you have to reallocate the matrix..

    Just prepared this for an article, that why I have it ready 🙂

    This is not directly related to benchmarking, since usually you study which operations you will mostly need and choose the right implementation for your needs, so it’s a sort of “theoretical” benchmark that you do by studying what you are going to implement. Otherwise you can just measure time that your code needs to do the whole work with both implementations and compare it.

    EDIT: since you use a sparse matrix implementation the complexity of operations could slightly change (mostly getting a little worse, since you are trading memory for speed).

    EDIT2: ok, now that I know that this is Java it will be fair simple:

    long before = System.nanoTime();
    
    /* execution of your algorithm */
    
    long elapsed = System.nanoTime() - before;
    

    Answer is in nanoseconds and accuracy is not guaranteed, so use this thing carefully. Doing an average of many runs (and checking that variance is low, discarding the result that are more distant from the average) will give coherence to your results.

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

Sidebar

Ask A Question

Stats

  • Questions 413k
  • Answers 413k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Create a migration that looks like this: class CreateQuestionsTags <… May 15, 2026 at 8:18 am
  • Editorial Team
    Editorial Team added an answer // SCENARIO 1 (*obj).foo(); Note that obj is a misnomer… May 15, 2026 at 8:18 am
  • Editorial Team
    Editorial Team added an answer This blog is exactly what you are looking for May 15, 2026 at 8:18 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.