---
title: "What is the asymptotic analysis? Provide an example of an algorithm and its asymptotic analysis."  
description: "What is the asymptotic analysis? Provide an example of an algorithm and its asymptotic analysis."  
author: "Revati S Misra"  
published: 2023-04-19  
updated: 2023-04-24  
canonical: https://www.mindstick.com/forum/157921/what-is-the-asymptotic-analysis-provide-an-example-of-an-algorithm-and-its-asymptotic-analysis  
category: "algorithm"  
tags: ["algorithm", "Algorithm analysis"]  
reading_time: 2 minutes  

---

# What is the asymptotic analysis? Provide an example of an algorithm and its asymptotic analysis.

What is the asymptotic [analysis](https://www.mindstick.com/articles/323533/prospective-analysis)? Provide an example of an [algorithm](https://www.mindstick.com/blog/119/implementing-cryptography-in-c-sharp-dot-net-by-using-sha1-algorithm) and its asymptotic analysis.

## Replies

### Reply by Krishnapriya Rajeev

Asymptotic analysis is a technique for evaluating an *algorithm's performance* in relation to the magnitude of its input. It helps to determine how the running time or space requirement of an algorithm changes as the size of the input grows. This analysis is important in understanding the scalability of an algorithm, which is crucial when dealing with large inputs.

The two most commonly used measures of asymptotic analysis are time complexity and space complexity. Space complexity indicates how much memory an algorithm needs to run, whereas time complexity represents how many operations an algorithm needs to finish as the size of the input increases.

An example of an algorithm and its asymptotic analysis is the sorting algorithm, *quick sort*. Quick sort is a popular sorting algorithm that works by selecting a pivot element, partitioning the array around the pivot, and recursively sorting the subarrays on either side of the pivot.

The pseudocode for quick sort is as follows:

```plaintext
function quicksort(array)
   if length(array) <= 1
       return array
   else
       pivot = select_pivot(array)
       less = []
       equal = []
       greater = []
       for element in array
            if element < pivot
                append element to less
            else if element = pivot
                append element to equal
            else
                append element to greater
        return concatenate(quicksort(less), equal, quicksort(greater))
```

The time complexity of quick sort is O(n log n) in the average and best-case scenarios, and O(n^2) in the worst-case scenario. The space complexity of quick sort is O(log n) on average, and O(n) in the worst-case scenario.


---

Original Source: https://www.mindstick.com/forum/157921/what-is-the-asymptotic-analysis-provide-an-example-of-an-algorithm-and-its-asymptotic-analysis

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
