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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T15:24:15+00:00 2026-05-10T15:24:15+00:00

This is an exercise for the CS guys to shine with the theory. Imagine

  • 0

This is an exercise for the CS guys to shine with the theory.

Imagine you have 2 containers with elements. Folders, URLs, Files, Strings, it really doesn’t matter.

What is AN algorithm to calculate the added and the removed?

Notice: If there are many ways to solve this problem, please post one per answer so it can be analysed and voted up.

Edit: All the answers solve the matter with 4 containers. Is it possible to use only the initial 2?

  • 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. 2026-05-10T15:24:16+00:00Added an answer on May 10, 2026 at 3:24 pm

    Assuming you have two lists of unique items, and the ordering doesn’t matter, you can think of them both as sets rather than lists

    If you think of a venn diagram, with list A as one circle and list B as the other, then the intersection of these two is the constant pool.

    Remove all the elements in this intersection from both A and B, and and anything left in A has been deleted, whilst anything left in B has been added.

    So, iterate through A looking for each item in B. If you find it, remove it from both A and B

    Then A is a list of things that were deleted, and B is a list of things that were added

    I think…

    [edit] Ok, with the new ‘only 2 container’ restriction, the same still holds:

    foreach( A ) {    if( eleA NOT IN B ) {     DELETED   } } foreach( B ) {   if( eleB NOT IN A ) {     ADDED   } } 

    Then you aren’t constructing a new list, or destroying your old ones…but it will take longer as with the previous example, you could just loop over the shorter list and remove the elements from the longer. Here you need to do both lists

    An I’d argue my first solution didn’t use 4 containers, it just destroyed two 😉

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

Sidebar

Ask A Question

Stats

  • Questions 73k
  • Answers 73k
  • 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
  • added an answer The 6 digits show the file mode using the classical… May 11, 2026 at 2:02 pm
  • added an answer local $/; my $text = <>; s/<.*?>//gs; print $text; May 11, 2026 at 2:02 pm
  • added an answer SELECT d.*, c.* FROM d JOIN junction j ON j.d_id… May 11, 2026 at 2:02 pm

Related Questions

This is an adapted version of a question from someone in my office. She's
This is an Eclipse question, and you can assume the Java package for all
This is an antique problem with VB6 DLL and COM objects but I still
This is an ASP.Net 2.0 web app. The Item template looks like this, for
The median of five is sometimes used as an exercise in algorithm design and
Just would like some thoughts of what you think about my strategy to learn
I'm doing the exercises to TAOCP Volume 1 Edition 3 and have trouble understanding
Recently, someone asked about an algorithm for reversing a string in place in C

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.