programming techniques Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

what is the difference between passing parameters BY VALUE and BY REFERENCE ?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

what is meant by modular programming ?

A
  • Modular programming is when a large program is broken down to smaller tasks which are easier to test and maintain.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

what are some advantage of modular programming?

A

-easier to test
-easier to maintain
-modules can be reused
-a team of programmers can work on modules

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

explain why using local variables makes a large program easier to maintain ?

A

-There are no unexpected side effects as its independent than other modules.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Describe one disadvantage of a recursive routine compared with an iterative routine?

A

disadvantage :
-Recursion is less memeory efficient
-consistent recursion could cause a stack overflow

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

what is A WATCH in an ide ?

what is a trace in an ide ?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

in OOP what is a :
class ?
constructor ?
Instantiation?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

what is an IDE ?

A

an IDE is a program that provides a set of tools and designed to maximise a programmers productivity.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

what does an IDE have ?

A
  • code editors
    -error diagnostics
    -translators
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

what is the difference between a whileloop and a loop ?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

what is a differnce between global and local variable ?

A

Global variable is visible throughout a program whereas local variable is visible only in module/construct where it is created/declared

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

what is a function ?

A

it returns a value often called inline

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

what is polymorphism?

what is encapsulation?
what are the benefits of encapsulation?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

what is meant by intractable?

A

intractable problems are problems for which there exist no efficient algorithms to solve them.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

what are the advantages of OOP?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

what is procedual programming?

A

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.

17
Q

explain how backtracking is used in traversal?

A

-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.

18
Q

explain how backtracking is used in traversal?

A

-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.

19
Q

explain why insertion sort might use less memory than merge sort?

A

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

20
Q

what are the benefits and drawback of decalring an array as a global variable instead of local ?

A

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.