Question

The sequence's insert member function normally puts a new item before the current item. What should...

The sequence's insert member function normally puts a new item before the current item. What should insert do if there is no current item?

Question 6 options:

A)

The insert precondition is violated.

B)

The new item is put at the beginning of the sequence.

C)

The new item is put at the end of the sequence.

D)

None of the above.

Suppose the bag and sequence are both implemented with a fixed-size array as in Chapter 3. What is the difference between the private member variables of the bag and the private member variables of the sequence?

Question 7 options:

A)

The bag has an extra array of Items.

B)

The bag has one extra size_t variable.

C)

The sequence has an extra array of Items.

D)

The sequence has one extra size_t variable.

Suppose that the bag is implemented with a fixed-size array. Which of these operations are likely to have a constant worst-case time?

Question 8 options:

A)

insert

B)

count

C)

erase_one

D)

ALL of (A), (B), and (C) are likely to have a constant worst-case time.

Which of the following C++ features are used by the bag class of Chapter 3?

Question 10 options:

A)

static member constant

B)

short-circuit evaluation

C)

The C++ Standard Library

D)

All of the above

Homework Answers

Answer #1
Question 1:
The sequence's insert member function normally puts a new item before the current item.
The new item is put at the beginning of the sequence when there is no current item
Answer:
The new item is put at the beginning of the sequence.

Question 2:
difference between the private member variables of the bag and the private member variables of the sequence is that the sequence has one extra size_t variable.
Answer
The sequence has one extra size_t variable.

Question 3:
operations are likely to have a constant worst-case time is insert
Answer:
insert

Question 4:
stack features of C++ Standard Library cab be used by the bag class
Answer:
The C++ Standard Library
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
a) Please Select All That Apply: What are the possible applications of Priority Queue?      CPU Scheduling...
a) Please Select All That Apply: What are the possible applications of Priority Queue?      CPU Scheduling All queue applications where priority is involved.               kernel of NT for keep track of process information b) Running Time Analysis: Give the tightest possible big-O upper bound for the worst case running time for each operation listed below in terms of N. Assume no duplicate values and that you can implement the operation as a member function of the class – with access to...
this is the book name. Data Structures and Abstractions with Java 1) Description: The sample programs...
this is the book name. Data Structures and Abstractions with Java 1) Description: The sample programs in Chapter 1 of your textbook are not complete. They are used for illustration purpose only. The implementation of Listing 1-1 on page 39 is explained in Chapter 2. And, in order to see the result of using it, we will need the following set of files: i. BagInteface.java – the specification only. ii. ArrayBag.java – the implementation of BagInerface.java. iii. ArrayBagDemo.java – a...
This program extends the earlier "Online shopping cart" program. (Consider first saving your earlier program). Extend...
This program extends the earlier "Online shopping cart" program. (Consider first saving your earlier program). Extend the ItemToPurchase class per the following specifications              Private fields string itemDescription - Initialized in default constructor to "none" Parameterized constructor to assign item name, item description, item price, and itemquantity (default values of 0).             Public instance member methods setDescription() mutator & getDescription() accessor (2 pts) printItemCost() - Outputs the item name followed by the quantity, price, and subtotal printItemDescription() - Outputs the...
Code Example 8-1 1. int count = 1; 2. int item_total = 0; 3. int item...
Code Example 8-1 1. int count = 1; 2. int item_total = 0; 3. int item = 0; 4. while (count < 4) { 5.      cout << "Enter item cost: "; 6.      cin >> item; 7.      item_total += item; 8.      ++count; 9. } 10. int average_cost = round(item_total / count); 11. cout << "Total cost: " << item_total << "\nAverage cost: " << average_cost; (Refer to Code Example 8-1.) If the user enters 5, 10, and 15 at the prompts, the output is: Total...
Complete this in C++ and explain what is being done. 1      Introduction The functions in the...
Complete this in C++ and explain what is being done. 1      Introduction The functions in the following subsections can all go in one big file called pointerpractice.cpp. 1.1     Basics Write a function, int square 1(int∗ p), that takes a pointer to an int and returns the square of the int that it points to. Write a function, void square 2(int∗ p), that takes a pointer to an int and replaces that int (the one pointed to by p) with its...
I'm currently stuck on Level 3 for the following assignment. When passing my program through testing...
I'm currently stuck on Level 3 for the following assignment. When passing my program through testing associated with the assignment it is failing one part of testing.   Below is the test that fails: Failed test 4: differences in output arguments: -c input data: a b c -c expected stdout: b observed stdout: a b expected stderr: observed stderr: ./test: invalid option -- 'c' Unsure where I have gone wrong. MUST BE WRITTEN IN C++ Task Level 1: Basic operation Complete...
Project Integration Management Questions Only A team member notifies you, after the fact, that she has...
Project Integration Management Questions Only A team member notifies you, after the fact, that she has added extra functionality to the project. There was no impact on the cost or schedule. What should be done as a result of this change? Make sure marketing is aware of the change. Implement change control processes to track the change. Inform the customer. Understand what functionality was added. You are having difficulty getting a project underway. You have not been able to get...
Objective: Write a Java program that will use a JComboBox from which the user will select...
Objective: Write a Java program that will use a JComboBox from which the user will select to convert a temperature from either Celsius to Fahrenheit, or Fahrenheit to Celsius. The user will enter a temperature in a text field from which the conversion calculation will be made. The converted temperature will be displayed in an uneditable text field with an appropriate label. Specifications Structure your file name and class name on the following pattern: The first three letters of your...
Item 1 In the case below, the original source material is given along with a sample...
Item 1 In the case below, the original source material is given along with a sample of student work. Determine the type of plagiarism by clicking the appropriate radio button. Original Source Material Student Version Major changes within organizations are usually initiated by those who are in power. Such decision-makers sponsor the change and then appoint someone else - perhaps the director of training - to be responsible for implementing and managing change. Whether the appointed change agent is in...
I've posted this question like 3 times now and I can't seem to find someone that...
I've posted this question like 3 times now and I can't seem to find someone that is able to answer it. Please can someone help me code this? Thank you!! Programming Project #4 – Programmer Jones and the Temple of Gloom Part 1 The stack data structure plays a pivotal role in the design of computer games. Any algorithm that requires the user to retrace their steps is a perfect candidate for using a stack. In this simple game you...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT