Data Structures Introduction Flashcards

1
Q

Abstract Data Type (ADT)

A

special data type with defined values and operations, but the operations are hidden from the user
(isFull(). isEmpty(), insert())

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

Data Structures

A

store data in an organized and efficient manner (arrays, stacks, queue, linked list, trees, hashing)

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

Computational Complexity

A

Big O Notation. classifies algorithms based on time/space complexity.

O(1): constant. n is not iterated or recursed.

O(log n) logarithmic: cut time cost in half (from which floor does the crystal ball shatter? log n starts from the middle and works in halves at least)

O(n): Linear, simple for loop through size n

O(n log n): log linear, likely recursive and binary tree sorts (for every n, reduce loop time)

O(n^c): polynomial. entirety of n is looped through for every C

O(c^n): exponential time: function runs through entirety of n, multiple times, and multiple times for every c

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

time vs space complexity trade-off

A

uncompressed data takes more space, but less time
look-up table: takes less time to process but costs more space to allocate table memory.

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

Amortized Complexity

A

total expense per operation, over a sequence of operations in a worst-case scenario.

the standard assumption for O notation

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

Efficiency vs Performance

A

But high efficiency will take less time and resources to run the program and achieve its goals.

Performance: how well a machine can handle the code. weaker systems might struggle and slow down with ‘highly efficient’ code, lacking the resources to give to the program to run efficiently.

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

True or false:

2n = O(n)

2n = O( n ^ 2 )

n^2 = O(n)

n^2 = O( n * ( log n ) ^ 2)

A

True, (2n is linear time. less than or equal to n)

False, linear 2n is not quadratic

false

True

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

LiLo

A

last in, last out. last entered element is processed first.

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

FiFo

A

First in First out. first entered element is processed first.

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

API

1 How can a user store stack elements by reference instead of by value?

2 which of the stack functions should assert? what should they assert on?

A

1 passing a pointer (value referring to the value’s location in memory)

2 destroy (check stack exists), create (element_size and num_of_elements are not 0, check stack exists) push (assert stack exists, element !< element_size, stack is not full.)

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