levo

Fundamentals of Data Structures

Graphs

  • 3 things to know
  • Paper 1

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.

What is inside Levo

Six ways to work the same material.

1Closed book
2Open book
3Closed book

The 3-step method, run for you

Answer cold, learn it, then prove it stuck. Levo tracks the jump between your first attempt and your last.

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

Cram a whole paper in one sitting

Sort every topic into what you know and what you do not, then drill only the weak ones.

A driver is .
softwarehardwarestorage

Blank Blitz makes facts automatic

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

AThe integer 5 is 0101.
B0.75 is 1/2 + 1/4.
CThe fraction bits are 1100.

Build It gets the exam shape right

Assemble a full-mark answer from its marking points, in the order an examiner wants them.

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

Test It catches misconceptions

Spot the fault in a statement. The traps are the mistakes students actually make.

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.

Attempt a question from memory, write the correct version, then attempt it again. Levo records the jump between your first attempt and your last, and brings each question back on the day you are due to forget it.

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