Theory of Computation

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall with Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/53

flashcard set

Earn XP

Description and Tags

computer systems, abstraction, decomposition, pattern recognition, algorithms, information hiding

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No study sessions yet.

54 Terms

1
New cards

define computation

processing something through mathematical/ logical/ interactive methods

2
New cards

define computability

measures what can/ can’t be processed

(non-computable programs = programs that can NEVER be processed)

3
New cards

define logical reasoning

using a set of facts to determine if new facts are true/ false

4
New cards

what are the basic components of a computer system?

  • convert human input to binary

  • computer processes binary data

  • binary data converted to ascii output

<ul><li><p>convert human input to binary</p></li><li><p>computer processes binary data</p></li><li><p>binary data converted to ascii output</p></li></ul><p></p>
5
New cards

what are the 4 components that make up computational thinking

abstraction

decomposition

pattern recognition

algorithm

6
New cards

define abstraction

taking most important components needed to solve problem & separating them from rest

7
New cards

define decomposition

breaking down problem into smaller (easier to solve) sub programs

8
New cards

define pattern recognition

finding similar approaches to solve problem and adapt them to solve current one

9
New cards

define algorithm

representing solution as a sequence of steps (step by step instructions needed to solve problem)

10
New cards

how do computers work? basic

an algorithm is run on a computer by translating it into a sequence of computer instructions

this is converted to binary (uses switches for 1s and 0s) where computer reacts to voltages on wires

11
New cards

what does it mean to automate a program?

automation: idea that computer programmer turns algorithm into computer program for computer to execute

e.g. paint onto car

12
New cards

three types of abstraction

  • representational abstraction

  • abstraction by generalisation

  • problem abstraction

13
New cards

what is abstraction by generalisation

reducing problem by putting similar aspects of the problem into hierarchical categories

<p>reducing problem by <strong>putting similar aspects </strong>of the problem into <strong>hierarchical categories   </strong></p>
14
New cards

explain problem abstraction and give an example

removing unnecessary details until underlying problem is identified to see if it has already been solved

e.g. pigeon hole principle

15
New cards

what is representation abstraction

removing details from problem until it becomes possible to represent problem in a way that it is possible to solve

16
New cards

what is the purpose of user interface?

  • hides complexity of program

  • easily operate computer

  • users are satisfied

  • makes program more popular

17
New cards

define information hiding and describe its uses in programming

  • hides details of object which do not contribute to essential characteristics

  • In programming:

    • Well designed program has a solution in which source code is divided into self-contained modules. Programmer works on module so do not need to know all detail contained in other programmer modules. This makes it easier as they are local rather than global changes.

    • Function age(DofB as date, today as date) as integer

18
New cards

describe decomposition with an example

top-down design: modular approach where main system is at top and then broken down into smaller & smaller units

procedural decomposition: problem is divided into smaller parts and then solved independently. they are then written and tested separately before being integrated into the larger problem

<p>top-down design: modular approach where<u> main system is at top</u> and then broken down into smaller &amp; <u>smaller units</u></p><p></p><p>procedural decomposition: problem is divided into smaller parts and then solved independently. they are then written and tested separately before being integrated into the larger problem</p>
19
New cards

benefits of using decomposition:

  • starting point in the aim of a project

    • helps users and the system analysts reach an early agreement about what the major functions should be

  • works through ‘logical’ design

    • not restricted by ‘physical’ attributes of programming language

    • result is more portable designs

20
New cards

why is procedural decomposition helpful?

  • makes programs more modular

  • easier to:

    • understand

    • debug

    • maintain

21
New cards

outline modular design:

  • number of small modules are written

  • each module has a clear objective/ specific function

  • each module may be a complete system in itself/ an executable file or subroutine

  • they are independently designed, programmed and maintained

  • modules are then put together in a larger structure

  • each module will have a single entry-entry and exit point

  • + can be easier to program

  • - may result in an inefficient system

  • - project can veer towards a bottom-up design

<ul><li><p>number of small modules are written</p></li><li><p>each module has a clear objective/ specific function</p></li><li><p>each module may be a complete system in itself/ an executable file or subroutine</p></li><li><p>they are independently designed, programmed and maintained</p></li><li><p>modules are then put together in a larger structure</p></li><li><p>each module will have a single entry-entry and exit point</p></li><li><p>+ can be easier to program </p></li><li><p>- may result in an inefficient system</p></li><li><p>- project can veer towards a bottom-up design</p><p></p></li></ul><p></p>
22
New cards

clear advantages for using modular design

  • separate programmers can be working on modules individually

  • programmer is only concerned for their part of the system so programming is easier

  • flow of data can be traced far more easily through program

  • debugging is made easier as errors can be traced back to a single module

23
New cards

define computational complexity

how economic the algorithm is with time and space

24
New cards

why is computational complexity used?

allows us to compare algorithms as there may be multiple algorithms for achieving a solution to a problem and they may vary considerably in their speed and use of memory

25
New cards

time complexity

algorithm indicates how fast it runs

26
New cards

space complexity

algorithm indicates how much memory algorithm needs (memory footprint)

27
New cards

worst case complexity

algorithm takes longest time or greatest workload

28
New cards

best case complexity

algorithm takes shortest time or smallest workload

29
New cards

how is average case complexity calculated

calculating arithmetic mean for all possible inputs

30
New cards

describe the 2 ways of measuring complexity of algorithm and evaluate

  • algorithm written in programming language an then run on computer and timed

    • CRUDE way because it is dependent on:

      • speed of computer

      • efficiency of programming language

      • length of list

  • measure speed of algorithm

    • better because it’s based on number of operations it requires to be carried out

31
New cards

how come the length of list (data) and algorithm is important factor of time complexity?

if we have a bubble sort for 5 numbers, it's efficient. If we have a bubble sort for 1 million numbers, it's not efficient.

therefore, the length of the list is an important factor.

<p>if we have a bubble sort for 5 numbers, it's efficient. If we have a bubble sort for 1 million numbers, it's not efficient.</p><p>therefore, the length of the list is an important factor.</p>
32
New cards

how to calculate execution time in algorithms: BASIC RULES

number of times loops repeat relates to size of input, denoted by n

when statements are simply evaluated sequentially by computer, it takes constant amount of time to execute, denoted by k

  • easy to count few instructions but when it becomes more complex we calculate time complexity using operation of algorithm

<p>number of times loops repeat relates to size of input, denoted by <strong>n</strong></p><p>when statements are simply evaluated sequentially by computer, it takes constant amount of time to execute, denoted by <strong>k</strong></p><p></p><p></p><ul><li><p>easy to count few instructions but when it becomes more complex we calculate time complexity using operation of algorithm</p></li></ul><p></p>
33
New cards

how to calculate execution time in algorithms: FOR LOOPS

For loop condition is executed n+1 times since it requires one extra check to see whether terminating condition has been satisfied

<p>For loop condition is executed <em>n+1</em> times since it requires one extra check to see whether terminating condition has been satisfied</p>
34
New cards

how to calculate execution time in algorithms: FOR LOOPS

execution times within inner FOR loop will be multiplied by those of outer loop. this produces a polynomial

<p>execution times within inner FOR loop will be multiplied by those of outer loop. this produces a polynomial </p>
35
New cards

Basic operation

operation contributing most total running time

36
New cards

asymptotic behaviour

idea that as amount of data changes, difference between two algorithms increases

in mathsy terms: behaviour of function f(n) for very large values of n

<p>idea that as <strong>amount of data changes, difference</strong> <strong>between two algorithms increases</strong> </p><p></p><p>in mathsy terms: behaviour of function <em>f(n)</em> for very large values of <em>n</em></p>
37
New cards

what is Big O notation

analysis of an time complexity considering worst-case scenario and provides notation for upper bound running of a function

38
New cards

state the functions & Big O notation for:

  • linear

  • polynomial

  • exponential

  • logarithmic

exponential:

  • function: y = 2x

  • Big O notation: O (an) e.g. O (3n)

polynomial:

  • function: y = 2x2

  • Big O notation: O (na) e.g. O (n3)

linear:

  • function: y = 2x

  • Big O notation: O (n)

logarithmic:

  • function: y = log10 x

  • Big O notation: O (log n)

39
New cards

exponential time algorithms:

  • take very long time to compute

  • growth takes form Kx, where K is constant and x = 1,2,3….

  • e.g. recursive Fibonacci numbers & recursive factorial calculations

<ul><li><p>take very long time to compute</p></li><li><p>growth takes form <em>K<sup>x</sup>, </em>where K is constant and x = 1,2,3….</p></li><li><p>e.g. recursive Fibonacci numbers &amp; recursive factorial calculations</p></li></ul><p></p>
40
New cards

polynomial time algorithms

  • mostly use nested loops

  • growth has form xk where K is a constant and x = 1,2,3…

  • e.g. bubble and insertion sorts

<ul><li><p>mostly use nested loops</p></li><li><p>growth has form <em>x<sup>k</sup> </em>where K is a constant and x = 1,2,3…</p></li><li><p>e.g. bubble and insertion sorts</p></li></ul><p></p>
41
New cards

linear time algorithms

  • go through data step by step

  • growth has mx + c (← normal calculation for gradient of line we learnt in gcse math)

  • e.g. linear search

<ul><li><p>go through data step by step</p></li><li><p>growth has mx + c (← normal calculation for gradient of line we learnt in gcse math)</p></li><li><p>e.g. linear search </p></li></ul><p></p>
42
New cards

logarithmic time algorithms

  • EXECUTION time does NOT increase as fast as IPUT size

  • n is halved each cycle since log2 is used to see how many times we can multiply number by 2 until answer is reached

  • e.g. binary search & binary tree search

<ul><li><p>EXECUTION time does NOT increase as fast as IPUT size</p></li><li><p>n is halved each cycle since log2 is used to see how many times we can multiply number by 2 until answer is reached</p></li><li><p>e.g. binary search &amp; binary tree search</p></li></ul><p></p>
43
New cards

constant time algorithm

  • time complexity remains same regardless of number of inputs

  • e.g. finding first item in list

<ul><li><p>time complexity remains same regardless of number of inputs</p></li><li><p>e.g. finding first item in list </p></li></ul><p></p>
44
New cards

draw the order of complexity graph:

most time consuming/ worst case scenario

  • factorial

  • exponential

  • polynomial

  • linear

  • logarithmic

least time consuming/ best case scenario

<p>most time consuming/ worst case scenario </p><ul><li><p>factorial</p></li><li><p>exponential</p></li><li><p>polynomial</p></li><li><p>linear</p></li><li><p>logarithmic</p></li></ul><p>least time consuming/ best case scenario</p>
45
New cards

Big-O Rules:

<p></p>
46
New cards

how to express functions as Big-O

  • only look at section that changes most significantly, make rest redundant

    • take off term from function which would give largest number

<ul><li><p>only look at section that changes most significantly, make rest redundant</p><ul><li><p>take off term from function which would give largest number</p></li></ul></li></ul><p></p>
47
New cards

state the best/ave./wost case time complexity for searching algorithms

knowt flashcard image
48
New cards

state the best/ave./wost case time complexity for sorting algorithms

<p></p>
49
New cards

define tractable problems + state an example

problem that can be solved in acceptable amount of time

  • e.g. searching ordered list

50
New cards

define intractable problems + state an example

problems that can be solved but not in an acceptable time frame

  • e.g. travelling salesman (has to travel between cities. distance between each pair of cities is known. he must visit each city once and return to start point. must calculate shortest route)

51
New cards

how are interactable problems tackled?

programmer produces heuristic algorithm

52
New cards

what are heuristic algorithms

method for producing a “rule of thumb“ to produce an acceptable solution to common sets of data and interactable programs within acceptable time frame

  • unlikely to produce optimal results but can produce results which are satisfactory in acceptable time frame

53
New cards

computable problems

problems that have effective procedure/ algorithm to solve them. contain finite set of instructions

54
New cards

non computable problems

never be able to be solved using a computer, irrespective of processing power

e.g. halting problem

<p>never be able to be solved using a computer, irrespective of processing power</p><p></p><p>e.g. halting problem </p>