Personal Website and Computer Science TUR EN

Array Data Structure

Last update: 2/2/2019 1:31:00 AM

Written by Fatih Kabakci

Array is a data structure that its items are ordered with index values in the random access memory. Each item in arrays has a index value starting from 0. Indexes are the integer numbers that describe where items are. The address of an array points out the same address of the first item of an array. Since the first element is 0 distance away from the head of array, therefore, array indexes start from 0.

int[] arr = {1, 2, 3, 4, 5};

arr[0] -> 1
arr[1] -> 2
arr[2] -> 3 
arr[3] -> 4
arr[4] -> 5

In order to access an item of an array, which is O(1), index values are provided like above. While accessing a data is pretty easy that is advantage of random access, inserting and removing operations are hard and require O(n) complexity because of shifting operation. Besides that, the implementation of array applications requires arrays to be initialized in fix size in first.

For instance, suppose there is an array with 10 items in first. If you need to add another item which will be 11th, then you have to re-initialize the array in new fix size in order to store 11th item. Arrays are very popular data structure in the applications where you are pretty sure how many items you will store.

Briefly, to be able to access an item is very easy. You just need to provide the index value of that item. The complexity is O(1). However, since there is a fixed size structure, you might have to think both the first size of the array whether its capacity will exceed after an insertion operation, and shifting operations will be enforced after a deletion or updating operation unless this updating operation is not just editing a data.

ArrayList - Dynamic Arrays

We mentioned that there is a limitation in array because of the uncertain size information unless you have to be sure. Java has provided ArrayList since Java 1.2 for dynamic array operations. So, the size of array increases or decreases as long as you add or remove items. After a certain number, if the size hits the capacity, ArrayList size will increase.

List<Integer> list = new ArrayList<Integer>():

list.get(0) -> 1
list.get(1) -> 2
list.get(2) -> 3
list.get(3) -> 4
list.get(4) -> 5

There has been no comment yet


   Please verify the image

The Topics in Computer Science

Search this site for


Software & Algorithms


In mathematics and computer science, an algorithm is a step-by-step procedure for calculations. Algorithms are used for calculation, data processing, and automated reasoning.

Programming Languages


A programming language is a formal constructed language designed to communicate instructions to a machine, particularly a computer. It can be used to create programs to control the behavior of a machine. Java,C, C++,C#



A database is an organized collection of data. The data are typically organized to model aspects of reality in a way that supports processes requiring information.



Computer hardware is the collection of physical elements that constitutes a computer system. Computer hardware refers to the physical parts or components of a computer such as the monitor, memory, cpu.

Web Technologies


Web development is a broad term for the work involved in developing a web site for the Internet or an intranet. Html,Css,JavaScript,ASP.Net,PHP are one of the most popular technologies. J2EE,Spring Boot, Servlet, JSP,JSF, ASP

Mobile Technologies


Mobile application development is the process by which application software is developed for low-power handheld devices, such as personal digital assistants, enterprise digital assistants or mobile phones. J2ME



A computer network or data network is a telecommunications network that allows computers to exchange data. In computer networks, networked computing devices pass data to each other along data connections.

Operating Systems


An operating system is software that manages computer hardware and software resources and provides common services for computer programs. The OS is an essential component of the system software in a computer system. Linux,Windows

Computer Science


Computer science is the scientific and practical approach to computation and its applications.A computer scientist specializes in the theory of computation and the design of computational systems.