Data Structures Flashcards

1
Q

What is Big O Notation?

A

Big O notation is a way of writing this function to show how an algorithm scales with the size of its input.

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

What are common Big O Functions?

A

O(1) - Constant time. Always fast. Number of operations never grows with input size n.

O(n) - Linear time. Fine. Number of operations grows at the same rate of input size n.

O(n^2) - Quadratic time. Bad. Number of operations explodes as the input size n grows.

O(n!) - Factorial. Trash. Number of operations is astronomical if n isn’t tiny.

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

How do you calculate Big O for a statement?

A

If this statement were to run once, how many simple calculations would it take in terms of the size of the data sets being used.

How many times will this statement run worst-case, within the context of this function, in terms of the size n of the data sets being used?

Take the answers from steps i and ii, and multiply them together.

Drop any constant, so 2n becomes n or 3(n^2) becomes n^2. That is the Big O notation for this statement.

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

After determining Big O for each statement, how do you find the function’s Big O?

A

Find the statement(s) with the worst Big O notation. That is the Big O notation for the function.

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

What does the acronym FIFO mean?

A

First In First Out

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

What methods are available on a Queue data structure?

A

enqueue(value)- adds avalueto the “back” of the queue

dequeue()- removes the “front” value from the queue and returns it

peek() - peeks the “front” value without modifying the queue

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

What must you do to access the value at an arbitrary point in a queue (not just the “front”)?

A

Dequeue until you reach desired value

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

What does the acronym LIFO mean?

A

Last In First Out

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
  • What methods are available on a Stack data structure?
A

pop() - Pops the “top” value off the stack.
push() - Pushes an item to the “top” of the stack
peek() - Returns the “top” value without modifying it

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

How are linked lists different from an array?

A

Linked lists are sequential access, where as arrays are random access

Does not need to be mutated to scan it’s contents (queue needs to be mutated)

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

How would you access an arbitrary node in a linked list (not just the “head”)?

A

Start at the head and traverse through with the next property

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

What properties are available on linked lists?

A

.data- contains the node’s value.

.nexta reference to the next node in the list, if there is one. If there is no “next” node in the list, this property is typically set tonull.

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