Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

64. In the definition of the Node class below, what does the reserved word friend mean? class Node { public: Node(string s); private: string data;

64. In the definition of the Node class below, what does the reserved word friend mean?

class Node { public: Node(string s); private: string data; Node* previous; Node* next; friend class List; friend class Iterator; };

Group of answer choices

Encapsulation exception: List and Iterator objects are permitted to access the Node members

Aggregation: List and Iterator objects are defined within the Node object

Inheritance: List and Iterator objects are derived from the Node object

Encapsulation protection: List and Iterator objects are forbidden from accessing the Node members

66. For an operation that involves frequent traversal of data items, such as a binary search, which of the two is better, linked lists or vectors?

Group of answer choices

Linked lists

Both perform the same.

A binary search cannot be performed on linked lists and vectors.

Vectors

68. The code snippet below defines a stack variable my_stack. Assume the stack is declared and then populated with an unknown number of values. Which line of code should be replace expression so that each of the elements on the stack are printed?

stackmy_stack; // . . . while (my_stack.size() > 0) { cout << my_stack.top() << endl; expression }

Group of answer choices

my_stack.top();

my_stack.delete();

my_stack.push();

my_stack.pop();

69. Suppose you are given a variable declared as stack and its size is 25. Using that stack as the actual parameter, you call function p below. What is the size of the stack after function p finishes executing?

void p(stack&s) { if (s.size() > 0) { char my_char = s.top(); s.pop(); p(s); cout << my_char; } return; }

Group of answer choices

1

0

25

24

70. Which of the following statements is correct about maps and keys?

Group of answer choices

Both keys and values have multiple associations.

Every key in a map has a unique value, and every value in turn has a unique key.

Every key in a map has a unique value, but a value may be associated with several keys.

Every value in a map has a unique key, but a key may be associated with several values.

74. What will be the output of the following code snippet?

map scores; scores["Tom"] = 90; scores["Diana"] = 86; scores["Mark"] = 80; for (auto it = scores.begin(); it != scores.end(); it++) { cout << " " << it->second << ": " << it->first ; }

Group of answer choices

Compiler error, no output

86:Diana 80:Mark 90:Tom

80:Mark 86:Diana 90:Tom

90:Tom 86:Diana 80:Mark

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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