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 950029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:29:57+00:00 2026-05-15T23:29:57+00:00

There are three ways to store a graph in memory: Nodes as objects and

  • 0

There are three ways to store a graph in memory:

  1. Nodes as objects and edges as pointers
  2. A matrix containing all edge weights between numbered node x and node y
  3. A list of edges between numbered nodes

I know how to write all three, but I’m not sure I’ve thought of all of the advantages and disadvantages of each.

What are the advantages and disadvantages of each of these ways of storing a graph in memory?

  • 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-15T23:29:58+00:00Added an answer on May 15, 2026 at 11:29 pm

    One way to analyze these is in terms of memory and time complexity (which depends on how you want to access the graph).

    Storing nodes as objects with pointers to one another

    • The memory complexity for this approach is O(n) because you have as many objects as you have nodes. The number of pointers (to nodes) required is up to O(n^2) as each node object may contain pointers for up to n nodes.
    • The time complexity for this data structure is O(n) for accessing any given node.

    Storing a matrix of edge weights

    • This would be a memory complexity of O(n^2) for the matrix.
    • The advantage with this data structure is that the time complexity to access any given node is O(1).

    Depending on what algorithm you run on the graph and how many nodes there are, you’ll have to choose a suitable representation.

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

Sidebar

Ask A Question

Stats

  • Questions 536k
  • Answers 536k
  • 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 Look at the permissions of the php session directory where… May 17, 2026 at 1:25 am
  • Editorial Team
    Editorial Team added an answer The following will remove all occurences of [idsomething]. something will… May 17, 2026 at 1:25 am
  • Editorial Team
    Editorial Team added an answer You can use UIScrollView horizontal paging. An Apple's sample code… May 17, 2026 at 1:25 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

Related Questions

Anybody knows ways to store data with javascript clients computer? Except using cookies. May
What are some clever (not ordinary) ways of implementing data structures in C, and
I store user editable articles in a database. Users can insert some simple widgets
I'm writing a small Django-based frontend to collect and graph internet usage statistics. Currently,
Is there any special support when you come to test callbacks with NUnit? Or
which is the best primary key to store website address and page URLs? To
I'm currently developing the foundation of a an application, and looking for ways to
We're thinking about putting up a data warehouse system to load with web access
I have a variable that very rarely gets an incorrect value. Since the system
I’m using Microsoft Chart extensions that ship with VS 2010. This suits my needs

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.