wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Quiz ADT linked list 20-12-66

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

จากส่วนของโปรแกรมที่กำหนดให้ จงหาค่า Big O

a)

O(1)

b)

O(n)

c)

O(n2)

d)

O(logn)

2.

จาก loop ที่กำหนดให้ มี Big O เท่าใด

a)

O(1)

b)

O(n)

c)

O(n2)

d)

O(n3)

3.

ถ้า head เป็น pointer ชี้ที่ linked list และ data เป็นข้อมูลที่จะทำการ insert

ข้อใดเป็นเงื่อนไขเป็นเงื่อนไขที่จะ insert data ด้านหน้า linked list

a)

if(data < head->value)

b)

if(data > head->value)

c)

if(data < head)

d)

if(data > head->next)

4.

กำหนด p=head;

while(p->next !=NULL)

p=p->next;

เมื่อ loop while ทำงานสิ้นสุดลง ค่า p จะมีค่าเท่าใด

a)

19

b)

NULL

c)

2000

d)

1080

5.

main โปรแกรมต้องการเรียกใช้ function insert ดังนี้

struct record *head=NULL;

cin >> data;

head=insert(data, head);

ในส่วนของ function insert ตรงหัวฟังก์ชันควรเขียนโปรแกรมอย่างไร

a)

struct record *insert(head, data)

b)

struct record *insert(struct record *head, int data)

c)

struct record *insert(int data, struct record *head)

d)

struct record insert(int data, struct record *head)

6.

กำหนด loop ดังนี้

temp=head;

while(temp!=NULL)

{ cout << temp->value;

temp=temp->next->next;

}

ผลลัพธ์ที่แสดงบนจอภาพคืออะไร

a)

4 5 10 15 20

b)

4 10 20

c)

5 15

d)

4 10

7.

เมนโปรแกรม เรียกใช้งาน function print()

int main()

{

struct record *head=NULL;

.......

print(head);

บริเวณหัวฟังก์ชัน print ควรเขียนอย่างไร

a)

void print(struct record head)

b)

void print(struct record *head)

c)

struct record *print(head)

d)

struct record print(struct record *head)

8.

จากส่วนของโปรแกรม

tmp=Head;

while(tmp->next !=NULL)

{ cout << tmp->value;

tmp=tmp->next;

}

ผลลัพธ์ที่แสดงบนจอภาพคืออะไร

a)

4 5 10 15 20

b)

4 5 10 15

c)

4

d)

15

9.

จากส่วนของโปรแกรม

tmp=Head;

while(tmp->next!=NULL)

{tmp=tmp->next;

}

cout << tmp->value;

จะแสดงผลลัพธ์อะไรบนจอภาพ

a)

4

b)

4 5 10 15 20

c)

20

d)

15

10.

ถ้า linked list มีข้อมูลจำนวน n ตัว loop while ต่อไปนี้ทำงานกี่รอบ

p=head;

while(p->next!= NULL)

{ p=p->next;

}

a)

n

b)

n-1

c)

n+1

d)

1