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.

KshatriyaYash | 658 |

RuntimeTerror | 446 |

nikhil_sojan | 388 |

cypherr | 384 |

striver119 | 378 |

KshatriyaYash | 1066 |

nikhil_sojan | 972 |

lonecoder | 909 |

mazumderrohit8 | 864 |

SumitSingh27 | 832 |

blackshadows | 5327 |

Ibrahim Nash | 5215 |

akhayrutdinov | 5111 |

mb1973 | 4462 |

Quandray | 4444 |

Login to report an issue on this page.