Implemented using min-heap

Assignment Help Business Management
Reference no: EM131441507

We discussed the priority queue (PQ) ADT implemented using min-heap. In a minheap,the element of the heap with the smallest key is the root of the binary tree. On the other hand, amax-heap has as root the element with the biggest key, and the relationship between the keys of anode and its parent is reversed of that of a min-heap. We also discussed an array-based implementation of heaps. In this assignment, your task is to implement your own flexible priority queue ADT using both min- and max-heap in Java. The specifications of the flexible priority queue are provided in the following.

The heap(s) must be implemented from scratch using an array that is automatically extendable.

You are not allowed to use any list (including arraylist), tree, vector, or heap implementation already available in Java.

You must not duplicate code for implementing min- and max-heaps (i.e. the same code must be used for constructing min or max heaps. Hence think of a flexible way to parameterize your code for either min- or max heap). The following are the access methods of the flexible priority queue ADT: remove(): removes and returns the entry (a key, value pair) with the smallest or biggest key depending on the current state of the priority queue (either Min or Max).]

insert (k,v): Insert the (k,v) entry which is a key(k), value(v) pair to the priority queue.

top(): returns the top entry (with the minimum or the maximum key depending on whether it is aMin- or Max-priority queue, without removing the entry.

toggle() transforms a min- to a max-priority queue or vice versa.

switchToMin(): transforms a max- to a min-priority queue; else leave unchanged.

switchToMax(): transforms a min- to a max-priority queue; else leave unchanged.

state (): returns the current state (Min or Max) of the priority queue.

isEmpty(): returns true if the priority queue is empty. size(): returns the current number of entries in the priority queue

You have to submit the following deliverables:

a) Pseudo code of your implementation of the flexible priority queue ADT using a parameterized heap that is implemented using extendable array. Note that Java code will notbe considered as pseudo code. Your pseudo code must be on a higher and more abstract level.

b) Tight big-Oh time complexities of toggle(), switchToMin(), and switchToMax() operations, together with your explanations.

c) Well documented Java source code with 20 different but representative examplesdemonstrating the functionality of your implemented ADT. These examples should demonstrate all cases of your ADT functionality (e.g., all operations of your ADT, several cases requiring automatic array extension, sufficient number of down and up-heap operations).

Reference no: EM131441507

Questions Cloud

Snooping and directory protocol implementations : What is false sharing and how does it affect parallelism in a program explain using the necessary architectural details? How can you prevent or reduce the impact of it's occurence? What is cache coherence and how do the snooping and directory prot..
Which motivational methods would you as a manager apply : Within your organization, upper management has decided that your department must be downsized, and it is up to each manager to begin preparing his or her team for the changes. One of the changes to be addressed involves motivational techniques.
Differences between original budget and the amended budget : What are the differences between the original budget and the amended budget, and what are the reporting objectives that are served by requiring both to be presented?
Accept a character parameter : Write a recursive method called printLettersForward that will accept a character parameter. The method should print all of the letters of the alphabet up to (including) the parameter value. For example, if the parameter passed to the method is 'f'..
Implemented using min-heap : We discussed the priority queue (PQ) ADT implemented using min-heap. In a minheap,the element of the heap with the smallest key is the root of the binary tree. On the other hand, amax-heap has as root the element with the biggest key, and the rela..
Explain the ways in which findings might be used in nursing : In a 1000-1,250 word essay, summarize the study, explain the ways in which the findings might be used in nursing practice, and address ethical considerations associated with the conduct of the study.Refer to the resource "Research Critique Guideli..
How household would deciding on purchase a new car : Using the Buyer Decision Process in Figure 5.4 show how each household would go about deciding on the purchase of a new car. Make sure you include enough details to clearly identify any differences between the two households
Explain the theory of comparative advantage : Explain how the theory of comparative advantage relates to the need for international business.
Distinguish software needs versus software wants : 1. Search the internet for tips on how to distinguish software needs versus software wants. 2. From your research, summarize 3 of most common tips.

Reviews

Write a Review

Business Management Questions & Answers

  Allocating overhead costs among products

Why is it sometimes important to allocate overhead costs among products, services or some other grouping? Other times the allocations should be disregarded as in this case - why?

  Shrinking planetthe planet started shrinking as the various

shrinking planetthe planet started shrinking as the various places around the world became more closely connected

  Cultivating small vegetable gardens

Many household supplement their food budget by cultivating small vegetable gardens. Explain how each of the following might influence this kind of household production.

  Produce the stabilization device

Based on a learning curve of 70%, how many man-hours will be required to produce the 8th stabilization devise? What is the cost to produce the 8th stabilization device? What is the accumulative cost to produce all 8 stabilization devises?

  Most significant aspect the leader

When crafting a vision, what is the most significant aspect the leader must consider in order for the vision to be effective? Why?

  A reinforcement strategy to help p&g product

Since many of P&G's consumer products are products used every day to satisfy customer needs, the company advertises frequently. However, the cost of advertising has increased dramatically over the years and P&G is concerned

  Type of dependency relates to 3nf

Describe what is meant by transitive dependency and describe how this type of dependency relates to 3NF. Provide an example to illustrate your answer.

  For numerous non-profits and governmental agencies

For numerous non-profits and governmental agencies as well as industry in general fluctuations (ups and downs) within budgets can be a challenge to a program

  Recent examples of organizations

Give me some recent examples of organizations (no matter which country, small or large) that have two of the following issues: creative potential, uncreative culture, innovation potential, knowledge management issues, change management or implemen..

  Policy analysis and policy makers

Policy Analysis and Policy Makers - What is your understanding of what policy analysis contains and what policy makers can learn from policy analysis

  Current carrying value of unprofitable stores

Explain why Food Lion must write down the current carrying value of its unprofitable stores.

  Explain the significant risk to the equity

The private equity group borrows money from wealthy individuals to invest in acquisitions. Because of the significant risk involved, lenders are promised a 12% return on their loans to the equity group. Is the purchase price of the new airline rea..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd