Algorithms arranged in data structures & algorithms

Sorting is to arrange data in a specific format. In computer science, sorting algorithms determine how to arrange data in a certain order. Sorted in order here is arranged in numeric or alphabetical order as in the dictionary.

The importance of arranging data is: finding data can be optimal if the data is arranged in a certain order (increase or decrease). Arrangements are also used to represent data in a more readable format.

In-place and Not-in-place arrangement algorithms

Arrangement algorithms may need to add some extra memory for comparison and temporary memory to store some data elements.

Algorithms that do not require any extra memory and the arrangement is carried out in the previously declared memory section (eg in an array for example) is called in-place sorting. An example of this sort of algorithm is the bubble sorting algorithm (bubble sorting).

But in some sort algorithms, the program needs to add the amount of memory that can be greater than or equal to the number of elements being sorted. These algorithms are called not-in-place sorting. For example, this sort of algorithm is merge sort.

Algorithm of fixed arrangement and comparison arrangement

A sorting algorithm is called a fixed arrangement if, after conducting the alignment, the relative position between equal elements is not changed.

Algorithms arranged in data structures & algorithms Picture 1

An algorithm is called comparative sort if in the process of performing the algorithm we proceed to compare the keys and swap elements for each other. That is, the relative position of equal elements is changed.

Algorithms arranged in data structures & algorithms Picture 2

Adaptive and Non-Adaptive Alignment algorithms

An algorithm is considered as an adaptive, if it takes advantage of the sorted elements in the list that has been sorted. That is, while sorting if the initial list has some sorted elements, the adaptive form algorithm will record these elements and will try not to change their order.

In contrast to the above algorithm, the non-adaptive algorithm does not record previously arranged elements. This type of algorithm will try to rearrange each element in the original list.

Important concepts in sorting algorithms

Below is a brief introduction to some of the concepts that appear while discussing sorting algorithms:

Order increases

A range of values ​​is considered as in increasing order if the following element is larger than the preceding element. Examples: 1, 3, 5, 6, 9.

Order decreased
A range of values ​​is treated as in descending order if the following element is smaller than the preceding element. Examples: 9, 6, 5, 3, 1.

Order does not increase

A range of values ​​is considered as in the order that does not increase if the following element is smaller than or equal to the preceding element. Examples: 9, 6, 5, 5, 1. This type of order appears when in a sequence that contains the same values ​​(in the example is 5).

Order does not decrease

A range of values ​​that are considered as in order does not decrease if the following element is greater than or equal to the preceding element. Examples: 1, 5, 5, 6, 9. This type of order appears when in a sequence containing the same values ​​(in the example is 5).

According to Tutorialspoint

Previous article: Hash Table data structure

Next lesson: Bubble Sort algorithm (Bubble Sort)

5 ★ | 1 Vote

May be interested

  • Bubble Sort (Bubble Sort)Photo of Bubble Sort (Bubble Sort)
    bubble arrangement is a simple sort algorithm. this sorting algorithm is carried out based on comparing pairs of adjacent and swap elements if they are not in order.
  • Insert algorithm (Insertion Sort)Photo of Insert algorithm (Insertion Sort)
    sort insertion is a sorting algorithm based on in-place comparison. here, a sub-list is always maintained in sorted form. inserting is inserting an element into the sorted list of children. the element is inserted in the appropriate position so that the list is still in order.
  • AVL tree in data structure and algorithmPhoto of AVL tree in data structure and algorithm
    what happens if the data entered into the binary search tree (bst) is in ordered form (ascending or descending). it will look like the following.
  • Spanning Tree in data structure and algorithmPhoto of Spanning Tree in data structure and algorithm
    a spanning tree is a subset of grahp g that has all vertices enclosed by the minimum number of edges. therefore, a spanning tree will not form a cycle and it cannot be interrupted in the middle.
  • Heap data structurePhoto of Heap data structure
    data structure the heap is a special case of a balanced binary tree data structure, where the root node's key is compared to its children and arranged accordingly.
  • Selection sort algorithm (Selection Sort)Photo of Selection sort algorithm (Selection Sort)
    selection sort is a simple algorithm. this sorting algorithm is an algorithm based on in-place comparison, in which the list is divided into two parts, sorted (list) on the left and unsorted (unsorted list) in the right. initially, the sorted part is blank and the unordered part is the original list.