EBK STARTING OUT WITH JAVA
3rd Edition
ISBN: 9780134038346
Author: MUGANDA
Publisher: PEARSON CUSTOM PUB.(CONSIGNMENT)
expand_more
expand_more
format_list_bulleted
Concept explainers
Expert Solution & Answer
Chapter 21, Problem 1MC
Program Description Answer
A Queue is a linear data structure in which items are accessed first-in-first-out fashion.
Hence, the correct answer is option “B”.
Expert Solution & Answer
Explanation of Solution
Queue:
- Queue is a linear data structure used to store a set of data.
- Queue is the collection of data which are accessed in FIFO (first-in-first-out) order for performing operations on it.
- Queue is opened at both the ends. One end to insert the items into the queue and the other end is to remove the items from the queue.
- There are two basic operations on queue data structure,
- enqueue() – add an item to queue.
- dequeue() – remove an item from the queue.
- Queue does not have fixed size.
Explanation for incorrect options:
A. Stack
A stack is used to store set of data that are accessed in last-in-first-out order.
Hence, option “A” is wrong.
C. Linked list
A linked list is a collection of data items. This stored item is accessed in random order for doing operations on it.
Hence, option “C” is wrong.
D. Array based collection
An array based collection (simply array) used to store set of items. Each stored item is accessed using array index or key.
Hence, option “D” is wrong.
Want to see more full solutions like this?
Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
Given the class Node below. We have a linked list with head node “A”. Write the code to remove the node “C” in the following linked list.
public class Node {
public String element;
public Node next;
}
The following method is defined within a linked list class. What does it do?
void MyList::doSomething() { Node* p = head;
while (p) { cout << p->value << " "; p = p->next; }}
Group of answer choices
inserts a node into linked list
deletes a node from linked list
displays contents of linked list
destroys the entire linked list
Question 1
If N represents the number of elements in the collection, then the add method of the SortedArrayCollection class is O(N).
True
False
Question 2
If N represents the number of elements in the list, then the index-based remove method of the ABList class is O(N).
True
False
Question 3
The add method of our Collection ADT might throw the CollectionOverflowException.
True
False
Question 4
A list allows retrieval of information based on the size of the information.
True
False
Question 5
Our CollectionInterface defines a single constructor.
True
False
Question 6
Our lists allow null elements.
True
False
Question 7
Even though our collections will be generic, our CollectionInterface is not generic.
True
False
Question 8
Our lists are unbounded.
True
False
Question 9
If N represents the number of elements in the collection, then the contains method of the ArrayCollection class is O(N).
True
False
Question 10
Our lists allow duplicate elements.
True
False
Chapter 21 Solutions
EBK STARTING OUT WITH JAVA
Ch. 21.3 - Prob. 21.1CPCh. 21.3 - Prob. 21.2CPCh. 21.3 - Prob. 21.4CPCh. 21.3 - Prob. 21.5CPCh. 21.6 - Prob. 21.6CPCh. 21.6 - Prob. 21.7CPCh. 21.6 - Prob. 21.8CPCh. 21.6 - Prob. 21.9CPCh. 21 - Prob. 1MCCh. 21 - Prob. 2MC
Ch. 21 - Prob. 3MCCh. 21 - The concept of seniority, which some employers use...Ch. 21 - Prob. 5MCCh. 21 - Prob. 6MCCh. 21 - Prob. 8TFCh. 21 - Prob. 9TFCh. 21 - Prob. 10TFCh. 21 - Prob. 1FTECh. 21 - Prob. 2FTECh. 21 - Prob. 3FTECh. 21 - Prob. 4FTECh. 21 - Prob. 5FTECh. 21 - Prob. 1AWCh. 21 - Prob. 2AWCh. 21 - Suppose that you have two stacks but no queues....Ch. 21 - Prob. 1SACh. 21 - Prob. 2SACh. 21 - Prob. 3SACh. 21 - Prob. 4SACh. 21 - Prob. 5SACh. 21 - Prob. 6SA
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- 34Given that values is of type LLNode<Integer> and references a linked list (non-empty) of Integer objects, what does the following code do if invoked as mystery(values)? void mystery(LLNode<Integer> list){if (list != null){System.out.println(list.getInfo());mystery(list.getLink());}}Group of answer choicesprints the list from start to end.prints the first element on the list.prints the last element on the list.prints the list in reverse order.None of these is correct.arrow_forwardI have a large number of string objects whose order is not really important, but I'd like to remove all duplicates. What container should I use to store them? Pick ONE option A dynamic array A linked list A set A map A Queuearrow_forwardWhich one of the following node is considered the top of the stack if the stack is implemented using the linked list? A. First node B. Second node C. Last node D. None of the abovearrow_forward
- If operations given below is applied on a stack, what will be the result? For array implementation we need is_full() operation, however in linked list case this function is not required. Explain the reason createStack()push(1)push(2)push(1)peek()push(2)pop()pop()pop()push(2)push(1)push(2)arrow_forward(A) If operations given below is applied on a stack, what will be the result? (B) For array implementation we need is_full() operation, however in linked list case this function is not required. Explain the reason createStack()push(1)push(2)push(1)peek()push(2)pop()pop()pop()push(2)push(1)push(2)arrow_forwardA skip listThe second programming homework is already on a server (http://marmoset.famnit.upr.si).In this task, a skip list data structure should be implemented. You can follow the followinginstructions:- Implement the class NodeSkipList with two components, namely key node and arrayof successors. You can also add a constructor, but you do not need to add anymethod.- In the class SkipList implement a constructor SkipList(long maxNodes). The parameter maxNodes determines the maximal number of nodes that can be added to askip list. Using this parameter we can determine the maximal height of a node, thatis, the maximal length of the array of successors. As the maximal height of a nodeit is usually taken the logarithm of the parameter. Further, it is useful to constructboth sentinels of maximal height.- In the class SkipList it is useful to write a method which simulates coin flip andreturns the number of all tosses until the first head comes up. This number representsthe height of a node…arrow_forward
- If N represents the number of elements in the queue, then the enqueue method of the ArrayBoundedQueue class is O(N). true or falsearrow_forwardThe tail of a linked list is distinguished from other nodes because its next pointer is:A. void B. empty C. NULL D. None of the above.arrow_forwardPart2: LinkedList implementation 1. Create a linked list of type String Not Object and name it as StudentName. 2. Add the following values to linked list above Jack Omar Jason. 3. Use addFirst to add the student Mary. 4. Use addLast to add the student Emily. 5. Print linked list using System.out.println(). 6. Print the size of the linked list. 7. Use removeLast. 8. Print the linked list using for loop for (String anobject: StudentName){…..} 9. Print the linked list using Iterator class. 10. Does linked list hava capacity function? 11. Create another linked list of type String Not Object and name it as TransferStudent. 12. Add the following values to TransferStudent linked list Sara Walter. 13. Add the content of linked list TransferStudent to the end of the linked list StudentName 14. Print StudentName. 15. Print TransferStudent. 16. What is the shortcoming of using Linked List?arrow_forward
- You will be given a Linked List of Integers. Remove all even numbers, and then print the Linked List. You are not allowed to use any data structure other than a custom built linked list. This should consist ONLY of a node class. You should not be creating a secondary class to handle the data structure. public class Node { private E item; private Node next; public Node(E item, Node next) { this.item = item; this.next = next; } public E getItem() { return item; } public void setItem(E item) { this.item = item; } public Node getNext() { return next; } public void setNext(Node next) { this.next = next; } } public Node removeInts(Node linkedList) { return null; // Return the start node of your linked list as well as printing it. }arrow_forwardWhat are the fundamental operations of a linked list and the main advantage of a linked list over an array? Test program LinkedList.java, and make sure that you understand each operation in the program. (refer to linkedListApplication.java). In this code which part I will keep main.java file and which part I will keep LinkedList.java.java file. Because I will use main.java IDE. Otherwise my program doesn't run. import java.util.*; public class LinkedList{ public Node header; public LinkedList() { header = null; } public final Node Search(int key) { Node current = header; while (current != null && current.item != key) { current = current.link; } return current; } public final void Append(int newItem) { Node newNode = new Node(newItem); newNode.link = header; header = newNode; } public final Node Remove() { Node x = header; if (header != null) {…arrow_forwardTo Do: LinkedList.h: add a new Node* called tailPtr which points to the last item in the list @file ListInterface.h */ #ifndef _LIST_INTERFACE#define _LIST_INTERFACE template<class ItemType>class ListInterface{public: /** Sees whether this list is empty. @return True if the list is empty; otherwise returns false. */ virtual bool isEmpty() const = 0; /** Gets the current number of entries in this list. @return The integer number of entries currently in the list. */ virtual int getLength() const = 0; /** Inserts an entry into this list at a given position. @pre None. @post If 1 <= position <= getLength() + 1 and the insertion is successful, newEntry is at the given position in the list, other entries are renumbered accordingly, and the returned value is true. @param newPosition The list position at which to insert newEntry. @param newEntry The entry to insert into the list. @return True if insertion is successful,…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning