- Related Questions & Answers
- Amortized time complexity in Data Structures
- Amortized Analysis
- Asymptotic Complexity
- Amortized Cost of Meld Operation
- Complexity of Interval Heap Operations
- Amortized analysis for increment in counter in C++
- What is 'Space Complexity’?
- An interesting time complexity question in C++
- Time and Space Complexity in Data Structure
- Complexity of an algorithm for size n=3
- An Insertion Sort time complexity question in C++
- Practice Questions on Time Complexity Analysis in C++
- How to calculate the time complexity of interpolation search?
- C++ Program to Implement Quick Sort with Given Complexity Constraint
- Object comparison Complexity in JavaScript using comparison operator or JSON.stringlify()?

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

This analysis is used when the occasional operation is very slow, but most of the operations which are executing very frequently are faster. In Data structures we need amortized analysis for Hash Tables, Disjoint Sets etc.

In the Hash-table, the most of the time the searching time complexity is O(1), but sometimes it executes O(n) operations. When we want to search or insert an element in a hash table for most of the cases it is constant time taking the task, but when a collision occurs, it needs O(n) times operations for collision resolution.

The aggregate method is used to find the total cost. If we want to add a bunch of data, then we need to find the amortized cost by this formula.

For a sequence of n operations, the cost is −

For a dynamic array, items can be inserted at a given index in O(1) time. But if that index is not present in the array, it fails to perform the task in constant time. For that case, it initially doubles the size of the array then inserts the element if the index is present.

For the dynamic array, let ๐๐ = cost of ๐๐กโ insertion.

Advertisements