Big O notation + log Flashcards

(9 cards)

1
Q

What is big O notation

A

Describes the time and space complexity of an alogorithm

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

Explain what log2(n) means

A

This means the number of times you can divide n by before reaching 1

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

Give an example of log2(n)

A

log2(8) = 8 - 4 - 2 - 1. This would be 3 visits

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

what Big o notation is binary search

A

O(log n) - Binary search works by repeatedly dividing the search space in half:

Start with a sorted array.

Compare the target to the middle element.

If the target is smaller, discard the right half; if larger, discard the left half.

Repeat until the target is found or the search space is empty.

Since the array is halved each time, the number of steps grows logarithmically with input size (n)

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

what equation is selection sort

A

n2 - quadratic time, ineficiant for large data sets. This is because it makes mutiple comparisons.

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

What is black box testing

A
  • Testing functionallility without knowing internal code
  • Testing from a users perspective
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what is white box testing

A
  • testing the soruce code and internal code structure
  • The goal is to test every possible possibillity
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Give me a simple recursive method

A

int fact (int n){
if (n == 1){
return 1
}else{
n * fact(n - 1);
}
}

  • loops keeps running until the base case it met
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly