first parameter is an array that contains all the elements that // will go into the heap; the second parameter tells how many elements // there are (so that the array "elts" can be larger than the number // of elements in it... we do not depend on elts.length to determine // the size of heap we build. // // The method works as follows: // first: the heap that is doing the build will do a clear() // and it will lose any elem

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

void build (int[] elts, int N);
// The "magic" build operation which constructs a heap in O(N) time
// the first parameter is an array that contains all the elements that
// will go into the heap; the second parameter tells how many elements
// there are (so that the array "elts" can be larger than the number
// of elements in it... we do not depend on elts.length to determine
// the size of heap we build.
//
// The method works as follows:
// first: the heap that is doing the build will do a clear()
// and it will lose any elements already in that heap
// second: load the elements in parameter "elts" into the heap
// array directly ( a O(N) copying action )
// third: perform the "bubble down" operations that a build
// requires on the heap array
//
// When testing look to find a sequence of elements that let you
// get two different heap structure when you
// 1) create a heap from N separate inserts
// 2) do this build method
//
// Here is one such sequence: 101, 37, 26, 19, 15, 12, 9, 2, 3, 5
//
// Here is another (from your class PPT): 6, 12, 9, 4, 5, 3
//
// Example: If you call insert on each element one-by-one
// for the sequence 6, 12, 9, 4, 5, 3, you obtain the following min-heap:

// 3, 5, 4, 12, 6, 9

// However, build() will produce the following min-heap:
// 3, 4, 6, 12, 5, 9

make a METHOD in java That does as the descriptinon says in a min heap array

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY