首页 > > 详细

辅导Coding Refresher、Python编程语言调试、Java,c++讲解、辅导zero matrix 辅导Web开发|讲解R语言编程

Homework 1 - Coding Refresher
Due Friday September 13th
1 Matrix mortality, obtaining the zero matrix
Definition: The mortal matrix problem is the problem of determining, given a finite set of n x n matrices
with integer entries, whether they can be multiplied in some order, possibly with repetition, to yield the
zero matrix.
Given the above definition, develop a program that determines if a pair of given input matrices are a mortal
pair. Your program should be capable of accepting any pair of n x n matrices and should return true if
the pair of matrices are a mortal pair. DO NOT hard-code these two matrices for your solution.
You can test your program using the following two matrices.
A = [2 -2; 2 2] and B = [0 0; 0 1]
2 Matrix mortality, coding complications
Consider the consequences of a user inputting a set of non-mortal matrices; such as two 3x3 filled with 1s.
For this pair, it is obvious they are non-mortal; however, other sets are not as obvious. No need to look
into formal proofs.
1. Build a safeguard into your program that does not allow the program to run longer than 5 minutes.
2. Explain why a safeguard like this is important for a problem such as this. Consider computability
and potential programming issues.
3 Working with data sets
Download the smart card data.csv from the bCourses website.
This file contains the metro smart card transaction data collected in a Chinese city for the duration of one
day. The columns are Time In, Time Out, Card Id, Fare, StationId In and StationId Out. Every entry
represents 1 metro trip.
Time In and Time Out is the time the person enter and exit the train. They are in local time. Card Id is
the ID of the smart card. StationId In and StationId Out is the station ID of entry and exit station.
Assumptions to make:
1. No delays occurred along the track on the day this data was collected.
2. There is no need to transfer trains.
3. Employees of the metro have free travel.
1
Using the metro data, answer the following questions:
1. Determine how many employee trips were taken on this day. Attempt this question using a for loop
and a built in search algorithm. Compare computation time and discuss why one may be faster than
the other.
2. On average, is the commute from home to work, or work to home longer? You may assume a ”work
day” of 6 hours or longer. You may ignore any card ID used more than 3 times in a day.
3. Determine the average travel time between train stations. Create a matrix with rows as station out
and columns as station in. Which stations appear the farthest apart? Which stations appear the
closest?
Submission Guidelines
These guidelines will continue throughout the semester
1. If there are theoretical portions of the question, unless otherwise stated, submit your answers as
comments within your code.
2. Typically, one file shall be submitted per problem. In this assignment, problem 1 and 2 can be
combined into one file named matrixMortality.
3. When multiple files are being submitted, submit as a zipped file with the naming format lastnameFirstname.
4. Submit the zipped file on bcourses by the due date at 11:59 pm PST.
2

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!