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
Here's the requirement. Write a client program Subset.java that takes a command-line integer k , reads...
Here's the requirement. Write a client program Subset.java that takes a command-line integer k , reads in a sequence of strings from standard input using StdIn.readString() , and prints out exactly k of them, uniformly at random. Each item from the sequence can be printed out at most once. You may assume that 0 k N , where N is the number of string on standard input. The running time of the program must be linear in the size of...
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...
Lab 02, Data Abstractions and Structures, CSE 274, Fall 2019 Linked Bag In this lab, we...
Lab 02, Data Abstractions and Structures, CSE 274, Fall 2019 Linked Bag In this lab, we will implement the Linked Bag. The bag will contain a sequence of strings. First, you need to design the Node class (Node.java). It will contain an integer data and a reference to the next Node. The constructor of Node class receives an integer and assigns it to the data field. It also has a default constructor. Then we will design another class named LinkedBag...
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...
You can complete this assignment individually or as a group of two people. In this assignment...
You can complete this assignment individually or as a group of two people. In this assignment you will create a ​​Sorted Singly-Linked List​ that performs basic list operations using C++. This linked list should not allow duplicate elements. Elements of the list should be of type ‘ItemType’. ‘ItemType’ class should have a private integer variable with the name ‘value’. Elements in the linked list should be sorted in the ascending order according to this ‘value’ variable. You should create a...