Topic 4: Computational Thinking Flashcards

1
Q

sub-procedure

define

A

A section of code in a program that does a specific job.

Can be called by name when needed without naming the details as these are wrapped in the procedure. It is therefore an example of abstraction.

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

pre-fetching / caching

define

A

Building libraries of pre-formed elements for future use (e.g. using Java libraries to increase efficiency, making sure you have your most commonly used spices ready at the front of your cupboard for cooking etc.)

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

pre-condition

define

A

Starting state before algorithm is executed, conditions that need to be fulfilled.

e.g. have to have the required ingredients, a place to cook, pre-conditions while making decisions in cooking (“Are the carrots still hard? Cook them a bit longer”).

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

post-condition

define

A

Final state after execution of algorithm, the state you are trying to achieve/ lead up to, the final result.

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

concurrent processing

define

A

execution of different instructions simultaneously by multiple processors

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

sequential/linear search

define

A

Usual search, go through every value and compare to the target value.

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

pros and cons of sequential/linear search

A

Pros:

  • Simple to implement
  • data doesn’t need to be in order.

Cons:

  • Inefficient with large number of elements – may have to go through every single one of them
  • time consuming
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

binary search

define

A

Values in order. Compare search value with middle value. If smaller, compare to middle value of sub-array to the left. If larger, compare to sub-array to the right, and so on.

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

pros and cons of binary search

A

Pros:

  • Faster than sequential search

Cons:

  • Too complicated for small number of elements
  • Only works on sorted lists
  • difficult if data is constantly being added.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

bubble sort

define

A

Compare adjacent values. If not in order, swap around

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

pros and cons of bubble sort

A

Pros:

  • Simple to write, less code

Cons:

  • Takes more time to sort – average time increases almost exponentially as number of elements increase.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

selection sort

define

A

Splits array into sub-arrays. First sub-array is sorted, second is unsorted. e.g. to sort in ascending order, find the smallest value, place it in the correct position in the first sub-array by swapping it with the element that was there, move position of beginning of sub-array forward one, loop through the rest (second sub-array) to find the smallest value again. Repeated for all elements.

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

pros and cons of selection sort

A

Pros:

  • Good for small lists

Cons:

  • Not efficient with big number of items – have to find the smallest value many times.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

collection

define

A

Group of objects.

No assumptions are made about the order of the collection (if any) or whether it can contain duplicate elements.

We add and retrieve data from them.

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

efficiency of an algorithm

define

A

Amount of computer resources required to perform algorithm’s functions

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

correctness of an algorithm

define

A

Extent to which algorithm satisfies specification

17
Q

reliability of an algorithm

define

A

Capability to maintain performance

18
Q

flexibility of an algorithm

define

A

Effort required to modify algorithm for other purposes

19
Q

Fundamental operations of a computer

A
  • Adding (and subtracting) values
  • Comparing values/data
  • Retrieving data
  • Storing data
20
Q

Machine language

define

A

Low-level language directly understood by computer, made up of binary numbers

21
Q

Assembly language

define

A

Low-level language using symbols for instructions and memory addresses

22
Q

High-level programming language

A

Uses elements of natural language. Easy to use for humans and more understandable.

Abstracts some areas of computing systems, would otherwise take too long to write our systems in machine code.

23
Q

What do programming languages need to have?

characteristics of programming languages

A
  • Fixed vocabulary - Instructions for operations do not change. e.g. “print” will always print
  • Unambiguous meaning - Clear instructions
  • Consistent grammar and syntax - The way we declare and use language features must be the same.
  • Provide a way to define basic data types and operations on those types - ability to write functions/procedures
  • It has to run on/be able to be processed by a computer - it must have a compiler/interpreter
24
Q

source code

define

A

Original code/program developed using high level language. Needs to be translated into machine code to be run/executed by the computer.

25
Q

object/target program

define

A

Program translated into machine language.

26
Q

methods of translating a source code into a target program

A

Compiler: Executes translation process only once, translates the whole program. Object program is saved so it doesn’t need to be compiled again. All errors are displayed when the whole program is checked, compilation ends only once errors are fixed. Example: C++

Interpreter: Reads, translates and executes program line by line. Errors are displayed after each line is interpreted. Goes through the process every time the program is run, much slower than a compiler. Example: BASIC

27
Q

variable

define

A

Used to store a data element that can be changed during program execution. Has an identifier and type.

28
Q

constant

define

A

Elements and quantities that don’t change.

e.g. final double PI = 3.14

29
Q

object

define

A

Comprised of data and methods (operations that can be performed by the object)

30
Q

Advantages of breaking down into sub-programs

A
  • Breaking complex job into simpler tasks
  • Distributing program amongst different programmers
  • Code reuse across multiple programs
  • Reducing code duplication in program
31
Q

Advantages of collections

A
  • Methods are predefined algorithms, can immediately use
  • Software reuse