diff --git a/app/visualizer/stack/implementation/usingArray/animation.jsx b/app/visualizer/stack/implementation/usingArray/animation.jsx deleted file mode 100755 index 7a923f8..0000000 --- a/app/visualizer/stack/implementation/usingArray/animation.jsx +++ /dev/null @@ -1,39 +0,0 @@ -"use client"; -import Footer from "@/app/components/footer"; -import ExploreOther from "@/app/components/ui/exploreOther"; -import Content from "@/app/visualizer/stack/implementation/usingArray/content"; -import CodeBlock from "@/app/visualizer/stack/implementation/usingArray/codeBlock"; -import GoBackButton from "@/app/components/ui/goback"; -import BackToTop from "@/app/components/ui/backtotop"; - -const InfixToPostfixVisualizer = () => { - return ( -
-
- - { /* go back block here */} -
- -
- - { /* main logic here */} -

- Stack Implementation -

-
- -

- - -
-
- -
- ); -}; - -export default InfixToPostfixVisualizer; diff --git a/app/visualizer/stack/implementation/usingArray/codeBlock.jsx b/app/visualizer/stack/implementation/usingArray/codeBlock.jsx index 24e7cbc..27f1e5d 100755 --- a/app/visualizer/stack/implementation/usingArray/codeBlock.jsx +++ b/app/visualizer/stack/implementation/usingArray/codeBlock.jsx @@ -420,10 +420,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/implementation/usingArray/content.jsx b/app/visualizer/stack/implementation/usingArray/content.jsx index 3f288e4..1dde175 100755 --- a/app/visualizer/stack/implementation/usingArray/content.jsx +++ b/app/visualizer/stack/implementation/usingArray/content.jsx @@ -1,4 +1,30 @@ +"use client"; +import React from "react"; +import { motion } from "framer-motion"; +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 push = [ { points: "Check if stack is full" }, { points: 'If full, return "Stack Overflow"' }, @@ -15,267 +41,233 @@ const content = () => { ]; const peek = [ - { points : "Check if stack is empty" }, - { points : "If empty, return null" }, - { points : "Return array[top] without removal" }, + { points: "Check if stack is empty" }, + { points: "If empty, return null" }, + { points: "Return array[top] without removal" }, ]; const isEmpty = [ - { points : "Return true if top pointer is -1" }, - { points : "Return false otherwise" }, + { points: "Return true if top pointer is -1" }, + { points: "Return false otherwise" }, ]; const initialize = [ - { points : "Create an empty array to store elements" }, - { points : "Initialize top pointer/index to -1" }, - { points : "Optional: Set maximum size limit" }, + { points: "Create an empty array to store elements" }, + { points: "Initialize top pointer/index to -1" }, + { points: "Optional: Set maximum size limit" }, ]; const isFull = [ - { points : "Return true if top equals (max_size - 1)" }, - { points : "Return false otherwise" }, + { points: "Return true if top equals (max_size - 1)" }, + { points: "Return false otherwise" }, ]; return ( -
-
- {/* Header Section */} -
-

- - What is Stack Implementation Using Array? -

-
-

- A stack is a linear data structure that follows the{" "}LIFO (Last In First Out){" "} - principle. Arrays provide a simple way to implement stack operations - with constant time complexity. -

-
-
- - {/* Core Operations */} -
-

- - Core Stack Operations -

-
- {["push(item)", "pop()", "peek()", "isEmpty()", "isFull()"].map( - (op) => ( -
+
+
+ {mounted && ( + + )} +
+
+ + Daily DSA Challenge by{" "} + - - {op} -
- ) - )} + Hello World + + +
-
- - {/* Algorithmic Steps */} -
-

- - Algorithmic Steps -

- -
- {/* Stack Basic Operations */} -
-

- Stack Basic Operations -

- -
- {/* Initialize Stack */} -
-

- Initialize Stack -

-
    - {initialize.map((item, index) => ( -
  1. - {item.points} -
  2. - ))} -
-
- - {/* Push Operation */} -
-

- push() -

-
    - {push.map((item, index) => ( -
  1. - {item.points} -
  2. - ))} -
-
- - {/* Pop Operation */} -
-

- pop() -

-
    - {pop.map((item, index) => ( -
  1. - {item.points} -
  2. - ))} -
-
+
+ {/* ------- HEADER ------- */} +
+

+ + What is Stack Implementation Using Array? +

+
+

+ A stack is a linear data structure that follows the LIFO (Last In First Out) principle. Arrays provide a simple way to implement stack operations with constant time complexity. +

-
+
- {/* Stack Helper Operations */} -
-

- Stack Helper Operations -

+ {/* ------- ALGORITHMIC STEPS – LIFT CARDS ------- */} +
+

+ + Algorithmic Steps +

-
- {/* Peek Operation */} -
-

- peek() -

-
    - {peek.map((item, index) => ( -
  1. - {item.points} -
  2. - ))} -
+
+ {/* Basic Operations */} +
+

Stack Basic Operations

+
+ {[{t:"Initialize Stack", s:initialize}, {t:"push()", s:push}, {t:"pop()", s:pop}].map( + ({t, s}, idx) => ( + + + Step {idx + 1} + +

{t}

+
    + {s.map((p, i) => ( +
  1. + {p.points} +
  2. + ))} +
+
+ ) + )} +
- {/* isEmpty Operation */} -
-

- isEmpty() -

-
    - {isEmpty.map((item, index) => ( -
  1. - {item.points} -
  2. - ))} -
+ {/* Helper Operations */} +
+

Stack Helper Operations

+
+ {[{t:"peek()", s:peek}, {t:"isEmpty()", s:isEmpty}, {t:"isFull()", s:isFull}].map( + ({t, s}, idx) => ( + + + Step {idx + 1} + +

{t}

+
    + {s.map((p, i) => ( +
  1. + {p.points} +
  2. + ))} +
+
+ ) + )} +
+
+
- {/* isFull Operation */} -
-

- isFull() -

-
    - {isFull.map((item, index) => ( -
  1. - {item.points} -
  2. +
    +

    + + Time Complexity +

    +
    + + + + + + + + + + {[ + ["push()", "O(1)", "Single array access"], + ["pop()", "O(1)", "Single array access"], + ["peek()", "O(1)", "Single array access"], + ["isEmpty()", "O(1)", "Pointer comparison"], + ].map(([op, comp, reason], index) => ( + + + + + ))} - - + +
    OperationComplexityReason
    {op}{comp}{reason}
    -
-
- + - {/* Visual Representation */} -
-

- - Visual Representation -

-
-
-
- 42 +
+

+ + Key Characteristics +

+
+
    + {[ + "LIFO Principle: Last element added is first removed", + "Dynamic Size: Can grow until memory limits", + "Efficiency: All operations work in constant time", + "Versatility: Foundation for many algorithms", + ].map((item) => ( +
  • + {item} +
  • + ))} +
-
- 17 -
-
- 8 (top) -
-
-
- Stack after operations: push(42), push(17), push(8) -
-
-
+ +
- {/* Time Complexity */} -
-

- - Time Complexity -

-
- - - - - - - - - - {[ - ["push()", "O(1)", "Single array access"], - ["pop()", "O(1)", "Single array access"], - ["peek()", "O(1)", "Single array access"], - ["isEmpty()", "O(1)", "Pointer comparison"], - ].map(([op, comp, reason], index) => ( - - - - - - ))} - -
OperationComplexity - Reason -
{op} - {comp} - - {reason} -
-
-
- - {/* Key Characteristics */} -
-

- - Key Characteristics -

-
-
    - {[ - "LIFO Principle: Last element added is first removed", - "Dynamic Size: Can grow until memory limits", - "Efficiency: All operations work in constant time", - "Versatility: Foundation for many algorithms", - ].map((item) => ( -
  • - {item} -
  • - ))} -
+ {/* Mobile iframe at bottom */} +
+ {mounted && ( + + )} +
+ + Daily DSA Challenge by{" "} + + Hello World + + +
-
- -
+ ); }; diff --git a/app/visualizer/stack/implementation/usingArray/page.jsx b/app/visualizer/stack/implementation/usingArray/page.jsx index 8a35df7..e583246 100755 --- a/app/visualizer/stack/implementation/usingArray/page.jsx +++ b/app/visualizer/stack/implementation/usingArray/page.jsx @@ -1,32 +1,104 @@ -import Animation from "@/app/visualizer/stack/implementation/usingArray/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/implementation/usingArray/content"; +import Code from "@/app/visualizer/stack/implementation/usingArray/codeBlock"; +import ModuleCard from "@/app/components/ui/ModuleCard"; +import { MODULE_MAPS } from "@/lib/modulesMap"; +import Footer from "@/app/components/footer"; +import ExploreOther from "@/app/components/ui/exploreOther"; +import BackToTopButton from "@/app/components/ui/backtotop"; export const metadata = { - title: 'Stack Implementation using Array | Learn Stack in DSA with JS, C, Python, Java Code', - description: 'Understand how to implement a Stack using an Array with visual explanations, animations, and complete code examples in JavaScript, C, Python, and Java. Perfect for DSA beginners and interview prep.', + title: + "Stack Implementation using Array | Learn Stack in DSA with JS, C, Python, Java Code", + description: + "Understand how to implement a Stack using an Array with visual explanations, animations, and complete code examples in JavaScript, C, Python, and Java. Perfect for DSA beginners and interview prep.", keywords: [ - 'Stack using Array', - 'Stack Implementation', - 'Stack Implementation in JavaScript', - 'Stack Implementation in C', - 'Stack Implementation in Python', - 'Stack Implementation in Java', - 'DSA Stack', - 'Array Stack', - 'Data Structures Stack', - 'Stack Push Pop Array', - 'Learn Stack DSA', - 'Visualize Stack Implementation', - 'Stack Code Examples', + "Stack using Array", + "Stack Implementation", + "Stack Implementation in JavaScript", + "Stack Implementation in C", + "Stack Implementation in Python", + "Stack Implementation in Java", + "DSA Stack", + "Array Stack", + "Data Structures Stack", + "Stack Push Pop Array", + "Learn Stack DSA", + "Visualize Stack Implementation", + "Stack Code Examples", ], - robots: 'index, follow', + robots: "index, follow", + openGraph: { + images: [ + { + url: "/og/stack/stackArray.png", + width: 1200, + height: 630, + alt: "Stack Implementation using Array", + }, + ], + }, }; -export default function Page(){ - return( +export default function Page() { + const paths = [ + { name: "Home", href: "/" }, + { name: "Visualizer", href: "/visualizer" }, + { name: "Stack : Implementation Using Array", href: "" }, + ]; + + return ( <> - - +
+ +
+ +
+
+
+ +
+ +
+
+

+ Stack +

+
+

+ Implementation Using Array +

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