邻接表和邻接矩阵能够在逻辑上表示非线性数据结构 [英] adjacency list and adjacency matrix are able to logically present a non-linear data structure

查看:76
本文介绍了邻接表和邻接矩阵能够在逻辑上表示非线性数据结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

邻接表和邻接矩阵如何逻辑上呈现非线性数据结构,即使它们本身是线性的也是如此.有人请解释

解决方案

堆栈,队列,列表,向量/数组:它们都线性存储数据,从某种意义上说,项是一个接一个地存储的.这里有项目A在项目B之前之前"和项目C在项目B 之后之后"的概念.前一个,后一个.它们的区别仅在于项目的访问方式(FIFO,LIFO,按等级,按位置).

树(图形的一种)分层存储数据.确实没有之前/之后的关系.而是根据父/子关系存储项目.然后,我们可以说项目A的父母是B",而项目A的孩子是B,C,D和E".

图形存储元素之间的任何类型的关系.一个项目可以与任何其他项目相关,如边缘所示.我们可以说项目A与B,C,D,E 相关"和项目B与A和F 相关".从这个意义上说,它们是非线性的.邻接表和邻接矩阵通过有效地维护这些关系的(线性)列表来实现此目的.

how adjacency list and adjacency matrix are able to logically present a non-linear data structure, even though they are themselves linear. Someone Pls explain

解决方案

Stacks, queues, lists, vectors/arrays: they all store data linearly in the sense that items are stored one after the other. There is the notion of "item A comes before item B", and "item C comes after item B". One before, one after. They only differ in how items can be accessed (FIFO, LIFO, by rank, by position).

Trees (a type of graph) store data hierarchically. There's not really a before/after relation. Instead, items are stored based on a parent/child relationship. Then, we can say "the parent of item A is B", and "the children of item A are B, C, D, and E".

Graphs store any type of relation between elements. An item can be related to any other item, as expressed by an edge. We can say "item A is related to B, C, D, E" and "item B is related to A and F". It is in this sense that they are nonlinear. An adjacency list and adjacency matrix accomplish this by, effectively, maintaining a (linear) list of these relationships.

这篇关于邻接表和邻接矩阵能够在逻辑上表示非线性数据结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆