Bubble sorting of a one-dimensional array: algorithm, C code

In working with information, the most advantageous ways of storing it are structures and arrays. The latter can contain any of the same type of data that is convenient to use in the program. They are often used in online stores and in game development. Therefore, the data contained in them are repeatedly sorted and interchanged, and logical or mathematical operations are performed on them. One way to clean up an array is through bubble sorting. This publication will examine its C code and permutation logic.

Array Sort Algorithm

, - . . . , .

bubble sort




. , . 8 0 . . 5 . 5 3 — . , , 5 . , — 3 9. .





bubble sorting algorithm




, : , . , . - .

. . , , . . , . , , .

, , , - . , , . N- N . . .





. void. , . .

bubble sorting algorithm




, . , . . — 100 .

, , , . , scanf(«%d», &value). «%d» - , , . value , .

, . , , : BubleSort(dataArray, sizeDataArray). , , . , dataArray – , , sizeDataArray – .

bubble array sorting




BubleSort() , sizeArray, , sizeDataArray. , BubleSort() dataArray. printArrayFunction() ArrayIntegerInputFunction(). , . , .

, , . , . , .

. , . .

bubble sort by inserts




Such processing is faster and has less computational complexity. C code is presented in a graphical application.

perform bubble sorting




It is also made in the form of a function, in which the name of the array in need of ordering and the size of the array are passed as arguments. Here you can see how slow bubble sorting is. Inlays, similar work is much faster and has compact program code.




All Articles