This is my repository for Data Structures and Algorithms using Python. All the implementations are for learning and research purposes only.
Bharathi kannan
Portfolio LinkedIn
Keep coding! :)
Show some ❤️ by starring this repository!
- Linked List
- Stack
- Queue
- Hash Table
- Heap
- Trie
- Tree
- Graph -> In progress
- Dynamic Programming
- Searches
- Sorting
- Linked List
-
Available Methods
- delete() - Deleting the data at any position
- deleteAlternateNodes() - Delete alternate nodes
- deleteGreaterValuesOnRight() - Delete an element if it's right node is grater than it
- deleteList() - Deleting the entire linked list
- getCountOfValue() - Get count of a data in linkedlist
- getMiddleElement() - Get the middle element
- ifNodeExists() - If a data exists in any node (Search method)
- insertAtFirst() - Inserting the element at the start of the linked list
- insertAtLast() - Insert the data at last
- insertAtPosition() - Inserting the data at a specific position.
- isFirstSecondHalfMatch() - Does First half and second half match
- isPalindrome() - Return true if a linked list is palindrome
- length() - Length of the LinkedList
- moveLastNodeToFront() - Move last node to front
- pairwiseSwapElements() - Swapping pairwise elements
- reverse() - Reverse the linked list
- reverseRecursion() - Same reverse function usinf recursion
- rotateAntiClockwise() - Rotate Anticlockwise
- rotateCloclwise() - Clockwise in linkedlist
- show() - Printing all the elements of the linked list
-
- Doubly Linked List
-
Available Methods
- delete() - Delete an element
- deleteList - Delete the entire doubly linked list
- insertAtFirst() - Inserting at first
- insertAtLast() - Insert node at last
- insertAtPosition() - Insert at a certain position
- length() - Count of nodes in our doubly linked list
- reversePrint() - Print all the elements in reverse
- show() - To print all the elements
-
- Merge two sorted linked list
- Reverse linked list
- Rotate linked list
-
Available Methods
- rotateClockwise() - Rotate Colockwise
- rotateAntiClocwise() - Rotate AntiClockwise
-
- Trie
-
Available Methods
- add() - Add words to trie
- search() - Search elements in trie
- show() - Display all words in trie
-
- Tree
- Binary Search Tree
-
Available Methods
- delete() - Delete the entire tree
- empty() - Checks empty or not
- getDiffEvenOddRows() - Difference of even and odd rows
- getLevelOfNode() -Get level of data
- height() - Height of the tree
- ifMirrorStructureTree() - If two trees are mirror structure or not
- ifMirrorTree() - If two trees are mirror ot not
- ifSameStructureTree() - If two trees are having same structure or not
- ifSameTree() - If two trees are same or not
- inorder - Inorder traversal
- inorderUsingStack() - Inorder traversal using stack
- insert() - Insert the data in a BST
- isFoldable() - Is the tree foldable or not
- isIdentical() - Two trees are identical or not
- leftSideOfTree() -Left side of the tree
- levelOrderTraversal() -Print values by level order
- levelOrderTraversalLineByLine() - Level order traversal line by line
- levelWiseSum() - Sum of all data in each level
- maxWidth() - Get maximum width of the tree
- mirrorTree() - Mirror the tree
- noOfNodes() - No of nodes in the tree
- noofLeafNodes - Number of leaf nodes
- postorder() - Postorder traversal
- preorder() - Preorder Traversal
- printAtGivenLevel() - Print values only at a certain level
- printBetweenTwoLevels() - Print data between any two levels
- printLeaves() - Print leaf nodes
- recursiveSearch() - Search using recursion
- reverseLevelOrderTraversal() - Level order traversal in reverse
- rightSideOfTree() - Right side of the tree
- search() - Return true if an element exists
- spiralOrder() -Print in spiral order
- sum() - Sum of all the values
-
In progress
- Edit distance - Number of edit distance required to change one string to another
- Egg drop - Minimum no of trials needed in worst case to find the floor where the egg breaks
- Fibanocci sequence - Generate fibanocci sequence
- Generate parenthesis - Generate matched parenthesis with n number of open and closed brackets
- Kadane algorithm - Largest sub array problem
- Knapsack 0/1 - knapsack 0/1 problem
- Longest common subsequence - Longest common subsequence of two strings
- Min no of coins - Minimum number of coins needed to make the given amount
- Range sum query - Return the sum between two indices
Data structure | Time Complexity | Space Complexity | |||||||
---|---|---|---|---|---|---|---|---|---|
Average | Worst | Worst | |||||||
Access | Search | Insertion | Deletion | Access | Search | Insertion | Deletion | ||
Array | Θ(1) | Θ(n) | Θ(n) | Θ(n) | O(1) | O(n) | O(n) | O(n) | O(n) |
Stack | Θ(n) | Θ(n) | Θ(1) | Θ(1) | O(n) | O(n) | O(1) | O(1) | O(n) |
Queue | Θ(n) | Θ(n) | Θ(1) | Θ(1) | O(n) | O(n) | O(1) | O(1) | O(n) |
Singly-Linked List | Θ(n) | Θ(n) | Θ(1) | Θ(1) | O(n) | O(n) | O(1) | O(1) | O(n) |
Doubly-Linked List | Θ(n) | Θ(n) | Θ(1) | Θ(1) | O(n) | O(n) | O(1) | O(1) | O(n) |
Hash Table | N/A | Θ(1) | Θ(1) | Θ(1) | N/A | O(n) | O(n) | O(n) | O(n) |
Binary Search Tree | Θ(log(n)) | Θ(log(n)) | Θ(log(n)) | Θ(log(n)) | O(n) | O(n) | O(n) | O(n) | O(n) |
Red-Black Tree | Θ(log(n)) | Θ(log(n)) | Θ(log(n)) | Θ(log(n)) | O(log(n)) | O(log(n)) | O(log(n)) | O(log(n)) | O(n) |
AVL Tree | Θ(log(n)) | Θ(log(n)) | Θ(log(n)) | Θ(log(n)) | O(log(n)) | O(log(n)) | O(log(n)) | O(log(n)) | O(n) |
Algorithm | Time Complexity | Space Complexity | ||
---|---|---|---|---|
Best | Average | Worst | Worst | |
Quicksort | Ω(n log(n)) | Θ(n log(n)) | O(n^2) | O(log(n)) |
Mergesort | Ω(n log(n)) | Θ(n log(n)) | O(n log(n)) | O(n) |
Bubble Sort | Ω(n) | Θ(n^2) | O(n^2) | O(1) |
Insertion Sort | Ω(n) | Θ(n^2) | O(n^2) | O(1) |
Selection Sort | Ω(n^2) | Θ(n^2) | O(n^2) | O(1) |
- Data Structure Visualizations -Interactive animations for a variety of data structures and algorithms
- Visualgo Visualizaing data structures and algorithms
- Interactive Visualizations of Graph Algorithms - Spanning trees, Shortest paths, Network flow and Routing.
- Sorting Algorithms Visualization - Simple animations for sorting algorithms
- A Visual Guide to Graph Traversal Algorithms - This resource is interactive and readers can use the visualisations to see how the algorithms can be applied to search graphs and solve certain problems.
- Algorithm Visualizer - It is an interactive onlineplatform that visualizas algorithsm from code
- Hacker Earth - Use Visualizer tab in each sorting algorithms
- Geeks for geeks
- Data structures Roadmap - zerotomastery
- Free Code Camp
- W3Schools
- Khan Academy - Introductory computer science algorithms, including searching, sorting, recursion, and graph theory
- List of Data structures - Wikipedia
- Big O cheatsheet - This webpage covers the space and time Big-O complexities of common algorithms used in Computer Science
- Algorithms and Data structures cheatsheet - Algorithms 4th edition, Robert Sedgewick and Kevin Wayn, Princeton university
- Reddit thread
- Algorithms, Part I - Coursera - Part I covers elementary data structures, sorting, and searching algorithms
- Algorithms, Part II - Coursera - Part II focuses on graph- and string-processing algorithms
This repo is inspired from my previous repo on Data structures and Algorithms in Java