Pyramid sorting algorithm

A sorting algorithm and pyramid technology, applied in computing, digital data processing, special data processing applications, etc., can solve the problems of heap sorting performance impact, quick sorting performance reduction, and many invalid moves.

Inactive Publication Date: 2016-05-11
CHANGZHOU COLLEGE OF INFORMATION TECH
View PDF3 Cites 5 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

Quick sort is a sorting algorithm with excellent performance, but if the quick sort reference value is not selected properly or the sequence to be sorted is basically ordered, the performance of quick sort will be greatly reduced
Heap sorting is faster than quick sorting when the sequence to be sorted is basically ordered, but heap sorting also has disadvantages: when the elements to be sorted are complex data structures, due to the large number of invalid moves in heap sorting, there is also a negative impact on heap sorting performance. greater impact

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Examples

Experimental program
Comparison scheme
Effect test

Embodiment 1

[0015] The pyramid sorting algorithm of the present embodiment comprises the following steps:

[0016] ①. When sorting n data, first define an array a with n units, and then find an integer m, m is an integer power of 2, and m / 2

[0017] The way to find the integer m is: assign a value of 1 to a variable, then compare the variable with the value of n, if it is smaller than n, multiply it by 2, compare it with the value of n again, ... until the data Until it is greater than or equal to n, the value of this variable is m at this time.

[0018] ②. Define a b array with m units, the b array forms the base of the pyramid; define a c array with m units, and the c array forms the pyramid body.

[0019] ③. Initialize the c array, put the n data to be sorted into the b array, and put m-n minimum value data in the b array, the minimum value data is the minimum value data among the n data, forming m / 2 pairs of adjacent data; then compare them one by one, put the relatively large...

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

PUM

No PUM Login to view more

Abstract

The invention discloses a pyramid sorting algorithm. According to the pyramid sorting algorithm, firstly, an integer m being integral power of 2 is found, and n is larger than m/2 and smaller than or equal to m; then n data required to be sorted are placed into a b array; adjacent data in the b array are compared one by one, and relatively larger subscripts are placed in a (m/2)-(m-1) unit of a c array; adjacent data in b[c[m-1]]-b[c[m/2]] are compared one by one, relatively larger subscripts are placed in c[m/2-1]-c[m/4], and so on; finally, subscripts of maximum data of the whole b array can be placed in c[1]; then maximum values in the b array are found out continuously, and sorting is completed. Under the condition that to-be-sorted sequences are basically sorted, the sorting speed of the pyramid sorting algorithm is obviously superior to that of quick sorting; under the condition that to-be-sorted elements adopting a more complicated data structure are sorted, the sorting speed of the pyramid sorting algorithm is obviously superior to that of heap sorting.

Description

technical field [0001] The invention relates to a pyramid sorting algorithm. Background technique [0002] Currently, when sorting large amounts of data, the quicksort algorithm is usually chosen. Quick sort is a sorting algorithm with excellent performance, but if the quick sort reference value is not selected properly or the sequence to be sorted is basically ordered, the performance of quick sort will be greatly reduced. Heap sorting is faster than quick sorting when the sequence to be sorted is basically ordered, but heap sorting also has disadvantages: when the elements to be sorted are complex data structures, due to the large number of invalid moves in heap sorting, it also has a negative effect on heap sorting performance. greater impact. Contents of the invention [0003] The purpose of the present invention is to provide a pyramid sorting algorithm, which improves the sorting speed when the sequence to be sorted is basically ordered and the elements to be sorte...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

Application Information

Patent Timeline
no application Login to view more
Patent Type & Authority Applications(China)
IPC IPC(8): G06F19/00
CPCG16Z99/00
Inventor 吕勇刘斌
Owner CHANGZHOU COLLEGE OF INFORMATION TECH
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Try Eureka
PatSnap group products