c Problems with cardinality sorting algorithms

Updated on technology 2024-03-31
5 answers
  1. Anonymous users2024-02-07

    Subfunction pointer used incorrectly!

  2. Anonymous users2024-02-06

    1.The practical application of the sorting algorithm is, of course, sorting. It will be used in practical applications, such as data statistics.

    Sorting a set of data also facilitates later data lookups. It is important to know that there is a world of difference between the time complexity and system cost of a lookup in an ordered array and a lookup in a random unordered array.

    2.Algorithm complexity is actually an estimate, which is that o(n). First of all, o This operation is defined as: if f(n) is a function of a positive integer n, then xn

    o(f(n)) indicates that there is a positive constant m, such that when n is greater than or equal to an integer n0, xn is less than or equal to m multiplied by f(n). The practical meaning of this in the algorithm is as follows:

    For example, to execute a sorting algorithm, you need to execute up to 5n+7 commands (statements): at most, it means that the loop is completely executed during the execution process, that is, for example, if the loop condition is from 1-n, then the loop can be executed n times at most. If there are 5 basic statements in the loop (including the incrementing loop variable i++), then there are 5n statements.

    Then according to the definition of the o function above, this time xn

    5n7。Note that when n is greater than or equal to 7, 5n+7 is less than or equal to 6n, that is, we can regard 6 as m and n as f(n), so we can say that the time complexity of this algorithm is o(n). For other o(n2), o(n

    logn) and so on. The "worst-case" (from the initial condition of the loop to the final condition of the loop, the condition branch should also consider the maximum possible case) when calculating the total number of commands executed, and then every basic statement (e.g. an assignment, a comparison, etc.) should be taken into account.

  3. Anonymous users2024-02-05

    I don't know which seven you're talking about. I don't think there's such a number. I'll just pick up something I'm familiar with and talk about it.

    The first is o(log(n)).

    1. Fast row. In addition to the interview, I didn't find any place to use the handwriting fast row, but this thing is really fast and easy to write, remember that there is a pivot, and then two cursors, divide and conquer, and see the c** you know for details** can;

    2. Merge. The algorithm has stable time and high efficiency, and the merge sorting, as the name suggests, is to sort and merge from the basic elements to get the result. In personal experience, merging is generally used for linked lists, and the sorting of adjacent tables will be more pleasant;

    Next is O(N2):

    3, 4, 5, select, insert, bubble... It's okay to remember this reason, and you don't need to write it at all.

    If you choose, you can choose the smallest or largest one at the beginning.

    If you insert it, this is easy to say, that is, when you are usually tidying up your wallet or organizing books, you just insert and sort, just remember this.

    Bubbling, maybe it is more commonly used, a number found and the number around the wrong order, just swap it, this is bubbling.

    What else? Barrel row (cardinal cardinal)? Hill sorting? These are relatively unpopular.。。 Although in special places, ideas still need to be used, but the general order does not involve these.

    In addition, there are sort and qsort, these are learning thinking, there is no need to write it by hand, unless you want to engage in acm and the like.

  4. Anonymous users2024-02-04

    Need help with this? Private chat.

  5. Anonymous users2024-02-03

    That's right. The general arithmetic operation is as follows (from high to low source fiber) arithmetic operations: +, cavity, %

    Logic Operations (1): >

    Logical operation (2): =

    Assignment operation: =

Related questions
10 answers2024-03-31

Fast row (the most common and the easiest).

The idea of algorithms is divide and conquer. >>>More

6 answers2024-03-31

First of all, I would like to talk about the essence of search engine optimization, I personally think that the essence of search and search optimization is "to truly improve the user experience or solve user problems while leaving a natural link", please note that my word "real" is really helping real users solve real problems, "natural by the way" means that it is natural to leave external links, and the address of leaving external links is not far-fetched or deliberate. Then, let's talk about the search engine ranking mechanism, in general, it should be the most slippery information that is high in user experience and valuable to users in front of the user's eyes.

16 answers2024-03-31

Just o(n) scans it once, millions of arrays are not big, and c can be opened so big for global variables. >>>More

18 answers2024-03-31

Why they are taken in this way, and why x is from 1 to 14, this needs to be carefully calculated. Because the amount of calculation in this problem is very small, sometimes I try to save my own effort (calculate a little less) and let the computer calculate a little more. >>>More

12 answers2024-03-31

The answer to the time complexity of the algorithm in most question banks is to choose the option related to the size of the problem, and the distractors are often the performance of the computer hardware, the quality of the compiled program, the programming language, and so on. (Direct). >>>More