Multiple Choice
Multiple Choice Section 3.1 The Bag ADT |
bag b; b.insert(5); b.insert(4); b.insert(6);What will be the values of b.used and b.data after the statements?
bag b; b.insert(5); b.insert(4); b.insert(6); b.erase_one(5);
for (i = 0; ___________________________________________; i++) cout << data[i] << endl;What is the correct way to fill in the blank? (If there is more than one correct answer, please select E.)
Multiple Choice Section 3.2 The Sequence ADT |
class sequence { public: typedef double value_type; typedef std::size_t size_type; static const size_type CAPACITY = 30; ... private: value_type data[CAPACITY]; size_type used; };The sequence's constructor sets used to zero, but does not place any values in the data array. Why?
Multiple Choice Section 3.3 Interactive Test Programs |
`Hey,
Note: Brother in case of any queries, just comment in box I would be very happy to assist all your queries
1)
OPTION B IS CORRECT
2)
OPTION A IS CORRECT
3)
OPTION A IS CORRECT
4)
OPTION B IS CORRECT
Kindly revert for any queries
Thanks.
Multiple Choice Multiple Choice Section 3.1 The Bag ADT For the bag class in Chapter 3...
Multiple Choice Multiple Choice Section 4.1 Pointers and Dynamic Memory Consider the following statements: int *p; int i; int k; i = 42; k = i; p = &i; After these statements, which of the following statements will change the value of i to 75? A. k = 75; B. *k = 75; C. p = 75; D. *p = 75; E. Two or more of the answers will change i to 75. Consider the following statements: int i =...
1.Suppose that the goop function from the previous question changes the value of z[1]. Does this change effect the value of the actual argument? A. Yes B. No 2.Here is a function declaration: void goo(int* x) { *x = 1; } Suppose that a is an int* variable pointing to some integer, and *a is equal to zero. What is printed if you print *a after the function call goo(a)? A. 0 B. 1 C. address of a D. address...
c++ Sequence class is a class that supports sequence of integers. Run the project ad verify that project works for integers. Next convert your sequence class into a template class. Demonstrate in your main function by using a sequence of int, float, string. sequence.cxx #include // Provides assert using namespace std; namespace main_savitch_3 { sequence::sequence() { used = 0; current_index = 0; } void sequence::start() { current_index = 0; } void sequence::advance() // Library facilities used: assert.h { assert(is_item()); current_index++;...
members of a class non-friends, non-members of a class All of the above be 13. Why do you want to usually make data members private in a class? so that no one can use the class ensure data integrity b. provide data abstraction c provide information hiding. d. e. Band D B.C and D 14. The copy constructor for a class is called when an object of the class is passed by value to a function. when an object of...
PLEASE HURRY. Below is the prompt for this problem. Use the code for bag1.cxx, bag1.h and my code for bag.cpp. Also I have provided errors from linux for bag.cpp. Please use that code and fix my errors please. Thank you The goal of assignment 3 is to reinforce implementation of container class concepts in C++. Specifically, the assignment is to do problem 3.5 on page 149 of the text. You need to implement the set operations union, intersection, and relative...
In class, we discussed the priority queue (PQ) ADT implemented using min-heap. In a min-heap, the element of the heap with the smallest key is the root of the binary tree. On the other hand, a max-heap has as root the element with the biggest key, and the relationship between the keys of a node and its parent is reversed of that of a min-heap. We also discussed an array-based implementation of heaps. In this assignment, your task is to...
The purpose of this lab is to help reinforce container class concepts and linked list concepts in C++. Specifically, the lab to repeat the sequence lab from last week except to use a linked list. You need to use the author's files sequence3.h and sequence_exam3.cpp. Author - Michael Main, Book - Data Structures and other objects using c++, 4th edition // FILE: sequence3.h // CLASS PROVIDED: sequence (part of the namespace main_savitch_5) // This is the header file for the...
The purpose of this program is to help reinforce container class concepts and linked list concepts in C++. Specifically, the task is to implement the sequence class using a linked list. You need to use the author's file sequence3.h to create your implementation file named sequence3.cpp. Please make your code as efficient and reusable as possible. Please make sure code can pass any tests. sequence3.h // FILE: sequence3.h // CLASS PROVIDED: sequence (part of the namespace main_savitch_5) // This is...
You will write the following files: mystack.h - contains the class definition for the mystack class. mystack.cpp - contains the definitions for member functions of the mystack class. inpost.cpp - contains your convert() function. inpost.h - contains the function prototype for convert() so that the main() can call it. Each of the files (with the exception of inpost.h) is described in more detail below. All header files should contain header guards to prevent them from being included multiple times in...
41. True or False? Searching the components of an unordered list ADT is faster with a linked list representation than with a direct array representation. a) true b) false 42. True or False? If an operation that allows random access to individual components of a list ADT is defined and occurs frequently, it is better to represent the list directly as an array than to use a linked list. a) true b) false 43. To prevent a compile-time error, how...