-
- {paragraphs[1]}
-
+
+ {/* What is Stack Push & Pop */}
+
+
+
+ What is Stack Push & Pop?
+
+
+
+
+ {/* Push Operation */}
+
+
+
+ Push Operation
+
+
+
+ Adds an element to the top of the stack.
+
+
+ Example: Pushing elements onto a stack
+
+
+ {examplePush.map((item, index) => (
+ -
+ {item.points}
+
+ ))}
+
+
+ {pushComplexity.map((item, index) => (
+ -
+
+ {item.points.split(":")[0]}:
+
+ {item.points.split(":")[1]}
+
+ ))}
+
+
+
+
+ {/* Pop Operation */}
+
+
+
+ Pop Operation
+
+
+
+ Removes and returns the topmost element from the stack.
+
+
+ Example: Popping elements from a stack
+
+
+ {examplePop.map((item, index) => (
+ -
+ {item.points}
+
+ ))}
+
+
+ {popComplexity.map((item, index) => (
+ -
+
+ {item.points.split(":")[0]}:
+
+ {item.points.split(":")[1]}
+
+ ))}
+
+
+
+ 1}
+ averageCase={(n) => 1}
+ worstCase={(n) => 1}
+ maxN={25}
+ />
+
+
+
+
+ {/* Stack Underflow & Overflow */}
+
+
+
+ Stack Underflow & Overflow
+
+
+
+ {combineData.map((item, index) => (
+ -
+ {item.title}:{" "}
+ {item.detail}
+
+ ))}
+
+
+
+
+ {/* Real-world Applications */}
+
+
+
+ Real-world Applications
+
+
+
+ {applications.map((items, index) => (
+ -
+ {items.points}
+
+ ))}
+
+
+
+
+ {/* Additional Info */}
+
+
+
+ {/* Mobile iframe at bottom */}
+
-
-
-
- );
- };
-
- export default content;
\ No newline at end of file
+
+ );
+};
+
+export default content;
diff --git a/app/visualizer/stack/push-pop/page.jsx b/app/visualizer/stack/push-pop/page.jsx
index 12408fb..0d9c69b 100644
--- a/app/visualizer/stack/push-pop/page.jsx
+++ b/app/visualizer/stack/push-pop/page.jsx
@@ -1,33 +1,124 @@
import Animation from "@/app/visualizer/stack/push-pop/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/push-pop/content";
+import Quiz from "@/app/visualizer/stack/push-pop/quiz";
+import Code from "@/app/visualizer/stack/push-pop/codeBlock";
+import ExploreOther from "@/app/components/ui/exploreOther";
+import ModuleCard from "@/app/components/ui/ModuleCard";
+import { MODULE_MAPS } from "@/lib/modulesMap";
+import Footer from '@/app/components/footer';
+import BackToTopButton from '@/app/components/ui/backtotop';
export const metadata = {
- title: 'Stack Push and Pop Visualizer | Understand Stack Operations with Code in JS, C, Python, Java',
- description: 'Learn how Push and Pop operations work in a Stack using interactive animations and code examples in JavaScript, C, Python, and Java. Perfect for beginners and interview preparation to understand stack-based data structures clearly.',
+ title:
+ "Stack Push & Pop Visualizer & Quiz | Learn Stack Operations with Code in JS, C, Python, Java",
+ description:
+ "Understand Stack Push and Pop operations through step-by-step animations and test your knowledge with an interactive quiz. Includes code examples in JavaScript, C, Python, and Java. Ideal for beginners and interview preparation to master stack-based data structures visually and through hands-on coding.",
keywords: [
- 'Stack Push',
- 'Stack Pop',
- 'Stack Operations',
- 'Push and Pop Visualizer',
- 'DSA Stack Animation',
- 'Learn Stack Operations',
- 'Stack DSA',
- 'Stack in JavaScript',
- 'Stack in C',
- 'Stack in Python',
- 'Stack in Java',
- 'Push and Pop Code Examples',
- 'Stack Data Structure',
- 'Stack Visualization Tool',
+ "Stack Push Visualizer",
+ "Stack Pop Visualizer",
+ "Push and Pop Animation",
+ "Stack Operations",
+ "Stack Algorithm",
+ "Stack Quiz",
+ "Data Structure Visualization",
+ "Learn Stack Push",
+ "Learn Stack Pop",
+ "Interactive Stack Tool",
+ "Practice Stack Operations",
+ "Test Stack Knowledge",
+ "Stack in JavaScript",
+ "Stack in C",
+ "Stack in Python",
+ "Stack in Java",
+ "Stack Code Examples",
],
robots: "index, follow",
+ openGraph: {
+ images: [
+ {
+ url: "/og/stack/pushPop.png",
+ width: 1200,
+ height: 630,
+ alt: "Stack Push and Pop Visualization",
+ },
+ ],
+ },
};
export default function Page() {
- return(
+ const paths = [
+ { name: "Home", href: "/" },
+ { name: "Visualizer", href: "/visualizer" },
+ { name: "Stack : Push & Pop", href: "" },
+ ];
+
+ return (
<>
-
-
+
+
+
+
+
+
+
+
+
+
+
+ Test Your Knowledge before moving forward!
+
+
+
+
+
+
+
+
+
+
+
+
+
>
);
-};
\ No newline at end of file
+}
diff --git a/app/visualizer/stack/push-pop/quiz.jsx b/app/visualizer/stack/push-pop/quiz.jsx
index bf1fe5d..eaefc3f 100644
--- a/app/visualizer/stack/push-pop/quiz.jsx
+++ b/app/visualizer/stack/push-pop/quiz.jsx
@@ -1,3 +1,4 @@
+"use client";
import React, { useState } from 'react';
import { FaCheck, FaTimes, FaArrowRight, FaArrowLeft, FaInfoCircle, FaRedo, FaTrophy, FaStar, FaAward } from 'react-icons/fa';
import { motion, AnimatePresence } from 'framer-motion';
@@ -122,37 +123,28 @@ const StackQuiz = () => {
const [showResult, setShowResult] = useState(false);
const [quizCompleted, setQuizCompleted] = useState(false);
const [answers, setAnswers] = useState(Array(questions.length).fill(null));
- const [showExplanation, setShowExplanation] = useState(false);
const [showIntro, setShowIntro] = useState(true);
const [showSuccessAnimation, setShowSuccessAnimation] = useState(false);
- const [penaltyApplied, setPenaltyApplied] = useState(false);
const handleAnswerSelect = (optionIndex) => {
- if (selectedAnswer !== null) return;
setSelectedAnswer(optionIndex);
- const newAnswers = [...answers];
- newAnswers[currentQuestion] = optionIndex;
- setAnswers(newAnswers);
};
const handleNextQuestion = () => {
if (selectedAnswer === null) return;
-
- if (showExplanation && !penaltyApplied) {
- setScore(prevScore => Math.max(0, prevScore - 0.5));
- setPenaltyApplied(true);
- }
- if (selectedAnswer === questions[currentQuestion].correctAnswer) {
- setScore(score + 1);
- }
-
- setShowExplanation(false);
- setPenaltyApplied(false);
-
+ const newAnswers = [...answers];
+ newAnswers[currentQuestion] = selectedAnswer;
+ setAnswers(newAnswers);
+
+ const newScore = newAnswers.reduce((acc, ans, idx) => {
+ return ans === questions[idx].correctAnswer ? acc + 1 : acc;
+ }, 0);
+ setScore(newScore);
+
if (currentQuestion < questions.length - 1) {
setCurrentQuestion(currentQuestion + 1);
- setSelectedAnswer(null);
+ setSelectedAnswer(newAnswers[currentQuestion + 1]);
} else {
setShowSuccessAnimation(true);
setTimeout(() => {
@@ -164,7 +156,6 @@ const StackQuiz = () => {
};
const handlePreviousQuestion = () => {
- setShowExplanation(false);
setCurrentQuestion(currentQuestion - 1);
setSelectedAnswer(answers[currentQuestion - 1]);
};
@@ -176,9 +167,7 @@ const StackQuiz = () => {
setShowResult(false);
setQuizCompleted(false);
setAnswers(Array(questions.length).fill(null));
- setShowExplanation(false);
setShowIntro(true);
- setPenaltyApplied(false);
};
const calculateWeakAreas = () => {
@@ -224,7 +213,7 @@ const StackQuiz = () => {
};
return (
-
+
{showIntro ? (
{
className="text-center"
>
-
Stack Quiz Challenge
-
+
How it works:
-
- -
-
- +1 point for each correct answer
-
- -
-
- 0 points for wrong answers
-
- -
-
- -0.5 point penalty for viewing explanations
-
- -
-
- Earn stars based on your final score (max 5 stars)
-
-
+
+ -
+
+ +1 point for each correct answer
+
+ -
+
+ 0 points for wrong answers
+
+ -
+
+ Earn stars based on your final score (max 5 stars)
+
+
- {selectedAnswer !== null && (
-
-
-
- {showExplanation && (
-
- {questions[currentQuestion].explanation}
-
- )}
-
-
- )}
+
diff --git a/lib/modulesMap.js b/lib/modulesMap.js
index 99d8892..46e89cd 100644
--- a/lib/modulesMap.js
+++ b/lib/modulesMap.js
@@ -6,4 +6,5 @@ export const MODULE_MAPS = {
selectionSort : "7dffce41-ff4c-4700-8cfe-04b8793cc25c",
mergeSort : "d6704302-d35c-4c32-a259-9518dec15920",
quickSort : "19ad8f43-b858-4e80-998c-49c5e0f69f8c",
+ pushPop : "48138388-914b-4f84-8468-683175ce1a1e",
}
\ No newline at end of file
diff --git a/public/og/stack/pushPop.png b/public/og/stack/pushPop.png
new file mode 100644
index 0000000..a024676
Binary files /dev/null and b/public/og/stack/pushPop.png differ