Code Monkey home page Code Monkey logo

bubble-sort-visualizer's Introduction

Bubble-Sort-Visualizer

Authors: Hamza Siddiqui

About: Bubble Sort: Bubble Sort is a simple sorting algorithm that compares values that neighbor eachother in a data-set/structure. Given two things to compare, once Bubble Sort sees that a comparison being tested is true, it swaps those values in the set. This algorithm does O(n^2) time because of its reliance on a nested loop.

This implementation: For my implementation, I used an array to hold values corresponding to the heights of the shapes used to visualize the sort. The array was populated with random values bounded by the height of the window, and had a length of the width of the window. I used standard Bubble Sort to sort all the values in the array from least to greatest. The algorithm involved nesting a loop that spans the entire array inside another loop that spans the array. The outer loop and its i variable are used to define how many values have already been sorted (the end of the array is gradually sorted as the algorithm progresses). The inner loop is meant to compare each element to the next element in the array. A standard swap method is used to swap any values for which the comparison returns true. This implementation uses a JavaScript framework based on processing called p5.js.

Demo: https://editor.p5js.org/Hamza_sid/present/GFy27Z9Np

bubble-sort-visualizer's People

Contributors

hamza-sid avatar

Watchers

 avatar

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.