saurabh47 / Data-structures-and-algorithms

Popular coding questions solution for interview preparation
MIT License
13 stars 8 forks source link

Implement graph data structures and traversal #30

Closed maheshj01 closed 11 months ago

maheshj01 commented 1 year ago

Adds an adjacency list for a simple case for graphs like this

0 --- 1
 |    /
 |  /
 2  - - - 3

But this would fail for random numbers (WIth index out-of range error) Because we only allocate an array of length 4.(since we only have 4 nodes in the array).

5 --- 4
 |    /
 |  /
 2  - - - 3
maheshj01 commented 1 year ago

@saurabh47 I think the solution for this issue is to create another array of length 4 that stores the values of all 4 nodes, What do you think?

maheshj01 commented 1 year ago

I have submitted a change is that the correct way to solve this issue?

saurabh47 commented 1 year ago
maheshj01 commented 1 year ago

submitted the change

saurabh47 commented 1 year ago

let me know once your changes finalize @maheshmnj

maheshj01 commented 1 year ago

This is ready to merge @saurabh47

maheshj01 commented 1 year ago

Also let me know if you have any topics in mind that needs to be added. I just realized the adjacency_list implementation should also implement a function to show "if path exists between two nodes."