agentsclimarketplace

Implement dfs and bfs in c using stack and queue

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt3.5_8_GLM4.7/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.From its SKILL.md

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

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

SKILL.md

2.5 KB, 451 tokens by cl100k_base, as published. Nobody here has run it

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

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.