EKAlgorithms
EKAlgorithms is a set of computer exercises implemented in Objective-C. Data structures, well known algorithms, CS curiosities, you name it!
Don't forget to watch the repository; Its content will be expanded and updated frequently.
Arrays and Lists
- Index of maximum element in array.
- Indexes of maximum and minimum elements simultaneously.
- Find longest string in array of strings.
- Find shortest string in array of strings.
- Array reverse.
- Intersection of two arrays.
- Union of two arrays (with remove duplicates).
- Union of two arrays (with remove duplicates) for some key.
- Find duplicates.
- Array with N unique/not unique random objects.
- Check if array is sorted.
- Array shuffle (Fisher-Yates).
- Sum of array elements.
- N of occurences of each element in array.
Search Algorithms
- Linear search.
- Binary search.
Sorting Algorithms
- Bubble sort.
- Shell sort.
- Merge sort.
- Quick sort.
- Insertion sort.
- Selection sort.
- Radix Sort.
- Partial selection sort.
- Heap sort.
Selection Algorithms
- Quickselect.
Strings
- Palindrome or not.
- String reverse.
- Words count.
- Permutations of string.
- Occurrences of each character (a - z).
- Count "needles" in a "haystack".
- Random string.
- Concatenation of two strings.
- Find 1st occurrence of "needle" in a "haystack".
- Last occurrence of "needle" in a "haystack".
- Longest common subsequence.
- Levenshtein distance.
- KMP (Knuth–Morris–Pratt).
- Boyer–Moore string search algorithm.
Numeric Algorithms
- Sieve of Eratosthenes.
- Great common divisor (GCD).
- Least common multiple (LCM).
- Factorial.
- Fibonacci numbers (5 algos).
- Sum of digits.
- Binary to decimal conversion.
- Decimal to binary conversion.
- Fast exponentiation.
- Number reverse.
- Even/odd check.
- Leap year check.
- Armstrong number check.
- Prime number check.
- Find Nth prime.
- Swap the value of two NSInteger pointers.
- Square root using Newton-Raphson method.
- Convert integer to another numeral system (2, 8, 12, 16).
- Fast inverse square root.
Data Structures
- Stack (LIFO).
- Queue (FIFO).
- Deque.
- Linked list.
- Graph:
- DFS (depth-first search);
- BFS (breadth-first search);
- MST (minimum spanning tree - Prim's algorithm);
- MST (minimum spanning tree - Kruskal's algorithm);
- Shortest path (Dijkstra's algorithm);
- Topsort.
- Tree.
- Binary tree:
- Pre-order traversal;
- In-order traversal;
- Post-order traversal.
- Binary search tree (BST).
- AVL tree.
- Binary heap.
Problems
- Josephus Problem.
- Modulo bias.
Geometry
- Array of sorted locations according to a distance to a given location.
- Cartesian quadrant selection algorithms
Recursion
- Tower of Hanoi.
Contributions
Pull requests are welcome! But if you want to do a contribution, open an issue first.
Originally, the compiled exercises are for educational purposes only and have no intention of being the ultimate solution complexity-wise, but they do intend to be used by you as a starting point of a deeper study on algorithms and their optimization.
Important Note
The Foundation framework already includes tools and methods for most of the exercises contained here. Kudos to Apple on that! But... this. is. SPARTA! So lets get our hands dirty and try to implement cool CS stuff with minimal use of existing APIs.
Thanks!
Similar repositories
algorithms playground for common questions (Ruby language)
Examples of commonly used data structures and algorithms in Swift. (Swift)
Algorithms and data structures in Swift, with explanations!
Contributors
Special thanks to these guys for their contributions to the project's development: