Quiz 1
Quiz 1
Dashboard / My courses /
CMPS2131-LFL / 31 August - 6 September /
Quiz 1: Units 1 & 2
Question 1
Correct
Lists of data can be stored in arrays, but linked lists provide several advantages except.
a. Linked lists are dynamic, so the length of a list can increase or decrease as necessary.
c. Linked lists allow random access and use less memory per element.
Question 2
Correct
In linked list each node contains a minimum of two fields. One field is data field to store the data second field is?
a. Pointer to integer
b. Node
c. Pointer to character
d. Pointer to node
https://doit.ub.edu.bz/mod/quiz/review.php?attempt=29371&cmid=9104 1/10
9/10/21, 3:27 PM Quiz 1: Units 1 & 2: Attempt review
Question 3
Correct
A Constructor is a special 'MEMBER FUNCTION' having the same name as that of its class which is used to initialize
some valid values to the data members of an object. ... The constructor can be defined as a class in the same way as that of
normal member functions and can access any of its data members.
Question 4
Incorrect
A node contains a pointer member that points to an object of the same class type.
Question 5
Correct
Select one:
True
False
https://doit.ub.edu.bz/mod/quiz/review.php?attempt=29371&cmid=9104 2/10
9/10/21, 3:27 PM Quiz 1: Units 1 & 2: Attempt review
Question 6
Complete
For the snippet of code below, create a display function. The function will traverse the nodes and display the assigned values as
outputs to the user.
int main()
{
second->Value=2;
third->Value=3;
fourth->Value=4;
system("pause>0");
}
#include<stdlib.h>
#include<iostream>
usingnamespacestd;
struct node{
int data;
struct node*next;
};
void display(node*n){a
while(n!=NULL){//whilenisnotequaltonull
cout<<n->data<<"";//print n
n=n->next;
https://doit.ub.edu.bz/mod/quiz/review.php?attempt=29371&cmid=9104 3/10
9/10/21, 3:27 PM Quiz 1: Units 1 & 2: Attempt review
Question 7
Complete
struct Node
int data;
};
This is a self-referential class. Contains a pointer member that points to an object of the same class type.
struct Node //name of class is node
struct Node* next; //pointer data member next is a link. can tie a node to another node
};
Question 8
Correct
https://doit.ub.edu.bz/mod/quiz/review.php?attempt=29371&cmid=9104 4/10
9/10/21, 3:27 PM Quiz 1: Units 1 & 2: Attempt review
Question 9
Correct
A(n) _____________is an operation that creates a new instance (object) of an abstract data type.
a. A destructor
b. An iterator
c. A constructor
Question 10
Correct
A node can not contain data of any type, including objects of other classes.
Select one:
True
False
Question 11
Correct
A Data structure is a collection of data elements whose organization is characterized by accessing operations that are
used to store and retrieve the individual data elements; the implementation of the composite data members in an abstract data
type
Question 12
Correct
A linear collection of self-referential class objects, called nodes, connected by pointer links.
a. linked list
b. node
c. data structure
https://doit.ub.edu.bz/mod/quiz/review.php?attempt=29371&cmid=9104 5/10
9/10/21, 3:27 PM Quiz 1: Units 1 & 2: Attempt review
Question 13
Correct
A __________ is a data-type that has its own members. It is the basic building block of OOP in C++. It's members are accessed in
programming languages by creating instances and may be user defined.
b. stack
c. class
Question 14
Correct
The linked list node is decomposed into two basic parts: the data and address to the next node(pointer).
https://doit.ub.edu.bz/mod/quiz/review.php?attempt=29371&cmid=9104 6/10
9/10/21, 3:27 PM Quiz 1: Units 1 & 2: Attempt review
Question 15
Incorrect
if(size ==0)
head = node;
else
Node temp,cur;
cur.setNext(node);
}
size++;
Question 16
Correct
By convention, the link pointer in the last node of a list is set to null (0) to mark the end of the list.
Select one:
True
False
https://doit.ub.edu.bz/mod/quiz/review.php?attempt=29371&cmid=9104 7/10
9/10/21, 3:27 PM Quiz 1: Units 1 & 2: Attempt review
Question 17
Complete
Question 18
Complete
https://doit.ub.edu.bz/mod/quiz/review.php?attempt=29371&cmid=9104 8/10
9/10/21, 3:27 PM Quiz 1: Units 1 & 2: Attempt review
Question 19
Correct
c. Fixed size
Jump to...
The Information Technology Program prepares students for work, further study and research in the Information Technology field locally,
regionally and globally. The program provides knowledge, skills and the discipline that will enable graduates to make a positive impact
on the working environment and be able to function as entrepreneurs in the community.
Quick Links
About UB
About FST
UB Virtual Tour
UB Student Portal
Follow Us
Contact
Hummingbird Avenue, City of Belmopan
https://doit.ub.edu.bz/mod/quiz/review.php?attempt=29371&cmid=9104 9/10
9/10/21, 3:27 PM Quiz 1: Units 1 & 2: Attempt review
https://doit.ub.edu.bz/mod/quiz/review.php?attempt=29371&cmid=9104 10/10