Thanks for your replies.

@wysota - will try out an algorithm based on your hints

Quote Originally Posted by wysota View Post
I'll give you a hint:

7 = 4+3 // to read 7MB, read 4MB and then 3
10 = 4+4+2 // to read 10MB read 4MB, then again 4MB and then 2 MB
445 = 4+...+4+1 // to read 445MB read 4MB as long as there is more than 4MB to read and then read whatever remains

And another hint:

If you tell read() to read 4MB but there is only 1MB available, it will read 1MB

Question:

How much memory is needed to read 445MB of data this way?

Now go and carve an algorithm out of it.
ans : 4 MB