notes.md 1.05 KB
Newer Older
michael lundquist's avatar
michael lundquist committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# class notes

- 3_19_19
- grading by end of week

## recap

- linked list = connected chain of nodes

## stacks n queues notes

- see what these things implement and override

### stacks

- LIFO
- only has a top pointer
- has an insert method
- push, pop, peek
- check if the stack is empty before popping
- peek returns, but doesn't remove from the stack
- a stack array can have an integer pointer
- next week depth first search

#### string parsing (in final exam)

- validate brackets with a stack by having a stack that tracks {,[,( as openers and ), ], and } as closers push on openers, pop on closers. When you pop, make sure your opener matches your closer.
- popping on an empty stack causes a failure.
- ending with elements in the stack is an error

#### math evaluation with stacks

- closing brackets means 2 pop from op stack until opening bracket.
- each pop from the op stack is 2 pops from num stack
- after an op, push back to num stack

### queues

- add = queue
- remove = dequeue
- queue has both head and tail, you add to tail, and pop from head.
-