ComputersProgramming

Sort by choice

One important way to work with data is sorting. Its use not only speeds up, but also greatly simplifies the necessary and important in the field of programming process. A narrow erase of this concept in the environment of programmers means the ordering of records in the database.

Sorting methods are relevant to this day, although technical progress has been replenished with modern methods of computing. Known in his field scientist D. Knuth argues that almost half the time in the work on data processing is busy sorting them. He points out three reasons that explain this course of events:

  1. Sorting by choice and other methods is very widely used.
  2. Its algorithm is often used without special need.
  3. An imperfect model is used to solve the set tasks.

In order to speed up the process of data processing, first of all it is necessary to find a solution to these problems. Programmers try to create a structure that itself could use algorithms when needed. If it is created, then work with a large amount of data will be accelerated significantly and considerable resources will be saved in computing. But so far this has not happened, and we will consider the methods of sorting that exist to date.

All of them are divided into internal or external. The essence of the first method is that all records that are sorted are placed in the machine's RAM. But when this does not happen, external sorting processes are required, and often they are built on the first mentioned methods with only minor additions.

Sorting by choice, which will be discussed, refers to the internal. It is necessary to dwell on it in more detail, since this method of processing allows for more flexible and profitable sorting. All its methods are divided into 4 main groups:

  1. Sorting by insertions.
  2. Processing of data by counting.
  3. Exchange process.
  4. Sort by choice.

It should be noted that there are no clear distinctions between them, they are closely intertwined and very similar. This causes a certain connection in their work. The simplest example of working with data processing is sorting by counting. It is, as it were, the basis for others, but it is very rarely used today. Another method - inserts - is more important. His idea is that the particular key being considered is placed on the place assigned to it. But here there are a number of inconveniences and this is negatively reflected in the work on a large number of records. Many very productive methods of data processing are present in the exchange sorting. The most popular and visual in this group is the so-called bubble method. Work in it is built on the following algorithm: the comparison of successive records is performed sequentially and, if the value of the first of them is greater, they simply change places. Such a process goes on until complete ordering.

And, finally, one of the most important, but at the same time, uncomplicated ways of processing databases is sorting by choice. As mentioned above, it belongs to the group of internal ones and it is possible to connect several types on its basis. The essence of the method is a choice, and multiple, one element. The actions are performed in the following order: the smallest element from the list is selected, then it should be sent to the output area and its value replaced by more than all the others. The sequence of actions is repeated until all the data in the list is fully selected.

It is quite clear that the implementation of the algorithm will require the visibility of all elements and, in addition, the area for outputting the data. And here there is the most natural way - this sorting is a simple choice, that is, splitting the list into several. With it, you should select the smallest element of the array and swap it with the first one. Above those elements that have remained, such manipulations are again performed until complete conformity.

Similar articles

 

 

 

 

Trending Now

 

 

 

 

Newest

Copyright © 2018 en.unansea.com. Theme powered by WordPress.