Git Product home page Git Product logo

bubblesortineverylang's Introduction

Bubble Sort In Every Programming Language

This repository contains different implementaions of bubble sort in different programming languages, feel free to create a PR if its not already here :) your code must print this array [21, 50, 12, 31, 61, 40, 30] and print the result after bubble sorting.

Setting up Git and Github

If this is your first time here, we suggest

  • Login / Sign-up to Github.
  • Download and install Git.
  • Configure git
  • Launch terminal or command promt.
  • Run the commands.
    git config --global user.name "Your name"
    git config --global user.email "Your email address"

What is Bubble sort ?

Bubble Sort is the most basic sorting algorithm, and it operates by frequently swapping nearby components to arrange them in an increasing order.

Here's a dry run through of the algorithm in sorting the array [ 21 ,50 ,12 ,31 ,61 ,40 ,30 ]

First Pass:

[ 21 ,50 ,12 ,31 ,61 ,40 ,30 ] since, 21 < 50 No Swap
[ 21 , 50 , 12 , 31 , 61 , 40 , 30 ] since, 50 > 12 Swap [ 21 ,12, 50 , 31 , 61 , 40 , 30 ]
[ 21 , 12 , 50 , 31 , 61 , 40 ,30 ] since, 50 > 31 Swap [ 21 , 12 , 31 , 50 , 61 , 40 , 30 ]
[ 21 , 12 , 31 , 50 , 61 , 40 , 30 ] since, 50 < 61 No Swap
[ 21 , 12 , 31 , 50 , 61 , 40 , 30 ] since, 60 > 40 Swap [ 21 , 12 , 31 , 50 , 40 , 61 , 30 ]
[ 21 , 12 , 31 , 50 , 40 , 61 , 30 ] since, 61 > 30 Swap [ 21 , 12 , 31 , 50 , 40 , 30 , 61 ]

Second Pass:

[ 21 , 12 , 31 , 50 , 40 , 30 , 61 ] since, 21 > 12 Swap [ 12 , 21 , 31 , 50 , 40 , 30 , 61 ]
[ 12 , 21 , 31 , 50 , 40 , 30 , 61 ] since, 21 < 31 No Swap
[ 12 , 21 , 31 , 50 , 40 , 30 , 61 ] since, 31 < 50 No Swap
[ 12 , 21 , 31 , 50 , 40 , 30 , 61 ] since, 50 > 40 Swap [ 12 , 21 , 31 ,40 , 50 , 30 , 61 ]
[ 12 , 21 , 31 ,40 , 50 , 30, 61 ] since, 50 > 40 Swap [ 12 , 21 , 31 , 40 , 30 , 50 , 61 ]
[ 12 , 21 , 31 , 40 , 30 , 50 , 61 ] since, 50 < 61 No Swap

Third Pass:

[ 12 , 21 , 31 , 40 , 30 , 50 , 61 ] since, 12 < 21 No Swap
[ 12 , 21 , 31 , 40 , 30 , 50 , 61 ] since, 21 < 31 No Swap
[ 12 , 21 , 31 , 40 , 30 , 50 , 61 ] since, 31 < 40 No Swap
[ 12 , 21 , 31 , 40 , 30 , 50 , 61 ] since, 40 < 30 Swap [ 12 , 21 , 31 , 30, 40 , 50 , 61 ]
[ 12 , 21 , 31 , 30 ,40 , 50 , 61 ] since, 40 < 50 No Swap
[ 12 , 21 , 31 , 30 , 40 , 50 , 61 ] since, 50 < 60 No Swap

Fourth Pass:

[ 12 , 21, 31 , 30 , 40 , 50 , 61 ] since, 12 < 21 No Swap
[ 12 , 21 , 31 , 30 , 40 , 50 , 61 ] since, 21 < 31 No Swap
[ 12 , 21 , 31 , 30, 40 , 50 , 61 ] since, 31 > 30 Swap [12 , 21 , 30 , 31 , 40 , 50 , 61 ]
[ 12 , 21 , 30 , 31 , 40, 50 , 61 ] since, 31 < 40 No Swap
[ 12 , 21 , 30 , 31 , 40 , 50 , 61 ] since, 40 < 50 No Swap
[ 12 , 21 , 30 , 31 , 40 , 50 , 61 ] since, 50 < 61 No Swap

Note: Although our array is completely sorted here, the algorithm doesn't know it yet. It needs one pass with no swaps to conclude it's operation.

Fifth Pass:

[12 , 21 , 30 , 31 , 40 , 50 , 61 ] since, 12 < 21 No Swap
[ 12 , 21 , 30 , 31 , 40 , 50 , 61 ] since, 21 < 30 No Swap
[ 12 , 21 , 30 , 31 , 40 , 50 , 61 ] since, 30 < 31 No Swap
[ 12 , 21 , 30 , 31 , 40 , 50 , 61 ] since, 31 < 40 No Swap
[ 12 , 21 , 30 , 31 , 40 , 50 , 61 ] since, 40 < 50 No Swap
[ 12 , 21 , 30 , 31 , 40 , 50 , 61 ] since, 50 < 61 No Swap

After 5 Passes the algorithm concludes and produces the output [ 12 , 21 , 30 , 31 , 40 , 50 , 61 ]

How to contribute?

We โ™ฅ Contributors!

You can solve issues or code an implementation of bubble sort in an language that isn't already implemented in the repository yet.

To ensure your contributions count, I implore you to follow the instructions mentioned in the CONTRIBUTING.md

Happy Submissions ๐Ÿ™‚

Project Maintainer

Project Contributors

bubblesortineverylang's People

Contributors

eishamazhar avatar everly-gif avatar falcon883 avatar giovannifreitas avatar mihir1739 avatar parthkholkute avatar sheharyarishfaq avatar speckyyt avatar tarithj avatar zaman3027 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

bubblesortineverylang's Issues

Create CONTRIBUTING.md

This repo is currently missing a contribution guideline(CONTRIBUTING.md file) there is a simple guideline in the README but it would be far better if it had its own separate file.

Update & Cleanup README

This repo is quite self explanatory but it would be better if the README had some information about Bubble sorting and the contributing guidelines should be under a separate heading.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.