I would second arunachalam's idea (read block-by-block backwards starting from end-of-file).  If there's a source code to "tail" tool, then you might see something useful there as well.

 
On 8/9/06, Dont Know <[EMAIL PROTECTED]> wrote:

The solution I know, needs O(n) space.  Take a circular queue of size
n.  Read a line at a time from the file and insert it into the queue.
If the queue is full remove the first line and insert the newly read
line.  Repeat this process untill EOF is encountered.  When we reach
end of the file the queue will contain the last n lines of the file.



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---

Reply via email to