代做python程序作业、代写 tree Tpython留学生作业

日期:2018-05-27 02:10

Exercise 2

We are again interested in lists of pairs of integers. However, this time, we

want to store these pairs into a rooted tree T. More precisely, each node of T

will store a pair of l. This tree T will have the property that for each inner node

k that stores a pair (a,b), the pair (c,d) stored at a node in the subtree of k

satisfies (a,b)≤(c,d). Furthermore, the pairs stored at sibling nodes must be

non-comparable.

We will suppose that the root of the tree is a dummy pair (?1,?1).

You need to provide a unit test for each question in this exercise where code

is required. Each question is evaluated on the correctness of your code and

the thoroughness of your unit tests.

Question 2.1

Define a class that stores the tree T for any given list of pairs. The __init__()

function must take a list as input and build the tree accordingly. An insert()

function must allow the insertion of a pair to an initialised tree. In O(), what is

the running time complexity of the functions you defined?

Question 2.2

In the class you have defined in Question 2.1, can there be multiple trees that

store the same list of pairs? (including after insertions?). Prove your answer.

(write your answer here).

Question 2.3

We now relax the constraint that T must be "exactly" a tree. A child node

which stores a pair (c,d) must now have as a parent all the nodes that have a

pair (a,b) such that (a,b)≤(c,d).

Design a class (it may be based on the previous one) to allow and build this

representation.

Question 2.4

Using the class written in Question 2.3, design and code an algorithm that

traverses all the nodes in that data structure and outputs the stored pairs in

sorted order (as defined in Question 1.2).

Exercise 3

You are given a tree T with an integer value (negative or positive) at each

node. We want to select a subtree of T (with the same root) that maximises

the sum of the values at its nodes. Note that the answer is trivially T if all

nodes have a non-negative value.

Question 3.1

Define a data structure to store T

Question 3.2

Design and code a dynamic programming algorithm that solves this problem.

Question 3.3

Write and run unit tests and performance tests.

python代写学生作业_代做python程序作业、代写 tree Tpython留学生作业相关推荐

  1. python垃圾回收 循环引用_在做 Python 循环引用垃圾回收实验中的一个小问题, Python3 的 print 是线程安全的吗?...

    以前都听说 Python 循环引用会导致引用数无法清零,所以不能垃圾回收,会内存泄漏,需要删除引用关系或者用 gc.collect()才能进行正常垃圾回收. 但做了下实验,好像还是会自动回收循环引用的 ...

  2. python字典输入学生信息_如何用Python将XML中的所有信息输入字典

    我通常使用标准库中的ElementTree模块解析XML. 它没有给你一个字典,你得到了一个更有用的DOM结构,它允许你为孩子们遍历每个元素.from xml.etree import Element ...

  3. python成为金融编程_想做金融矿工,会写Python和C++就够了吗?

    "对 Quant 而言 Python 的需求高吗,除 C++ 外还有哪些流行的编程语言?">>更多FRM 相关问题点我咨询 1. 高 2. 还有:Python, Jav ...

  4. 计算机编程导论python程序设计答案-学堂在线_计算机科学与Python编程导论_作业课后答案...

    学堂在线_计算机科学与Python编程导论_作业课后答案 答案: 更多相关问题 近代中国完全沦为半殖民地半封建社会的标志是:A.<马关条约>B.<辛丑条约>C.<凡尔赛和 ...

  5. python write 写多行_如何用 Python 执行单行命令

    一般来说,面对日常处理的一些小任务,直接用 sed,grep 之类的就可以搞定,更复杂一点的就会考虑 awk 或者用一些现成的轮子,要是 awk 搞不定我就只好用 Python 了.但有些时候,我仅仅 ...

  6. python与会计的论文_甭管前浪后浪,写完论文的先浪!

    原标题:甭管前浪后浪,写完论文的先浪! 自愿返校已是板上钉钉的事儿了 而对于大家的期末考 现在也基本上已经通知线上考试 如果没有线上考试的话,那就是交论文 可是,论文动不动就2000字10%查重 毛概 ...

  7. 计算机编程导论python程序设计答案-学堂云_计算机科学与Python编程导论_作业课后答案...

    学堂云_计算机科学与Python编程导论_作业课后答案 答案: 更多相关问题 保本基金参与股指期货交易,应当根据风险管理的原则,以套期保值为目的.() 基金经理主要依据股票投资价值报告来决定实际的投资 ...

  8. 基于python的毕设难吗_毕设做个小程序 毕业设计做小程序难吗

    打算用Python做毕业设计,可以做哪些方面的? Python做毕业设计,我想谈谈我的看法,供大家参考: 1.Python web前端.您可以使用python开发网站. 2.Python网络爬虫.您可 ...

  9. python是商业组织吗_可以用Python做什么?

    **从入门级选手到专业级选手都在做的--爬虫 ** 用 Python 写爬虫的教程网上一抓一大把,据我所知很多初学 Python 的人都是使用它编写爬虫程序.小到抓取一个小黄图网站,大到一个互联网公司 ...

最新文章

  1. mysql乐观锁总结和实践
  2. 纳微科技完成近亿元融资,华兴医疗产业基金独家投资
  3. sql挂起小工具cleanup_SQL注入的攻防策略
  4. swiper默认选中_Swiper
  5. java中redis原理_Redis字符串键的底层原理
  6. 第十一节:WebApi的版本管理的几种方式
  7. 【问题汇总】Ubuntu使用常见问题
  8. Chapter 3 - 作用域
  9. Java编程语言的重要性
  10. discuz内置代码
  11. Datawhale组队学习(Pandas) task8-文本数据
  12. 搜狐狐友通过增加知名度增加用户量
  13. 支持P2P传输的M3U8播放器
  14. UWP 手绘视频创作工具技术分享系列 - 文字的解析和绘制
  15. Java 开发工程师的核心竞争力
  16. 使用git 提交本地文件夹及文件
  17. 机器学习(ML)中文视频教程
  18. 5G NR带宽 频点
  19. 银行应构建主动式客户体验管理体系,助力客户价值增长
  20. RTSP服务器(二)

热门文章

  1. 关于河南xx公司对工作流引擎,表单引擎 jflow问题汇总以及相应的问题解决办法
  2. SpringBoot中使用@PropertySource的问题
  3. HDMI,VGA,DVI,DP,MINI DP,AV等影音设备接口规参数
  4. 运维手册——Mysql索引字段长度太长报错
  5. 有你不知道的:键盘上每个键作用 (很全)
  6. 在外包公司熬了 3 年终于进了华为测试岗,竭尽全力终有获
  7. hal编程 gt911 触摸芯片驱动 ( 枚举 结构体 熟用)( 安富莱 f429 4.3寸电容屏 )
  8. Notepad++快捷键(快速选中一行等)
  9. JavaScript算法——插入排序
  10. JS解决迷宫老鼠算法