Data Structures & Algorithms Flashcards

1
Q

What is Big O Notation

A

shows how efficient an algorithm is in the worst-case scenario relative to its input size

Omicron

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

Time Complexity

A

How much time does it take to run completely?

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

Space Complexity

A

How much extra space does it require in the process?

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

Ω

Omega

A

Best case scenario

Loop through [1, 2, 3, 4, 5, 6, 7] looking for 1

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

θ

Theta

A

Average case

Loop through [1, 2, 3, 4, 5, 6, 7] looking for 4

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

O

Omicron

A

Worst case

Loop through [1, 2, 3, 4, 5, 6, 7] looking for 7

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

Contiguous vs Noncontigous

Types of memory allocation

A
  • Contiguous -single contiguous section/part of memory is allocated
  • Noncontiguous - memory is allocated to different locations
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Stack

Data Structure

A
  • You can only get to the last item (most recently added) that you pushed onto the stack
  • Example - back button in Web Browser will pop off the most recently visited site
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Queue

Data Structure

A
  • Typically FIFO
  • Add on one end, remove on other end
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Binary Tree

Data Structure

A
  • nodes can have this.left and this.right values
  • Full - every node either points to two nodes or zero nodes
  • Perfect - Any level in the tree that has any nodes is completely filled across
  • Complete -as long as left side is filled with no gaps
  • Although Binary Tree will only have each node point to two nodes, other trees could have nodes that point to multiple nodes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Binary Search Tree

A

for any node:
* any nodes below and right will be greater than
* any nodes below and left will be less than

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

Big O of for loop

A

O(n)

Linear Time

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

Big O of arr.push() or arr.pop()

A

O(1)
Constant time

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

Big O of sorting algorithm

A

usually O(nlog n)

For JS array sort, depends on (browser) implementation

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