Stanford - Algorithms: Design and Analysis, Part 1 - Week 6 Assignment: hash table and heap

这是Stanford算法课程第1部分第6周的作业,涉及哈希表和堆。作业包含两道题目,第一题要求计算在[-10000, 10000]区间内有多少不同整数x和y的和等于目标值t。可选挑战是实现自己的哈希表。第二题涉及构建两个堆,一个最大堆存储小于等于中位数的元素,另一个最小堆存储大于等于中位数的元素,以确保中位数的位置。" 136886012,594666,灰度图恢复与存储:华为OD真题解析与JavaScript实现,"['图像处理', '算法', '开发语言', '华为OD']
摘要由CSDN通过智能技术生成

太久没有更新博客了,原来做的作业都没有写blog,现在印象已经有点模糊了,不过还是得贴出来,方便以后查阅。。

本次作业算是比较简单的一次。。。。

一共两道题,第一题题目要求如下:

Question 1

Download the text file  here. (Right click and save link as).

The goal of this problem is to implement a variant of the 2-SUM algorithm (covered in the Week 6 lecture on hash table applications).

The file contains 1 million integers, both positive and negative (there might be some repetitions!).This is your array of integers, with the  ith  row of the file specifying the  ith  entry of the array.

Your task is to compute the number of target values  t  in the interval [-10000,10000] (inclusive) such that there are distinctnumbers  x,y  in the input file that satisfy  x+y=t

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值