Skip to content

Commit 0d03524

Browse files
author
Anastasiia Shcherbakova
committed
changed summary able of data structures
1 parent 3d73d1d commit 0d03524

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

episodes/optimisation-data-structures-algorithms.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -352,14 +352,13 @@ These results are subject to change based on the number of items and the proport
352352

353353
Dictionaries are designed to handle insertions efficiently, with average-case O(1) time complexity per insertion for a small size dict, but it is clearly problematic for large size dict. In this case, it is better to find an alternative Data Structure for example List, NumPy Array or Pandas DataFrame. The table below summarizes the best uses and performance characteristics of each data structure:
354354

355-
| Data Structure | Small Size Insertion (O(1)) | Large Size Insertion | Search Performance (O(1)) | Best For |
356-
|------------------|-----------------------------|------------------------------------------|---------------------------|--------------------------------------------------------------------------|
357-
| Dictionary | Yes | Problematic (O(n) resizing) | Yes | Fast insertions and lookups, key-value storage, small to medium data |
358-
| List | Yes (Amortized) | Efficient (Amortized O(1)) | No (O(n)) | Dynamic appends, ordered data storage, general-purpose use |
359-
| Set | Yes | Problematic (O(n) resizing) | Yes | Membership testing, unique elements, small to medium data |
360-
| NumPy Array | No | Efficient (Fixed Size) | No (O(n)) | Numerical computations, fixed-size data, vectorized operations |
361-
| Pandas DataFrame | No | Efficient (Column-wise) | No (O(n)) | Column-wise analytics, tabular data, large datasets |
362-
355+
| Data Structure | Small Size Insertion (O(1)) | Large Size Insertion | Search Performance (O(1)) | Best For |
356+
|------------------|-----------------------------------|------------------------------------------|---------------------------|--------------------------------------------------------------------------|
357+
| Dictionary || ⚠️ Occasional O(n) (due to resizing) | ✅ O(1) (Hashing) | Fast insertions and lookups, key-value storage, small to medium data |
358+
| List | ✅ Amortized (O(1) Append) | ✅ Efficient (Amortized O(1)) | ❌ O(n) (Linear Search) | Dynamic appends, ordered data storage, general-purpose use |
359+
| Set | ✅ Average O(1) | ⚠️ Occasional O(n) (due to resizing) | ✅ O(1) (Hashing) | Membership testing, unique elements, small to medium datasets |
360+
| NumPy Array | ❌ (Fixed Size) | ⚠️ Costly (O(n) when resizing) | ❌ O(n) (Linear Search) | Numerical computations, fixed-size data, vectorized operations |
361+
| Pandas DataFrame | ❌ (if adding rows) | ⚠️ Efficient (Column-wise) | ❌ O(n) (Linear Search) | Column-wise analytics, tabular data, large datasets |
363362
NumPy and Pandas, which we have not yet covered, are powerful libraries designed for handling large matrices and arrays. They are implemented in C to optimize performance, making them ideal for numerical computations and data analysis tasks.
364363

365364
:::::::::::::::::::::::::::::::::::::::::::::

0 commit comments

Comments
 (0)