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

2574 Views

See similar Computing GCSE tutors

Related Computing GCSE answers

All answers ▸

Calculate the file size in bits for a two minute sound recording that has used a sample rate of 1000 Hertz (Hz) and a sample resolution of 5 bits.


Describe the process used by a binary search algorithm, and explain why binary search would not be appropriate for the list [3,2,5,7,9]


Describe how sensors and microprocessors are used to maintain certain conditions.


Describe the differences between a binary and linear search algorithm.


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