Coder Social home page Coder Social logo

efficient_sorting_using_multithreading's Introduction

Sorting a large array using threads in an eficient way

  • This source codes focusses on posix threads and sorting

  • uses linux environment

  • has 2 different implementations

  • MAKE FILE
We have a makefile which is responsible for compiling the source codes and producing the executables named model1 and model2.
command:
> $make

And then we have a clean option in make file which clears the executables and removes the output file.
command:
> $make clean
  • about the programs

The source codes accepts a file named "inp.txt" which has two values S and T, which refers to the number of elements in the array and number of threads to be used, raised to the power of 2.

The source code 1 creates an array of size 2 raised to the power of S and then the threads of number 2 raised to power of T, sorts the array segment wise with segment size of 2 raised to the power of S-T. And then it merges the sorted segments sequentially to get an sorted array.

The source code 2 does the same way as source code 1 does till merging. The merge process is carried out in a different way, that the merging is done with threads here too, in a way that the threads becomes halves of the previously existing threads, each thread merging two sorted segments at a time and then continues till the count reaches one, suggesting the array is completely sorted.

Tested for inputs for values S <= 12 and T <= S

Comments are written in detail in source codes. Any improvements in the code are highly appreciated. Input file is attatched for reference.

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.