Coder Social home page Coder Social logo

blitsort's People

Contributors

scandum avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

blitsort's Issues

Number of swaps

Hi, I wanted to ask about the complexity of the number of swaps/moves/assignments that come from the merging algorithm. The table only gives the complexity of the comparisons and extra memory used.

The description about the merging algorithm let it sound similiar to Symmerge and Recmerge:

A rotate merge sort uses rotations to partition two sorted arrays until they're small enough to be merged using auxiliary memory. Blitsort does so by taking the center element of the first array, using a binary search to find all elements smaller than the center element in the second array, and performing an array rotation. It does so recursively until a partition becomes small enough to be merged.

It probably recursively halves the size and rotates. I assume, the number of swaps/moves/assignments is O(m*Log2(m+n)) for two sorted sequences of sizes m and n, where m <= n. This would then result in a total complexity for blitsort of O(N*Log2(N)) comparisons and O(N*Log2(N)*Log2(N)) swaps/moves, if my assumption is correct. This would also be in line with the observation:

Performance on larger arrays degrades steadily

To sum up my question: Has blitsort a total worst-case complexity of O(N*Log2(N)) or O(N*Log2(N)*Log2(N))?

Random int test record on mac

I wrote a simple test program. The output revealed qsort is better than blitsort on ARM macOS when sort the random int.
And on ARM macos, the size of long long and size of long double maybe is the same.
I used gcc to compile the code, compiler said duplicated value 8byte. So I commented the line and compiled successfully.
I don't know wether the qsort implementation in c is optimized on ARM Macos or not.I'm just a noob, the code maybe have some errors. You can point out my error. My operating system is bigsur 11.0 on mac.
My code as follow:

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <time.h>
#include <errno.h>
#include <math.h>

#include "blitsort.h"

int cmp_int (const void * a, const void * b)
{
return ( (int)a - (int)b );
}

long long utime()
{
struct timeval now_time;
gettimeofday(&now_time, NULL);
return now_time.tv_sec * 1000000LL + now_time.tv_usec;
}

int main(){
int a[100000],b[100000],c[100000];
int seed = time(NULL);
srand(seed);
long long assignment_start_one = utime();
for(int i = 0;i < 100000;i++){
a[i] = rand();
}
for(int j = 0;j < 100000;j++){
b[j] = a[j];
c[j] = a[j];
}
long long assignment_end_one = utime();
printf("Assignment time: %lld. \n",assignment_end_one - assignment_start_one);
long long start = utime();
blitsort(b,100000,sizeof(int),cmp_int);
long long end = utime();
long long total = end - start;
long long start_qsort = utime();
qsort(c,100000,sizeof(int),cmp_int);
long long end_qsort = utime();
long long total_qsort = end_qsort - start_qsort;
printf("Blitsort time: %lld. \n",total);
printf("Qsort time: %lld. \n",total_qsort);
return 0;
}

Problems when building blitsort

Hello!

When building code I get lots of errors (1370 exactly). Most of them are "use of undeclared identifier" or "unknown type name". Any help here?.

Also, what is supposed I have to pass in the last parameter of blitsort func (type CMPFUNC*)?

Thanks in advance.

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.