Arrays Flashcards
What is an array?
A collection of elements, each identified by an index. Elements are stored in contiguous memory locations, meaning they are stored in sequence.
What is a static array?
Arrays that have a fixed size, determined at compile time. Once declared, the size cannot be changed.
What is a dynamic array?
Arrays that can change size during runtime. They can grow or shrink as needed, offering more flexibility.
What is the time complexity of accessing elements in an array?
O(1)
What is the time complexity of inserting an element at the end of an array?
O(1)
What is the time complexity of inserting an element at a specific index in an array?
O(n)
What is the time complexity of deleting an element at the end of an array?
O(1)
What is the time complexity of deleting an element at a specific index in an array?
O(n)
What is the time complexity of searching for a specific element in an array?
O(n)
What is the time complexity of searching for a specific element in a sorted array?
O(log n)
What is the time complexity of updating an element at a specific index in an array?
O(1)