Closed JunJul closed 1 year ago
This description is for the graph one.
// We can create either a directed graph or an undirected graph according to the flag // if the flag is false which means undirected; otherwise, it is directed // insert vertex and return its index which will be used for insertEdge // for example if we have A and B two vertices in the array, which are index 0, 1 // so insert the edge in edges[0][1] and edges[1][0] if it is an undirected graph // if it is directed, only need to do edges[0][1]
@Mridul07Sharma Hi, I think I have done two pull requests here, but it seems I only can see my first pull request here. When my first pull request is closed, my next one will be pulled out, right?
Ok, after this. I will do one more pull request for my graph, sorry about this.
Please add files of only c and cpp code
do not add .h files
The search function is to search an element in the list if it cannot find the element, so return -1. If it finds the element, then delete it. We need to move the elements in the array when deleting an element. This remove function still costs O(n). On the contrary, a linked list only need to link node together after removing a node. This is O(1).