# Sorting Algorithms in Data Structures

A sorting algorithm is used to organize the elements of an array or list. Sorting an array, for example.

Unsorted array

Sorted array

We're sorting the array in ascending order right now.

This procedure may be completed using a variety of sorting algorithms. And, depending on the situation, we may apply any algorithm.

## Various Sorting Algorithms

• Bubble Sort
• Selection Sort
• Insertion Sort
• Merge Sort
• Quick Sort
• Counting Sort
• Bucket Sort
• Heap Sort
• Shell Sort
• Comb Sort

## Sorting Algorithms' Complexity

The time complexity and space difficulty of any sorting algorithm influence the method's efficiency.

1. Time Complexity: The time it takes an algorithm to finish its execution in relation to the amount of the input is referred to as time complexity. It can be expressed in a variety of ways:
• Big-O notation (O)
• Omega notation (Ω)
• Theta notation (θ)
2. Space Complexity: The entire amount of memory utilised by the method for

A sorting algorithm is used to organize the elements of an array or list. Sorting an array, for example.

Unsorted array

Sorted array

We're sorting the array in ascending order right now.

This procedure may be completed using a variety of sorting algorithms. And, depending on the situation, we may apply any algorithm.

## Various Sorting Algorithms

• Bubble Sort
• Selection Sort
• Insertion Sort
• Merge Sort
• Quick Sort
• Counting Sort
• Bucket Sort
• Heap Sort
• Shell Sort
• Comb Sort

## Sorting Algorithms' Complexity

The time complexity and space difficulty of any sorting algorithm influence the method's efficiency.

1. Time Complexity: The time it takes an algorithm to finish its execution in relation to the amount of the input is referred to as time complexity. It can be expressed in a variety of ways:
• Big-O notation (O)
• Omega notation (Ω)
• Theta notation (θ)
2. Space Complexity: The entire amount of memory utilised by the method for a complete execution is referred to as space complexity. Both the extra memory and the input are included.

Auxiliary memory is the space used up by the method in addition to the input data. When determining the space complexity of an algorithm, auxiliary memory is usually taken into account.

Let's look at the complexity of several sorting methods.

## Sorting Algorithm Stability

When two or more items with the same value keep the same relative positions after sorting, the sorting method is deemed stable.

In the figure below, for example, there are two objects with the identical value of 3. The two places of 3 may or may not be maintained depending on the stability of the sorting algorithm.

Unsorted array

After unstable sorting there are 2 possibilities

However, there is always one alternative following a stable sorting algorithm in which the locations are preserved as in the original array.

Unsorted array

Sorted array

This table displays the consistency of several sorting algorithms.

a complete execution is referred to as space complexity. Both the extra memory and the input are included.

Auxiliary memory is the space used up by the method in addition to the input data. When determining the space complexity of an algorithm, auxiliary memory is usually taken into account.

Let's look at the complexity of several sorting methods.

## Sorting Algorithm Stability

When two or more items with the same value keep the same relative positions after sorting, the sorting method is deemed stable.

In the figure below, for example, there are two objects with the identical value of 3. The two places of 3 may or may not be maintained depending on the stability of the sorting algorithm.

Unsorted array

After unstable sorting there are 2 possibilities

However, there is always one alternative following a stable sorting algorithm in which the locations are preserved as in the original array.

Unsorted array

Sorted array

This table displays the consistency of several sorting algorithms.