everything on the mock add plain English for algs tho

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

1/69

encourage image

There's no tags or description

Looks like no tags are added yet.

70 Terms

1
New cards

linear search big o

O(n)

2
New cards

binary search

O(log(n))

3
New cards

bubble sort

O(n²)

4
New cards

stacks

last in first out data structure

implemented as an array and use a single pointer to keep track of the top of the stack - points to the element currently at the top of the stack

top is initialised at -1

5
New cards

stack functions

size() - check size

isEmpty() - check if empty

peek() - return top element but dont remove it

push(data) - add data to the top of the stack

pop() - remove top element of the stack and return removed element

6
New cards

size()

return top+1

7
New cards

isEmpty()

if top < 0:

return true

else:

return false

8
New cards

peek()

if isEmpty():

return error

else:

return list[top]

9
New cards

push(data)

top+=1

list[top] = data

10
New cards

pop()

if isEmpty()

error

else:

top-=1

return list[top+1]

11
New cards

queues

first in first out

implemented as arrays

front and back pointers

front holds position of the first element

back stores the last element

either or ^^

12
New cards

queue functions

size

isEmpty

peek

enqueue(data)

dequeue()

13
New cards

size() queues

back+1

14
New cards

isEmpty() queues

if front>back

return true

else

return false

15
New cards

peek() queues

return items[front]

16
New cards

enqueue(data) queues

back+=1

list[back] = data

17
New cards

dequeue()

if is empty

return error

else:

front+=1

return list[front-1]

18
New cards

what is sequencing

code is executed line by line top to bottom

19
New cards

what is branching

a certain block of code is run if a specific condition is met using IF statements

this is also known as selection

20
New cards

what is iteration

a block of code is executed a certain number of times or while a condition is met.

FOR / WHILE / REPEAT UNTIL

21
New cards

count controlled

iteration is repeated a given number of times (hard coded)

22
New cards

condition controlled

iteration continues until a given condition is met ( used when it is unknown how many times code needs to be repeated )

23
New cards

what is recursion

recursion is when a subroutine calls itself during its execution

this continues until a certain condition is met called the stopping condition.

must move towards the base case

24
New cards

advantages of recursion

code can be written using fewer lines of code - less prone to errors

25
New cards

what happens when a recursive function is called?

many stack frames are created within the call stack where parameters, local variables, and return addresses are stored. this info allows the subroutine to return to that particular point during its execution.

a finite number of stack frames are created until the stopping condition or base case is reached at which point the subroutine unwinds. - information from the call stack being popped off the stack.

26
New cards

disadvantages of recursion

inefficient use of memory

danger of stack overflow - call stack runs out of memory

recursion is difficult to trace

27
New cards

what is scope

scope is the section of code in which a variable is available

variables can be defined with either global or local scope

28
New cards

local varaibles

can only be accessed within the block of code in which they were defined

29
New cards

why is using local variables good practice?

it ensures that subroutines are self contained with no danger of variables being affected by code outside the subroutine

30
New cards

what are global variables

they can be accessed across the whole program

this is useful for values that need to be used by multiple parts of the program.

31
New cards

why are global variables not recommended

they can be unintentionally overwritten and edited.

they require more memory than local variables as they are not deleted until the program terminates.

32
New cards

what happens if a local and global variables have the same name

the local variable takes precedence within the subroutine.

33
New cards

what is modular programming

a techniques used to split large, complex programs into smaller, self contained modules.

this is essential to making a problem easier to understand and approach

34
New cards

benefits of a modular design

makes it easier to divide tasks between a team and manage

testing is simplified as each component can be dealt with individually.

this allows for re usability of components

35
New cards

what is the top down approach / stepwise refinement

a problem is continually broken down into sub problems until each can be represented as an individual self contained blackbox which performs a certain task

this is also known as stepwise refinement

36
New cards

what can subroutines be classified as

functions or procedures

37
New cards

functions

must always return a value - can only return one value

38
New cards

procedures

do not have to return a value

can return multiple values

typically given data as parameters for manipulation

39
New cards

passing by value

a copy of the value is passed to the subroutine and discarded at the end. the values outside of the subroutine is not affected

in exam questions, assume passed by value

40
New cards

passing by reference

the address of the parameter is given to the subroutine so the value of the parameter will be updated at the given address

41
New cards

what is an IDE

an integrated development environment is a program which provides a set of tools to make it easier for programmers to write, develop and debug code.

42
New cards

what is stepping

allows you to monitor the effect of each individual line of code by executed a single line at a time

43
New cards

what is variable watch

used to pinpoint errors by observing how the contents of a variable change in real time through the execution of a program

44
New cards

what is breakpoint

users can set a point in the program at which the program will stop.

this can be based on a condition or set to occur at a specific line. this can help to pinpoint where an error is ocurring

45
New cards

what is a source code editor

the editor aims to make coding easier by providing features such as autocompletion, indentation, syntax highlighting and automatic bracket completion

46
New cards

what are debugging tools

some ides provide run time detection of errors with a guide as to where in the code they are likely to have occurred

47
New cards

Linear search

knowt flashcard image
48
New cards

Binary search

knowt flashcard image
49
New cards

Bubble sort

knowt flashcard image
50
New cards

Insertion sort

knowt flashcard image
51
New cards

what is abstraction

the process of separating ideas from reality - hiding unnecessary detail and showing details that are important in context

52
New cards

what is an example of abstraction? where is it used

icons. When designing software and interface, abstraction often uses symbols, legends, colour-coding and icons to accentuate real life feature

icons are a great example of abstraction they can be used to suggest a function or process in a simple, efficient way

53
New cards

what is the need for abstraction?

to remove some details and highlight others to improve clarity of what is trying to be conveyed

removal of less important things to highlight the more important things

54
New cards

think of an example of abstraction in file management

when saving a file, the details of where is it stored and how is the data represented is abstracted

the users only need to be able to create, open, move, save and delete files. they dont need to know how it all happens

55
New cards

how to abstraction

remove unimportant details, add in details, change details, highlight details

56
New cards

What do you need to determine when designing a new system

the inputs the system needs

the outputs the system should produce


first decide what your system needs to output - what is its goal

once you understand what your system does, backtrack and work out the inputs it will need to produce the desir

57
New cards

what are most systems designed to produce

an output

visual, audio, haptic feedback, data to be input into another process or system

58
New cards

what should you identify when writing a computer program

the inputs, processes and outputs of a problem

59
New cards

what is a precondition

conditions that already exist and could affect how a solution to a problem is created.

whenever trying to solve a problem, it is always good to ask if there are any preconditions that you must take into consideration.

60
New cards

What is caching

an example of thinking ahead in computer architecture

instruction/data retrieved from secondary storage and placed into main memory often remain there in case they are needed again. resulting in much faster retrieval times as they don’t need to be fetched from secondary storage which is much slower compared to primary storage

61
New cards

what is prefetching

prefetching involves data being requested from main memory by the processor before it is actually needed

for prefetching to work, algorithms need to be designed to predict that an instruction or piece of data will be required soon.

a good example of this is taking your wallet out before paying to reduce time spent at checkout

62
New cards

bubble sort in english

Bubble sort repeatedly steps through a list, comparing adjacent elements and swapping them if they are in the wrong order.
Each pass moves the largest unsorted value to its correct position at the end of the list.
The process continues until no swaps are needed, meaning the list is sorted.

63
New cards

insertion sort in english

Insertion sort builds a sorted list one item at a time.
Each new element is taken and inserted into its correct position within the already sorted part of the list.
Elements greater than the current value are shifted to the right to make space for the insertion.

64
New cards

binary search in english

Binary search works on a sorted list by repeatedly dividing the search interval in half.
The middle value is compared to the target value.
If the target is smaller, the search continues in the left half; if larger, in the right half.
This process repeats until the value is found or the search space is empty.

65
New cards

linear search in english

A linear search checks each item in a list one at a time, starting from the beginning, until the required value is found or the end of the list is reached.
It does not require the list to be sorted.
If the item is found, its position is returned; otherwise, the search reports that the item is not in the list.

66
New cards

thinking concurrently

working out which parts of a program can be developed to take place at the same time / which parts are dependant on each other therefore cannot do at the same time.

67
New cards

concurrency

advancing tasks at the same time

e.g. 5 push ups 10k run

1 push up, 5k run, 4 pushups, 5k run

68
New cards

parallelism

advancing tasks at the same exact moments.

e.g 5 push ups, 10k run

cant run and pushup at the same time therefore its concurrent

so youd need another core

one does 5 push ups, one does 10k run

69
New cards

concurrent processing benefits

user can interact with applications while tasks are running in the background

a long running task wont delay short running ones

allows for parallelism


NUMBER OF TASKS COMPLETED IN A GIVEN TIME IS INCREASED

LESS TIME WASTED ON WAITING FOR USER / PROCESS IS REDUCED.

70
New cards

concurrent processing disadvantages

possibility of corrupting the consistent state of a program

tasks can suspend and wait on each other indefinitely - deadlock

threads can consume resources - harming scheduling, context switching, synchronisation