Yanshuo Li
    • 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
    • Make a copy
    • 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 Make a copy 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
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Homework ## Lists - [HW-1](https://hackmd.io/@ysl/SkcJ3mJXp/edit) - [HW-2](https://hackmd.io/@ysl/SyIsnXyXT/edit) - [HW-3](https://hackmd.io/@ysl/HyT9nXyQa/edit) - [HW-4](https://hackmd.io/@ysl/S1Qi3Xkma/edit) - [HW-5](https://hackmd.io/@ysl/HyEepQy7a/edit) - [HW-6](https://hackmd.io/@ysl/rkceamkXp/edit) - [HW-7](https://hackmd.io/@_EUdnTNeRl-LUa2kz_WvLw/SkrBcugv6) ## HW-1 (Legacy) ### 1 > Recall the recursive program (discussed in the class) that computes the $n$-th Fibonacci number. Compute the exact number of additions used by the program. 令 $T(n)$ 為計算第 n 個費氏數所需的加法次數,則根據遞迴公式可得 $T(n)=T(n-1)+T(n-2)+1, T(1)=0,T(2)=0,T(3)=1$ $T(n)=T(n-1)+T(n-2)+1\leq2T(n-1)+1$ $$ \begin{split} T(n)&\leq2T(n-1)+1\\ &=2[2T(n-2)+1]+1\\ &=2^2T(n-2)+2+1\\ &=2^2[2T(n-3)+1]+2+1\\ &=2^3T(n-3)+2^2+2+1=...\\ &=2^kT(n-k)+2^{k-1}+2^{k-2}+...+2^2+2+1=2^kT(n-k)+\dfrac{1-2^k}{1-2}\\ &=2^kT(n-k)+2^k-1 \ \ (let \ n-k=1)\\ &=2^{n-1}T(1)+2^{n-1}-1=2^{n-1}-1=O(2^n) \end{split}$$ 故 $T(n)\in O(2^n)$ --- ### 2 > Given a tree T and k subtrees of T such that each pair of subtrees has at least one vertex in common, prove that there is at least one vertex in common to all the subtrees. **解法一 :** 令$k=2$,$T_1$與$T_2$為$T$的subtree,根據題目給定條件,$T_1$與$T_2$至少有一個共同頂點,因此當$k=2$時成立。 假設$k=m$,如果任意一組subtree $T_1,T_2,...,T_m$至少有一個共同的頂點,那麼存在至少一個頂點為subtree $T_1,T_2,...,T_m$的共同頂點。 令$k=m+1$,要證明任意一組subtree $T_1,T_2,...,T_{m+1}$至少有一個共同的頂點的條件下,至少存在一個全部subtree的共同頂點。 由於任意一組subtree $T_1,T_2,...,T_m$至少有一個共同的頂點,且存在至少一個頂點為subtree $T_1,T_2,...,T_m$的共同頂點,因此我們只需要考慮subtree $T_{m+1}$與$T_1,T_2,...,T_m$之間的關係。由於$T_{m+1}$與任一一個subtree至少有一個共同頂點,且在$T_1,T_2,...,T_m$存在一個共同頂點,因此$T_{m+1}$也存在一個與$T_1,T_2,...,T_m$共同的頂點。 根據數學歸納法,在一個tree中有$k$個subtree使得每一組subtree中至少存在一個頂點,那麼在所有subtree中必定存在至少一個共同的頂點。 **解法二** : 題目等同於證明 Helly property 的定理 **Helly property** : A family $\{A_i:i \in I\}$ of subsets of a set A is said to satisfiy the Helly property if $J\subseteq I$, and $A_i\cap A_j \neq \varnothing$, for every $i, j \in J$, then $\bigcap_{j\in J}A_j\neq\varnothing$. **Theorem : A family of subtrees of a tree satisfies the Helly property 一棵樹的所有子樹皆滿足 Helly property** **Proof**: 令 A 收集的是樹 T 的所有子樹,$A=\{T_i:i \in I=\{1, 2, ..., n\}\}$。假設對所有的 $i, j \in J=\{1, 2, ...,k\}\subseteq I, T_i \cap T_j \neq \varnothing$,我們需要證明出 $\bigcap_{j\in J}T_j\neq\varnothing$。 若有一棵子樹 $T_i \in A, i \in J$ 只有一個點 $v$,則明顯可證出 $\bigcap_{j\in J}T_j=\{v\}$。所以假設每個子樹 $T_i \in A, i \in J$ 至少有兩個節點。 我們對子樹的節點數進行歸納法。假設樹 T 有 n 個節點,每個子樹最多有 n 個節點,且滿足 Helly property。 當 T 為 n + 1 個節點的樹時, 令 $v_0$ 為 T 的樹葉節點且其唯一的鄰點為 $u$。 令 $T_i'=T_i-v_0,i \in J$ 且 $T'=T-v_0$ 為 n 個節點的樹。 ($T_i'$ 為 T 的子樹去除 $v_0$,所以最多有 n 個節點) 根據歸納假設,$T'$ 滿足 Helly Property。 1. 若 $T_i\ 和 \ T_j$ 有一共同點 $x(\neq v_0)$,則 $T_i'\ 和 \ T_j'$ 一定也有一共同點 $x$。 2. 若 $T_i\ 和 \ T_j$ 有一共同點 $v_0$,則 $T_i\ 和 \ T_j$ 一定還有一共同點 $u_0$,因為前面有假設子樹最少兩個節點,所以如果 $v_0$ 在裡面,$u_0$ 勢必也一定會在裡面,不然其中一個子樹只有一個節點 $v_0$ 會矛盾。 $\Rightarrow$ $T_i'\ 和\ T_j'$ 有一個共同點 $u_0$ 由 (1)(2) 根據歸納假設,因為 $T_i'\cap T_j'\neq \varnothing,$,則 $\bigcap_{j\in J}T_j'\neq \varnothing$,也因此每個 $T_j'$ 再加入 $v_0$ 得到 $\bigcap_{j\in J}T_j\neq \varnothing$。所以當 T 的節點數為 n + 1時命題亦成立,故由數學歸納法可得證。

    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