bubble and selection algorithm