Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 2 Lnai 9285

Authors: Annalisa Appice ,Pedro Pereira Rodrigues ,Vitor Santos Costa ,Joao Gama ,Alipio Jorge ,Carlos Soares

1st Edition

3319235249, 978-3319235240

Students also viewed these Databases questions