• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/12

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

12 Cards in this Set

  • Front
  • Back

What's the difference between a graph and a tree?

trees are a special case of a graph with no cycles

What's an undirected graph?

Any connection goes both ways.

What's a directed graph?

Connections only go one way.

What is an adjaceny list?

Something like,


a, b


a, c


c, b to model a graph with connections between those pairs of objects.

What is an adjacenty matrix

Something like


- a b c


a 0 1 1


b 0 0 0


c 0 1 0


to model a graph with connections between those objects

How do you represent a graph with objects and pointers

You'd have object a with pointers to b and c, and object c with a pointer to b, to model a graph with connections between objects

What's std::set?

In c++, a container that holds many (unlimited) const objects. Useful for declaring std::set<Pointer_type*> to store all the pointers from an object in a graph, when you don't know ahead of time how many there will be. Also takes custom less than comparators

Explain DFS in the context of graphs

Favors exploring unvisited nodes with a greater distance from root first. Good for finding things that are likely to be far away from root. Must have a way to make nodes visited/unvisited. Push things onto the stack (LIFO) until you run out of choices; then pop until you find a choice again.

Explain BFS In the context of graphs

Favors exploring unvisited nodes at the same distance from root first. Examine item at front of queue. If not searched-for-thing, add it's unvisited neighbors to the end of the queue and mark them visited (to prevent re-adding same nodes).

What are the complexity properties of an adjacency list?

Storage: O(V / E)


Adding Vertex: O(1)


Adding Edge: O(1)


Removing Vertex O(V/E)


Removing Edge O(E)


Query O(V)

What are the complexity properties of an adjacency matrix?

Storage: O(V^2)


Adding Vertex: O(V^2)


Adding Edge: O(1)


Removing Vertex O(V^2)


Removing Edge O(1)


Query O(1)

What's Dijkstra ?

How you go about calculating the "best" path when edges have weight; for example a busy road might be shorter but less ideal for a directions finding app. Instead of maintaining the shortest number of nodes, you maintain the shortest total weights.