diff --git a/Submissions/001567668_Zihao_Liu/.ipynb_checkpoints/Assignment4-checkpoint.ipynb b/Submissions/001567668_Zihao_Liu/.ipynb_checkpoints/Assignment4-checkpoint.ipynb new file mode 100644 index 0000000..9262886 --- /dev/null +++ b/Submissions/001567668_Zihao_Liu/.ipynb_checkpoints/Assignment4-checkpoint.ipynb @@ -0,0 +1,174 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "819640f9-7344-4ce9-9fc4-4fb3b0db2a35", + "metadata": { + "tags": [] + }, + "source": [ + "# Assignment 4\n", + "### Zihao Liu\n", + "### 001567668" + ] + }, + { + "cell_type": "markdown", + "id": "274a8e1f-c901-4014-9225-6f2c07ecb486", + "metadata": {}, + "source": [ + "## Q1: k-edge-disjoint cycle-cover problem\n", + "**Problem Statement:**\n", + "\n", + "Given a directed graph $ G = (V, E) $, a k-edge-disjoint cycle-cover is a set of edge-disjoint cycles such that each edge $ e \\in E $ belongs to exactly one cycle. In other words, a k-edge-disjoint cycle cover of a graph$ G $ is a set of cycles which are sub-graphs of $G$ and contain all edges of $G$ exactly once. If the cycles of the cover have no edges in common, the cover is called an edge-disjoint cycle cover.\n", + "\n", + "The edge-disjoint cycle-cover problem asks whether a given directed graph has an edge-disjoint cycle cover.\n", + "\n", + "**Problem A (10 points): Is the edge-disjoint cycle-cover problem in P? If so, prove it.**\n", + "\n", + "*Answer:*\n", + "\n", + "This question is a known NP-Hard problem, meaning that there is no known polynomial-time solution for it unless P = NP. However, there are approximate polynomial-time algorithms to solve the problem.\n", + "\n", + "Naive Approach: Consider all subsets of edges and determine if they form a cycle that covers all vertices in the graph. For a graph with a small number of edges, this is feasible. For example, in a graph with only 4 edges, consider subsets like $\\{e_1, e_2\\}, \\{e_2, e_3\\}, \\{e_1, e_2, e_3, e_4\\}$, etc. Check if these subsets form cycles that cover all vertices in the graph. Update the optimal answer accordingly, and determine the subset with the minimum number of edges that covers all vertices of the graph.\n", + "\n", + "**Problem B (5 points): Suppose we require each cycle to have at most four edges. We call this the 4-edge-cycle-cover problem. Is the 4-edge-cycle-cover problem in NP? If so, prove it.**\n", + "\n", + "*Answer:*\n", + "\n", + "The 4-Edge-Cycle Cover Problem is similar to the Edge-Cycle Cover Problem but with an additional constraint that each cycle must have a length of at most four edges. \n", + "\n", + "4-Edge-Cycle Cover is in NP: The certificate of a \"yes\" instance is the cover itself. To check if it is a valid cover, inspect each cycle to ensure it is indeed a cycle and verify that each edge is covered. This process can be done in polynomial time.\n", + "\n", + "**Problem C (10 points): Is the 4-edge-cycle-cover problem NP-complete? If so, prove it.**\n", + "\n", + "*Answer:*\n", + "\n", + "To demonstrate that the 4-Edge-Cycle Cover is NP-hard, we can reduce from a known NP-hard problem such as the Hamiltonian Cycle problem. The reduction process involves constructing a graph in such a way that a solution to the 4-Edge-Cycle Cover problem on this graph would imply a solution to the Hamiltonian Cycle problem in the original graph. \n", + "\n", + "The construction and correctness proof would be intricate but based on ensuring that each Hamiltonian cycle in the original graph corresponds to a valid 4-edge-cycle cover in the constructed graph, and vice versa. The reduction can be performed in polynomial time, thus proving the NP-hardness of the 4-Edge-Cycle Cover problem. \n", + "\n", + "Given the problem is in NP and NP-hard, it is NP-complete." + ] + }, + { + "cell_type": "markdown", + "id": "bafbc806-442f-4a0b-8a90-cfbbb2f0cddf", + "metadata": {}, + "source": [ + "## Q2: The Directed Edge-Disjoint Paths Problem\n", + "\n", + "#### Context\n", + "In graph theory, the Directed Edge-Disjoint Paths Problem involves finding paths in a directed graph such that no two paths share an edge. This problem is fundamental in network routing where paths represent communication links.\n", + "\n", + "#### Problem Statement\n", + "\n", + "Given a directed graph $ G = (V, E) $ and $ k $ pairs of nodes $ (s_1, t_1), (s_2, t_2), \\ldots, (s_k, t_k) $, the Directed Edge-Disjoint Paths Problem asks whether there exist $ k $ edge-disjoint paths $ P_1, P_2, \\ldots, P_k $ such that each path $ P_i $ connects $ s_i $ to $ t_i $ without sharing any edges with other paths. Is the Directed Edge-Disjoint Paths Problem NP-complete?\n", + "\n", + "**Answer:**\n", + "Consider the k Edge-Disjoint Shortest Paths Problem, where we are given a graph and pairs of vertices $ (s_1, t_1), \\ldots, (s_k, t_k) $. The goal is to find $k$ pairwise edge-disjoint paths $ P_1, \\ldots, P_k $ such that each path $P_i$ is a shortest path from $ s_i $to $ t_i $, if such paths exist. When the length of each edge is zero, this simplifies to the edge-disjoint paths problem.\n", + "\n", + "If we consider positive edge lengths, certain variants of the problem can be solved in polynomial time. However, the 2 Edge-Disjoint Paths Problem in directed graphs is known to be NP-hard (referencing Richard M. Karp's work on computational complexity). Therefore, the Directed Edge-Disjoint Paths Problem, even for $ k = 2 $, is NP-hard. This conclusion applies to almost all variants of the directed $k $ Edge-Disjoint Shortest Paths Problem, with only a few exceptions known to be solvable in polynomial time." + ] + }, + { + "cell_type": "markdown", + "id": "19260f89-e40c-4c66-aa3b-7118df46a5f0", + "metadata": {}, + "source": [ + "## Q3: Efficient Project Team Formation\n", + "\n", + "You are leading a project that requires a diverse set of skills (e.g., software development, project management, graphic design, data analysis, marketing, etc.). You have received applications from $ m $ potential team members. Each individual possesses a subset of the necessary skills. The challenge is: For a given number $ k \\leq m $, is it possible to assemble a project team of at most $ k $ members that collectively possess all required skills? This problem will be called the Efficient Project Team Formation.\n", + "\n", + "**Answer:**\n", + "\n", + "1. **The problem is in NP**: Given a set of $ k $ team members, we can efficiently check in linear time relative to the number of skills and $ k $ members, whether every required skill is covered by at least one team member.\n", + "\n", + "2. **Proving NP-completeness**: This problem can be shown to be NP-complete by reducing from the Set Cover problem. In the Set Cover problem, given a set $ U $ of $ n $ elements, and a collection of $ m $ subsets of $ U $ whose union equals the set of elements, the question is whether there are at most $ k $ of these subsets whose union covers all of $ U $. Given an instance of Set Cover, we can construct an instance of Efficient Project Team Formation as follows: For each element of $ U $, create a required skill. For each of the $ m $ subsets in Set Cover, create a potential team member with skills corresponding to the elements in that subset. This reduction is done in polynomial time.\n", + "\n", + "3. **Conclusion**: There exists a team of $ k $ members that collectively possess all required skills if and only if there are $ k $ subsets in the Set Cover problem whose union covers all elements of $ U $. Thus, Set Cover ≤P Efficient Project Team Formation. Therefore, Efficient Project Team Formation is an NP-Complete problem." + ] + }, + { + "cell_type": "markdown", + "id": "6cc29573-c4ef-4334-ab66-11d40a8a5efb", + "metadata": {}, + "source": [ + "## Q4: Efficient Event Staffing Problem\n", + "Consider you're coordinating a large-scale international conference that features multiple thematic sessions, such as technology, economics, culture, etc. The conference requires at least one expert for each thematic session. There have been applications from a number of potential speakers. For each thematic session, there is a subset of these applicants who are qualified to speak on that topic. The question is: For a given number $ k < m $ (where $ m $ is the number of applicants), is it possible to select at most $ k $ speakers and ensure at least one qualified speaker for each thematic session? This is known as the Efficient Event Staffing Problem.\n", + "\n", + "**Answer:**\n", + "\n", + "1. **The Problem is in NP:** Given a set of $ k $ speakers, we can easily verify in linear time relative to the number of thematic sessions and $ k $ speakers, whether each session has at least one speaker who is qualified to present on its topic.\n", + "\n", + "2. **Proving NP-Completeness through Reduction from Set Cover:**\n", + " - **Recall the Set Cover Problem:** Given a set $ U $ of $ n $ elements and a collection of $ m $ subsets of $ U $ whose union equals the set of elements, the question is whether there exist at most $ k $ of these subsets whose union equals all of $ U $.\n", + " - **Reduction to Efficient Event Staffing:** For each element of $ U $, create a thematic session. For each of the $ m $ subsets, create a speaker and assign expertise to this speaker in the sessions corresponding to the elements of this subset. This reduction is clearly polynomial in time.\n", + " - **Equivalence of Solutions:** If there are $ k $ speakers who collectively cover all thematic sessions, this corresponds to $ k $ subsets whose union is $ U $ in the Set Cover problem. Thus, Set Cover ≤P Efficient Event Staffing.\n", + "\n", + "3. **Conclusion:** Since we have shown that the Efficient Event Staffing Problem is in NP and that Set Cover (a known NP-Complete problem) can be polynomially reduced to it, we conclude that the Efficient Event Staffing Problem is NP-Complete." + ] + }, + { + "cell_type": "markdown", + "id": "5e645a2c-f307-4ab3-88a4-308c0a901225", + "metadata": {}, + "source": [ + "## Q5 \n", + "Imagine you are part of a community group, the \"Garden and Stars Collective,\" that consists of m members. Over the next m days, each member is expected to lead a community activity once, ensuring that there's a leader for each day.\n", + "\n", + "However, everyone has commitments on certain days (like yoga classes, space lectures, etc.), making the scheduling of leaders a challenging task. To structure this, let's denote the members as M ∈ {m1, ..., mm} and the days as D ∈ {d1, ..., dm}. For member mi, there is a set of days Ti ⊂ {d1, ..., dm} when they are unavailable to lead. No member can have Ti empty.\n", + "\n", + "If a member fails to lead on any of the m days, they must contribute $100 to the community fund. \n", + "\n", + "A) Frame this problem as a maximum flow problem to maximize the number of matches between the members and the days.\n", + "\n", + "**Algorithm:**\n", + "\n", + "1. Construct a graph with a source vertex s and a sink vertex t.\n", + "2. For each member mi, create a vertex xi, representing the member's availability to lead. Add an edge from the source s to xi with a capacity of 1.\n", + "3. For each day dj, create a vertex yj, indicating the need for a leader on that day. Add an edge from yj to the sink t with a capacity of 1.\n", + "4. For each member mi, let Ai be the set of days they are available to lead (the complement of Ti). For each a ∈ Ai, add an edge from xi to ya with infinite capacity.\n", + "5. Run the Ford-Fulkerson algorithm on this graph to compute the flow and then determine the minimum cut.\n", + "6. For edges (s, xi) in the cut, check with the member mi. For edges (yj, t) in the cut, assign member mi to lead on day dj.\n", + "\n", + "B) Is it always possible to match all m members with one of the m days? Justify your answer.\n", + "\n", + "**Answer:**\n", + "\n", + "The feasibility of matching all members to a day depends on the availability patterns. For instance, if all members are unavailable on a specific day, say Tuesday, it's impossible to find a leader for that day. The best solution might be to contribute $100 to the community fund for Tuesday and schedule members for other days, assuming there is at least one available member per day. \n", + "\n", + "Moreover, if the schedule requires more than 'm' days, it's unfeasible to have a leader for each of the 'm' days. Conversely, if the schedule requires at most 'm' days, then arranging a leader for each day is possible." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ba71135a-ea73-491a-8e5b-f3e30f632f5f", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.12" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/Submissions/001567668_Zihao_Liu/A4Q5.jpg b/Submissions/001567668_Zihao_Liu/A4Q5.jpg new file mode 100644 index 0000000..ab72956 Binary files /dev/null and b/Submissions/001567668_Zihao_Liu/A4Q5.jpg differ diff --git a/Submissions/001567668_Zihao_Liu/Assignment2_Readme.md b/Submissions/001567668_Zihao_Liu/Assignment2_Readme.md deleted file mode 100644 index 075bd7b..0000000 --- a/Submissions/001567668_Zihao_Liu/Assignment2_Readme.md +++ /dev/null @@ -1,19 +0,0 @@ -First Name: "Zihao" - -Last Name : "Liu" - -NU_ID : "001567668" - -## Assignment-2: - -### How ChatGPT or the tool you used assisted in this task - -Question 1, 2, 3 are regarding Heuristic Search and A*. ChatGPT gives me a Pac Man Project. It is the great example for the practice. Question 4, 5, 6 are regarding greedy algorithm. It is my first time trying to learn pseudocode. ChatGPT helped me to -Question 7, 8, 9 are regarding dynamic programming. Climbing stair, coin change, and 0-1 Knapsack Problem. - - -### Challenges you faced while ensuring the problem maintained the spirit of the example -All questions is related to the topic we've covered from Assignment 1 to last Wednesday. I have done some graph problems on Assignment 1. This time I decide to practice more regarding terminology and coding questions. The questions are hard without support. Pseudocode is another different language as well. Again, not all questions are necessarily similar to the sample question. However, it is really helpful on learning those challenging topic. - -### What you learned about problem design in the realm of algorithms -ChatGPT now is a good free "Leetcode" because it can generate a topic-specific coding question and gives a sample solution to check the answer. It is a good resource to use for supporting study. \ No newline at end of file diff --git a/Submissions/001567668_Zihao_Liu/Assignment3_Readme.md b/Submissions/001567668_Zihao_Liu/Assignment3_Readme.md deleted file mode 100644 index b49973b..0000000 --- a/Submissions/001567668_Zihao_Liu/Assignment3_Readme.md +++ /dev/null @@ -1,19 +0,0 @@ -First Name: "Zihao" - -Last Name : "Liu" - -NU_ID : "001567668" - -## Assignment-3: - -### How ChatGPT or the tool you used assisted in this task - -Question 1, 2, 3 are regarding Bellman-Ford Algorithm. Theese questions help to understand Bellman-Ford algorithm and apply them to solve problems. Question 4, 5, 8 are regarding Network Flow. ChatGPT gives me a question regarding network flows and the Max Flow-Min Cut theorem. Question 6, 7 are regarding dynamic programming. ChatGPT provides detailed explanations and comparisons of complex concepts. For example, for question 8, it explains the Push-relabel algorithm in the context of the Ford-Fulkerson method, breaking down their methodologies, efficiencies, and complexities. - -### Challenges you faced while ensuring the problem maintained the spirit of the example - -ChatGPT often gives wrong graph representation. I asked multiple time to ChatGPT, then it acknowledged the mistake, illustrating the model's capacity for error correction and iterative refinement in response to user feedback. This adaptability is crucial in collaborative tasks, especially in problem design where precision and clarity are paramount. - - -### What you learned about problem design in the realm of algorithms -In algorithm-related problems, every detail can be crucial to the problem-solving process. Ensuring that the problem statement is clear and unambiguous is important. Some of the question that ChatGPT made is completly incorrect and giving an absolutely wrong response. Identifing this issue is also hard. \ No newline at end of file diff --git a/Submissions/001567668_Zihao_Liu/Assignment4.ipynb b/Submissions/001567668_Zihao_Liu/Assignment4.ipynb new file mode 100644 index 0000000..1253600 --- /dev/null +++ b/Submissions/001567668_Zihao_Liu/Assignment4.ipynb @@ -0,0 +1,179 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "819640f9-7344-4ce9-9fc4-4fb3b0db2a35", + "metadata": { + "tags": [] + }, + "source": [ + "# Assignment 4\n", + "### Zihao Liu\n", + "### 001567668" + ] + }, + { + "cell_type": "markdown", + "id": "274a8e1f-c901-4014-9225-6f2c07ecb486", + "metadata": {}, + "source": [ + "## Q1: k-edge-disjoint cycle-cover problem\n", + "**Problem Statement:**\n", + "\n", + "Given a directed graph $ G = (V, E) $, a k-edge-disjoint cycle-cover is a set of edge-disjoint cycles such that each edge $ e \\in E $ belongs to exactly one cycle. In other words, a k-edge-disjoint cycle cover of a graph$ G $ is a set of cycles which are sub-graphs of $G$ and contain all edges of $G$ exactly once. If the cycles of the cover have no edges in common, the cover is called an edge-disjoint cycle cover.\n", + "\n", + "The edge-disjoint cycle-cover problem asks whether a given directed graph has an edge-disjoint cycle cover.\n", + "\n", + "**Problem A (10 points): Is the edge-disjoint cycle-cover problem in P? If so, prove it.**\n", + "\n", + "*Answer:*\n", + "\n", + "This question is a known NP-Hard problem, meaning that there is no known polynomial-time solution for it unless P = NP. However, there are approximate polynomial-time algorithms to solve the problem.\n", + "\n", + "Naive Approach: Consider all subsets of edges and determine if they form a cycle that covers all vertices in the graph. For a graph with a small number of edges, this is feasible. For example, in a graph with only 4 edges, consider subsets like $\\{e_1, e_2\\}, \\{e_2, e_3\\}, \\{e_1, e_2, e_3, e_4\\}$, etc. Check if these subsets form cycles that cover all vertices in the graph. Update the optimal answer accordingly, and determine the subset with the minimum number of edges that covers all vertices of the graph.\n", + "\n", + "**Problem B (5 points): Suppose we require each cycle to have at most four edges. We call this the 4-edge-cycle-cover problem. Is the 4-edge-cycle-cover problem in NP? If so, prove it.**\n", + "\n", + "*Answer:*\n", + "\n", + "The 4-Edge-Cycle Cover Problem is similar to the Edge-Cycle Cover Problem but with an additional constraint that each cycle must have a length of at most four edges. \n", + "\n", + "4-Edge-Cycle Cover is in NP: The certificate of a \"yes\" instance is the cover itself. To check if it is a valid cover, inspect each cycle to ensure it is indeed a cycle and verify that each edge is covered. This process can be done in polynomial time.\n", + "\n", + "**Problem C (10 points): Is the 4-edge-cycle-cover problem NP-complete? If so, prove it.**\n", + "\n", + "*Answer:*\n", + "\n", + "To demonstrate that the 4-Edge-Cycle Cover is NP-hard, we can reduce from a known NP-hard problem such as the Hamiltonian Cycle problem. The reduction process involves constructing a graph in such a way that a solution to the 4-Edge-Cycle Cover problem on this graph would imply a solution to the Hamiltonian Cycle problem in the original graph. \n", + "\n", + "The construction and correctness proof would be intricate but based on ensuring that each Hamiltonian cycle in the original graph corresponds to a valid 4-edge-cycle cover in the constructed graph, and vice versa. The reduction can be performed in polynomial time, thus proving the NP-hardness of the 4-Edge-Cycle Cover problem. \n", + "\n", + "Given the problem is in NP and NP-hard, it is NP-complete." + ] + }, + { + "cell_type": "markdown", + "id": "bafbc806-442f-4a0b-8a90-cfbbb2f0cddf", + "metadata": {}, + "source": [ + "## Q2: The Directed Edge-Disjoint Paths Problem\n", + "\n", + "#### Context\n", + "In graph theory, the Directed Edge-Disjoint Paths Problem involves finding paths in a directed graph such that no two paths share an edge. This problem is fundamental in network routing where paths represent communication links.\n", + "\n", + "#### Problem Statement\n", + "\n", + "Given a directed graph $ G = (V, E) $ and $ k $ pairs of nodes $ (s_1, t_1), (s_2, t_2), \\ldots, (s_k, t_k) $, the Directed Edge-Disjoint Paths Problem asks whether there exist $ k $ edge-disjoint paths $ P_1, P_2, \\ldots, P_k $ such that each path $ P_i $ connects $ s_i $ to $ t_i $ without sharing any edges with other paths. Is the Directed Edge-Disjoint Paths Problem NP-complete?\n", + "\n", + "**Answer:**\n", + "Consider the k Edge-Disjoint Shortest Paths Problem, where we are given a graph and pairs of vertices $ (s_1, t_1), \\ldots, (s_k, t_k) $. The goal is to find $k$ pairwise edge-disjoint paths $ P_1, \\ldots, P_k $ such that each path $P_i$ is a shortest path from $ s_i $to $ t_i $, if such paths exist. When the length of each edge is zero, this simplifies to the edge-disjoint paths problem.\n", + "\n", + "If we consider positive edge lengths, certain variants of the problem can be solved in polynomial time. However, the 2 Edge-Disjoint Paths Problem in directed graphs is known to be NP-hard (referencing Richard M. Karp's work on computational complexity). Therefore, the Directed Edge-Disjoint Paths Problem, even for $ k = 2 $, is NP-hard. This conclusion applies to almost all variants of the directed $k $ Edge-Disjoint Shortest Paths Problem, with only a few exceptions known to be solvable in polynomial time." + ] + }, + { + "cell_type": "markdown", + "id": "19260f89-e40c-4c66-aa3b-7118df46a5f0", + "metadata": {}, + "source": [ + "## Q3: Efficient Project Team Formation\n", + "\n", + "You are leading a project that requires a diverse set of skills (e.g., software development, project management, graphic design, data analysis, marketing, etc.). You have received applications from $ m $ potential team members. Each individual possesses a subset of the necessary skills. The challenge is: For a given number $ k \\leq m $, is it possible to assemble a project team of at most $ k $ members that collectively possess all required skills? This problem will be called the Efficient Project Team Formation.\n", + "\n", + "**Answer:**\n", + "\n", + "1. **The problem is in NP**: Given a set of $ k $ team members, we can efficiently check in linear time relative to the number of skills and $ k $ members, whether every required skill is covered by at least one team member.\n", + "\n", + "2. **Proving NP-completeness**: This problem can be shown to be NP-complete by reducing from the Set Cover problem. In the Set Cover problem, given a set $ U $ of $ n $ elements, and a collection of $ m $ subsets of $ U $ whose union equals the set of elements, the question is whether there are at most $ k $ of these subsets whose union covers all of $ U $. Given an instance of Set Cover, we can construct an instance of Efficient Project Team Formation as follows: For each element of $ U $, create a required skill. For each of the $ m $ subsets in Set Cover, create a potential team member with skills corresponding to the elements in that subset. This reduction is done in polynomial time.\n", + "\n", + "3. **Conclusion**: There exists a team of $ k $ members that collectively possess all required skills if and only if there are $ k $ subsets in the Set Cover problem whose union covers all elements of $ U $. Thus, Set Cover ≤P Efficient Project Team Formation. Therefore, Efficient Project Team Formation is an NP-Complete problem." + ] + }, + { + "cell_type": "markdown", + "id": "6cc29573-c4ef-4334-ab66-11d40a8a5efb", + "metadata": {}, + "source": [ + "## Q4: Efficient Event Staffing Problem\n", + "Consider you're coordinating a large-scale international conference that features multiple thematic sessions, such as technology, economics, culture, etc. The conference requires at least one expert for each thematic session. There have been applications from a number of potential speakers. For each thematic session, there is a subset of these applicants who are qualified to speak on that topic. The question is: For a given number $ k < m $ (where $ m $ is the number of applicants), is it possible to select at most $ k $ speakers and ensure at least one qualified speaker for each thematic session? This is known as the Efficient Event Staffing Problem.\n", + "\n", + "**Answer:**\n", + "\n", + "1. **The Problem is in NP:** Given a set of $ k $ speakers, we can easily verify in linear time relative to the number of thematic sessions and $ k $ speakers, whether each session has at least one speaker who is qualified to present on its topic.\n", + "\n", + "2. **Proving NP-Completeness through Reduction from Set Cover:**\n", + " - **Recall the Set Cover Problem:** Given a set $ U $ of $ n $ elements and a collection of $ m $ subsets of $ U $ whose union equals the set of elements, the question is whether there exist at most $ k $ of these subsets whose union equals all of $ U $.\n", + " - **Reduction to Efficient Event Staffing:** For each element of $ U $, create a thematic session. For each of the $ m $ subsets, create a speaker and assign expertise to this speaker in the sessions corresponding to the elements of this subset. This reduction is clearly polynomial in time.\n", + " - **Equivalence of Solutions:** If there are $ k $ speakers who collectively cover all thematic sessions, this corresponds to $ k $ subsets whose union is $ U $ in the Set Cover problem. Thus, Set Cover ≤P Efficient Event Staffing.\n", + "\n", + "3. **Conclusion:** Since we have shown that the Efficient Event Staffing Problem is in NP and that Set Cover (a known NP-Complete problem) can be polynomially reduced to it, we conclude that the Efficient Event Staffing Problem is NP-Complete." + ] + }, + { + "cell_type": "markdown", + "id": "5e645a2c-f307-4ab3-88a4-308c0a901225", + "metadata": {}, + "source": [ + "## Q5 \n", + "Imagine you are part of a community group, the \"Garden and Stars Collective,\" that consists of m members. Over the next m days, each member is expected to lead a community activity once, ensuring that there's a leader for each day.\n", + "\n", + "However, everyone has commitments on certain days (like yoga classes, space lectures, etc.), making the scheduling of leaders a challenging task. To structure this, let's denote the members as M ∈ {m1, ..., mm} and the days as D ∈ {d1, ..., dm}. For member mi, there is a set of days Ti ⊂ {d1, ..., dm} when they are unavailable to lead. No member can have Ti empty.\n", + "\n", + "If a member fails to lead on any of the m days, they must contribute $100 to the community fund. \n", + "\n", + "A) Frame this problem as a maximum flow problem to maximize the number of matches between the members and the days.\n", + "\n", + "**Algorithm:**\n", + "\n", + "1. Construct a graph with a source vertex s and a sink vertex t.\n", + "2. For each member mi, create a vertex xi, representing the member's availability to lead. Add an edge from the source s to xi with a capacity of 1.\n", + "3. For each day dj, create a vertex yj, indicating the need for a leader on that day. Add an edge from yj to the sink t with a capacity of 1.\n", + "4. For each member mi, let Ai be the set of days they are available to lead (the complement of Ti). For each a ∈ Ai, add an edge from xi to ya with infinite capacity.\n", + "5. Run the Ford-Fulkerson algorithm on this graph to compute the flow and then determine the minimum cut.\n", + "6. For edges (s, xi) in the cut, check with the member mi. For edges (yj, t) in the cut, assign member mi to lead on day dj.\n", + "\n", + "
\n", + "\n", + "
\n", + "\n", + "\n", + "B) Is it always possible to match all m members with one of the m days? Justify your answer.\n", + "\n", + "**Answer:**\n", + "\n", + "The feasibility of matching all members to a day depends on the availability patterns. For instance, if all members are unavailable on a specific day, say Tuesday, it's impossible to find a leader for that day. The best solution might be to contribute $100 to the community fund for Tuesday and schedule members for other days, assuming there is at least one available member per day. \n", + "\n", + "Moreover, if the schedule requires more than 'm' days, it's unfeasible to have a leader for each of the 'm' days. Conversely, if the schedule requires at most 'm' days, then arranging a leader for each day is possible." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ba71135a-ea73-491a-8e5b-f3e30f632f5f", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.12" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/Submissions/001567668_Zihao_Liu/readme.md b/Submissions/001567668_Zihao_Liu/readme.md index bb6a7d0..c97fba5 100644 --- a/Submissions/001567668_Zihao_Liu/readme.md +++ b/Submissions/001567668_Zihao_Liu/readme.md @@ -1,20 +1,19 @@ First Name: "Zihao" + Last Name : "Liu" + NU_ID : "001567668" -Assignment-1 : +## Assignment-4: ### How ChatGPT or the tool you used assisted in this task +ChatGPT's ability to understand and dissect complex problems in graph theory and computational complexity was invaluable. It provided clear explanations and step-by-step guidance, particularly in breaking down NP-completeness proofs and constructing algorithmic solutions. For problems like the Q3 and Q4, ChatGPT's suggestions on reducing them from the Set Cover problem sparked ideas for solution frameworks, showcasing its strength in identifying parallels between different computational problems. The tool's capability to create a diagram for the maximum flow problem in Q5 significantly aided in visualizing the problem structure and solution approach. -Question 1, 7, 9 are about big O notation. I created question 2, 3 regarding Stable matching. Question 4, 5, 6, 8 are graphs questions. I learned from ChatGPT on creating graph and how to use markdown language. -I want to emphasize how helpful ChatGPT is for helping me on Question 7. It is a tricky question because I was confused about part 3. The growth rate for cubic function should be faster than quadratic function but come with a conclusion that $h(n)$ is an upper bound of $h(n)$. ChatGPT gives me a deeper explanation regarding part 3 that $h(n)$ grows at least as fast as $f(n)$ but in this case it is faster. Because $h(n)$ will eventually outgrow the quadratic function for sufficiently large values of n, thus $h(n)$ can be considered as an upper bound for $f(n)$ in terms of Big O notation. This is really helpful for me to better understand the worst-case runtime of an algorithm. -WolframAlpha also helped me with generating a graph to show the relationship between 2 functions. ### Challenges you faced while ensuring the problem maintained the spirit of the example +Like Professor Brown said, this assignment is hard and really makes me struggle. On last assignment, I was trying to generate questions based on the topic we've learned but I ended up received low score for not remaining true to the original problem’s spirit. Although some times ChatGPT gives me confusion, itss responses needed refinement for accuracy or clarification. This was particularly evident in complex algorithmic reductions and proofs, where precision is crucial. -Question 1 is similar to the sample homework assignment 1 question 1 because I find out this question is helpful for me to understand the order of the functions. -Other questions are related to the topics we have covered in the past 3 weeks of lecture. However, not all of them are necessarily similar to the sample question. To ensure the problem maintained the spirit of the example, I will need to make sure to review the lecture material and create similar questions we have discussed in lecture and the Youtube video. These questions are helps me to review the topics we have covered in lecture pretty well. ### What you learned about problem design in the realm of algorithms -Designing algorithm problems and coding questions for the assignment helps me to identify the learning objective for the specific topic. Using ChatGPT for designing problem is a good way to learn new knowledge. \ No newline at end of file +The use of ChatGPT revealed the importance of interdisciplinary thinking in problem design, especially in algorithms. For example, the application of flow algorithms in Q5 showcased how algorithmic principles can be applied in varied contexts. \ No newline at end of file