Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

6. Assume a linked list contains following integers: 6, 2, 4, 5, 8, 3, 5 and the pointer head is pointing to the first node

6. Assume a linked list contains following integers: 6, 2, 4, 5, 8, 3, 5 and the pointer head is pointing to the first node of the list. What will be the value of variable a after the following statements are executed:

Node *curNode;

curNode=new Node(5,head);

head=curNode;

int a=0;

while(curNode!=NULL){

a+=curNode->getItem();

curNode=curNode->getNext();

}

Group of answer choices

a) 38

b) 15

c) 17

d) 33

7.

Assume the pointer head is holding the address of the first node of a linked list and such linked list is holding following integers: 6, x, 3, -2, x, 11, 4, 2 (with 6 in the first node of the list). What will be shown on the output screen after following statements are executed?

Node *currentNode=head;

int a=0;

while(currentNode!=NULL){

a++;

currentNode=currentNode->getNext();

}

cout<

Group of answer choices

a) 6 x 3 -2 x 11 4 2

b) x

c) 2x+24

d) 8

8. Assume the pointer head is holding the address of the first node of a linked list and such linked list is holding following integers: 5, 8, 3, -2, 10, 11, x, 2. What will be showing on the output screen after following statements are executed?

Node *currentNode=head;

int a=1;

while(currentNode!=NULL){

if(currentNode->getItem()!=11){

a++;

currentNode=currentNode->getNext();

}

else{

break;

}

}

cout<

Group of answer choices

a) 24

b) 5

c) x

d) 6

9. Assume a linked list contains following integers: -3, 2, 4, 5, 8, 11, x (with -3 in the first node of the list) and the pointer head is pointing to the first node of the list. What will be showing on the output screen after the following statements are executed:

Node *currentNode=head;

while(currentNode!=NULL){

if(currentNode->getItem()<9){

currentNode=currentNode->getNext();

}

else{

break;

}

}

cout<getItem()<

Group of answer choices

a) -3

b) 8

c) x

d) 11

10. Assume a linked list contains following integers: -3, 2, 4, 5, 8, 2, 15 and the pointer head is pointing to the first node of the list. What will be showing on the output screen after the following statements are executed:

Node *currentNode=head;

int a=0;

while(currentNode!=NULL){

if(currentNode->getItem()%5==0)

a++;

currentNode=currentNode->getNext();

}

cout<

Group of answer choices

a) 5

b) 7

c) 6

d) 2

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

More Books

Students also viewed these Databases questions

Question

2. What are the prospects for these occupations?

Answered: 1 week ago