Exam 17: Linked Data Structures

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

Here is a diagram of a three node linked list with a head pointer and a node to be inserted.Show all steps necessary to delete the second node,pointed to by discard_me.You may assume the necessary search for the node to be deleted is done and the pointer discard_me is already positioned. You are to make clear the sequence of steps by either numbering the steps,or by making several copies of this drawing,with one change per drawing,numbered to show the sequence. You may assume that a search routine taking a head pointer and data arguments has been defined for you. Give code and the drawing to make clear what you are doing. NodePtr discard_me; NodePtr temp_ptr; Here is a diagram of a three node linked list with a head pointer and a node to be inserted.Show all steps necessary to delete the second node,pointed to by discard_me.You may assume the necessary search for the node to be deleted is done and the pointer discard_me is already positioned. You are to make clear the sequence of steps by either numbering the steps,or by making several copies of this drawing,with one change per drawing,numbered to show the sequence. You may assume that a search routine taking a head pointer and data arguments has been defined for you. Give code and the drawing to make clear what you are doing. NodePtr discard_me; NodePtr temp_ptr;

Free
(Essay)
4.9/5
(28)
Correct Answer:
Verified

  Code: NodePtr discard_me; NodePtr temp_ptr; discard_me = search( head,discard_data); head->link = discard_me->link; delete discard_me Code:
NodePtr discard_me;
NodePtr temp_ptr;
discard_me = search( head,discard_data);
head->link = discard_me->link;
delete discard_me

Given the doubly linked list in the diagram below,give the code to delete the second node in the list with the number 31.Assume each entry in the list is a node of class Node with a public next and prev member variable. Given the doubly linked list in the diagram below,give the code to delete the second node in the list with the number 31.Assume each entry in the list is a node of class Node with a public next and prev member variable.

Free
(Essay)
4.8/5
(39)
Correct Answer:
Verified

Node *toDelete = head->next;
head->next->next->prev = head;
head->next = toDelete->next;
delete toDelete;

A linked list is

Free
(Multiple Choice)
4.8/5
(37)
Correct Answer:
Verified

B

Given the type definitions: const int STRING_SIZE = 20; struct ListNode { char item[STRING_SIZE]; int count; ListNode *link; }; ListNode *head = new ListNode; Give a typedef statement that hides the pointer operator *.Call the new type identifier NodePtr.

(Short Answer)
5.0/5
(43)

Here is a diagram of a three node linked list with a head pointer and a node to be inserted.Show all steps necessary to insert the node pointed to by temp between the second and third nodes,including the search for the node prior to insertion.You are to make clear the sequence of steps by either numbering the steps,or by making several copies of this drawing,with one change per drawing,numbered to show the sequence.You may assume a search routine taking a head node and data has been defined for you. Give code and the drawing to make clear what you are doing. Here is a diagram of a three node linked list with a head pointer and a node to be inserted.Show all steps necessary to insert the node pointed to by temp between the second and third nodes,including the search for the node prior to insertion.You are to make clear the sequence of steps by either numbering the steps,or by making several copies of this drawing,with one change per drawing,numbered to show the sequence.You may assume a search routine taking a head node and data has been defined for you. Give code and the drawing to make clear what you are doing.

(Essay)
4.9/5
(40)

A hash function maps an object to a unique number.

(True/False)
4.8/5
(34)

Data is removed at the back of the queue.

(True/False)
4.8/5
(41)

To insert a node into a doubly linked list requires references to the node before and after the location we wish to insert the new node.

(True/False)
4.7/5
(28)

A linked list is normally specified by giving a pointer pointing to the first node of a list.An empty list has no nodes at all.What is the value of a head pointer for an empty list?

(Essay)
4.9/5
(34)

Given the structure definition: const int STRING_SIZE = 20; struct ListNode { \quad char item[STRING_SIZE]; \quad int count; \quad ListNode * link; }; ListNode *head = new ListNode; Show two equivalent ways to set the count member in the ListNode variable to which head points.

(Essay)
4.9/5
(37)

Data is inserted into a queue at the back.

(True/False)
4.9/5
(35)

Which of the following are potential problems when we use the delete operator on a pointer variable?

(Multiple Choice)
4.8/5
(39)

Suppose you have the following struct definition and typedef statements in your program: struct N { double d; N *next; }; typedef N* node_ptr; node_ptr head,p1,p2; Now suppose further that p1 points to a node of type N in the middle of a linked list (neither the first nor the last node).Write code that deletes the node after the node p1 points to in the linked list.After the code is executed,the linked list should be the same,excepting the specified node is missing.

(Essay)
4.8/5
(31)

Insertion into a linked list takes the same number of operations no matter where the insertion occurs

(True/False)
4.9/5
(40)

Give pseudocode for inserting a node in front of the head node in a linked list.

(Essay)
4.8/5
(40)

Placing data on a stack is called popping the stack.

(True/False)
4.9/5
(31)

Name the stack operations as implemented in the text.Tell what each does.

(Essay)
4.7/5
(39)

A friend class is made to further a sense of community among the students.

(True/False)
4.9/5
(31)

Why can a raw pointer be used as an iterator for an array,but not for a list?

(Essay)
4.9/5
(26)

Most applications that use a stack will store a struct or class object on the stack.

(True/False)
4.7/5
(33)
Showing 1 - 20 of 30
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)