Suggest an editImprove this articleRefine the answer for “What is an array as a data structure?”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)**An array** is a basic data structure in which elements are stored in contiguous memory cells and have the same type. Its main property is direct access by index: you can instantly get the element with the needed number. **Key point:** accessing an array element by index takes O(1), constant time.Shown above the full answer for quick recall.Answer (EN)Image**An array** is a basic data structure in which elements are stored **in contiguous memory cells** and have **the same type** (for example, all numbers or all strings). The main property of an array is **direct access by index**, meaning you can instantly get the element with the needed number. --- ### **1. How it works** Picture a row of memory cells, where each element sits strictly one after another: ```javascript [10] [20] [30] [40] 0 1 2 3 ← indices ``` To get the element at index `2`, the computer simply calculates the address: `start_address + (element_size × index)` - and immediately accesses the needed cell. That's why accessing an element takes **O(1)** - constant time. --- ### **2. Main operations** | Operation | Time complexity | Description | |---|---|---| | Access by index | **O(1)** | Fast - direct addressing. | | Search for an element | **O(n)** | Requires scanning the whole array. | | Insert/delete | **O(n)** | Requires shifting the rest of the elements. | | Iterate over all elements | **O(n)** | Linear time. | --- ### **3. Pros** - Fast access by index. - Simple structure and implementation. - Efficient memory use (cells go one after another). --- ### **4. Cons** - Fixed size (in classic arrays). - Slow inserts and deletes in the middle. - Memory is not freed automatically when elements are removed. --- ### **5. Example in Python** ```python arr = [10, 20, 30, 40] print(arr[2]) # 30 ``` (Although in Python this is a *list*, under the hood it is implemented as a dynamic array.) --- **Summary:** > An array is a data structure with fast index-based access and sequential storage of elements, optimal for cases where the amount of data is known in advance and insertions happen rarely.For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.