Unit 2 Notes

Beschreibung

Covers Recursion, Lists & Pointers, Stacks & Queues and Graphs & Trees
Jacob Pienkowski
Notiz von Jacob Pienkowski, aktualisiert more than 1 year ago
Jacob Pienkowski
Erstellt von Jacob Pienkowski vor etwa 11 Jahre
74
1

Zusammenfassung der Ressource

Seite 1

Recursion aims to solve a large problem by solving increasingly smaller instances of the problem.

The Droste effect is an example of recursion in art.

One of the common examples of recursion used in programming is a factorial. A factorial, written as n! is every number from n to 1 multiplied together.

For a recursive solution, it helps to think of n! as n * (n-1)! instead.

We can now make a solution in pseudocode:function factorial is: input: integer n such that n >= 1output: [n × (n-1) × (n-2) × … × 1] 1. if n is >= 1, return [ n × factorial(n-1) ] 2. otherwise, return 1 end factorial

function factorial(ByVal n as integer) if n >= 1 then return n * factorial(n-1) 'recursive call else return 1 end if end function sub main() console.writeline(factorial(10)) end sub 

RECURSION

Zusammenfassung anzeigen Zusammenfassung ausblenden

ähnlicher Inhalt

Cells And Cell Techniques - Flashcards (AQA AS-Level Biology)
Henry Kitchen
Computing Hardware - CPU and Memory
ollietablet123
French diet and health vocab
caitlindavies8
Biology AQA 3.1.3 Cells
evie.daines
Biology AQA 3.2.5 Mitosis
evie.daines
Biology AQA 3.1.3 Osmosis and Diffusion
evie.daines
Enzymes and Respiration
I Turner
AQA Physics P1 Quiz
Bella Statham
GCSE AQA Biology - Unit 2
James Jolliffe
GCSE AQA Biology 1 Quiz
Lilac Potato
GCSE AQA Physics 1 Energy & Efficiency
Lilac Potato