Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is in java and it is building a Binomial Queues. The packaging division at Complex Circuits Inc. is assigned the task of packing integrated

This is in java and it is building a Binomial Queues.

The packaging division at Complex Circuits Inc. is assigned the task of packing integrated circuit chips into boxes for shipment. Boxes come in different sizes and the capacity of a box (in terms of number of chips) is an exponent of 2, i.e., boxes can hold 1, 2, 4, 8, 16.chips. Each chip has the following parameters:

weight a positive, real number in the range of 0-1

id positive integer in the range of 1000-9999

priority a positive integer in the range of 1-100

Boxes carrying chips arrive on the production line at the end of each hour in lots. The maximum number of chips that can be produced in each lot is 128. The software developer for the packaging division plans to use a binomial queue to represent the data structure for the chips, boxes and lots - each lot corresponds to a binomial queue, each box corresponds to a binomial tree and each chip corresponds to a node in the binomial tree.

Write a program in Java that does the following:

Input:

input the number of lots

randomly generate a number in the range of 1-128, to denote the number of chips produced in each lot; instantiate the chip object for each chip

for each lot, insert each chip object into a binomial queue, using the priority parameter as the key. Make sure that you satisfy the heap order property while creating the binomial queue. You should randomly generate each chip's parameters within the prescribed range, when you instantiate the chip object

deleteMin(int lot): deletes the chip with the minimum key in the lot (remember to adjust nodes after the delete to restore the binomial queue structure)

levelOrder(int lot): prints the level order traversal of each binomial tree in the binomial queue corresponding to the parameter lot. Nodes within each level should be put inside square brackets while printing; each node's (chip's) parameters should be put inside curly braces. (see sample I/O below)

Finally, you need to write a user interface for the program. Sample input and output are given below:

> Enter the number of lots in this production: 3

Randomly generating number of chips in each lot...

Lot 1: 7

Lot 2: 23

Lot 3: 4

Generating the chips for each lot:

Lot 1, Chip 1: {0.2, 3425, 14}

Lot 1, Chip 2: {0.7, 1298, 7}

Lot 1, Chip 3: {0.9, 1389, 15}

Lot 1, Chip 4: {0.3, 1929, 35}

Lot 1, Chip 5: {0.5, 9526, 92}

Lot 1, Chip 6: {0.1, 1748, 5}

Lot 1, Chip 7: {0.2, 7284, 51}

Lot 2, Chip 1: {0.5, 1357, 45}

Lot 2, Chip 23: {0.7, 3313, 39}

Lot 3, Chip 1: {0.7, 3313, 39}

Lot 3, Chip 4: {0.4, 7163, 27}

> Enter a choice: 1) deleteMin(lot), 2) levelOrder (lot), 3) exit: 2

> Enter the lot number: 1

> Printing level order traversal of lot 1:

Box 1: [{0.2, 7284, 51}]

Box 2: [{0.1, 1748, 5}] [{0.5, 9526, 92}]

Box 3: [{0.7, 1298, 7}] [{0.2, 3425, 14} {0.9, 1389, 15}] [{0.3, 1929, 35}]

> Enter a choice: 1) deleteMin(lot), 2) levelOrder (lot), 3) exit: 1

> Enter the lot number: 1

> Deleted minimum priority chip: {0.1, 1748, 5}

> Enter a choice: 1) deleteMin(lot), 2) levelOrder (lot), 3) exit: 2

> Enter the lot number: 1

> Printing level order traversal of lot 1:

Box 1:

Box 2: [{0.2, 7284, 51}] [{0.5, 9526, 92}]

Box 3: [{0.7, 1298, 7}] [{0.2, 3425, 14} {0.9, 1389, 15}] [{0.3, 1929, 35}]

> Enter a choice: 1) deleteMin(lot), 2) levelOrder (lot), 3) exit: 3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 2012 Proceedings Part 2 Lnai 7197

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284892, 978-3642284892

More Books

Students also viewed these Databases questions

Question

For every x, y in an inner product space, |xT y| ||x|| ||y||

Answered: 1 week ago