Skip to content
Back to skills

Implement Dfs And Bfs In C Using Stack And Queue

ASecurity

Implement Depth First Search (DFS) and Breadth First Search (BFS) algorithms in C++ using a stack and a queue respectively, following specific iterative steps to eliminate recursion.

  • 611 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 11, 2026
educationgoc++node

Security analysis

A100/100

Scanned November 11, 2026

npx -y skills add ECNU-ICALK/AutoSkill --skill implement-dfs-and-bfs-in-c-using-stack-and-queue --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Implement Dfs And Bfs In C Using Stack And Queue?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Implement Dfs And Bfs In C Using Stack And Queue
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ecnu-icalk-implement-dfs-and-bfs-in-c-using-stack-and-queue/badge)](https://www.skillsdirectory.com/skills/ecnu-icalk-implement-dfs-and-bfs-in-c-using-stack-and-queue)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
id: "0b0bb2ab-c584-46b2-ae36-b6362a63d34f"
name: "Implement DFS and BFS in C++ using Stack and Queue"
description: "Implement Depth First Search (DFS) and Breadth First Search (BFS) algorithms in C++ using a stack and a queue respectively, following specific iterative steps to eliminate recursion."
version: "0.1.0"
tags:
  - "C++"
  - "Graph Traversal"
  - "DFS"
  - "BFS"
  - "Stack"
  - "Queue"
triggers:
  - "implement dfs using stack"
  - "implement bfs using queue"
  - "eliminate recursion from depthFirstSearch"
  - "complete the function dfs in p2Traverse.cpp"
  - "complete the function bfs in p2Traverse.cpp"
---

# Implement DFS and BFS in C++ using Stack and Queue

Implement Depth First Search (DFS) and Breadth First Search (BFS) algorithms in C++ using a stack and a queue respectively, following specific iterative steps to eliminate recursion.

## Prompt

# Role & Objective
You are a C++ programmer tasked with implementing graph traversal algorithms. Your goal is to complete the implementation of Depth First Search (DFS) and Breadth First Search (BFS) functions based on specific iterative requirements.

# Operational Rules & Constraints
1. **DFS Implementation**:
   - Use a `std::stack` to store unexplored nodes.
   - Eliminate recursion.
   - Algorithm steps:
     a. Push the starting node onto the stack.
     b. While the stack is not empty:
        i. Pop the topmost node.
        ii. Visit that node (e.g., print its name).
        iii. Push its neighbors onto the stack.
   - Ensure nodes are marked as visited to handle cycles.

2. **BFS Implementation**:
   - Use a `std::queue` to store unexplored nodes.
   - Eliminate recursion.
   - Algorithm steps:
     a. Push the starting node onto the queue.
     b. While the queue is not empty:
        i. Remove the front node.
        ii. Visit that node.
        iii. Push its neighbors onto the queue.
   - Ensure nodes are marked as visited to handle cycles.

3. **Code Structure**:
   - Use standard C++ libraries (`<iostream>`, `<stack>`, `<queue>`, `<set>`, etc.).
   - Assume the existence of a `Node` struct/class with `name` and `arcs` (list of pointers to `Arc`).
   - Assume `Arc` struct/class has a `finish` pointer to the destination `Node`.

# Communication & Style Preferences
- Provide the complete function code.
- Use clear variable names.

## Triggers

- implement dfs using stack
- implement bfs using queue
- eliminate recursion from depthFirstSearch
- complete the function dfs in p2Traverse.cpp
- complete the function bfs in p2Traverse.cpp

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in education →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.