-->
当前位置:首页 > 题库 > 正文内容

程序填空题:Selection Sort with Doubly Linked List

Luz2年前 (2022-11-16)题库429
The function SelectionSort is to sort the doubly linked list L (with a dummy header) in non-decreasing order.

The list structure is defined as the following:


typedef struct Node *PtrToNode;
struct Node{
int Data;
PtrToNode Pre, Next;
};
typedef PtrToNode List;


Please fill in the blanks.

c++
void SelectionSort( List L )
{
List tail, minp, ptr;
List t;

tail = L;
while (tail->Next) {
ptr = minp = tail->Next;
while (ptr) {
if () minp = ptr;
ptr = ptr->Next;
}
if (tail->Next != minp) {
minp->Pre->Next = minp->Next;
if (minp->Next) minp->Next->Pre = ;
minp->Next = tail->Next;
minp->Pre = tail;
tail->Next->Pre = ;
;
}
tail = tail->Next;
}
}








答案:
第1空:ptr->Data < minp->Data

第2空:minp->Pre

第3空:minp

第4空:tail->Next = minp

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。