Section 1 - Fundamentals of algorithms Flashcards

1
Q

What is the definition of an algorithm?

A

Algorithm:

— A series of steps that are followed in order to solve a problem.

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

What does decomposition mean?

A

Decomposition:

— Breaking down a problem into smaller, more manageable sub-problems.

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

What is abstraction?

A

Abstraction:

— Removing unnecessary details from a problem to make it easier to solve.

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

What are the flowchart symbols and what are they used for in a flowchart?

A
  • – Oval: used to START and END the flowchart
  • – Parallelogram: used to input/output instructions
  • – Diamond: decision box that only accepts yes and no answers
  • – Rectangle: process box
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the three programming constructs? Explain them in detail.

A
  • – Sequence: writing down steps in the order they happen
  • – Selection: picking between different options using IF…THEN…ELSE
  • – Iteration: looping a program using FOR…ENDFOR, REPEAT…UNTIL, WHILE…ENDWHILE
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the two ways to search an algorithm? Explain both in detail.

A
  • – Linear search: When data in unsorted, every item is checked till the item being looked for is found
  • – Binary search: When data is sorted, the data is continously divided into half and examined till the one you are looking for is found
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Compare a linear and binary search.

A

A linear search is beneficial when there aren’t a lot of items in a list but if there a lot of items then a binary search would be more efficient because since half the list is discarded each time, you don’t have to search as many items.

If you need to recognise which search is being shown in a program, look to see if there is a dividing by 2 and that will tell you it is a binary search.

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

What are the two ways to sort an algorithm? Explain in detail

A
  • – Bubble sort: the list is repeatedly gone through and items are compared then swapped if the items are in the wrong order. The number of passes is the number of items in the list -1
  • – Merge sort: the list is continuously divided into half forming sublists until there is only sublists of one length. The items in the sublists are then merged into pairs in the correct order until all items are merged and there is only one list remaining.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Compare a bubble sort and merge sort.

A

A bubble sort is very time consuming and inefficient when sorting through a list of more than about eight items because it requires a lot of passes through the list before the list is sorted. The merge sort is more effective because it takes less time to execute however it can be hard for an inexperienced programmer as it requires a lot more programming. A merge sort also requires a lot of memory to store the lists which can be a problem if the list is large.

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