<< Patricians VS Arriviste >> Not the very obvious in Computer science.
Saturday, October 20, 2007
Simplicity !! in Software Engineering.
Wednesday, May 16, 2007
StrStr as an Interview question.
StrStr happens to be the favorite question for some interviewers. I have a senior colleague who is especially fond of this question. He had a hard time getting people from X country answer that correctly. So he decided, to gauge the difficulty of the strstr question by using my answer as a benchmark (Don’t know how wise this decision was?).
He started out by explaining the question to me. And then i started thinking about this. I knew about this question but never had the patience to find an answer. So i decided to think :), n2 algorithms are BAD so I did not even discuss the search the needle in the haystack solution.
Eventually after he putting almost all the words into my mouth I/we got the variant of the KMP strstr algorithm. And then to test if I really understood the solution (this is imp now because I did not design it :)) he just asked me to build another failure table as used in the KMP algorithm which takes the number of matches before a character failure and gives the skip count. And then I got that while waiting for my bus.
Conclusions are.
1. "Efficient" StrStr is not a simple algo to design.
2. There is much to think about it.
3. Once you get it, it easy. BUT... it can always be further optimized.
4. Its not a good interview question for a telephonic interviews. The reason being on the extremely smarts can do w/o hints, i think the person being interviewed should be given hints. Hints are not conveyed effectively over the phone. :)
5. It will fairly gauge the thinking abilities of the person being interviewed.
Tips for the "being interviewed".
1. If you know the answer be honest say that u already know the answer.
2. Don’t get overwhelmed, the direction to start working is not that intuitive. The starting is important.
3. As for all thinking questions you have to convey to the interviewer the fact that u r actually thinking. So think aloud getting the answer doesn't matter as long as you are able to think.
Monday, May 14, 2007
Google Stemming and Other features.
Saturday, May 13, 2006
Where's the bug ?
__time64_t merge_lower_time;
__time64_t merge_upper_time;
printf("\nMerge files greater than:");
status = getTimeFromUser(&merge_lower_time);
if (status != ERROR_SUCCESS) {
printf("\nInvalid Date");
return -1;
}
printf("\nMerge files less than:");
status = getTimeFromUser(&merge_upper_time);
if (status != ERROR_SUCCESS) {
printf("\nInvalid Date");
return -1;
}
printf("\n Attempting merge between time Range \n %S %S", _localtime64(&merge_lower_time)?_wasctime(_localtime64(&merge_lower_time)):L"Time Config Error.", _localtime64(&merge_upper_time)?_wasctime(_localtime64(&merge_upper_time)):L"Time Config Error.");
return 0;
}
Merge files greater than:
Specify an Time Stamp:
Enter year [1900-3000]:2000
Enter month [0,11]:0
Enter day [1,31]:1
Enter hour [0,23]:0
Enter minute [0,59]:0
Enter seconds [0,59]:0
Merge files less than:
Specify an Time Stamp:
Enter year [1900-3000]:2005
Enter month [0,11]:0
Enter day [1,31]:1
Enter hour [0,23]:0
Enter minute [0,59]:0
Enter seconds [0,59]:0
Attempting merge on c: between time Range
Sat Jan 01 00:00:00 2000
Sat Jan 01 00:00:00 2000
/
int HypAcceptAndPrint2Dates() {
__time64_t merge_lower_time;
__time64_t merge_upper_time;
printf("\nMerge files greater than:");
status = getTimeFromUser(&merge_lower_time);
if (status != ERROR_SUCCESS) {
wprintf(L"\nInvalid Date");
return -1;
}
printf("\nMerge files less than:");
status = getTimeFromUser(&merge_upper_time);
if (status != ERROR_SUCCESS) {
wprintf(L"\nInvalid Date");
return -1;
}
printf("\n Attempting merge between time Range \n %S ", _localtime64(&merge_lower_time)?_wasctime(_localtime64(&merge_lower_time)):L"Time Config Error.");
printf("%S",_localtime64(&merge_upper_time)?_wasctime(_localtime64(&merge_upper_time)):L"Time ConfigError.");
}
Merge files greater than:
Specify an Time Stamp:
Enter year [1900-3000]:2000
Enter month [0,11]:0
Enter day [1,31]:1
Enter hour [0,23]:0
Enter minute [0,59]:0
Enter seconds [0,59]:0
Merge files less than:
Specify an Time Stamp:
Enter year [1900-3000]:2005
Enter month [0,11]:0
Enter day [1,31]:1
Enter hour [0,23]:0
Enter minute [0,59]:0
Enter seconds [0,59]:0
Attempting merge on c: between time Range
Sat Jan 01 00:00:00 2000
Sat Jan 01 00:00:00 2005
Conclusion:
Exceprt From MSDN which did not read, WHY because i thougt printing time is a trivial thing.
asctime uses a single, statically allocated buffer to hold the return string. Each call to this function destroys the result of the previous call.
Monday, April 24, 2006
I/O Namespace differences between NT and Linux.
Everything is a file cool!
But what about the IO namespace
Logging of some activity on to a given volume in the standard task required for most of volume level activity monitors. So we had a problem at hand, which goes as such.
At configuration time a volume+dir name will be provided to you and you will always write your log files on to that given volume. Now if the volume was to be give as c:\logdir. And some smart fellow now mounts another volume at the mount point c:\logdir your log file will now go to the newly mounted volume rather than going on to the originally configured volume.
Linux team had no simple solution to the problem. The windows team had a very simple solution that being of not accessing the journal directory via the mount point and instead using the volume identifier for the original volume. So the original underlying volume could always be accessed as
\\?\Volume{8400c6bf-7662-11d9-ab4c-806e6f6e6963}\logdir\log
This path will always log to the same volume. i.e the volume with the unique identifier Volume{8400c6bf-7662-11d9-ab4c-806e6f6e6963}
Instead C:\logdir\log.txt could go onto a totally different volume if logdir was a mount point for it. Bottom line is, Windows provides a way to access the files on a volume without going thru the mount point crossing process.
This was a very sentimental issue for me, because I always believed that everything that can be done in NT could be also easily done in Linux. But, this time it was not possible at all. It's against the UNIX semantics to the underlying volume at a given mount point. But Linux’s inability still needs to be justified by some rationale
Clearly UNIX was not designed to trouble us implementing this feature, neither was NT designed with considerations to our interests. I had to conclude on why was the feature present on one OS and not on the other.
The final conclusion is in Linux the device name space contained in the file system name space i.e. your device files are hosted on the file system as special nodes. viz /dev/sda1 is a special node on the root file system.
Its exactly the opposite way on NT i.e the file system namespace is contained within the Device Name space i.e. your file t1 resides on \\Device\HardiskVolume0\t1.txt so to access a file you go through a device and this is the only reason you can access the underlying volume in NT which is not achievable in Linux.
Think about it! In Linux /dev/sda1/f1.txt can never point to file on the volume /dev/sda1
On windows you can \device\sda1\f1.txt to point a file on hypothetical volume \device\sda1\.
And vice versa
in windows c:\com1 can never point to the device com1 (Can be done :)).
And in Linux this can be achieved simply by a device special node /dev/com1
This for me is the second most important difference between NT and UNIX second only to the synchronous VS asynchronous IO model. I think there has to be a way to arrange the IO namespace in such a way that it does have both features of the NT and the UNIX IO namespace. Until someone finds it everything will be just a file.
Followers
Blog Archive
Links
Labels
- Advanced Storage Systems 18-746 (1)
- awatch (1)
- Brent Welch (1)
- Carnegie Mellon University (2)
- dlmalloc (1)
- Faraz Shaikh (3)
- heap corruption (1)
- installing ISR using C functions (1)
- interrupt service routines (1)
- memory corruption (1)
- poison bytes (1)
- programmable (1)
- rwatch (1)
- Simplicity (1)
- Software Engineering 11-791 (1)
- stemming google google search (1)
- vmware (1)
- watch (1)
- x64 debug registers (1)
