Answer to Question #284038 in C for Muhammad Usman

Question #284038

Complete the function ‘find_path_dfs()’ which finds cost of going from the source vertex (src) to destination vertex (dst) using Depth First Search (DFS) algorithm. Use stack for implementing DFS algorithm.


void find_path_dfs(int * graph, int size, int src, int dst)

{

  int visited[size] ={0};

  struct node * top =NULL; //Make a stack for holding the visited vertices

  int crnt_visiting =src;

  int crnt_exploring =src;

  int path_cost =0;

  bool PATH_FOUND =false;

  while(!PATH_FOUND)

  {

    visited[crnt_visiting] =1;

    struct element temp;

    if(crnt_visiting==dst) //If the vertex is found

   {

      printf("\nPath found: ");

      printf("\nCost: %d\n", path_cost);

      while(!isStackEmpty(&top))

     {

        printf("Pop\n");

        pop(&top);

     }

      PATH_FOUND=true;

      continue;

   }

    else  //Explore this vertex

    { //Complete this function. You are free to make any changes to this function. Make sure that path cost is correctly found.

    }}}



1
Expert's answer
2022-01-03T10:42:36-0500
Dear Muhammad Usman, your question requires a lot of work, which neither of our experts is ready to perform for free. We advise you to convert it to a fully qualified order and we will try to help you. Please click the link below to proceed: Submit order

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS