CampusNavigator Graph Data Structures and Algorithms

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

1/30

flashcard set

Earn XP

Description and Tags

Vocabulary flashcards covering Java syntax, graph representations, and traversal algorithms (BFS and Dijkstra) based on the CampusNavigator lecture.

31 Terms

1
New cards

static (in static class Edge)

Specifies that the nested class belongs to CampusNavigator itself, allowing an Edge object to be instantiated without creating an instance of CampusNavigator first.

2
New cards

void

A return type keyword indicating that a method performs an action but returns no value back to the caller (e.g., public void addBuilding(…)).

3
New cards

Constructor

A special method with no return type (not even void) that matches the exact name of its class and executes automatically when new is called.

4
New cards

this.destination

The object's internal field variable stored within Edge, distinguished from the plain destination parameter passed into the constructor.

5
New cards

implements

A keyword indicating that a class guarantees to fulfill the contract of an interface by providing definitions for all of its required methods (such as compareTo for Comparable).

6
New cards

compareTo (Node)

A method required by Comparable that returns a negative number when this Node is cheaper, 00 when equal, or a positive number when more expensive, enabling PriorityQueue to prioritize the lowest-cost node.

7
New cards

@Override

A compiler annotation indicating that a method is implementing or overriding a method declared in an interface or superclass, triggering a compile-time error if the method signature does not match.

8
New cards

HashMap

A class that stores key-value pairs and provides key lookup with an average time complexity of O(1)O(1).

9
New cards

Map (vs. HashMap)

Map is an interface defining expected operations (put, get, containsKey), while HashMap is the concrete implementation. Declaring variables as Map allows alternative implementations to be swapped in without changing remaining code.

10
New cards

Hashtable

An older, thread-safe class in Java that stores key-value pairs, which is not used by the CampusNavigator code.

11
New cards

adjList (CampusNavigator)

A private Map data structure where each key is a building (node/vertex) and each value is an ArrayList containing the Edge objects departing from that building.

12
New cards

Diamond Operator (<>)

An empty pair of angle brackets in object instantiation (e.g., new HashMap<>()) that instructs Java to infer generic type arguments directly from the variable's declaration.

13
New cards

Campus Graph Properties

An undirected, weighted graph consisting of 88 buildings (vertices), 1010 walking paths, and 2020 Edge objects (each path stored twice, once in each direction).

14
New cards

BFS Route (Hibbard to Schofield)

Hibbard \rightarrow Haas \rightarrow Schofield, totaling 22 stops and 687 m687\,\text{m} (365+322365 + 322).

15
New cards

Dijkstra Route (Hibbard to Schofield)

Hibbard \rightarrow Phillips \rightarrow Davies \rightarrow Schofield, totaling 33 stops and 521 m521\,\text{m} (150+200+171150 + 200 + 171).

16
New cards

BFS vs. Dijkstra Routing Criterion

BFS solely minimizes the number of edge hops (stops) regardless of distance, whereas Dijkstra minimizes cumulative path distance (meters).

17
New cards

@param

A Javadoc tag used to document a method parameter for code readers; it is ignored during execution but displayed in code editor tooltips.

18
New cards

@return

A Javadoc tag that describes the value returned by a method, including special values like empty collections.

19
New cards

putIfAbsent

A Map method that maps the specified key to a value only if the key is not already present, preventing existing edge lists and paths from being overwritten.

20
New cards

ArrayList

A resizable-array implementation of the List interface that automatically grows and shrinks as items are added or removed, allowing duplicates and null elements.

21
New cards

addPath

A method that verifies both buildings exist and meters is strictly greater than 00, then adds two directed edges (a→ba \rightarrow b and b→ab \rightarrow a) to maintain an undirected graph.

22
New cards

prev Map (BFS)

A map storing predecessors as prev.put(edge.destination, current), which simultaneously tracks visited buildings and enables path backtracking.

23
New cards

FIFO (First In, First Out)

The processing order of BFS's queue, ensuring nodes 11 stop away are fully dequeued and explored before nodes 22 stops away.

24
New cards

BFS Time Complexity

O(V+E)O(V + E), achieved because the algorithm checks whether a node is in prev before queuing it, ensuring each vertex is processed at most once.

25
New cards

reconstructPath

A helper method that traces backward from the end building to the start building using the prev map and reverses the sequence so it reads start \rightarrow end.

26
New cards

Collections

A Java utility class providing static helper methods such as Collections.emptyList(), not to be confused with the Collection interface.

27
New cards

poll()

A queue method that retrieves and removes the front (cheapest) element of a PriorityQueue, returning null if the queue is empty.

28
New cards

peek()

A queue method that inspects the element at the head of the queue without removing it.

29
New cards

Stale Entry (Dijkstra)

An obsolete node representation inside the priority queue whose cost is higher than the currently known shortest distance to that building, discarded via continue.

30
New cards

Deque

A double-ended queue supporting insertion and removal at both endpoints; used as a LIFO stack in reconstructPath to reverse the backward-traversed path.

31
New cards

ArrayDeque

A modern, efficient implementation of Deque recommended by Java documentation for stack operations in place of the legacy Stack class.