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 7555453
In Process

The Archive Base Latest Questions

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

Give k sorted inverted lists, I want an efficient algorithm to get the union

  • 0

Give k sorted inverted lists, I want an efficient algorithm to get the union of these k lists?
Each inverted list is a read-only array in memory, each list contains integer in sorted order.
the result will be saved in a predefined array which is large enough. Is there any algorithm better than k-way merge?

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

    K-Way merge is optimal. It has O(log(k)*n) ops [where n is the number of elements in all lists combined].

    It is easy to see it cannot be done better – as @jpalecek mentioned, otherwise you could sort any array better then O(nlogn) by splitting it into chunks [inverted indexes] of size 1.

    • Note: This answer assumes it is important that inverted indexes
      [resulting array] will be sorted. This assumption is true for most
      applications that use inverted indexes, especially in the
      Information-Retrieval area. This feature [sorted indexes] allows
      elegant and quick intersection of indexes.
    • Note: that standard k-way merge allows duplications, you will have to
      make sure that if an element is appearing in two lists, it will be
      added only once [easy to do it by simply checking the last element in
      the target array before adding].
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array that is already sorted but i want to give a
If i want to insert the data in these collection class Dictionary,List and Sorted
I'm looking for a good sorted list for java. Googling around give me some
I've two files of 1 GB each containing only numbers in sorted order. Now
Give an algorithm to find a given element x (give the co-ordinates), in an
Give a linear-time algorithm to test whether a tree has a perfect matching, that
Give a base class Base , I want to write a method Test, like
I want to know which header the user clicked on to give the currently
I have sorted collection (List) and I need to keep it sorted at all
the question is like this: there is a sorted list of n numbers. Given

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.