CSE 122 Q1

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/33

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

34 Terms

1
New cards

Stack

Last-In First-Out (LIFO) collection. Use push() to add

2
New cards

Queue

First-In First-Out (FIFO) collection. Use add() or offer() to enqueue

3
New cards

PriorityQueue

A type of Queue that orders elements based on natural ordering or a Comparator. Not FIFO.

4
New cards

Deque (Double-Ended Queue)

Can act as both a queue (FIFO) and stack (LIFO). Supports addFirst()

5
New cards

HashSet

Stores unique elements

6
New cards

TreeSet

Sorted set that keeps elements in natural order (or a custom Comparator). Backed by a Red-Black tree

7
New cards

LinkedHashSet

Maintains insertion order while still preventing duplicates. Slightly slower than HashSet.

8
New cards

Set iteration method

Use enhanced for loop (for (Type x : set)) or an Iterator (Iterator it = set.iterator()).

9
New cards

HashMap

Key-value pairs

10
New cards

TreeMap

Sorted map ordered by keys (natural or Comparator). No null keys allowed. O(log n) operations.

11
New cards

LinkedHashMap

Maintains insertion order of keys. Slightly slower than HashMap.

12
New cards

Map iteration (keys)

for (K key : map.keySet()) { … }

13
New cards

Map iteration (values)

for (V value : map.values()) { … }

14
New cards

Map iteration (entries)

for (Map.Entry<K

15
New cards

Map get vs put

get(key) retrieves value or null if missing

16
New cards

put(key

value) inserts or replaces value.

17
New cards

Map containsKey vs containsValue

containsKey() checks if a key exists

18
New cards

containsValue() checks if any key maps to that value (slower).

19
New cards

Reference Semantics

When you assign or pass objects

20
New cards

Value Semantics

When primitive values or immutable objects (like Strings) are copied by value

21
New cards

Iterator syntax

Iterator it = collection.iterator()

22
New cards

while (it.hasNext()) { Type element = it.next()

23
New cards

}

24
New cards

Iterator remove()

Safely removes elements while iterating to avoid ConcurrentModificationException.

25
New cards

Enhanced for loop (for-each)

for (Type x : collection) { // read-only access to elements }

26
New cards

HashSet vs TreeSet

HashSet — unordered

27
New cards

TreeSet — sorted

slower (O(log n)).

28
New cards

HashMap vs TreeMap

HashMap — unordered

29
New cards

TreeMap — sorted

no null key.

30
New cards

LinkedHashSet vs TreeSet

LinkedHashSet keeps insertion order

31
New cards

TreeSet keeps sorted order.

32
New cards

Map<String

List>

33
New cards

Set

Set containing lists — duplicates determined by list equality (equals()). Order of lists in set not guaranteed.

34
New cards

Map<String

Set>