CSCI 251 Ch. 4 Lists

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

numsList: 2, 8, 1 ListRemove(numsList, list tail) numsList = ________

2, 8

numsList: 23, 17, 8 ListInsertAfter(numsList, node 23, node 5) numsList = _____

23, 5, 17, 8

Prepending 29 to trainsList updates the list's head pointer to point to node _____. 4 29 31

29

Given a doubly-linked list with nodes 8, 12, 7, 3, node 7's next pointer points to node _____. 12 3

3

How many nodes will ListSearch visit when searching for 54?

3

ListAppend(charList, node F) inserts node F _____. after node Q before node N after node N

after node N

Given a new node, the ________ operation for a singly-linked list inserts the new node after a provided existing list node.

InsertAfter

Inserts x after w

InsertAfter(list, w, x)

Returns true if list has no items

IsEmpty(list)

Given taskList, node D is followed by node _____.

K

ListAppend() Algorithm (Doubly-linked List)

ListAppend(list, newNode) { if (list⇢head == null) { // List empty list⇢head = newNode list⇢tail = newNode } else { list⇢tail⇢next = newNode newNode⇢prev = list⇢tail list⇢tail = newNode } }

Removes x

Remove(list, x)

Given a specified existing node in a singly-linked list, the _______ operation removes the node after the specified list node.

RemoveAfter

A list where elements contain pointers to the next and/or previous elements in the list

positional list

a common ADT for holding ordered data, having operations like append a data item, remove a data item, search whether a data item exists, and print the list

list

A ______ ______ algorithm visits all nodes in the list once and performs an operation on each node.

list traversal

Given a doubly-linked list with nodes 4, 7, 5, 1, node 7's previous pointer points to node _____. 4 5

4

numsList: 91, 80, 77, 60, 75 ListRemoveAfter(numsList, node 60) ListRemoveAfter(numsList, node 77) ListRemoveAfter(numsList, null) numsList = ______

80, 77

numsList: 9, 4, 11, 7 ListRemoveAfter(numsList, node 11) numsList = ______

9, 4, 11

Inserts x at end of list

Append(list, x)

Appending node D to charList updates which node's next pointer? M T E

E

Returns the number of items in the list

GetLength(list)

ListSearch() Algorithm

ListSearch(list, key) { curNode = list⇢head while (curNode is not null) { if (curNode⇢data == key) { return curNode } curNode = curNode⇢next } return null }

Prepending Evelyn to deliveryList executes which statement? a. list⇢head = null b. newNode⇢next = list⇢head c. list⇢tail = newNode

b

Suppose ListTraverseReverse is called on the following list. If ListTraverseReverseRecursive were called directly on node 91, the nodes visited would be: _____. a. node 91 and node 67 b. node 18, node 46, and node 91 c. node 18, node 46, node 91, and node 67

b

A node with an unused data member that always resides at the head of the list and cannot be removed

dummy/header node

Doubly-linked list with dummy node. ListInsertAfter(list, null, newNode) will insert newNode before the list's dummy node. True False

false

Suppose dataList is a singly-linked list with a dummy node. Which statement removes the first item from the list? a. ListRemoveAfter(dataList, null) b. ListRemoveAfter(dataList, dataList⇢head) c. ListRemoveAfter(dataList, dataList⇢tail)

b

Prepending node 789 to studentIdList updates the list's tail pointer. True False

false

The head and tail pointers always point to the dummy node. True False

false

ListPrepend(shoppingList, node Milk) updates the list's tail pointer. True False

true

Given ListInsertionSortSinglyLinked is called to sort the list below. How many times is ListInsertAfter called? 0 1 2

0

A special value indicating a pointer points to nothing

null

How many nodes will ListSearch visit when searching for 48?

6

Suppose a linked list has 10 nodes. Calling ListSearch results in a minimum of _____ calls to ListSearchRecursive. 1 2 10 11

1

numsList: 1 ListInsertAfter(numsList, node 1, node 6) ListInsertAfter(numsList, node 1, node 4) numsList = _____

1, 4, 6

Prepending a node to a doubly-linked list

1. Prepend to empty list: If the list's head pointer is null (empty), the algorithm points the list's head and tail pointers to the new node. 2. Prepend to non-empty list: If the list's head pointer is not null (not empty), the algorithm points the new node's next pointer to the list's head node, points the list head node's previous pointer to the new node, and then points the list's head pointer to the new node.

Removing a node from a singly-linked list

1. Remove list's head node (special case): If curNode is null, the algorithm points sucNode to the head node's next node, and points the list's head pointer to sucNode. If sucNode is null, the only list node was removed, so the list's tail pointer is pointed to null (indicating the list is now empty). OR 2. Remove node after curNode: If curNode's next pointer is not null (a node after curNode exists), the algorithm points sucNode to the node after curNode's next node. Then curNode's next pointer is pointed to sucNode. If sucNode is null, the list's tail node was removed, so the algorithm points the list's tail pointer to curNode (the new tail node).

numsList: 10, 20, 30, 40, 50, 60 ListRemoveAfter(numsList, node 40) ListRemoveAfter(numsList, node 20) numsList = ______

10, 20, 40, 60

If ListTraverse is called to traverse a list with 10 nodes, how many calls to ListTraverseRecursive are made? 9 10 11

11

Given ListInsertionSortSinglyLinked is called to sort the list below. How many times is ListPrepend called? 0 1 2

2

Type the list after the given operations. Each question starts with an empty list. Append(list, 3) Append(list, 2) Append(list, 1) Remove(list, 3)

2, 1

numsList: 2, 5, 9 ListRemoveAfter(numsList, node 5) numsList = ______

2, 5

numsList: 3, 57, 28, 40 ListRemoveAfter(numsList, null) numsList = ______

57, 28, 40

Type the list after the given operations. Each question starts with an empty list. Append(list, 3) Append(list, 2)

3, 2

Given a list with items 40, 888, -3, 2, what does GetLength(list) return? 4 Fails

4

numsList: 5, 9 ListInsertAfter(numsList, node 9, node 4) numsList = _____

5, 9, 4

numsList: 70, 82, 41, 120, 357, 66 ListRemove(numsList, node 82) ListRemove(numsList, node 357) ListRemove(numsList, node 66) numsList = ________

70, 41, 120

numsList: 71, 29, 54 ListRemove(numsList, node 29) numsList = ________

71, 54

numsList: 77 ListInsertAfter(numsList, node 77, node 32) ListInsertAfter(numsList, node 32, node 50) ListInsertAfter(numsList, node 32, node 46) numsList = _____

77, 32, 46, 50

ListTraverseReverse can be used to traverse a singly-linked list. True False

False

Singly-linked list with a dummy node

List operations such as append, prepend, insert after, and remove after are simpler to implement compared to a linked list without a dummy node, since a special case is removed from each implementation. ListAppend, ListPrepend, and ListInsertAfter do not need to check if the list's head is null, since the list's head will always point to the dummy node. ListRemoveAfter does not need a special case to allow removal of the first list item, since the first list item is after the dummy node.

ListAppend() Algorithm

ListAppend(list, newNode) { if (list⇢head == null) { // List empty list⇢head = newNode list⇢tail = newNode } else { list⇢tail⇢next = newNode list⇢tail = newNode } }

ListFindInsertionPosition() Algorithm

ListFindInsertionPosition(list, dataValue) { curNodeA = null curNodeB = list⇢head while (curNodeB != null and dataValue > curNodeB⇢data) { curNodeA = curNodeB curNodeB = curNodeB⇢next } return curNodeA }

ListInsertAfter() Algorithm

ListInsertAfter(list, curNode, newNode) { if (list⇢head == null) { // List empty list⇢head = newNode list⇢tail = newNode } else if (curNode == list⇢tail) { // Insert after tail list⇢tail⇢next = newNode newNode⇢prev = list⇢tail list⇢tail = newNode } else { sucNode = curNode⇢next newNode⇢next = sucNode newNode⇢prev = curNode curNode⇢next = newNode sucNode⇢prev = newNode } }

InsertAfter() Algorithm

ListInsertAfter(list, curNode, newNode) { if (list⇢head == null) { // List empty list⇢head = newNode list⇢tail = newNode } else if (curNode == list⇢tail) { // Insert after tail list⇢tail⇢next = newNode list⇢tail = newNode } else { newNode⇢next = curNode⇢next curNode⇢next = newNode } }

ListInsertionSortDoublyLinked() Algorithm

ListInsertionSortDoublyLinked(list) { curNode = list⇢head⇢next while (curNode != null) { nextNode = curNode⇢next searchNode = curNode⇢prev while (searchNode != null and searchNode⇢data > curNode⇢data) { searchNode = searchNode⇢prev } // Remove and re-insert curNode ListRemove(list, curNode) if (searchNode == null) { curNode⇢prev = null ListPrepend(list, curNode) } else { ListInsertAfter(list, searchNode, curNode) } // Advance to next node curNode = nextNode } }

ListInsertionSortSinglyLinked() Algorithm

ListInsertionSortSinglyLinked(list) { beforeCurrent = list⇢head curNode = list⇢head⇢next while (curNode != null) { next = curNode⇢next position = ListFindInsertionPosition(list, curNode⇢data) if (position == beforeCurrent) beforeCurrent = curNode else { ListRemoveAfter(list, beforeCurrent) if (position == null) ListPrepend(list, curNode) else ListInsertAfter(list, position, curNode) } curNode = next } }

ListPrepend() Algorithm (Doubly-linked List)

ListPrepend(list, newNode) { if (list⇢head == null) { // List empty list⇢head = newNode list⇢tail = newNode } else { newNode⇢next = list⇢head list⇢head⇢prev = newNode list⇢head = newNode } }

ListPrepend() Algorithm

ListPrepend(list, newNode) { if (list⇢head == null) { // list empty list⇢head = newNode list⇢tail = newNode } else { newNode⇢next = list⇢head list⇢head = newNode } }

ListRemove() Algorithm (Doubly-linked List)

ListRemove(list, curNode) { sucNode = curNode⇢next predNode = curNode⇢prev if (sucNode is not null) { sucNode⇢prev = predNode } if (predNode is not null) { predNode⇢next = sucNode } if (curNode == list⇢head) { // Removed head list⇢head = sucNode } if (curNode == list⇢tail) { // Removed tail list⇢tail = predNode } }

ListRemoveAfter() Algorithm

ListRemoveAfter(list, curNode) { // Special case, remove head if (curNode is null && list⇢head is not null) { sucNode = list⇢head⇢next list⇢head = sucNode if (sucNode is null) { // Removed last item list⇢tail = null } } else if (curNode⇢next is not null) { sucNode = curNode⇢next⇢next curNode⇢next = sucNode if (sucNode is null) { // Removed tail list⇢tail = curNode } } }

ListSearch() Algorithm (Recursive Version)

ListSearch(list, key) { return ListSearchRecursive(key, list⇢head) }

ListSearchRecursive() Algorithm

ListSearchRecursive(key, node) { if (node is not null) { if (node⇢data == key) { return node } return ListSearchRecursive(key, node⇢next) } return null }

ListTraverse() Algorithm

ListTraverse(list) { curNode = list⇢head // Start at head while (curNode is not null) { Print curNode's data curNode = curNode⇢next } }

ListTraverse() Algorithm (Recursive Version)

ListTraverse(list) { ListTraverseRecursive(list⇢head) }

ListTraverseRecursive() Algorithm

ListTraverseRecursive(node) { if (node is not null) { Visit node ListTraverseRecursive(node⇢next) } }

ListTraverseReverse() Algorithm

ListTraverseReverse(list) { curNode = list⇢tail // Start at tail while (curNode is not null) { Print curNode's data curNode = curNode⇢prev } }

Given waitList, the tail node's data value is _____.(Answer "None" if no tail exists)

Mary

After the following operations, will Search(list, 2) find an item? Type yes or no. Append(list, 3) Append(list, 2) Append(list, 1) Remove(list, 2)

No

ListPrepend is called on which node(s)? Node 11 only Node 22 only Nodes 11 and 22

Node 11 only

ListTraverseReverse visits which node second? Node 2 Node 13

Node 13

What is the first node that curNode will point to? Node 39 Node 45 Node 11

Node 45

Given ListInsertionSortSinglyLinked is called to sort the list below. What is returned by the first call to ListFindInsertionPosition? null Node 63 Node 71 Node 84

Node 63

ListSearch(charList, E) first assigns curNode to _____. Node M Node T Node E

Node M

The best case runtime of ListInsertionSortSinglyLinked is ______, which occurs when the list is sorted in descending order.

O(N)

Insertion sort's typical runtime is ______

O(N^2)

The average and worst case runtime of ListInsertionSortSinglyLinked is ________

O(N^2)

Inserts x at start of list

Prepend(list, x)

Prints list's items in order

Print(list)

Prints list's items in reverse order

PrintReverse(list)

Returns item if found, else returns null

Search(list, x)

Which sorting algorithm uses a gap value to jump between elements, and is difficult to adapt to linked lists for this reason? Insertion sort Merge sort Shell sort

Shell sort

Sorts the lists items in ascending order

Sort(list)

Inserting a new node in a doubly-linked lists

The InsertAfter algorithm considers three insertion scenarios: 1. Insert as first node: If the list's head pointer is null (list is empty), the algorithm points the list's head and tail pointers to the new node. 2. Insert after list's tail node: If the list's head pointer is not null (list is not empty) and curNode points to the list's tail node, the new node is inserted after the tail node. The algorithm points the tail node's next pointer to the new node, points the new node's previous pointer to the list's tail node, and then points the list's tail pointer to the new node. 3. Insert in middle of list: If the list's head pointer is not null (list is not empty) and curNode does not point to the list's tail node, the algorithm updates the current, new, and successor nodes' next and previous pointers to achieve the ordering {curNode newNode sucNode}, which requires four pointer updates: point the new node's next pointer to sucNode, point the new node's previous pointer to curNode, point curNode's next pointer to the new node, and point sucNode's previous pointer to the new node.

Inserting a node in a singly-linked list

The InsertAfter algorithm considers three insertion scenarios: 1. Insert as list's first node: If the list's head pointer is null, the algorithm points the list's head and tail pointers to the new node. 2. Insert after list's tail node: If the list's head pointer is not null (list not empty) and curNode points to the list's tail node, the algorithm points the tail node's next pointer and the list's tail pointer to the new node. 2. Insert in middle of list: If the list's head pointer is not null (list not empty) and curNode does not point to the list's tail node, the algorithm points the new node's next pointer to curNode's next node, and then points curNode's next pointer to the new node.

Removing a node from a doubly-linked list

The algorithm uses four separate checks to update each pointer: 1. Successor exists: If the successor node pointer is not null (successor exists), the algorithm points the successor's previous pointer to the predecessor node. 2. Predecessor exists: If the predecessor node pointer is not null (predecessor exists), the algorithm points the predecessor's next pointer to the successor node. 3. Removing list's head node: If curNode points to the list's head node, the algorithm points the list's head pointer to the successor node. 4. Removing list's tail node: If curNode points to the list's tail node, the algorithm points the list's tail pointer to the predecessor node.

Appending a node to a singly-linked list

The append algorithm behavior differs if the list is empty versus not empty: 1. Append to empty list: If the list's head pointer is null (empty), the algorithm points the list's head and tail pointers to the new node. 2. Append to non-empty list: If the list's head pointer is not null (not empty), the algorithm points the tail node's next pointer and the list's tail pointer to the new node.

Appending a node to a doubly-linked list

The append algorithm behavior differs if the list is empty versus not empty: 1. Append to empty list: If the list's head pointer is null (empty), the algorithm points the list's head and tail pointers to the new node. 2. Append to non-empty list: If the list's head pointer is not null (not empty), the algorithm points the tail node's next pointer to the new node, points the new node's previous pointer to the list's tail node, and points the list's tail pointer to the new node.

Prepending C to gradesList updates which pointer? The list's head pointer A's next pointer D's next pointer

The list's head pointer

Prepending a node to a singly-linked list

The prepend algorithm behavior differs if the list is empty versus not empty: 1. Prepend to empty list: If the list's head pointer is null (empty), the algorithm points the list's head and tail pointers to the new node. 2. Prepend to non-empty list: If the list's head pointer is not null (not empty), the algorithm points the new node's next pointer to the head node, and then points the list's head pointer to the new node.

Appending node K to rentalList executes which of the following statements? a. list⇢head = newNode b. list⇢tail⇢next = newNode c. newNode⇢prev = list⇢tail

a

For each question, assume 2 list types are available: a doubly-linked list with 1 dummy node at the list's head, and a doubly-linked list with 2 dummy nodes, one at the head and the other at the tail. When list⇢head == list⇢tail is true in _____, the list is empty. a. a list with 1 dummy node b. a list with 2 dummy nodes c. either a list with 1 dummy node or a list with 2 dummy nodes

a

ListInsertAfter(charList, node T, node Q) assigns newNode's next pointer with _____. a. curNode⇢next b. charList's head node c. null

a

ListInsertAfter(wagesList, list head, node 246) executes which statement? a. list⇢head = newNode b. list⇢tail⇢next = newNode c. curNode⇢next = newNode

a

Which statement is NOT executed when node 70 is appended to ticketList? a. list⇢head = newNode b. list⇢tail⇢next = newNode c. list⇢tail = newNode

a

Why are sorting algorithms for arrays generally more difficult to adapt to singly-linked lists than to doubly-linked lists? a. Singly-linked lists do not support backward traversal. b. Singly-linked do not support inserting nodes at arbitrary locations.

a

For each question, assume 2 list types are available: a doubly-linked list with 1 dummy node at the list's head, and a doubly-linked list with 2 dummy nodes, one at the head and the other at the tail. list⇢head⇢next is always non-null in _____. a. a list with 1 dummy node b. a list with 2 dummy nodes c. neither list type

b

ListAppend(callList, node 5) executes which statement? a. list⇢head = newNode b. list⇢tail⇢next = newNode c. newNode⇢next = list⇢tail

b

ListPrepend(earningsList, node 977) executes which statement? a. list⇢tail = newNode b. newNode⇢next = list⇢head c. newNode⇢next = list⇢tail

b

Suppose numbersList is a singly-linked list with items 73, 19, and 86. Item 86 is at the list's tail. What is the list's contents after the following operations? lastItem = numbersList⇢tail ListAppend(numbersList, node 25) ListInsertAfter(lastItem, node 49) a. 73, 19, 86, 25, 49 b. 73, 19, 86, 49, 25 c. 73, 19, 25, 49, 86

b

For each question, assume 2 list types are available: a doubly-linked list with 1 dummy node at the list's head, and a doubly-linked list with 2 dummy nodes, one at the head and the other at the tail. list⇢tail may be null in _____. a. a list with 1 dummy node b. a list with 2 dummy nodes c. neither list type

c

If myList is a singly-linked list with a dummy node, which statement is true when the list is empty? a. myList⇢head == null b. myList⇢tail == null c. myList⇢head == myList⇢tail

c

ListInsertAfter(numList, node 1, node 6) executes which statement? a. list⇢head = newNode b. newNode⇢next = curNode⇢next c. list⇢tail⇢next = newNode

c

Suppose numbersList is a singly-linked list with items 73, 19, and 86. Item 86 is at the list's tail. Suppose the following statement is executed: node19 = numbersList⇢head⇢next⇢next Which subsequent operations swap nodes 73 and 19? a. ListPrepend(numbersList, node19) b. ListInsertAfter(numbersList, numbersList⇢head, node19) c. ListRemoveAfter(numbersList, numbersList⇢head⇢next)ListPrepend(numbersList, node19)

c

What aspect of linked lists makes adapting array-based sorting algorithms to linked lists difficult? a. Two elements in a linked list cannot be swapped in constant time. b. Nodes in a linked list cannot be moved. c. Elements in a linked list cannot be accessed by index.

c Lack of indexed access is what prevents many sorting algorithms from being easily adapted to work with linked lists.

A data structure for implementing a list ADT, where each node has data, a pointer to the next node, and a pointer to the previous node.

doubly-linked list

If a list ADT has operations like Sort or PrintReverse, the list is clearly implemented using an array. True False

false *No such conclusion can be drawn. The point of an ADT is that the implementation is not known.

Given numsList is: 5, 8, 2, 1. ListTraverse(numsList) visits _____ node(s). one two four

four

A singly-linked list's first node

head

Given a doubly-linked list with nodes 20, 67, 11, node 20 is the _____. head tail

head

The ListTraverse function takes a list as an argument, and searches the entire list by calling ListTraverseRecursive on the list's _______.

head

Appending node W to sampleList updates which of sampleList's pointers? head and tail head only tail only

head and tail

Sorting algorithms easily adapted to efficiently sort linked lists

insertion sort, merge sort

Suppose dataList is a singly-linked list with a dummy node. Which is a requirement of the ListPrepend function? The list is empty The list is not empty newNode is not null

newNode is not null

Given carList, ListRemove(carList, node Bugatti) executes which of the following statements? list⇢tail = predNode Yes No

no

Given numList, ListRemove(numList, node 12) executes which of the following statements? list⇢head = sucNode Yes No

no

Given numList, ListRemove(numList, node 12) executes which of the following statements? list⇢tail = predNode Yes No

no

Given carList, ListRemove(carList, node Bugatti) executes which of the following statements? predNode⇢next = sucNode Yes No

no A predecessor node does not exist.

Given numList, ListRemoveAfter(numList, node 55) executes which of the following statements? list⇢head = sucNode Yes No

no Node 12 (node after node 55) is removed. Node 12 is not the list's head node, so the list's head pointer is unchanged.

Given numList, ListRemoveAfter(numList, node 55) executes which of the following statements? list⇢tail = curNode Yes No

no Node 12 (node after node 55) is removed. Node 12 is not the list's tail node, so the list's tail pointer is unchanged.

Given charList, ListRemoveAfter(charList, null) executes which of the following statements? list⇢tail = curNode Yes No

no The node being removed, node H, was not the list's tail node, so the list's tail pointer will not be changed.

Given numList, ListRemoveAfter(numList, node 55) executes which of the following statements? sucNode = list⇢head⇢next Yes No

no curNode is not null, so the list's head node is not removed.

Given charList, ListRemoveAfter(charList, null) executes which of the following statements? curNode⇢next = sucNode Yes No

no curNode is null, which does not point to a valid node. Assigning the next pointer of a non-existent node is an error.

Suppose ListTraverseReverse is called on the following list. ListTraverseReverse passes _____ as the argument to ListTraverseReverseRecursive. node 67 node 18 null

node 67

For ListSearch(captainList, Sisko), after checking node Riker, to which node is curNode pointed? node Riker node Kirk

node Kirk

A dummy node can also be used in a doubly-linked list implementation. The dummy node in a doubly-linked list always has the prev pointer set to ______.

null

Given charList, C's next pointer value is _____.

null

Suppose a linked list has 10 nodes. When the key is not found, ListSearch returns _____. the list's head the list's tail null

null

What value does ListSearch return if the search key is not found?

null

A ______ ______ algorithm visits all nodes starting with the list's tail node and ending after visiting the list's head node.

reverse traversal

Given a key, a ________ algorithm returns the first node whose data matches that key, or returns null if a matching node was not found.

search

Sorting algorithms that cannot as efficiently sort linked lists

shell sort, quick sort, heap sort

A data structure for implementing a list ADT, where each node has data and a pointer to the next node.

singly-linked list

A singly-linked list's last node

tail

Suppose a linked list has 10 nodes. When more than 1 of the list's nodes contains the search key, ListSearch returns _____ node containing the key. the first the last a random

the first

ListTraverse begins with _____. a specified list node the list's head node the list's tail node

the list's head node

A doubly-linked list supports a reverse traversal. True False

true

Doubly-linked list with dummy node. ListPrepend(list, newNode) is equivalent to ListInsertAfter(list, list⇢head, newNode). True False

true

Doubly-linked list with dummy node. ListRemove's implementation must not allow removal of the dummy node. True False

true

Given a list with items 'Z', 'A', 'B', Sort(list) yields 'A', 'B', 'Z'. True False

true

ListTraverse can be used to traverse a doubly-linked list. True False

true

ListTraverseRecursive works for an empty list. True False

true

ListTraverseRecursive works for both singly-linked and doubly-linked lists. True False

true

Prepending node 6 to parkingList updates the list's tail pointer. True False

true

Suppose ListTraverseReverse is called on the following list. ListTraverseReverseRecursive has been called for each of the list's nodes by the time the tail node is visited. True False

true

The dummy node's next pointer points to the first list item. True False

true

The ordering of list nodes is not altered when node 45 is removed and then inserted after node 39. True False

true

The traversal algorithm supports both singly-linked and doubly-linked lists. True False

true

Using a dummy node simplifies the algorithms for a linked list because the head and tail pointers are never null. True False

true

Each node in a doubly-linked list contains data and _____ pointer(s). one two

two

Given carList, ListRemove(carList, node Bugatti) executes which of the following statements? list⇢head = sucNode Yes No

yes

Given carList, ListRemove(carList, node Bugatti) executes which of the following statements? sucNode⇢prev = predNode Yes No

yes

Given numList, ListRemove(numList, node 12) executes which of the following statements? predNode⇢next = sucNode Yes No

yes

Given numList, ListRemove(numList, node 12) executes which of the following statements? sucNode⇢prev = predNode Yes No

yes

Given numList, ListRemoveAfter(numList, node 55) executes which of the following statements? curNode⇢next = sucNode Yes No

yes A successor node exists, so node 55's next pointer is pointed to node 74.

Given charList, ListRemoveAfter(charList, null) executes which of the following statements? list⇢head = sucNode Yes No

yes The node being removed, node H, is the list head, so the list's head pointer will be pointed to node A.

Given charList, ListRemoveAfter(charList, null) executes which of the following statements? sucNode = list⇢head⇢next Yes No

yes curNode is null, so the head node is removed. Node A is the list head's successor.


Set pelajaran terkait

The Chemical World (Summary Questions)

View Set

NRSG102 Med Surg Exam 2 - Cellular Regulation

View Set

Triangle Congruence: ASA and AAS Assignment

View Set