Warning: Attempt to read property "ID" on bool in /www/wwwroot/129.28.78.18/wp-content/themes/storeys-pro/wbc/components/og_schema/wb_og_schema.php on line 471

Warning: Attempt to read property "display_name" on bool in /www/wwwroot/129.28.78.18/wp-content/themes/storeys-pro/wbc/components/og_schema/wb_og_schema.php on line 480

Warning: Attempt to read property "display_name" on bool in /www/wwwroot/129.28.78.18/wp-content/themes/storeys-pro/wbc/components/og_schema/wb_og_schema.php on line 487

Warning: Attempt to read property "description" on bool in /www/wwwroot/129.28.78.18/wp-content/themes/storeys-pro/wbc/components/og_schema/wb_og_schema.php on line 489

Warning: Attempt to read property "ID" on bool in /www/wwwroot/129.28.78.18/wp-content/themes/storeys-pro/wbc/components/og_schema/wb_og_schema.php on line 493

10-7张森霖

链表

  • 链表由node节点构成,每个node节点储存了pre,next对象和数据。pre对象储存了前一个节点的地址引用,next储存了后一个节点的地址引用。这样,就把所有的节点连接起来。而node 的外部类linkedlist储存了first和last,first指向第一个node节点的地址,last指向最后一个节点的地址。
  • 链表没有下标的说法,查找某个元素的时候,必须依次遍历每一个节点。这也是链表数据结构的缺点。

链表与数组的对比

  • 链表添加和删除数据比数组快。
  • 链表查找数据比数组慢。因为数组有索引,而链表查找数据的时候要遍历每一个节点。
  • 链表比数组更节约内存空间,因为数组添加数据的时候,会先创建一个1.5倍长度的数组,把原数组复制进去,再添加。这样就浪费了内存空间。

今日总结:今天的链表很难,但是下去看书,再回忆老师上课所讲,加上自己的理解,总算有一点收获。今天的作业没做完,老师明天讲的时候一定要在认真的听。对链表的节点是如何连接的,理论上理解了,但是代码实现的过程中就不理解了,比如node j=first。

评论留言