First of all i would like to describe the what an event it is.. so In computing an event is an action that is usually initiated outside the scope of a program and that is handled by a piece of code inside the program.
I Would Like to Add Some Points & modify the above algo so that it can be coded in multi-threaded environment.because once any one see this algo he will definitely ask whether your code is able to run in multi- threaded environment or not..?? because it might be possible in single minute several threads may initiates the event in parallel because there is no condition that is stopping thread to execute the common piece of program that can be shared b/w them as thread share common part of process. .so there is more chances to loss of integrity of data . hope you know race condition.Also a global variable can also create linking (external reference resolution ) problem in addition to global variable can be modified by any thread.at any time. so basically what i am talking about some kind of synchronization is needed & above can can be re-implemented in multi-threaded environment to resolve above problem so that 1) we can Record all Events (For the sake of simplicity, treat the Event as an integer code) generated by threads 2) Return the number of Events recorded in the last one minute by all threads 3) Return the number of Events recorded in the last one hour by all threads. so these are the few points on which we can further discuss with interviewer to show him awareness about multi thread environment.the basic approach given by ankit is fine from my points of view with only overhead of shifting ?? for open ended question if we don't have enough space to store an event then we can divided the space required by event in multiples of memory available isn't it..?? Correct me if anything i explained seems to be wrong or if you wants to add something more. Thanks Shashank CSE BIT Mesra -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
