How are second and third option correct in this mcq

Which of the following can be used to store a simple undirected graph with N nodes?

vector < int > graph [ N + 1 ]

bool graph [ N + 1 ][ N + 1 ]

vector < vector < int > > graph(N+1)

All of them.

hello @S19APPN0069
bool graph[N+1][N+1] -> this is adjacency matrix , u can mark graph[i][j]=true if there exist edge between vertex i and vertex j otherwise false.

vector < vector < int > > graph(N+1)-> this is same as first one, only difference is that here we are using vector in place of array.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.