Short Answers 1. A queue q stores int values. Show what q will look like after e
ID: 3704927 • Letter: S
Question
Short Answers
1. A queue q stores int values. Show what q will look like after each of the following instructions is executed.
q.enqueue(6);
q.enqueue(12);
q.enqueue(13);
q.dequeue();
q.dequeue();
q.enqueue(19);
q.enqueue(21);
q.enqueue(22);
q.dequeue();
q.enqueue(20);
Example Code (Linked List) The following is a class definition of a linked list Node:
class Node {
int info;
Node next;
}
2. Use Example Above: Show the instructions required to create a linked list that is referenced by head and stores in order, the int values 3, 6 and 2. Assume that Node's constructor receives no parameters.
3. Use Example Above: Assume that head references a linked list and stores in order, the int values 3, 6 and 2. Show the instructions needed to delete the Node with 3 so that head would reference the list 6 and 2.
4. One use of a stack is to reverse the order of input. Write a method that reads a series of Strings from the keyboard (assume the Scanner class has been imported) and outputs the Strings in reverse order of how they were entered. The input will end with the String "end" but do not output the String "end". Assume that SStack is a stack that can store Strings. Remember to declare and instantiate your SStack in your method.
True / False: Answer True or False explain your answer.
1. A linked list that contains six Nodes will have six reference pointers.
2. The push and enqueue operations are essentially the same operations. push is used for stacks and enqueue is used for queues.
3. The Abstract Data Type (ADT) is thought of as abstract because the operations that are to be implemented are separated from the actual implementation; that is, an ADT can be implemented in more than one way and that implementation is separate from how we might use the ADT.
Multiple Choice
1. A variation of a linked list is a circular linked list where the last Node in the list has next = head rather than next = null. One problem with this type of list is that
a. it wastes memory space since head already points at the first Node, so the last one does not need to
b. there is no ability to add a new Node at the end of the list since the last Node points at the first Node
c. it is more difficult to traverse the list since the old terminating condition, (next == null), is no longer true for the last node
d. a header Node for this type of list is more complex
e. All of these
2. In a linked list in Java
a. the link is an object
b. the link is a node
c. the link is a reference
d. the link is an int e. the link is a class
3. A linear data structure
a. always has more than one link per node
b. is sometimes represented as a tree or a graph
c. can have only a single link per node
d. almost always is kept in sorted order, either ascending or descending
e. None of these
Explanation / Answer
Hi Dear,
I have answered last 2 Sections : True/Fasle and MCQs
As per the chegg guideline, please post only one question per post.
Hope you understand this.
True / False: Answer True or False explain your answer.
1. A linked list that contains six Nodes will have six reference pointers.
Ans: True
2. The push and enqueue operations are essentially the same operations. push is used for stacks and enqueue is used for queues.
Ans: True
3. The Abstract Data Type (ADT) is thought of as abstract because the operations that are to be implemented are separated from the actual implementation; that is, an ADT can be implemented in more than one way and that implementation is separate from how we might use the ADT.
Ans: True
MCQ:
1. A variation of a linked list is a circular linked list where the last Node in the list has next = head rather than next = null. One problem with this type of list is that
Ans: c. it is more difficult to traverse the list since the old terminating condition,
(next == null), is no longer true for the last node
2. In a linked list in Java
Ans: c. the link is a reference
3.A linear data structure
Ans:c. can have only a single link per node
Please DONT forgot to rate my answer. We are working hard for you Guys!!
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.