Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
92 views2 pages

LAB211 Assignment: Title Background Context

The document outlines an assignment to design a program implementing the bubble sort algorithm, which is a simple but inefficient O(n²) sorting method. Users will input a positive integer to generate and sort an array of random integers, displaying both the unsorted and sorted arrays. The assignment includes guidelines on the algorithm's functionality and user interface expectations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
92 views2 pages

LAB211 Assignment: Title Background Context

The document outlines an assignment to design a program implementing the bubble sort algorithm, which is a simple but inefficient O(n²) sorting method. Users will input a positive integer to generate and sort an array of random integers, displaying both the unsorted and sorted arrays. The assignment includes guidelines on the algorithm's functionality and user interface expectations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Type: Short Assignment

Code: J1.S.P0001

LAB211 Assignment LOC:


Slot(s):
40
1

Title
Bubble sort algorithm.
Background Context
Bubble sort is a simple and well-known sorting algorithm. It is used in practice once in a blue moon and its
main application is to make an introduction to the sorting algorithms. Bubble sort belongs to O(n2) sorting
algorithms, which makes it quite inefficient for sorting large data volumes. Bubble sort is stable and adaptive.
Program Specifications

Design a program that allows users to input the number of array. Generate random integer in number range
input. Display unsorted array and sorted array using bubble sort.

Function details:
1. Display a screen to prompt users to input a positive integer number.
o Users run the program, display a screen to ask users to enter a positive integer number.

o Users input a positive integer number. Then, perform Function 2.

2. Display & sort array.


o Generate random integer in number range for each array element.

o Display array before and after sorting.

Expectation of User interface:

Guidelines

Algorithm

1. Compare each pair of adjacent elements from the beginning of an array and, if they are in reversed order, swap
them.
2. If at least one swap has been done, repeat step 1.

You can imagine that on every step big bubbles float to the surface and stay there. At the step, when no bubble moves,
sorting stops. Let us see an example of sorting an array to make the idea of bubble sort clearer.

Example. Sort {5, 1, 12, -5, 16} using bubble sort.

You might also like