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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:47:44+00:00 2026-05-26T09:47:44+00:00

I need to perform a search in two different data structures in C#, and

  • 0

I need to perform a search in two different data structures in C#, and here’s the deal:
I have one name (which is a string) and I want to perform a search. I have a function called Exists which will return a bool indicating whether it exists or not.

In case it exists, I increase the name (simply adding a 1 at the end of the string), and then I need to perform the search again (via method exists) to see if an object with the new name exists.

This would go on until there’s an unused name, which I could use, BUT, in case it doesn’t exist, now I should perform a search another data structure which contains the objects that were deleted, and if the string is found there, then I’d have to increase the name again, and start searching since the beginning.
This would all end in case there’s no object with such name neither using Exists method nor in the data structure where all the deleted objects are.

How could I approach this problem?

I hope I expressed myself clearly 🙂

Thanks a lot in advance!

  • 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-26T09:47:45+00:00Added an answer on May 26, 2026 at 9:47 am

    a non recursive and simple solution could be something like this ( I don’t see any need of recursion in this case)

       //pseudocode
    
        String name;
        bool condition = true;
    
        while(condition)
        {
            if(ExistInFirstDataStructure(name))
            {
               //increment name
            }
            else
            {
               if(ExistInDeletedDataStructure(String name))
               {
                   //increment name
               }
               else
               {
                   condition = false;
               }
    
            }
        }
    
    
        bool ExistInFirstDataStructure(String name)
        {
    
        }
    
        bool ExistInDeletedDataStructure(String name)
        {
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a set of data on which I need to perform a topological
I have a need to perform search and replace operations on large blocks of
I need to perform a regular expression search for a string x in another
I need to perform a search action on a jqgrid that has local data
i need to perform a name search in the database based on a set
I need to perform 9 different operations on a coordinate, depending on the position
I need to perform a find and replace using XSLT 1.0 which is really
We have a project using LINQ to SQL, for which I need to rewrite
I want to perform a JOIN on two Datatables in a Dataset. For example,
I have a data set with latitude and longitude coordinates (two separate decimal columns).

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.