Given a set of KEY->VALUE pairs such that each KEY is unique, describe a method of storing these pairs on disk, and a method for accessing the corresponding VALUE given a KEY. Assume that RAM is fixed at 1gb and the set of pairs requires 40gb.
Lets say you have a disk of size N with N blocks. Every block stores part of a file. Every file starts from a single block. The block size is not enough to store a file. Every block has a used/unused bit and a pointer to the next block in the disk which will store the next part of the file and so on. A block which stores the end of a file points to null. Also a block whose unused bit is 0 doesnt point to anything and is not pointed to by any block. Now u have an index of files with filename as index and the value as the first block in which the file starts.Lets says u somehow lose these indices and values. How will you find an efficient algorithm to recreate this index structure with values. You can use any filenames while creating the indices.(While solving one shld think of cases where the file starts at block 4 which points to 1 then to 2 and ends at 3)
Imagine a disk spinning like a record player turn table. Half of the disk is black and the other is white. Assume you have an unlimited number of color sensors. How many sensors would you have to place around the disk to determine the direction the disk is spinning? Where would they be placed?
Lets say you have a disk of size N with N blocks. Every block stores part of a file. Every file starts from a single block. The block size is not enough to store a file. Every block has a used/unused bit and a pointer to the next block in the disk which will store the next part of the file and so on. A block which stores the end of a file points to null. Also a block whose unused bit is 0 doesnt point to anything and is not pointed to by any block. Now u have an index of files with filename as index and the value as the first block in which the file starts.Lets says u somehow lose these indices and values. How will you find an efficient algorithm to recreate this index structure with values. You can use any filenames while creating the indices. (While solving one shld think of cases where the file starts at block 4 which points to 1 then to 2 and ends at 3)