Computer Science

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

1/90

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 7:36 PM on 4/19/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

91 Terms

1
New cards

What is an ADT?

Abstract Data Design: defines behavior, not implementation

2
New cards

What is procedural abrastaction?

Breaking problems into functions

3
New cards

Why use abstraction?

Simplifies complexity

4
New cards

Stack order?

LIFO (Last In First Out)

5
New cards

Queue Order?

FIFO (First In First Out)

6
New cards

Stack Operations?

Push, pop, peek.

7
New cards

Queue operations?

Enqueue, dequeue

8
New cards

Real life stack example?

Undo feature

9
New cards

Reali life queue example?

Line at store

10
New cards

What is node?

Data + reference to next

11
New cards

What is a linked list?

Chain of nodes?

12
New cards

Advantage of linked list?

Dynamic size

13
New cards

What is Big-O?

Growth rate of algorithm

14
New cards

O(1)?

Constant time?

15
New cards

O(n)

Linear

16
New cards

O(n²)?

Nested loops

17
New cards

O(log n)?

Halving (binary search)

18
New cards

What is recursion?

Function calling itself

19
New cards

Two required parts?

Base case + recursive case

20
New cards

What happens without base case?

Infinite recursion

21
New cards

Root?

Top node

22
New cards

Leaf?

Node with no children

23
New cards

Binary Tree?

≤ 2 children

24
New cards

Preorder traversal?

Root → Left → Right

25
New cards

Inorder traversal?

Left → Root → Right

26
New cards

Postorder traversal?

Left → Right → Root

27
New cards

BST Rule

Left < Root < Right

28
New cards

BST search complexity?

O(log n) average

29
New cards

What is brute force?

Try everything

30
New cards

What is Dynamic Programming?

Store/reuse solutions

31
New cards

What is backtracking?

Try + undo

32
New cards

What is class?

Blueprint for objects

33
New cards

What is the Huffman coding?

Compression using frequency?

34
New cards

What is a frame?

Table mapping variable names → references

35
New cards

What are the 3 aspects of a variable?

Name, value, and address

36
New cards

What does “is” mean?

Same reference (same object)

37
New cards

Does Python treat all data the same?

Yes, everything is an object

38
New cards

Does Python copy values automatically?

No, only references

39
New cards

Why does Python cache some values?

Efficiency (e.g., small integers, True, None)

40
New cards

What happens here?

x = [1]

y = x

y.append(2)

x becomes [1,2] (same object)

41
New cards

What happens here?

x = 5
y = x
x = 7

y is still 5 (immutable)

42
New cards

Why are lists tricky with references?

They are mutable → changes affect all references

43
New cards

What happens here?

def f(a):
    a.append(3)

x = [1,2]
f(x)

x becomes [1,2,3]

44
New cards

What happens here?

def f(a):
    a = [3]

x = [1,2]
f(x)

x stays [1,2] (new reference only local)

45
New cards

What is the main idea of prime checking (basic)?

Test divisibility

46
New cards

What is the Sieve method?

Mark multiples as not prime

47
New cards

Gambler’s Ruin problem?

Simulate win/lose until goal or 0

48
New cards

Coupon Collector problem?

Collect all items randomly

49
New cards

Self Avoiding Random Walk?

Random movement without revisiting?

50
New cards

Why do we use simulations?

Approximate probabilities

51
New cards

How to solve big problems?

Break into functions

52
New cards

Why use helper functions?

Simplicity + reuse

53
New cards

What is abstraction?

Hide details, focus on behavior

54
New cards

How to read file data?

Open file → store content in list

55
New cards

Why store file data in list?

Easier processing

56
New cards

Biggest source of bugs?

Misunderstanding references

57
New cards

Q: What happens?

x = [1, 2]
y = x
y = y + [3]
print(x)

[1, 2]
y + [3] creates a NEW list (no mutation)

58
New cards

: What happens?

x = [1, 2]
y = x
y += [3]
print(x)

[1, 2, 3]
+= mutates list (same object)

59
New cards

What happens?

def f(a):
    a = a + [4]

x = [1, 2]
f(x)
print(x)

[1, 2]
new list created locally

60
New cards

What happens?

def f(a):
    a += [4]

x = [1, 2]
f(x)
print(x)

[1, 2, 4]
mutation affects original

61
New cards

What happens?

x = [[1], [2]]
y = x
y[0].append(9)
print(x)

[[1, 9], [2]]
nested references

62
New cards

What happens?

x = [[1], [2]]
y = x[:]
y[0].append(9)
print(x)

[[1, 9], [2]]
shallow copy → inner lists shared

63
New cards

What happens?

def f(x):
    x = 10

a = 5
f(a)
print(a)

5
integers are immutable

64
New cards

What happens?

def f(L):
    L.append(10)

a = [5]
f(a)
print(a)

[5, 10]

65
New cards

What happens?

def f(L):
    L = [10]

a = [5]
f(a)
print(a)

[5]

66
New cards

What happens?

def f(x):
    return x + 1

a = 3
f(a)
print(a)

3

67
New cards

Output?

L = [1,2,3]
for i in range(len(L)):
    L[i] += 1
print(L)

[2,3,4]

68
New cards

Output?

L = [1,2,3]
for x in L:
    x += 1
print(L)

[1,2,3]
x is copy of value

69
New cards

Output?

L = [1,2,3]
for i in range(len(L)):
    L.append(i)
print(L)

Infinite loop (grows while iterating)

70
New cards

Output?

d = {"a":1}
d["b"] = 2
print(d)

{'a':1, 'b':2}

71
New cards

Output?

d = {"a":1}
x = d
x["a"] = 5
print(d)

{'a':5}

72
New cards

What is output?

def f(n):
    if n == 0:
        return 0
    return n + f(n-1)

print(f(3))

6

73
New cards

Output?

def f(n):
    if n == 1:
        return 1
    return f(n-1) * 2

print(f(4))

8

74
New cards

What is missing?

def f(n):
    return f(n-1)

Base case → infinite recursion

75
New cards

Complexity?

for i in range(n):
    print(i)

O(n)

76
New cards

Complexity?

for i in range(n):
    for j in range(n):
        print(i,j)

O(n²)

77
New cards

Complexity?

while n > 1:
    n = n // 2	

O(log n)

78
New cards

What does this algorithm do?

while len(L) > 0:
    m = min(L)
    L.remove(m)

Extracts smallest repeatedly → sorting idea

79
New cards

What does % do?

Remainder

80
New cards

: What does this check?

if n % i == 0:

If i divides n

81
New cards

Why is Sieve faster?

Eliminate multiples instead of checking all

82
New cards

Key idea of simulation?

Repeat random trials

83
New cards

Why loop simulations many times?

Get accurate average

84
New cards

Q: Output?

x = [1,2]
y = x
x = [3,4]
print(y)

[1,2]

85
New cards

Output?

x = [1,2]
y = x
x[0] = 9
print(y)

[9,2]

86
New cards
87
New cards
88
New cards
89
New cards
90
New cards
91
New cards