What Is Array Sorting?
Sorting is an operation often performed in a computer, and its purpose is to adjust a set of "out-of-order" record sequences to an "ordered" record sequence. There are internal sorting and external sorting. If the entire sorting process can be completed without accessing external memory, this sort of sorting problem is called internal sorting. Conversely, if the number of records participating in the sorting is large, the sorting process of the entire sequence cannot be completed in memory, so this sorting problem is called external sorting. The internal sorting process is a process of gradually increasing the length of the ordered sequence of records. [1]
- Will be messy
- by
- Quick sorting is the fastest sorting method among commonly used sorting algorithms known to everyone. [4]
- Given a set of unordered positive integer data a [1], a [2], ... a [n], they need to be arranged in ascending order. First define a
Sorting principle
- Tree selection sort, also known as Tournament Sort, is a method of selecting and sorting according to the idea of tournament. First make a pairwise comparison of the keywords of the n records, and then make a pairwise comparison between the n / 2 smaller ones, and repeat this until the smallest record is selected. The key to tree ordering is to make all the left subtrees larger than the root and right subtrees. [1]
Sorting pros and cons
- Advantages: high efficiency.
- Cons: Unstable.
Pascal Sort Pascal Program
- program shupai;
- type
- point = ^ nod;
- nod = record
- w: integer;
- right, left: point;
- end;
- var
- a: array [1..100] of integer;
- root, first: point;
- k: boolean;
- i: integer;
- procedure hyt (d: integer; var p: point);
- begin
- if p = nil then
- begin
- new (p);
- with p ^ do begin
- w: = d;
- right: = nil;
- left: = nil
- end;
- if k then
- begin
- root: = p;
- k: = false
- end;
- end
- else
- with p ^ do
- if d> = w then
- hyt (d, right)
- else
- hyt (d, left);
- end;
- procedure hyt1 (p: point);
- begin
- with p ^ do
- begin
- if left <> nil then
- hyt1 (left);
- write (w, '');
- if right <> nil then hyt1 (right);
- end;
- end;
- begin
- first: = nil;
- k: = true;
- readln (n);
- for i: = 1 to n do
- read (a [i]);
- for i: = 1 to n do
- hyt (a [i], first);
- hyt1 (root);
- end.