{"id":22430,"date":"2021-02-12T09:11:37","date_gmt":"2021-02-12T00:11:37","guid":{"rendered":"https:\/\/www.waca.associates\/en\/?p=22430"},"modified":"2021-03-22T08:52:52","modified_gmt":"2021-03-21T23:52:52","slug":"kit-popular-uniform-search-algorithm","status":"publish","type":"post","link":"https:\/\/www.waca.or.jp\/en\/growthhacking\/kit-popular-uniform-search-algorithm\/","title":{"rendered":"[KIT] Popular Uniform search Algorithm"},"content":{"rendered":"<p>Uniform search algorithm is an algorithm that has no additional info about the state beside from problem definition. In this article i will bring you to a brief introduction of some popular uninform search algorithms.<\/p><ol class=\"wp-block-list\"><li><strong>Breadth-first Search<\/strong><\/li><li><strong>Depth-first Search<\/strong><\/li><li><strong>Depth-limited Search<\/strong><\/li><li><strong>Iterative deepening depth-first search<\/strong><\/li><li><strong>Uniform cost search<\/strong><\/li><li><strong>Bidirectional Search<\/strong><\/li><\/ol><h3 class=\"wp-block-heading\">1. Breath first Search<\/h3><figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"187\" height=\"175\" src=\"https:\/\/www.waca.associates\/en\/wp-content\/uploads\/2021\/02\/Animated_BFS-1-1.gif\" alt=\"\" class=\"wp-image-22432\" \/><\/figure><ul class=\"wp-block-list\"><li> breath first search is a tree and graph search algo it start from root node then expands all successor before going to next level <\/li><li> All the node in the same level are expand before go to next level <\/li><li> this algo use FIFO queue as frontier <\/li><\/ul><ul class=\"wp-block-list\"><li>BFS is completeness: that mean it will give us the solution if solution exist<\/li><li>BFS is optimal it will give us a less step solution to get to the goal<\/li><\/ul><h3 class=\"wp-block-heading\">Problem with BFS<\/h3><p>There is no algorithm that the best each algo has it own advantage and disavantage so base on our problem we need to choose one.<\/p><p>Also  in BFS the problem are<\/p><ul class=\"wp-block-list\"><li>require a lot of memory because all the node in tree was stored<\/li><li>required more time to complete<\/li><\/ul><p>Because these problems we have another algo that can reduce the memmory and space complexity for us<\/p><h2 class=\"wp-block-heading\">2. Uniform cost search<\/h2><figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"606\" height=\"387\" src=\"https:\/\/www.waca.associates\/en\/wp-content\/uploads\/2021\/02\/Algorithm-1-1.png\" alt=\"\" class=\"wp-image-22433\" \/><figcaption>source : educba<\/figcaption><\/figure><ul class=\"wp-block-list\"><li>instead of expand the successor by level we expand the node base on the cost.<\/li><li>we use pririority queue base on g(n) for this that mean the node with the lowest g(n) will expand first<\/li><li>goal test will not perform until that node selected for expandsion<\/li><\/ul><h2 class=\"wp-block-heading\">Algorithm<\/h2><pre class=\"wp-block-code\"><code>step1: initialize a queue with root node with its pririority and a set \nstep2: while queue is not empty:\n\t- remove node highest pririority from queue,add to set\n\t- if goal return success\n\t- else add all child to queue with pririority\n\n<\/code><\/pre><ul class=\"wp-block-list\"><li>It give a lowest path cost solution in weight graph<\/li><li>It is optimal<\/li><li>It is complete<\/li><li>Time complexity<\/li><\/ul><p>$$time=O(b^x), x=c+1$$<\/p><p>C is a number of depth from root to the goal<\/p><p>n maximum number of child of each o<\/p><h2 class=\"wp-block-heading\">3.Depth First search<\/h2><figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"500\" height=\"500\" src=\"https:\/\/www.waca.associates\/en\/wp-content\/uploads\/2021\/02\/dfs.gif\" alt=\"\" class=\"wp-image-22434\" \/><\/figure><ul class=\"wp-block-list\"><li>It start from root node and follow each path until the last depth before moving to next path<\/li><li>we use LIFO queue (stack)<\/li><li>Algorithm is similiar to BFS<\/li><li>time complexity<\/li><\/ul><ul class=\"wp-block-list\"><li>It use less memory because it store only the node in one depth<\/li><li>less time than BFS if take the right path<\/li><\/ul><h3 class=\"wp-block-heading\">The problem with DFS<\/h3><ul class=\"wp-block-list\"><li>it will be a loop if the tree is not bounce<\/li><li>so it will be not complete<\/li><li>Not optimal<\/li><\/ul><p>to avoid this loop we have another solution that is Depth limited search<\/p><h2 class=\"wp-block-heading\">4. Depth Limited Search<\/h2><figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"424\" height=\"338\" src=\"https:\/\/www.waca.associates\/en\/wp-content\/uploads\/2021\/02\/s.png\" alt=\"\" class=\"wp-image-22435\" \/><\/figure><ul class=\"wp-block-list\"><li>It&#8217;s like DFS but what we do is adding limited depth to avoid loop<\/li><li>It will be terminated if the depth exit the limit<\/li><li>it is not optimal<\/li><li>it is not complete if if the solution above the limit<\/li><li>Not optimal<\/li><\/ul><h2 class=\"wp-block-heading\">5. Recursive Depth limited search<\/h2><ul class=\"wp-block-list\"><li>It is like depth limit search but it set the limit again and again until we found the solution<\/li><\/ul><h2 class=\"wp-block-heading\">6. Iterative Deepening depth first search<\/h2><ul class=\"wp-block-list\"><li>As we know it BFS even it is fast but it require a lot of space to store the node because it store all the node in the level to the queue<\/li><li>Also DFS even it require less space but it take log time to find the solution<\/li><\/ul><figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"420\" src=\"https:\/\/www.waca.associates\/en\/wp-content\/uploads\/2021\/02\/w-1024x420.png\" alt=\"\" class=\"wp-image-22436\" \/><\/figure><p>That why IDDFS came in. In IDDFS we get the benefit from BFS(time) and DFS(space)<\/p><h2 class=\"wp-block-heading\">7. Bidirectional Search<\/h2><ul class=\"wp-block-list\"><li>it is an algo that search from both direction simontanously<\/li><li>start from initial state by forward searching<\/li><li>also start from goal node by backward searching<\/li><li>so we can perform 2 algorithm one from intial state and one from goal state<\/li><li>we can use BFS,DFS,IDDFS in each side<\/li><\/ul>","protected":false},"excerpt":{"rendered":"Uniform search algorithm is an algorithm that has no additional info about the state beside from problem defin [&hellip;]","protected":false},"author":718,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[169],"tags":[],"class_list":["post-22430","post","type-post","status-publish","format-standard","hentry","category-growthhacking"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.waca.or.jp\/en\/wp-json\/wp\/v2\/posts\/22430"}],"collection":[{"href":"https:\/\/www.waca.or.jp\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.waca.or.jp\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.waca.or.jp\/en\/wp-json\/wp\/v2\/users\/718"}],"replies":[{"embeddable":true,"href":"https:\/\/www.waca.or.jp\/en\/wp-json\/wp\/v2\/comments?post=22430"}],"version-history":[{"count":1,"href":"https:\/\/www.waca.or.jp\/en\/wp-json\/wp\/v2\/posts\/22430\/revisions"}],"predecessor-version":[{"id":22437,"href":"https:\/\/www.waca.or.jp\/en\/wp-json\/wp\/v2\/posts\/22430\/revisions\/22437"}],"wp:attachment":[{"href":"https:\/\/www.waca.or.jp\/en\/wp-json\/wp\/v2\/media?parent=22430"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.waca.or.jp\/en\/wp-json\/wp\/v2\/categories?post=22430"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.waca.or.jp\/en\/wp-json\/wp\/v2\/tags?post=22430"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}