<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>algorithm on Two Tigers Engineering</title>
    <link>https://blog.twotigers.xyz/series/algorithm/</link>
    <description>Recent content in algorithm on Two Tigers Engineering</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <lastBuildDate>Thu, 09 Dec 2021 09:12:25 +0800</lastBuildDate><atom:link href="https://blog.twotigers.xyz/series/algorithm/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>一个简单的快排算法</title>
      <link>https://blog.twotigers.xyz/posts/algorithm/sort/quicksort/</link>
      <pubDate>Thu, 09 Dec 2021 09:12:25 +0800</pubDate>
      
      <guid>https://blog.twotigers.xyz/posts/algorithm/sort/quicksort/</guid>
      <description> 使用快排的思想 空间复杂度很垃圾, 只是为了更好的理解快排算法 TODO 修改成不需要额外空间的算法 def quicksort(data: list): if len(data) &amp;lt;= 1: return data less = [] more = [] pivot = data[0] for item in data: if item &amp;lt; pivot: less.append(item) elif item &amp;gt; pivot: more.append(item) return quicksort(less) + [pivot] + quicksort(more) data = [1, 4, 2, 6, 3, 10, 12, 11] print(quicksort(data)) </description>
    </item>
    
    <item>
      <title>二叉树生成与遍历</title>
      <link>https://blog.twotigers.xyz/posts/algorithm/tree/</link>
      <pubDate>Wed, 08 Dec 2021 14:12:25 +0800</pubDate>
      
      <guid>https://blog.twotigers.xyz/posts/algorithm/tree/</guid>
      <description>class Node: def __init__(self, val, left=None, right=None) -&amp;gt; None: self.val = val self.left = left self.right = right def create_tree(data: list): if not data: return None first_node = Node(data[0]) tmp_list = [first_node] tmp_count = 0 for item in data[1:]: node = tmp_list[0] new_node = Node(item) if item is not None else None if tmp_count == 0: node.left = new_node # add to tmp_list if item is not None: tmp_list.append(new_node) tmp_count += 1 continue if tmp_count == 1: node.</description>
    </item>
    
  </channel>
</rss>
