110-2 CSIE Algorithms
  • NEW!
    NEW!  Connect Ideas Across Notes
    Save time and share insights. With Paragraph Citation, you can quote others’ work with source info built in. If someone cites your note, you’ll see a card showing where it’s used—bringing notes closer together.
    Got it
        • 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
          • Owners
          • Signed-in users
          • Everyone
          Owners Signed-in users Everyone
        • Write
          • Owners
          • Signed-in users
          • Everyone
          Owners 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 No publishing access yet

        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.

        Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

        Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

        Explore these features while you wait
        Complete general settings
        Bookmark and like published notes
        Write a few more notes
        Complete general settings
        Write a few more notes
        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
      • 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 Help
    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
    Owners
    • Owners
    • Signed-in users
    • Everyone
    Owners Signed-in users Everyone
    Write
    Owners
    • Owners
    • Signed-in users
    • Everyone
    Owners 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 No publishing access yet

    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.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    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
    # Week 17 :::info :::spoiler Click to Open TOC [TOC] ::: # Question :::info :::spoiler Click to Open Question ![](https://i.imgur.com/QftuGAw.png) ## Check - [x] Q1 - [ ] Q2 - [ ] Q3 - [ ] Q4 ::: # Answer ## Q1 > - [name=LXS] :::spoiler 題目 Let 2-CNF-SAT be the set of satisfiable Boolean formula in CNF with exactly 2 literals per clause. Show that 2-CNF-SAT ∈ P. Make your algorithm as efficient as possible. (Hint: Observe that x ∨ y is equivalent to ¬x → y. Reduce 2-CNF-SAT to an efficiently solvable problem on a directed graph.) ::: #### 【解題思路】 將一個Boolean formula,其中有n個Boolean variable、m個calause,轉成一個directed graph,每個Boolean variable,$x_1,...,x_n$對應圖中點 $x_1,\neg x_1,...,x_n,\neg x_n$ 共2n個點,每個calause $x\lor y$相當於$\neg x\to y\land \neg y\to x$,對於圖中我們也連接$\neg x\to y$與$\neg y\to x$共個點共2m個邊。 首先找strongly connected components,需要$O(n)$時間,然後確保每個$x_k$與$\neg x_k$不在同一個SCC(不能存在$x_k\to ...\to\neg x_k$,$\neg x_k\to ...\to x_k$),需要$O(n)$,如果在同一個S CC則該Boolean formula是Unsatisfiable的。 我們可以在多項式時間內決定2-CNF-SAT問題,因此2-CNF-SAT ∈ P. #### 找Assignment 假如我們把每個SCC視為一個點(同一個SCC塗同樣顏色)稱作$G$,將每個點之間的邊的方向相反,稱作$G^T$,在$G^T$中,依照從原本$G$的Sink開始按照拓撲排序填色,相連的兩個SCC中填入相反的顏色,否則填入相同顏色,將同Sink顏色的點設為true即可以找到assignment。 ## Q2 > - [name=xian] :::spoiler **【題目】** The subgraph-isomorphism problem takes two undirected graphs G1 and G2, and it asks whether G1 is isomorphic to a subgraph of G2. Show that the subgraph-isomorphism problem is NP-complete. ::: 【證明】 > 證明 $SIP\in NP \rightarrow 驗證 \in P$ * 假設我們有G1和G2的子圖G,從上禮拜作業已證明 GRAPH-ISOMORPHISM $\in NP$,證明同構需要驗證以下四項: 1. Equal number of vertices. 2. Equal number of edges 3. Same degree sequence 4. Same number of circuit of particular length * 而這些都可以在 $P$ 時間內驗證 * 因此 $SIP \in NP$ > 證明 $SIP\in \text{NP-hard} \Rightarrow \text{CLIQUE} \le_p SIP$ * $對於\text{CLIQUE}問題給定一張圖G_2,另外生成一圖G_1,令G_1=K_i,|G_1|=i的完全圖, i\le |G_2|$,問$G_2$是否存在一個大小為 $k$ 的完全子圖(cliqu) $G$ * $如果G_2存在大小為i的\text{CLIQUE},則G_1為G_2的子圖$ * 因此將$G_1、G_2$ 丟入 $SIP$ 中,確認 $G_1$ 是否和 $G_2的子圖$同構 * 如果同構則回答true,不同構則回答false $\because 生成\ G_1\ 最多只需\ O(|G_1|^2),因此轉換時間為指數時間$ $\therefore \text{CLIQUE}$在指數時間下可解,則$SIP$也可 且我們已知$\;\text{CLIQUE} \in \text{NP-hard}\ \land SIP \in NP \implies SIP \in \text{NP-hard}$ 又因為 $SIP \in \text{NP-hard}\ \land NP$ $\therefore\ \bf SIP \in \text{NP-complete}_\#$ ## Q3 > - [name=chung] :::spoiler **【題目】** Given an integer m x n matrix A, and an integer m-vector b, the 0-1 integer-programming problem asks whether there exists an integer n-vector x with elements in the set {0, 1} such that Ax ≤ b. Prove that 0-1 integer programming problem is NP-complete. (Hint: Reduce from 3-CNF-SAT.) ::: **【證明】** - Problem ∈ NP : Find a certificate to verify that it is the correct answer to this question. - A certificate would be the n-vector x, and we can verify in polynomial time that Ax ≤ b, so 0-1 integer linear programming (01LP) is in NP. - Problem ∈ NP-hard : 3-CNF-SAT $≤_𝑝$ 0-1 integer- programming problem - 3-CNF-SAT $Ex : ( 𝑥_1∨𝑥_2∨𝑥_3 ) ∧ ( 𝑥_1∨¬𝑥_3∨¬𝑥_4 )$ If $𝑥_𝑗$ in clause i with negation → $𝐴_(𝑖,𝑗) = 1$ If $𝑥_𝑗$ in clause i without negation → $𝐴_(𝑖,𝑗) = -1$ Other, $𝐴_(𝑖,𝑗) =0$ $𝑏_𝑖$ = – 1 + num of negation in clause i $( 𝑥_1∨𝑥_2∨𝑥_3 ) : 𝑥_1+𝑥_2+𝑥_3≥1 ⇒ −𝑥_1−𝑥_2−𝑥_3≤−1 \\ ( 𝑥_1∨¬𝑥_3∨¬𝑥_4) : 𝑥_1+(1−𝑥_3 )+(1−𝑥_4)≥1 ⇒ −𝑥_1+𝑥_3+𝑥_4≤1 \\ Ax ≤ b : \begin{bmatrix} -1&-1&-1&0\\-1&0&1&1 \end{bmatrix}𝜒 ≤ \begin{bmatrix} -1\\1 \end{bmatrix}$ 轉換時間在 polynomial time 內,其又為 NP Problem,故得證 0-1 integer- programming problem is NP-complete. ## Q4 > - [name=yee] :::spoiler **【題目】** Based on hw14-7,we know that longest-simple-cycle problem is an NP-problem. Prove that the problem is NP-complete ::: **【解題思路】** 由14-7我們知道LSC為NP問題,$\text{certificate}$依序為$v_1, v_2, v_3,..., v_k$,且已知Hami-cycle 為NP-complete問題,因此可由Hami-cycle reduce to LSC 來證明LSC也是NP-complete問題。 **【證明】** $Hami-cycle <=_p LSC$ 若一Graph存在一個Hami-cycle也代表該Graph存在一k = |V|的LSC,若一Graph存在一序列$v_1, v_2, v_3,..., v_n(n = |V|)$的LSC,也代表該Graph也存在一Hami-cycle,因此可知Hami-cycle\ \ iff.\ LSC $\therefore\ \bf LSC \in \text{NP-complete}_\#$

    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
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    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