Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ Multiple Choice questionhelp please~ Which of the following is a disadvantag

ID: 3830610 • Letter: C

Question

C++ Multiple Choice questionhelp please~

Which of the following is a disadvantage to implementing a dynamic singly linked list? A. Random access is not allowed. We have to access elements sequentially starting from the first node. So we cannot do binary search with linked lists. B. Extra memory space for a pointer is required with each element of the list C. Cannot in constant time determine what is at item n in the list D. All of the above are disadvantages Consider the following function to traverse a linked list. void traverse (struct Node *head) {while (head -> next != NULL) {printf ("%d ", head -> data); head = head -> next;}} Which of the following is FALSE about the above function? A. The function is implemented incorrectly because it changes head B. The function may crash when the linked list is empty C. The function doesn't print the last node when the linked list is not empty The operation for adding an entry to a stack is traditionally called: A. add B. append C. insert D. push The following function reverse() is supposed to reverse a singly linked list. There is one line missing at the end of the function./* Link list node */struct node {int data; struct node* next;};/* head_ref is a double pointer which points to head (or start) pointer of linked list */static void reverse (struct node** head_ref) {struct node* prev = NULL; struct node* current = *head_ref; struct node* next; while (current != NULL) {next = current -> next; current -> next = prev; prev = current; current = next;}/*ADD A STATEMENT HERE*/} What should be added in place of "/*ADD A STATEMENT HERE*/", so that the function correctly reverses a linked list? A. *head_ref = prev; B. *head_ref = current; C. *head_ref = next; D. *head_ref = NULL;

Explanation / Answer

21. D All options are correct

22. B will give segmentation fault and crash to make it correct use while(head != NULL)

23. Push

24. A. *head_ref = prev will reverse as prev will contain last node when current become null

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote