tag:blogger.com,1999:blog-1953325079793449971.post5418898414684068155..comments2024-02-15T20:32:59.333+01:00Comments on Algorithms Weekly by Petr Mitrichev: TCO R1, R2 and R3 screencastsPetr Mitrichevhttp://www.blogger.com/profile/00138130656174416711noreply@blogger.comBlogger7125tag:blogger.com,1999:blog-1953325079793449971.post-27022558366639562012009-05-10T17:27:00.000+02:002009-05-10T17:27:00.000+02:00want to see more of your screencasts~want to see more of your screencasts~wainguonoreply@blogger.comtag:blogger.com,1999:blog-1953325079793449971.post-86394656781152301532009-03-26T17:07:00.000+01:002009-03-26T17:07:00.000+01:00The idea of a hash table is quite simple: first, w...The idea of a hash table is quite simple: first, we choose the number N of buckets. Second, when we add a new object X to the hashtable, we choose bucket (X.GetHashCode() % N) and put this object to that bucket. When there are several objects in the bucket, they are compared using the Equals() method to check if the newly added object is already present.<BR/><BR/>Dictionary doesn't choose hash function by itself; by default, the hash function depends on the address of the object in the heap, and thus is most probably different for any two different objects. Thus, if you don't specify the hash function, all your objects tend to go into differnt buckets. In other words, after adding a new State(1,2) to the dictionary, ContainsKey(new State(1,2)) would return false, since these two State objects are different. This makes the solution evaluate the same case mutiple times and thus time out.<BR/><BR/>So, if it's possible for your objects to be equal, you should override both Equals() and GetHashCode() with the latter returning the same value for equal objects. On the other hand, it's better for it to return different values for different objects, so that the number of objects in any one bucket is not too big. 3137*n+k makes is not very likely for different objects to have the same hash code.Petr Mitrichevhttps://www.blogger.com/profile/00138130656174416711noreply@blogger.comtag:blogger.com,1999:blog-1953325079793449971.post-48470765652350260812009-03-26T14:36:00.000+01:002009-03-26T14:36:00.000+01:00I am interset in your 250solution for last srm(437...I am interset in your 250<BR/>solution for last srm(437).<BR/>I understand the idea but:<BR/>why your function for hashing work?,how you choose 3137*n+k?why didnt let dictionary choose hash functioin?<BR/>I imitate your code,and submit my own in practice room and of cource let dictionary choose hashcode,but It time out in somecases.<BR/>can you give a breif explanation of your code?<BR/>I should say that maybe one reason that i dont understand your sloution enough is that i dont know C# and hashing enough.<BR/>anyway if you have time,pls explain your code:)<BR/><BR/>thanks in advance<BR/><BR/>hadiHadi_Asiaiehttps://www.blogger.com/profile/01637333461994889471noreply@blogger.comtag:blogger.com,1999:blog-1953325079793449971.post-27375095908705178152009-03-25T22:01:00.000+01:002009-03-25T22:01:00.000+01:00nw this is a kind of vid that can inspire beginner...nw this is a kind of vid that can inspire beginners like m2 :)..ty Pter..Any other uploads will be highly appreciatedudayhttps://www.blogger.com/profile/10334163076335891962noreply@blogger.comtag:blogger.com,1999:blog-1953325079793449971.post-18371639762141098902009-03-25T16:24:00.000+01:002009-03-25T16:24:00.000+01:00Petr do you know a tutorial of Dynamic Programming...Petr do you know a tutorial of Dynamic Programming diferent of TopCoder's tutorial? i want to learn it but i can't find a complete tutorial.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-1953325079793449971.post-62609090384704870402009-03-22T21:59:00.000+01:002009-03-22T21:59:00.000+01:00You should solve the CAPTCHA to the top of the gre...You should solve the CAPTCHA to the top of the green button, and then press the green button. If there's a checkbox around (this is browser-dependent), uncheck it - it is about installation of their toolbar.Petr Mitrichevhttps://www.blogger.com/profile/00138130656174416711noreply@blogger.comtag:blogger.com,1999:blog-1953325079793449971.post-73832142351575704692009-03-22T21:53:00.000+01:002009-03-22T21:53:00.000+01:00Its all Russian .....I am not able to follow the i...Its all Russian .....I am not able to follow the instructions...Anonymousnoreply@blogger.com