REQUIREMENTS: 1 Using Python, you will write a program called dfs-stack.py that implements Algorithm 2.3 (p. 49): Graph depth-first search (DFS) with a stack. 2. You will not use an adjacency list, as indicated in Algorithm 2.3. Instead, you will use an adjacency matrix (i.e., a two-dimensional array, or, in Python, a list of lists). 3. You may use ANY list method you wish (e.g., append, pop, etc.). IMPLEMENTATION DETAILS: 1. Based upon the REQUIREMENTS above, along with the IMPLEMENTATION DETAILS (i.e., this section), you MUST first develop an algorithmic solution using pseudocode. This includes both your logic (in pseudocode) and the logic presented in the pseudocode indicated in Algorithm 2.3. 2. Be sure to include your name, along with the Certificate of Authenticity, as comments at the very beginning of your Python code. Also, if you collaborated with others, be sure to state their names as well. 3. Your program should begin by prompting the user for the number of vertices, V, in the graph, G. 4. Your program will represent the graph G using an adjacency matrix, which is a square matrix with a row and a column for each vertex. Thus, your program will need to create a matrix M that consists of a VxVtwo-dimensional array -- in Python, a list of lists. (I recommend that your program initialize each element of the matrix equal to zero.) 5. 6. 7. 8. 9. Next, your program should prompt the user to indicate which elements in the matrix should be assigned the value of 1 (i.e., information about vertices). Recall that each element in the matrix is the intersection of a row and a column. The result of steps 3, 4, and 5 should be an adjacency matrix representation of a graph, G. At this point, your program should print the newly-created adjacency matrix on the screen. Next, your program should prompt the user to specify node -- i.e., the starting vertex in G. From here, you then proceed with the implementation of Algorithm 2.3, with the following enhancements: Be sure to use the newly-created adjacency matrix, instead of an adjacency list. Immediately following line 5 (but before line 6) of Algorithm 2.3, your program should print the values currently on the stack. At the end of the while block, your program should print the values currently on the stack. In effect, the result of step 9 above should be a display of the stack evolution for your implementation of the DFS algorithm on graph G.
REQUIREMENTS: 1 Using Python, you will write a program called dfs-stack.py that implements Algorithm 2.3 (p. 49): Graph depth-first search (DFS) with a stack. 2. You will not use an adjacency list, as indicated in Algorithm 2.3. Instead, you will use an adjacency matrix (i.e., a two-dimensional array, or, in Python, a list of lists). 3. You may use ANY list method you wish (e.g., append, pop, etc.). IMPLEMENTATION DETAILS: 1. Based upon the REQUIREMENTS above, along with the IMPLEMENTATION DETAILS (i.e., this section), you MUST first develop an algorithmic solution using pseudocode. This includes both your logic (in pseudocode) and the logic presented in the pseudocode indicated in Algorithm 2.3. 2. Be sure to include your name, along with the Certificate of Authenticity, as comments at the very beginning of your Python code. Also, if you collaborated with others, be sure to state their names as well. 3. Your program should begin by prompting the user for the number of vertices, V, in the graph, G. 4. Your program will represent the graph G using an adjacency matrix, which is a square matrix with a row and a column for each vertex. Thus, your program will need to create a matrix M that consists of a VxVtwo-dimensional array -- in Python, a list of lists. (I recommend that your program initialize each element of the matrix equal to zero.) 5. 6. 7. 8. 9. Next, your program should prompt the user to indicate which elements in the matrix should be assigned the value of 1 (i.e., information about vertices). Recall that each element in the matrix is the intersection of a row and a column. The result of steps 3, 4, and 5 should be an adjacency matrix representation of a graph, G. At this point, your program should print the newly-created adjacency matrix on the screen. Next, your program should prompt the user to specify node -- i.e., the starting vertex in G. From here, you then proceed with the implementation of Algorithm 2.3, with the following enhancements: Be sure to use the newly-created adjacency matrix, instead of an adjacency list. Immediately following line 5 (but before line 6) of Algorithm 2.3, your program should print the values currently on the stack. At the end of the while block, your program should print the values currently on the stack. In effect, the result of step 9 above should be a display of the stack evolution for your implementation of the DFS algorithm on graph G.
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 4 images
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY