CSC263H Data Structures and Analysis 2024 Homework #2R

「文智助手」全场景办公AI助理AI+OPC全流程实践方案(大赛作品) 阅读详情

Java Python Computer Science CSC263H

September 11, 2024

Homework Assignment #2

Due: September 25, 2024, by 11:00 am

• You must submit your assignment through the  Crowdmark system. You will receive by email an invitation through which you can submit your work. If you haven’t used Crowdmark before, give yourself plenty of time to figure it out!

• You must submit a separate PDF document with for each question of the assignment.

• To work with one or two partners, you and your partner(s) must form a group on Crowdmark (one submission only per group).  We allow groups of up  to  three students.  Submissions by groups of more than three students will not be graded.

• The PDF file that you submit for each question must be typeset (not handwritten) and clearly legible. To this end, we encourage you to learn and use the LATEX typesetting system, which is designed to produce high-quality documents that contain mathematical notation. You can use other typesetting systems if you prefer, but handwritten documents are not accepted.

• If this assignment is submitted by a group of two or three students, for each assignment question the PDF file that you submit should contain:

1. The name(s) of the student(s) who wrote the solution to this question, and

2. The name(s) of the student(s) who read this solution to verify its clarity and correctness.

• By virtue of submitting this assignment you (and your partners, if you have any) acknowledge that you are aware of the homework collaboration policy for this course, as stated here .

•  For any question, you may use data structures and algorithms previously described in class, or in prerequisites of this course, without describing them. You may also use any result that we covered in class (in lectures or tutorials) by referring to it.

• Unless we explicitly state otherwise, you should justify your answers. Your paper willbe marked based on the correctness and efficiency of your answers, and the clarity, precision, and conciseness of your presentation.

• The total length of your pdf submission should be no more than 3 pages long in a 11pt font.

Question 1. (20 marks)   Let H be a binomial heap that intially contains n keys (i.e.,  |H| = n).  In this question, you will determine the “amortized” (i.e., average) cost of successively inserting k keys into H.

a. Recall that α(n) is the number of 1’s in the binary representation of n.  Prove that binomial heap H has exactly n - α(n) edges.

Hint:  See Appendix B.5 about trees in our CLRS textbook.

b. We define the worst-case cost of inserting a new key into H to be the maximum  number  of pairwise comparisons  between keys that is required to do this insertion.

Consider the worst-case total cost of successively inserting k keys into H.  It is clear that for k = 1 (i.e., in-serting only one key) the worst-case cost is O(log2 n).  Show that when k > log2 n, the average cost of an in-sertion,i.e., the worst-case total cost of the k successive insertions divided by k, is bounded above by constant.

Hint:  Relate the cost of an insertion with the number of edges that it creates and use Part a.

Question 2. (20 marks) Part I.

In the following, H denotes a binomial max heap, n is the number of items in H , x is (a pointer to the node of) an item inside H, and k is a number (key).

a. Describe a simple  algorithm to  increase  the key of a given  item x in a binomial max heap H to

become k. Your algorithm should not change anything if k ≤ x.key.

The worst-case running-time of your algorithm must be O(log n).  Give a high-level description of your algorithm in clear English.

b. Using part  (a), describe a  simple  algorithm to  delete  a given item x from a binomial max heap H. The worst-case running-time of your algorithm must be O(log n).  Give a high-level description of your algorithm in clear English.

Part II.

Your task here is to design a data structure called  Ultra-Heap that supports the following operations:

• Insert(k): inserts the key k into the Ultra-Heap,

• ExtractMax(): removes a max key from the Ultra-Heap,

• ExtractMin(): removes a min key from the Ultra-Heap,

• Merge(D ,D′ ): merges Ultra-Heaps D and D′ into one Ultra-Heap.

The worst-case running-time of each operation must be O(log n) where n is the total number of items.

c. Describe your Ultra-Heap data structure in clear English.  Your description should include any new information that you add to existing data structures that you use.

d. Explain how you implement each operation of Ultra-Heap in clear English. Hint: Use binomial heaps and your solution to Part I.

Question 3. (20 marks)   Give a linear-time algorithm that determines if a Binary Search Tree (BST) is an AVL tree (i.e., whether it satisfies the balance property of an AVL tree).

The algorithm’s input is a pointer u to the root of a BST T where each node v has the following fields:  an integer key, and pointers parent, lchild and rchild to the parent, the left and right children of v in T (any unused pointer is set to Nil).  The algorithm’s output should be True if T is an AVL tree, and False otherwise.

The worst-case running time of your algorithm must be Θ(n) where n is the number of nodes in T.    Describe your algorithm by giving its pseudo-code. Explain why its worst-case running time is Θ(n). Your algorithm will be graded by its correctness, running time,  simplicity, and clarity.

[The questions below will not be corrected/graded.  They are given here as interesting problems that use material that you learned in class.]

Question 4. (0 marks)

In the following, B1  and B2  are two binary search trees such that every key in B1  is smaller than every key in B2 .

Describe an algorithm that, given pointers b1  and b2  to the roots of B1  and B2, merges B1  and B2  into a single binary search tree T. Your algorithm should satisfy the following two properties:

1. Its worst–case running time is O(min{h1 , h2 }), where h1  and h2  are the heights of B1  and B2 .

2.  The height of the merged tree T is at most max{h1 , h2 } + 1.

Note that the heights h1  and h2  are not given to the algorithm  (in other words, the algorithm does not “know” the heights of B1  and B2).  Note also that B1 , B2  and T are not required to be balanced.

Describe your algorithm, and justify its correctness and worst-case running time, in clear and concise English.

Hint: First derive an algorithm that runs in O(max{h1 , h2 }) time, and then optimize it.

Question 5. (0 marks)

A path between two nodes u,v in a Binary Search Tree (BST), is a sequence of distinct edges connecting a sequence of adjacent nodes in this tree, where the starting node in the sequence is u and the ending node is v; the length of a path is the number of edges in that path. Two distinct nodes u,v are said to adjacent if either u is the parent of v or v is the parent of u.

For example, the figure below shows the path between 15 and 45 (length 3), the path between 7 and 20 (length 3), and the path between 47 and 50 (length 1) in a BST.

In this question, you must derive an algorithm that, given any two keys in a BST, computes the lenght of the path between these two keys in the tree. To do so, solve the three subquestions outlined below.

Henceforth assume that root is not nil and the BST rooted at root does not have duplicate keys.  Morever, each node u of the BST has the following fields:  key(u),  containing the key of the node, lchild(u) and rchild(u), containing pointers to u’s left and right children respectively; note that node u does not have a pointer to its parent. For a key k in the BST, let node(k) be the BST node with key k.

For each of the following subquestions, first describe your algorithm in clear and concise English, and then give the pseudocode.  Then give a brief explanation of why your algorithm achieves the worst-case time complexity specified in that subquestion (where h is the height of the BST rooted at root).

a. Give an efficient algorithm for the following procedure.

PathLengthFromRoot(root,k):    Given the root of a BST and a key k, return the length of the path between root and node(k). Assume that the key k is in the BST.

For example, if root is the root of the BST in Figure  1, then PathLengthFromRoot(root, 15) should return 2, and PathLengthFromRoot(root, 47) should return 3.

The worst-case time complexity of your algorithm should be O(h).

b. Given the root of a BST and two distinct keys k,m present in the BST, define the FCP of k  and m in the BST rooted at root, to be the root of the subtree that is furthest away from root which contains both k and m.  In other words, the FCP of k and m is a node parent such that:  (a) the subtree rooted at parent has both the keys k and m in it, and (b) the length of the path between root and parent is the maximum among all such parents. Give an efficient algorithm for the following procedure.

FCP(root,k, m):     Given the root of a BST and two distinct keys k and m, return the FCP of k and m in the BST rooted at root. Assume that both k and m are present in the BST.

For example, if root is the root of the BST in Figure 1, then FCP(root, 15, 45) should return the node with key 30, FCP(root, 7, 20) should return the node with key 10, and FCP(root, 50, 47) should return the node with key 50.

The worst-case time complexity of your algorithm should be O(h).

c. Give an efficient algorithm for the following procedure.

PathLength(root,k, m):     Given the root  of a BST, and two distinct keys k and m, return the length of the path between node(k) and node(m). Assume that the keys k and m are present in the BST.

For example, if root is the root of the BST in Figure 1, then PathLength(root, 15, 45) should return 3, and PathLength(root, 50, 47) should return 1.

The worst-case time complexity of your algorithm should be O(h). Hint: Use the procedures from Parts a and b         

船载 OpenHarmony AIS 航海工作台:告警与防碰撞预警系统 船载OpenHarmony AIS航海工作台的告警与防碰撞系统,集成十余类告警(超速、偏航、会遇、SOS等),通过网格空间索引实现高效邻近判定,保障实时性。告警管理器统一调度规则、去重、通知与日志,支持悬浮球、语音、跑马灯、弹窗多渠道触达,确保航行安全。SOS紧急通道独立运行,避免干扰。系统设计强调性能优化与多场景适配,为航海安全提供核心支撑。 阅读详情

相关推荐

AI 应用开发:四维架构落地实战——以 HR Agent 为例拆解感知·推理·记忆·执行【意图路由、规划编排、长期记忆、工具执行、面试题】

本文基于四维架构(感知·推理·记忆·执行),以HR Agent为例,系统拆解大模型应用从“聊天”到“生产可用”的落地路径。通过Spring AI实现意图路由、规划编排、RAG检索与工具调用,结合真实踩坑复盘,揭示架构化设计对安全、成本与可维护性的关键价值,为AI Agent工程化提供可复用的实战框架。

王大师企业官方博客 1320

Fill in the Blanks: Using Math to Turn Lo-Res Datasets Into Hi-Res Samples

Using a mathematical concept called sparsity, the compressed-sensing algorithm takes lo-res files and transforms them into sharp images. Illustration: Gabriel Peyre In the early spring of 2009

991的专栏 1252

Mac用户看过来!M1/M2芯片安装CiteSpace完整指南(从Homebrew到成功运行)

本文为Mac M1/M2芯片用户提供CiteSpace安装的完整指南,从Homebrew安装适配的Java环境到最终成功运行CiteSpace。详细步骤包括环境检查、Java配置、CiteSpace下载与优化,解决常见问题如内存分配、图形渲染和中文显示乱码,确保科研人员能顺利使用这一文献可视化工具。

weixin_42530458的博客 308

EMC 2011 校园招聘 笔试题

EMC 2011 校园招聘 笔试题

Bloodwolf的专栏 4670

标准恢复二极管整流器的全球与中国市场2022-2028年:技术、参与者、趋势、市场规模及占有率研究报告

报告页数: 150 图表数: 100 报告价格:¥16800 本文研究全球与中国市场标准恢复二极管整流器的发展现状及未来发展趋势,分别从生产和消费的角度分析标准恢复二极管整流器的主要生产地区、主要消费地区以及主要的生产商。重点分析全球与中国市场的主要厂商产品特点、产品规格、不同规格产品的价格、产量、产值及全球和中国市场主要生产商的市场份额。 主要生产商包括: Yangzhou Yangjie Vishay Intertechnology Power Semiconductors Inc Nexperia B

Fj69258的博客 5850

FAST-LIO2实战:从零搭建香港大学火星实验室SLAM框架(附官方数据集测试指南)

本文提供了一份详细的FAST-LIO2实战指南,帮助读者从零开始搭建香港大学火星实验室开源的这一高效激光惯性里程计框架。内容涵盖系统环境配置、依赖安装、源码编译、官方数据集测试以及参数调优,旨在让开发者快速上手并应用于机器人SLAM项目。

ppp33的博客 689

AI 问数真的能替代 BI 报表吗?

AI问数赋能自然语言查询,提升临时分析效率,但无法替代传统报表。报表适用于稳定输出与持续监控,AI则擅长探索性提问。企业用好AI问数,关键在于夯实数据模型、统一指标口径、健全权限体系与结果校验机制。合理组合报表、仪表板与AI,才能实现高效、准确的业务洞察。

葡萄城技术团队博客 338

Django 前后端分离实战:网络设备运维系统 - 从登录认证到业务模块

这篇文章分享了Django+Vue前后端分离开发网络设备运维系统的实战经验,重点介绍了登录认证、全局布局和设备管理三大模块的实现。文章包含以下核心内容: 登录模块实现:包括表单验证、Token认证、记住密码功能,以及美观的UI设计(渐变背景、毛玻璃效果) 全局布局架构:采用侧边栏+顶部导航的响应式设计,支持菜单权限控制和多设备适配 业务功能开发:详细展示了设备分类和部门管理的CRUD功能实现,包括列表展示、搜索过滤、分页等功能 常见问题解决:提供了5个开发中常见问题的解决方案,如Vue Router警告、C

qq_16766705的博客 526

【从零理解 Spring AI · 12】MCP 的两种角色:做客户端还是做服务端

上一篇讲了 MCP 的概念:标准协议、三大角色、M+N 替代 M×N。

nice_lcj520的博客 614

开篇词:学习系统分析师的好处?核心考点有哪些?

系统分析师备考指南 系统分析师是IT行业的高级专业人才,具备系统分析与设计能力,能指导开发团队工作。学习系统分析师不仅能获得职业晋升的"黄金跳板",还能全面提升技术架构思维和业务理解能力。 核心价值: 职业发展:晋升管理岗位的硬性要求,突破职业天花板 能力提升:构建T型知识结构,培养架构思维和软技能 市场竞争力:成为"业务+技术"桥梁,获得国家级专业认证 考试内容: 计算机基础知识(硬件、操作系统、网络等) 系统分析专业知识(软件工程、架构设计等) 进阶知识(企业信息

数据知道的博客 5950

Python 爬虫实战:爬取哔哩哔哩知识区,抓取高赞课程信息

哔哩哔哩(Bilibili)是一个广受欢迎的综合性视频社区,其中的知识区汇聚了大量优质的教育、科普、技术等课程内容。本文将指导读者如何使用 Python 爬虫技术从哔哩哔哩知识区抓取高赞课程信息,并进行数据分析。本文深入探究了利用 Python 爬虫技术从哔哩哔哩知识区抓取高赞课程信息的全流程。从前期的环境搭建、模拟登录,到核心的课程数据抓取、存储,再到后续的数据分析与可视化,都详细展开讲解并提供代码支持。通过此方法所获取的数据,能够助力创作者优化内容、用户发现优质课程、平台洞察用户需求。

u014481728的博客 1137

ChatGPT、Perplexity、Gemini 与 AI Overviews 引用对比:谁的引用更可信

AI 引擎的引用机制差异很大:ChatGPT 以行内引用加 Sources 列表呈现来源,Perplexity 几乎逐句可溯源,Gemini 在回答中内嵌相关来源链接,AI Overviews 则把多源聚合答案与来源列表一起放在搜索结果顶部。本文从引用透明度、来源偏好、可干预性 3 个维度对比这 4 个引擎,并给出 GEO 的 3 点启示,帮企业在多引擎环境下提升被引用的概率。

淡然一笑 的专栏 276

GEE案例:Landsat 5、7、8影像构建1985-2023年rsei生态遥感指数详细代码

rsei(Regional Silviculture Ecological Index,地区林业生态指数)是一种生态遥感指标,用于评估森林生态系统的健康状况和生态服务。构建1985-2023年的rsei生态遥感指,主要需要使用Landsat 5、7和8的遥感影像数据。以下是一种可能的构建方法:1. 数据获取:从美国地质调查局(USGS)或其他可靠数据提供商处获取Landsat 5、7和8的遥感影像数据。确保选择的影像具有适当的空间和时间分辨率,以覆盖所需的时间段。

此星光明博客 3452

抽象主义人工智能和生命体AI的内在联系

彭军辉提出“抽象主义人工智能”作为第四大AI范式,批判符号主义、连接主义、行为主义剥离生命本体的误区,确立“智能是现象,生命是本体”的核心公理。主张原生智能必须依附具备存续诉求的生命本体,提出“生命体AI理论”,构建七层演化阶梯与自闭环工程框架,强调智能不可跳过底层存续机制直接模拟语言。该体系为生成式AI提供科学边界,推动从“仿真表象”向“原生智能”的范式跃迁,开辟硅基人工生命新赛道。

抽象主义人工智能和生命体AI 207

GEE土地分类:一文读懂精度评定—混淆矩阵confusion matrix、整体精度OA、用户者精度、生产者精度、kappa系数和F1score系数含案例

本文介绍了如何在 Google Earth Engine (GEE) 中构建和分析混淆矩阵,以评估分类模型的性能。首先,通过 ee.Array 构建混淆矩阵,并展示了如何指定自定义类标签。接着,计算了多种性能指标,包括准确率、Kappa 值、F1-score、消费者准确率和生产者准确率。此外,还演示了如何计算不同类别的 F1-score。最后,通过一个实际案例,展示了如何利用 GEE 进行土地分类,并评估分类器的性能,包括训练和验证样本的准确率、Kappa 值等指标。这些步骤帮助用户理解模型的优缺点,并进行

此星光明博客 444

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

OpenAI Control Room 架构拆解:给企业 AI Agent 加一套可审计的急停系统

OpenAI 公开了用于追踪和停止研究模型工作负载的 Control Room。本文拆解 job_id、推理前鉴权、35 秒撤销窗口与 Fail Closed 设计,并给出企业 AI Agent 急停控制面的数据模型、FastAPI 参考实现、缓存撤销策略和故障演练清单。

jerry764的博客 340

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

OpenClaw 深度调查:把 AI 助手做成你自己的控制平面

对 openclaw/openclaw 的完整技术尽调:Gateway 架构、Agent 运行时、工具与沙箱、30 个消息通道、181 个插件、安全信任边界、工程代价与采用建议。17 章 / 10 张图,全部数字标注口径,数据截至 2026-10-31。

厚积薄发 349

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

AI赋能智慧港口建设|造形家快速生成港口全要素三维场景

随着智慧港口、港口数字孪生项目的持续推进,港口三维场景的需求日益旺盛。传统港口三维建模,往往需要航拍倾斜摄影采集数据,再人工搭建吊机、岸桥、船舶、集装箱等大量工业设施模型,项目周期长、人力成本高,修改迭代繁琐,制约港口可视化项目落地效率。国产AI三维建模工具,依托卫星影像 AI 识别能力,无需航拍作业,一键快速搭建港口完整三维场景,为港口数字孪生、方案汇报、投标演示提供高效的场景解决方案。

m0_69539167的博客 84

从设备增点到治理闭环:老旧小区物业数智化落地实践

系统连接合同审批、银行流水、收费记录与项目台账,执行到期提醒、收入核验、异常标色和月度对账,让每一笔资金来源明确、去向可查。针对设施老旧、诉求响应慢、公共收益不透明等问题,津南以6类小区为试点场景,统一建设物业数字化底座,关联楼栋、单元、房屋、业主、空间、设施设备、工单、公共收益等核心数据。系统采用统一编码管理,将摄像头、路灯、井盖、道路、绿化等设施纳入资产台账,解决纸质记录更新滞后、故障责任难追溯的问题。基于历史工单建立分类模型和知识库,辅助识别照明、给排水、电梯、环境秩序、秩序维护等问题;

wuyeshuzhihua的博客 159

企业微信iPad协议详解:接口接入、实时消息同步与语音转码实践

深入解析企业微信iPad协议的技术架构与开发思路,涵盖API接口接入、长连接通信、实时消息同步、Silk语音转码、异常重连及高并发优化,帮助开发者了解企业微信自动化系统的设计与实现。

欢迎来到祖安! 511

Product Hunt 热榜 2026-11-13:Plurai Simulation、YouArt Desktop App、Omnigraph

2026-11-13 Product Hunt 新产品精选:Plurai Simulation、YouArt Desktop App、Omnigraph。汇总 15 款产品的中文介绍、功能关键词和产品链接。

LaughingZhu的博客 615

【AI Agent面试系列】AI Agent可观测、评测、安全相关的知识点

之前的文章介绍了和,本文主要介绍AI Agent的测评、可观测等知识。

405

Docling 原理解读:是什么、为什么、怎么样

从论文视角拆解 Docling 的整体架构、DoclingDocument 数据模型、PDF 预处理、版面分析、OCR、TableFormer 双解码器、阅读顺序与装配流程,并解释版面框与 OCR 框的区别。

PLANTTHESON的博客 401

WorkBuddy 实战:一句话需求 → 七屏可交互原型,户外徒步 App 的 AI 设计全流程

WorkBuddy 实战:一句话需求 → 七屏可交互原型,户外徒步 App 的 AI 设计全流程,跟着博主一起来还原整个过程。

夜郎King的博客 5156

从认识人工智能到理解机器学习:我的 AI 入门第一课

正式开始学习人工智能之前,我对 AI 的认识其实比较模糊:知道 ChatGPT、知道大模型,也知道现在很多岗位都在谈 AI,但如果有人问我“人工智能到底是什么”“机器是怎么学会识别一只猫的”,我未必能从头到尾讲清楚。上午的课程更偏向行业全景:人工智能的发展、研究方向、NLP、岗位分工、学习路线和 AI Coding 工具。下午的课程更偏向技术基础:机器学习的原理、有监督学习、深度学习、模型训练和评估方法。

chh563的博客 564

企业宣传片发前如何批量排查并遮挡视频里的敏感信息

做企业视频的人都会碰到一个具体问题:实拍画面里混进了不该出现的信息。办公室背景里有贴着客户信息的白板,采访对象的授权书边缘露出一串身份证号码,街采素材里路人面孔和车牌号直接入镜。人眼在时间线上扫视,会漏掉快速闪过的帧、画面边缘的小字、以及暗光区域里的证件号码。用抹影AI完成车牌、人脸和证件区域批量检测后,又手动补充了两个时间段的屏幕遮罩,最终导出时画面已无合规隐患。重点关注快速运动、遮挡、低光照条件下的目标,这些是漏检的高发区域。导入视频后选择要检测的目标类型(人脸、车牌、证件号、二维码等)。

Mysssone的博客 181
上一篇: ISE529 Predictive Analytics 2024 Fall Homework 4Statistics
下一篇: CCC8011 Term 2 2024-2025 3Python
priorityqueue2
博客等级 码龄2年 175粉丝 30原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值