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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:51:55+00:00 2026-06-17T07:51:55+00:00

I need some advice to chose a sorting algorithm to code for this problem.

  • 0

I need some advice to chose a sorting algorithm to code for this problem.

In phase one, the program will fetch clientIDs and respective hashes (will be using a struct, probably) from a database. There can be 0 or many thousands of records.

In phase two, the program will complete this set with records read from a XML file. I’ve already built the stream parser. The XML file has all the client info sequentially before invoice data.

When phase two is done, the program will read the invoice data. For each invoice there’s one clientID and this has to be checked from the set of clients. The number of invoices can be millions of records.

What I initially thought. Since I don’t know how many client records there will be, I must add memory dynamically using a linked list. At the end of phase two I can create an array of data ordered by clientID, so that I can perform further searches, one for each invoice, can be retrieved quick, maybe using a binary search.

I’d like to know what do you advise me to handle this situation. What sort algorithms should I use? (I’ll be coding in C).

  • 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-17T07:51:56+00:00Added an answer on June 17, 2026 at 7:51 am

    Arguably, the best algorithm is one that satisfies the following criteria:

    • You don’t have to write any code
    • You don’t incur any 3rd-party dependencies
    • Is fast enough for your purposes

    Given that thousands of records is basically none, I’d suggest using qsort for the sort, and bsearch for the searches; both of these are in the C standard library.

    Issues to note:

    • qsort can’t be used on a linked-list. I’d strongly suggest storing your data in a dynamically-grown array; the amortized cost of creation is the same, and you’ll have other benefits (e.g. less memory overhead, better locality of reference).

    • If, after careful profiling, you find that bsearch is not sufficiently fast, then you may want to move over to a hashtable-based lookup, as this is O(1), not O(log N). However, don’t attempt to write your own; use an existing library for this. (See other answers here for suggestions.)

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

Sidebar

Related Questions

need some advice on this one as im struggling abit and cannot figure it
I need some advice from experts :) I will develop a website using PHP
I need some advice on techniques to perform page redirect in asp.net. Which one
I need some advice on how to model this simple categorization (?) example: I
I need some advice on how to build my DB. I will tell you
I'm in need of some advice in proper coding: I'm working on a program
I need some advice on how to tackle an algorithmic problem (ie. not programming
I need some advice on which Swing Components to choose in order to achieve
I need some advice on how to successfully update mutiple rows in my database
I need some advice. I’m building an app that has a sequence of 4

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.