Path: utzoo!attcan!uunet!tut.cis.ohio-state.edu!morganucodon.cis.ohio-state.edu!jgreely From: jgreely@morganucodon.cis.ohio-state.edu (J Greely) Newsgroups: comp.lang.perl Subject: Re: Uniq, anyone? Message-ID: Date: 15 Oct 90 15:23:20 GMT References: <1990Oct12.075314.15054@utgard.uucp> <1990Oct13.182400.22738@agora.uucp> Sender: news@tut.cis.ohio-state.edu Reply-To: J Greely Distribution: na Organization: Ohio State University Computer and Information Science Lines: 17 In-reply-to: markb@agora.uucp's message of 13 Oct 90 18:24:00 GMT In article <1990Oct13.182400.22738@agora.uucp> markb@agora.uucp (Mark Biggar) writes: >This requires sorting the list before uniq'ing it, which make the algorithm >nlogn. The following algorithm is better: "Better" is a slippery word in algorithm analysis. In this case, you're ignoring the overhead of using an associative array, which can be significant. I find that when the array is filled with random strings (for example, the lines of a fortune(6) file), the sort-and- iterate method wins big (at n=32000, your solution failed with "Out of memory!" after about 15 minutes, while mine completed in less than 30 seconds). (Side note: you should declare $_ local in your solution, to avoid stomping on its current value) -- J Greely (jgreely@cis.ohio-state.edu; osu-cis!jgreely)