Average case vs. expectation

Naftali. In summary, "average case" running time is the expected value for the running time of a deterministic algorithm when inputs are chosen randomly, while "expected" running time is the expected value for the runtime of a randomized algorithm on a specific input. Additionally, one can also refer to the "expected worst case running time" which is the worst case of the expected running time for all inputs of a certain size.
  • #1
naftali
31
0
Hi,

I am not sure if I understand well : is there a difference between avarage case complexity to expectation of running time?

thank you

Naftali
 
Technology news on Phys.org
  • #2
Well, different authors might use them in different ways, but here's how I learned it...
"Average case" running time is for a deterministic algorithm (the most familiar example that you use average case runtime for is quicksort). It is the expected value of the running time that the algorithm would have if inputs were chosen randomly.

"Expected" running time is usually for a randomized algorithm (for example, Karger's algorithm). It is the expected value for the runtime of the algorithm on a particular input. You might also speak of expected worst case running time, which would be the worst case of the expected running time over all inputs of a certain size.
 
  • #3
Thanks
 

1. What is the difference between average case and expectation?

Average case and expectation are two different measures used to describe the performance of an algorithm. The average case refers to the average number of operations or steps an algorithm takes to solve a problem, while the expectation refers to the expected number of operations or steps an algorithm takes based on a probability distribution of inputs. In other words, the average case is a specific value, while the expectation is a theoretical value based on probability.

2. Can an algorithm have the same average case and expectation?

Yes, it is possible for an algorithm to have the same average case and expectation. This would occur when the probability distribution of inputs is evenly distributed, meaning that each input has an equal chance of occurring. In this case, the average case and expectation would be the same, as they both represent the same value.

3. How are average case and expectation calculated?

The average case is calculated by taking the sum of the number of operations for each possible input and dividing by the total number of inputs. The expectation is calculated by taking the sum of the number of operations for each possible input multiplied by its probability of occurring.

4. Why is it important to consider both average case and expectation in algorithm analysis?

Considering both average case and expectation provides a more comprehensive understanding of an algorithm's performance. While the average case gives a specific value, the expectation takes into account the likelihood of different inputs and provides a more realistic estimate of an algorithm's performance in real-world scenarios. This allows for better comparison and selection of algorithms for different applications.

5. Can an algorithm have a good average case but a poor expectation?

Yes, an algorithm can have a good average case but a poor expectation. This would occur when the probability distribution of inputs is skewed, meaning that certain inputs are more likely to occur than others. In this case, the average case may be low as it is influenced by the most common inputs, but the expectation may be much higher as it considers the less common inputs as well.

Similar threads

  • Programming and Computer Science
Replies
22
Views
3K
Replies
14
Views
1K
  • Programming and Computer Science
Replies
1
Views
461
  • Programming and Computer Science
Replies
1
Views
979
  • Programming and Computer Science
Replies
13
Views
470
  • Programming and Computer Science
Replies
2
Views
842
  • Set Theory, Logic, Probability, Statistics
Replies
10
Views
1K
Replies
76
Views
4K
  • Differential Equations
Replies
0
Views
284
  • Set Theory, Logic, Probability, Statistics
Replies
5
Views
889
Back
Top