Re: [algogeeks] Need the algorithm or idea

2011-05-03 Thread Sathaiah Dontula
is it not EDIT DISTANCE  (DP) problem ?

Thanks & regards,
Sathaiah Dontula

On Tue, May 3, 2011 at 9:03 AM, lichenga2404  wrote:

> The question in an interview. And I got lost with this one.
>
> Could you guys give some algorithm or idea on  this ?
>
>
> Write a program that reads a large list of English words (e.g. from /
> usr/share/dict/words on a unix system) into memory, and then reads
> words from stdin, and prints either the best spelling suggestion, or
> "NO SUGGESTION" if no suggestion can be found. The program should
> print ">" as a prompt before reading each word, and should loop until
> killed.
>
> Your solution should be faster than O(n)
>
> For example:
>
> > shep
> sheep
> > peepple
> people
> > sheeple
> NO SUGGESTION
> The class of spelling mistakes to be corrected is as follows:
>
> Case (upper/lower) errors: "inSIDE" => "inside"
> Repeated letters: "jjoobbb" => "job"
> Incorrect vowels: "weke" => "wake"
> Any combination of the above types of error in a single word should be
> corrected (e.g. "CUNsperrICY" => "conspiracy").
>
> If there are many possible corrections of an input word, your program
> can choose one in any way you like. It just has to be an English word
> that is a spelling correction of the input by the above rules.
>
> Final step: Write a second program that *generates* words with
> spelling mistakes of the above form, starting with correctly spelled
> English words. Pipe its output into the first program and verify that
> there are no occurrences of "NO SUGGESTION" in the output
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Divisibility by five

2011-05-03 Thread Umer Farooq
public static isDivisibleByFive(int input)
{
String str_input = String.valueof(input); // convert initial int to string.
if ((str_input.charat(str_input.length()-1) == '5') ||
(str_input.charat(str_input.length()-1) == '0') // check if the last
character is 0 or 5
 return true;
return false;
}

u can try something like this ...
On Tue, May 3, 2011 at 9:25 AM, Dave  wrote:

> Given an integer n, give an O(log n) algorithm to determine if n is
> divisible by 5 without using division or mod.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
Umer

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Need the algorithm or idea

2011-05-03 Thread Umer Farooq
I have got a solution for this problem but It is greater than O(n^2).

The idea is to take the edit distance with selected words from dictionary of
all words in english and output the word with min edit distance (An edit
distance is number of insertions, deletions and replacement operations
needed to convert one word into another)

The edit distance is calculated via dynamic programming technique and
complexity of calculating edit distance for one pair of words is O(n^2)

Btw, in which company did they ask this question?

On Tue, May 3, 2011 at 8:33 AM, lichenga2404  wrote:

> The question in an interview. And I got lost with this one.
>
> Could you guys give some algorithm or idea on  this ?
>
>
> Write a program that reads a large list of English words (e.g. from /
> usr/share/dict/words on a unix system) into memory, and then reads
> words from stdin, and prints either the best spelling suggestion, or
> "NO SUGGESTION" if no suggestion can be found. The program should
> print ">" as a prompt before reading each word, and should loop until
> killed.
>
> Your solution should be faster than O(n)
>
> For example:
>
> > shep
> sheep
> > peepple
> people
> > sheeple
> NO SUGGESTION
> The class of spelling mistakes to be corrected is as follows:
>
> Case (upper/lower) errors: "inSIDE" => "inside"
> Repeated letters: "jjoobbb" => "job"
> Incorrect vowels: "weke" => "wake"
> Any combination of the above types of error in a single word should be
> corrected (e.g. "CUNsperrICY" => "conspiracy").
>
> If there are many possible corrections of an input word, your program
> can choose one in any way you like. It just has to be an English word
> that is a spelling correction of the input by the above rules.
>
> Final step: Write a second program that *generates* words with
> spelling mistakes of the above form, starting with correctly spelled
> English words. Pipe its output into the first program and verify that
> there are no occurrences of "NO SUGGESTION" in the output
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
Umer

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: If any one have algorithms for interviews by adnan aziz ebook... Please mail ...

2011-05-03 Thread venkat kumar
sir,
 kindly send me the link too.
 thank you

On Fri, Apr 29, 2011 at 9:35 PM, Umer Farooq  wrote:

> please send it to me at "the.um...@gmail.com"
>
> Thanks in advance :)
>
>
> On Sat, Apr 30, 2011 at 8:41 AM, Manish Kumar 
> wrote:
>
>> please send me this book to my email , thanks" manish.iitia...@gmail.com'
>>
>>
>>
>> On Sat, Apr 30, 2011 at 6:07 AM, Venkat  wrote:
>>
>>> Hey how's ur interview?
>>> if u have the book pls mail me to " gvr.su...@gmail.com "
>>>
>>> On Apr 19, 6:19 am, nagajyothi gunti 
>>> wrote:
>>> > Please send me too at nagajyothi.gu...@gmail.com
>>> > Also, please let me know what all to prepare...I have an phone
>>> interview
>>> > from amazon this wednesday.
>>> >
>>> > On Mon, Apr 18, 2011 at 2:40 PM, vaibhav agrawal >> >wrote:
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > > Please send it to me tooo agrvaib...@gmail.com
>>> >
>>> > > On Mon, Apr 18, 2011 at 10:30 PM, Rel Guzman Apaza <
>>> rgap...@gmail.com>wrote:
>>> >
>>> > >> Send to me too. Please. rgap...@gmail.com
>>> >
>>> > >> 2011/4/18 Abhishek Goswami 
>>> >
>>> > >>> I think we can share into email...that will not be any
>>> issue. :)
>>> >
>>> > >>> On Mon, Apr 18, 2011 at 10:07 PM, Abhishek Goswami <
>>> > >>> zeal.gosw...@gmail.com> wrote:
>>> >
>>> >  can u please me also .. zeal_gosw...@yahoo.com
>>> >
>>> >  On Thu, Apr 14, 2011 at 11:50 AM, Himanshu Neema <
>>> >  potential.himansh...@gmail.com> wrote:
>>> >
>>> > > Hi All ,
>>> > > Yesterday I received an email from Author that this is *violation
>>> of
>>> > > Intellectual Property Ownership* ,So kindly please delete pdfs &
>>> > > please remove all the sharing.
>>> >
>>> > > Thanks Guys.
>>> > > Himanshu
>>> >
>>> > > On Thu, Apr 14, 2011 at 10:52 AM, Harshal 
>>> wrote:
>>> >
>>> > >> Thanks :)
>>> >
>>> > >> On Thu, Apr 14, 2011 at 9:59 AM, Rajeev Kumar <
>>> > >> rajeevprasa...@gmail.com> wrote:
>>> >
>>> > >>> check this link:
>>> >
>>> > >>>
>>> https://docs.google.com/viewer?a=v&pid=explorer&chrome=true&srcid=1B5...
>>> >
>>> > >>> If you have any problem in access,please inform
>>> me
>>> >
>>> > >>> On Thu, Apr 14, 2011 at 1:04 AM, Abhishek Goswami <
>>> > >>> zeal.gosw...@gmail.com> wrote:
>>> >
>>> >  Hi,
>>> >  I tried to open this book in google docs and got message that
>>> file
>>> >  is not avaliable. does this file not available in google docs
>>> >  if yes , can anybody share this book again
>>> >
>>> >  On Tue, Mar 22, 2011 at 10:41 PM, Himanshu Neema <
>>> >  potential.himansh...@gmail.com> wrote:
>>> >
>>> > > Turns out that I cant send file larger than 4 MB , please
>>> download
>>> > > it from here , let me know if you're still unable to
>>> download:
>>> >
>>> > >
>>> http://dl.dropbox.com/u/2681370/Algorithms%2Bfor%2BInterviews%2B%28sc...
>>> >
>>> > > have fun !
>>> >
>>> > > On Tue, Mar 22, 2011 at 10:21 PM, Himanshu Neema <
>>> > > potential.himansh...@gmail.com> wrote:
>>> >
>>> > >> Enjoy :)
>>> >
>>> > >> On Tue, Mar 22, 2011 at 10:09 PM, Saravanan T <
>>> > >> mail2sarava...@gmail.com> wrote:
>>> >
>>> > >>> ++
>>> >
>>> > >>> On Tue, Mar 22, 2011 at 9:51 PM, Anurag atri <
>>> > >>> anu.anurag@gmail.com> wrote:
>>> >
>>> >  and me too :)
>>> >
>>> >  On Tue, Mar 22, 2011 at 9:28 PM, Nikhil Mishra <
>>> >  mishra00...@gmail.com> wrote:
>>> >
>>> > > count me too
>>> >
>>> > > On Tue, Mar 22, 2011 at 11:16 AM, kunal srivastav <
>>> > > kunal.shrivas...@gmail.com> wrote:
>>> >
>>> > >> plz send it to me too
>>> >
>>> > >> On Tue, Mar 22, 2011 at 11:14 AM, D.N.Vishwakarma@IITR<
>>> > >> deok...@gmail.com> wrote:
>>> >
>>> > >>> --
>>> >
>>> > >>> *With Regards
>>> > >>> Deoki Nandan Vishwakarma
>>> > >>> IITR MCA
>>> > >>> Mathematics Department
>>> > >>> *
>>> >
>>> > >>> --
>>> > >>> You received this message because you are subscribed to
>>> the
>>> > >>> Google Groups "Algorithm Geeks" group.
>>> > >>> To post to this group, send email to
>>> > >>> algogeeks@googlegroups.com.
>>> > >>> To unsubscribe from this group, send email to
>>> > >>> algogeeks+unsubscr...@googlegroups.com.
>>> > >>> For more options, visit this group at
>>> > >>>http://groups.google.com/group/algogeeks?hl=en.
>>> >
>>> > >> --
>>> > >> thezeitgeistmovement.com
>>> >
>>> > >>  --
>>> > >> You received this message because you are subscribed to
>>> the
>>> > >> Google Groups "Algorithm Geeks" group.
>>> > >> To post to this group, send email 

Re: [algogeeks] If anyone have this book please mail me Thanks in advance

2011-05-03 Thread Priyanka Chatterjee
Yes please delete the links and stop asking for books which are not free

On 30 April 2011 21:24, Varun Nagpal  wrote:

> Please refrain from sharing such links and engaging in piracy.
>
> I kindly request the admin of this forum to delete all such posts and to
> warn the users on the forum for possible barring in case they are found to
> use this forum for piracy and malpractices.
>
>
> On Sat, Apr 30, 2011 at 12:09 PM, Charles Turner wrote:
>
>> This doesn't look legal to me. Has the author allowed you to redistribute
>> their book? I can't see any such evidence.
>>
>> If you don't have permission to redistribute the book, you're breaking the
>> law. This is a serious offence. You are lowering the reputation of this
>> list.
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Thanks & Regards,
Priyanka Chatterjee
Final Year Undergraduate Student,
Computer Science & Engineering,
National Institute Of Technology,Durgapur
India
http://priyanka-nit.blogspot.com/

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Divisibility by five

2011-05-03 Thread Dave
@anshu: Spoiler alert... I was thinking of something more along the
line

int DivisibleBy5 (int n)
{
n = n > 0 ? n : -n;
while( n > 0 )
n = (n >> 2) - (n & 3);
return (n == 0);
}

To see that it works, write n as n = 4*a + b, where 0 <= b <= 3. Then
the iteration replaces n by a - b. Consider (4*a + b) + (a - b), the
sum of two consecutive values of n. This simplifies to 5*a, which is a
multiple of 5. Thus, n is a multiple of 5 before an iteration if and
only if it also is a multiple of 5 afterwards,

It is clearly log n because n is replaced by a number no greater than
n/4 on each iteration.

Examples:
n = 125. The sequence of iterates is 30, 5, 0. Ergo, 125 is a multiple
of 5.
n = 84. The sequence of iterates is 21, 4, -1. Ergo, 84 is not a
multiple of 5.

Dave

On May 3, 3:13 am, anshu  wrote:
> algorithm:
>
> if any number(a) is divisible by 5 it can be wriiten as 4*b + b -->
> this cleary shows the last two bit of a & b will be same.
>
> lets understand by an example (35)10 = (100011)2
>
>  xx1100
> +   xx11
> -
>  100011
>
> now this clearly shows we can calculate the unknowns(x) by traversing
> right to left
>
> code:
>
> int main()
> {
>         int n, m;
>         cin >> n;
>         m = n;
>
>         int a, b;
>         int i=2;
>
>         a = (m&3)<<2;
>         b = (m&3);
>         m >>= 2;
>
>         bool rem = 0,s,r;
>
>         while (m>3)
>         {
>                 r = a&(1<                 s = r^(m&1)^rem;
>                 b = b|(s<                 a = a|(s<<(i+2));
>                 rem = (r&s)|(s&rem)|(r&rem) ;
>                 i++;
>                 m >>= 1;
>         }
>
>         if (a+b == n) cout << "yes\n";
>         else cout << "no\n";
>
>         return 0;
>
>
>
> }- Hide quoted text -
>
> - Show quoted text -

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: If any one have algorithms for interviews by adnan aziz ebook... Please mail ...

2011-05-03 Thread Ashish
Hi,

Could you pls email this book to me :ashish...@gmail.com?

Regards,
Ashish




-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: TRICK BRAIN TEASER - MAN ALIVE 3 may

2011-05-03 Thread Dave
The ice was poisoned. He drank the punch early, before enough ice
melted to result in a fatal dose.

Dave

On May 3, 2:40 am, Lavesh Rawat  wrote:
> *TRICK BRAIN TEASER MAN ALIVE
>  *
> *
> *
> **
> *A man went to a party and drank some of the punch. He then left early.
> Everyone else at the party who drank the punch subsequently died of
> poisoning. Why did the man not die ??
> *
>
> *Update Your Answers at* : * *Click
> Here
>
> Solution:
> Will be updated after 1 day
>
> --
>
>                     "Never explain yourself. Your friends don’t need it and
> your enemies won’t believe it" .

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: A SIMPLE C++ PROGRAM.

2011-05-03 Thread Don
The code is undefined, meaning that a valid compiler can produce any
result that it wants. Multiple side effects between sequence points
are not defined. It would be perfectly acceptable for a valid compiler
to shoot flying monkeys out of your monitor. And it would serve you
right for writing such code.
Don

On Apr 29, 3:31 am, MANNU  wrote:
> *Can anyone please explain me the output of this program:*
>
> int x=1;
> int y=x++ + ++x + ++x + x++;
> cout< cout

Re: [algogeeks] Re: Need the algorithm or idea

2011-05-03 Thread Anand
You can use edit distance to find out how close is your given word with
words present in the dictionary. I could not think of anything in O(n).
http://anandtechblog.blogspot.com/2010/08/edit-distance-algorithm.html


On Tue, May 3, 2011 at 7:27 AM, bittu  wrote:

> in hurryi will suggest you to study TRIE in Detail  as Much as you
> can..Then you will not only get the idea but also you will able to
> implement & see practical uses of Trie in computer Science
>
> Ka
> Thanks & Regards
> Shashank Mani
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] A SIMPLE C++ PROGRAM.

2011-05-03 Thread Logic King
What about the people explaining the answer above as '12'saying
processing will start from left in cout and write in printf ??

On Sun, May 1, 2011 at 1:33 AM, Amit Jaspal  wrote:

> This is compiler dependent..and not a portable way of writing code
>
>
> On Sat, Apr 30, 2011 at 12:11 PM, Ashish Modi wrote:
>
>>  For such type of questions, the best method is to draw a parse
>> tree according to precedence  and evaluate the tree. This is how it is
>> evaluated at compiler level. Many times parsing tree creation is
>> implementation dependent.
>>
>>
>>
>>
>>
>>
>> On Fri, Apr 29, 2011 at 6:43 PM, Varun Nagpal wrote:
>>
>>> I think these questions are stupid in the sense that no one would ever
>>> use these constructs in their production code unless someone wants to write
>>> an obscure obfuscated code in some competition. Many times similar
>>> expressions are non-portable.
>>>
>>> Anyways, to understand this and related concepts, please see iso c or c++
>>> standard and try to understand operator precedence, operator associativity
>>> and sequence points.
>>>
>>> On Fri, Apr 29, 2011 at 3:06 PM, Nikhil Gupta >> > wrote:
>>>
 12
 5

 because y=4+4+3+1
 and x is incremented to 5


 On Fri, Apr 29, 2011 at 2:01 PM, MANNU  wrote:

> *Can anyone please explain me the output of this program:*
>
> int x=1;
> int y=x++ + ++x + ++x + x++;
> cout< cout<
> --
> You received this message because you are subscribed to the Google
> Groups "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



 --
 Nikhil Gupta
 Senior Co-ordinator, Publicity
 CSI, NSIT Students' Branch
 NSIT, New Delhi, India

  --
 You received this message because you are subscribed to the Google
 Groups "Algorithm Geeks" group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.

>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>
>>
>> --
>> With Regards
>> Ashish Modi
>> 9423721478
>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Amit Jaspal.
>
> Men do less than they ought,
> unless they do all they can
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Efficient Way to Detect Duplicate Document

2011-05-03 Thread bittu
suppose You have a billion urls, where each is a huge page. How do you
detect the duplicate documents?
on what  criteria you will detect it, what algorithm , approach ,
whats will be the complexity of each approach
as it has many application in computer science ...i would like to have
some good discussion on this topic

Lets Explorer All The Approach ???

Thanks & Regrads
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 algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Divisibility by five

2011-05-03 Thread ADITYA KUMAR
awesome solution

On Tue, May 3, 2011 at 1:43 PM, anshu  wrote:

> algorithm:
>
> if any number(a) is divisible by 5 it can be wriiten as 4*b + b -->
> this cleary shows the last two bit of a & b will be same.
>
> lets understand by an example (35)10 = (100011)2
>
>  xx1100
> +   xx11
> -
>  100011
>
> now this clearly shows we can calculate the unknowns(x) by traversing
> right to left
>
> code:
>
> int main()
> {
>int n, m;
>cin >> n;
>m = n;
>
>int a, b;
>int i=2;
>
>a = (m&3)<<2;
>b = (m&3);
>m >>= 2;
>
>bool rem = 0,s,r;
>
>while (m>3)
>{
>r = a&(1b = b|(srem = (r&s)|(s&rem)|(r&rem) ;
>i++;
>m >>= 1;
>}
>
>if (a+b == n) cout << "yes\n";
>else cout << "no\n";
>
>return 0;
> }
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
Regards
Aditya Kumar
B-tech 3rd year
Computer Science & Engg.
MNNIT, Allahabad.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Need the algorithm or idea

in hurryi will suggest you to study TRIE in Detail  as Much as you
can..Then you will not only get the idea but also you will able to
implement & see practical uses of Trie in computer Science


Thanks & Regards
Shashank Mani

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Divisibility by five

algorithm:

if any number(a) is divisible by 5 it can be wriiten as 4*b + b -->
this cleary shows the last two bit of a & b will be same.

lets understand by an example (35)10 = (100011)2

 xx1100
+   xx11
-
 100011

now this clearly shows we can calculate the unknowns(x) by traversing
right to left

code:

int main()
{
int n, m;
cin >> n;
m = n;

int a, b;
int i=2;

a = (m&3)<<2;
b = (m&3);
m >>= 2;

bool rem = 0,s,r;

while (m>3)
{
r = a&(1<>= 1;
}

if (a+b == n) cout << "yes\n";
else cout << "no\n";

return 0;
}

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Divisibility by five

Given it should be of O(log(n)).

On Tue, May 3, 2011 at 12:48 PM, abhishekriyer
wrote:

> A naive method would be repeated subtraction which is division. So
> subtract the number repeatedly by 5 unless the value that remains is
> less than 0. If its 0 then the number is divisible by 5
>
> On May 3, 9:25 am, Dave  wrote:
> > Given an integer n, give an O(log n) algorithm to determine if n is
> > divisible by 5 without using division or mod.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
P.S.Raghu Chandra,
IIIT Allahabad,
B.Tech 8th sem.

ps.raghuchan...@gmail.com

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Divisibility by five

A naive method would be repeated subtraction which is division. So
subtract the number repeatedly by 5 unless the value that remains is
less than 0. If its 0 then the number is divisible by 5

On May 3, 9:25 am, Dave  wrote:
> Given an integer n, give an O(log n) algorithm to determine if n is
> divisible by 5 without using division or mod.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Divisibility by five

http://www.ken.duisenberg.com/potw/archive/arch05/050608sol.html

On May 3, 9:25 am, Dave  wrote:
> Given an integer n, give an O(log n) algorithm to determine if n is
> divisible by 5 without using division or mod.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.