Question
31. Given the code fragment struct NodeType { int data; NodeType* next; }; NodeType* p; NodeType* q; p = new NodeType; p->data = 12; q
31. Given the code fragment
struct NodeType { int data; NodeType* next; }; NodeType* p; NodeType* q; p = new NodeType; p->data = 12; q = new NodeType; p->data = 12;
p->next = NULL; q->new NodeType; q->data = 5;
q->next= p;
which of the following expressions has the value NULL?
a) p
b) q
c) q->next
d) q->next->next
e) none of the above
32. If a program accidentally corrupts the next member of a node in the middle of a linked list, how much of the original linked list is now inaccessible?
a) only the corrupted node is inaccessible
b) all nodes preceding the corrupted node are inaccessible
c) all nodes following the corrupted node are inaccessible
d) the entire linked list is inaccessible
33. The following code, which builds a linked list with the numbers 18 and 32 as its components, has a missing statement. What should the statement be? struct NodeType { int data; NodeType* next; }; NodeType* p; NodeType* q; p = new NodeType; p->data = 18; q = new NodeType; q->data = 32; <--- Statement is missing here q->next = NULL; the original linked list is now inaccessible?
a) p = q;
b) p-> = new NodeType;
c) p->next = q;
d) p->next = q->next;
e) q = p->next;
34. Given the declarations struct ListNode { float volume; ListNode* next; }; ListNode* headPtr; assume that headPtr is the external pointer to a linked list of many nodes. Which statement deletes the first node? (Ignore deallocation of the node.)
a) headPtr = headPtr->next;
b) *headPtr = headPtr->next;
c) headPtr->next = headPtr->next->next;
d) headPtr->(*next) = headPtr->next->next;
e) none of the above
35. The order of determining the length of a list.
a) O(1)
b) O(logN)
c) O(N)
d) O(NlogN)
e) not enough informaiton
36. The order of inserting into an unordered array-based list.
a) O(1) b) O(logN) c) O(N) d) O(NlogN) e) not enough informaiton |
37. True or False? A linear relationship is one in which all elements have a unique predecessor and a unique successor.
a) True
b) False
38. True or False? Given only the external pointer to a linked list, it is faster to insert a node at the front of the list than at the back.
a) True
b) False
39. True or False? The external pointer is considered to be one of the nodes of a linked list.
a) True
b) False
40. True or False? Reading components into an initially empty list is faster if the list is represented directly as an array rather than a linked list.
a) True
b) False
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