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.

thanuvinu94 | 238 |

the_coder95 | 215 |

ShivayLamba | 208 |

sandeep.prajapati | 129 |

Ashish Kumar Vaishy | 114 |

the_coder95 | 1441 |

RishabhTanwar1 | 1110 |

thanuvinu94 | 914 |

tathagat289 | 668 |

themanhasnoname | 620 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4897 |

Quandray | 4547 |

Login to report an issue on this page.