id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

tmhscs@gmail.com monroe > add
prev  |  next  |  chance

Mr. Monroe is teaching his CSB class about Priority Queues! Priority Queues are automatically created as min heaps. A min heap is a binary tree where all of the parent nodes have lower numerical values than their children. For a major grade, you must create a method that adds an integer to a priority queue and heapifys it. For assistance, view an example of a min heap at http://www.algolist.net/Data_structures/Binary_heap/Insertion. (No loops needed)


add([101, 102, 103, 119, 106, 118, 111, 130], 104) → [101, 102, 103, 104, 106, 118, 111, 130, 119]
add([1, 3, 6, 5, 9, 8], -2) → [-2, 3, 1, 5, 9, 8, 6]
add([10, 15, 30, 40, 50, 100, 40], 12) → [10, 12, 30, 15, 50, 100, 40, 40]

...Save, Compile, Run (ctrl-enter)

public int[] add(int[] arr1, int n) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 460 Post-solution available

Copyright Nick Parlante 2017 - privacy