Skip to content

meugenom/java-common-algorithms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧠 πŸ“š ⏱ Java Common Data Structures and Algorithms

This repository contains an implementation of common data structures and algorithms in Java. This code is primarily intended for understanding and learning data structures, and for finding their complexity. It is designed for students and self-learners.

Great request, if you see an error or inaccuracy, please make a correction. Any help is welcome.

Notation keys

The following keys are used to indicate the level of difficulty and time/space complexity of each algorithm:

  • 🍏: easy;
  • 🍊: medium;
  • 🍎: hard;
  • ⭕️(1), ⭕️log(N), ⭕️(N^2), etc: time and space complexity;
  • [✍🏻]: in progress;
  • [πŸ™‡πŸ»β€β™‚οΈ]: hard to solve;
  • [❓]: the solution is not optimal;
  • [πŸ†—]: Test passed Ok;

Data Structures:

The following data structures are implemented in this repository:

The Arrays class provides the following algorithms:

Algorithm (operation) Level Done Time Complexity Space Complexity Tests passed:
findMin 🍏 βœ”οΈ ⭕️(N) ⭕️(1) [πŸ†—] Open
mergeSortedArrays 🍊 βœ”οΈ ⭕️(N) ⭕️(N) [πŸ†—] Open
mergeUnsortedArrays 🍊 βœ”οΈ ⭕️(N^2) ⭕️(N) [πŸ†—] Open
pop 🍏 βœ”οΈ ⭕️(N) ⭕️(N) [πŸ†—] Open
push 🍏 βœ”οΈ ⭕️(N) ⭕️(N) [πŸ†—] Open
remove(position) 🍏 βœ”οΈ ⭕️(N) ⭕️(N) [πŸ†—] Open
reverse 🍊 βœ”οΈ ⭕️(N) ⭕️(1) [πŸ†—] Open
reverse(start,end) 🍊 βœ”οΈ ⭕️(N) ⭕️(1) [πŸ†—] Open
size 🍏 βœ”οΈ ⭕️(N) ⭕️(1) [πŸ†—] Open
sort 🍊 βœ”οΈ ⭕️(N^2) ⭕️(1) [πŸ†—] Open
genericArray <T> 🍎 βœ”οΈ [πŸ†—] Open

The Sort classes provide the following algorithms:

Algorithm (operation) Level Done Time Complexity Space Complexity Tests passed:
Buble Sort <T> 🍏 βœ”οΈ ⭕️(N^2) ⭕️(1) [πŸ†—] Open
Quick Sort 🍊 βœ”οΈ ⭕️(N log(N)) ⭕️(log(N)) [πŸ†—] Open
MergeSort 🍏 βœ”οΈ ⭕️(N log(N)) ⭕️(N) [πŸ†—] Open
Insertion Sort 🍏 βœ”οΈ ⭕️(N^2) ⭕️(1) [πŸ†—] Open

The Matrix class provides the following algorithms:

Algorithm (operation) Level Done Time Complexity Space Complexity Tests passed:
rotate 🍊 βœ”οΈ ⭕️(N^2) ⭕️(1) [πŸ†—] Open
transpose 🍊 βœ”οΈ ⭕️(N^2) ⭕️(1) [πŸ†—] Open
reflect 🍊 βœ”οΈ ⭕️(N^2) ⭕️(1) [πŸ†—] Open

The SinglyLinkedList class provides the following algorithms:

Algorithm (operation) Level Done Time Complexity Space Complexity Tests passed:
append(data) 🍏 βœ”οΈ ⭕️(1) ⭕️(1) [πŸ†—] Open
preppend(data) 🍏 βœ”οΈ ⭕️(N) ⭕️(1) [πŸ†—] Open
find(data) 🍏 βœ”οΈ ⭕️(N) ⭕️(1) [πŸ†—] Open
deleteFirst() 🍏 βœ”οΈ ⭕️(N) ⭕️(1) [πŸ†—] Open
deleteLast() 🍏 βœ”οΈ ⭕️(N) ⭕️(1) [πŸ†—] Open
deletePos(position) 🍏 βœ”οΈ ⭕️(N) ⭕️(1) [πŸ†—] Open
length() 🍏 βœ”οΈ ⭕️(N) ⭕️(1) [πŸ†—] Open
reverse() 🍏 βœ”οΈ ⭕️(N^2) ⭕️(N) [πŸ†—] Open
getMid(LinkedList) 🍏 βœ”οΈ ⭕️(N) ⭕️(1) [πŸ†—] Open
merge(LinkedList, LinkedList) 🍊 βœ”οΈ ⭕️(N+M) ⭕️(1) [πŸ†—] Open
sort() 🍊 βœ”οΈ ⭕️(N log(N)) ⭕️(log(N)) [πŸ†—] Open

The DoublyLinkedList class provides the following algorithms:

Algorithm (operation) Level Done Time Complexity Space Complexity Tests passed:
append(data) 🍏 βœ”οΈ ⭕️(1) ⭕️(1) [πŸ†—] Open
preppend(data) 🍏 βœ”οΈ ⭕️(1) ⭕️(1) [πŸ†—] Open
deleteFirst() 🍏 βœ”οΈ ⭕️(1) ⭕️(1) [πŸ†—] Open
deleteLast() 🍏 βœ”οΈ ⭕️(1) ⭕️(1) [πŸ†—] Open

The BinarySearchArray class provides the following algorithms:

Algorithm (operation) Level Done Time Complexity Space Complexity Tests passed
Binary Search Iterative 🍊 βœ”οΈ ⭕️(log(N)) ⭕️(1) [πŸ†—] Open
Binary Search Recursive 🍊 βœ”οΈ ⭕️(log(N)) ⭕️(log(N)) [πŸ†—] Open

The Stack class provides the following algorithms:

Algorithm (operation) Level Done Time Complexity Space Complexity Tests passed
getMin() 🍏 βœ”οΈ ⭕️(N) ⭕️(1) [πŸ†—] Open
peek() 🍏 βœ”οΈ ⭕️(1) ⭕️(1) [πŸ†—] Open
pop() 🍏 βœ”οΈ ⭕️(1) ⭕️(1) [πŸ†—] Open
push(data) 🍏 βœ”οΈ ⭕️(1) ⭕️(1) [πŸ†—] Open

The Queue class provides the following algorithms:

Algorithm (operation) Level Done Time Complexity Space Complexity Tests passed
isEmpty() 🍏 βœ”οΈ ⭕️(1) ⭕️(1) [πŸ†—] Open
peek() 🍏 βœ”οΈ ⭕️(1) ⭕️(1) [πŸ†—] Open
enqueue() 🍏 βœ”οΈ ⭕️(N) ⭕️(1) [πŸ†—] Open
dequeue() 🍏 βœ”οΈ ⭕️(N) ⭕️(1) [πŸ†—] Open

The BinaryHeap class provides the following algorithms:

Algorithm (operation) Level Done Time Complexity Space Complexity Tests passed
insert() 🍎 βœ”οΈ ⭕️(log(N)) ⭕️(1) [πŸ†—] Open
delete(index) 🍎 βœ”οΈ ⭕️(log(N)) ⭕️(1) [πŸ†—] Open
sort() 🍎 βœ”οΈ ⭕️(N log(N)) ⭕️(1) [πŸ†—] Open
fixHeapAbove(index) 🍎 βœ”οΈ ⭕️(log(N)) ⭕️(1)
fixHeapAbove(index, lastHeapIndex) 🍎 βœ”οΈ ⭕️(log(N)) ⭕️(1)

The Tree class provides the following algorithms:

Algorithm (operation) Level Done Big ⭕️ Notation Tests passed
Binary Tree Recursive: insert(data) 🍎 βœ”οΈ ⭕️log(N) [πŸ†—] Open
Binary Tree Recursive: preOrderPrint() 🍎 βœ”οΈ ⭕️log(N) [πŸ†—] Open
Binary Tree Recursive: inOrderPrint() 🍎 βœ”οΈ ⭕️log(N) [πŸ†—] Open
Binary Tree Recursive: postOrderPrint() 🍎 βœ”οΈ ⭕️log(N) [πŸ†—] Open
Binary Tree Recursive: find(data) 🍎 βœ”οΈ ⭕️log(N) [πŸ†—] Open
Binary Tree Recursive: delete() 🍎 βœ”οΈ ⭕️log(N) [πŸ†—] Open
Binary Tree Iterative: insert(data) 🍎 βœ”οΈ ⭕️(N) [πŸ†—] Open
Binary Tree Iterative: preOrderPrint() 🍎 βœ”οΈ ⭕️(N) [πŸ†—] Open
Binary Tree Iterative: inOrderPrint() 🍎 βœ”οΈ ⭕️(N) [πŸ†—] Open
Binary Tree Iterative: postOrderPrint() 🍎 βœ”οΈ ⭕️(N) [πŸ†—] Open
AVL Tree 🍎 [✍🏻]
Fenwick Tree 🍎 [✍🏻]
Red-Black Tree 🍎 [✍🏻]
Segment Tree 🍎 [✍🏻]

Data Structure: Hash Table<Listnode>

Algorithm (operation) Level Done Big ⭕️ Notation
hash(key) 🍏 [✍🏻]
set(key, value) 🍏 [✍🏻]
delete(key) 🍏 [✍🏻]
get(key) 🍏 [✍🏻]
has(key) 🍏 [✍🏻]
getKeys() 🍏 [✍🏻]
getValues() 🍏 [✍🏻]

Data Structure: Trie

Algorithm (operation) Level Done Big ⭕️ Notation
addWord 🍎 [✍🏻]
deleteWord 🍎 [✍🏻]

Data Structure: Graph

Algorithm (operation) Level Done Big ⭕️ Notation
directed 🍎 [✍🏻]
undirected 🍎 [✍🏻]

πŸ›  Use Tests:

mvn clean test

Autor

meugenom

About

Common Data Structures and Algorithms, Java realization

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published