1. The following code snippet shows a printing function for a sparse matrix implemented with a linked-list. Circle the option that best describes the efficiency of such a function:void PrintMatrix_Slow(Node *listpointer, int size) {//added size to help for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { printf("%d ", Search(listpointer, i, j)); } printf("\n"); } printf("\n"); }a) This is inefficient because the linked-list can be accessed randomly. b) This is the most efficient way to write a printing function because the linked-list has to be traversed from the head for every new Search(O call. c) This is inefficient because the linked-list has to be traversed from the head for every new Search() call. d) This is the most efficient way to write a printing function, as linked-list can be accessed randomly.请帮我选出答案
时间: 2024-02-14 22:36:15 浏览: 54
array 和linklist在查询和增加的时候实现的效率问题
答案是c) This is inefficient because the linked-list has to be traversed from the head for every new Search() call. 在该函数中,对于每个元素,都需要从链表头部开始搜索,这样会导致时间复杂度增加。应该考虑使用其他数据结构或优化搜索算法来提高效率。
阅读全文