Friday, October 2, 2009

virus and linux

[freedom]] This is a post not regarding any algorithm but a very general topic.Virus in Linux , although I am no genius to talk about this issue , it's just because this topic has fascinated me and I would like to share my little bits of knowledge with you.
Virus, everyone knows what they are and Windows Users need to grapple with them every single day, but what's with Linux ,does Linux have viruses, you sure have Anti virus softwares for Linux which can be downloaded using Package Manager .
But Linux OS is well protected , no OS is immune to virus attack and moreover when your code can be seen by million eyes across the globe . Linux community also provides latest security updates that help in saving your accounts from virus attacks.
Linux OS is hence more stable than windows for virus attacks and no single big malware attack has been witnessed in Linux , although as popularity increases virus attacks will sure be on the rise.
Linux also does a pretty cool thing by locking one's root account and using sudo command which is also used in Mac while using root you are the master and changes apply system wide, which does not happen with sudo , which asks for your password while entering any command , graphical commands (gksudo) for gnome , you get a 15 minute timeout for a terminal for using sudo within which your password will not be asked .
Also if one has to hack your system he needs to know your username not just hack your password.That is why it is more advisable to use sudo rather than go for an easy alternative of root.And your file permissions provide you a safe haven from these attacks.
To protect your system more you can also set passwords for you grub and BIOS .
So nothing is virus free in this world and nothing is impossible to hack ......
So keep on trying.............someday you might triumph .

Wednesday, September 30, 2009

Segmented Sieve Algorithm

[Impervious] : This algorithm can be used to check for prime numbers up to 10^14 in a given range [ m , n ], as large as 10^7. For example, it can be used to check for prime numbers in [ 10^5 ,10^6 ]. The essence of the algorithm lies in the fact that the square root of the largest 14-digit prime will be less than the largest 7-digit prime. The algo. is as follow : First store all primes up to 10^7 in an array(say primes[]), using simple sieve. Now based upon the input, proceed as follows :

1. If n < 10^7 , simple iterate and print the primes, stored in the array.

2. If m > 10^7 , then first declare an array of size n-m(this can also be declared initially as test_range[10^7] ). Now for each prime in primes, strike out all multiples of it in the range(that is , mark all multiples of primes[i] in test_range[] as composite , as we do in simple sieve). Note that the first element of test_range corresponds to m , the second to m+1, and so on , the last to n. Finally , print the remaining elements of the test_range.

3. If m is less than 10^7 and n is greater than 10^7, a combination of the above two,split the range. Damn simple.

Note that, we can only check the prime numbers in a given range and not store them.

I`ll be posting the code a little later.
Happy coding!!!