CompTIA PenTest+ (PT0-002) — Question 157

An exploit developer is coding a script that submits a very large number of small requests to a web server until the server is compromised. The script must examine each response received and compare the data to a large number of strings to determine which data to submit next. Which of the following data structures should the exploit developer use to make the string comparison and determination as efficient as possible?

Answer options

Correct answer: C

Explanation

The correct answer is C, a dictionary, because it allows for average-case constant time complexity for lookups, making string comparisons efficient. Other options like a list or an array would require linear time complexity for searching, while a tree, although more efficient than a list, would still not match the performance of a dictionary for this specific use case.