Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #34851
| From | Melzzzzz <mel@zzzzz.com> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: Rosetta Code: Top rank per group |
| Date | 2014-12-09 05:08 +0100 |
| Organization | albasani.net |
| Message-ID | <20141209050842.1695200d@maxa-pc> (permalink) |
| References | <77e31dd1-7692-4ef6-83b7-8f2fe3cb7957@googlegroups.com> <f7ed596e-a72d-4e9f-bcc7-82fc6037498f@googlegroups.com> |
On Mon, 8 Dec 2014 16:43:22 -0800 (PST) hughaguilar96@gmail.com wrote: > On Wednesday, February 12, 2014 6:37:15 PM UTC-7, Julian Fondren > wrote: > > 1. brute-force the answer with high-level data structures: walk the > > table, adding departments as keys to a hash table, the values of > > which are lists of salaries. Once you've exhausted the table, sort > > the keys of the hash (for nice output) and then print them and > > their top N of the sorted lists of salaries. > > > > (If you've never used a Perl oneliner that you wrote in a minute to > > chew on multiple repquota streams and spit out the top > > diskspace-using users, then that I call this a 'good solution' may > > puzzle you.) > > A program like this is trivial using my ASSOCIATION.4TH in the novice > package: http://www.forth.org/novice.html > It uses an LLRB tree internally, and it allows associations (or > subsets of associations) to be traversed in order. I would just build > one association sorted by department, then for each department I > would build an association sorted by salary, then just dump out the > leftmost N nodes. For a real program that has a lot of data and has > to be robust, it would make more sense to build an association sorted > by name, and then build associations sorted by department, salary, > etc. in which the record is a pointer to a node in the main > association --- like a relational-database, this saves memory by not > replicating data. Hm, sounds complicated. SQL/Database is best for such tasks... You just have to send SQL command and that's all. Not worth a fuss... > > I don't think Rosetta Stone allows the use of libraries however --- > so it favors languages such as Perl that have data-structures built > in --- if the programmer has to implement all of these > data-structures from scratch as Elizabeth Rather demands her cult > members to do, the program is going to be huge and complicated. It > will also likely use an inefficient data-structure such as a basic > binary-tree rather than an LLRB tree, because implementing an LLRB > tree for a single program is way too much work. What's so good about LLRB tree? I think that classical RB tree performs better. Only advantage of LLRB is like AA tree ease of implementation, I guess... > > Actually, implementing a basic binary tree with insert and delete is > a lot of work too, Nope, not much of a code. It requires some thinking but nothing one cannot finish in couple of days. if it has to be done from scratch for every > program. One can write it once and use it in every other program. It is not necessary to write everytime one starts new program. Problem is that like C (which also doesn;t have standard container library) Forth is low level language and people can't agree on interface. This is why ANS-Forth is never used in commercial > programming --- implementing everything from scratch is just too much > work --- the boss expects a trivial program like this to be done in > an hour or two, and he will fire a programmer who spends a week on it > and then says: "Well, um, I'm bogged down in figuring out how LLRB > trees work, as they are quite complicated!" There is internet, but then again, there are programmers that make memory leaks in Java :p
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Rosetta Code: Top rank per group hughaguilar96@gmail.com - 2014-12-08 16:43 -0800
Re: Rosetta Code: Top rank per group Melzzzzz <mel@zzzzz.com> - 2014-12-09 05:08 +0100
Re: Rosetta Code: Top rank per group hughaguilar96@gmail.com - 2014-12-09 21:43 -0800
Re: Rosetta Code: Top rank per group hughaguilar96@gmail.com - 2014-12-09 21:55 -0800
Re: Rosetta Code: Top rank per group november.nihal@gmail.com - 2014-12-10 03:40 -0800
Re: Rosetta Code: Top rank per group hughaguilar96@gmail.com - 2014-12-11 19:15 -0800
Re: Rosetta Code: Top rank per group hughaguilar96@gmail.com - 2014-12-13 09:11 -0800
Re: Rosetta Code: Top rank per group "WJ" <w_a_x_man@yahoo.com> - 2014-12-15 06:08 +0000
Re: Rosetta Code: Top rank per group "WJ" <w_a_x_man@yahoo.com> - 2014-12-17 02:50 +0000
Re: Rosetta Code: Top rank per group hughaguilar96@gmail.com - 2014-12-18 22:06 -0800
Re: Rosetta Code: Top rank per group hughaguilar96@gmail.com - 2014-12-21 17:14 -0800
Re: Rosetta Code: Top rank per group Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2014-12-22 10:27 +0000
Re: Rosetta Code: Top rank per group hughaguilar96@gmail.com - 2014-12-22 22:03 -0800
Re: Rosetta Code: Top rank per group hughaguilar96@gmail.com - 2015-01-08 17:17 -0800
Re: Rosetta Code: Top rank per group Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2015-01-09 09:56 +0000
Re: Rosetta Code: Top rank per group hughaguilar96@gmail.com - 2015-03-16 19:11 -0700
Re: Rosetta Code: Top rank per group "WJ" <w_a_x_man@yahoo.com> - 2014-12-24 05:25 +0000
Re: Rosetta Code: Top rank per group mix <mix@test.net> - 2014-12-14 11:55 +0000
Re: Rosetta Code: Top rank per group empty-buffers <empty.buffersYOU-DONT-WANT-THIS@gmail.NEITHER-THIS.com> - 2014-12-14 13:52 +0000
Re: Rosetta Code: Top rank per group mix <mix@test.net> - 2014-12-14 11:58 +0000
csiph-web