# amortized-analysis

##### 每次以固定常数增长动态数组的效率？(Efficiency of growing a dynamic array by a fixed constant each time?)

2021-07-29 01:17:48    分类:技术分享    arrays   data-structures   big-o   time-complexity   amortized-analysis

##### Design a stack that can also dequeue in O(1) amortized time?

I have an abstract data type that can be viewed as a list stored left to right, with the following possible operations: Push: add a new item to the left end of the list Pop: remove the item on the left end of the list Pull: remove the item on the right end of the list Implement this using three stacks and constant additional memory, so that the amortized time for any push, pop, or pull operation is constant. The stacks have basic operations, isEmpty, Push, and Pop. Amortized time means "If I spend this amount of time, I can spend another block of it and store it in a bank of time to be used

2021-06-22 17:34:33    分类:问答    algorithm   stack   amortized-analysis

##### 不相交集森林数据结构的联合/查找算法不按等级联合(Union/find algorithm without union by rank for disjoint-set forests data structure)

2021-06-11 20:54:15    分类:技术分享    algorithm   data-structures   time-complexity   disjoint-sets   amortized-analysis

##### need to find the amortized cost of a sequence using the potential function method

There is a sequence of n operations, The ith operation costs 2i if i is an exact power of 2, costs 3i if i is an exact power of 3, and 1 for all other operations.Hi first up I want to say that it is a homework problem and I don't want you to solve it for me. I have solved it using the aggregate method. For which I summed up the series of powers of 2 and series of powers of 3 and got amortized cost of 10. I then checked it using the accounting method, for really long sequences and it did not fail. But my problem is how to prove that it would never fail, I can show for as long sequence I want

2021-06-10 14:08:52    分类:问答    algorithm   amortized-analysis

##### Efficiency of growing a dynamic array by a fixed constant each time?

So when a dynamic array is doubled in size each time an element is added, I understand how the time complexity for expanding is O(n) n being the elements. What about if the the array is copied and moved to a new array that is only 1 size bigger when it is full? (instead of doubling) When we resize by some constant C, it the time complexity always O(n)?

2021-06-02 17:00:00    分类:问答    arrays   data-structures   big-o   time-complexity   amortized-analysis

##### Union/find algorithm without union by rank for disjoint-set forests data structure

Here's a breakdown on the union/find algorithm for disjoint set forests on wikipedia: Barebone disjoint-set forests... (O(n)) ... with union by rank ... (now improved to O(log(n)) ... with path compression (now improved to O(a(n)), effectively O(1)) Implementing union by rank necessitates that each node keeps a rank field for comparison purposes. My question is, is union by rank worth this additional space? What happens if I skip union by rank and just do path compression instead? Is it good enough? What is the amortized complexity now? A comment is made that implies that union by rank without

2021-05-24 13:01:53    分类:问答    algorithm   data-structures   time-complexity   disjoint-sets   amortized-analysis

##### 为什么python的list.append（）方法的时间复杂度为O（1）？(Why is the time complexity of python's list.append() method O(1)?)

2021-05-08 16:37:52    分类:技术分享    python   python-2.7   time-complexity   amortized-analysis

##### 用外行的术语摊销复杂性？(Amortized complexity in layman's terms?)

2021-04-26 11:11:16    分类:技术分享    algorithm   amortized-analysis

##### 摊销算法分析(Amortized Analysis of Algorithms)

2021-04-24 04:12:19    分类:技术分享    algorithm   amortized-analysis

##### Amortized time of dynamic array

As a simple example, in a specific implementation of the dynamic array, we double the size of the array each time it fills up. Because of this, array reallocation may be required, and in the worst case an insertion may require O(n). However, a sequence of n insertions can always be done in O(n) time, because the rest of the insertions are done in constant time, so n insertions can be completed in O(n) time. The amortized time per operation is therefore O(n) / n = O(1). --from Wiki But in another book :Each doubling takes O(n) time, but happens so rarely that its amortized time is still O(1)

2021-04-19 02:36:41    分类:问答    algorithm   amortized-analysis