graph intro and DFS flashcards

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/128

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 4:28 AM on 5/11/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

129 Terms

1
New cards

Graph Representation

Graphs consist of vertices (nodes) and edges (connections) and can be directed or undirected

2
New cards

Adjacency List

Stores for each node a list/set/vector of all connected neighbors and is efficient for sparse graphs

3
New cards

Adjacency Matrix

A 2D matrix where matrix[i][j] indicates edge presence and is efficient for dense graphs but uses O(V^2) space

4
New cards

Node Map Representation

UTK notes often use maps from node names to sets/vectors of neighboring nodes for flexible graph construction

5
New cards

Directed Graph

Edges have direction from one node to another

6
New cards

Undirected Graph

Edges work both ways

7
New cards

Sparse Graph

Has relatively few edges compared to possible maximum

8
New cards

Dense Graph

Has many edges and may justify matrix storage

9
New cards

DFS (Depth First Search)

Traverses graph by exploring as deep as possible along one path before backtracking

10
New cards

DFS Core Idea

Visit node then recursively visit each unvisited neighbor

11
New cards

DFS Data Structure

Uses recursion or explicit stack

12
New cards

DFS Starting Point

Begins at chosen source node then expands depth-first

13
New cards

DFS Visit Rule

Mark node visited immediately to avoid revisits/cycles

14
New cards

DFS Backtracking

When no unvisited neighbors remain return to previous node

15
New cards

DFS Runtime

O(V + E) because each node and edge is processed once

16
New cards

DFS Space Complexity

O(V) due to recursion stack/visited tracking

17
New cards

DFS Tree

The traversal creates a spanning tree showing discovery paths

18
New cards

DFS Recognition Pattern

Long branch exploration before returning rather than level-by-level

19
New cards

DFS Example Pattern

Go deep A→B→D→F before exploring sibling branches

20
New cards

Recursive DFS

Function calls itself on each unvisited neighbor

21
New cards

Iterative DFS

Uses stack manually instead of recursion

22
New cards

Recursive DFS Advantage

Simpler and cleaner code

23
New cards

Iterative DFS Advantage

Avoids recursion depth limits

24
New cards

Stack Behavior

LIFO order causes newest discovered node to be explored next

25
New cards

DFS vs BFS

DFS explores depth-first while BFS explores breadth/level-first

26
New cards

DFS on Cyclic Graphs

Requires visited set to prevent infinite loops

27
New cards

Connected Component

A maximal set of vertices where each is reachable from others

28
New cards

DFS for Connected Components

Run DFS from unvisited nodes repeatedly to identify each component

29
New cards

Component Counting

Each new DFS call from an unvisited node indicates a new connected component

30
New cards

DFS Forest

Collection of DFS trees for disconnected graphs

31
New cards

Spanning Tree

A subset of edges connecting all reachable nodes without cycles

32
New cards

DFS Spanning Tree

Contains discovery edges only

33
New cards

Tree Edge

Edge used to first discover a node

34
New cards

Back Edge

Edge connecting node to ancestor indicating cycle in directed DFS

35
New cards

Cross Edge

Edge connecting unrelated branches in directed DFS

36
New cards

Cycle Detection with DFS

If DFS reaches an already active ancestor then a cycle exists

37
New cards

Undirected Cycle Detection

Ignore parent edge but revisiting another visited node implies cycle

38
New cards

Topological Sort Connection

Reverse DFS postorder can produce valid topological ordering in DAGs

39
New cards

Preorder Traversal

Order nodes when first visited

40
New cards

Postorder Traversal

Order nodes when fully processed after children

41
New cards

Reverse Postorder

Useful for topological sort

42
New cards

DFS Maze Analogy

Follow one corridor fully before trying alternatives

43
New cards

Graph File Parsing

UTK notes emphasize reading vertices and edges from structured input files

44
New cards

Building Graph from File

Create node entries then add adjacency relationships

45
New cards

Node Discovery State

Commonly white/unvisited gray/active black/finished conceptually

46
New cards

Marking Visited

Usually boolean set/map

47
New cards

DFS Pseudocode

Mark current node visited then recursively process each unvisited neighbor

48
New cards

DFS Base Case

Return when all neighbors are already visited

49
New cards

DFS Order Dependency

Traversal order depends on adjacency list ordering

50
New cards

Neighbor Ordering

Changing adjacency ordering changes DFS output but not correctness

51
New cards

DFS for Path Existence

Can determine if target node is reachable

52
New cards

Reachability

If DFS visits node then it is reachable from source

53
New cards

DFS Path Reconstruction

Store parent pointers to reconstruct route

54
New cards

Parent Pointer

Tracks node from which current node was discovered

55
New cards

DFS Parent Tree

Allows path backtracking to source

56
New cards

DFS on Disconnected Graph

Must loop through all nodes and launch DFS on unvisited ones

57
New cards

Full Graph Traversal

Outer loop + DFS covers all components

58
New cards

DFS Application Maze Solving

Explores possible routes deeply until exit found

59
New cards

DFS Application Topological Sort

Postorder stack gives valid dependency ordering

60
New cards

DFS Application Cycle Detection

Detects loops in prerequisite/dependency graphs

61
New cards

DFS Application Connectivity

Determines whether graph is fully connected

62
New cards

DFS Application SCC Foundations

Forms basis for strongly connected component algorithms

63
New cards

BFS Comparison Runtime

Both BFS and DFS are O(V+E)

64
New cards

BFS Comparison Memory

BFS often uses more memory due to queue of broad frontier

65
New cards

DFS Memory Strength

Usually smaller active set if graph is deep not wide

66
New cards

DFS Weakness

Does not guarantee shortest path

67
New cards

BFS Shortest Path

BFS guarantees shortest path in unweighted graphs

68
New cards

DFS Traversal Output

Produces deep recursive-like visitation order

69
New cards

BFS Traversal Output

Produces level-order visitation

70
New cards

DFS Edge Processing

Each adjacency list scanned once

71
New cards

DFS with Stack Push

Push neighbors onto stack for later processing

72
New cards

DFS Iterative Ordering

May reverse neighbor visitation depending on push order

73
New cards

DFS Recursive Output

Typically follows adjacency list order directly

74
New cards

Infinite Loop Risk

Without visited markers DFS may repeat forever in cyclic graphs

75
New cards

Graph Search Goal

Explore structure

76
New cards

DFS Component Example

If graph has 3 disconnected groups DFS outer loop runs 3 times

77
New cards

Visited Vector

Boolean vector indexed by node ID for fast tracking

78
New cards

Visited Set

Useful when node labels are strings

79
New cards

Adjacency Set Advantage

Prevents duplicate edges automatically

80
New cards

Adjacency Vector Advantage

Faster iteration and preserves insertion order

81
New cards

Graph Construction Complexity

O(E) insertion plus node setup

82
New cards

DFS Discovery Edge

Edge followed to first visit new node

83
New cards

DFS Finish Time

Timestamp after exploring all descendants

84
New cards

Discovery Time

Timestamp when node first visited

85
New cards

Finish Time Use

Helpful in topological sort and SCC algorithms

86
New cards

DFS Exam Phrase

Explore one branch fully before backtracking using recursion/stack in O(V+E)

87
New cards

Connected Graph

A graph where every node is reachable from every other

88
New cards

Disconnected Graph

Contains multiple components

89
New cards

DAG

Directed acyclic graph with no directed cycles

90
New cards

DFS on DAG

Can support topological sorting

91
New cards

DFS Tree Height

Can be as deep as longest path

92
New cards

Worst Case Stack Depth

O(V)

93
New cards

DFS Best Use Cases

Connectivity cycle detection topological preprocessing

94
New cards

DFS Poor Use Case

Shortest path in unweighted graph

95
New cards

Edge List

Simple pair list of edges often converted into adjacency list

96
New cards

DFS Traversal Determinism

Depends on neighbor processing order

97
New cards

Graph Label Mapping

Map string labels to integer indices for efficient storage

98
New cards

DFS Start Node Choice

Affects traversal order but not full reachability

99
New cards

DFS Forest Root

Each unvisited start node becomes root of new DFS tree

100
New cards

Component Labeling

Mark all nodes in same DFS run with same component ID