zoukankan      html  css  js  c++  java
  • 数据结构 ---- 链表

    逻辑:

        集合

        线性表

        树

        图


    物理:

        顺序

        链式

    typedef struct Node{
        
        ElmetType data;
        
        struct Node *next;


    }Node;


    头指针 : 链表的起始
    尾指针 : 链表的结束


    判空 : 头指针为空

    头结点 不存任何节点

        head->next == NULL

    尾部插入

        Node *r = malloc (sizeof(Node));
        Node *p = head;
        while (p->next != NULL){
            p = p->next;
        }

        p->next = r;
        

    中间插入
        
        //后插
        Node *f = malloc(sizeof(Node));
        Node *p = head->next;

        while (p->next != NULL){
            if (p->data == ‘b’){    
                f->next = p->next;
                p->next = f;
                return ;
            }        
            p = p->next;
        }
        



    删除

        Node *p = head;
        while (p->next != NULL){
        
            if (p->next->data == ‘c’){
                Node *n = p->next;
                p->next = n->next;
                n->next = NULL;
                free(n);
                return ;
            }
            p = p->next;
        }

        

  • 相关阅读:
    EFCore实践教程三
    EFCore实践测试二
    EFCore实践测试一
    git学习3
    git学习2
    git学习1
    ABP学习
    autofac笔记
    时间计算本质理论3-平行宇宙,对未来的子线程计算
    时间计算本质理论2-时间计算速度的不同步
  • 原文地址:https://www.cnblogs.com/Ager/p/5074292.html
Copyright © 2011-2022 走看看