DATA STRUCTURES 8 Flashcards
Ο( g(n) )
a ≤ b; f(n) ≤ cg(n)
Ω( g(n) )
a ≥ b; f(n) ≥ cg(n)
Θ( g(n) )
a = b; c₁g(n) ≤ f(n) ≤ c₂g(n)
ω( g(n) )
a > b; f(n) > cg(n)
ο( g(n) )
a < b; f(n) < cg(n)
O( n² )
bubble sort; Shell sort; quicksort; selection sort; insertion sort
O( log n )
binary search
When parameters are passed ______, the formal parameters of a function refer to _______ of the actual parameters which are discarded as soon as the function call returns.
by-value; copies
void addOne( long x )
passed by-value
void addOneByRef( long& x )
passed by-reference
Function overloading
Has to have different parameters. Can return different value types. Can have one version with 2 parameters and one with 3 parameters.
*p = ?
value of variable pointed to
p = ?
address of variable pointed to
&x = ?
address of variable
N + (N - 1) + … + 2 + 1 =
N(N+1)/2
Time for searching?
O( log n )
Time for Traveling Salesman?
O( n! )
Time for one loop?
O( n )
Time for a loop with in a loop?
O( n² )
Static memory is created on the _____?
Stack
Dynamic memory is created on the ____?
Heap
Dynamic memory must be ____ via _____?
released; delete
Static is freed when they go out of ____?
Scope
______ is a data structure that uses a ____ function to map identifying values, known as keys (e.g., a person’s name), to their associated values (e.g., their telephone number).
Hash Table; Hash
What are hash tables good for?
The main advantage of hash tables over other table data structures is speed. This advantage is more apparent when the number of entries is large (thousands or more). Hash tables are particularly efficient when the maximum number of entries can be predicted in advance, so that the bucket array can be allocated once with the optimum size and never resized.
In what situations are hash tables not likely to be useful?
The main issue is the flexibility of the table in terms of size. Once you have chosen a particular size m for the array, you will also commit to a particular hash function h whose range is exactly {0,…,m-1}. If you do not have a reasonably tight estimate for the size of the set S that you’d like to store in your hash table ahead of time, hash tables may not be the best answer. Hash tables become quite inefficient when there are many collisions.