How do I initialise a heap data structure in simple, basic Java pseudo-code with 7 numbers?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you want to do it yourself and not use Java’s PriorityQueue then you have to put all X items at the right place so they uphold heap properties:
When looking for the greatest child of any item you have to remember that one or both children could be outside of your array. In this case you don’t have to take it into account, of course.