Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am habing trouble with these problems for my review sheet. If you could please help, I will upvote clear helpful response. Also if you

I am habing trouble with these problems for my review sheet. If you could please help, I will upvote clear helpful response. Also if you could go into a bit more detail with questions #6 and #7 I would appreicate it. Thanks

1. 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.

2. 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.

3. 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*

4. 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*&

5.

Consider the usual algorithm for determining whether a sequence of parentheses is balanced. Suppose that you run the algorithm on a sequence that contains 2 left parentheses and 3 right parentheses (in some order). What is the maximum number of parentheses that will ever appear on the stack AT ONE TIME during the computation?

A. 1

B. 2

C. 3

D. 4

E. 5 or more

6.In the circular array version of the queue class (with a fixed-sized array), which operations require linear time for their worst-case behavior?

A. front

B. push

C. empty

D. None of these operations require linear time.

7. In the linked-list version of the queue class, which operations require linear time for their worst-case behavior?

A. front

B. push

C. empty

D. None of these operations require linear 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

Students also viewed these Databases questions