Create a temp array to hold visited flag of all elements . Note that , calloc is used here so that all values are initialized as false
bool * visited = ( bool * ) calloc ( n , sizeof ( bool ) ) ; int i ; for ( i = 0 ; i < n ; i ++ ) {