1 / 6

a. ptr = ptr->link; b. ptr++; c. *ptr = ptr->link; d. ptr = *ptr; e. ptr->link = ptr;

0. Given the declarations struct ListNode { float volume; ListNode* link; }; ListNode* ptr; which of the following statements advances ptr to point to the next node of a list?. a. ptr = ptr->link; b. ptr++; c. *ptr = ptr->link; d. ptr = *ptr; e. ptr->link = ptr;.

niel
Télécharger la présentation

a. ptr = ptr->link; b. ptr++; c. *ptr = ptr->link; d. ptr = *ptr; e. ptr->link = ptr;

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 0 Given the declarations struct ListNode { float volume; ListNode* link; }; ListNode* ptr; which of the following statements advances ptr to point to the next node of a list? • a. ptr = ptr->link; • b. ptr++; • c. *ptr = ptr->link; • d. ptr = *ptr; • e. ptr->link = ptr;

  2. 0 The following code, which builds a linked list with the numbers 18 and 32 as its components, has a missing statement. What should the statement be? struct NodeType { int data; NodeType* link; }; NodeType* head, p, q; p = new NodeType; head = p; p->data = 18; q = new NodeType; q->data = 32; <-- Statement is missing here q->link = NULL; • a. p = q; • b. p->link = new NodeType; • c. p->link = q; • d. p->link = q->link;

  3. 0 What is special about the last node in a dynamic linked list? • a. Its component (data) member is undefined. • b. Its component (data) member contains the value 0. • c. Its link member is undefined. • d. Its link member contains the value NULL. • e. It has no link member

  4. 0 If a program accidentally corrupts the link member of a node in the middle of a linked list, how much of the original linked list is now inaccessible? a. only the corrupted node is inaccessible b. all nodes preceding the corrupted node are inaccessible c. all nodes following the corrupted node are inaccessible d. the entire linked list is inaccessible

  5. 0 Given the declarations struct ListNode { float volume; ListNode* link; }; ListNode* headPtr; assume that headPtr is the external pointer to a linked list of many nodes. Which statement removes the first node from the list? (Ignore deallocation of the node.) • a. headPtr = headPtr->link; • b. *headPtr = headPtr->link; • c. headPtr->link = headPtr->link->link; • d. headPtr = headPtr.link; • e. none of the above

  6. 0 The following code is meant to search a linked list of 4 nodes for item. If item is not in the list, what is printed? currPtr = head ;string found = “false”;int position = 0; while ( item != currPtr->info && currPtr != NULL ) { currPtr = currPtr->link ; position++; } if (item == currPtr->info) found = “true”;cout << “found:”<<found<<“ position:”<<position<<endl; • a. found:false position: 3 • b. found:false position: 4 • c. found:true position: 3 • d. found:true position: 4 • e. none of the above

More Related