3.1 Algorithms Flashcards

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

What is an algorithm?

A

A set of instructions to complete a task

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

What is decomposition?

A

Breaking down problems into sub problems until each sub problem can be solved separately

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

What is Pseudocode and its benefits?

A

-Pseudocode is a way of writing code in plain English
-Pseudocode can be translated into all other coding languages
-It can be easy to understand

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

What are terminators in a flowchart and what shape is it?

A

-A start or end
-It is oval shaped

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

What is an input/output in flowchart and what shape is it?

A

-Where a flowchart is inputting information or outputting it back to the user
-It is a parallelogram shape
-writeline and readline in VB
-OUTPUT and USERINPUT in Pseudocode

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

Which shape represents a process happening in a flowchart?

A

Rectangle

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

What is:
IF THEN…
…ELSE

A

-Form of selection
-If a certain condition is met, this code will run otherwise it will not
-logical test

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

What is:
WHILE…
…ENDWHILE

A

-Indefinite iteration
-Code is repeated until a condition is met
-Checks the condition before the code inside is executed

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

What is:
REPEAT…
…UNTIL

A

-Indefinite iteration
-Code is repeated until a condition is met
-Checks the condition after the code inside is executed

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

What is:
FOR…
…ENDFOR

A

-Definite Iteration
-Repeats the code a set number of times

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

What is USERINPUT?

A

What the user types in

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

What is OUTPUT?

A

What the computer displays onto the screen

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

What does this symbol mean?
+

A

Addition

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

What does this symbol mean? -

A

Subtration

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

What does this symbol mean?
*

A

Multiplication

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

What does this symbol mean?
/

A

Division

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

What does this symbol mean? ^

A

-Carrot
-Used for indices

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

What is DIV?

A

-Division which only returns the integer
- 9 DIV 2 = 8
- \ in VB

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

What is MOD?

A

-Division which only returns the remainder
-9 MOD 2 = 1
-Modulas

20
Q

What does this symbol mean? =

A

Equal to

21
Q

What does this symbol mean?
>

A

Greater than

22
Q

What does this symbol mean?
<

A

Less than

23
Q

What does this symbol mean?
≥ in Pseudocode
>= in VB

A

Greater than or equal to

24
Q

What does this symbol mean?
≤ in Pseudocode
=< in VB

A

Less than or equal to

25
Q

What does this symbol mean?
≠ in Pseudocode
<> in VB

A

Not equal to

26
Q

What is nested iteration?

A

In a nutshell: iteration inside of iteration

27
Q

What is meant by casting?

A

Changing from one data type to another

28
Q

What is INT_TO_STRING?

A

-Casting
-Used in Pseudocode, not VB
-Integer to string

29
Q

What is STRING_TO_INT?

A

-Casting
-Used in Pseudocode, not VB
-String to Integer

30
Q

What is an integer?

A

A whole number

31
Q

What is a real / float?

A

A decimal

32
Q

What is a string?

A

A sequence of characters

33
Q

What is a character?

A

-One character is one letter / digit / special character
-Any press on the keyboard
-A character is one byte

34
Q

What is a boolean?

A

True or False

35
Q

What is a binary search?

A

A binary search finds the midpoint of a list in ascending order and checks if the value it is looking for is in that half or not and deletes the half of which it isn’t in.

36
Q

What are pros and cons of a binary search?

A

PRO: It is much more efficient than a binary search
CON: -It has to be in order (i.e. numerical or alphabetical)
-It is hard to code

37
Q

How is the middle number found in a binary seach?

A

(n + 1) DIV 2

38
Q

What is a linear search

A

Searches through the list one item at a time

39
Q

What are the pros and cons of a linear search?

A

PRO: -The list can be ordered in any way
-Easy to code
CON: It isn’t at all efficient

40
Q

How do you find the maximum number of searches needed in a binary search?

A

2^n + 1

41
Q

How does a bubble sort work?

A

-It checks the first two numbers, if the first number is larger than the second it swaps; otherwise it doesn’t
-At the end of the pass, the largest number is left on the far right
-This is repeated until the items have been sorted

42
Q

How do you work out how many passes the bubble sort will need?

A

(amount of items on the list) - 1

43
Q

How does a merge sort work?

A

-Keeps splitting the list in half until the numbers are left individually
-Merges the numbers back together but in order

44
Q

How are two numbers/lists merged?

A

-Checks the first number from each list
-The smaller one is put first
-Checks the second number from the list which was the one with the smaller number in it
-Repeats until the lists are merged

45
Q

What are the pros and cons of a merge sort?

A

PRO - faster than a bubble sort on longer lists
CON - Uses more memory
- Harder to code than a bubble sort

46
Q

What are the pros and cons of a bubble sort?

A

PRO - Easier to code than a merge sort
CON - Less efficient than a merge sort

47
Q

What is the point of a merge or binary search?

A

To get the list into order so you can do binary searches on it