http://stackoverflow.com/questions/200384/constant-amortized-time

分摊常量时间:

Amortised time explained in simple terms:

If you do an operation say a million times, you don't really care about the worst-case or the best-case of that operation - what you care about is how much time is taken in total when you repeat the operation a million times.

So it doesn't matter if the operation is very slow once in a while, as long as "once in a while" is rare enough for the slowness to be diluted away. Essentially amortised time means "average time taken per operation, if you do many operations". Amortised time doesn't have to be constant; you can have linear and logarithmic amortised time or whatever else.

Let's take mats' example of a dynamic array, to which you repeatedly add new items. Normally adding an item takes constant time (that is, O(1)). But each time the array is full, you allocate twice as much space, copy your data into the new region, and free the old space. Assuming allocates and frees run in constant time, this enlargement process takes O(n) time where n is the current size of the array.

So each time you enlarge, you take about twice as much time as the last enlarge. But you've also waited twice as long before doing it! The cost of each enlargement can thus be "spread out" among the insertions. This means that in the long term, the total time taken for adding m items to the array is O(m), and so the amortised time (i.e. time per insertion) is O(1).

[名词解释]Constant Amortized Time的更多相关文章

  1. nodejs、npm、grunt——名词解释

    最近着手开发一个新项目,打算从工程化的角度整理一套自己的前端开发.发布体系. grunt这些工具,之前别人用我也用,并没有认真想过它们的前世今生,正好趁着这个机会,我来理一理目前业界比较流行这些工具的 ...

  2. Sql常用语法以及名词解释

    Sql常用语法以及名词解释 SQL分类: DDL—数据定义语言(CREATE,ALTER,DROP,DECLARE) DML—数据操纵语言(SELECT,DELETE,UPDATE,INSERT) D ...

  3. 转OSGchina中,array老大的名词解释

    转OSGchina中,array老大的名词解释 转自:http://ydwcowboy.blog.163.com/blog/static/25849015200983518395/ osg:: Cle ...

  4. css名词解释

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  5. sudo权限添加 和 rpm、deb之名词解释

    sudo权限添加: 刚开始用Center_os Linux操作系统,想装个输入法,搜了一下,看到linux下的搜狗输入法(帖子链接)下载下来的文件的扩展名是.deb,直接用帖子上的一个命令: sudo ...

  6. SourceTree&Git部分名词解释

    SourceTree&Git部分名词解释 克隆(clone):从远程仓库URL加载创建一个与远程仓库一样的本地仓库 提交(commit):将暂存文件上传到本地仓库(我们在Finder中对本地仓 ...

  7. b2c项目基础架构分析(二)前端框架 以及补漏的第一篇名词解释

    继续上篇,上篇里忘记了也很重要的前端部分,今天的网站基本上是以一个启示页,然后少量的整页切换,大量的浏览器后台调用web服务局部.动态更新页面显示状态这种方式在运作的,从若干年前简单的ajax流行起来 ...

  8. b2c项目基础架构分析(一)b2c 大型站点方案简述 已补充名词解释

    我最近一直在找适合将来用于公司大型bs,b2b b2c的基础架构. 实际情况是要建立一个bs架构b2b.b2c的网站,当然还包括wap站点.手机app站点. 一.现有公司技术人员现状: 1.熟悉asp ...

  9. Lucene/ElasticSearch 学习系列 (2) Information Retrival 初步之名词解释

    计算机领域一半是理论,一半是在理论基础之上的应用.要想深入地掌握某个方面的应用,就需要先学习那方面的理论. “搜索”是应用,其背后的理论是 "Information Retrieval&qu ...

随机推荐

  1. Linux 守护进程一

    守护进程是一个后台进程,它无需用户输入就能运行,经常是提供某种服务. LInux作为服务器,主要的进程也都是为系统或用户提供后台服务功能. 常见的守护进程有Web服务器.邮件服务器以及数据库服务器等等 ...

  2. (转载)Apache下error.log文件太大的处理

    偶尔发现Apache下的错误日志非常的大,有5G多,先停止Apache服务的所有进程,最简单就是输命令:net stop apache2.4,然后删除 Apache/logs/目录下的 error.l ...

  3. 专门用于微信公众平台的Javascript API

    1 /**! 2 * 微信内置浏览器的Javascript API,功能包括: 3 * 4 * 1.分享到微信朋友圈 5 * 2.分享给微信好友 6 * 3.分享到腾讯微博 7 * 4.新的分享接口, ...

  4. &10 基本数据结构——栈,队列和链表

    #1,栈(stack) 定义[来自百度]:栈(stack)又名堆栈,它是一种运算受限的线性表.其限制是仅允许在表的一端进行插入和删除运算.这一端被称为栈顶,相对地,把另一端称为栈底.向一个栈插入新元素 ...

  5. Caffe学习系列(17):模型各层数据和参数可视化

    cifar10的各层数据和参数可视化 .caret,.dropup>.btn>.caret{border-top-color:#000!important}.label{border:1p ...

  6. 学习bash

    工作8年,前6年基本是Windows环境下,也就是个鼠标党:两年前换工作开始用linux,也就开始了领略了命令行的强大,无论是直接在命令行组合命令,也还写几行简单的shell脚本,其能完成的功能往往令 ...

  7. 20145208 《Java程序设计》第8周学习总结

    20145208 <Java程序设计>第8周学习总结 教材学习内容总结 NIO与NIO2 NIO与IO的区别 IO           NIO 面向流             面向缓冲 阻 ...

  8. ROM存储1/4周期正弦信号构造DDS

    上周的时候,老师让编写一个简单的dds程序,本文说明了整个过程中我遇到问题以及一些个人的思考.初次接触FPGA,如有问题请多多指教~ 1.几个疑问,解决和没有解决的. 为何采用ROM而不是直接采用DD ...

  9. jQuery基础之(一)jQuery概述

    1.jQuery的简介 就像上节所将到的Ajax框架一样,简单的说,jQuery是一个优秀的javascript框架,它能够让用户方便的处理html,events(冒泡)事件,动画效果,ajax交互等 ...

  10. “耐撕”团队 2016.04.11 站立会议

    1. 时间 : 19:30--19:50. 共计20分钟. 2. 成员 : Z 郑蕊 * 组长 (博客:http://www.cnblogs.com/zhengrui0452/), P 濮成林(博客: ...