Data Structure: Arrays, Stack, Link-list
Data Structure: Arrays, Stack, Link-list
Arrays/Linked
DATA STRUCTURES:
List/Stack/Queue
Tuesday,
11/02/25
Uchenna-Declan
Mba
Arrays (codes)
public class Arrays {
public static void main(String[] args) {
int [] numbers = new int[10];
numbers[0] = 10;
numbers[1] = 500;
numbers[2] = 1000;
numbers [3] = 534;
numbers [4] = 702;
numbers [6] = 342;
numbers [9] = 5543;
}
Arrays (codes) Initialization & Declaration
}
Arrays (codes) DT.
Strings
public class Arrays {
}
}
Arrays cont…
Besides the fundamental operations like getting and setting, Java
provides various functions to manipulate arrays in the Arrays class.
The Arrays is a utility class which can be found in
the java.util package.
asList(): returns a fixed-size list backed by an array.
binarySearch(): searches for a specific value in an array. Returns the
index of the element if found, or -1 if not found. Note that the array
must be sorted first.
copyOf(): copies a portion of the specified array to a new one.
copyOfRange(): copies a specified range of an array to a new one.
equals(): compares two arrays to determine if they are equal or not.
fill(): fills same values to all or some elements in an array.
sort(): sorts an array into ascending order.
And other methods you can find in the Array Class Javadoc.
Main disadvantages of array: fixed length, not appropriate if a
dynamic container is required.
Linked List
A linked list is a linear data structure in which
elements are not stored at contiguous
memory locations. The elements in a linked
list are linked using pointers.
They are;
Singly-linked list