# Comparison of collection efficiency

The efficiency of a collection refers to its ability to perform operations quickly and efficiently, minimizing the time and resources used.

When evaluating the efficiency of a collection, it is important to consider the runtime of key operations, such as reading, inserting, deleting, and searching for elements.

These operations vary depending on the type of collection and its internal implementation.

## Efficiency Comparison Table

Let’s take a look at a summary table of the efficiencies of the collections we have seen in the course, for different operations:

Sequential Access🟢🟢🟢
Random Access🟢🟢🔴🟢🟢
Delete at the beginning🔴🟢
Delete at the end🟢🟢🟢🟢🟢
Random Insertion🔴🟢🟡🟡
Random Deletion🔴🟢🟢🟢
Search🔴🔴🔴🟢🟢

Where the meaning of each symbol is,

• 🟢O(1): Constant runtime.
• 🟡O(1)-O(n): Constant runtime in the best case, but linear in the worst case.
• 🔴O(n): Linear runtime, proportional to the size of the collection.
• ⚫N/A: The operation is not applicable or does not make sense for that particular collection.

### Description of operations

Here is a description of each of the operations mentioned in the table:

1. Sequential Access: Refers to the ability to access the elements of the collection in sequence, one after another, regardless of their position.

2. Random Access: Means the ability to directly access an element at a specific position in the collection, without the need to sequentially traverse from the beginning.

3. Add at the beginning: The operation of adding a new element at the beginning of the collection.

4. Delete at the beginning: It is the operation of deleting the first element of the collection.

5. Add at the end: Adding a new element at the end of the collection.

6. Delete at the end: Refers to the operation of deleting the last element of the collection.

7. Random Insertion: Means adding a new element at an arbitrary position in the collection.

8. Random Deletion: It is the operation of deleting an element at an arbitrary position in the collection.

9. Search: Means finding a specific element in the collection.