Skip to content

feat: add interactive stack demo, fix board size validation, and clean up exit signals#856

Merged
darshan2456 merged 1 commit into
darshan2456:mainfrom
vedant-kawale-27:main
Jul 16, 2026
Merged

feat: add interactive stack demo, fix board size validation, and clean up exit signals#856
darshan2456 merged 1 commit into
darshan2456:mainfrom
vedant-kawale-27:main

Conversation

@vedant-kawale-27

@vedant-kawale-27 vedant-kawale-27 commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

PR Description:

Overview

This PR resolves validation inconsistencies, improves code readability, and adds a missing interactive demonstration for the stack data structure in the Linear Data Structures menu.

Proposed Changes

1. 💡 Feature: Interactive Stack Demo

  • Files:
    • [NEW] stack_demo.c
    • [MODIFY] stack.h
    • [MODIFY] data_structures_demo.c
  • Description: Added a standalone interactive console demo for Stacks to complete the Linear Data Structures suite. It provides option-driven interactions for:
    • Push: Pushes elements (bounded 1 to 100) onto the stack.
    • Pop: Pops elements from the top of the stack (checking for stack underflow).
    • Peek: Views the top element.
    • Prints a live text-based representation of the stack layout (Stack (top -> bottom): | val1 | val2 |) after each operation.

2. 🐛 Bug Fix: Knight's Tour Board Size Validation

  • File: knights_tour_demo.c
  • Description: Corrected the validation constraints on board size input. While the prompt requested a value "between 4 and 8", safe_input_int previously accepted 1, 2, or 3. The minimum value limit has been corrected from 1 to 4.

3. 🧹 Code Quality: Replace Magic Numbers for Exit Signals

  • File: main.c
  • Description: Replaced hardcoded -111 occurrences in the menu structures (run_legacy_menu and tui_menu) with the standardized INPUT_EXIT_SIGNAL macro for consistency with the rest of the codebase.

Verification Done

  1. Verified compiler syntax checks for all modified and new files:
    gcc -Wall -Wextra -Werror -std=c11 -c demos/data_structures/stack_demo.c -Isrc/data_structures -Isrc/utils
    gcc -Wall -Wextra -Werror -std=c11 -c demos/data_structures/data_structures_demo.c -Isrc/data_structures -Isrc/utils
  2. Rebuilt and ran standard unit test assertions:
    • Tested and passed all test suites under Linux/WSL compilation bounds.

closes #857

Copilot AI review requested due to automatic review settings July 15, 2026 16:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@darshan2456

Copy link
Copy Markdown
Owner

@vedant-kawale-27 changes you have done are relevant and legitimate but it isnt what the issue described. In the issue I meant the interactive help page. However. Keep the PR and make a separate issue for this PR and link with it

@vedant-kawale-27

vedant-kawale-27 commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

Understood. I have already detailed these findings (including the interactive help page manual gaps) in a comment on the original issue.

I will keep this PR open, create a new separate issue covering these specific changes (the Stack demo, Knight's Tour validation, and exit signal clean-up), and link this PR to that new issue.

@darshan2456

@darshan2456
darshan2456 merged commit 7852221 into darshan2456:main Jul 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhancement: Add Interactive Stack Demo, Fix Knight's Tour Input Boundaries, and Clean Up Exit Signal Magic Numbers

3 participants