Given an adjacency matrix representation of a graph g having 0 based index your task is to complete the function **isBipartite** which returns true if the graph is a bipartite graph else returns false.

**Input:**

The first line of input contains an integer T denoting the no of test cases. Then T test cases follow. Each test case contains an integer v denoting the no of vertices of the graph then in the next line are v*v space separated values of the adjacency matrix representation of the graph g.

**Output:**

For each test case in a new line output will be 1 if the graph is bipartite else 0.

**Constraints:**

1<=T<=100

1<=v<=15

0<=g[][]<=1

**Example(To be used only for expected output):
Input:**

2

4

0 1 0 1 1 0 1 0 0 1 0 1 1 0 1 0

3

0 1 0 0 0 1 1 0 0

1

0

Author: Shubham Joshi 1

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

cs_abhi | 102 |

PiyushPandey4 | 100 |

codefundo | 95 |

kya_bolti_public | 93 |

masterishaan19 | 74 |

PiyushPandey4 | 916 |

john_wick | 765 |

ASWATHAMA | 565 |

UsfShilpa | 556 |

akhyasharma01 | 547 |

blackshadows | 5362 |

Ibrahim Nash | 5242 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4598 |

Login to report an issue on this page.