| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2049 人关注过本帖
标题:求助一个算法问题!N+K Algorithm Creation
只看楼主 加入收藏
john841116
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2015-4-22
收藏
 问题点数:0 回复次数:0 
求助一个算法问题!N+K Algorithm Creation
Suppose you are given n+k words of memory to use and a sequence of n INSERT, DELETE, and MEMBER operations to process. The integers 1 through k are the values of the operations (e.g., INSERT 1, MEMBER k,...).

Explain how to do each of the three operations in constant time, using at most a constant amount of additional storage space beyond the alloted n+k words.

Note: You cannot use preprocessing to initialize memory.

假设有n+k的内存空间,运行n次操作INSERT, DELETE, and MEMBER等。操作的对象是1到k的整数。
INSERT 1 是插入1
DELETE 1 是删除1
MEMBER 1 则return 1 是否已经在内存中,是return true,否return false
设计算法是这三种操作在常数时间内完成。在n+k内存空间之外最多允许使用的额外空间为常数,常熟不随n,k变化而变化
注:不允许预先初始化内存空间。

先谢过啦!!!
搜索更多相关主题的帖子: storage process beyond sequence additional 
2015-04-22 05:01
快速回复:求助一个算法问题!N+K Algorithm Creation
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.028157 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved