Topic 6 -Algorithms Flashcards

1
Q

What are 3 key techniques for computational thinking?

A
  • decomposition
  • abstracton
  • algorithmic thinking
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is decomposition?

A

breaking a complex problem down into smaller problems and solving each one individually

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

What is abstraction?

A

picking out the important bits of information from the problem, ignoring the specific details that dont matter

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

What is alghorithmic thinking?

A

a logical way of getting from the problem to the solution

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

What is an algorithm?

A

A set of instructions for solving a problem

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

What does START do in pseudocode?

A

Marks the beginning of the pseudocode.
Example: START

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

What does END do in pseudocode?

A

Marks the end of the pseudocode.
Example: END

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

What does INPUT do in pseudocode?

A

Requests data from the user or another source (like a file)
Example: INPUT age

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

What does OUTPUT do in pseudocode?

A

Displays information to the user.
Example: OUTPUT "Hello, World!"

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

What does IF…THEN…ELSE do in pseudocode?

A

A conditional structure used to make decisions.
Example:
~~~
IF number > 10 THEN
OUTPUT “Greater than 10”
ELSE
OUTPUT “10 or less”
END IF
~~~

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

What does WHILE…DO do in pseudocode?

A

A loop that repeats while a condition is true.
Example:
~~~
WHILE number > 0 DO
OUTPUT “Positive number”
number = number - 1
END WHILE
~~~

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

What does FOR…TO do in pseudocode?

A

A loop that runs a specific number of times.
Example:

FOR i = 1 TO 10 DO
   OUTPUT i
END FOR
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What does REPEAT…UNTIL do in pseudocode?

A

Similar to WHILE, but it checks the condition after the loop, meaning the loop runs at least once.
Example:

REPEAT
   OUTPUT "Enter a number"
   INPUT number
UNTIL number > 0
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What does END IF do in pseudocode?

A

Marks the end of an IF statement
Example:

IF number > 10 THEN
   OUTPUT "Greater than 10"
ELSE
   OUTPUT "10 or less"
END IF
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What does RETURN do in pseudocode?

A

Returns a value from a function or procedure.
Example:
RETURN sum

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

How is a start/stop represented in a flow chart?

A

A rounded rectangle and the beginning and the end of the algorithm

17
Q

How is a input/output represented in a flow chart?

A

Anything that is put into or displayed in the algorithm is shown as a parallelogram

18
Q

How is a process represented in a flow chart?

A

General instructions, processes and calculations are shown as normal rectangular boxes

19
Q

How is a decision represented in a flow chart?

A

Decisions, often a yes or no question is shown as a diamond box

20
Q

How is a subroutine represented in a flow chart?

A

They are like sub programs- referencing other flow diagrams- shown as a rectangle with a verticle line on both sides

21
Q

What connects each shape in a flowchart and show the direction to go?

22
Q

What does a binary search do?

A

looks for items in an ordered list

23
Q

Whats the steps of binary search?

divide and conquer

A
  • find the middle item (n+1)/2 and round down if needed
  • compare it with the target:
  • if it’s the target, you’re done
  • if the target is smaller, repeat with the left half
  • if the target is larger, repeat with the right half
  • repeat steps until the item is found
24
Q

What does a linear search do?

A

look for items in an unordered list

25
Whats the steps of linear search?
* look at the first item in the list. * check if it’s the target. * if not, move to the next item. * repeat until you find it
26
What does bubble sort do?
compares pairs of items to sort an unordered list
27
Whats the steps of bubble sort?
* look at the first two items in the list * if they are in the right order, don't do anything, if not, swap them * move onto the next pair and then repeat step 2 * repeat step 3 until the highest number bubbles to the end- this is called one pass * repeat steps 1 to 4 until there are no swaps in a pass
28
What does a merge sort do?
splits the list apart then merges it back together
29
Whats the steps of merge sort? | divide and conquer
* split the list in half * keeping splitting the sub-lists until there is only one item in each list * merge and order the sub-lists back together * keep on merging the sublists until you only have one list
30
What is an insertion sort?
orders the items as it goes
31
How does insertion sort work?
* llook at the second item * compare it to all the items before it and inset it into the right place * repeat step two for the third,fourth,fifth, ect until the last number in the list has been inserted into the correct place