W18 Flashcards
The most two important computational resources are:
1- Time 2- Space (memory) Also, we can measure: - number of operations performed - order of growth (big O notation)
Terminology for describing performance:
What is best case, worst case and average case?
best case: is the minimum running time overall possible inputs of a given size
worst case: is the maximum running time over all possible inputs of a given size
average case: is the average running time over all possible inputs
Order of growth ( big O notation) describes what?
the running time in relation to input size (usually the worst case scenario)
ways of sorting:
1- bubble sort
2- selection sort
3- merge sort
ways of searching:
1- linear search
2- bisection search
linear search
1- list does not have to be sorted
2- brute force search???
bisection search
1- list must be sorted
2- divide and conquer approach
A template that describes a set of objects with the same behaviours ??
A class
What is Encapsulation?
1- hiding the implementation details
2- enables changes in the implementation without affecting users of a class
An instance(نموذج) of a class?
An object
object reference?
The memory location of the object
How to check if two objects are aliases (point to the same memory location)?
using (is)
if obj1 is obj2:
print(“Aliases”)
How to check if two objects contain same data?
using ( ==)
if obj1 == obj2:
print(“objects contain same data”)
How to check if an object is not empty before using it?
using (is)
if obj is None:
…..
function vs methos
A method is defined as part of class definition so, it always has, at least, one parameter which is (self)