unit 11 Flashcards
what is an IDE?
an integrated development environment which enables the user to enter edit and compile programs
what features does an IDE have?
automatic indentation
auto complete commands
comment a region
syntax errors
what debugging facilities does an IDE have?
setting a breakpoint causing program to stop at that line
set a watch on a variable so value is displayed each time it changes
trace execution of a program
what is an algorithm?
a sequence/set of instructions that can be followed to solve the problem
what is pseudocode?
statements in between english and a programming language to help think out program steps needed
what is selection?
if statements
switch case statements
used to test conditions and outcome determines program flow
what is a switch case statement?
conditional statement that performs multiple comparisons based on value of expressions
what is iteration?
repetition
a sequence of instructions is repeated multiple times
what are the 3 iterative loops?
while, for, do until/repeat until
what is the difference between a while loop and a do until loop?
while - condition is tested upon entry to the loop
do - condition tested at end of the loop (always run at least once)
what is the difference between a while and for loop?
while - indefinite iteration
for - definite iteration (count controlled loop, specified number of times)
what happens when a parameter is passed by value?
copy of the actual value is made and assigned to function’s parameter
any changes to the parameter do not affect original value
copy of value is destroyed at the end
what happens when a parameter is passed by reference?
function receives memory address of the value rather than a copy of the value
any changes made to parameter will directly affect the original value
directly modify original data
what are the advantages of passing by reference?
can directly modify original data so good for large data structures
what are the disadvantages of passing by reference?
can lead to unwanted side effects as changes in code can affect other parts of function
what are the advantages of passing by value?
original data remains unchanged so it is suitable when you want to protect the original value
what are the disadvantages of passing by value?
can lead to performance overhead when working with large data structures as a copy is made
what is recursion?
process of a function calling itself to execute a task
what are the 3 features of recursion?
function must call itself
a base case - it can return a value without further recursive calls
an exit case - must be reachable after a finite number of times
why do we need a base case/stopping condition?
to avoid stack overflow errors which result in program crashes
if no base case, it will call itself indefinitely which uses excessive memory
what are the benefits of recursion?
can be expressed in a more concise way
simply stating what needs to be done without focusing on how makes it more readable
what are the disadvantages of recursion?
repeated function calls can be CPU intensive leading to slower execution
recursive code is more difficult to debug and track state of program
not all problems can be solved recursively
what are the advantages of iteration?
more efficient than recursion, less memory usage
easier to debug
wider range of problems
what are the disadvantages of iteration?
can get very complex and use more lines of code than recursion
less concise than recursion