Algorithm · Confluent · Hard
Implement List tail(SeekableFile file, int n), which returns the last n logical lines of a seekable file. The file can be far larger than available memory, so when n is small the implementation must not start at byte 0 and scan the entire file. Read in bounded chunks from positions near the end and move toward the beginning. A logical line is defined on the byte stream using \n (0x0A) as the delimiter. Split the bytes on \n; if the file ends with \n, discard the empty…
Checking your access…