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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:12:42+00:00 2026-06-02T06:12:42+00:00

I am working on a project (implemented in C) where we are required to

  • 0

I am working on a project (implemented in C) where we are required to maintain a list of a features or keywords. The user enters a string. We need to do case insensitive search for this string in the stored array of string. The list currently consists of 100 strings and new strings may be added (5 strings a year or so).

I want to know the best way to store this array and make the search more efficient.

The solution which is currently implemented is something like below:(I have not compiled this code. This is just a code snippet.)

    char **applist={ asdf , adgh, eftg , egty, ...} 
    char *user_input; // this string contains user entered string
    int id;
    switch(user_input[0])
    {
     case 'a':
     case 'A':
     switch(user_input[1]
     {
     case 's':
     case 'S':
     id=0
     break;

     case 'd':
     case 'D':
     id=1
     break;
     }
     break;
     case'e':
     case'E':
     switch(user_input[1])
     {
     case 'f':
     case 'F':
     id=2
     break;

     case 'g':
     case 'G':
     id=3
     break;
     }
     break;
     }
    if(stricmp(user_input,applist[id]))
    return id;
    else 
    return -1;

In actual code applist is not sorted. As new strings are added to applist I need an efficient way to store this array.

If I store the string sorted alphabetically then every time a new string is added I have to manually find the correct position of the new string. (New Strings are added to applist before compiling the code not at the runtime)

Suggest an efficient way of doing this.

EDIT: My current approach leads to a longer code but its efficient. But this code is not easy to maintain. What I need is a data structure which can do search with same efficiency as this but with smaller code. The datastructure you suggest, should not have additional overhead. The only requirement is efficient searching. And a way to add elements to the data structure at compile time easily. Sorting at run-time is not my requirement as new strings are added at compile time(This is to avoid restrict user from adding any new string to the list).

  • 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-02T06:12:47+00:00Added an answer on June 2, 2026 at 6:12 am

    One good data structure for this might be a TRIE:

    http://en.wikipedia.org/wiki/Trie

    It sort of looks like this is what you’ve begun implementing in code.

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

Sidebar

Related Questions

I am working on one project where there is a functionality need to implement
I've been slowly working my way through the list of Project Euler problems, and
I'm working on a ruby on rails project that requires recording some simple user
I am working in a Ruby on Rails project which has implemented authentication mechanism
I'm working on a project that will require me to implement a calendar. I'm
I am working a school project to implement a Huffman code on text. The
I am working on a project to implement digital signatures of outgoing messages and
I am working on a project. I am trying to implement the core as
I am working on a web project. I want to implement same in ruby.
I'm currently working on a ASP.Net 3.5 project and trying to implement session timeout

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.