Fichas
6) How do we solve problems?
Fichas del conjunto (9)
- 1Give a recursive version of Euclid's algorithmRecursive:
algorithm: Euclid(m, n)
IF n == 0:
output m
ELSE:
set m = n and n = m mod n # simultaneous assignment
Euclid(m, n) - 2Give an iterative version of Euclid's algorithmWHILE n =/ 0:
m = m - n
IF n > m:
swap m and n
output m - 3What is the fundamental difference between the research areas of formal methods and software testing when it comes to verifying that programs are correct?In formal methods, the overriding ethos is to prove things about programs. In software testing, a more pragmatic approach is taken and which involves the systematic study of program executions so as to establish program capability.
- 4Describe the key difference between recursion and iterationIteration=the repetition of a process
Recursion=the repetition of a process where the algorithm is calling itself - 5Why is the programming instruction GOTO frowned upon?It is inelegant and complicates the understanding of the semantics of an algorithm or program
- 6Describe the Towers of Hanoi problem-there are three rods and n circular rings, each of a different diameter;
-rings can be placed on rods (one at a time) but a ring can only be placed on top of another ring if the upper ring has smaller diameter;
-all rings start on rod number 1 (with smaller rings placed on top of larger rings); and
-the aim is to move the rings from rod number 1 to rod number 3. - 7What do we mean by the semantics of a programming language?The attribution of meaning to programs
- 8Explain the difference between call-by-value and call-by-referenceCall-by-value=the values of the parameter variables are passed over to the call, on return the old values take effect
Call-by-reference=the parameter variables are passed over and any changes made to these variables remain as such on return - 9Give 2 areas of Computer Science where semantics plays a significant roleSemantic Web and Combinatorics
Información
- Descripción
- Degree Engineering Fichas sobre 6) How do we solve problems?, creado por jeevanaujla97 el 30/05/2016.
- Creado por
- jeevanaujla97
- Visitas
- 1
- Valoración