<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: YongxiangJ</title>
    <description>The latest articles on DEV Community by YongxiangJ (@ghooul).</description>
    <link>https://dev.to/ghooul</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F913005%2Fd9b36fb0-0477-4daf-93b9-b78717ed66fd.png</url>
      <title>DEV Community: YongxiangJ</title>
      <link>https://dev.to/ghooul</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ghooul"/>
    <language>en</language>
    <item>
      <title>A Star Algorithm with UI</title>
      <dc:creator>YongxiangJ</dc:creator>
      <pubDate>Thu, 25 Aug 2022 20:52:52 +0000</pubDate>
      <link>https://dev.to/ghooul/a-star-algorithm-with-ui-257a</link>
      <guid>https://dev.to/ghooul/a-star-algorithm-with-ui-257a</guid>
      <description>&lt;h1&gt;
  
  
  What is A Star Algorithm?
&lt;/h1&gt;

&lt;p&gt;A* algorithm is a search algorithm usually used in path finding. It guarantees to find a complete and optimal path if there is one (the target is not surrounded by walls on all sides). Since it is an informed search, we have the control over where the target is and the distance between each nodes.&lt;/p&gt;

&lt;h1&gt;
  
  
  Why did I do it?
&lt;/h1&gt;

&lt;p&gt;A* algorithm is one of the most frequent algorithms that I used during my undergraduate study. The map system for the hospital app, robot which explores the maze, and other projects all uses A* for path finding. Since I lost access to most of the project code, I would really like to rewrite the algorithm. I could also use this algorithm in the future projects if needed.&lt;/p&gt;

&lt;h1&gt;
  
  
  How did I do it?
&lt;/h1&gt;

&lt;p&gt;I first implemented A* on nodes connected with edges. This was represented using a graph. I used priority queue for the algorithm because this data structure perfectly blends with A*'s property(v.0.1.0 release on GitHub).&lt;/p&gt;

&lt;h2&gt;
  
  
  Part 2
&lt;/h2&gt;

&lt;p&gt;A* is cool in action. I decided to visualize the A* using a simple interactive UI. The Swing library was my first UI library, it's enough for a simple UI to use.&lt;/p&gt;

&lt;h1&gt;
  
  
  The Program
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--v3RXk2tW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bo6c7yj9v3sqfz7f88po.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--v3RXk2tW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bo6c7yj9v3sqfz7f88po.PNG" alt="Image description" width="880" height="933"&gt;&lt;/a&gt;&lt;br&gt;
(The start of the program.)&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4AI0nven--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/szq9f95aedhf6c0qmgoe.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4AI0nven--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/szq9f95aedhf6c0qmgoe.PNG" alt="Image description" width="880" height="927"&gt;&lt;/a&gt;&lt;br&gt;
(When we click on the Manual A* button, it proceeds with 1 step of A* search.)&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kxOC1lfS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xxsgx2unwxh8qrzd0xsc.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kxOC1lfS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xxsgx2unwxh8qrzd0xsc.PNG" alt="Image description" width="880" height="927"&gt;&lt;/a&gt;&lt;br&gt;
(This is A* auto mode. This finds the path with 1 click.)&lt;/p&gt;

&lt;h1&gt;
  
  
  Time &amp;amp; Space Complexity
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Time Complexity
&lt;/h2&gt;

&lt;p&gt;In the worst case scenario, the time complexity is O(b^d), where b is the branching factor, and d is the depth of the solution. The branching factor is how many nodes we are comparing in an iteration. The depth is the the minimum number of nodes we need to take to reach the target(shortest path). The time complexity is exponential, because each node has 4 (or 8 if including diagonal nodes) neighbors to expand.&lt;/p&gt;

&lt;h2&gt;
  
  
  Space Complexity
&lt;/h2&gt;

&lt;p&gt;The space complexity is the same as Time Complexity; O(b^d).&lt;/p&gt;

</description>
      <category>java</category>
      <category>swing</category>
      <category>programming</category>
      <category>algorithms</category>
    </item>
    <item>
      <title>Tea Shop Recommendation System</title>
      <dc:creator>YongxiangJ</dc:creator>
      <pubDate>Mon, 22 Aug 2022 00:09:46 +0000</pubDate>
      <link>https://dev.to/ghooul/tea-shop-recommendation-system-2h8n</link>
      <guid>https://dev.to/ghooul/tea-shop-recommendation-system-2h8n</guid>
      <description>&lt;h1&gt;
  
  
  What is it?
&lt;/h1&gt;

&lt;p&gt;This program is used to return a list of possible items based on the user's input string.&lt;/p&gt;

&lt;h1&gt;
  
  
  Why?
&lt;/h1&gt;

&lt;p&gt;I really like Chinese tea just as my father. He owns a tea shop called Orijin Tea. I tried to use the official website and found out that the search results were not so accurate. I suddenly realized that I can improve the search functionality.&lt;/p&gt;

&lt;h1&gt;
  
  
  Brief Methodology
&lt;/h1&gt;

&lt;p&gt;There are two major parts to this system: saving data and retrieving data. The raw data are stored in a 2d python list. I put this data set into a hash table before running through the algorithm. To retrieve the correct product, I take the user input and go through each product. If the user input appears inside the product, then we can print that product for the user (in a specific format). &lt;/p&gt;

&lt;h1&gt;
  
  
  Current Progress
&lt;/h1&gt;

&lt;p&gt;Right now, the program can quickly handle the whole tea collection at Orijin Tea (approximately 135 types of Chinese Tea). As the user types in a search text, the program suggests a few possible products, including the rating, price, tea origin, and its name.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UOq0tOMh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d7k85nrxljvc9w4iw2m1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UOq0tOMh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d7k85nrxljvc9w4iw2m1.png" alt="Image description" width="880" height="831"&gt;&lt;/a&gt;&lt;br&gt;
(The ratings section is not set yet.)&lt;/p&gt;

&lt;p&gt;The current data retrieval is good enough for small data. I tested it with 20k sized data set (20k tea data) and the time it iterated through the whole data set was approx. 0.04s.&lt;/p&gt;

&lt;h1&gt;
  
  
  Next Steps
&lt;/h1&gt;

&lt;p&gt;I am considering to implement this functionality into GUI to visualize it better. Function wise, I am still trying to implement a better algorithm which can handle larger data sets.&lt;/p&gt;

&lt;p&gt;If you want to see more details in code, follow on GitHub:&lt;br&gt;
&lt;a href="https://github.com/OrijinTech/TeaRecommendation"&gt;Link&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thank you for reading it through! ^_^&lt;/p&gt;

</description>
      <category>python</category>
      <category>algorithms</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
