GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Microsoft  >  DotNet
Go To First  |  Previous Question  |  Next Question 
 DotNet  |  Question 114 of 165    Print  
Given a server with 4 cpu\'s, and no databases write a pseudocode to search for the word camera in 100,000 html documents.


  
Total Answers and Comments: 3 Last Update: March 13, 2006     Asked by: a khan 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
January 12, 2006 00:02:53   #1  
samiksc Member Since: October 2005   Contribution: 233    

RE: Given a server with 4 cpu's, and no databases wri...

Start 4 threads which do the following task:

  1. Opens every nth file (first thread will open 0th 4th 8th 12th file second thread will open 1st 5th 9th and so on)
  2. Scans the file for occurrences of word 'camera' and notes down line numbers (possibly in a hash table -- the key would be the file name with complete path and value will be an array / arraylist containing line numbers)

 
Is this answer useful? Yes | No
January 12, 2006 00:08:11   #2  
samiksc Member Since: October 2005   Contribution: 233    

RE: Given a server with 4 cpu's, and no databases wri...

The program would be as follows:

  1. start threads scanning every nth file -- 0-4-8-12; 1-5-9-13 etc.
  2. Scan the file for word 'camera' and note down line numbers in a hash table -- the key would be file path and values would be the line numbers.

 
Is this answer useful? Yes | No
March 13, 2006 16:36:44   #3  
labrynth        

RE: Given a server with 4 cpu's, and no databases wri...

but why nth file ? Why not simply divide 100 000 into four groups and have each thread run on a group ..


 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape