linked lists, stacks, queues

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/37

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.

38 Terms

1
New cards

Node

Element with data + pointer to next

2
New cards

Head

First node in a linked list

3
New cards

Tail

Last node (points to null or head)

4
New cards

Normal Linked List

Last node points to null

5
New cards

Circular Linked List

Last node points to head

6
New cards

Insert in Ascending Order

Traverse until current > new, insert before

7
New cards

Insert in Descending Order

Traverse until current < new, insert before

8
New cards

Delete Node by Value

Find node with value, bypass it in links

9
New cards

Stack

LIFO structure (last in, first out)

10
New cards

Push

stack.push(element)

Pushes to the top of the stack (head)

11
New cards

Pop

stack.pop()

removes from the top of the stack, returns the element

throws emptystackexception

12
New cards

Peek

stack.peek()

returns the top of the stack wo removing

throws emptystackexception

13
New cards

infix expression

Operators between operands A+B

14
New cards

Postfix Expression

Operators after operands (A B +)

15
New cards

Convert Infix to Postfix

Use stack for operators, follow precedence and parentheses

16
New cards

Evaluate Postfix

Use stack, push numbers, pop and apply operators

17
New cards

Queue

FIFO structure (first in, first out)

18
New cards

Enqueue

Add item at rear

19
New cards

add(element) - type, what it does

Queues

adds to queue. if failure, throws exception

AddException

20
New cards

offer(element) - type, what it does

Queues

inserts, if failure, returns false

21
New cards

remove() - type, what it does

Queues

deletes head, if failure throws exception

add and remove throw a hissy fit

22
New cards

poll() - type, what it does

Queues

deletes head, if failure returns null

23
New cards

remove(element)

queues

deletes the first instance of element

24
New cards

limitation of linear queues

after multiple pops the space is wasted, cannot reuse

25
New cards

circular queue

rear points to head to reuse space

26
New cards

full circular queue condition

(rear+1) % size == front

27
New cards

what does head = head.next mean

deletes head node

28
New cards

what happens if you forget to update prev.next when deleting

node stays in the list—not actually removed

29
New cards

circular lists: how to check end of list

curr.next == head

30
New cards

what happens if delete last node in circular list, but don’t update the tail

tail points to deleted memory and everything explodes

31
New cards

insert at beginning of a singly list

newNode.next = head;

head = newNode;

32
New cards

stack underflow

pop on empty stack—error

33
New cards

infix to postfix—where do we pop operators from

stack

34
New cards

what to do when see ) in infix

pop until see (

ex stack:

)

2

+

1

(

pop from ) to ( to get (1+2)

35
New cards

what does front == rear mean in a circular queue

empty

36
New cards

What if you insert at head but forget newNode.next = head?

You lose the rest of the list — only the new node remains

37
New cards

What's the tail’s .next in a circular list?

Points to the head

38
New cards

How do you delete the head in a circular list with one node?

Set head = null

like any other list you stupid bumbling oaf