
please wait
|
|
adj
is passed to addEdge
5 new contiguous memory locations (20 bytes in total) are allocated. These newly allocated memory blocks will retain the same values that the original adj
had from the main function, but will be located at different memory addresses. If addEdge
processes/manipulates data, the data at the newly allocated addresses will change. But the data from the original address (in main) will stay the same. Once execution ends at addEdge
, and returns to main, adj
will be referring to its original addresses. This is of course different from passing by reference or pointer, where data from the original addresses can be modified (Unless const is used). adj
in printGraph
gets iterated through, and it behaves like an array of linked lists. Where the first element 0 outputs 0: 1, 4
1: 2, 3, 4