Yahoo Interview Question for Software Engineer / Developers






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

write a script to use grep on those 100 text files for the keyword

- chennavarri October 18, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

A more efficient way of doing it would be to use Distributed Grep with something like MapReduce. Google for MapReduce: Simplied Data Processing on Large Clusters and read the paper. This paper perfectly answers ur question

- Chander Shivdasani November 01, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Are we expected to write code from scratch or use grep as suggested above?

- cirus November 07, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Assumptions: perfect hashing, a keyword appears only once in all 100 text files.
Divide all the 100 files into keywords, suppose we will get some 1000 keywords.
Consider having hashtable(array representation) of 1000 entries. Each hash table entry can hold a struct pointer having fd and offset in the file pointing to particular paragraph.
____________
k1 | fd1,offset1|
|------------|
k2 | fd2,offset2|
|------------|
k3 | fd3,offset3|
|------------|
and soo on
FD represents a particular file and offset represent distance from starting of file to starting of paragraph in which keyword is present.
After preprocessing its O(1) time operation. with O(num of keywords space).


"If a particular keyword can be part of different paragraphs and also be different files. And have to return all the paragraphs in which the file a particular keyword occurs"
_______ ___________ _______ _______
k1| --|--|fd1,of1,of4|--|fd2,of2|--|fd3,of3|
|-------| _______
k2| ----|--|fd5,of5|
and so on

Fd1 represents a particular file and of1,of4 represents the offsets to two different paragraphs in which this keyword K1 occurred.

- Anonymous January 19, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Create a trie from all the words in all the files. Every time a word's leaf is reached store the paragraph-index and the file-index in it.
Using this a word can be searched in o(m) where m is the length of the word.

- chandransuraj February 07, 2011 | Flag Reply


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