Skip to content

Commit

Permalink
added blogs
Browse files Browse the repository at this point in the history
  • Loading branch information
SrijaVuppala295 committed Oct 27, 2024
1 parent df2669f commit 4fde576
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 4 deletions.
2 changes: 1 addition & 1 deletion blog/dynamic-programming-breaking-down-complex-problems.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---

### 6. Dynamic Programming: Breaking Down Complex Problems
### Dynamic Programming: Breaking Down Complex Problems
slug: dynamic-programming-breaking-down-complex-problems
title: "Dynamic Programming: Breaking Down Complex Problems"
authors: [ADITYA-JANI]
Expand Down
4 changes: 1 addition & 3 deletions blog/greedy-algorithm.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
.

---

### 9. Greedy Algorithms: Making the Best Local Choice
### Greedy Algorithms: Making the Best Local Choice
slug: greedy-algorithms-making-the-best-local-choice
title: "Greedy Algorithms: Making the Best Local Choice"
authors: [AKSHITHA-CHILUKA]
Expand Down
70 changes: 70 additions & 0 deletions blog/searching-algorithms-finding-your-way-through-data.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@


### Searching Algorithms: Finding Your Way Through Data
slug: searching-algorithms-finding-your-way-through-data
title: "Searching Algorithms: Finding Your Way Through Data"
authors: [Rishi-Verma]
tags: [Rishi-Verma, algorithms, dsa, searching-algorithms, data-structures, optimization, coding, programming, computer-science, learning]
---

Searching algorithms are essential for retrieving data from data structures efficiently. They enable us to find specific elements within a dataset, which is a fundamental operation in computer science and programming.

In this blog, we’ll cover:

- **What are Searching Algorithms?**
- **Types of Searching Algorithms**
- **Common Searching Algorithms**
- **Performance Considerations**

## What are Searching Algorithms?

Searching algorithms are methods used to locate a specific value or set of values within a data structure. The choice of algorithm depends on the structure and organization of the data, as well as the required performance characteristics.

## Types of Searching Algorithms

1. **Linear Search**: A straightforward method that checks each element in a list sequentially until the target value is found or the list is exhausted.
2. **Binary Search**: A more efficient method that works on sorted lists by repeatedly dividing the search interval in half.

### Example of Linear Search:

```python
def linear_search(arr, target):
for index, value in enumerate(arr):
if value == target:
return index
return -1
```

### Example of Binary Search:

```python
def binary_search(arr, target):
left, right = 0, len(arr) - 1
while left <= right:
mid = left + (right - left) // 2
if arr[mid] == target:
return mid
elif arr[mid] < target:
left = mid + 1
else:
right = mid - 1
return -1
```

## Common Searching Algorithms

1. **Linear Search**: O(n)
2. **Binary Search**: O(log n) (requires a sorted array)
3. **Ternary Search**: Similar to binary search but divides the array into three parts.
4. **Interpolation Search**: A refined version of binary search that uses a probe position to improve search efficiency.

## Performance Considerations

- **Time Complexity**: Analyzing the time complexity helps determine the efficiency of a searching algorithm. For large datasets, binary search is preferable due to its logarithmic time complexity.
- **Space Complexity**: Consider how much additional memory an algorithm uses. Most searching algorithms have a space complexity of O(1).

## Conclusion

Searching algorithms are vital for efficiently accessing and retrieving data in various applications. By understanding the different types and their use cases, you can choose the most appropriate searching method for your programming tasks.

---

0 comments on commit 4fde576

Please sign in to comment.