Trinomial heaps-binomial heaps

Assignment Help Other Subject
Reference no: EM13220634

Programming question for Homework 1: Trinomial Heaps 
Purpose: 
In class, you learned about binomial heaps. In this question, you will investigate another type of priority queue, which we will call a trinomial heap. The goal of the assignment is to make you more familiar with both binomial heap and trinomial heap operations, and how priority queue data structures are programmed. 

Trinomial heaps:
In order to define a trinomial heap, we must first define a trinomial tree. A trinomial tree can be defined recursively: 

the trinomial tree T0 consists of a single node 
the trinomial tree Tk consists of three trinomial trees Tk-1 that are linked together: the roots of two trees are the leftmost and second leftmost children of the root of the third tree. 

The trinomial trees T0, T1 and T2 are shown below: 


The trinomial tree Tk has the following properties: 

tree Tk has 3k nodes, 
tree Tk has height k, and 
the root of tree Tk has 2k children. 

A trinomial heap H is a set of trinomial trees that satisfies the following two properties: 
Each binomial heap obeys the min-heap property, and 
For any nonnegative integer k, there are at most two trinomial trees in H with height k. 
Task: 
The file THeap.java is an implementation of a binomial heap. You must modify the code in the file THeap.java to turn it into a trinomial heap implementation. In particular, the operations insert, minimum, extractMin and decreaseKey must all work correctly for a trinomial heap. It is your task to figure out what code needs to be changed and to change it. 

Interface file:
To assist you with this question, we are also providing a file Heap.java to test the THeap methods. Do not submit this file. Once you have downloaded the file THeap.java and Heap.java, you can use the command javac Heap.java to compile the code, and use the command java Heap to run the code. (This is exactly how the marker will compile and run your program!) 
About the print command:
The print command will print a binomial heap in the following format: 
key = 9, degree = 0
key = 3, degree = 2
key = 4, degree = 1
key = 6, degree = 0
key = 5, degree = 0

The indentation represents the depth of a node in the binomial tree. Thus, all siblings have the same amount of indentation. The parent of a node x is the last node printed above x with one less indent. For example, in the printout above, the nodes with the keys 4 and 5 are the children of the node with key 3, and the node with key 6 is the child of the node with key 4. A drawing of the binomial heap is given below. 

Testing:
We will test your THeap.java file using a secret set of test cases. (You will not be surprised to learn that we will be mainly testing the insert, minimum, extractMin and decreaseKey methods to ensure that your code is correct.) 

Do not change the names of the methods in the file THeap.java or any of the input parameters or return types. We will not be able to call the methods if you change them! Also, do not change any code in the print method! You may add new methods, however, if needed. 

If your code does not compile on the UTSC computer system, you will receive a mark of 0 on the programming component. 

Submission instructions:
Submit your code using the "submit" mechanism on fissure (by 6:00pm on Sunday, June 1). Use the following command from the directory containing your solution:
submit -N p1 cscb63s THeap.java
The command "man submit" contains general instructions for submitting your code electronically.

Submit only the file THeap.java. Do not submit any other files, and in particular, do not submit any class files. Any other files submitted will be deleted before we test your program.

Do not submit any printout of the code.

Fill in your name, student number and login name in the comment at the top of the THeap.java file.

Your code must compile and run on the fissure system. Test it there! Programs that do not compile and run get 0 marks.

Hints:
Compare the definitions of trinomial tree and trinomial heap with the deifnitions of binomial tree and binomial heap on pages 457 and 459 of the textbook (Chapter 19). 
Make sure you understand the output of the print command. 
Think carefully about what needs to be changed before making any changes!

Reference no: EM13220634

Questions Cloud

Growth of cognitive perspectives in psychology : How has early memory research concerning the growth of cognitive perspectives in psychology changed over the course of the 20th century.
Transportation models-decision making under uncertainty : Are most transportation models an example of decision making under certainty or decision making under uncertainty? Why?
Effects on our legal system : Describes the models and options within the sentencing structure and explain sentencing reforms and their effects on our legal system.
Pros and cons of literature sources : Pros and Cons of Literature Sources. Describe the pros and cons of different sources of literature including the library, online libraries, academic journals and World Wide Web resources.
Trinomial heaps-binomial heaps : In class, you learned about binomial heaps. In this question, you will investigate another type of priority queue, which we will call a trinomial heap. The goal of the assignment is to make you more familiar with both binomial heap and trinomial heap..
Sales promotion techniques : Summarizing the key sales promotion techniques that marketing firms direct toward trade and consumers. Include real-world examples to describe the following classifications of sales promotion techniques:
Application of criminology theory : You are the vice principal in charge of discipline at a prestigious school. An eighth grade teacher has a problem with one of the students. The student comes from a disadvantaged socioeconomic background and the principal would like to keep him in th..
Create application-hobby-popular music-astronomy-interest : Create an application that creates a quiz that contains at least five questions about a hobby, popular music, astronomy, information technology, or any other personal interest.
Government expenditures : A research study suggested that changes in hours worked over time are due, in part, to changes in tax rates. “If taxes and [government expenditures] are high, that may lead to less work,

Reviews

Write a Review

Other Subject Questions & Answers

  What are gardiners strongest reasons for believing

In "Ethics and Global Climate Change" (pp. 362-386), Stephen Gardiner argues that the richer nations should pay most of the costs for addressing global warming. What are Gardiner's strongest reasons for believing this Do you find his rationales si..

  Pest framework

main components of sustainability work against sustainable tourism, challenges that a land-locked country might face in developing its tourism destination as compared to an island, core pointers that underpin sustainable tourism

  Describe each of the approaches to therapy

Briefly describe each of the following approaches to therapy

  Employers use noncompetition agreements

Should employers use noncompetition agreements or other restrictive covenants? If so, under what circumstances? I need about 150 words.

  Classified in terms of formation-performance-enforceability

Ed waves the candy at Fran without saying a word and walks out. If this is a contract, how would it be classified in terms of formation, performance, and enforceability?

  Benefits and disadvantages of soft-path energy development

Write down the advantages and disadvantages of soft-path energy development compared to hard-path energy development?

  Explain the role of partisan views with these systems

Discuss the ways in which a candidate can use media in order to express their message, including air, ground, and web based media. Explain the role of partisan views with these systems.

  Explore your main idea of problem related to health

Effect of drug abuse on specific cultures or groups. Is there a specific cultural group or population that has demonstrated increased consumption of alcohol leading to increased alcoholism and related problems? Is special or more specialized treat..

  Reviewing research

Which of the following is a common mistake when reviewing research?

  Major social factors in negotiation

What are the major social factors in negotiation? Who are the possible parties? How are they different, and how does this affect the negotiation?

  Cognitive interventions among older adults

Cognitive Interventions among Older Adults: an article that is about the trends in psychological research methodology.

  The orbital period of the binary system

The orbital period of the binary system containing A0620-00 is 0.32 day, and Doppler shift measurements reveal that the radial velocity of the X-ray source peaks at 457 km/s (about 1 million miles per hour).

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