{"id":18429695,"url":"https://github.com/jonperk318/searching-algorithms","last_synced_at":"2026-04-07T08:32:08.786Z","repository":{"id":243334307,"uuid":"812146734","full_name":"jonperk318/searching-algorithms","owner":"jonperk318","description":"Comparing the efficiencies of linear, binary, and ternary searching algorithms in Python, Java, C++, and JavaScript","archived":false,"fork":false,"pushed_at":"2024-09-02T04:41:09.000Z","size":31013,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-13T23:00:00.887Z","etag":null,"topics":["binary-search","cpp","css","file-io","graphjs","html","java","javascript","js","linear-search","python","ternary-search","webpack"],"latest_commit_sha":null,"homepage":"https://jonperk318.github.io/searching-algorithms/","language":"C++","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/jonperk318.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-08T04:49:18.000Z","updated_at":"2024-10-02T16:45:59.000Z","dependencies_parsed_at":"2024-12-24T20:51:45.890Z","dependency_job_id":null,"html_url":"https://github.com/jonperk318/searching-algorithms","commit_stats":null,"previous_names":["jonperk318/algorithms-and-data-structures","jonperk318/searching-algorithms"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jonperk318/searching-algorithms","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonperk318%2Fsearching-algorithms","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonperk318%2Fsearching-algorithms/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonperk318%2Fsearching-algorithms/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonperk318%2Fsearching-algorithms/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonperk318","download_url":"https://codeload.github.com/jonperk318/searching-algorithms/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonperk318%2Fsearching-algorithms/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31506562,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-07T03:10:19.677Z","status":"ssl_error","status_checked_at":"2026-04-07T03:10:13.982Z","response_time":105,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["binary-search","cpp","css","file-io","graphjs","html","java","javascript","js","linear-search","python","ternary-search","webpack"],"created_at":"2024-11-06T05:18:24.926Z","updated_at":"2026-04-07T08:32:08.759Z","avatar_url":"https://github.com/jonperk318.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Searching Algorithms in Four Languages\nComparing the efficiencies of searching algorithms implemented \nin four programming languages: Python, Java, C++, and JavaScript.\n\nResults: https://jonperk318.github.io/searching-algorithms/\n\n## How to Use\nLanguages and packages used:\n* Python 3.12.2\n* Java 21.0.1\n* C++ Apple Clang 15.0.0 (clang-1500.3.9.4)\n* JavaScript Node 20.15.0\n* * webpack-cli 5.1.4\n\nFirst, run `./samples/sample_generator.py` to generate 50 sample arrays of logarithmically-spaced sizes from\n100 to 1,000,000, each containing randomly-generated integers ranging from 1 to 1,000,000. These arrays are outputted \ninto text files along with `./samples/sample-sizes.txt`, which contains the array sizes.\n\nSecond, run the following four main functions each utilizing three searching algorithms (with three trials each) \nimplemented in their respective languages:\n* `./python-algorithms/main.py`\n* `./java-algorithms/src/Main.java`\n* `./cpp-algorithms/main.cpp`\n* `./javascript-algorithms/main.js`\n\nThese each generate text files containing the searching times for each algorithm.\n\nThird, run `./src/result-loader.js` to convert these results into `./dist/results.js`, using a format readable by \n`./dist/main.js`. To generate this file, run `npx webpack` in the root directory.\n\n## Results\n\nThe first four sections show all searching algorithms in one of four languages. The y-axis \nof each graph is scaled logarithmically.\n\nIn Python, Java, and JavaScript, linear search with a random key and with the key not found performed similarly, \nand both were the slowest. Linear search performs better than the other algorithms when the key was the first element \nin the array, while binary search and ternary search performed similarly whether the key was the first element, random\ninteger potentially present in the array, or an integer not present.\n\n![demo-1.gif](src/demo-1.gif)\n\nPython and C++ were the slowest languages, while Java and JavaScript performed the best.\n\nJavaScript had the fastest times for larger arrays on all algorithms except for merge sort, \nand Java came in second on several others. It is unclear why C++ performed so poorly compared to the other languages \nwhich are less optimized for speed, but perhaps this is a memory allocation issue. The issue will be further explored \nto provide more accurate results.\n\n![demo-2.gif](src/demo-2.gif)\n\n## Sources\n\nThis project was inspired by:\n* The searching algorithms demonstrated in multiple languages on GeeksforGeeks:\n  https://www.geeksforgeeks.org/searching-algorithms/\n* A sorting benchmark project by Ilya Frolov:\n  https://github.com/frolovilya/sorting-benchmark/","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonperk318%2Fsearching-algorithms","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonperk318%2Fsearching-algorithms","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonperk318%2Fsearching-algorithms/lists"}