V8 Flashcards

Algorithms and Functions

1
Q

what are algorithms

A
  • a list of a discrete number of steps that, when followed, will complete a certain task (or fail)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

state diagrams

A

used to describe the behaviour pf a system
- visualisation of an algorithm
very similar to a flow chart
- state diagrams respond to actions/events
- flowcharts do not need explicit events

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

for/for each loop

A
  • modelled very close to natural language

- > for(x in 1:ncol(M)) = for each x going from 1 to the umber of columns in M

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

while loop

A
  • less natural bur more flexible
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

design pattern

A
  • general reusable solution to a commonly occurring problem within a given context in software design
  • not a finished design that can be transformed directly into source or machine code, is a template for how to solve a problem that can be used in many different situations
  • to avoid reinventing the wheel
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

design patterns: some examples

A
  • model view controller(MVC): used in web development
  • monte carlo sampling: everything that might happen , used in genetics, economics, agriculture, etc.
  • facade pattern - provide a stable call - interface
  • scheduler - ways to schedule tasks in a certain time
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

recursion + example sum up 7 (calculates 1+2+3+4+5+6+7)

A
  • a function calling itself
  • a simple base case (or cases)
  • rules that reduce all other cases toward the base case

example:

sumUp

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

important notes for recursion

A
  • hand weird/unexpected input
  • there is a recursion limit in R
  • > set limit by : options(expressions = 500)
  • every time we call our function : a new function call is created, internal variables need to be stored
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
  • recursion invariant
A

sumUp if input negative then the ‘ summing up’ becomes infinite
- there is no stop for negative numbers

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

why use recursion

A
  • in many programming languages - more efficient, cleaner code, often more in line to how people think about problems
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

indirect recursions

A

then can return different functions within each other

-> that makes them indirect - what the purpose of this is, i have no idea

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