Skip to content

bharathikannann/Python-Data-Structures-and-Algorithms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Data Structures and Algorithms using Python

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!

In this repository

Data structures and Algorithms

Big O complexities

Useful tools and websites

Linked List

  • 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

Stack

Queue

Hash Table

Heap

Trie

  • Trie
    • Available Methods
      • add() - Add words to trie
      • search() - Search elements in trie
      • show() - Display all words in trie

Tree

  • 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

Graph

In progress

Dynamic Programming

Searches

Sorting

Big O Complexities

Common Data Structure Operations

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)

Array Sorting Algorithms

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)

Useful Tools and Websites

Visualization Tools

Websites

Cheatsheets

Free Online Courses

Motivation

This repo is inspired from my previous repo on Data structures and Algorithms in Java