FANFNA
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    10
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # 演算法 研究所讀書筆記 [TOC] ## 大綱 | Unit | 考古程度 | 熟練程度 | 備註 | |:----------------------:|:--------:|:--------:|:----:| | Introduction | ★☆☆☆☆ | ✓✓✓✓✓ | | | Time Complexity | ★★★★★ | ✓✓✓✓✓ | | | Recurrence | ★★★★☆ | ✓✓✓✓✓ | master thoerm | | Dynamic Programming | ★★★★☆ | ✓✓✓ | | | Graph Algorithm | ★★★★★ | ✓✓✓✓✓ | | | Computational Geometry | ★★☆☆☆ | ✓ | | | NP Complete | ★★★★★ | ✓✓✓ | | ### 準備 [x] Time Complexity &gt; Master Thereom必備!畫tree也是另種方法,求時間複雜度有很多種方法,我覺得每個都很重要,所以建議大家都要讀一下~ - [ ] Recurrence(Divide and Conquer) &gt; 遞迴對於一個programmer也不是件簡單的事情,當然,邊界條件一定要定義清楚,清大常會叫你手寫出遞迴psuedo code,所以在讀這邊的時候要記得自己寫寫看遞迴code。 - [ ] Dynamic Programming &gt; 除了KMP那邊需要多花時間去著墨,其他都是將recurrence的問題化簡,而產出的code,所以難度沒有太高。建議演算法的code也要會,自己最好可以自己默寫一遍。能在電腦上Compile當然是更好! - [ ] Graph Algorithm &gt; 五顆星!每個的演算法時間都要知道,哪個演算法有啥限制(例:不能有負環等)也要知道,並且要知道為什麼會有些限制,曾經考過證明。 &gt; 1. BFS、DFS &gt; 2. Minimum Spanning Tree &gt; 3. Shortest Path Problem &gt; 4. Flow Network &gt; 5. Topological Sort - [ ] Computational Geometry &gt; 不是很重要... - [ ] NP Complete &gt; 要練習Reduction的話找清大考古題,要練習觀念的話找交大考古題,這兩所的考題方向不同,清大會要求你有能Reduce的能力,交大要你觀念清晰,並且知道哪些是已知的NPC問題。台大資工今年也有考一題NP Reduction,不過我直接沒寫😔 :::spoiler ![](https://i.imgur.com/Q1t9OMA.jpg) ::: ## 第一章節(time complex) ### Asymptotic Algo Here we need to know. When we slove the ploblem we use the Algo. * 1.And the Avg time we use to slove is the θ(n) tigh bu, * 2.The worst we use to slove is O(n) we also call it lower bum * 3.The best time to slove is Ω(n) we call it upper bum ____ Here have an cloums | Slove time | simpsize | growth oder | name | | --------------- | --------- | ----------- | ------------- | | Wost time | f(n)=O(n) | g(n)≥f(n) | upper bound ⇓ | | Avg time | f(n)=θ(n) | g(n)=f(n) | tight bound | | Best time | f(n)=Ω(n) | g(n)≤f(n) | lower bound ⇑ | | Stric Wost time | f(n)=o(n) | g(n)>f(n) | upper bound ⇓ | | Stric Best time | f(n)=o(n) | g(n)<f(n) | lower bound ⇑ | ___ We need to find the best sloution we also call it tight boum and sita(θ(n)) * pinck the upper(O) to forward the (θ) (the upper go down ) * pinck the lower(Ω) to forward the (θ)(the lower go down) ![](https://i.imgur.com/OxCiF6m.png) ![](https://i.imgur.com/A0xuYKB.png) ### Calculate E.g Here we need to find the tight bound * Tower of Hanoi (河內塔) * ## 第二章 Recursion(遞迴) ### info The recusion is the function call it self (we also call it to find the) **Fibonacci** ![](https://i.imgur.com/ekxg7EL.png) It is really good sample to let you know here we use the **python** ``` def factorial(n): if n == 0 or n == 1: return 1 else: return n * factorial(n - 1) ``` And we ## CH3 Divide-and-Conquer - When we slove an problem we is to hard to slove maybe we can dive it to subproblem - Often gives significant, usually polynomial, speedup ### step of the Dc use - Step 1. Divide list to two halves, A and B - Step 2. Sort A using Merge Sort - Step 3. Sort B using Merge Sort - Step 4. Merge sorted lists of A and B ## CH4 Sort ## DP ### Gready * we need to find the optimal algo(global maximal) ![](https://i.imgur.com/y2e1Cto.png) ![](https://i.imgur.com/POUclDT.png) # greedy algo ## 1 Minimum Spanning Trees ### Spanning Tree - 定義 - S = (V, F)為G的一個Spanning Tree且S滿足 - 自F’中任取一邊加入S中必形成Cycle - 在S中任何頂點對之間必存在一唯一Simple path - 性質 - 若G 不連通則G無Spanning Tree - G中的Spanning Tree不只一個 - 同一G中的任二個不同之Spanning Tree不一定有交集的邊存在 ### Minimal Spanning Tree - 定義 - ![](https://i.imgur.com/PQcs5xE.png) - 在G 的所有Spanning Tree中,具有最小的邊成本總和者。 可求MST的演算法如下 #### Prim’s Algorithm: - 從一個點出發( U, V-U ),像Dijkstra,由擴張樹的某一頂點與其它頂點的所有邊中挑選出具最小值者,不允許有迴路,O(n^2),使用資料結構Heap優化,O(ElgV)。 - ![](https://i.imgur.com/MOWM2GJ.png) #### Sollin’s Algorithm: - 以merge的概念實作,剩一棵樹結束 **皆是greedy algorithm。** #### Kruskal’s Algorithm - 概念 - Kruskal演算法是一種用來尋找最小生成樹的演算法,是greedy演算法的應用。Kruskal演算法是以增加邊的觀念做為出發點。首先將所有的邊,依照權重的大小排序。再來依序加入權重最小的邊,如果造成cycle時,則必須捨棄,直到增加了n - 1條邊為止(假設有 n 個節點)。Kruskal演算法在圖中存在相同權值的邊時也有效。 - 步驟 - 選擇:由spanning tree的所有邊中,挑選出具最小值者**(不允許有迴路)**。 重複直到下列任一條件成立為止 (n-1)個邊已挑出 //n是頂點的個數 無邊可挑,若 |F| < n-1,則無spanning tree 複雜度分析 建邊權重的heap : O(E) 取得並刪除最小權重的邊(u,v) : O(logE) 需偵測取得的邊是否構成cycle,使用set operation操作,同一集合為同set union(u,v) : O(1) Find(u) : 花O( a(m,n) ), 逼近O(1) 每回合最多花O(logE) 因此Kruskal’s Algorithm complexity = O(E) + O(ElogE) = O(ElogE) 證明 手法為cut-and-paste 假設最小權重的邊E不在minimum spanning tree T中 在T中加入E會形成cycle 因此拿掉一個比E權重大的邊,形成權重較小的T’,矛盾而得證 ## SEARCH ![](https://i.imgur.com/9g8PQaT.png)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully