ajay-dhangar / algo

This repository contains a collection of data structures and algorithms implemented in various programming languages. It is designed to help learners understand key concepts through hands-on examples. Contributions and improvements are welcome!
https://ajay-dhangar.github.io/algo/
MIT License
70 stars 223 forks source link

[Feature Request] Searching Algorithm #575

Closed Bhumika-00 closed 1 month ago

Bhumika-00 commented 1 month ago

🚀 Feature Request

A searching algorithm is a method used to locate a specific element or value within a data structure, such as an array, list, or tree. Searching algorithms can be classified into two main categories: linear and binary searches.

  1. Linear Search

Description: This is the simplest search algorithm. It sequentially checks each element in the data structure until it finds the target value or reaches the end of the structure.

Complexity:

Time Complexity: O(n), where n is the number of elements in the array.

Space Complexity: O(1), as it uses a constant amount of extra space.

Use Cases: Useful for unsorted or small datasets.

  1. Binary Search

Description: This algorithm is more efficient than linear search but requires the data to be sorted. It repeatedly divides the search interval in half. If the target value is less than the middle element, it continues searching in the left half; if it's greater, it searches the right half.

Complexity:

Time Complexity: O(log n).

Space Complexity: O(1) for the iterative version and O(log n) for the recursive version (due to call stack).

Use Cases: Ideal for large, sorted datasets.

  1. Other Searching Algorithms

Depth-First Search (DFS): Used in tree and graph structures, this algorithm explores as far down a branch as possible before backtracking.

Breadth-First Search (BFS): Also for trees and graphs, it explores all neighbor nodes at the present depth before moving on to nodes at the next depth level.

Interpolation Search: An improvement over binary search for uniformly distributed data, it estimates the position of the target value.

Exponential Search: Works on unbounded or infinite lists and finds the range where the target may exist before applying binary search.

Applications

Searching algorithms are fundamental in computer science and are widely used in various applications, including:

Database querying

Information retrieval systems

AI and machine learning

Networking and routing protocols

Choosing the right searching algorithm depends on the specific requirements of the application, such as the size of the dataset, whether it is sorted, and the need for efficiency.

Is your feature request related to a problem? Please describe.

A clear and concise description of what the problem is. Example: "I'm frustrated when I get question where this algorithm are used by default.

Describe the solution you'd like

I will include all the searching algorithms.

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.

Additional context

Add any other context or screenshots about the feature request here.


Would you like to work on this feature?

Bhumika-00 commented 1 month ago

I have completed this please review it

On Sat, 12 Oct, 2024, 5:17 pm Ajay Dhangar, @.***> wrote:

Assigned #575 https://github.com/ajay-dhangar/algo/issues/575 to @Bhumika-00 https://github.com/Bhumika-00.

— Reply to this email directly, view it on GitHub https://github.com/ajay-dhangar/algo/issues/575#event-14616767152, or unsubscribe https://github.com/notifications/unsubscribe-auth/BKOHTVRANEX5G7KTABXERVDZ3ED4RAVCNFSM6AAAAABP2ILPSWVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJUGYYTMNZWG4YTKMQ . You are receiving this because you were assigned.Message ID: @.***>