Git Product home page Git Product logo

merge-sort's Introduction

Merge-Sort

Merge Sort is a sorting algorithm used in Computer Science.

Time complexity cases of Merge Sort are:

Best Case Complexity O(nlog n) *

Worst Case Complexity O(nlog n) *

Average Case Complexity O(nlog n) *

So, why the all situations are the same?

Because Merge Sort always works with Divide and Conquer methods.

What are the Divide and Conquer methods?

Divide and Conquer methodologies are coming from the ancient Roman politicians at history. When the ancient politicians decide to develop an efficient method to defeat the enemies, they improved these methods. According to these methods, if you divide your enemies to small pieces, then you can conquer them easily. As a result, hence, we should understand how can we find solutions easily to huge problems.

How Merge Sort algorithm works

1- The first step is dividing unsorted elements into sub element groups. But the dividing have to be at the middle point.

2- If still there are sub element groups to dividing, the second step goes like the before one. The sub element groups need to divide to into sub element groups. If there are not any element groups to dividing,- and all elements are single-, then we must pass to the other step.

3- Let's start pairing with the two single elements which are adjacent. But the pairing should be doing sorted.

4- When all element groups were paired as sorted, then we got a sorted array.

Let's check the example.

Example 1: [16,21,11,8,12,22]

solution of example1

merge-sort's People

Contributors

huseyingulsin 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.