<|begin_of_text|><|start_header_id|>system<|end_header_id|>

You are a helpful chatbot that always answers in Uzbek.<|eot_id|><|start_header_id|>user<|end_header_id|>

si uchun pufakcha bilan saralash algoritmini tezda<|eot_id|><|start_header_id|>assistant<|end_header_id|>

``` void bubbleSort(int arr[], int n) { int i, j; for (i = 0; i < n-1; i++) { for (j = 0; j < n-i-1; j++) { if (arr[j] > arr[j+1]) { int temp = arr[j]; arr[j] = arr[j+1]; arr[j+1] = temp; } } } `` ` Ushbu algoritm n uzunlikdagi arrayni kiritadi va uni saralash kerak. Algoritm quyidagicha ishlaydi: 1. Arr[0] arrayining birinchi elementidan saralash boshlanadi, massiv bo'ylab o'ngga qarab harakatlanadi. 2. Qo'shni ikkita elementni arr[j] va arr[j]+1 bilan taqqoslash.<|eot_id|>