tag:blogger.com,1999:blog-4640943833280351629.post1383694350354351944..comments2023-04-27T07:50:23.441-07:00Comments on Algo Ramblings: Ternary Search Tree implementationRamhttp://www.blogger.com/profile/14216463582774488342noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-4640943833280351629.post-32154445208270716022013-06-17T15:10:17.589-07:002013-06-17T15:10:17.589-07:00This code is correct with modification. In the ins...This code is correct with modification. In the insert function <br />if (s[pos] < node.m_char)<br />{<br /> insert(key, pos, node.left); <br />}<br /><br />Here it is calling a new insert function with null node(node.left). Here node.left is a null node. So in each call of insert function a node is created but it is not linked with its parent node. So initialize a node(left/right/center) first then call insert function.<br /> <br />Modified part for left node:<br />if (s[pos] < node.m_char)<br />{<br /> if(node.left == null) node.left = new Node(s[pos], false);<br /> insert(key, pos, node.left); <br />}<br /><br />So left node are linked with its parent. change for the right and center node. Anonymoushttps://www.blogger.com/profile/11043786061956743225noreply@blogger.comtag:blogger.com,1999:blog-4640943833280351629.post-75091493185631965382012-05-08T08:58:01.099-07:002012-05-08T08:58:01.099-07:00The code is mostly correct. With some minor chang...The code is mostly correct. With some minor changes, such as returning the object upon an insert, it can be fixed.Larry M. Lemonshttps://www.blogger.com/profile/13921663093024873533noreply@blogger.comtag:blogger.com,1999:blog-4640943833280351629.post-74288571006178125872012-05-08T08:56:09.400-07:002012-05-08T08:56:09.400-07:00The code is mostly right. With some minor changes...The code is mostly right. With some minor changes (such as returning the object and storing it upon an insert), it can be fixed.Larry M. Lemonshttps://www.blogger.com/profile/13921663093024873533noreply@blogger.comtag:blogger.com,1999:blog-4640943833280351629.post-39958662639246779622011-11-27T23:54:26.662-08:002011-11-27T23:54:26.662-08:00It should be noted that this code is actually WRON...It should be noted that this code is actually WRONG.Prog47https://www.blogger.com/profile/04328727890915709491noreply@blogger.comtag:blogger.com,1999:blog-4640943833280351629.post-65542530570238652202011-05-10T22:10:31.702-07:002011-05-10T22:10:31.702-07:00Won't containsKey() always return false?Won't containsKey() always return false?eggmattershttps://www.blogger.com/profile/09773427157780914618noreply@blogger.com