On Thu, Nov 29, 2001 at 11:34:24AM -0800, Chris Thorpe wrote:
> 
> On Thu, 29 Nov 2001, Yanick wrote:
> 
> > On Thu, Nov 29, 2001 at 01:34:02PM -0500, Michael G Schwern wrote:
> >
> >>> Yesterday, I saw an interesting related exercise.  Write a program that
> >>> reads the lines from a file and outputs the middle line.  The kicker is
> >>> that you can't use arrays.
> > >
> > > I'll interpret that as O(1) memory, O(n) time.
> 
>   You can't do it in O(1) memory and O(n) time.  There's a time/memory
> tradeoff.  At line m, you have to store m/2 lines in memory if you use
> O(n) time, if the file stops anywhere between m and m*2 (which you don't
> know.)
> 
>   If you elect to use O(1) memory, then you have to use O(1.5*n) time,
> as the already submitted examples do.
> 
>   It seems silly to try to use O(n/2) memory if you aren't allowed to use
> an array.


Please study what big-Oh *means* before you try to use it in conversation.
The above doesn't make any sense.



Abigail
            • ... Uri Guttman
              • ... Chris Thorpe
              • ... Michael G Schwern
              • ... Uri Guttman
              • ... Michael G Schwern
              • ... Sam Holden
              • ... abigail
            • ... abigail
              • ... Michael G Schwern
          • ... Uri Guttman
          • ... abigail
      • ... Uri Guttman
        • ... Michael G Schwern
          • ... Uri Guttman
      • ... Ariel Scolnicov
      • ... abigail
  • ... Ian Phillipps
  • ... Yanick
  • ... Greg Bacon
    • ... Michael G Schwern
      • ... Dmitry Kohmanyuk Дмитрий Кохманюк

Reply via email to