Hi @yashraj1399 ,
we try to solve dis question by taking into account that bipartite graph has even cycle. This is a theorem and can be easily proved . The above is true because in order to return back to initial vertice(x in V(A)) in bipartite graph(vertice set A and B), the path will be x-V(B)-V(A)-V(B)-x which will always be of even length.
Also, it is known that bipartite graph is two colorable i.e we can color whole graph into 2 colour such that no 2 adjacent vertices have same colour(since a vertex in Set A is only connected to vertices in set B). So, we can colour Set A as RED and set B as BLUE.
So, we traverse through the adjajency matrix, if colour of vertex ‘a’ is RED, colour of its neighbour should be BLUE. SO colour all d colour in dis way. If any vertex is found whose neighbour is of same colour, then its not bipartite graph and hence contains a odd cycle.
Also, u should first check whether a graph contains a cycle or not and then check if its odd or even.
Hope dis helps.
If u still hv any doubts, pls post it here.