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

  Cross-cultural opportunities and conflicts in canada

Short Paper on Cross-cultural Opportunities and Conflicts in Canada.

  Sociology theory questions

Sociology are very fundamental in nature. Role strain and role constraint speak about the duties and responsibilities of the roles of people in society or in a group. A short theory about Darwin and Moths is also answered.

  A book review on unfaithful angels

This review will help the reader understand the social work profession through different concepts giving the glimpse of why the social work profession might have drifted away from its original purpose of serving the poor.

  Disorder paper: schizophrenia

Schizophrenia does not really have just one single cause. It is a possibility that this disorder could be inherited but not all doctors are sure.

  Individual assignment: two models handout and rubric

Individual Assignment : Two Models Handout and Rubric,    This paper will allow you to understand and evaluate two vastly different organizational models and to effectively communicate their differences.

  Developing strategic intent for toyota

The following report includes the description about the organization, its strategies, industry analysis in which it operates and its position in the industry.

  Gasoline powered passenger vehicles

In this study, we examine how gasoline price volatility and income of the consumers impacts consumer's demand for gasoline.

  An aspect of poverty in canada

Economics thesis undergrad 4th year paper to write. it should be about 22 pages in length, literature review, economic analysis and then data or cost benefit analysis.

  Ngn customer satisfaction qos indicator for 3g services

The paper aims to highlight the global trends in countries and regions where 3G has already been introduced and propose an implementation plan to the telecom operators of developing countries.

  Prepare a power point presentation

Prepare the power point presentation for the case: Santa Fe Independent School District

  Information literacy is important in this environment

Information literacy is critically important in this contemporary environment

  Associative property of multiplication

Write a definition for associative property of multiplication.

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