All of Computer Science Paper One

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

1/193

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 7:23 PM on 6/7/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

194 Terms

1
New cards

Regular language

any language that can be described using regular expressions

2
New cards

Regular expression

notation (ab*,a+) that represents all elements of a set

3
New cards

Context-free languages

a way of describing the syntax of a language when the syntax is complex (e.g. palindrome). Used when counting and matching is infinite

4
New cards

Backus-Naur Form

a form of notation describing the syntax used by a programming language

  • method of context-free language

  • produces a set of acceptable strings (describing the rules of the language)

e.g. <Integer> ::= <Digit>|<Digit><Integer>

5
New cards

Terminal

the final element that requires no further rules

6
New cards

Syntax diagram

a way to represent BNF expressions or any context-free language

7
New cards

A set

A set is a collection of unordered, unique values (only appears once)

8
New cards

cartesian product

combining the elements of two or more sets to create a set of unordered pairs

e.g.
A = {1, 2}

B = {x, y}
then A × B = {(1, x), (1, y), (2, x), (2, y)}

9
New cards

Finite State machines

  • Any device that changes state based on an input

10
New cards

State transition diagram

  • a visual representation of finite state machines using circles and arrows

  • double circle - end state

11
New cards

State transition table

  • a table to represent an FSM by showing its inputs, current state and next state

12
New cards

Mealy machine

  • a finite state machine with outputs

13
New cards

Turing Machine

a type of finite state machine that reads and writes data to an unlimited tape

14
New cards

How does a Turing Machine operate

  • the tape is used as memory and is divided into many cells

  • the read write head can either read the cell or write into it

  • the machine can halt at any point if the 'halting state' is entered or if the input has been processed fully

15
New cards

Universal Machine

  • a machine simulating other turing machines by reading a description of the machine with the inputs of its own tape

  • (turing machines linked together with one tape)

16
New cards

Constant O(C)

time independent of input (e.g. determining if a number is odd or even)

17
New cards

Logarithmic - O(log2(n))

halves items per iteration (e.g. binary)

18
New cards

linear O(n)

worst case scenario, goes through every item (e.g. linear)

19
New cards

linear logarithmic

o(nlog(n)) - merge sort

20
New cards

polynomial O(n2)

bubble sort

21
New cards

Exponential O(2n)

Cannot be solved, intractable - recursively calculating fibonacci numbers

22
New cards

Factorial O(n!)

intractable - travelers problem

23
New cards

graphs for BigO

knowt flashcard image
24
New cards

Algorithm

a sequence of steps that can be followed to complete a task that always terminates

25
New cards

tractable problems

problems that have a polynomial (or less) time solution

26
New cards

intractable problems

problems that have a longer time solution than polynomial

27
New cards

representational abstraction

Removes unnecessary details from the problem

28
New cards

abstraction by generalisation

Groups common characteristics

29
New cards

Information hiding

 hiding unessential details of an object

30
New cards

Procedural abstraction

breaking down a complex model into reusable procedures

31
New cards

Functional abstraction

disregards the particular method of a procedure and results in just a function

32
New cards

Data abstraction

hiding specific details of how data is represented to create new data structures

33
New cards

Problem abstraction/reduction

 removing details from a  problem until its solvable

34
New cards

Decomposition

 breaking down a problem into small sub-problems to be solved individually

35
New cards

Composition

combining procedures to form a larger system

36
New cards

Automation

putting abstractions of real world phenomena into actions by creating algorithms

37
New cards

Halting Problem

Process of writing a program to test if another program will halt from given inputs without running the given program

The halting problem demonstrates that there are some problems that cannot be solved

38
New cards

Depth-first

Fully explores branch before backtracking
Uses a stack

e.g. navigating a maze

39
New cards

Breadth-first

searches left to right in rows from the top (level by level)

uses a queue

e.g. shortest path for an unweighted graph

40
New cards

tree traversal orders (pre,in,post)

pre-order: VLR

in-order: LVR

post-order: LRV

41
New cards

Linear Search

Searches every item in a list

List can be unordered

O(N)

42
New cards

Binary Search

Looks at the midpoint of a list and determines if the target is higher or lower than the midpoint until it is found

Time halves each search

Requires an ordered list

O(logN)

43
New cards

Binary tree search

Compares child nodes on a binary tree to see if its higher/lower

O(logN)

44
New cards

Bubble sort

Makes passes through data and swaps adjacent items until no swaps are performed

O(n2)

45
New cards

Merge sort

Divides array up into sorted lists and merges them together

O(nlogn)

46
New cards

Dijkstra’s algorithm

works out the shortest path between a single source and every other vertex on weighted graphs, producing the shortest path tree

47
New cards

Tracing Dijkstra’s algorithm

  1. starting with A, list all the connections to other nodes, marking unconnected nodes as infinity

  2. the smallest number from this row is the next row's node

  3. B was the smallest so next we list all the connections from B to other nodes as before.

48
New cards

what does pre-order traversal do on a tree

copies the tree

49
New cards

what does in-order traversal do on a tree

sorted output for BST

50
New cards

what does post-order traversal do on a tree

delete tree

51
New cards

What are data structures

methods for storing information on a computer

52
New cards

Why are there multiple data structures?

Depending on the usecase, different complexities and efficiencies are needed

53
New cards

Arrays

A finite indexed set of related elements (of the same data type)

54
New cards

What are files made up of (records/fields)

Each file is made up of records, composed of fields

55
New cards

Characteristics of static datatypes

  • amount of memory set prior by the programmer

  • fixed in size

  • fast access speeds

    • cannot grow/shrink in size (results in memory wastage or overflow)

56
New cards

Characteristics of dynamic data structures

  • Flexible in size

  • Efficient memory use

  • Slower access

  • Requires more memory

  • Increased complexity

57
New cards

Why are graphs used

to represent complex relationships between items (e.g. networks - transport, IT, the internet)

58
New cards

What do graphs consist of

nodes, joined by edges

59
New cards

Weighted vs unweighted graphs

Weighted graphs assign values to an edge (e.g. time, distance, cost)

60
New cards

Directed vs undirected graphs

Edges have directions, connecting nodes to each other

61
New cards

Adjacency list

Stores every possible connection per node

A: B,C,D
B: A,C,E

62
New cards

Adjacency matrix

Stores all possible connections that exist on a table (1 = edge exist, 0 = no edge)

63
New cards

Adjacency List advantages

Adjacency List is quicker for lookups (searched by row/column) and is suited for sparse graphs with lots of connections

64
New cards

Adjacency List disadvantages

More complex to implement

65
New cards

Adjacency Matrix advantages

Suited for dense graphs with less connections
O(1) lookup time

66
New cards

Disadvantages of Adjacency matrixes

wastes space if there a few edges

67
New cards

Tree characteristics

  • connected

  • undirected

  • no loops

68
New cards

Rooted trees

all nodes stem from root/parent node

69
New cards

Leaf nodes

Nodes with no children

70
New cards

Binary trees characteristics

  • has a root node

  • two or less child nodes

Used in file management on computers

71
New cards

how does a hashing algorithm work

hashing algorithm takes an input (key) and returns a hash, that aims to be unique to its input.

the result of the hash is the index of the key-value pair in the hash table.

72
New cards

what is a hash table

a way of storing data that allows it to be retrieved with a constant time complexity O(1) made up of a table containing the data and key

73
New cards

advantages of hashing

faster to lookup and search

74
New cards

disadvantages of hashing

hard to design

risk of collisions

75
New cards

two ways to how to handle hashing collisions

  • chaining

  • rehashing

76
New cards

what is chaining

creating a linked list for duplicated indexs

77
New cards

what is rehashing

recalculating the hashing algorithm to provide a new index until it finds an empty slot or using an alternative hashing algorithm

78
New cards

dictionaires

a data structure that stores key-value pairs

79
New cards

how do dictionaries work?

a dictionary maps keys to data (associative array), where the keys identifiy the location of the data. this can be done by implementing a hash table to calculate the key.

for example:

Car = {"make": " toyota"}

Car["make"]

or

Car = {}

Car["make"] = "toyota"

80
New cards

dot product

dot product of A = [12,3] and B = [5,8]
= (12×5) + (3×8) = 84

81
New cards

what does scaling a vector do (magnitude/direction)

magnitude changes, direction remains the same

82
New cards

Access order in Queues

FIFO (first in, first out)

83
New cards

Usecase of queues

Computer keyboards → letters appear in order typed

84
New cards

Enqueuing an item to a linear queue

  1. Check if full - if full → error

  2. If empty, set front to 0

  3. Increment rear and insert value at rear

85
New cards

Dequeuing an item from a linear queue

  1. Check queue isn’t empty - if empty → error

  2. Remove item at front

  3. Increment front pointer

86
New cards

Benefits of circular queues

Reuses empty spaces, wrapping the array around itself

87
New cards

Enqueuing to a circular queue

  1. Check if queue is full → error

  2. Compare rear pointer with maximum size of array

  3. If not empty, rear pointer increments and item added to new rear position

88
New cards

Dequeuing from circular queue

  1. Check if queue is empty → error

  2. If not, dequeue front item in queue

  3. Reduce size of queue

  4. Check if front pointer is at the end of the array, if it is set to first position. Else, add 1 to front pointer

89
New cards

Priority queue advantages

Higher priority elements are removed first

Equal prioriy elements = standard FIFO order

90
New cards

Elements in priority queue are based on

their priority, with elements being shifted when added

91
New cards

Usecase for priority queues

Processor scheduling

92
New cards

Access order in stacks

LIFO (last in, first out)

93
New cards

Adding to a stack

Push

  1. check if full

  1. Increment top

  2. Inset item at top

94
New cards

Remove item from stack

Pop

  1. Check if empty

  2. Remove elements from top

  3. Decrement top

95
New cards

Peek operation

Returns item at top

96
New cards

Checking if stack is full/empty

  • IsFull

  • IsEmpty

97
New cards

Binary search trees

  • used for efficient searching

  • searches left, then root, then right

98
New cards

div symbol

//

99
New cards

mod symbol

%

100
New cards

normal division

/