# Array Data Structure For Cracking Technical Interviews

## Array Data Structure For Cracking Technical Interviews

In today’s blog post, i am discussing the basics of array data structure for cracking technical interviews.

## Array Data Structure

An array is a collection of items stored in contiguous memory locations. All the items stored in an array are usually of same data type.

Arrays are the oldest and most important data structure and I guess are the most commonly used data structure.

Since they stored in contiguous memory locations, it’s very efficient to calculate the position of an element based on the index, if you have the base address.

For e.g., if the base address is 100 and the array is of type int and each int is taking 4 bytes. If you want to calculate the position of 5th element in an array of size 10, here is the formula:

Base Address + index * element size = 100 + 5 * 4 = 120.

Arrays are usually of fixed size. In order to increase their capacity, we usually have to create a new array of larger size and then copy the existing elements into new array. This can be a somewhat expensive operation.

In order to learn the ins and outs of this data structure, I will recommend you all to implement your own version of array. You can call it myArray. Then, practice typical operations on the array. For e.g. inserting an element in the array, deleting an element from the array, traversing all the elements of array, searching for an element in the array. Then for each of these algorithms, please understand the Big O complexity in terms of run-time as well as space complexity. That should make you more comfortable & fluent with the data structure itself.

In future videos, I will be covering a few actual questions related to arrays that are asked in interviews. That should give you a better idea of the types of questions that are actually asked in the interviews.