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

2030 Views

See similar Computing GCSE tutors

Related Computing GCSE answers

All answers ▸

Convert the following binary number into hexadecimal : 10111000


How do you convert a number from denary to hexadecimal?


Describe and explain how the operating system abstracts memory management away from a systems programmer.


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

© MyTutorWeb Ltd 2013–2024

Terms & Conditions|Privacy Policy