Written Assignment Guidelines
Written Assignment Guidelines
项目类别:计算机
Written Assignment Guidelines
·Assignments should be typed and submitted as pdf (no pdf containing text as images, no handwriting).
.Start by typing your student ID at the top of the first page of your submis- sion. Do not type your name.
.Submit only your answers to the questions. Do not copy the questions..When asked to give a plain English description, describe your algorithm as you would to a friend over the phone, such that you completely and unambiguously describe your algorithm, including all the important (i.e., non-trivial) details. It often helps to give a very short (1-2 sentence) de- scription of the overall idea, then to describe each step in detail. At the end you can also include pseudocode, but this is optional.
.In particular, when designing an algorithm or data structure, it might help you (and us) if you briefly describe your general idea, and after that you might want to develop and elaborate on details. If we don't see/under- stand your general idea, we cannot give you marks for it.
.Be careful with giving multiple or alternative answers. If you give multiple answers, then we will give you marks only for "your worst answer", as this indicates how well you understood the question.
. Some of the questions are very easy (with the help of the slides or book). You can use the material presented in the lecture or book without proving it. You do not need to write more than necessary (see comment above)..When giving answers to questions, always prove/explain/motivate your answers.
.When giving an algorithm as an answer, the algorithm does not have to be given as (pseudo-)code.
.If you do give (pseudo-)code, then you still have to explain your code and your ideas in plain English.
. Unless otherwise stated, we always ask about worst-case analysis, worst- case running times, etc.
. As done in the lecture, and as it is typical for an algorithms course, we are interested in the most efficient algorithms and data structures, though slower solutions may receive partial marks.

.If you use further resources (books, scientific papers, the internet,...) to formulate your answers, then add references to your sources and explain it in your own words. Only citing a source doesn't show your understanding and will thus get you very few (if any) marks. Copying from any source without reference is considered plagiarism.

This assignment is due on September 22 and should be submitted on Grade- scope. All submitted work must be done individually without consulting someone else's solutions in accordance with the University's “Academic Dishonesty and Plagiarism" policies.
Before you read any further, go to the last page of this document and read the Written Assignment Guidelines section.
Problem 1. (10 points) In this question we're going to analyse a response gener- ated by an AI, in this case ChatGPT. It was asked to design an algorithm for the following problem that runs in O(n²logn) (expected) time, argue its correctness, and analyse its running time.
Problem Description: You and your best friend just got out of the movies and are very hungry; unfortunately, it is now very late at night and all restaurants are closed. You manage to find, by chance, some vending machine still full of very... nutritious foods (bags of chips, and the occasional cereal bar). Looking into your pockets, you look what change you have, in order to try and buy something (anything!) to eat.
You have n coins of various values. So does your friend! As for the vending machine... it contains n different "food items" each with its own price.Looks like you may eat tonight... except for two things:
· the vending machine is old and somewhat broken: it only accepts at most two coins, and does not return change: you must put exactly the right price to get the item you ask for.
. out of fairness, you and your friend refuse to pay for the whole thing alone. So each of you has to contribute (no matter how little): to buy the food, each of you has to contribute at least one coin.
Which means that, if you want to eat tonight, you must figure out if there is an item in the vending machine whose price is exactly equal to the sum of two coins, one from you and one from your friend. And you are very hungry, so you want to figure that out fast.
Your task: given three arrays Y, F, and V (You, Friend, Vending machine) each containing n positive integers, decide if there exist 0 ≤ i,j,k < n such that Y[i] + F[j] = V[k]. You can assume that all integers in all arrays are distinct (also between different arrays). Since you want to eat soon, you want an algorithm for this task which solves your problem fast: running in (expected) time O(n²logn).
Example:
Y =[3,2,1], F =[4,5,6], V =[50,8,13].
We need to return true, since Y[1] + F[2] = V[1] (i.e., 2 + 6+8).
For the same Y and F, but with V =[50, 2123, 9123], we'd return false, as there are no i, j, and k such that Y[i] +F[j] = V[k]. AI Output:
Algorithm Description:

留学ICU™️ 留学生辅助指导品牌
在线客服 7*24 全天为您提供咨询服务
咨询电话(全球): +86 17530857517
客服QQ:2405269519
微信咨询:zz-x2580
关于我们
微信订阅号
© 2012-2021 ABC网站 站点地图:Google Sitemap | 服务条款 | 隐私政策
提示:ABC网站所开展服务及提供的文稿基于客户所提供资料,客户可用于研究目的等方面,本机构不鼓励、不提倡任何学术欺诈行为。