1 Flashcards

(62 cards)

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
what is casting?
changing between data types
26
what is DIV?
how many times the number can go into the other, without a fractional part
27
what is MOD?
the remainder after division
28
= meaning
assigns the variable to a number eg: age = 25
29
== meaning?
checks if the variable/value is equal to it eg: age == 25 (checks if age is 25)
30
what is a variable?
stores a value that can be changed
31
what is concatenation?
joining together two strings
32
what is the process of joining together two strings?
concatenation
33
how to concatenate?
use a + within speech EG: string1 = "my fave colour is" string2 = "red" newstring = string1 + " " + string2 print(newstring) PRINTS: my fave colour is red
34
x.upper
changes all characters in string x to uppercase eg: HELLO
35
x.lower
changes all characters in string x to lowercase eg: hello
36
x.length
returns the number of characters in string x eg: 5
37
what is an IF statement?
contains a condition if elif else
38
what is a FOR loop?
repeats a section of code a certain number of times
39
what is a WHILE loop?
controlled by a condition which must be true
40
types of boolean gates?
AND OR NOT
41
what is an AND gate?
both inputs must be true for the outcome to be true
42
what is an OR gate?
only one input has to be true for a true outcome
43
what is a NOT gate?
output is the opposite of the input
44
AND gate diagram
__ ------| \__ ------|__/
45
OR gate diagram?
___ -----\ \___ -----/___/
46
NOT gate diagram
_____|\______ |/
47
what is an array?
a data structure that can store a collection of similar data values under one name
48
what is "for i in range"
repeats the section of code however many times eg: for i in range(5) repeats five times
49
how to open a file in code?
file = open("file.txt")
50
what is a record?
stores a collection of different data types in a data structure
51
what is a field?
an item in a record with a data type
52
what does SQL stand for?
structured query language
53
what is SQL?
used to search tables for specific data and output it
54
how to do SQL?
SELECT FROM WHERE
55
what is a sub program?
small programs within a larger one used to save time and simplify code
56
what is a procedure?
a set of instructions stored under one name
57
what is a function?
set of instructions that return a value
58
what is a parameter?
special variables used to pass values into a sub program
59
what is an argument?
the actual values that a parameter takes when a sub program is called
60
example of a parameter?
(name) (age)
61
what is a local variable?
can be used within the structure they're declared in local scope
62
what is a global variable?
can be used any time after their declaration global scope