| Type | Set of Values (Examples) | Java Example |
|---|---|---|
| Boolean | {true, false} |
boolean flag = true; |
| Integer | {β¦, -2, -1, 0, 1, 2, β¦} |
int n = 42; |
| Real / Float | decimal numbers (approx.) | double x = 3.14; |
| Character | single symbols: { 'a', '7', '#', 'Z' } |
char c = 'A'; |
| String | sequences of characters: "", "hi", "batata" |
String s = "hello"; |
| Set | collections without duplicates | no direct Java type (but Set<Integer>) |
| Enumerated | fixed named constants: {MONDAY, β¦, SUNDAY} |
enum Day { MON, TUE, β¦ } |
| Type | Set of Values | Common Operations (makes it a Data Type) | Java Example |
|---|---|---|---|
| Boolean | {true, false} |
AND (&&), `OR ( |
|
| Integer | {β¦, -1, 0, 1, β¦} |
+ - * / %, comparisons <, >, == |
int n = 5 + 3; |
| Real / Float | decimals | + - * /, comparisons <, >, == |
double x = 2.5 * 3; |
| Character | symbols | comparisons, casting to int, increment ++ |
char c = 'A'; c++; |
| String | sequences | concatenation +, length(), substring(), charAt() |
"hi".toUpperCase() |
| Set | collections | add, remove, union, intersection, contains |
Set<Integer> s = new HashSet<>(); |
| Enumerated | fixed constants | equality check, switch-case, iteration | Day d = Day.MON; |
| ADT | Description | Core Operations |
|---|---|---|
| List | Ordered collection of elements | insert, delete, search, traverse |
| Stack | LIFO (last in, first out) | push, pop, peek, isEmpty |
| Queue | FIFO (first in, first out) | enqueue, dequeue, peek, isEmpty |
| Deque | Double-ended queue | insert/remove at front or rear |
| Set | Collection of unique elements | add, remove, contains, union, intersection |
| Map / Dictionary | Key β Value associations | put(key, value), get(key), remove(key) |
| Priority Queue | Queue where each element has a priority | insert, extractMin/extractMax, peek |
A data structureis the implementation of a data type (or ADT) in a programming language.
It organizes and stores data in memory so that operations (insert, delete, search, etc.) can be performed efficiently.
ADT tells me what i can do with data, like stacks can do operations like push pop and peek. Data structures tell me how to do it, they organize data and memory and implement the code such as arrays, linked lists, trees, graphs,
Array
arr[i] directly in O(1).