Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8976717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:12:33+00:00 2026-06-15T19:12:33+00:00

I am implementing a priority queue using a heap-array of defined newsFeed objects, which

  • 0

I am implementing a priority queue using a heap-array of defined “newsFeed” objects, which all have a String, an int of “likes”, and an int of “age”. The heap is prioritized by the number of “likes” each newsFeed object has, however when I use a removeMax on it, the removeMaxReorder method I wrote for it is giving me null pointers. As I’m debugging it, I was just curious as to if anyone knows of an algorithm that will get around this and basically reorder the array into descending order, thus still keeping the priority queue properties. I can’t implement a comparable method, because I can’t modify the newsFeed class, so I’m imagining a lot of for loops and statements like array[i].getLikes and a lot of >,< and =

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T19:12:34+00:00Added an answer on June 15, 2026 at 7:12 pm

    I assume you are not talking about the PriorityQueue class, and I am not sure if you are talking about an array or an ArrayList, but you don’t need to implement Comparable as you can create a Comparator without changing the original class.

    For your description it sounds like you want to reverse sort an array (or sort it in descending order) To do this I would use

    NewsFeed[] newsFeed =
    Arrays.sort(newsFeed, new MyDescendingPriorityOrderComparator());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently took a stab at implementing a concurrent priority queue using a skip-list
When implementing a graph search algorithm, I needed a priority queue which allowed for
How would you go about implementing a priority queue using a linked list in
I am implementing a priority queue of custom objects. The custom object class looks
implementing publishActivity in PHP using the REST API using this code: $activity = array(
Implementing a simple Login screen using JSF and Spring and Hibernate. I have written
I am implementing a small queue to handle which process gets to run first.
Say I'm creating a library which provides amongst other stuff a priority-queue class. The
I am implementing a generic Priority Queue as part of a homework project. I
I'm implementing a simple priority queue in C for a kernel and so I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.