2.2 Problem solving and programming

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/17

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

18 Terms

1
New cards

What is sequencing?

Code is executed line-by-line, from top to bottom.

2
New cards

What is Branching/Selection?

A certain block of code is run if a specific condition is met, using IF statements.

3
New cards

What is Iteration?

A block of code is executed a certain number of times or while a condition is met. Iteration uses FOR (Count-controlled), WHILE (Condition-controlled) or REPEAT UNTIL loops.

4
New cards

What is recursion?

a programming construct in which a subroutine calls itself during its execution. This continues until the stopping condition is met.

5
New cards

What is a Call stack?

a stack data structure that stores information about the active subroutines of a computer program.

6
New cards

What is a Stack Frame?

Stack frames are used by computers to store ​return addresses​, ​parameters ​and ​local variables​ for each ​subroutine call​ that occurs during the execution of a program.
This information allows the subroutine to return to that particular point during its execution.

7
New cards

Disadvantages of recursion?

● Inefficient use of memory; If the subroutine calls itself too many times, there is a danger of a stack overflow (call stack runs out of memory).
● Difficult to trace, especially with more and more function calls.

8
New cards

What is a more efficient form of recursion called?

Tail recursion is a form of recursion which is implemented in a more efficient way in which less stack space is required.

9
New cards

What is the Scope of a variable?

It defines where the variable can be used in a program.

10
New cards

Local vs Global Scope

●Local variables have limited scope which means that they can only be accessed within the block of code in which they were defined. E.g. if defined in a subroutine can only be used in the subroutine.
●Global variables, on the other hand, can be accessed across the whole program. All variables used in the main body of a program are automatically declared to be global.

11
New cards

Advantages and Disadvantages of Local Scope

●Advantages
Ensures subroutines are self-contained, with no danger of variables being affected by code outside of the subroutine.
●Allows variables with the same name to exist (as long as they are in different subroutines).
Disadvantages
●It can only be accessed within its Scope

12
New cards

Advantages and Disadvantages of Global Scope

Advantages
●Useful for values that need to be used by multiple parts of the program.
Disadvantages
●Require more memory as not deleted until end of program.
●Can be unintentionally overwritten.
●Local variables take precedence over Global variables.

13
New cards

Difference between byVal and ByRef

●ByVal means that you are passing a copy of a variable to your Subroutine. You can make changes to the copy and the original will not be altered. The copy is discarded at the end.
●ByRef means the address of the given parameter is passed into the subroutine and the value at the location will be updated.

14
New cards

Difference between function and procedure

●Procedures do not have to return a value (hence void)
●Functions must always return a value

15
New cards

Define Stepwise Refinement

A Technique used to modularise programs; The problem is broken down into sub-problems until each module preforms a certain task.

16
New cards

What is an IDE (Integrated Development Environment)?

Program which provides a set of tools to make it easier for programmers to write, develop and debug code.

17
New cards

Name features of an IDE

●Stepping-This allows you to monitor the effect of each individual line of code by executing a single line at a time.
●Variable Watch-observe how the contents of a variable change in real-time through the execution of a program.
●Breakpoint-o set a point in the program at which the program will stop. This can either be based on a condition or set to occur at a specific line. This can help to pinpoint where an error is occurring.
●Source code Editor-Provides features such as: autocompletion of words, Indentation, syntax highlighting and automatic bracket completion.
●Debugging tools- Run-time detection of errors; stating the lines errors are found and highlighting them.

18
New cards

Uses of OOP

●Encapsulation
●Reusability (Using Classes, Inheritance and Polymorphism)