AQA A Level · Computer Science 7517

Dictionaries: แบบฝึกหัด

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

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

Which of the following describes a dictionary as an abstract data type?

ข้อ 2
1 คะแนน

A 4-vector over \( \mathbb{R} \) is represented as a dictionary mapping indices to values. Given the vector:
\( 0 \mapsto 2.0 \)
\( 1 \mapsto 3.14 \)
\( 2 \mapsto -1.0 \)
\( 3 \mapsto 2.72 \)
Which of the following is the correct representation of this vector in Python dictionary syntax?

ข้อ 3
1 คะแนน

A dictionary is used to represent a sparse vector in a high-dimensional space. If a vector in \( \mathbb{R}^5 \) is defined as \( v = [0, 1.5, 0, 0, -3.2] \), which dictionary representation is both memory-efficient and logically correct based on the index-to-value mapping?

ข้อ 4
1 คะแนน

A programmer is representing a document containing the words 'The green, green grass grows' as a dictionary by mapping each unique word to its frequency of occurrence. What would be the correctly formatted dictionary representation, ignoring letter case?

ข้อ 5
2 คะแนน

A dictionary is a data structure consisting of key-value pairs. Describe the primary method used to access a value within a dictionary.

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

ข้อ 6
4 คะแนน

Explain why a dictionary can be considered a valid representation of a vector, and provide an example of the vector \([0.5, 0.0, 1.2]\) represented as a dictionary.

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

ข้อ 7
5 คะแนน

A Dictionary is used to represent the sparse vector \( [0, 0, 4.5, 0, -1.2] \) where indices map to values. Provide the dictionary representation and explain why this is more efficient than a 1D array for very large sparse vectors.

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

ข้อ 8
3 คะแนน

A Dictionary is an abstract data type that stores key-value pairs. Consider the following dictionary representing the inventory of a small store:
Inventory = {"Apple": 50, "Banana": 20, "Orange": 30}

a. What is the value associated with the key "Banana"? (1 point)
b. Describe the logical result of performing the operation Update(Inventory, "Apple", 45). (1 point)
c. What occurs if a programmer attempts to add a new key "Apple" with a different value? (1 point)

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

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

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

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

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

เริ่มฝึกเลย