csi 33

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/61

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

62 Terms

1
New cards

Function Specification

Tells WHAT a function does (its purpose), but not HOW it does it.

2
New cards

Precondition

What must be TRUE BEFORE the function is called. The "rules" for using it.

3
New cards

Postcondition

What is TRUE AFTER the function finishes. The "promise" it keeps.

4
New cards

Side Effects

Functions should not produce undocumented side effects

5
New cards
Function specification
tells what a function does but not how that is done
6
New cards
Function precondition
tells what is true before the function is called
7
New cards
Function postcondition
tells what is true after the function finishes executing
8
New cards
functions should not
produce undocumented side effects
9
New cards
Enforcing preconditions
raise an exception or use an assert statement
10
New cards
assert
for finding bugs in your code
11
New cards
exception
is for handling expected errors from the user or environment.
12
New cards
t(n)
the number of "steps" a computer needs to take to finish an algorithm, where n is the "size" of the problem.
13
New cards
n can be number of items to sort, number of items in the list, number of users.
14
New cards

abstract data type (ADT)

type (or class) for objects with behavior defined by a set of values and a set of operations.

15
New cards
ADT
tells what operations are to be performed, but not how operations will be implemented. does not
16
New cards
specify how data will be represented or and
17
New cards
what algorithms will be used for operations
18
New cards
ADT examples
dataset, rational, card
19
New cards
Class invariant
is a set of properties that allobjects in the class must satisfy.
20
New cards
Class invariant
It gives a criterion for the object to be valid, must be fulfilled by the constructor, must be maintained by the public methods.
21
New cards
python list methods
deck of cards, hand of cards using python list as container
22
New cards
python list
a manager for a dynamic array of references
23
New cards
Dynamic Array
A contiguous block of memory that holds memory addresses (references to the actual objects).
24
New cards
dynamic
The array can grow by allocating a new, larger array and copying the references over when it runs out of space.
25
New cards
Arrays
homogeneous, size determinedstatically (unless additional programming fordynamic array class), efficient random memoryaccess
26
New cards
stack ADT
last in, first out ADT, methods -push to place data, pop to remove data, top to examine data
27
New cards
Stack applications
managing function calls,evaluating Reverse Polish expressions, changing infix expressions to reverse Polish expressions
28
New cards
queue ADT
first in, first out ADT, methods -enqueue to add data, dequeue to remove and return data, front to examine data
29
New cards
Recursive function
a function that is defined using a call to the function itself in the definition. The definition must have one or more base cases where the function can be computed without a recursive call.
30
New cards
every chain of recursive calls must what
terminate at a base case
31
New cards
examples of recursive functions
factorial, string reversal,permutations, exponentiations by repeated squaring, binary search, Fibonacci
32
New cards
append()
adds to the end
33
New cards
Time Complexity Analysis
the methods for analyzing the amount of time that it takes for an algorithm to run
34
New cards
Big-O (f(n)) bound
an upper bound by a multiple of f(n) of how much the number of steps ofan algorithm grows as the problem instance gets larger. Common functions f(n) are c, n, n2,log(n), and n log(n)
35
New cards
Big-Theta(f(n))
an upper and lower bound by a multiple of f(n) of how much the number of steps of an algorithm grows as the problem instance gets larger
36
New cards
Object-oriented programming
programming paradigm (way to conceptually organize the implementation of a program) that emphasizes creating a model of the problem environment that links data and methods that work on the data into a unit, called an object.
37
New cards
Class
a category of objects defined by program code that gives the data members and defines function members that operate on the data
38
New cards
Instance Variables
a variable that belongs to an object or instance of a class.
39
New cards
Instance method
A method that belongs to an object in a class that can be used to access or modify the data of a class, or do computations related to that data.
40
New cards
Class invariant
a condition that all objects of a class must satisfy to be valid, established by the constructor and maintained by class methods
41
New cards
Operator overloading
giving an existing operator an additional definition to allow it to work with user-defined data types
42
New cards
Container class
a class whose objects hold a collection of objects, such as lists, tuples,dictionaries, and sets
43
New cards
ADT or abstract data type
A type for an object whose behavior is defined by a set of values and what operations are to be performed but does describe how the operations are implemented
44
New cards
ADT specification
The description of the possible values and behavior of the operations for that ADT
45
New cards
Dictionary or mapping
an ADT that holds data as key-value pairs. Keys must be unique and are used to retrieve the corresponding value.
46
New cards
Hash table
the structure that is used to implement a dictionary of key-value pairs, combining a large array with a hash function to compute an integer to be used as an index in the array at which to store a key-value pair
47
New cards
Linked list
A sequential data structure that consists of a collection of nodes, each with some data and a link or reference to the next node in the list
48
New cards
Node
an individual element of a linked list, containing data and a link to the next node,
49
New cards
Stack or LIFO ADT
an ADT that stores a linear collection of data elements and follows a"Last In, First Out" principle. A data element is added or pushed onto the stack, and the last or most recent element added is the element that is removed or popped from the stack
50
New cards
Queue or FIFO ADT
an ADT that stores a linear collection of data elements and follows a"First In, First Out" principle. A data element is added or enqueued onto the end or tail of the queue, and the first element enqueued is the element that is removed or dequeued from head of the queue
51
New cards
Functional abstraction
a programming technique of separating the task to be performed by a function from the implementation details of the function, allowing a programmer to use a function without knowing its implementation
52
New cards
Base case
A non-recursive part of a recursive function definition, that computes the function value or carries out the function task without a recursive call.
53
New cards
Recursive case
the part of a recursive function definition that calls the same function on a simpler or smaller version of the problem
54
New cards
Unit testing
a software testing method that validates that each unit, such as a function, class, or method, works as intended in isolation
55
New cards

o(1)

constant time - instant

56
New cards

o(log n)

logarithmic - very slow growth

57
New cards

o(n)

linear - doubles when n doubles

58
New cards

o(n²)

quadratic - 4x time when n doubles

59
New cards

o(2^n)

exponential - time doubles when n increases by 1

60
New cards

Container Class

Class that holds collections of objects

61
New cards

LIFO operations

  • push(): Add to top

  • pop(): Remove from top

  • top(): Examine top element

Applications: Function calls, expression evaluation

62
New cards

FIFO operations

enqueue(): Add to back

dequeue(): Remove from front

front(): Examine front element

Applications: Resource sharing, simulations