Skip to content

This program is written in C language and implements the Bubble Sort algorithm to sort an array of 5 integers in ascending order

Notifications You must be signed in to change notification settings

pooja210603/Bubble_Sort

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Bubble Sort

This program is written in C language and implements the Bubble Sort algorithm to sort an array of 5 integers in ascending order. The program initializes an unsorted array of integers and calls the Bubble Sort function to sort the array in place. The program then outputs the sorted array.

Algorithm:

  1. The program defines the Bubble Sort function, which takes an integer array and its size as inputs.
  2. The Bubble Sort algorithm is used to sort the array in ascending order.
  3. The function implements two loops, one to iterate over each element in the array and another to compare adjacent elements and swap them if necessary.
  4. The sorting process continues until all the elements are sorted in ascending order. Finally, the function outputs the sorted array.
  5. The main function initializes an integer array with 5 unsorted elements and calls the Bubble Sort function to sort the array in ascending order.

image

Advantages:

  1. Bubble Sort is simple to implement and understand, making it a good choice for small arrays.
  2. Bubble Sort is stable, meaning that it preserves the relative order of equal elements in the sorted array.

Output

image

About

This program is written in C language and implements the Bubble Sort algorithm to sort an array of 5 integers in ascending order

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages