1

キューを使用して幅優先検索を実装するプログラムを作成しようとしています。

// Queue.h

    #pragma once
    #include<iostream>

    struct node
     {
      int b1,b2,b3,b4;
      node* link;
     };

struct state
    {
     int b1,b2,b3,b4;
     state* rightChild;
     state* leftChild;
    };

class Queue
{
   private:
    node* front, *rear ;
   public:
        bool enqueue(node n);
        //......
};

  //BFS.cpp
  #include <iostream>
  #include "Queue.h"

  int main()
  {

   struct state
       {
          int b1,b2,b3,b4;
          state* rightChild;
          state* leftChild;
      };

    // now i define all the nodes of the tree, each node is of type state
    Queue Q;        // make a queue
    Q.enqueue(initialState);         //where initialState is the root
    //...

  }

私が作成したキューには node- タイプのノードが格納されていますが、ツリー内のノードは State タイプです。どちらも個別の構造であるため、コピー コンストラクターは使用できません。では、ツリーのノードがキューに受け入れられるようにコードを編成する効率的な方法は何でしょうか?

4

0 に答える 0