Giter VIP home page Giter VIP logo

sorts's Introduction

O(n**2) Sorts Final

First coding assignment of the quarter where I have created algorithms for bubble, insertion and select sorts.

The star emoji represents completed code.

Unit tests created ✔️

Files separated ✔️

Bubble Sort

Bubble sort is a simple, sorting algorithm that iterates through a list to be sorted, comparing each pair adjacent to each other and swaps them if they are in the wrong order. The iteration through the list is repeated until all the numbers have been listed according to the algorithm. 🌟

Insertion Sort

Insertion sort is a simple, sorting algorthim that builds the final sorted array one element at a time. This algorithm iterates through a list, removes one element, and finds the location where it belongs. This process continues until the list is sorted. 🌟

Selection Sort

The selection sort algorithm divies input into two subsets. The algorithm finds the smallest element in the unsorted subset and swaps it with the leftmost unsorted element, while moving to the right, until the list is sorted. This process continues until both subsets are sorted. 🌟

Setup

First, compile the program by making main on the command line.

make

Now you can call the function of your choosing. e.g.

./main bubble 4 3 2 1
./main insertion 4 3 2 1
./main selection 4 3 2 1

any of the three will print

Sorted list in ascending order:
1 2 3 4

Test Setup

First, compile the unit tests by making test on the command line.

make test

Once you compile the unit test, the test functions will run automatically and display

./test_functions

Even length array works (bubble).
Odd length array works (bubble).
Negative, odd numbered array works (bubble).
Bubble sort works.

Even length array works (selection).
Odd length array works (selection).
Negative, odd numbered array works (selection).
Selection sort works.

Even length array works (insertion).
Odd length array works (insertion).
Negative, odd numbered array works (insertion).
Insertion sort works.

on the terminal.

sorts's People

Contributors

hyfr avatar

Watchers

James Cloos avatar  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.