From 5b898330477e49dd51178acf6afdff0ffb04355c Mon Sep 17 00:00:00 2001 From: Ajay-Dhangar Date: Wed, 25 Sep 2024 07:07:57 +0530 Subject: [PATCH 1/3] Fixed issue --- docs/dsa/algorithms/searching_algorithm.md | 4 ++++ src/components/Lesson/index.tsx | 5 ++--- .../LinearSearchVisualizer/index.tsx | 11 ++++++++++- src/pages/about/index.tsx | 2 +- src/pages/blogs/index.tsx | 10 +--------- 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/docs/dsa/algorithms/searching_algorithm.md b/docs/dsa/algorithms/searching_algorithm.md index d8a8e0203..ed0dbb6bc 100644 --- a/docs/dsa/algorithms/searching_algorithm.md +++ b/docs/dsa/algorithms/searching_algorithm.md @@ -20,6 +20,10 @@ Searching is a fundamental operation in computer science and is widely used in v 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. + + +
+ ```python def linear_search(arr, target): for i in range(len(arr)): diff --git a/src/components/Lesson/index.tsx b/src/components/Lesson/index.tsx index 265964008..bae4f4b13 100644 --- a/src/components/Lesson/index.tsx +++ b/src/components/Lesson/index.tsx @@ -10,13 +10,12 @@ interface LessonProps { /** * Lesson component displays a single lesson with its title, description, and tags. - * @param id - Unique identifier for the lesson. * @param title - Title of the lesson. * @param tags - Array of tags associated with the lesson. * @param description - Description or content of the lesson. * @returns JSX element representing the lesson. */ -const Lesson: React.FC = ({ id, title, tags, description }) => { +const Lesson: React.FC = ({ title, tags, description }) => { return (
{/* Container for the lesson */}

{title}

{/* Title of the lesson */} @@ -31,4 +30,4 @@ const Lesson: React.FC = ({ id, title, tags, description }) => { ); }; -export default Lesson; +export default Lesson; \ No newline at end of file diff --git a/src/dsa/searching-algorithms/LinearSearchVisualizer/index.tsx b/src/dsa/searching-algorithms/LinearSearchVisualizer/index.tsx index 30f4cf7f6..799ae05f4 100644 --- a/src/dsa/searching-algorithms/LinearSearchVisualizer/index.tsx +++ b/src/dsa/searching-algorithms/LinearSearchVisualizer/index.tsx @@ -42,9 +42,15 @@ const LinearSearchVisualizer: React.FC = () => { setSearching(false); }; + const shuffleArray = () => { + const shuffledArray = [...array].sort(() => Math.random() - 0.5); + setArray(shuffledArray); + resetVisualization(); + }; + return (
- Linear Search Visualization + Linear Search Visualization
{array.map((num, index) => (
{ +
); diff --git a/src/pages/about/index.tsx b/src/pages/about/index.tsx index bb467e009..e249d97e3 100644 --- a/src/pages/about/index.tsx +++ b/src/pages/about/index.tsx @@ -4,7 +4,7 @@ import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; import React from "react"; import Head from "@docusaurus/Head"; -export default function About() { +export default function About(): React.JSX.Element { const { siteConfig } = useDocusaurusContext(); return ( Date: Wed, 25 Sep 2024 01:39:41 +0000 Subject: [PATCH 2/3] Restyled by prettier-markdown --- docs/dsa/algorithms/searching_algorithm.md | 51 +++------------------- 1 file changed, 7 insertions(+), 44 deletions(-) diff --git a/docs/dsa/algorithms/searching_algorithm.md b/docs/dsa/algorithms/searching_algorithm.md index ed0dbb6bc..a26f654e6 100644 --- a/docs/dsa/algorithms/searching_algorithm.md +++ b/docs/dsa/algorithms/searching_algorithm.md @@ -4,14 +4,9 @@ title: Searching in Data Structures and Algorithms sidebar_label: Searching Algorithm sidebar_position: 1 description: "" -tags: - [dsa,data-algorithms , searching - ] +tags: [dsa, data-algorithms, searching] --- - - - 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. ![alt text](image.png) @@ -73,8 +68,8 @@ Remember to provide appropriate input and handle edge cases when implementing th ## Additional Questions 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: - - **Input:** Array: [5, 2, 9, 7, 3], Target: 9 - - **Output:** Index: 2 + - **Input:** Array: [5, 2, 9, 7, 3], Target: 9 + - **Output:** Index: 2 ```cpp #include @@ -100,8 +95,8 @@ int main() { ``` 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: - - **Input:** Array: [1, 3, 5, 7, 9], Target: 5 - - **Output:** Index: 2 + - **Input:** Array: [1, 3, 5, 7, 9], Target: 5 + - **Output:** Index: 2 ```java public class BinarySearch { @@ -131,8 +126,8 @@ public class BinarySearch { ``` 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: - - **Input:** Dictionary: ```{"apple": 1, "banana": 2, "orange": 3}```, Key: "banana" - - **Output:** Value: 2 + - **Input:** Dictionary: `{"apple": 1, "banana": 2, "orange": 3}`, Key: "banana" + - **Output:** Value: 2 ```python hash_map = { @@ -148,7 +143,6 @@ print("Value:", value) Remember to provide appropriate input and handle edge cases when implementing these algorithms to ensure correct results. - 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. 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. @@ -161,37 +155,6 @@ When implementing these algorithms, it is important to provide appropriate input Overall, understanding and implementing different searching algorithms is crucial for efficient data retrieval and manipulation in various programming scenarios. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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. 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. From 8f67ca2680c09d91381836e5bf482f168afe1b5a Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Wed, 25 Sep 2024 01:39:41 +0000 Subject: [PATCH 3/3] Restyled by whitespace --- src/components/Lesson/index.tsx | 4 ++-- src/dsa/searching-algorithms/LinearSearchVisualizer/index.tsx | 2 +- src/pages/about/index.tsx | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/Lesson/index.tsx b/src/components/Lesson/index.tsx index bae4f4b13..b51d6eb59 100644 --- a/src/components/Lesson/index.tsx +++ b/src/components/Lesson/index.tsx @@ -22,7 +22,7 @@ const Lesson: React.FC = ({ title, tags, description }) => {

{description}

{/* Description or content of the lesson */}
{/* Container for tags */} {tags.map((tag, index) => ( - {tag} + {tag} )) }
@@ -30,4 +30,4 @@ const Lesson: React.FC = ({ title, tags, description }) => { ); }; -export default Lesson; \ No newline at end of file +export default Lesson; diff --git a/src/dsa/searching-algorithms/LinearSearchVisualizer/index.tsx b/src/dsa/searching-algorithms/LinearSearchVisualizer/index.tsx index 799ae05f4..f9ecaed61 100644 --- a/src/dsa/searching-algorithms/LinearSearchVisualizer/index.tsx +++ b/src/dsa/searching-algorithms/LinearSearchVisualizer/index.tsx @@ -85,4 +85,4 @@ const LinearSearchVisualizer: React.FC = () => { ); }; -export default LinearSearchVisualizer; \ No newline at end of file +export default LinearSearchVisualizer; diff --git a/src/pages/about/index.tsx b/src/pages/about/index.tsx index e249d97e3..3c099a531 100644 --- a/src/pages/about/index.tsx +++ b/src/pages/about/index.tsx @@ -23,7 +23,7 @@ export default function About(): React.JSX.Element { src="https://cdn.ampproject.org/v0/amp-auto-ads-0.1.js" /> - +
);