📜  后验分析和先验分析的区别

📅  最后修改于: 2021-09-28 09:25:04             🧑  作者: Mango

先决条件——算法分析
算法是解决给定问题的有限状态的组合或序列。如果问题有多个解决方案或算法,那么最好的解决方案或算法由基于两个因素的分析决定。

  1. CPU 时间(时间复杂度)
  2. 主存空间(空间复杂度)

算法的时间复杂度可以通过两种方法计算:

  1. 后验分析
  2. 先验分析

后验分析和先验分析的区别:

A Posteriori analysis A priori analysis
Posteriori analysis is a relative analysis. Piori analysis is an absolute analysis.
It is dependent on language of compiler and type of hardware. It is independent of language of compiler and types of hardware.
It will give exact answer. It will give approximate answer.
It doesn’t use asymptotic notations to represent the time complexity of an algorithm. It uses the asymptotic notations to represent how much time the algorithm will take in order to complete its execution.
The time complexity of an algorithm using a posteriori analysis differ from system to system. The time complexity of an algorithm using a priori analysis is same for every system.
If the time taken by the algorithm is less, then the credit will go to compiler and hardware. If the program running faster, credit goes to the programmer.