1 - Fundamentals of Algorithms Flashcards

Not to screw up

1
Q

What is an algorithm

A

A series of instructions that describes how to solve a specific problem or perform a specific task

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

What is decomposition

A

Breaking down a problem down into smaller ‘sub-problems’

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

Advantages of decomposition

A
  • Smaller problems are easier to solve than larger problems
  • Each ‘sub-problem’ can be developed separately, making planning and working to a timescale easier
  • ‘Sub-problems’ are easier to distribute among a team than one large problem
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Inputs, Initialisation, processing, outputs

A

Inputs - what data enters the system and how?
Initialisation - What variables are needed and what are their initial values?
Processing - What processes (calculations, sorts, etc.) are carried out on the inputs?
Outputs - What data leaves the system and in what format?

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

Abstraction

A

Hiding the layers of complexity within a system, in order to focus on one specific layer of complexity

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

Common methods of defining algorithms

A
  • Pseudocode

- Flowcharts

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

Pseudocode

A

A cross between English and a generic-looking programming language. While pseudocode would not compile, a competent programmer could convert it to code that would compile

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

Flow Chart

A

A means of defining an algorithm using shapes and arrows. Within each shape, an action is taking place or a decision is being made. The direction of arrows indicates which action or decision comes next

Flow charts are easier understood than pseudocode to someone who is not a programmer

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

Oval

A

This is the terminator. One is used to mark the start and another is used to mark the end. They are not used elsewhere

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

Arrow

A

Shows which instruction should take place next

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

Diamond

A

A decision. It asks a question and each arrow leaving must have a possible answer

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

Square/ rectangle

A

This is a process. Each one contains a single instruction. so complex tasks usually incorporate several processes

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

Parallelogram

A

This shape represents data that is entered into the system or output from it. Basically input or output

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

Sequence

A

A sequence is when instructions in an algorithm each need to be executed only once, and in the order in which they are written

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

Selection

A

Selection is when one sequence of instructions or another, but not both, is executed. The sequence that is executed will depend on what happened in earlier instructions.

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

Iteration

A

Iteration takes place when one or more instructions are executed more than once. Iteration is also known as repetition. Iteration is taking place when a program code (or pseudocode) contains the words LOOP, FOR, WHILE, or REPEAT.

17
Q

Trace tables

A

Interpreting an algorithm works best when you do so one line at a time, as a computer would. A trace table can and should be used to keep track of variables that change throughout the algorithm.

18
Q

Efficiency

A

A measure to compare two different algorithms that solve the same problem. A more efficient algorithm is a better choice. Efficiency can be measured in a number of different ways, the main type is TIME efficiency. An algorithm that can be executed in 20 instructions is more efficient than one that takes 30 instructions

19
Q

Searching

A

Determining whether a specific piece of data exists within a data structure. If it does exist, a search algorithm will reveal its location

20
Q

Linear search

A

A search algorithm that begins at one end of a data structure, checking each data item in turn until the required item is found, or the end of the structure is reached

21
Q

Binary search

A

A search algorithm that begins in the middle of a data structure, eliminating half of the remaining data with each pass. Binary searches are only appropriate when performed upon a sorted data structure. (Meaning that data is already ordered)

22
Q

Comparing searches

A

A binary search is more efficient that a linear search since it will, on average, find a search term more quickly than a linear search. However, binary searches do not work on unsorted data, so efficiency is not the only consideration

23
Q

Sorting

A

Putting data into order, whether that be numerical order, alphabetical order or chronological order, ascending (A-Z) or descending (Z-A)

24
Q

Bubble sort

A

Passes through the data, and swaps data that are not ascending
Keeps passing through until one lass pass proves that the data is sorted

A bubble sort only ends when a complete pass has yielded no changes or when n-1 (n being the number of elements to be sorted) passes have taken place

25
Q

Merge sort

A

Unsorted data is split into individual units
Then paired with the smaller number first
Then merged into 4’s in ascending order
Keeps merging until the whole data set is merged in ascending order

26
Q

Bubble sort vs Merge sort

A

Bubble sort:
Adv
- Straightforward to program
- Does not use much extra memory space while the sort is in progress
Dis
- Can take a very long time with a large set of data to sort

Merge sort
Adv
- More efficient in terms of time
Dis
- More complex to program
- Requires lots of memory space as it runs