Computer Science 220S1C (2019)

Computer Science 220S1C (2019)
Assignment 4 (traversal and optimisation)
Due date June 7, 2019, 10pm
100 Marks in total
This assignment requires you to submit programs in Python that you have written yourself
to the automarker, http://www.cs.auckland.ac.nz/automated-marker. Your implementation
must be from first principles and cannot use an existing library methods that
might solve the problem (eg graph search algorithms etc). You can use libraries for standard
implementations of data structures such as queues, stacks and priority queues.
The automarker uses the PyPy compiler on a Linux box. Read the automarker help and
FAQ for more details.
Please submit only Python source code.
1. Arithmetic trees 50 marks
You are given an input file with multiple pairs of input lines. The first line of each
pair is a tree given as a predecessor array. The second line is the value at the
corresponding node. Values at leaf nodes (nodes with no children) are integers. At
non-leaf nodes, the two possible values are + or ?.
The tree represents an arithmetic expression where the value at a non-leaf node u is
the sum of values at the children of u in the case of +, or the product of values at
the children of u in the case of ?.

代写220S1C留学生作业、代做Python编程设计作业、programs作业代做、代写Python实验作业
You need to calculate the value at each node and output the calculated value at the
root. The tree is not constrained to be binary.
Input format: Input consists of m pairs of lines of comma separated values, so
2m lines in total. The first line is each pair is a comma separated list of integers
representing a tree in predecessor array format where ?1 represents null.
The second line in each pair is a comma separated list of integers and the symbols +and . The ith item on the list is the value or operator at the ith node in the tree.
For example:
Output format: For each pair of input lines, output a line containing the value
calculated at the root of the tree.
For the example input above, output would be:
1
2. Optimisation 50 Marks
Suppose you are flying a drone that can fly exactly 100 km before needing a battery
recharge. Recharging is only possible at towns for which you are given locations.
Your aim is to find the length of the shortest possible path to get the drone from an
origin town to a destination town given the range restriction.
Assume that the landscape is a n × n two dimensional square (units are km) with
coordinates for towns described by (x, y) where 0 <= x, y <= n. Use Euclidean
distance to calculate the distance between towns.
Input format: You are given multiple lines of input. Each line has 2k + 1 comma
separated numbers where k ≥ 2. The first number in each line is the size of the
landscape, n.
The following 2k numbers locations of k towns so that that the ith town is located
at (2i, 2i + 1).
In each line the first town listed is the origin, the final town listed in the destination.
For example:
100,0,0,0,100,100,100
1000,20.892,986,602,138.97,206.2,10.44
200,25,25,10,1,50,25,140,30
Output format: For each line of input, output a single number which is the length
of the shortest path from the origin town to the desitination town. Use str.format to
give this value to 2 decimal places. Precisely, format x using ’{:.2f}’.format(x).
Do not use any other rounding throughout your algorithm. If the destination town
is unreachable from the origin, output -1.
For the example input above, output would be:
The maximum number of submissions for each problem is fixed at 10.
Each problem has five test cases associated with it worth one fifth of the marks for
that problem. Some of the test cases will be large to test for speed. You get full
marks if you pass all test cases.

因为专业,所以值得信赖。如有需要,请加QQ:99515681 或邮箱:[email protected]

微信:codinghelp

原文地址:https://www.cnblogs.com/sabd/p/10986535.html

时间: 2024-11-01 02:09:03

Computer Science 220S1C (2019)的相关文章

Computer Science 320 S2

Computer Science 320 S2 (2019)Assignment 4Due date Sep 28, 2019 23:59pmAnswer all of the following questions. There are 10 points, which contribute 5% of your total coursemarks. Submit a properly typesetted pdf file (LATEX preferred) of your answers

CSCI 1100 Computer Science

CSCI 1100 — Computer Science 1 Homework 8Bears, Berries and Tourists Redux: ClassesOverviewThis homework is worth 100 points toward your overall homework grade, and is due Wednesday,December 11, 2019 at 11:59:59 pm. It has three parts. The first two

Computer Science Theory for the Information Age-5: 学习理论——VC维的定义以及一些例子

学习理论--VC维的定义以及一些例子 本文主要介绍一些学习理论上的东西.首先,我们得明确,从训练集上学习出来的分类器的最终目标是用于预测未知的样本,那么我们在训练的时候该用多少的样本才能使产生的分类器的效果尽可能的好呢?这些就是VC-理论要解决的问题.在介绍这个理论之前,我们得先介绍一个比较抽象的概念--VC维.这个指标是用与衡量假设空间的复杂程度.为了能更好的理解VC维,本文还会举一些例子来加深理解. (一)由一个例子引出的动机 为了更好的说明为什么我们要定义这个VC维,我们先来看一个例子.假

Discovering the Computer Science Behind Postgres Indexes

This is the last in a series of Postgres posts that Pat Shaughnessy wrote based on his presentation at the Barcelona Ruby Conference. You can also watch the video recording of the presentation. The series was originally published on his personal blog

Computer Science Theory for the Information Age-6: 学习理论——VC定理的证明

VC定理的证明 本文讨论VC理论的证明,其主要内容就是证明VC理论的两个定理,所以内容非常的枯燥,但对于充实一下自己的理论知识也是有帮助的.另外,VC理论属于比较难也比较抽象的知识,所以我总结的这些证明难免会有一些错误,希望各位能够帮我指出. (一)简单版本的VC理论. 给定一个集合系统$(U,\mathcal{S})$,VC理论可以解决以下问题.对于一个在$U$上的分布$P$,那么至少需要选择多少个样本(根据分布$P$选择),才能使对每个$S\in\mathcal{S}$,用样本估计出来的值以

MIT Introduction to Computer Science and Programming (Lesson one )

MIT Introduction to Computer Science and Programming (Lesson one ) 这篇文是记载 MIT 计算机科学及编程导论 第一集 的笔记 Lesson one : Goals of the course;what is computation;introduction to data types,operators,and variables 一 讲解课程的任务.课程目标 目标 像一个计算机科学家一样思考 都能够读写程序 tacking t

Note 2 for &lt;Pratical Programming : An Introduction to Computer Science Using Python 3&gt;

Book Imformation : <Pratical Programming : An Introduction to Computer Science Using Python 3> 2nd Edtion Author : Paul Gries,Jennifer Campbell,Jason Montojo Page : Chapter 2.3 to Chapter 2.5 1.A type consists of two things: (1).a set of values (2).

Side effect (computer science)

In computer science, a function or expression is said to have a side effect if it modifies some state outside its scope or has an observable interaction with its calling functions or the outside world besides returning a value. For example, a particu

How do you explain Machine Learning and Data Mining to non Computer Science people?

How do you explain Machine Learning and Data Mining to non Computer Science people? Pararth Shah, ML Enthusiast Answered Dec 22, 2012 · Featured on VentureBeat · Upvoted by Melissa Dalis, CS & Math major at Duke and Alberto Bietti, PhD student in mac