mac_n_cheese_pog's blog

By mac_n_cheese_pog, history, 3 years ago, In English

i read cp algorithm and understand bfs theory.when it comes to implementation i cant. see this code https://pastebin.com/5RtDSMMW this is literally copying yet its still wrong idk whats wrong.pls help

| Write comment?
»
3 years ago, # |
  Vote: I like it -18 Vote: I do not like it

pls help.im tired of asking someone in discord since theyll just ignore me.i really want to learn bfs and i cant.

  • »
    »
    3 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it
    • »
      »
      »
      3 years ago, # ^ |
        Vote: I like it -25 Vote: I do not like it

      that book is the worst.it left me confused at the implementation like what am i suppose to write in int main? whenever i tried to see the implementation example it just wont print anything.

      • »
        »
        »
        »
        3 years ago, # ^ |
        Rev. 2   Vote: I like it +1 Vote: I do not like it

        If you can't implement bfs by your own in main function despite having the bfs structure ready, then you have lack of understanding of bfs, that's not the fault of the book

        • »
          »
          »
          »
          »
          3 years ago, # ^ |
            Vote: I like it -23 Vote: I do not like it

          what i dont understand is actually the variations.some use vector<vectir> for storing adj list for bfs and some use vector pair.i was confused since in the article i read it uses vector vector and what i elarn from my teacher is vector pair.this also applies to that book.the standards are different

          • »
            »
            »
            »
            »
            »
            3 years ago, # ^ |
              Vote: I like it 0 Vote: I do not like it

            I don't know how the vector of pairs implementation works, but vector of vectors is used because for a vector with index $$$i$$$, all the values in that vector are neighbours of $$$i$$$. For example if 1,2,3 are stored in vector adj[0], then nodes 1,2,3 are neighbours of node 0. This way after processing node 0, you can push it's neighbours (1,2,3) in the queue for processing.