programming techniques Flashcards
what is the difference between passing parameters BY VALUE and BY REFERENCE ?
passed by reference is when the funtion will call its memory location of the variable , passed by value this is when the function will receive a copy of the variable
what is meant by modular programming ?
- Modular programming is when a large program is broken down to smaller tasks which are easier to test and maintain.
what are some advantage of modular programming?
-easier to test
-easier to maintain
-modules can be reused
-a team of programmers can work on modules
explain why using local variables makes a large program easier to maintain ?
-There are no unexpected side effects as its independent than other modules.
Describe one disadvantage of a recursive routine compared with an iterative routine?
disadvantage :
-Recursion is less memeory efficient
-consistent recursion could cause a stack overflow
what is A WATCH in an ide ?
what is a trace in an ide ?
a watch -any item of data that a programmer wants to observe runs on its own.
A trace can be set so that a programmer can step through a program , line by line to trace the execution
in OOP what is a :
class ?
constructor ?
Instantiation?
a class is a blue print for objects
a constructor is a method/procedure which allows new objects in the class to be created.
instantiation is a statement which creates an object belonging to a particular class
what is an IDE ?
an IDE is a program that provides a set of tools and designed to maximise a programmers productivity.
what does an IDE have ?
- code editors
-error diagnostics
-translators
what is the difference between a whileloop and a loop ?
A while loop will keep repeating until the correct
password has been input // condition is met .
A for loop will only repeat a certain number of
times
what is a differnce between global and local variable ?
Global variable is visible throughout a program whereas local variable is visible only in module/construct where it is created/declared
what is a function ?
it returns a value often called inline
what is polymorphism?
what is encapsulation?
what are the benefits of encapsulation?
Polymorphism is the ability of a programming language to present the same interface for several different underlying data types.
encapsulation refers to the bundling of data, along with the methods that operate on that data, into a single unit.
Benefits:
- hiding data
-Easy to reuse
-more flexible
what is meant by intractable?
intractable problems are problems for which there exist no efficient algorithms to solve them.
what are the advantages of OOP?
encapsulation - hides unnecessary details , so only necessary data is shown
- inheritance- links classes that are similar , which makes it easier to refer to when coding
what is procedual programming?
this is a type of programming paradigm , where a program is built from one or more subroutines. e.g global,local or procedures and functions.
explain how backtracking is used in traversal?
-It starts at the root and goes the bottom of the branch, and stores all the visited lists into a stack
-when it cannot go further, it backtracks to other nodes
-it then goes to another branch in the binary tree and back tracks from the beginning.
explain how backtracking is used in traversal?
-It starts at the root and goes the bottom of the branch, and stores all the visited lists into a stack
-when it cannot go further, it backtracks to other nodes
-it then goes to another branch in the binary tree and back tracks from the beginning.
explain why insertion sort might use less memory than merge sort?
An insertion sort may use less memory as a merge sort as
- merge sort might create new arrays
-insertion sort is an in-place algorithm
what are the benefits and drawback of decalring an array as a global variable instead of local ?
Benefit :
-can be accessed from any function/ anywhere in the program
-you don’t need to return a value
-vairbale doesn’t need to be passed by parameter
drawback:
-incrases memry usage
-unwanted altercations within the function may lead to side affects.