Which of the following are valid declarations of a Priority Queue? PriorityQueue
ID: 3811479 • Letter: W
Question
Which of the following are valid declarations of a Priority Queue?
PriorityQueue<double> foo = new PriorityQueue<double>();
PriorityQueue<IndexOutOfBoundsException> foo = new PriorityQueue<IndexOutOfBoundsException>();
PriorityQueue<Stack> foo = new PriorityQueue<Stack>();
PriorityQueue<char> foo = new PriorityQueue<char>();
PriorityQueue<Boolean> foo = new PriorityQueue<Boolean>();
PriorityQueue<LinkedList<TreeSet>> foo = new PriorityQueue<LinkedList<TreeSet>> ();
Explanation / Answer
just as a list can be implemented with a linked list or an array, a priority queue can be implemented with a heap or a variety of other methods such as an unordered array.
PriorityQueue<double> foo = new PriorityQueue<double>(); //Invalid because it requires a reference variable but a double type found.
PriorityQueue<IndexOutOfBoundsException> foo = new PriorityQueue<IndexOutOfBoundsException>();//Valid
PriorityQueue<Stack> foo = new PriorityQueue<Stack>();//Valid
PriorityQueue<char> foo = new PriorityQueue<char>();//Invalid because it requires a reference variable but a char type found.
PriorityQueue<Boolean> foo = new PriorityQueue<Boolean>();//Valid
PriorityQueue<LinkedList<TreeSet>> foo = new PriorityQueue<LinkedList<TreeSet>> ();//Valid
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.