Array Data Structure

  • Last Updated : 05 Aug, 2022

Data Structure and Algorithms Course
Practice Problems on Arrays
Recent articles on Arrays

An array is a collection of items stored at contiguous memory locations. The idea is to store multiple items of the same type together. This makes it easier to calculate the position of each element by simply adding an offset to a base value, i.e., the memory location of the first element of the array (generally denoted by the name of the array).
Array Data Structure
The above image can be looked as a top-level view of a staircase where you are at the base of the staircase. Each element can be uniquely identified by their index in the array (in a similar way as you could identify your friends by the step on which they were on in the above example).

Topics :

Array Introduction :

Array Rotations :

More >>

Arrangement Rearrangement :

  1. Rearrange an array such that arr[i] = i
  2. Write a program to reverse an array or string
  3. Rearrange array such that arr[i] >= arr[j] if i is even and arr[i]<=arr[j] if i is odd and j < i
  4. Rearrange positive and negative numbers in O(n) time and O(1) extra space
  5. Rearrange array in alternating positive & negative items with O(1) extra space | Set 1
  6. Move all zeroes to end of array
  7. Move all zeroes to end of array | Set-2 (Using single traversal)
  8. Minimum swaps required to bring all elements less than or equal to k together
  9. Rearrange positive and negative numbers using inbuilt sort function
  10. Rearrange array such that even positioned are greater than odd
  11. Rearrange an array in order – smallest, largest, 2nd smallest, 2nd largest, ..
  12. Double the first element and move zero to end
  13. Reorder an array according to given indexes
  14. Rearrange positive and negative numbers with constant extra space
  15. Arrange given numbers to form the biggest number
  16. Rearrange an array such that ‘arr[j]’ becomes ‘i’ if ‘arr[i]’ is ‘j’
  17. Rearrange an array in maximum minimum form | Set 1
  18. Rearrange an array in maximum minimum form | Set 2 (O(1) extra space)
  19. Move all negative numbers to beginning and positive to end with constant extra space
  20. Move all negative elements to end in order with extra space allowed
  21. Rearrange array such that even index elements are smaller and odd index elements are greater
  22. Positive elements at even and negative at odd positions
  23. Replace every array element by multiplication of previous and next
  24. Shuffle a given array
  25. Segregate even and odd numbers

More >>


Order Statistics :

More >>

Range Queries :

More >>

Optimization Problems :

Sorting :

More >>

Searching :

  1. Search, insert and delete in an unsorted array
  2. Search, insert and delete in a sorted array
  3. Given an array A[] and a number x, check for pair in A[] with sum as x
  4. Searching in an array where adjacent differ by at most k
  5. Find common elements in three sorted arrays
  6. Find position of an element in a sorted array of infinite numbers
  7. Find the only repetitive element between 1 to n-1
  8. Find the element that appears once
  9. Maximum Subarray Sum Excluding Certain Elements
  10. Maximum equlibrium sum in an array
  11. Equilibrium index of an array
  12. Leaders in an array
  13. Ceiling in a sorted array
  14. Majority Element
  15. Check for Majority Element in a sorted array
  16. Check if an array has a majority element
  17. Two Pointers Technique
  18. Find a peak element
  19. Find the two repeating elements in a given array
  20. Find a Fixed Point in a given array
  21. Find sub-array with given sum
  22. Maximum triplet sum in array
  23. Smallest Difference Triplet from Three arrays
  24. Find a triplet that sum to a given value
  25. Find all triplets with zero sum

More >>

Matrix :

More >>

Misc :

Quick Links :

GeeksforGeeks Courses:

Complete Interview Preparation

Get fulfilled all your interview preparation needs at a single place with the Complete Interview Preparation Course that provides you with all the required stuff to prepare for any product-based, service-based, or start-up company at the most affordable prices.

Live Courses

GFG Live Classes offers Interactive LIVE and Self-Paced Courses with Individual Attention from Industry Leading Experts to Encourage Out-of-the-Box Thinking, Leading to Clarity in Concepts, Creativity, and Innovative Ideas. Clear your doubts with the instructor, just like an offline classroom program. Check out GeeksforGeeks valuable Live Courses. – System Design Live, Competitive Programming Live, and more!

Language Foundation Courses[C Programming / C++ / JAVA / Python ]

Master any programming language from scratch and understand all its core fundamental concepts for a solid programming foundation at a pocket-friendly price with help of GeeksforGeeks Language Foundation Courses– C Programming | Java Foundation | Python Foundation | C++ Foundation. These courses are designed for complete beginners who want to get started with programming and build their foundations.

If you like GeeksforGeeks and would like to contribute, you can also write an article and mail your article to See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above

My Personal Notes arrow_drop_up

Writing code in comment? Please use, generate link and share the link here.