220 câu trắc nghiệm Cấu trúc dữ liệu và giải thuật có đáp án - Phần 2

Với cấu trúc dữ liệu như sau: typedef struct DNode { int Key; DNode * NextNode;

20/20

Với cấu trúc dữ liệu như sau:
typedef struct DNode
{
int Key;
DNode * NextNode;
DNode * PreNode;
} DOneNode
typedef DLLOneNode * DPointerType;
typedef struct DPairNode
{ DPointerType DLLFirst;
DPointerType DLLLast;
} DPType;
Hàm thêm phần tử vào cuối danh sách liên kết đôi quản lý bởi 2 phần
tử đầu và cuối
DPointerType DLLAddLast(DPType &DList, int NewData)
{
DPointerType NewNode = gọi hàm tạo nút mới có vùng dữ liệu là
NewData ;
if (NewNode == NULL)
return (NULL);
if (DList.DLLLast == NULL)
DList.DLLFirst = DList.DLLLast = NewNode;
else
{
……………………………………………….
……………………………………………….
………………………………………………
}
return (NewNode);
} Hãy lựa chọn câu đúng nhất để điền vào chỗ trống ở trên

DList.DLLLast ->NextNode = NewNode; NewNode ->PreNode = DList.DLLLast; NewNode = DList.DLLLast;

DList.DLLLast ->NextNode = NewNode; DList.DLLLast = NewNode ->PreNode; DList.DLLLast = NewNode;

NewNode = DList.DLLLast ->NextNode; NewNode ->PreNode = DList.DLLLast; DList.DLLLast = NewNode;

DList.DLLLast ->NextNode = NewNode; NewNode ->PreNode = DList.DLLLast; DList.DLLLast = NewNode;

Giải thích

Chọn đáp án D