Which of the following algorithms will run in constant time?(1 point) Responses sorting an array sorting an array binary search on a sorted array binary search on a sorted array traversing an array traversing an array accessing an element of an array

3 answers

The algorithm that will run in constant time (O(1)) is accessing an element of an array.

  • Sorting an array: This requires O(n log n) time complexity.
  • Binary search on a sorted array: This has a time complexity of O(log n).
  • Traversing an array: This has a time complexity of O(n).

Thus, the only operation that runs in constant time is accessing an element of an array.

Which of these matches keys to values and stores and stores them?(1 point) Responses hash table hash table unsorted array unsorted array efficiency efficiency simple data structure

The correct response that matches keys to values and stores them is a hash table. A hash table is a data structure that uses a hash function to map keys to values, enabling efficient data retrieval.

  • Unsorted array: This does not inherently match keys to values, as it simply stores elements in an array without associated keys.
  • Efficiency: This term refers to the performance of an algorithm or data structure, not a specific data structure.
  • Simple data structure: This is a general term and does not specifically relate to the matching of keys to values.

Therefore, the answer is hash table.