Wipro Technologies Interview Question for Applications Developers
- 0of 0 votes
Answersroot, directory, 128, admin, NONE
- vijayinani May 01, 2014 in India for Java
users, directory, 512, admin, root
santana, directory, 1024, santana, users
santana.jpg, photo, 128000, santana, santana
Project.doc, document, 256000, santana, santana
Incredibles.mpg, movie, 4123456123, santana, santana
marcus, directory, 128, marcus, users
Resume.doc, document, 256000, marcus, marcus
This contains information about files stored in a file system. Each line corresponds to one file, and the fields are separated by commas. The first field contains the filename, the second contains the file type, the third field is the size of the file in bytes, the fourth field is the username of the owner of the file, and the last field is the name of the parent directory of this file (i.e. the name of the directory in which this file is located.) Note: the special parent directory name NONE indicates that this file is the root directory of the filesystem. Also, for the purposes of this program, assume that all file/directory names are unique in the system.
write a Java program which reads data in this format from a file, parses it, and figures out the total size of storage consumed by each directory in this system. The size of storage consumed by any directory is defined as the sum of the size of this directory, sizes of all the files in this directory and the total storage sizes consumed by all the directories in this directory. Your program should write the name of each directory, and the total storage consumed by it. The output should have one directory per line, and the format should be dirname: size.
Output should be:
santana: 4123841147
marcus: 256128
root: 4124097915
users: 4124097787
Provide the best algorithm and java program.| Report Duplicate | Flag | PURGE
Wipro Technologies Applications Developer Algorithm
Country: India
Interview Type: Written Test