Data Structures
Data Structures are a way of collecting and organising data in such a way that we can perform operations on these data in an effective way.
Types of Data Structures
Section titled “Types of Data Structures”- Primitive: Integer, Character, Boolean, Float, etc.
- Non-Primitive:
- Linear:
- Arrays
- Lists
- Linked Lists
- Stacks
- Queues
- Non-Linear: ❌
- Trees
- HashMaps
- Graphs
- Linear:
Primitive Data Structures
Section titled “Primitive Data Structures”These are basic built-in data types in Java.
| Type | Description | Example |
|---|---|---|
int | 32-bit integer, range: -2,147,483,648 to 2,147,483,647 | int i = 123456; |
char | Single 16-bit Unicode character | char c = 'A'; |
boolean | True or false value | boolean flag = true; |
float | 32-bit floating-point, single precision | float f = 3.14f; |
double | 64-bit floating-point, double precision | double d = 3.14159; |
byte | 8-bit integer, range: -128 to 127 | byte b = 100; |
short | 16-bit integer, range: -32,768 to 32,767 | short s = 20000; |
long | 64-bit integer, range: very large whole numbers | long l = 123456789L; |
Non-Primitive Data Structures
Section titled “Non-Primitive Data Structures”Are more complex and are made up of primitive data types. They can be divided into two types:
- Linear Data Structures
- Non-linear Data Structures
Linear Data Structures
Section titled “Linear Data Structures”Data elements are arranged in a sequential manner, where each element is connected to its previous and next element.
Non-Linear Data Structures
Section titled “Non-Linear Data Structures”Data elements are not arranged sequentially - they can have multiple connections.