/*
1、双向链表的优点:大部分与单链表差不多,主要的区别在于,向后寻查结点的复杂度为O(1)
2、双向链表的缺点:同单链表类似,同时比单链表占据更大的内存
*/
#include<stdio.h>
#define OK 1#define ERROR 0
typedef int Status;//表示返回的状态值
typedef int ElemType;
//双向链表的结构体定义
typedef struct DuNode
{
ElemType data;
struct DuNode *next;//后继结点地址
struct DuNode *prior;//前继结点地址
}*DuLinkList,DuNode;
//双向链表的插入,插入元素到第i位元素之前(不支持插入到末尾)
//平均时间复杂度为O(n)
Status DuLinkListInsert(DuLinkList &L,ElemType e,int i)
{
DuNode *p=L->next,*q;