Skip to content

An analysis of different search and sorting algorithms in Python

License

Notifications You must be signed in to change notification settings

minh-dng/Search-and-Sort-Analysis

Repository files navigation

🔎 Search and 🗃 Sort Algorithms Analysis

🧩 Version Details

  1. Search_v1: Search for 1 item with time taken details included
  2. Search_v2: Automated search for all values within array, returning performance visualisation between different search algorithms
  3. Sort_v1: Sort an customise array and return bar chart visualisation
  4. Sort_v2: Sort an array with the minimum length of 1 to the specified maximum array length

📍 Requirements

🉑 Language

Windows icon Python 3.6 or above

python or python3 in terminal to check the version

📦 Libraries

Installation

  • Windows icon Windows only: Execute start.bat

  • Manually through system terminal with pip install package (e.g. pip install pandas)

Usages

numpy ipython matplotlib pandas
Search_v1 🟢 🟢
Search_v2 🟢 🟢 🟢 🟢
Sort_v1 🟢 🟢 🟢
Sort_v2 🟢 🟢 🟢

🗝 Operation

  1. .ipynb is the recommended format, to be used in environments that allow Jupyter Notebook execution

  2. .py

    • Direct execution through python or python3

    • Execute start.bat and select version.

    Batch script start.bat is case sensitive

📥 Download

Check releases for more details

  1. Python: .zip

  2. Jupyter Notebooks: .zip


⏳ Performance

⚠ Warning

Linear Search is not time-efficient, adjust the parameters wisely

Sorting is not time-efficient, adjust the parameters wisely

  • Bubble sort (Unoptimized) -- 4 times longer than Insertion Sort
  • Bubble sort (Optimized) -- 2 times longer than Insertion Sort
  • In Sort_v2, the recommend upper limit is 1000 as higher parameters would led to long execution time, turning your computer into a jet engine slowing other processes within your computer

💊 Testing

File Search_v1 Search_v2 Sort_v1 Sort_v2
Demo Deepnote Deepnote Deepnote Deepnote
Execution time (Demo) < 1 min 40 min 70 min 12.5 hours
Notes Duplicates: 4884
Values Remain: 95116
Seed: 1
Number: 3620
Duplicates: 4733
Values Remain: 95267
Seed: 1698699006
Seed: 1440114639
Array Length: 41001
Seed: 1355045386
Upper Limit: 5000

📊 Graphs

Binary vs Linear Search

41001 Array Sorting Performance

Different Sorting Algorithms' Performance

📎 Other Links

Preview or run services for Jupyter Notebook

Deepnote, Replit, Datalore (from JetBrains), Google Colab, Binder

More sites here StackOverflow Answer

Visual Studio Code useful links

Jupyter Notebook website

https://jupyter.org/