Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #147550

Re: So here's a fun challenge

From Ian Collins <ian-news@hotmail.com>
Newsgroups comp.lang.c
Subject Re: So here's a fun challenge
Date 2019-11-04 08:03 +1300
Message-ID <h28mjmFa2cqU10@mid.individual.net> (permalink)
References <NNgvF.21265$hh5.17108@fx07.iad> <5dbf0295.12592219@core>

Show all headers | View raw


On 04/11/2019 06:35, Scott wrote:
> On Sat, 2 Nov 2019 10:53:01 -0400, DFS <nospam@dfs.com> wrote:
> 
>> - create 2 (equal or unequal sized) arrays of random strings of random
>>     lengths from low to high, ie 2 to 4, or 8 to 16, etc
>> - manually add a few of the same values to each array to ensure dupes
>> - print the top and bottom 10 to show initial data set
>> - combine the arrays
>> - case-insensitive sort the arrays (I use qsort but any method is fine)
>> - dedupe the combined array
>> - add the unique vals to a new array that's sized appropriately
>> - print the top and bottom 10 to show final sorted data
> 
> Data points for you - Win10, Intel i5-8600 @3.6GHz. I just copied your
> code (I may attempt my own later):

<snip>

> randclc 100000000 8 16
> = 279.29 s

I wonder if the platform is playing a part?  On my Ryzen 2700 
(reasonably but not very fast) with Ubuntu 18.04, the C version:

14.9726s to create 100000000 random string elements (+ add dupes)
qsorting... 76.1025s
program ran in 103.0170s seconds
real	1m43.187s

C++:
12.8076S to create 100000000 random string elements (+ add dupes)
40.4154S to sort
1.10336S to dedup
real	0m56.337s

Which also highlights the difference between sorting in C and C++.

-- 
Ian.

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

So here's a fun challenge DFS <nospam@dfs.com> - 2019-11-02 10:53 -0400
  Re: So here's a fun challenge Bart <bc@freeuk.com> - 2019-11-02 17:08 +0000
    Re: So here's a fun challenge Richard Damon <Richard@Damon-Family.org> - 2019-11-02 15:01 -0400
      Re: So here's a fun challenge Bart <bc@freeuk.com> - 2019-11-02 19:38 +0000
        Re: So here's a fun challenge Richard Damon <Richard@Damon-Family.org> - 2019-11-02 16:07 -0400
        Re: So here's a fun challenge DFS <nospam@dfs.com> - 2019-11-03 09:29 -0500
  Re: So here's a fun challenge Bart <bc@freeuk.com> - 2019-11-02 20:36 +0000
    Re: So here's a fun challenge DFS <nospam@dfs.com> - 2019-11-03 09:33 -0500
      Re: So here's a fun challenge Paul <nospam@needed.invalid> - 2019-11-03 20:53 -0500
  Re: So here's a fun challenge Ian Collins <ian-news@hotmail.com> - 2019-11-03 14:33 +1300
    Re: So here's a fun challenge Ian Collins <ian-news@hotmail.com> - 2019-11-03 14:35 +1300
      Re: So here's a fun challenge DFS <nospam@dfs.com> - 2019-11-03 00:18 -0400
        Re: So here's a fun challenge Ian Collins <ian-news@hotmail.com> - 2019-11-03 18:02 +1300
          Re: So here's a fun challenge Bart <bc@freeuk.com> - 2019-11-03 11:19 +0000
            Re: So here's a fun challenge Ian Collins <ian-news@hotmail.com> - 2019-11-04 00:33 +1300
          Re: So here's a fun challenge DFS <nospam@dfs.com> - 2019-11-03 09:39 -0500
    Re: So here's a fun challenge Autist <autist69@gmail.com> - 2019-11-03 11:16 +0100
      Re: So here's a fun challenge Autist <autist69@gmail.com> - 2019-11-03 11:29 +0100
      Re: So here's a fun challenge Ian Collins <ian-news@hotmail.com> - 2019-11-03 23:34 +1300
      Re: So here's a fun challenge Melzzzzz <Melzzzzz@zzzzz.com> - 2019-11-03 11:04 +0000
        Re: So here's a fun challenge Autist <autist69@gmail.com> - 2019-11-03 14:56 +0100
          Re: So here's a fun challenge Autist <autist69@gmail.com> - 2019-11-03 15:36 +0100
  Re: So here's a fun challenge nobody@example.org (Scott) - 2019-11-03 17:35 +0000
    Re: So here's a fun challenge Ian Collins <ian-news@hotmail.com> - 2019-11-04 08:03 +1300
    Re: So here's a fun challenge DFS <nospam@dfs.com> - 2019-11-04 10:07 -0500
      Re: So here's a fun challenge nobody@example.org (Scott) - 2019-11-04 16:06 +0000
        Re: So here's a fun challenge DFS <nospam@dfs.com> - 2019-11-04 15:33 -0500

csiph-web