Question: Multiple Choice Multiple Choice Sections 5.1-5.2 Linked List Fundamentals Suppose cursor points to a node in a linked list (using the node definition with member

Multiple Choice

Multiple Choice Sections 5.1-5.2 Linked List Fundamentals
  1. Suppose cursor points to a node in a linked list (using the node definition with member functions called data and link). What statement changes cursor so that it points to the next node?
    • A. cursor++;
    • B. cursor = link( );
    • C. cursor += link( );
    • D. cursor = cursor->link( );

  2. Suppose cursor points to a node in a linked list (using the node definition with member functions called data and link). What Boolean expression will be true when cursor points to the tail node of the list?
    • A. (cursor == NULL)
    • B. (cursor->link( ) == NULL)
    • C. (cursor->data( ) == NULL)
    • D. (cursor->data( ) == 0.0)
    • E. None of the above.

  3. Why does our node class have two versions of the link member function?
    • A. One is public, the other is private.
    • B. One is to use with a const pointer, the other with a regular pointer.
    • C. One returns the forward link, the other returns the backward link.
    • D. One returns the data, the other returns a pointer to the next node.

  4. Suppose that p is a pointer variable that contains the NULL pointer. What happens if your program tries to read or write *p?
    • A. A syntax error always occurs at compilation time.
    • B. A run-time error always occurs when *p is evaluated.
    • C. A run-time error always occurs when the program finishes.
    • D. The results are unpredictable.

  5. Suppose that f is a function with a prototype like this:
     void f(________ head_ptr); // Precondition: head_ptr is a head pointer for a linked list. // Postcondition: The function f has done some computation with // the linked list, but the list itself is unchanged. 
    What is the best data type for head_ptr in this function?
    • A. node
    • B. const node
    • C. node*
    • D. const node*

  6. Suppose that f is a function with a prototype like this:
     void f(________ head_ptr); // Precondition: head_ptr is a head pointer for a linked list. // Postcondition: The function f has done some manipulation of // the linked list, and the list might now have a new head node. 
    What is the best data type for head_ptr in this function?
    • A. node
    • B. node&
    • C. node*
    • D. node*&

    Multiple Choice Section 5.3 The Bag ADT with with a Linked List

  7. In the linked list version of the bag class a member variable many_nodes is used to keep track of how long the linked list is. Why not just make a call to the list toolkit function list_length()?
    • A. The list_length() function is O(n) and the alternative is O(1).
    • B. The list_length() function is private.
    • C. The list_length() function results in an infinite loop for circular lists.
    • D. The list_length() function works only for lists of integers.

  8. Suppose that the bag is implemented with a linked list. Which of these operations are likely to have a constant worst-case time?
    • A. insert
    • B. count
    • C. erase_one
    • D. None of (A), (B), and (C) have a constant worst-case time
    • E. TWO of (A), (B), and (C) have a constant worst-case time
    • F. ALL of (A), (B), and (C) have a constant worst-case time

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!