diff --git a/app/visualizer/stack/isempty/page.jsx b/app/visualizer/stack/isempty/page.jsx index 659816f..7868874 100644 --- a/app/visualizer/stack/isempty/page.jsx +++ b/app/visualizer/stack/isempty/page.jsx @@ -37,7 +37,7 @@ export const metadata = { url: "/og/stack/isEmpty.png", width: 1200, height: 630, - alt: "Stack Peek Visualization", + alt: "Stack isEmpty Visualization", }, ], }, diff --git a/app/visualizer/stack/isfull/animation.jsx b/app/visualizer/stack/isfull/animation.jsx index b67481a..8b85d3e 100644 --- a/app/visualizer/stack/isfull/animation.jsx +++ b/app/visualizer/stack/isfull/animation.jsx @@ -1,202 +1,161 @@ -'use client'; -import React, { useState, useEffect } from 'react'; -import Footer from '@/app/components/footer'; -import Content from '@/app/visualizer/stack/isfull/content'; -import CodeBlock from '@/app/visualizer/stack/isfull/codeBlock'; -import ExploreOther from '@/app/components/ui/exploreOther'; -import PushPop from '@/app/components/ui/PushPop'; -import GoBackButton from "@/app/components/ui/goback"; -import Quiz from '@/app/visualizer/stack/isfull/quiz'; -import BackToTop from '@/app/components/ui/backtotop'; +"use client"; +import React, { useState, useEffect } from "react"; +import PushPop from "@/app/components/ui/PushPop"; const StackVisualizer = () => { - const [stack, setStack] = useState([]); - const [operation, setOperation] = useState(null); - const [message, setMessage] = useState('Stack is empty'); - const [isAnimating, setIsAnimating] = useState(false); - const [stackLimit] = useState(5); // Set stack capacity - const [isFull, setIsFull] = useState(false); - - // Check if stack is full - const checkIfFull = () => { - setIsAnimating(true); - setOperation('Checking if stack is full...'); - - setTimeout(() => { - const fullStatus = stack.length >= stackLimit; - setIsFull(fullStatus); - setOperation(null); - setMessage(fullStatus ? 'Stack is FULL!' : 'Stack is NOT full'); - setIsAnimating(false); - }, 1000); - }; - - // Reset stack - const reset = () => { - setStack([]); - setMessage('Stack is empty'); - setOperation(null); - setIsFull(false); - }; - - // Effect to update isFull status when stack changes - useEffect(() => { - setIsFull(stack.length >= stackLimit); - }, [stack, stackLimit]); - - return ( -
-
- {/* go back block here */} -
- -
- - {/* main logic here */} -

- Stack IsFull -

-
- -

- Visualize the LIFO (Last In, First Out) principle -

- -
- {/* Use the PushPop component */} - - - {/* Is Full Check Button */} - + + {/* Stack Visualization */} +
+

Stack Visualization

+ + {/* Operation Status */} + {operation && ( +
+ {operation} +
+ )} + + {/* Message Display */} + {message && ( +
- Check If Full - - - {/* Stack Visualization */} -
-

- Stack Visualization -

- - {/* Operation Status */} - {operation && ( -
- {operation} -
- )} + {message} +
+ )} - {/* Message Display */} - {message && ( -
- {message} -
- )} + {/* Stack capacity indicator */} +
+ Capacity: {stack.length}/{stackLimit} +
- {/* Stack capacity indicator */} -
- Capacity: {stack.length}/{stackLimit} -
+ {/* Vertical Stack */} +
+ {/* Top indicator */} +
+ {stack.length > 0 ? "↑ Top" : ""} +
- {/* Vertical Stack */} -
- {/* Top indicator */} -
- {stack.length > 0 ? "↑ Top" : ""} + {/* Stack elements with full state animation */} +
+ {stack.length === 0 ? ( +
+ Stack is empty
- - {/* Stack elements with full state animation */} -
- {stack.length === 0 ? ( -
- Stack is empty -
- ) : ( -
- {stack.map((item, index) => ( -
- {item} - {index === 0 && ( -
- (Top) -
- )} + ) : ( +
+ {stack.map((item, index) => ( +
+ {item} + {index === 0 && ( +
+ (Top)
- ))} + )}
- )} + ))}
+ )} +
- {/* Bottom indicator */} -
- {stack.length > 0 ? "↓ Bottom" : ""} -
-
+ {/* Bottom indicator */} +
+ {stack.length > 0 ? "↓ Bottom" : ""}
- - {/* quiz block here */} -

- Test Your Knowledge before moving forward! -

- - - - -
-
- -
- ); + + ); }; -export default StackVisualizer; \ No newline at end of file +export default StackVisualizer; diff --git a/app/visualizer/stack/isfull/codeBlock.jsx b/app/visualizer/stack/isfull/codeBlock.jsx index 9d32db8..72c4dc5 100644 --- a/app/visualizer/stack/isfull/codeBlock.jsx +++ b/app/visualizer/stack/isfull/codeBlock.jsx @@ -390,10 +390,10 @@ int main() { initial={{ opacity: 0, y: 20 }} animate={{ opacity: 1, y: 0 }} transition={{ duration: 0.3 }} - className="bg-white dark:bg-gray-800 rounded-xl shadow-lg overflow-hidden border border-gray-200 dark:border-gray-700 transition-colors duration-300" + className="bg-white dark:bg-neutral-950 rounded-xl shadow-lg overflow-hidden border border-gray-200 dark:border-gray-700 transition-colors duration-300" > {/* Header */} -
+

diff --git a/app/visualizer/stack/isfull/content.jsx b/app/visualizer/stack/isfull/content.jsx index 9cfeeae..b32ebaa 100644 --- a/app/visualizer/stack/isfull/content.jsx +++ b/app/visualizer/stack/isfull/content.jsx @@ -1,169 +1,246 @@ -import { parseAlpha } from "@tsparticles/engine"; -import { use } from "react"; +"use client"; +import ComplexityGraph from "@/app/components/ui/graph"; +import { useEffect, useState } from "react"; + +const content = () => { + const [theme, setTheme] = useState("light"); + const [mounted, setMounted] = useState(false); + + useEffect(() => { + const updateTheme = () => { + const savedTheme = localStorage.getItem("theme") || "light"; + setTheme(savedTheme); + }; + + updateTheme(); + setMounted(true); + + window.addEventListener("storage", updateTheme); + window.addEventListener("themeChange", updateTheme); + + return () => { + window.removeEventListener("storage", updateTheme); + window.removeEventListener("themeChange", updateTheme); + }; + }, []); -const Content = () => { const paragraphs = [ `The Is Full operation checks whether a stack has reached its maximum capacity. This is particularly relevant for fixed-size stack implementations (arrays) rather than dynamic implementations (linked lists).`, `The Is Full operation is crucial when working with fixed-size stacks to prevent overflow errors. While not needed for dynamically-sized stacks, it's an essential safety check in many system-level implementations.`, ]; const working = [ - { points : "Returns true if the stack cannot accept more elements." }, - { points : "Returns false if the stack can accept more elements." }, - { points : "For dynamic stacks (no fixed size), this operation typically always returns false." }, - { points : "Often used with Push operations to prevent stack overflow." }, + { points: "Returns true if the stack cannot accept more elements." }, + { points: "Returns false if the stack can accept more elements." }, + { + points: + "For dynamic stacks (no fixed size), this operation typically always returns false.", + }, + { points: "Often used with Push operations to prevent stack overflow." }, ]; const complexity = [ - { points : "Fixed-size Stack:", - subpoints : [ - "Time Complexity: O(1)", - "Space Complexity: O(1)", - ], - }, - { points : "Dynamic Stack:", - subpoints : [ - "Time Complexity: O(1)", - "Space Complexity: O(1)", - ], - }, + { + points: "Fixed-size Stack:", + subpoints: ["Time Complexity: O(1)", "Space Complexity: O(1)"], + }, + { + points: "Dynamic Stack:", + subpoints: ["Time Complexity: O(1)", "Space Complexity: O(1)"], + }, ]; const useCase = [ - { points : "Preventing stack overflow in memory-constrained systems." }, - { points : "Implementing bounded buffers or fixed-size caches." }, - { points : "Memory management in embedded systems." }, - { points : "Validating stack capacity before push operations" }, + { points: "Preventing stack overflow in memory-constrained systems." }, + { points: "Implementing bounded buffers or fixed-size caches." }, + { points: "Memory management in embedded systems." }, + { points: "Validating stack capacity before push operations" }, ]; return ( -
-
- {/* What is the "Is Full" Operation? */} -
-

- - What is the "Is Full" Operation? -

-
-

- {paragraphs[0]} -

-
-
- - {/* How It Works */} -
-

- - How It Works -

-
-
    - {working.map((item, index) => ( -
  • - {item.points} -
  • - ))} -
-
-
- - {/* Time and Space Complexity */} -
-

- - Time and Space Complexity -

-
-

- Here's the time and space complexity analysis for stack operations: -

-
    - {complexity.map((item, index) => ( -
  • - - {item.points.split(':')[0]}: - - {item.points.split(':')[1]} - {item.subpoints && ( -
      - {item.subpoints.map((subitem, subindex) => ( -
    • - {subitem} -
    • - ))} -
    - )} -
  • - ))} -
+
+
+
+ {mounted && ( + + )} +
+
+ + Daily DSA Challenge by{" "} + + Hello World + + +
-
- - {/* Practical Example */} -
-

- - Practical Example -

-
-

- Consider a stack with maximum capacity of 3 elements: -

-
-
-
Stack: [ ]
-
- isFull() → false +
+ {/* What is the "Is Full" Operation? */} +
+

+ + What is the "Is Full" Operation? +

+
+

+ {paragraphs[0]} +

+
+
+ + {/* How It Works */} +
+

+ + How It Works +

+
+
    + {working.map((item, index) => ( +
  • + {item.points} +
  • + ))} +
+
+
+ + {/* Time and Space Complexity */} +
+

+ + Time and Space Complexity +

+
+

+ Here's the time and space complexity analysis for stack + operations: +

+
    + {complexity.map((item, index) => ( +
  • + + {item.points.split(":")[0]}: + + {item.points.split(":")[1]} + {item.subpoints && ( +
      + {item.subpoints.map((subitem, subindex) => ( +
    • + {subitem} +
    • + ))} +
    + )} +
  • + ))} +
+ +
+ 1} + averageCase={(n) => 1} + worstCase={(n) => 1} + maxN={25} + />
-
-
Stack: [5, 3]
-
- isFull() → false +
+ + {/* Practical Example */} +
+

+ + Practical Example +

+
+

+ Consider a stack with maximum capacity of 3 elements: +

+
+
+
Stack: [ ]
+
+ isFull() →{" "} + false +
+
+
+
Stack: [5, 3]
+
+ isFull() →{" "} + false +
+
+
+
Stack: [7, 3, 5]
+
+ isFull() →{" "} + + true + +
+
-
-
Stack: [7, 3, 5]
-
- isFull() → true +
+ + {/* Common Use Cases */} +
+

+ + Common Use Cases +

+
+
    + {useCase.map((item, index) => ( +
  • + {item.points} +
  • + ))} +
+
+
+ + {/* Additional Info */} +
+
+
+

+ {paragraphs[1]} +

-
-
-
- - {/* Common Use Cases */} -
-

- - Common Use Cases -

-
-
    - {useCase.map((item, index) => ( -
  • - {item.points} -
  • - ))} -
-
-
- - {/* Additional Info */} -
-
-
-

- {paragraphs[1]} -

-
-
-
-
-
+ + + ); }; -export default Content; +export default content; diff --git a/app/visualizer/stack/isfull/page.jsx b/app/visualizer/stack/isfull/page.jsx index 0993c10..f58d8ce 100644 --- a/app/visualizer/stack/isfull/page.jsx +++ b/app/visualizer/stack/isfull/page.jsx @@ -1,31 +1,119 @@ import Animation from "@/app/visualizer/stack/isfull/animation"; import Navbar from "@/app/components/navbarinner"; +import Breadcrumbs from "@/app/components/ui/Breadcrumbs"; +import ArticleActions from "@/app/components/ui/ArticleActions"; +import Content from "@/app/visualizer/stack/isfull/content"; +import Quiz from "@/app/visualizer/stack/isfull/quiz"; +import Code from "@/app/visualizer/stack/isfull/codeBlock"; +import ModuleCard from "@/app/components/ui/ModuleCard"; +import { MODULE_MAPS } from "@/lib/modulesMap"; +import ExploreOther from '@/app/components/ui/exploreOther'; +import Footer from "@/app/components/footer"; +import BackToTopButton from "@/app/components/ui/backtotop"; export const metadata = { - title: 'Stack Is Full Visualizer | Check Full Condition in Stack with Code in JS, C, Python, Java', - description: 'Understand how to check if a Stack is full using interactive animations and code examples in JavaScript, C, Python, and Java. A simple guide for beginners and DSA interview preparation.', + title: + "Stack Is Full Visualizer | Check Full Condition in Stack with Code in JS, C, Python, Java", + description: + "Understand how to check if a Stack is full using interactive animations and code examples in JavaScript, C, Python, and Java. A simple guide for beginners and DSA interview preparation.", keywords: [ - 'Stack Is Full', - 'Is Full Operation Stack', - 'Stack Full Condition', - 'Stack Capacity Check', - 'DSA Stack Animation', - 'Learn Stack Operations', - 'Stack in JavaScript', - 'Stack in C', - 'Stack in Python', - 'Stack in Java', - 'Stack Code Examples', - 'Stack Overflow Condition', + "Stack Is Full", + "Is Full Operation Stack", + "Stack Full Condition", + "Stack Capacity Check", + "DSA Stack Animation", + "Learn Stack Operations", + "Stack in JavaScript", + "Stack in C", + "Stack in Python", + "Stack in Java", + "Stack Code Examples", + "Stack Overflow Condition", ], robots: "index, follow", + openGraph: { + images: [ + { + url: "/og/stack/isFull.png", + width: 1200, + height: 630, + alt: "Stack isFull Visualization", + }, + ], + }, }; export default function Page() { - return( + const paths = [ + { name: "Home", href: "/" }, + { name: "Visualizer", href: "/visualizer" }, + { name: "Stack : IsFull", href: "" }, + ]; + + return ( <> - - +
+ +
+ +
+
+
+ +
+
+
+

+ Stack +

+
+

+ IsFull Operation +

+ +
+
+ +
+ +
+ +
+ +
+

+ Test Your Knowledge before moving forward! +

+ +
+ +
+ +
+ +
+ +
+ +
+ +
+
+ + +