levo

Fundamentals of Data Structures

Graphs

  • 3 things to know
  • Paper 1
Start revising · £5/month

Overview

Recall questions on vertices and edges, weighted, directed and undirected graphs, and the trade-off between an adjacency matrix and an adjacency list.

What you need to know

Answer each one before you reveal it.

Your recallNot started
Key term

Would you model a friendship network on a social media site as directed or undirected, and why?

Key term

What is a sparse graph, and why does it waste space in an adjacency matrix?

Numbers

When is an adjacency list preferable to an adjacency matrix?

Questions from this subtopic

Each one with the model answer underneath.

  1. 1

    What is a graph, and why is it used as a data structure?

    Model answer

    A graph is a set of vertices (also called nodes) connected by edges (also called arcs). It is used to represent relationships that are more complex than the simple linear or hierarchical orders that lists and trees can express, because any vertex may be connected to any number of others, and connections may run in either or both directions.

  2. 2

    Define a vertex and an edge.

    Model answer

    A vertex, or node, is one of the objects in the graph — the things being connected, such as a town or a web page. An edge, or arc, is a connection between two vertices, representing a relationship between them, such as a road or a hyperlink.

  3. 3

    What is a weighted graph?

    Model answer

    A graph in which every edge carries a value, called its weight, representing a cost associated with using that connection — for example a distance, a travelling time, a price or a bandwidth. Algorithms that find the cheapest route work on the total of the weights along a path rather than on the number of edges.

  4. 4

    Explain the difference between an undirected graph and a directed graph.

    Model answer

    In an undirected graph an edge has no direction: an edge between A and B can be traversed from A to B and from B to A equally, so the relationship is symmetric. In a directed graph (a digraph) each edge has a direction and can only be traversed that way, so an edge from A to B does not imply one from B to A. A two-way road is an undirected edge; a one-way street is a directed one.

  5. 5

    Give six typical uses of graphs.

    Model answer

    Road and rail networks, where vertices are places and weighted edges are the routes between them, used for journey planning. Computer networks, where vertices are devices and edges are the links, used for routing packets. Social networks, where vertices are people and edges are friendships. The World Wide Web, where vertices are pages and directed edges are hyperlinks. Also state transition diagrams and the dependency graphs used to schedule tasks.

  6. 6

    Would you model a friendship network on a social media site as directed or undirected, and why?

    Model answer

    It depends on whether the relationship is mutual. A site where both people must agree to a friendship is best modelled by an undirected graph, because the relationship is symmetric. A site where one person can follow another without being followed back is best modelled by a directed graph, because the edge from follower to followed does not imply an edge the other way.

Other ways to work this

The same content, four other ways.

Everything in your subscription

Runs, plus a mode for every other kind of session.

1Flash
2Imposter
3Fade
4Brain dump

Learn every subtopic in runs of four questions

Facts flash and fade, a wrong word hides in some of them, and a brain dump decides which questions are locked in.

Fundamentals of Programming
Fundamentals of Data Structures
Fundamentals of Algorithms
Theory of Computation

Cram the night before, weakest topic first

A quick scan finds your weakest topics. Recall each fact you missed three times in a row.

A driver is .
softwarehardwarestorage

Blank Blitz consolidates the facts

Rapid timed gap-fills on the terms and numbers you need to recall without thinking.

✓What it iscovered
~Why it happenspartly there
How long it lastsnot there yet

Explain It tests your understanding

Explain a concept in your own words and see which of its points you covered.

Head means the first single element of a non-empty list.
TrueFalse

Test It catches misconceptions

Spot the fault in a statement. The faults are the mistakes students make most often.

721941163128510

Brain Breaks between sessions

Short focus games to reset attention, so the next set lands better than the last.

Every question in Fundamentals of Data Structures, on a schedule.

Learn it in runs of four questions, each ending on a brain dump against the clock. Every question you lock in comes back the next day, then at longer gaps, each time just before you would forget it.

Or £46 a year, about £3.83 a month. Cancel anytime.