| 1. |
Explain What Is The Difference Between Best Case Scenario And Worst Case Scenario Of An Algorithm? |
|
Answer» Best case scenario: Best case scenario for an algorithm is explained as the ARRANGEMENT of data for which the algorithm performs best. For example, we TAKE a BINARY search, for which the best case scenario would be if the target value is at the very center of the data you are searching. The best case time complexity would be 0 (1) Worst case scenario: It is REFERRED for the worst set of input for a given algorithm. For example quick sort, this can perform worst if you select the largest or SMALLEST element of a sublist for the pivot value. It will cause quick sort to degenerate to O (n2). Best case scenario: Best case scenario for an algorithm is explained as the arrangement of data for which the algorithm performs best. For example, we take a binary search, for which the best case scenario would be if the target value is at the very center of the data you are searching. The best case time complexity would be 0 (1) Worst case scenario: It is referred for the worst set of input for a given algorithm. For example quick sort, this can perform worst if you select the largest or smallest element of a sublist for the pivot value. It will cause quick sort to degenerate to O (n2). |
|