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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!