Question
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=new Node
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
int a=0;
while(currentNode!=NULL){
a++;
currentNode=currentNode->getNext();
}
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
int a=1;
while(currentNode!=NULL){
if(currentNode->getItem()!=11){
a++;
currentNode=currentNode->getNext();
}
else{
break;
}
}
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
while(currentNode!=NULL){
if(currentNode->getItem()<9){
currentNode=currentNode->getNext();
}
else{
break;
}
}
cout<
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
int a=0;
while(currentNode!=NULL){
if(currentNode->getItem()%5==0)
a++;
currentNode=currentNode->getNext();
}
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started