Repository: TheAlgorithms/C-Plus-Plus
File: sorting/bubble_sort.cpp (C++)

Code before:
 * @file
 * @brief Bubble sort algorithm
 *
 * @details
 * Bubble sort algorithm is the bubble sorting algorithm. The most important reason
 * for calling the bubble is that the largest number is thrown at the end of this
 * algorithm. This is all about the logic. In each iteration, the largest number is
 * expired and when iterations are completed, the sorting takes place.
 * 
 * What is Swap?
 * 
 * Swap in the software means that two variables are displaced.
 * An additional variable is required for this operation. x = 5, y = 10.
 * We want x = 10, y = 5. Here we create the most variable to do it.
 * 
 * int z;
 * z = x;
 * x = y;
 * y = z;
 * 
 * The above process is a typical displacement process.
 * When x assigns the value to x, the old value of x is lost.
 * That's why we created a variable z to create the first value of the value of x,
 * and finally, we have assigned to y.
 * 
 * Bubble Sort Algorithm Analysis (Best Case - Worst Case - Average Case)
 * 
 * Bubble Sort Worst Case Performance is \f$O(n^{2})\f$. Why is that? Because if you
 * remember Big O Notation, we were calculating the complexity of the algorithms in
 * the nested loops. The \f$n * (n - 1)\f$ product gives us \f$O(n^{2})\f$ performance. In the
 * worst case all the steps of the cycle will occur. Bubble Sort (Avarage Case)
 * Performance. Bubble Sort is not an optimal algorithm. in average, \f$O(n^{2})\f$
 * performance is taken. Bubble Sort Best Case Performance. \f$O(n)\f$. However, you
 * can't get the best status in the code we shared above. This happens on the
 * optimized bubble sort algorithm. It's right down there.
 */

#include <cassert>  /// for assert
#include <iostream> /// for IO implementations
#include <string>   /// for std::string
#include <utility>  /// for std::pair, std::swap
#include <vector>   /// for std::vector, std::vector::push_back, std::vector::size

/**
 * @namespace sorting
 * @brief Sorting algorithms
 */
namespace sorting {
/**
 * @namespace bubble_sort
 * @brief Bubble sort algorithm

Review comment (suggestion):
```suggestion
 * ## Bubble Sort Algorithm Analysis (Best Case - Worst Case - Average Case)
```

Code after:
 * @file
 * @brief Bubble sort algorithm
 *
 * @details
 * Bubble sort algorithm is the bubble sorting algorithm. The most important reason
 * for calling the bubble is that the largest number is thrown at the end of this
 * algorithm. This is all about the logic. In each iteration, the largest number is
 * expired and when iterations are completed, the sorting takes place.
 * 
 * What is Swap?
 * 
 * Swap in the software means that two variables are displaced.
 * An additional variable is required for this operation. x = 5, y = 10.
 * We want x = 10, y = 5. Here we create the most variable to do it.
 * 
 * ```cpp
 * int z;
 * z = x;
 * x = y;
 * y = z;
 * ```
 * 
 * The above process is a typical displacement process.
 * When x assigns the value to x, the old value of x is lost.
 * That's why we created a variable z to create the first value of the value of x,
 * and finally, we have assigned to y.
 * 
 * ## Bubble Sort Algorithm Analysis (Best Case - Worst Case - Average Case)
 * 
 * ### Best Case
 * Bubble Sort Best Case Performance. \f$O(n)\f$. However, you
 * can't get the best status in the code we shared above. This happens on the
 * optimized bubble sort algorithm. It's right down there.
 * 
 * ### Worst Case
 * Bubble Sort Worst Case Performance is \f$O(n^{2})\f$. Why is that? Because if you
 * remember Big O Notation, we were calculating the complexity of the algorithms in
 * the nested loops. The \f$n * (n - 1)\f$ product gives us \f$O(n^{2})\f$ performance. In the
 * worst case all the steps of the cycle will occur.
 * 
 * ### Average Case
 * Bubble Sort is not an optimal algorithm. In average, \f$O(n^{2})\f$ performance is taken. 
 * 
 * @author [Deepak](https://github.com/Deepak-j-p)
 * @author [Nguyen Phuc Chuong](https://github.com/hollowcrust)
 */

#include <algorithm> /// for std::is_sorted
#include <cassert>   /// for assert
#include <iostream>  /// for IO implementations
#include <string>    /// for std::string