当前位置:网站首页>Circular linked list--

Circular linked list--

2022-07-01 12:23:00 Between the steps

Circular single chain table


bool InitList(LinkList &L){
    
    L=(LNode*)malloc (sizeof(LNode));
    
    if(L==NULL){
    
        return false;
    }
    L->next=L; // Head node next Point to the head node 
    return true;
}
 
 // Sentenced to empty 
bool Empty(LinkList L){
    
    if(L->next=L)
        return true;
    else
        return false;
}

bool isTail(LinkList L){
    
if(L->next==L)
	return true;
else
	return false;
}

Circular double linked list

bool InitDLinkList(DLinkList &L){
    
    L=(LNode*)malloc (sizeof(LNode)); // Assign a head node 
    
    if(L==NULL){
    
        return false;
    }
    L->prior=L; // The first node prior Point to the head node 
    L->next=L; // Head node next Point to the head node 
    return true;
}

Double-linked list inserts and deletes , If it is a circular double linked list , Regardless of tail node NULL
 Insert picture description here

 Insert picture description here

Judge whether the circular double linked list is empty Is it a tail node
 Insert picture description here

原网站

版权声明
本文为[Between the steps]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/182/202207011204421867.html