Skip to content

Commit 6338ba5

Browse files
authored
Merge pull request #4446 from CodeHarborHub/dev-3
Fixed issue
2 parents 2280a91 + cfad89f commit 6338ba5

File tree

5 files changed

+27
-60
lines changed

5 files changed

+27
-60
lines changed

docs/dsa/algorithms/searching_algorithm.md

Lines changed: 11 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,9 @@ title: Searching in Data Structures and Algorithms
44
sidebar_label: Searching Algorithm
55
sidebar_position: 1
66
description: ""
7-
tags:
8-
[dsa,data-algorithms , searching
9-
]
7+
tags: [dsa, data-algorithms, searching]
108
---
119

12-
13-
14-
1510
Searching is a fundamental operation in computer science and is widely used in various applications. In the context of Data Structures and Algorithms (DSA), searching refers to the process of finding a specific element within a collection of data.
1611

1712
![alt text](image.png)
@@ -20,6 +15,10 @@ Searching is a fundamental operation in computer science and is widely used in v
2015

2116
Linear search is a simple algorithm that sequentially checks each element in a collection until the target element is found or the end of the collection is reached. It is commonly used for small collections or unsorted data.
2217

18+
<LinearSearchVisualizer />
19+
20+
<br />
21+
2322
```python
2423
def linear_search(arr, target):
2524
for i in range(len(arr)):
@@ -69,8 +68,8 @@ Remember to provide appropriate input and handle edge cases when implementing th
6968
## Additional Questions
7069

7170
1. **Question:** Implement a linear search algorithm in C++ to find the index of a target element in an array. Provide the input and output for the following scenario:
72-
- **Input:** Array: [5, 2, 9, 7, 3], Target: 9
73-
- **Output:** Index: 2
71+
- **Input:** Array: [5, 2, 9, 7, 3], Target: 9
72+
- **Output:** Index: 2
7473

7574
```cpp
7675
#include <iostream>
@@ -96,8 +95,8 @@ int main() {
9695
```
9796
9897
2. **Question:** Write a binary search algorithm in Java to find the index of a target element in a sorted array. Provide the input and output for the following scenario:
99-
- **Input:** Array: [1, 3, 5, 7, 9], Target: 5
100-
- **Output:** Index: 2
98+
- **Input:** Array: [1, 3, 5, 7, 9], Target: 5
99+
- **Output:** Index: 2
101100
102101
```java
103102
public class BinarySearch {
@@ -127,8 +126,8 @@ public class BinarySearch {
127126
```
128127

129128
3. **Question:** Implement a hash-based search algorithm in Python to retrieve the value associated with a given key in a dictionary. Provide the input and output for the following scenario:
130-
- **Input:** Dictionary: ```{"apple": 1, "banana": 2, "orange": 3}```, Key: "banana"
131-
- **Output:** Value: 2
129+
- **Input:** Dictionary: `{"apple": 1, "banana": 2, "orange": 3}`, Key: "banana"
130+
- **Output:** Value: 2
132131

133132
```python
134133
hash_map = {
@@ -144,7 +143,6 @@ print("Value:", value)
144143

145144
Remember to provide appropriate input and handle edge cases when implementing these algorithms to ensure correct results.
146145

147-
148146
In conclusion, searching is a fundamental operation in computer science and is widely used in various applications. In the context of Data Structures and Algorithms (DSA), there are several types of searching algorithms, including linear search, binary search, and hash-based search. Each algorithm has its own characteristics and is suitable for different scenarios.
149147

150148
Linear search is a simple algorithm that sequentially checks each element in a collection until the target element is found or the end of the collection is reached. It is commonly used for small collections or unsorted data.
@@ -157,37 +155,6 @@ When implementing these algorithms, it is important to provide appropriate input
157155

158156
Overall, understanding and implementing different searching algorithms is crucial for efficient data retrieval and manipulation in various programming scenarios.
159157

160-
161-
162-
163-
164-
165-
166-
167-
168-
169-
170-
171-
172-
173-
174-
175-
176-
177-
178-
179-
180-
181-
182-
183-
184-
185-
186-
187-
188-
189-
190-
191158
Searching is a fundamental operation in computer science and is widely used in various applications. In the context of Data Structures and Algorithms (DSA), searching refers to the process of finding a specific element within a collection of data.
192159

193160
There are several types of searching algorithms commonly used in DSA, including linear search, binary search, hash-based search, and tree-based search. Each algorithm has its own characteristics and is suitable for different scenarios.

src/components/Lesson/index.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,19 @@ interface LessonProps {
1010

1111
/**
1212
* Lesson component displays a single lesson with its title, description, and tags.
13-
* @param id - Unique identifier for the lesson.
1413
* @param title - Title of the lesson.
1514
* @param tags - Array of tags associated with the lesson.
1615
* @param description - Description or content of the lesson.
1716
* @returns JSX element representing the lesson.
1817
*/
19-
const Lesson: React.FC<LessonProps> = ({ id, title, tags, description }) => {
18+
const Lesson: React.FC<LessonProps> = ({ title, tags, description }) => {
2019
return (
2120
<div className="lesson"> {/* Container for the lesson */}
2221
<h2 className="lesson-title">{title}</h2> {/* Title of the lesson */}
2322
<p className="lesson-description">{description}</p> {/* Description or content of the lesson */}
2423
<div className="lesson-tags"> {/* Container for tags */}
2524
{tags.map((tag, index) => (
26-
<span key={index} className="lesson-tag">{tag}</span>
25+
<span key={index} className="lesson-tag">{tag}</span>
2726
))
2827
}
2928
</div>

src/dsa/searching-algorithms/LinearSearchVisualizer/index.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,15 @@ const LinearSearchVisualizer: React.FC = () => {
4242
setSearching(false);
4343
};
4444

45+
const shuffleArray = () => {
46+
const shuffledArray = [...array].sort(() => Math.random() - 0.5);
47+
setArray(shuffledArray);
48+
resetVisualization();
49+
};
50+
4551
return (
4652
<div className="linear-search-container">
47-
<Heading as="h2">Linear Search Visualization</Heading>
53+
<Heading as="h2">Linear Search Visualization</Heading>
4854
<div className="array-container">
4955
{array.map((num, index) => (
5056
<div
@@ -71,9 +77,12 @@ const LinearSearchVisualizer: React.FC = () => {
7177
<button onClick={resetVisualization} disabled={!searching && !target}>
7278
Reset
7379
</button>
80+
<button onClick={shuffleArray} disabled={searching}>
81+
Shuffle Array
82+
</button>
7483
</div>
7584
</div>
7685
);
7786
};
7887

79-
export default LinearSearchVisualizer;
88+
export default LinearSearchVisualizer;

src/pages/about/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
44
import React from "react";
55
import Head from "@docusaurus/Head";
66

7-
export default function About() {
7+
export default function About(): React.JSX.Element {
88
const { siteConfig } = useDocusaurusContext();
99
return (
1010
<Layout
@@ -23,7 +23,7 @@ export default function About() {
2323
src="https://cdn.ampproject.org/v0/amp-auto-ads-0.1.js"
2424
/>
2525
<meta name="google-adsense-account" content="ca-pub-5832817025080991" />
26-
</Head>
26+
</Head>
2727
<AboutUsSection />
2828
</Layout>
2929
);

src/pages/blogs/index.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,7 @@ import Link from "@docusaurus/Link";
66
import blogs from "../../database/blogs";
77
import Head from "@docusaurus/Head";
88

9-
// interface Blog {
10-
// id: number;
11-
// title: string;
12-
// image: string;
13-
// description: string;
14-
// slug: string;
15-
// }
16-
17-
export default function Blogs() {
9+
export default function Blogs(): React.JSX.Element {
1810
const { siteConfig } = useDocusaurusContext();
1911

2012
return (

0 commit comments

Comments
 (0)