1 Flashcards

1
Q

what is a binary search?

A

looks for items in an ordered list

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

how does binary search work?

A

compare your number to the middle one

if it comes before the middle, get rid of the second half

if it comes after, get rid of the first half

repeat until you get your number

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

what is a linear search?

A

used to find items in an unsorted list

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

how does a linear search work?

A

checks each item to see if it is the correct one

if it is, it stops

if it isn’t, it continues checking until it finds it or has checked the entire list

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

what is a search algorithm?

A

computers use them to find items in a list

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

examples of search algorithms

A

binary search

linear search

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

what is a sorting algorithm?

A

used to order lists of values

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

examples of sorting algorithms?

A

bubble sort

merge sort

insertion sort

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

what is bubble sort?

A

used to sort an unordered list

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

how does bubble sort work?

A

compares two values at a time, keeps going through the list even after swapping two values

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

pros of bubble sort?

A

simple algorithm

efficient way check numbers are in order, only has to check once

doesn’t use much memory as it is done using the original list

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

cons of bubble sort?

A

inefficient way to sort a long list

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

what is merge sort?

A

divide and conquer algorithm

splits the list apart then merges it back together

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

how does merge sort work?

A

split the list in half into sub-lists until each sub list contains one item

merge pairs of sub lists and order them

repeat until you’ve merged all the sub lists together

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

pros of merge sort?

A

much more efficient and quicker than bubble

consistent running time regardless of amount of numbers

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

cons of merge sort?

A

slower than others on small lists

even if the list is sorted it goes through the whole process - taking a long time

uses more memory to create separate lists

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

what is insertion sort?

A

orders items by following one item through the list until it is in the correct place

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

how does insertion sort work?

A

follows one item until it is in the correct place then goes back to the start and follows the next number

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

pros of insertion sort?

A

can be easily coded

good with small lists

doesn’t need much additional memory

quick to check an already sorted list

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

integar

code, characteristics, example

A

int

whole number

6, 204, -987

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

real/float

code, characteristics, example

A

real

decimal number

1.00, 4.5, -7.8

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

boolean

code, characteristics, example

A

bool

either true or false

true/false, yes/no, 1/0

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

character

code, characteristics, example

A

char

a single letter, number or symbol

A, 8, !

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

string

code, characteristics, example

A

string

a collection of characters

isla!, pizzaisready, 7Azo59!?

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

what is casting?

A

changing between data types

26
Q

what is DIV?

A

how many times the number can go into the other, without a fractional part

27
Q

what is MOD?

A

the remainder after division

28
Q

= meaning

A

assigns the variable to a number

eg: age = 25

29
Q

== meaning?

A

checks if the variable/value is equal to it

eg: age == 25 (checks if age is 25)

30
Q

what is a variable?

A

stores a value that can be changed

31
Q

what is concatenation?

A

joining together two strings

32
Q

what is the process of joining together two strings?

A

concatenation

33
Q

how to concatenate?

A

use a + within speech
EG:
string1 = “my fave colour is”
string2 = “red”
newstring = string1 + “ “ + string2
print(newstring)

PRINTS: my fave colour is red

34
Q

x.upper

A

changes all characters in string x to uppercase

eg: HELLO

35
Q

x.lower

A

changes all characters in string x to lowercase

eg: hello

36
Q

x.length

A

returns the number of characters in string x

eg: 5

37
Q

what is an IF statement?

A

contains a condition

if
elif
else

38
Q

what is a FOR loop?

A

repeats a section of code a certain number of times

39
Q

what is a WHILE loop?

A

controlled by a condition which must be true

40
Q

types of boolean gates?

A

AND
OR
NOT

41
Q

what is an AND gate?

A

both inputs must be true for the outcome to be true

42
Q

what is an OR gate?

A

only one input has to be true for a true outcome

43
Q

what is a NOT gate?

A

output is the opposite of the input

44
Q

AND gate diagram

A

__
——| \__
——|__/

45
Q

OR gate diagram?

A

___
—–\ \___
—–/___/

46
Q

NOT gate diagram

A

_____|\______
|/

47
Q

what is an array?

A

a data structure that can store a collection of similar data values under one name

48
Q

what is “for i in range”

A

repeats the section of code however many times

eg: for i in range(5)

repeats five times

49
Q

how to open a file in code?

A

file = open(“file.txt”)

50
Q

what is a record?

A

stores a collection of different data types in a data structure

51
Q

what is a field?

A

an item in a record with a data type

52
Q

what does SQL stand for?

A

structured query language

53
Q

what is SQL?

A

used to search tables for specific data and output it

54
Q

how to do SQL?

A

SELECT
FROM
WHERE

55
Q

what is a sub program?

A

small programs within a larger one used to save time and simplify code

56
Q

what is a procedure?

A

a set of instructions stored under one name

57
Q

what is a function?

A

set of instructions that return a value

58
Q

what is a parameter?

A

special variables used to pass values into a sub program

59
Q

what is an argument?

A

the actual values that a parameter takes when a sub program is called

60
Q

example of a parameter?

A

(name)
(age)

61
Q

what is a local variable?

A

can be used within the structure they’re declared in

local scope

62
Q

what is a global variable?

A

can be used any time after their declaration

global scope