Amazon Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
1
of 1 vote

Just to get the ball rolling:

class File{
permissions user;
permissions group;
permissions other;
char * owner;
char *group
int size;
date created;
date modified;
char * name;
char * extension;
}

class Directory:public File{
List <File> filesInTheDirectory[];
}

class FileSystem{
Tree <Directory> fileSystem;
}

- Vader May 06, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

Since File System is like a tree structure, I would say using Composite Pattern works here. Where the Component node will be directory and file will be a root node.
The base class which is composite node has methods like
-vector<Component_Class> child.
+addFile()
+removeFile()
-_lastmodified
_creationtime

- CodeHAcked September 17, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

FAT is an easy one. Implement the FAT as a hash table of size n.

I would use a Binary Tree for each FAT entry.

- Jack February 01, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think it's more about OOD, have a look at the

"Pattern Hatching"

Composite, Proxy, Mediator,Singleton Pattern are used to design the file system

- yoyo March 08, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

is there more detailed explanation on this one? like what needs to be considered when designing a file system? what data strcutures to use and why not the others? Thanks!

- cd April 30, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Could anyone give more details about this...?

- Jack.. May 06, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

A filesystem has a bunch of directories. Each directory has a bunch of files. A file can be a text file, binary file, etc.

- Khoa May 06, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

each file or directory has attributes like permission, last accessed, size,etc

- Khoa May 06, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Class Directory inheriting from File is a bit odd. You should use composition instead of inheritance.

- Khoa May 06, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Just had an interview with Amazon..and first two questions were..

What are the classes and data structures you would use for a file
system
What kind of data structure would you use to implement a map (not a
location map... But rather a mapping from a key to a value).

Both of these questions were mentioned under Gayle's tips. I think I bombed...in the interview...

Any insight about the second question...?

- anonymous... May 06, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

if you mean a mapping from the logical address to the physical one, then file systems usually use an Extensible Hash Table. Even a B-Tree isn't such a bad answer :)

- JH December 27, 2007 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

He probably means map as in std::map or such associative arrays. It's usually implemented using Red-Black trees.

- Anonymous October 24, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Just had an interview with Amazon..and first two questions were..

What are the classes and data structures you would use for a file
system
What kind of data structure would you use to implement a map (not a
location map... But rather a mapping from a key to a value).

Both of these questions were mentioned under Gayle's tips. I think I bombed...in the interview...

Any insight about the second question...?

- anonymous... May 06, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Map is usually implemented using a hash table or balanced binary tree (Red Black Tree is the popular tree data structures). If you know ahead of time how many elements are to be inserted and the number is small, an array would do the job. A Splay Tree would be a good data structures if there are some accessing pattern.

- Khoa May 06, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

What were some other questions that you received?

- Khoa May 06, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

rest were simpler, code for reverse string ( the guy wasnt sure if i cud call a function like this...

reverse_Str ( char src [], char dest [] )

but u can declare a function like this...

bitwise operator
virtul functions
inheritance
method signature
some other basic questions...

- anonymous May 06, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Is there any place ( I already bought PIE after I blew it up ) where i can find similar set of questions....?

- anoymous May 06, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Is there any place ( I already bought PIE after I blew it up ) where i can find similar set of questions....?

- anoymous May 06, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Go through and solve all the questions on this website. This is the best preparation. I don't know any other good interview books. I recommend reading data structures and algorithms and design patterns books. I recommend Algorithms in C++ by SedgeWick, Effective C++ and More Effective C++ by Scott Meyers. The Algorithm Design Manual by Steven Skienna and the classic Introductions to Algorithms(CLR). Mark Weiss Data Structures and Algorithms book is very useful. If you read all these books and and solve all the questions on Gayle's website, I think you would have an easier time with these interview questions.

- Khoa May 07, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

For Design Patterns, read Head First Design Patterns. The style is silly and it works for me. This book definitely makes you think differently. Good luck!

- Khoa May 07, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I was wrong. Vader is right. Since everything is really a File in Unix, A Directory has the same attributes as a File. Directory should inherit from File.

- Khoa May 07, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Pattern Hatching is used to implement file system with classes........
http://www.ida.liu.se/~uweas/Lectures/DesignPatterns01/panas-pattern-hatching.ppt.

- Naitik Dani October 10, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

B-trees are commonly the underlying basis for modern operating systems. (Including NTFS and the Google File System)

http://en.wikipedia.org/wiki/B-tree

- fred November 16, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

To answer this question I would probably go into B-Trees and it's variants (B+ and B-) for the data structures of file systems. Not sure as far as classes go, but I imagine it's a little more complicated than having a list of files for a directory, and a tree/map of directories for a filesystem.

As far as data structures for maps (ie. associative arrays), Red-Black trees is a good answer as well.

Both of these are basically self-balancing binary trees, the knowledge of which is what I think what they are really after.

- fred November 16, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I'm thinking of going with Hashing all the data and then segregating the files into buckets. It gives O(1) complexity to traverse and since its hashed, searching would be easier.

Within each bucket, data can be stored as B Trees.
Plz correct me if i'm wrong anywhere.
Thanks.

- Niti December 05, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

class Directory:public File{ 
List <File> filesInTheDirectory[]; 
}

I think in this Directory class filesInTheDirectory should be a Hashtable or a Dictionary to fasten the seach for a file when the path has given absolutely as a URI.

- Jobi March 08, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Can someone provide me the link to Gayle's website for interview questions -- Thanks

- Annie December 24, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I am also looking for Gayle's website that everyone is refering to here. Can someone please post a link or some more info about it.
Thanks.

- newcomer January 21, 2008 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

You are in that site dude ! Look at the bottom you can see the person's name

- prolificcoder August 28, 2008 | Flag


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More