DEV Community

Chinonso Ikewelugo
Chinonso Ikewelugo

Posted on

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:

Image description

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.

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs