Understanding Sorting Algorithms (with Examples in Java)

Understanding Sorting Algorithms (with Examples in Java)


Sorting is used to rearrange elements in a list in a specified order. For instance, we might want to sort this list in ascending order:

A sorting algorithm is used to carry out the process of sorting.



Different Sorting Algorithms

There are several different sorting algorithms in use today. A few we will look at are:

  1. Bubble Sort
  2. Selection Sort
  3. Insertion Sort
  4. Merge Sort
  5. Quick Sort



Efficiency of Sorting Algorithms

We can determine the efficiency of sorting algorithms by checking their time and space complexities.



Time Complexity:

This refers to the amount of time taken for the algorithm its execution with respect to the input. It can be represented in many forms, but the most common is using the Big O notation.



Space Complexity:

This refers to the amount of memory used by the algorithm to complete its execution. It can also be represented using the Big O notation.



Source link
lol

By stp2y

Leave a Reply

Your email address will not be published. Required fields are marked *

No widgets found. Go to Widget page and add the widget in Offcanvas Sidebar Widget Area.