Chat with us, powered by LiveChat Florida State College at Jacksonville Artificial Intelligence Python Project | Credence Writers
+1(978)310-4246 [email protected]

Description

Page
1
>
of 3
ZOOM
+
1. Given a matrix of Os and 1s that represent the state space of a search problem, we have a starting row
and column given by a tuple (starting_row, starting_column), and a target row and column (target_row,
target_column). Implement an algorithm that outputs the length of the shortest path from (starting_row,
starting_column) to (target_row, target_column) where the path contains only 1 values along the way.
Note that each location in the path (including the start and target), must be a 1.
Each subsequent location in the path must be a 4-directionally adjacent to the previous (north, south,
east, west).
If the task is not possible, the algorithm should return -1.
Examples:
input:
matrix = [[1, 1, 1, 1], [0, 0, 0, 1],[1, 1, 1, 1]] # list of lists in python
=
starting_row = 0, starting_column = 0, target_row = 2, target_column = 0
output: 8
(The lines below represent this matrix:)
1111
0001
1111
matrix = [[1, 1, 1, 1], [0, 0, 0, 1), (1, 0, 1, 1]]
=
starting_row = 0, starting_column = 0, target_row = 2, target_column = 0
=
=
=
output: -1
(The lines below represent this grid:)
1111
0001
1011
2. Tesla organizes their distribution system as a non-binary tree. The root of such tree is the source
distributor, and every node in the tree represents another Tesla distributor that receives cars from the
parent node and sends them to its children’s nodes. The leaves of the tree are the final dealers that sell
cars to customers. Further, every node holds an integer representing the cost associated of shipping a car
to it.
Tesla would like to compute the minimum cost in its distribution tree. Given a rootNode, write a program
getMinimumCost that computes the minimum route’s cost in the tree. For example, given the root node
of the tree above, your program should return 7 since it is the minimal route (we have two minimal cost
paths: 0?6+1,0-3+2+1+1).
Use the following code to build the nodes of the tree.
# A node
class Node:
# Constructor to create a new node
def __init__(self, cost):
5
self.cost = cost
=
10
self.children = []
=
self.parent = None
Page <
3
of 3
ZOOM
+
3. Given the root of a binary tree, using DFS, return the tree’s nodes as if you were doing the following:
3.1 get all the leaf nodes
3.2 remove all leaf nodes
3.3 repeat previous two steps until the tree is empty.
Example:
more
Input: root = (1,2,3,4,5)
Output: [[4,5,3], [2], [1]]
[[3,5,4), [2],[1]] and [[3,4,5),[2],[1]] are also considered correct answers it does not matter the order on
which elements are returned.
Use the following Definition for a binary tree node.
class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
=
4. In 1895, G. Tarry gave the following rule for traversing a maze. Do not return along the passage which
has led to a junction for the first time unless you cannot do otherwise. Explain the connection between
Tarry’s rule and the depth-first search algorithm.
Extra-credit:
5. Prove by contradiction that BFS computes the shortest path starting from a given source vertex s. Feel
free to introduce suitable notation for the proof. You are free to switch this question with any of the
previous questions and submit this instead.
Deliverables:
1. Upload a zip file to canvas with your name as the file’s name. For example, if your name is John
Doe, the file should be named john_doe.zip. Include a README file with your name, panther id,
and explaining which questions you answered and anything you think we should know to better
evaluate and grade your work. Do not let us guess or assume anything about your work.
2. For the python programming questions, you should include .py files or Jupyter notebooks,
documenting your code accordingly, and showing the output of your programs for the examples
provided and with other tests that you create.
3. For the non-programming questions, you are free to type the answers using Microsoft words, or
LaTeX. However, please include only a .pdf file for us to read and grade.

Purchase answer to see full
attachment