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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:18:34+00:00 2026-06-14T05:18:34+00:00

I have encountered the following interview question from another website: You are given a

  • 0

I have encountered the following interview question from another website:

You are given a bunch of emails in an inbox. You want to send all the
sender addresses to some server. You can send them in batches (each
batch containing a bunch of sender email addresses). The restriction
is that no batch can contain duplicate email address. How would you
write a program to send all the email addresses in batches such that
it takes the minimum number of batches.

Analyze the complexity

The answer to this that I like involves placing the emails into a binary search tree (thus removing the duplicates), then serializing it and sending it. This would send just one batch, and is O(n*log n) time. Anyone care to chime in with a better solution?

  • 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-14T05:18:36+00:00Added an answer on June 14, 2026 at 5:18 am

    You can use hash, first you check if special name is in hash, if not, you will put it hash and add it to batch. this is O(n) in average, but your current method is O(n logn).

    Your current approach is O(n log n) because creating binary tree takes O(n logn), as you any comparison base algorithm, fails to bit n log n barrier.

    Also about the hash function, it takes O(n) in average. In all it’s better than sorting methods in speed, but it takes may be too much space, and you should consider your data format.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have often encountered the following warning from gdb: warning: .dynamic section for XXX
so i'm following the OpenGL superbible 5 and have encountered yet another issue: I'm
More than one time I have encountered the following problem when building code with
I'm getting started with Qt and have encountered the following issue: when i compile
I am just starting working with jquery and have encountered the following problem <div
I have the following problem that other people must have encountered. I am working
We've encountered the following situation in our database. We have table 'A' and table
I'm learning C# and I encountered the following problem. I have two classes: base
I have encountered a problem with creating a thumbnail from an uploaded image file,
I'm attempting to P/Invoke a C library from F#, and have encountered a peculiar

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.