C Questions What is the output of the following pseudocode c

C++ Questions

What is the output of the following pseudocode code:

ages = new List

Append(ages, 55)

Append(ages, 88)

Append(ages, 66)

Print(ages)

55, 66, 88

55, 88, 66

55, because there is no loop

66, because there is no loop

None of the above.

QUESTION 2

Type the list after the given operations. Each question starts with an empty list. Type the list as: 5, 7, 9

Append(list, 3)
Append(list, 2)
Append(list, 1)
Remove(list, 3)

3, 2

2, 1

1, 2

2, 3

None of the above.

QUESTION 3

Assume 11 element list alist contains the characters in the string \"mathematics\". What is the sequence of elements after executing the instructions?

list<char> alist;

list<char>::iterator iter;

iter = alist.begin();

iter++;

alist.erase(iter++);

iter++;

alist.erase(iter);

alist.pop_front();

m a t   h e m a t

a t h e   m a t i

m t e a t i c s

t e m a t i c s

None of the above.

QUESTION 4

Given a list with nodes \'Z\', \'A\', \'B\', Sort(list) yields \'A\', \'B\', \'Z\'.

True

False

Lists can not be sorted

Not enough information whether it is ascending or descending.

None of the above.

QUESTION 5

Assume the declaration:

string weekName[] = {\"Sun\", \"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\");

const int DAYSINWEEK = 7;

list<string>::iterator strIterA, strIterB;

After executing the following instructions, strIterA is the location of day _______.

strIterA = weekList.end();

strIterA--;

strIterA--;

Mon

Wed

Fri

Tues

None of the above.

A.

55, 66, 88

B.

55, 88, 66

C.

55, because there is no loop

D.

66, because there is no loop

E.

None of the above.

Solution

Please follow the data and description :

a)

Given, pseudocode as

ages = new List
Append(ages, 55)
Append(ages, 88)
Append(ages, 66)
Print(ages)

Here the data is appended to the list so the data in the list is given as 55, 88, 66.

So the answer is OPTION B(55, 88, 66).

b)

After the given operations we have the resultant list as

Append(list, 3)
Append(list, 2)
Append(list, 1)
Remove(list, 3)

2,1

So the answer is OPTION B(2,1).

c)

After the given operations we have the resultant list as

list<char> alist;
list<char>::iterator iter;
iter = alist.begin();
iter++;
alist.erase(iter++);
iter++;
alist.erase(iter);
alist.pop_front();


t e m a t i c s

So the answer is OPTION D (t e m a t i c s).

d)

Given a list with nodes \'Z\', \'A\', \'B\', Sort(list) yields \'A\', \'B\', \'Z\'.

We can\'t use std::sort to sort std::list, because std::sort requires iterators to be random access, and std::list iterators are only bidirectional.

So the answer is OPTION C(Lists can not be sorted).

e)

From the code we could see that the list named weekList is not present. So the answer is OPTION E (None of the Above).


Hope this is helpful.

C++ Questions What is the output of the following pseudocode code: ages = new List Append(ages, 55) Append(ages, 88) Append(ages, 66) Print(ages) 55, 66, 88 55,
C++ Questions What is the output of the following pseudocode code: ages = new List Append(ages, 55) Append(ages, 88) Append(ages, 66) Print(ages) 55, 66, 88 55,
C++ Questions What is the output of the following pseudocode code: ages = new List Append(ages, 55) Append(ages, 88) Append(ages, 66) Print(ages) 55, 66, 88 55,

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site