Algorithms and programs Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

what is an algorithm?

A

set of sequential steps that are followed in order to complete a task.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

how can you represent an algorithm?

A

pseudocode
flowcharts

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

what is a variable?

A

named location in the computer’s memory that a programmer can use to store data whilst the program is running.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what is the scope of a variable?

A

the time that a variable is accessible and if it is local or global

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

how to make your code understandable to other programmers?

A

self-documenting identifiers, annotation and program layout

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

function vs procedure

A

function is a subroutine that returns a value while a procedure is a subroutine that doesn’t

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

passing a parameter by value

A

a copy of the data is passed into the procedure and cannot be altered - avoids accidental value changes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

passing a parameter by reference

A

a copy of the memory address is passed into the procedure - data in the calling environment can be changed by the subroutine.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

recursive function

A

calls itself until a base case is met - allows the same operation to be carried out a number of times.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

key validation checks

A

type check - correct data type
length check
range check - numeric values within certain range
format check - data conforms to set of rules
existence check
check digit

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

typical answer to big O of storage

A

O(1)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

pros of linear search

A

easy to program
fast with small data sets
data doesn’t need to be sorted

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

linear search cons

A

not efficient if item at the end of the array
very slow with large data sets

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

binary search pros

A

fast for large set of numbers
divide and conquer so adding large numbers doesn’t incrementally increase search time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

binary search cons

A

data must be sorted
more complex to program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly