## Introduction

Bubble Sort is a simple sorting algorithm that repeatedly swaps adjacent elements if they are in the wrong order. It is named as bubble sort because the smaller elements bubble up to the top of the list as the algorithm iterates through the list. Bubble Sort is not an efficient algorithm for large lists and is generally used for educational purposes.

## Implementation

Here is an implementation of Bubble Sort in OCaml:

``````let bubble_sort arr =
let n = Array.length arr in
for i = 0 to n - 2 do
for j = 0 to n - i - 2 do
if arr.(j) > arr.(j+1) then
let temp = arr.(j) in
arr.(j) <- arr.(j+1);
arr.(j+1) <- temp
done
done;;
``````

Here, `arr` is the array to be sorted. The function `bubble_sort` uses two nested loops to iterate through the array and compare adjacent elements. If the elements are in the wrong order, they are swapped. The outer loop iterates from 0 to n-2, while the inner loop iterates from 0 to n-i-2. This is because the largest element in the list will already be in its correct position after each iteration of the outer loop.