Re: [BLACKBOX] AVL Trees

From: [at]} <Bob>
Date: Wed, 7 Sep 2011 19:17:49 +0100

----boundary-LibPST-iamunique-391380553_-_-
Content-type: text/plain

> then count the list.
...
> I then traverse the ordered list counting distinct entries.

Why do you need a second pass to count them? You should just add 1 when
you've put a new entry in the list.

Bob

> -----Original Message-----
> From: BlackBox [mailto:BLACKBOX{([at]})nowhere.xy
> Robert (SELEX GALILEO, UK)
> Sent: 07 September 2011 09:27
> To: BLACKBOX{([at]})nowhere.xy
> Subject: Re: [BLACKBOX] AVL Trees
>
> >> Hello Robert,
> >>
> >> What do you call a fast list?
> >>
> >> Gérard

>
>
> The problem generates 'B' numbers in a some order I shall call
> 'Random', since I
> can't exploit it.
>
> I want to count the number of distinct numbers 'A'.
>
>
> My 'Slow list-based algorithm' is to add each number to the list
> maintaining order
> and rejecting duplicates, then count the list. This requires of order B
> * A comparisons,
> but the list length is no more than A.
>
> My 'Fast list-based algorithm' is to add all the numbers to the list in
> order of arrival,
> then sort the list. I use Merge sort, which is in my list library so
> required no new coding,
> but any B Log (B) sort, or Quicksort, would be fine.
> I then traverse the ordered list counting distinct entries.
>
> The downside is that the list has a length of B, which might be much
> more than A.
>
>
> The actual problem is
> http://projecteuler.net/index.php?section=problems&id‡
>
>
> I like Merge sort & Heap sort because although they are not the fastest
> on average, they both
> have good worst case performance. I find Merge sort convenient for
> lists, Heap sort convenient for
> arrays.
>
>
> Regards
>
> Robert
>
>
> SELEX Galileo Ltd
> Registered Office: Sigma House, Christopher Martin Road, Basildon,
> Essex SS14 3EL
> A company registered in England & Wales. Company no. 02426132
> ********************************************************************
> This email and any attachments are confidential to the intended
> recipient and may also be privileged. If you are not the intended
> recipient please delete it from your system and notify the sender.
> You should not copy it or use it for any purpose nor disclose or
> distribute its contents to any other person.
> ********************************************************************
>
>
> ----
> To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to
> LISTSERV{([at]})nowhere.xy


----
To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy----boundary-LibPST-iamunique-391380553_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzc1xmY2hhcnNldDAgQXJpYWw7fQ0Ke1xmMVxmbW9kZXJuIENvdXJpZXIgTmV3O30NCntcZjJc
Zm5pbFxmY2hhcnNldDIgU3ltYm9sO30NCntcZjNcZm1vZGVyblxmY2hhcnNldDAgQ291cmllciBO
ZXc7fX0NCntcY29sb3J0YmxccmVkMFxncmVlbjBcYmx1ZTA7XHJlZDBcZ3JlZW4wXGJsdWUyNTU7
fQ0KXHVjMVxwYXJkXHBsYWluXGRlZnRhYjM2MCBcZjBcZnMyMCA+IHRoZW4gY291bnQgdGhlIGxp
c3QuIFxwYXINCi4uLlxwYXINCj4gSSB0aGVuIHRyYXZlcnNlIHRoZSBvcmRlcmVkIGxpc3QgY291
bnRpbmcgZGlzdGluY3QgZW50cmllcy5ccGFyDQpccGFyDQpXaHkgZG8geW91IG5lZWQgYSBzZWNv
bmQgcGFzcyB0byBjb3VudCB0aGVtPyBZb3Ugc2hvdWxkIGp1c3QgYWRkIDEgd2hlblxwYXINCnlv
dSd2ZSBwdXQgYSBuZXcgZW50cnkgaW4gdGhlIGxpc3QuXHBhcg0KXHBhcg0KQm9iXHBhcg0KXHBh
cg0KPiAtLS0tLU9yaWdpbmFsIE1lc3NhZ2UtLS0tLVxwYXINCj4gRnJvbTogQmxhY2tCb3ggW21h
aWx0bzpCTEFDS0JPWEBMSVNUUy5PQkVST04uQ0hdIE9uIEJlaGFsZiBPZiBDYW1wYmVsbCxccGFy
DQo+IFJvYmVydCAoU0VMRVggR0FMSUxFTywgVUspXHBhcg0KPiBTZW50OiAwNyBTZXB0ZW1iZXIg
MjAxMSAwOToyN1xwYXINCj4gVG86IEJMQUNLQk9YQExJU1RTLk9C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T0ZGIEJMQUNLQk9YIiB0byBM
SVNUU0VSVkBMSVNUUy5PfX0AMjXiMgNDdGV4BUEB
----boundary-LibPST-iamunique-391380553_-_---
Received on Wed Sep 07 2011 - 20:17:49 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:30:11 UTC