Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/dsa/algorithms/searching_algorithm.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<LinearSearchVisualizer />

<br />

```python
def linear_search(arr, target):
for i in range(len(arr)):
Expand Down
5 changes: 2 additions & 3 deletions src/components/Lesson/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<LessonProps> = ({ id, title, tags, description }) => {
const Lesson: React.FC<LessonProps> = ({ title, tags, description }) => {
return (
<div className="lesson"> {/* Container for the lesson */}
<h2 className="lesson-title">{title}</h2> {/* Title of the lesson */}
Expand All @@ -31,4 +30,4 @@ const Lesson: React.FC<LessonProps> = ({ id, title, tags, description }) => {
);
};

export default Lesson;
export default Lesson;
11 changes: 10 additions & 1 deletion src/dsa/searching-algorithms/LinearSearchVisualizer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,15 @@ const LinearSearchVisualizer: React.FC = () => {
setSearching(false);
};

const shuffleArray = () => {
const shuffledArray = [...array].sort(() => Math.random() - 0.5);
setArray(shuffledArray);
resetVisualization();
};

return (
<div className="linear-search-container">
<Heading as="h2">Linear Search Visualization</Heading>
<Heading as="h2">Linear Search Visualization</Heading>
<div className="array-container">
{array.map((num, index) => (
<div
Expand All @@ -71,6 +77,9 @@ const LinearSearchVisualizer: React.FC = () => {
<button onClick={resetVisualization} disabled={!searching && !target}>
Reset
</button>
<button onClick={shuffleArray} disabled={searching}>
Shuffle Array
</button>
</div>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/about/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Layout
Expand Down
10 changes: 1 addition & 9 deletions src/pages/blogs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,7 @@ import Link from "@docusaurus/Link";
import blogs from "../../database/blogs";
import Head from "@docusaurus/Head";

// interface Blog {
// id: number;
// title: string;
// image: string;
// description: string;
// slug: string;
// }

export default function Blogs() {
export default function Blogs(): React.JSX.Element {
const { siteConfig } = useDocusaurusContext();

return (
Expand Down
Loading