NEW
Font size
WorksheetsQuiz ADT linked list 20-12-66
Total questions: 10
Worksheet time: 5mins
จากส่วนของโปรแกรมที่กำหนดให้ จงหาค่า Big O
O(1)
O(n)
O(n2)
O(logn)
จาก loop ที่กำหนดให้ มี Big O เท่าใด
O(1)
O(n)
O(n2)
O(n3)
ถ้า head เป็น pointer ชี้ที่ linked list และ data เป็นข้อมูลที่จะทำการ insert
ข้อใดเป็นเงื่อนไขเป็นเงื่อนไขที่จะ insert data ด้านหน้า linked list
if(data < head->value)
if(data > head->value)
if(data < head)
if(data > head->next)
กำหนด p=head;
while(p->next !=NULL)
p=p->next;
เมื่อ loop while ทำงานสิ้นสุดลง ค่า p จะมีค่าเท่าใด
19
NULL
2000
1080
main โปรแกรมต้องการเรียกใช้ function insert ดังนี้
struct record *head=NULL;
cin >> data;
head=insert(data, head);
ในส่วนของ function insert ตรงหัวฟังก์ชันควรเขียนโปรแกรมอย่างไร
struct record *insert(head, data)
struct record *insert(struct record *head, int data)
struct record *insert(int data, struct record *head)
struct record insert(int data, struct record *head)
กำหนด loop ดังนี้
temp=head;
while(temp!=NULL)
{ cout << temp->value;
temp=temp->next->next;
}
ผลลัพธ์ที่แสดงบนจอภาพคืออะไร
4 5 10 15 20
4 10 20
5 15
4 10
เมนโปรแกรม เรียกใช้งาน function print()
int main()
{
struct record *head=NULL;
.......
print(head);
บริเวณหัวฟังก์ชัน print ควรเขียนอย่างไร
void print(struct record head)
void print(struct record *head)
struct record *print(head)
struct record print(struct record *head)
จากส่วนของโปรแกรม
tmp=Head;
while(tmp->next !=NULL)
{ cout << tmp->value;
tmp=tmp->next;
}
ผลลัพธ์ที่แสดงบนจอภาพคืออะไร
4 5 10 15 20
4 5 10 15
4
15
จากส่วนของโปรแกรม
tmp=Head;
while(tmp->next!=NULL)
{tmp=tmp->next;
}
cout << tmp->value;
จะแสดงผลลัพธ์อะไรบนจอภาพ
4
4 5 10 15 20
20
15
ถ้า linked list มีข้อมูลจำนวน n ตัว loop while ต่อไปนี้ทำงานกี่รอบ
p=head;
while(p->next!= NULL)
{ p=p->next;
}
n
n-1
n+1
1
