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.

bruceewayne | 192 |

manvirag982 | 178 |

theAwesome | 168 |

shivam123ahuja | 167 |

Core_Ka_Bachha | 160 |

mr_kksparrow | 433 |

manvirag982 | 394 |

TheHandle | 282 |

rajupraaa1234 | 276 |

Exception_404 | 268 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4567 |

Login to report an issue on this page.