Question 2 (a)
Which of the following is the code to insert a new node, referenced by newNode, into an empty queue implemented by a SinglyLinkedList with a head and tail references?
Question 2a options:
| A) | tail. setNext(tail); tail = newNode; head = newNode; | |
| B) | head. setNext(newNode); tail= newNode; | |
| C) | newNode.setNext(tail); head = newNode; tail = newNode; | |
| D) | newNode.setNext(tail); newNode = tail; newNode = head; | |
Question 2 (b)
Which of the following code fragments is used to delete the item at the front of a queue represented by a circular array?
Question 2b options:
| A) | front = front - back; --count; | |
| B) | front = MAX_QUEUE - front; --count; | |
| C) | front = (front+1) % MAX_QUEUE; --count; | |
| D) | front = (back+1) % MAX_QUEUE; --count; | |
Question 2 (c)
If a sequence of number 8, 12, 10, 6, 15 is added to a queue, in the order given, which number will be the second number to be removed from the queue?
Question 2c options:
Save
Question 2 (d)
If a sequence of numbers 6, 2, 7, 13, 5, 4, 20 is added to a stack, in the order given, which number will be the last number to be removed from the stack?
Question 2d options: