{"id":20169103,"url":"https://github.com/shikha-code36/competitive-python","last_synced_at":"2025-04-10T02:20:39.631Z","repository":{"id":114296448,"uuid":"601135813","full_name":"Shikha-code36/Competitive-Python","owner":"Shikha-code36","description":"Python Algorithms Package used in competitive programming","archived":false,"fork":false,"pushed_at":"2023-03-19T12:46:19.000Z","size":38,"stargazers_count":16,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-24T03:53:02.762Z","etag":null,"topics":["algorithms","algorithms-and-data-structures","bfs","binary-search-tree","competitive-coding","competitive-programming","data-structures","data-structures-and-algorithms","dfs","dijkstra-algorithm","graph-algorithms","leetcode","leetcode-python","pypi-package","python","python-competitive-programming","python-ds-algo","searching-algorithms","sorting-algorithms","trees"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/competitivepython/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Shikha-code36.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-02-13T12:52:39.000Z","updated_at":"2024-04-04T08:28:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"af546fa5-d580-4c17-9552-7a8df01f4166","html_url":"https://github.com/Shikha-code36/Competitive-Python","commit_stats":{"total_commits":24,"total_committers":3,"mean_commits":8.0,"dds":0.25,"last_synced_commit":"6564f8bfa7f366a2468e5f70f49817f67b0ab544"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shikha-code36%2FCompetitive-Python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shikha-code36%2FCompetitive-Python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shikha-code36%2FCompetitive-Python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shikha-code36%2FCompetitive-Python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Shikha-code36","download_url":"https://codeload.github.com/Shikha-code36/Competitive-Python/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248143059,"owners_count":21054697,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithms","algorithms-and-data-structures","bfs","binary-search-tree","competitive-coding","competitive-programming","data-structures","data-structures-and-algorithms","dfs","dijkstra-algorithm","graph-algorithms","leetcode","leetcode-python","pypi-package","python","python-competitive-programming","python-ds-algo","searching-algorithms","sorting-algorithms","trees"],"created_at":"2024-11-14T01:11:24.650Z","updated_at":"2025-04-10T02:20:39.608Z","avatar_url":"https://github.com/Shikha-code36.png","language":"Python","readme":"# Competitive Programming Algorithm Library in Python\n\ncompetitivepython is an open-source library of algorithms and data structures implemented in Python. It offers a collection of frequently used algorithms and data structures that can be directly used in any Python-based project.\n\n- Checkout the blog regarding this library [Click Here](https://pandeyshikha075.medium.com/an-overview-of-competitivepython-a-python-library-for-implementing-algorithms-and-data-structures-3a5776e13535)\n\n## Features\n\n- Provides implementations for several common algorithms and data structures such as:\n  - Searches: Binary Search, Linear Search, KMP Pattern Search\n  - Graphs: BFS, DFS, Dijkstra\n  - Sorting: Bubble Sort, Insertion Sort, Shell Sort, Selection Sort, Bucket Sort, Merge Sort, Tim Sort, Quick Sort, Heap Sort, Radix Sort\n  - Trees: Binary Search Tree\n- Codebase is easy to use, well-documented, and compatible with Python 3.\n- Open source and available under the MIT license\n\n## Installation\n\nTo install competitivepython library, simply run the following command:\n\n```\n  pip install competitivepython\n  ```\n\n## Usage\n\nTo use competitivepython in your project, import the desired algorithm or data structure and use it as needed. Below are some example use cases:\n\n- Implementing searches:\n  - Binary Search\n    ```\n    from competitivepython import searches\n    \n    arr = [1, 2, 3, 4, 5]\n    target = 3\n    \n    result = searches.binary_search(arr, target)\n  \n    print(\"Binary Search:\",result)  \n    \n    '''Output: \n    Binary Search: 2\n    '''\n    ```\n  - Linear Search\n    ```\n    from competitivepython import searches\n    \n    arr = [5, 7, 9, 2, 4, 10]\n    target = 4\n    \n    result = searches.linear_search(arr, target)\n    \n    print(\"Linear Search:\",result)  \n    \n    '''Output: \n    Linear Search: 4\n    '''\n    ```\n  - Knuth–Morris–Pratt string Search\n    ```\n    from competitivepython import searches\n    \n    txt = \"ABABDABACDABABCABAB\"\n    pat = \"ABABCABAB\"\n    \n    result = searches.kmp_search(pat,txt)\n    \n    print(\"KMP Search:\",result) \n    \n    '''Output: \n    KMP Search: [10]\n    '''\n    ```\n    \n- Implementing sorting:\n  - Bubble Sort\n    ```\n      from competitivepython import sorting\n\n      arr = [112, 6, 7, 12, 15]\n\n      result = sorting.bubble_sort(arr)\n      print('bubble sort:', result)\n\n      ''' Output --- \n       bubble sort: [6, 7, 12, 15, 112] \n      '''\n      ```\n   - Bucket Sort\n      ```\n      from competitivepython import sorting\n\n      arr = [112, 6, 7, 12, 15]\n\n      result = sorting.bucket_sort(arr)\n      print('bucket sort:', result)\n\n      ''' Output --- \n       bucket sort: [6, 7, 12, 15, 112]\n      '''\n      ```\n  - Heap Sort\n    ```\n    from competitivepython import sorting\n\n    arr = [112, 6, 7, 12, 15]\n    \n    result = sorting.heap_sort(arr)\n    \n    print('heap sort:', result)\n\n    ''' Output --- \n     heap sort: [6, 7, 12, 15, 112] \n    '''\n    ```\n  - Insertion Sort\n    ```\n    from competitivepython import sorting\n\n    arr = [112, 6, 7, 12, 15]\n\n    result = sorting.insertion_sort(arr)\n    \n    print('insertion sort:', result)\n\n    ''' Output ---  \n    insertion sort: [6, 7, 12, 15, 112] \n    '''\n    ```\n  - Merge Sort\n    ```\n    from competitivepython import sorting\n\n    arr = [112, 6, 7, 12, 15]\n\n    result = sorting.merge_sort(arr)\n    \n    print('merge sort:', result)\n\n    ''' Output --- \n     merge sort: [6, 7, 12, 15, 112] \n    '''\n    ```\n  - Quick Sort\n    ```\n    from competitivepython import sorting\n\n    arr = [112, 6, 7, 12, 15]\n\n    result = sorting.quick_sort(arr)\n    \n    print('quick sort:', result)\n\n    ''' Output --- \n     quick sort: [6, 7, 12, 15, 112] \n    '''\n    ```\n  - Radix Sort\n    ```\n    from competitivepython import sorting\n\n    arr = [112, 6, 7, 12, 15]\n\n    result = sorting.radix_sort(arr)\n    \n    print('radix sort:', result)\n\n    ''' Output --- \n    radix sort: [6, 7, 12, # 15, 112]\n    '''\n    ```\n  - Selection Sort\n    ```\n    from competitivepython import sorting\n\n    arr = [112, 6, 7, 12, 15]\n    \n    result = sorting.selection_sort(arr)\n    \n    print('selection sort:', result)\n\n    ''' Output --- \n    selection sort: [6, 7, 12, 15, 112]\n    '''\n    ```\n  - Shell Sort\n    ```\n    from competitivepython import sorting\n\n    arr = [112, 6, 7, 12, 15]\n\n    result = sorting.shell_sort(arr)\n\n    print('shell sort:', result)\n\n    ''' Output --- \n     shell sort: [6, 7, 12, 15, 112] \n    '''\n    ```\n  - Tim Sort\n    ```\n    from competitivepython import sorting\n\n    arr = [112, 6, 7, 12, 15]\n\n    result = sorting.tim_sort(arr)\n\n    print('tim sort:', result)\n\n    ''' Output --- \n    tim sort: [6, 7, 12, 15, 112]\n    '''\n    ```\n  \n-  Implementing graphs:\n    - Breadth First Search (or Breadth First Traversal)\n      ```\n      from competitivepython import graphs\n\n      graph = {\n          'A': {'B': 1, 'C': 4},\n          'B': {'A': 1, 'C': 2, 'D': 5},\n          'C': {'A': 4, 'B': 2, 'D': 1},\n          'D': {'B': 5, 'C': 1},\n      }\n      start = 'A'\n      end = 'D'\n\n      result = graphs.breadth_first_search(graph, 'C')\n\n      print(\"bfs:\",result)\n\n      ''' Output--\n          bfs: {'B', 'D', 'C', 'A'}\n      '''\n      ```\n    - Depth First Search(or Depth First Traversal)\n      ```\n      from competitivepython import graphs\n\n      graph = {\n          'A': {'B': 1, 'C': 4},\n          'B': {'A': 1, 'C': 2, 'D': 5},\n          'C': {'A': 4, 'B': 2, 'D': 1},\n          'D': {'B': 5, 'C': 1},\n      }\n      start = 'A'\n      end = 'D'\n\n      result = graphs.depth_first_search(graph, 'C')\n      print(\"dfs:\",result)\n\n      ''' Output--\n          dfs: {'B', 'D', 'C', 'A'}\n      '''\n      ```\n    - Dijkstra’s Shortest Path\n      ```\n      from competitivepython import graphs\n\n      graph = {\n          'A': {'B': 1, 'C': 4},\n          'B': {'A': 1, 'C': 2, 'D': 5},\n          'C': {'A': 4, 'B': 2, 'D': 1},\n          'D': {'B': 5, 'C': 1},\n      }\n      start = 'A'\n      end = 'D'\n\n      result = graphs.dijkstra(graph, start, end)\n      print(\"dijikstra:\",result)\n\n      ''' Output--\n         dijikstra: {'distance': 4, 'path': ['B', 'C', 'D']}\n      '''\n      ```\n\n- Implementing trees:\n\n    ```\n    from competitivepython import trees\n\n    # Create an instance of the BinarySearchTree\n    bst = trees.BinarySearchTree()\n\n    # Insert some values into the tree\n    bst.insert(50)\n    bst.insert(30)\n    bst.insert(20)\n    bst.insert(40)\n    bst.insert(70)\n    bst.insert(60)\n    bst.insert(80)\n\n    # Check if a value is present in the tree\n    print(bst.search(50)) # Output: True\n    print(bst.search(35)) # Output: False\n\n    # Get the values in the tree in in-order traversal order\n    print(bst.get_in_order_traversal()) # Output: [20, 30, 40, 50, 60, 70, 80]\n    ```\n\n## Contributing\n\nIf you would like to contribute to the competitivepython project, please refer to the contributing guidelines in CONTRIBUTING.md. We welcome contributions of all types, including bug reports, feature requests, and code contributions.\n\n## License\n\ncompetitivepython is open source software released under the MIT license. Refer to the LICENSE file for more information.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshikha-code36%2Fcompetitive-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshikha-code36%2Fcompetitive-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshikha-code36%2Fcompetitive-python/lists"}