AQA A Level · Computer Science 7517

Queues: แบบฝึกหัด

ข้อปรนัย 5 ข้อ ตรวจให้ทันทีที่ตอบ และข้อเขียน 4 ข้อ พร้อมวิธีทำละเอียด ทั้งหมดจากเรื่อง Queues

9 ข้อ24 คะแนนฟรี ไม่ต้องสมัคร
ข้อ 1
1 คะแนน

In a priority queue, how is the position of an item determined when it is added to the structure?

ข้อ 2
1 คะแนน

A circular queue is implemented using an array of size 4 (indices 0 to 3). The queue currently contains the following data:
Index 0: [Empty]
Index 1: 'A'
Index 2: 'B'
Index 3: 'C'

If the front pointer is 1 and the rear pointer is 3, what happens to the rear pointer when item 'D' is added?

ข้อ 3
1 คะแนน

A priority queue is implemented using an ordered list where the highest priority item is at the front. If a new item with priority \(P\) is added, and there are currently \(n\) items in the queue, what is the worst-case time complexity for the add operation?

ข้อ 4
1 คะแนน

Which of the following operations is necessary to test if a linear queue implemented using a static array of size N is full?

ข้อ 5
1 คะแนน

A linear queue is implemented using a static array of size 6 (indices 0 to 5).

Initially, the queue is empty with front at 0 and rear at -1. The following operations occur:
1. Enqueue 'X', 'Y', 'Z'
2. Dequeue two items
3. Enqueue 'W'

What are the current values of the front and rear pointers?

ข้อ 6
3 คะแนน

Consider a linear queue implemented with a static array of size 10. After several additions and removals, the front pointer is at index 9 and the rear pointer is also at index 9. Explain why this queue might be reported as 'full' even if index 0 to 8 are empty.

ลองเขียนคำตอบด้วยตัวเองก่อน แล้วค่อยเทียบกับวิธีทำ

ข้อ 7
5 คะแนน

A priority queue is used in a CPU scheduler. If three tasks with priorities 1, 5, and 3 (where 5 is the highest priority) are added in that order, what is the logical order in which they will be removed?

ลองเขียนคำตอบด้วยตัวเองก่อน แล้วค่อยเทียบกับวิธีทำ

ข้อ 8
4 คะแนน

A Priority Queue is used to manage print jobs. Each job has a priority level (1 = High, 5 = Low).

a. If the queue contains jobs with priorities [3, 1, 4] in that order, which job will be removed first? (1 point)
b. Describe the steps to add a job with priority 2 to a priority queue implemented as an ordered list. (2 points)
c. How does the remove operation in a priority queue differ from that in a standard FIFO linear queue? (1 point)

ลองเขียนคำตอบด้วยตัวเองก่อน แล้วค่อยเทียบกับวิธีทำ

ข้อ 9
7 คะแนน

A circular queue is implemented using a fixed-size array of 8 elements, indexed 0 to 7. The current state of the queue is as follows:
- front pointer: 6
- rear pointer: 1
- size: 4

a. Identify the indices of the array that currently contain data, assuming the rear pointer points to the last element added. (2 points)

b. Describe the steps involved in adding a new item to this circular queue. In your answer, include the specific calculations for updating the rear pointer using the MOD operator, given the array size of 8. (3 points)

c. Explain how a circular queue differs from a linear queue in terms of memory utilization. (2 points)

ลองเขียนคำตอบด้วยตัวเองก่อน แล้วค่อยเทียบกับวิธีทำ

* เนื้อหาของ thinka สร้างโดย AI อาจไม่ถูกต้องสมบูรณ์ในทุกกรณี กรุณาใช้เป็นสื่อเสริมและตรวจสอบกับเอกสารอ้างอิงอย่างเป็นทางการ

คุณเห็นเฉลยแล้ว ทีนี้มาตรวจคำตอบของคุณบ้าง

หน้านี้บอกได้ว่าคำตอบที่ดีเป็นอย่างไร แต่บอกไม่ได้ว่าคำตอบของคุณขาดอะไร thinka ตรวจข้อเขียนของคุณตามเกณฑ์ให้คะแนนจริงในราว 15 วินาที

อยากฝึกโจทย์แบบนี้เพิ่มไหม เริ่มฝึกหัวข้อนี้ได้เลย ตรวจให้ทันทีทุกข้อ

เริ่มฝึกเลย