数据结构单向链表线性结构

Imagine you have gone to a crowded place, say to a k-pop concert with your friends and you don’t have any electronics or compass with you.

想象您去了一个拥挤的地方,与您的朋友一起参加一场韩流音乐会,而您却没有任何电子设备或指南针。

Now one of your friends wants to go a bit far away to fetch something, say light sticks. If he goes to fetch it, then he won't be able to find and reach you in the large crowd :(

现在,您的一位朋友想走很远的距离来拿东西,例如荧光棒。 如果他去拿东西,那么他将无法在大群人中找到并到达你:(

How would you solve this problem? Here is a solution for it given that you have sufficient friends with you. You have to make your friends stand in pairs with an even amount of distance between them till the target place. In the pair of your friends standing at equal distances, one of them should look at the next friend pair nearer to the target place, and the other person to look at the previous friend pair. Now your friend after reaching the target place can return to the initial place easily (and the friends who stand in pairs of course) with the help of the person in the pair who was looking over the previous pair.

您将如何解决这个问题? 考虑到您有足够的朋友,这是一个解决方案。 您必须让您的朋友成对站立,彼此之间的距离要均匀,直到到达目标位置。 在一对等距站立的朋友中,其中一个应查看目标位置附近的下一个朋友对,另一个人应查看上一个朋友对。 现在,您的朋友到达目标位置后,可以很轻松地返回初始位置(以及成对站立的朋友),这对伙伴中的人正在寻找上一个对。

If you managed to set up or understand this, then Congratulations! you have successfully implemented(understood) a doubly-linked list.

如果您成功设置或了解此内容,那么恭喜! 您已成功实现(理解)了双向链接列表。

If you didn’t understand the practical example don’t worry about it, you will understand it at the end of this article :)

如果您不了解实际示例, 请不必担心 ,在本文结尾处您将了解:)

What is a data structure and why should you care? Data structures are a core concept of Software Development. I would like to quote from Wikipedia.

什么是数据结构,为什么要关心? 数据结构是软件开发的核心概念。 我想引用维基百科。

In computer science, a data structure is a data organization, management, and storage format that enables efficient access and modification. Data structures provide a means to manage large amounts of data efficiently for uses such as large databases and internet indexing services. Usually, efficient data structures are key to designing efficient algorithms.

在计算机科学中, 数据结构是一种数据组织,管理和存储格式,可实现高效访问 和 修改。 数据结构提供了一种有效管理大量数据以供使用的方法,例如大型数据库和Internet索引服务。 通常,有效的数据结构是设计高效算法的关键。

Even though Data Structures are important but why Linked List when there are a lot of Data Structures? Here are the advantages of linked list

即使数据结构很重要,但是为什么有很多数据结构时为什么要使用链表? 这是链表的优点

  • Dynamic Data structure: Linked list unlike arrays is dynamic data structures. It basically means that amount of data it can store is not fixed i.e, we can increase or decrease the size of the linked list as per the needs.

    动态数据结构 :与数组不同,链接列表是动态数据结构。 这基本上意味着它可以存储的数据量不是固定的,即,我们可以根据需要增加或减少链表的大小。

  • Insertion and deletion operations are easier.

    插入和删除操作更容易。

  • Efficient Memory Utilization: Unlike arrays, there is no need to pre-allocate memory.

    高效的内存利用率:与数组不同,无需预先分配内存。

  • Linear Data Structures: As it is a linear data structure, accessing the data can be done sequentially.

    线性数据结构:由于它是线性数据结构,因此可以顺序访问数据。

  • Easy Implementation of Other Linear Data Structures: Linear Data Structures such as Stack, Queue can be easily implemented using the Linked list.

    轻松实现其他线性数据结构 :可以使用链接列表轻松实现诸如栈,队列之类的线性数据结构。

With why you should learn the linked list, lets deep dive into the linked list!

为什么要学习链表,让我们深入了解链表!

Linked List is made of nodes.

链表由节点组成。

A single Node in Linked List consists of 2 parts:-

链表中的单个节点由两部分组成:

  • Data: This is where the data is stored.数据:这是存储数据的位置。
  • Reference to the next Node. This consists of a reference to the next node. using this reference we can access data in the next node. We generally name it as “next

    参考下一个节点。 这包括对下一个节点的引用。 使用此参考,我们可以访问下一个节点中的数据。 我们通常将其命名为“ 下一个

A single node
单节点

If you are using low-level language like C then you will be using pointers to create a reference to the next node. pointers are nothing but variables that hold the address of another variable. So we will be storing the address of the next node in the reference part of the node.

如果使用的是C之类的低级语言,则将使用指针创建对下一个节点的引用。 指针不过是保存另一个变量地址的变量。 因此,我们将下一个节点的地址存储在该节点的参考部分中。

In case you are using other languages then you create a reference just by assigning another variable to it.

如果您使用其他语言,则只需给它分配另一个变量即可创建引用。

What I mean by “A references B” is that the variable “A” and the variable “B”, share the same memory block. So changing A changes the value stored and hence changes the value accessed by B. In other words, A and B reference the same memory block.

我所说的“ A引用B”是指变量“ A”和变量“ B”共享同一存储块 。 因此,更改A会更改存储的值,因此也会更改B所访问的值。换句话说,A和B 引用同一存储块

class Node:def __init__(self,data):self.data = dataself.next = None
class Node {int data;Node* next;Node(int data){this->data = data;this->next = nullptr;}Node(){this->data = 0;this->next = nullptr;}}

A Linked list
链表

This is what a typical Linked List Looks like

数据结构单向链表线性结构_线性数据结构链表为何以及如何解释相关推荐

  1. 数据结构——线性结构(线性表)

    文章目录 一. 线性结构概述 1. 线性结构(线性表的逻辑结构)的定义 2. 线性表的特点 二. 线性结构分类 1. 连续存储[顺序表] (1). 什么叫数组 (2). 顺序表算法的基本操作 (3). ...

  2. 【数据结构笔记04】线性结构:线性表及其实现

    本次笔记内容: 2.1.1 引子:多项式表示 2.1.2 线性表及其存储顺序 2.1.3 顺序存储的插入和删除 2.1.4 链式存储及查找 2.1.5 链式存储的插入和删除 2.1.6 广义表与多重链 ...

  3. 数据结构 二叉树的存储结构_线程二叉树| 数据结构

    数据结构 二叉树的存储结构 线程二叉树 (Threaded Binary Tree ) A binary tree can be represented by using array represen ...

  4. 线性链表java实现_线性表的Java实现--链式存储(双向链表)

    线性表的Java实现--链式存储(双向链表) 有了单向链表的基础,双向链表的实现就容易多了. ? 双向链表的一般情况: ? ? class="decoded" alt=" ...

  5. 数据结构算法动图识记_【数据结构与算法】用动图解说数组、链表、跳表原理与实现...

    「初」前言 在学习数据结构与算法的过程中,感觉真的是一入算法深似海,但是越学越觉得有趣.不过我们会发现在终身学习的过程中,我们都是越学越多,不知的也越来越多,但是更渴望认知更多的知识,越是对知识感兴趣 ...

  6. 栈和队列都是限制存取点的线性结构_栈的练习以及解析

    The Practice Of Stack栈的练习01 栈是(). A.顺序存储的线性结构     B.链式存储的非线性结构 C.限制存取点的线性结构     D.限制存储点的非线性结 答案:B 解析 ...

  7. 广义表头尾链表存储结构_单向循环链表的存储结构和操作

    单向循环链表的存储结构 单向循环链表(Circular Linked List)是单向链表的一种扩充,当单向链表带有头结点时,把单向链表中尾结点的指针域由空指针改为头结点的指针(当单向链表不带头结点时 ...

  8. 图解数据结构使用java电子书下载_图解数据结构:使用Java 胡昭民著 PDF下载

    本书内容架构完整,逻辑清楚,采用丰富的图例来阐述基本概念及应用.强调边做边学,结合下载文件,给予最完整的支援.以Java程序语言实现数据结构中的重要理论,以范例程序说明数据结构的内涵.采用JavaID ...

  9. 数据结构 线性 非线性_线性和非线性数据结构之间的区别

    数据结构 线性 非线性 Here you will learn about difference between linear and non linear data structure. 在这里,您 ...

最新文章

  1. WebRTC对你意味着什么
  2. mysql 5.7 多实例_MySQL 5.7--------多实例部署最佳实战
  3. oracle10g优化器默认,Oracle10g数据库优化实用心得小结
  4. Java静态代理类的特点和示例
  5. php文件同名怎么办,php根据文件不同关闭同名进程
  6. 贪吃蛇小游戏程序(C语言)
  7. python 图像二值化处理
  8. 数字信号处理原理及实现一书的思维导图
  9. 步进电机低频震动问题
  10. 文本无关说话人确认的深度神经网络嵌入
  11. 看完这篇 教你玩转渗透测试靶机vulnhub——DC1
  12. 【Discuz】原系统进入论坛自动注册并进行登录
  13. 前端追梦人Cytoscape.js教程
  14. 密码学笔记5 非对称密钥算法
  15. python的describe参数_Python Pandas Series.describe()用法及代码示例
  16. MICCAI 2022 | CLFC:基于对比学习的多模态脑肿瘤分割与单模态正常脑图像的特征比较
  17. ACM—最短路—8月14日
  18. 构建一致性哈希ring Part2
  19. FLEX发布问题,流错误2032,找不到swz文件
  20. 揭秘国内6家主流CRM产品:NPS亟待提升 兼容性制约客户体验

热门文章

  1. events.js:187 throw er; // Unhandled 'error' event ^ Error: connect ETIMEDOUT at Co
  2. android 闹钟定时提醒,安卓手机便签怎么设定三天后的闹钟提醒?
  3. 定制护肤技术领导者Skin Inc宣布获得来自Mistletoe的Pre-A轮融资
  4. 用于一般光学系统的光栅元件
  5. 自动驾驶系列(十九)Autoware使用YoloV3识别(海康相机)
  6. 【数据库-3】dbSNP数据库
  7. 霍尔效应电流传感器——以开环电流传感器实现闭环精度
  8. 怎样把扫描的图片转换成pdf
  9. 找实习中的一些困惑,如何解决?
  10. CPU发现高危安全漏洞 修复要损失多达39%性能