Question

Java Short Answer . 1:Would it make more sense for the elements in a priority queue...

Java Short Answer

.

1:Would it make more sense for the elements in a priority queue to be immutable or mutable? Explain.

2:Is an array that is sorted in decreasing order a "max" priority queue?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer 1) Elements in the priority queue may be immutable or mutable process If they are mutable it change the priorities and

Add a comment
Know the answer?
Add Answer to:
Java Short Answer . 1:Would it make more sense for the elements in a priority queue...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program in Java to implement the max-priority queue using max-heap data structure. Implement the...

    Write a program in Java to implement the max-priority queue using max-heap data structure. Implement the max-heap data structure using an integer array of 10 cells. (Do not use Java in-built PriorityQueue class.) [In a max-heap, the root node and the intermediate node vales are always greater than their children.] First, take 10 integer values from the user and insert them in the max-priority queue. Then print the elements of the queue. After that, delete two elements from the queue...

  • Written in Java By maintaining the invariant that the elements in the priority queue are sorted...

    Written in Java By maintaining the invariant that the elements in the priority queue are sorted in non-increasing order (that is, the largest item is first, the smallest is last), you can implement both findMin and delete Min in constant time. However, insert is expensive. Do the following: b. What is the Big-Oh running time for insert? c. Write an implementation that uses these algorithms. Algorithm “insert": l/Algorithm insert insert(key, priority) //Check condition if (size == Capacity) //Call the method...

  • Q2 [ 20 pts]. In computer science, a priority queue is an abstract data type which is like a regu...

    Data Structure Java code Q2 [ 20 pts]. In computer science, a priority queue is an abstract data type which is like a regular queue data structure, but where additionally each element has a "priority" associated with it. In a priority queue, an element with high priority is served before an element with low priority. If two elements have the same priority, they are served according to the order in which they were enqueued A typical priority queue supports following...

  • Need some help with some Java studying. Please be as detailed as possible with the answer....

    Need some help with some Java studying. Please be as detailed as possible with the answer. - Explain the difference between a mutable and an immutable string, why it’s usually more efficient to use a mutable string, and why using an immutable string make programs safer and more robust. - Explain how Java determines the initial capacity of a StringBuilder object and the new capacity of a StringBuilder object when its current capacity is exceeded.

  • 5. Answer the following. (a) (5 points) Suppose you are given a maxheap of n unique...

    5. Answer the following. (a) (5 points) Suppose you are given a maxheap of n unique numbers. Explain where will the smallest of these n numbers be located in the maxheap. Explain where will the second largest number be located on this maxheap. Please be specific. (b) (5 points) Suppose you are given an array A of n numbers, where all the elements of the array are already sorted in decreasing order. Is this a max-heap? Explain. (c) (5 points)...

  • 1. a. Stack b. Queue c. Priority Queue d. List - (ADTs)  Given the following steps: push(...

    1. a. Stack b. Queue c. Priority Queue d. List - (ADTs)  Given the following steps: push( "Jane" ); push( "Jess" ); push( "Jill" ); push( pop() ); push( "Jim" ); String name = pop(); push( peek() ); Write separate programs for each of the data structures Stack, Queue, PriorityQueue, and List. Use the appropriate push(), pop(), peek() for each of the respective ADT's. Use the Java class library of the ADT's as opposed to the author's implementation. What is in...

  • 2. Short programming assignment. Implement a bottom-up mergesort that first sorts blocks of M elements using...

    2. Short programming assignment. Implement a bottom-up mergesort that first sorts blocks of M elements using insertion sort. Test your program with large sets of random data and determine what value of M works best. 3. The following refer to linked list mergesort Explain why mergesort is more suitable for linked lists than other sorting methods. a. Explain why mergesort is more suitable for linked lists than other b. Consider a file that is “mostly sorted.” Explain how the principles...

  • Please answer in Java for an immediate upvote :) Given the following array of 8 elements,...

    Please answer in Java for an immediate upvote :) Given the following array of 8 elements, trace the merge sort algorithm. Assume the array is to be sorted in ascending order.                        81          16          4        6             34          11          23        67 ANSWER: (Hint 6 – lines): Why don’t we select the median element of all the n-entries in the array to be our pivot point? ANSWER:

  • A priority queue is a collection of items each having a priority. A priority queue supports three...

    A priority queue is a collection of items each having a priority. A priority queue supports three fundamental operations. You can ask a priority queue whether it is empty. You can insert an item into the priority queue with a given priority. You can remove the item from the priority queue that has the smallest priority. For example, suppose that you start with an empty priority queue and imagine performing the following steps. Insert item "one" with priority 10. Insert...

  • Java We did in lecture, and explain your answer briefly. Problem 4: Sorting practice 14 points;...

    Java We did in lecture, and explain your answer briefly. Problem 4: Sorting practice 14 points; 2 points for each part individual-only Important: When answering these questions, make sure to apply the versions of these algorithms that were discussed in lecture. The Java code for each algorithm can be found in our Sort class. Given the following array: {14, 7, 27, 13, 24, 20, 10, 33 1. If the array were sorted using selection sort, what would the array look...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT