Problem solving and programming 2.2 Flashcards
Name the three programming constructs
- Sequence
- Selection
- Iteration
What is sequence?
Sequence is the order in which instructions occur and are proccessed
What does selection do?
Selection determines which path the program takes
What is iteration?
iteration is the repeated excecution of a section of code when a program is running
Which two categories of loop are iteration split up into?
- Count controlled(for loop)
- Condition controlled(while loop)
What is recursion?
Where a subroutine call itself during excecution until the stopping condtion is met
State two advantages of recusion
- Can be represented in fewer lines of code
2.Easier to express some functions recursively than using iteration
State two disadvatages of recursion
- Inefficent use of memory
2.Difficult to trace - Danger of stack overflow
Define scope
The section of the program in which a variable is accessible
Give two advantages of using local variables over global variables
- Less memory is used
2.Take priority over global variables with the same name - uneffected by code outside of the subroutine
What is the difference between a procedure and a function?
Functions must always return a single value, while procedures do not always need to return a value
What does it mean to pass in a parameter (to a subroutine) by reference?
The address in memory of the parameter is passed to the subroutine so the value outside the subroutine will be updated
The value in the parameter is changed
What does it mean to pass in a parameter (to a subroutine) by value?
The value stored inside memory location is passed into the function
The variable outside the function does not change
What are IDE’s?
Integrated development environment is a software application that provides a comprehensive set of tools. They are useful tools for software developers
What does IDE stand for?
Integrated Development enviornment
State two features of IDEs
- Debuggin tools
- Source code editior
- Breakpoint
- Variable watch
What is encapsulations in OOP?
When attributes and methods are declared as private so they can only be accessed by setters and getters
What is the purpose of encapsulation in OOP?
Program complexity is reduced by protecting data from being accidentally editied from other parts of the program
What is Inheritance in OOP?
Inheritance is when a child class inherits its methods and attributes from the parent class
What is polymorphism?
When two mehods in two different classes share the same name and purpose
What is it meant by a computable problem?
A problem that can be solved using an algorithm
Give three limiting factors of computable problems
- Time
- Proccessing power
- Processor speed
- Computer memory
Describe how divide and conquer techniques work
The problem size is halfed with each iteration. Each individual subroutine is solved recursively. Then they are recombined
Give two applications of divide and conquer
- Quick sort
- Merge sort
- Binary search