+
{paragraph[2]}
@@ -185,6 +247,35 @@ const content = () => {
+
+ {/* Mobile iframe at bottom */}
+
+ {mounted && (
+
+ )}
+
+
);
};
diff --git a/app/visualizer/queue/operations/enqueue-dequeue/page.jsx b/app/visualizer/queue/operations/enqueue-dequeue/page.jsx
index 7699a2b..7167457 100755
--- a/app/visualizer/queue/operations/enqueue-dequeue/page.jsx
+++ b/app/visualizer/queue/operations/enqueue-dequeue/page.jsx
@@ -1,33 +1,121 @@
import Animation from "@/app/visualizer/queue/operations/enqueue-dequeue/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/queue/operations/enqueue-dequeue/content";
+import Quiz from "@/app/visualizer/queue/operations/enqueue-dequeue/quiz";
+import Code from "@/app/visualizer/queue/operations/enqueue-dequeue/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 BackToTop from "@/app/components/ui/backtotop";
export const metadata = {
- title: 'Enqueue and Dequeue Operations in Queue | Learn Queue with JS, C, Python, Java Code',
- description: 'Visualize and understand the Enqueue and Dequeue operations in a Queue with real-time animations and code examples in JavaScript, C, Python, and Java. Perfect for DSA beginners and interview preparation.',
+ title:
+ "Enqueue and Dequeue Operations in Queue | Learn Queue with JS, C, Python, Java Code",
+ description:
+ "Visualize and understand the Enqueue and Dequeue operations in a Queue with real-time animations and code examples in JavaScript, C, Python, and Java. Perfect for DSA beginners and interview preparation.",
keywords: [
- 'Enqueue Operation',
- 'Dequeue Operation',
- 'Queue Operations',
- 'Queue DSA',
- 'Queue Enqueue Dequeue',
- 'Learn Queue',
- 'Queue Visualization',
- 'Interactive DSA Tools',
- 'Queue Data Structure',
- 'Queue Code Examples',
- 'Enqueue Dequeue in JavaScript',
- 'Enqueue Dequeue in C',
- 'Enqueue Dequeue in Python',
- 'Enqueue Dequeue in Java',
+ "Enqueue Operation",
+ "Dequeue Operation",
+ "Queue Operations",
+ "Queue DSA",
+ "Queue Enqueue Dequeue",
+ "Learn Queue",
+ "Queue Visualization",
+ "Interactive DSA Tools",
+ "Queue Data Structure",
+ "Queue Code Examples",
+ "Enqueue Dequeue in JavaScript",
+ "Enqueue Dequeue in C",
+ "Enqueue Dequeue in Python",
+ "Enqueue Dequeue in Java",
],
robots: "index, follow",
+ openGraph: {
+ images: [
+ {
+ url: "/og/queue/enqueueDequeue.png",
+ width: 1200,
+ height: 630,
+ alt: "Enqueue Dequeue Algorithm Visualization",
+ },
+ ],
+ },
};
export default function Page() {
+ const paths = [
+ { name: "Home", href: "/" },
+ { name: "Visualizer", href: "/visualizer" },
+ { name: "Enqueue-Dequeue", href: "" },
+ ];
+
return (
<>
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+ Enqueue & Dequeue
+
+
+
+
+
+
+
+
+
+
+
+ Test Your Knowledge before moving forward!
+
+
+
+
+
+
+
+
+
+
+
+
+
>
);
-};
\ No newline at end of file
+}
diff --git a/app/visualizer/queue/operations/enqueue-dequeue/quiz.jsx b/app/visualizer/queue/operations/enqueue-dequeue/quiz.jsx
index eb980c1..b9b0d15 100755
--- a/app/visualizer/queue/operations/enqueue-dequeue/quiz.jsx
+++ b/app/visualizer/queue/operations/enqueue-dequeue/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';
@@ -53,53 +54,8 @@ const QueueQuiz = () => {
],
correctAnswer: 2,
explanation: "Dequeueing from an empty queue results in an **underflow** error."
- },
- {
- question: "Which operation retrieves the front element without removing it?",
- options: ["Enqueue", "Dequeue", "Peek", "Search"],
- correctAnswer: 2,
- explanation: "Peek (or front) examines the front element without modification."
- },
- {
- question: "In a queue implementation using an array, what problem occurs if the rear reaches the end?",
- options: [
- "Stack overflow",
- "Memory leak",
- "Queue saturation",
- "Need for circular queue"
- ],
- correctAnswer: 3,
- explanation: "Fixed-size arrays may require a **circular queue** to reuse space when rear/front pointers wrap around."
- },
- {
- question: "Which real-world scenario best demonstrates a queue?",
- options: [
- "Pile of stacked plates",
- "Supermarket checkout line",
- "Emergency room triage",
- "Random lottery draw"
- ],
- correctAnswer: 1,
- explanation: "A checkout line follows FIFO—first customer in line is first served."
- },
- {
- question: "What is the space complexity of a queue storing N elements?",
- options: ["O(1)", "O(log N)", "O(N)", "O(N²)"],
- correctAnswer: 2,
- explanation: "Queues use O(N) space to store all elements linearly."
- },
- {
- question: "Which algorithm commonly uses a queue for implementation?",
- options: [
- "Depth-First Search (DFS)",
- "Breadth-First Search (BFS)",
- "Binary Search",
- "QuickSort"
- ],
- correctAnswer: 1,
- explanation: "BFS uses a queue to explore neighbor nodes level by level."
}
-];
+ ];
const [currentQuestion, setCurrentQuestion] = useState(0);
const [selectedAnswer, setSelectedAnswer] = useState(null);
@@ -107,13 +63,10 @@ const QueueQuiz = () => {
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;
@@ -123,18 +76,9 @@ const QueueQuiz = () => {
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);
-
if (currentQuestion < questions.length - 1) {
setCurrentQuestion(currentQuestion + 1);
setSelectedAnswer(null);
@@ -149,7 +93,6 @@ const QueueQuiz = () => {
};
const handlePreviousQuestion = () => {
- setShowExplanation(false);
setCurrentQuestion(currentQuestion - 1);
setSelectedAnswer(answers[currentQuestion - 1]);
};
@@ -161,38 +104,30 @@ const QueueQuiz = () => {
setShowResult(false);
setQuizCompleted(false);
setAnswers(Array(questions.length).fill(null));
- setShowExplanation(false);
setShowIntro(true);
- setPenaltyApplied(false);
};
const calculateWeakAreas = () => {
const weakAreas = [];
if (answers[0] !== questions[0].correctAnswer) {
- weakAreas.push("understanding the basic principle of Selection Sort");
+ weakAreas.push("understanding the basic FIFO principle");
}
if (answers[1] !== questions[1].correctAnswer) {
- weakAreas.push("time complexity analysis");
+ weakAreas.push("queue operations (enqueue/dequeue)");
}
if (answers[2] !== questions[2].correctAnswer) {
- weakAreas.push("counting swaps in Selection Sort");
+ weakAreas.push("time complexity analysis");
}
if (answers[3] !== questions[3].correctAnswer) {
- weakAreas.push("comparison with other simple sorts");
+ weakAreas.push("practical queue manipulation");
}
if (answers[4] !== questions[4].correctAnswer) {
- weakAreas.push("space complexity");
- }
- if (answers[5] !== questions[5].correctAnswer) {
- weakAreas.push("stability characteristics");
- }
- if (answers[6] !== questions[6].correctAnswer) {
- weakAreas.push("practical applications");
+ weakAreas.push("edge case handling");
}
return weakAreas.length > 0
? `Focus on improving: ${weakAreas.join(', ')}. Review the corresponding sections above.`
- : "Perfect! You've mastered all Selection Sort concepts!";
+ : "Perfect! You've mastered all Queue concepts!";
};
const startQuiz = () => {
@@ -209,22 +144,22 @@ const QueueQuiz = () => {
};
return (
-
+
{showIntro ? (
-
-
Queue Quiz Challenge
-
+
How it works:
@@ -259,14 +194,14 @@ const QueueQuiz = () => {
-
{
-
+
{
{questions[currentQuestion].question}
-
+
{questions[currentQuestion].options.map((option, index) => (
-
handleAnswerSelect(index)}
>
-
+
{String.fromCharCode(65 + index)}
{option}
@@ -341,32 +272,9 @@ const QueueQuiz = () => {
))}
-
- {selectedAnswer !== null && (
-
-
-
- {showExplanation && (
-
- {questions[currentQuestion].explanation}
-
- )}
-
-
- )}
+
-
+
-
+
@@ -401,84 +308,62 @@ const QueueQuiz = () => {
{[...Array(5)].map((_, i) => (
-
))}
- You scored {((score / questions.length) * 100).toFixed(0)}%
- correct
+ You scored {((score / questions.length) * 100).toFixed(0)}% correct