Skip to content

Latest commit

 

History

History
38 lines (34 loc) · 2.12 KB

arrays.md

File metadata and controls

38 lines (34 loc) · 2.12 KB

Array Data Structure

Table of Contents

Initialize

Function Name Description Time Complexity Space Complexity
array_init Initializes an array with specified type and size O(1) O(n)
array_destroy Destroys an array & frees up heap O(1) O(n)
array_append Adds an element to the end of array O(1) O(1)
array_insert Inserts an element at a specific index O(n) O(1)
Delete Removes an element from the array O(n) O(1)
Swap Swaps two elements in the array O(1) O(1)
Linear Search Searches for an element sequentially O(n) O(1)
Binary Search Searches for an element in a sorted array O(log n) O(1)
Get Retrieves an element from the array O(1) O(1)
Set Sets an element in the array O(1) O(1)
Max Finds the maximum element in the array O(n) O(1)
Min Finds the minimum element in the array O(n) O(1)
Sum Calculates the sum of array elements O(n) O(1)
Reverse1 Reverses the array in place O(n) O(1)
Reverse2 Reverses the array using an auxiliary array O(n) O(n)