Comparing object graph representation to adjacency list and matrix representations

后端 未结 4 1082
清歌不尽
清歌不尽 2021-01-29 22:42

I\'m currently following Steve Yegge\'s advice on preparing for a technical programming interview: http://steve-yegge.blogspot.com/2008/03/get-that-job-at-google.html

In

4条回答
  •  盖世英雄少女心
    2021-01-29 23:05

    Objects and pointers is mostly the same as adjacency list, at least for the purpose of comparing algorithms that use these representations.

    Compare

    struct Node {
        Node *neighbours[];
    };
    

    with

    struct Node {
        Node *left;
        Node *right;
    };
    

    You can easily construct the list of neighbours on-the-fly in the latter case, if it is easier to work with than named pointers.

提交回复
热议问题