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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:45:18+00:00 2026-05-16T10:45:18+00:00

I’m using a naive approach to this problem, I’m putting the words in a

  • 0

I’m using a naive approach to this problem, I’m putting the words in a linked list and just making a linear search into it. But it’s taking too much time in large files.

I was thinking in use a Binary Search Tree but I don’t know if it works good with strings. Also heard of Skip Lists, didn’t really learn it yet.

And also I have to use the C language…

  • 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-16T10:45:19+00:00Added an answer on May 16, 2026 at 10:45 am

    The first upgrade to your algorithm could be having the list sorted, so, your lineal search could be faster (you only search until you find one element greater than yours), but this is still a naive solution.

    Best approaches are Binary Search Trees and even better, a prefix tree (or trie, already mentioned in other answer).

    In “The C Programming Language” From K&R you have the exact example of what you are looking for.
    The first example of “autoreferenced data structs” (6.5) is a binary search tree used for counting the ocurrences of every word in a string. (You don’t need to count :P)

    the structure is something like this:

    struct tnode {
            char *word;
            struct tnode *left;
            struct tnode *right;
    };
    

    In the book you can see the whole example of what you want to do.

    Binary Search Trees works good with any tipe of data structure that can accept an order, and will be better than a lineal search in a list.

    Sorry for my poor english, and correct me if i was wrong with something I’ve said, Im very noob with C :p

    EDIT: I can’t add comments to other answers, but I have read a coment from OP saying “The list isn’t sorted so I can’t use binary search”. It is nonsense to use binary search on a linked list. ¿Why? Binary Search is efficient when the access to a random element is fast, like in an array. In a double linked list, your worst access will be n/2.. However, you can put a lot of pointers in the list (accesing to key elements), but it is a bad solution..

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

Sidebar

Related Questions

No related questions found

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.