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

  • Home
  • SEARCH
  • 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 351139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:36:57+00:00 2026-05-12T11:36:57+00:00

The problem is to access a series of values by two different methods. First,

  • 0

The problem is to access a series of values by two different methods. First, by priority; that is implemented simply enough with a heap. Additionally, it must be possible to “tag” each value with one or more symbols through which a list of items may be accessed.

This would be easy enough to implement efficiently by referencing the same data in two different structures. However, these must form a cohesive queue. Therefore, items removed through the one structure must also be removed from the other, an operation for which a heap is not extremely suitable.

Is there a data structure which is able to provide efficient ordering by one value (ideally optimized for pushing/popping), without wholly degrading the performance of finding/deleting nodes at arbitrary locations?

  • 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-05-12T11:36:57+00:00Added an answer on May 12, 2026 at 11:36 am

    You can delete any element from a binary heap in O(log(n)) time if you know which one to delete. Any node can be treated as a valid “sub-heap” and you can use the delete-max (or delete-min) operation just as you would on the whole thing.

    The only problem is how do you know which one to delete? I think I have a solution for that. Use a wrapper for the stored class that has a reference to its heap node and delete that node from the wrappers destructor. When you want to remove any element from the collection you can just delete the wrapper through any of the indexes and it will take care of the rest. When you insert something to the collection you need to create a wrapper object and pass a reference to its heap node.

    Here is some C++ code:

    template <class T> class Wrapper {
        T data;
        HeapNode* index_heap;
        Foo* index_tags;
        Bar* index_queue;
    
        public: ~Wrapper() {
            index_heap->delete_max();
            index_tags->delete_foo();
            index_queue->delete_bar();
        }
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 212k
  • Answers 212k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This is for the case where you are using anonymous… May 12, 2026 at 10:21 pm
  • Editorial Team
    Editorial Team added an answer It's not immediate. Google does crawl some sites a lot… May 12, 2026 at 10:21 pm
  • Editorial Team
    Editorial Team added an answer I think the point is that if you overflow an… May 12, 2026 at 10:21 pm

Related Questions

[Edit 2: More information and debugging in answer below...] I'm writing a python script
I have an object that has properties of another object and one called DataValue
A few days ago I posted this question: switch statement and loops using jquery/javascript
I have an OpenGL program that works on all of my computers but one.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.