What is Bubble Sort algorithm and how it works? Give an example of pseudo-code explaining the process.

A Bubble Sort algorithm is one of the simplest and easy-to-program sorting algorithms, at an expense of inefficiency. One of the main reasons why it is simple is because that it uses the notion of swapping by comparison the neighbouring elements in the array or in other kind of not pre-sorted list data structure.The pseudo-code is as simple as the real code itself: it utilises two "for" type loops and compares two neighbouring elements in the array. Swapping is performed by introducing a temporary variable, "temporaryElement".algorithm BubbleSort(array A): for each i = 0 in the array A in steps of 1 do: for each j = 0 in the array A in steps of 1 do: if A[i] < A[j]: temporaryElement = A[i]; A[i] = A[j]; A[j] = temporaryElement; end if end for end for

Answered by Nedas M. Computing tutor

2492 Views

See similar Computing GCSE tutors

Related Computing GCSE answers

All answers ▸

Why are certain fields chosen to be the primary key in a database?


Convert 01010001 from binary to decimal


how do you convert binary to a form in which you can perform subtraction?


Describe the time complexity for the search operation in a binary search tree.


We're here to help

contact us iconContact usWhatsapp logoMessage us on Whatsapptelephone icon+44 (0) 203 773 6020
Facebook logoInstagram logoLinkedIn logo
Cookie Preferences