Linear Data structures

Pardhu Guttikonda
4 min readSep 30, 2021

commonly used linear data structures.

Photo by Markus Spiske on Unsplash

🔭Types of Data Structures:-

Data structures are divided into two categories:

  1. Linear data structures
  2. Non-linear data structures

Linear data structures:-

In linear data structures, elements are arranged in sequence one after the other.


An array is a collection of items stored at contiguous memory locations. The idea is to store multiple items of the same type together.

from google
int[] intArray = new int[20]; 

For dynamic use of arrays, we can use ArrayList:-

ArrayList<Integer> arrli = new ArrayList<Integer>();
ArrayList<Integer> arrc = new ArrayList<Integer>(C);
//ArrayList with C collections
ArrayList<Integer> arrli = new ArrayList<Integer>();
//EmptyArrayList with int n capacity
//common used functions
arrli.set(index,element);//replaces the element
arrli.set(index,element);//inserts the element


It works in the LIFO(last in first out) principle. I use to remember this structure like placing all C.D’s one by one in the holder while searching we need to take out last in C.D. (OR) Pack of tennis balls.

Stack stack = new Stack();  // can push any datatype
Stack<String> stack1 = new Stack<String>(); // only String😁
stack.push(2);// adding element 2
stack.push(3);// adding element 3
stack.pop();// returns top element and removes it---3
stack.peek();//returns top element---2;//returns index of element---0


It works in the FIFO(First in first out) principle. I use to remember this structure using the movie tickets queue, bus…

Pardhu Guttikonda

Certified AWS Cloud Practitioner

Recommended from Medium


See more recommendations