Urgent!! Questions about data structure algorithms!!

Updated on technology 2024-02-09
16 answers
  1. Anonymous users2024-02-05

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

    If it is larger, it is necessary to construct a hash function, which is a hash.

    There is no need for hashing at all in this question.

    The hash constructor is often used to divide by a prime number (which will not be proven here) and treat the same chain with the same result as a linked list. Pay attention to conflict handling: For numbers with the same result but different numbers, the common practice is to link to the next header node.

    It's been talked about in the data structure book, and there are many ways to do it.

    Of course, if you take a prime number that is larger than the range of numbers, it is no different from an array.

  2. Anonymous users2024-02-04

    lz good, n

    2 to the nth power of 5462 hope it helps you!

  3. Anonymous users2024-02-03

    Should the distribution of the data also be considered?

    If there aren't many numbers, I think it's a good idea to use a binary sort tree.

  4. Anonymous users2024-02-02

    Convert the number to a string, num[max], max can define a large enough by yourself, if the maximum number is 1000, max=6 is fine.

    Check the character num[i], via num[i]-'0'Convert it into a number, get the size of each digit of a number, and I don't need to talk about the rest.

    If there is a problem, you can re-** each other. The following is a small program I made to calculate the number of occurrences of a number, the function is to find out the number of numbers from 0 to an arbitrary number.

    Find the number of 0-num with the number nc, nc! =0

    #include

    #include

    #include

    #define nc 1

    main()

    int nl,i,t;

    long result=0;

    char num[64];

    printf("enter your number:");

    scanf("%s",num);

    i=nl=strlen(num);

    while (i--)

    t=num[~-nl-i]-'0';

    if(t>nc)

    result+=pow(10,i)+t*pow(10,~-i)*(i);

    else if(t==nc)

    else if(tnc)

    else if(atoi(&t)==nc)

    printf("num is %s,length is %d,result is %d",num,nl,result);

    It's just that hashing makes queries faster, and that's a validation feature. Expect to have a master.

  5. Anonymous users2024-02-01

    Is it a linear or sequential table?

    Function prototype: lnode*reverselist(lnode*l).

    Description: Inversion of a singly linked list.

    Enter :lnode * l the head pointer of a singly linked list returns :head pointer.

    lnode * reverselist(lnode **l)(*l)->next=null;

    l=prv;

    return *l;

    You can just swap the sequence table, I don't write **.

  6. Anonymous users2024-01-31

    The translation is really poor, that is, a person who has not learned a little English translates word by word. It is about the same level as Google Translate, and there are more than 100 printing errors in the whole book, and more than 10 errors (a total of dozens of pictures). I don't want to use this word, but other words are difficult to express my feelings, and they are more rubbish than TM garbage bureau rolling!

    People who do not have the patience and a certain foundation do not want to understand what the Chinese version says. I really don't know what Tsinghua Publishing House does. The original book must be good and substantial.

    Be organized. If you can patiently read the Chinese version, or directly read the original English version, you will definitely benefit a lot!

  7. Anonymous users2024-01-30

    There is a problem with the statement of Chishui Remnant Sun, what does it mean to learn data structures well? You can use your knowledge of data structures to implement STL libraries, boost libraries, and solve real-world programming problems.

    To learn data structures well, you need to learn at least one computer language.

    So if your computer language is C++, then you will definitely not be able to learn data structures well (ironclad) if you don't learn C++ well.

    Why? There are several core courses in the field of computer development: data structures, principles of operating systems, principles of database systems, and assembly language programming.

    Data structures are the foundation of these other core courses.

    Data structures are ultimately for implementation, and if you don't learn and experiment with C++**, then learning is like a quick fix, and you can't understand the details.

    At that time, there will be a lot of programming requirements for data structures, and if a person does not learn the pointer well, he will not be able to program one-way linked lists, bidirectional linked lists, binary trees, and graphs.

    However, even if you didn't invest much time in C++ before, you can make up for it by taking half a month to a month off to concentrate on it, and even better than most of your class: constant programming practice.

  8. Anonymous users2024-01-29

    It is very simple to write in the book, but it is difficult to use it in practice, this is the most basic thing is the basis for learning computer science in the future, just like learning high mathematics in the first year, it is a basic course As for the degree of learning, it depends on your own requirements for yourself!

    a) Basic concepts and terminology.

    1.The concept of data structures.

    2.Representation and implementation of abstract data structure types.

    3.Algorithms, requirements for algorithm design, measurement of algorithm efficiency, storage space requirements.

    b) Line table.

    1.Type definition of a line table.

    2.Sequential representation and implementation of line tables.

    3.Chained representation and implementation of linear tables.

    c) Stacks and queues.

    1.Definition, representation, and implementation of the stack.

    2.Application of stack: number system conversion, parenthesis matching, row, maze solving, expression evaluation 3Stack vs. recursive implementation.

    4.Queue. d) Strings.

    1.Definition, representation, and implementation of strings.

    2.Pattern matching algorithm for strings.

    5) Trees and binary trees.

    1.Definition and basic terms of a tree.

    2.Binary tree, traversing binary tree and clue binary tree.

    3.Trees and Forests: Storage Structures, Transformations with Binary Trees, Traversal 4Hoffman trees and Hoffman coding.

    5.Retrospective method and tree traversal.

    6) Search. 1.Static lookup tables.

    2.Dynamic lookup tables.

    3.Hash table.

    vii) Figure. 1.Definition and terminology of diagrams.

    2.The storage structure of the graph.

    3.Traversal of the graph.

    4.Connectivity issues for graphs.

    5.Topological ordering and critical path.

    6.The shortest path.

    viii) Internal sorting.

    1.The concept of sorting.

    2.Insert sorting.

    3.Quick sort.

    4.Select sorting: simple selection, tree selection, heap sorting.

    5.Merge sorting.

    6.Cardinality sorting.

    7.Comparison of various sorting methods.

  9. Anonymous users2024-01-28

    I just finished learning about data structures this semester and I'm using C++. For the course of data structures and algorithms, C++ programming is the foundation, and we have a big homework in this semester's class, which will be very inconvenient if you are not familiar with the language. But you don't have to worry, the most important thing to learn programming is to learn a computational thinking method, if you just can't use the syntax, then just look up the book when you need to use it.

  10. Anonymous users2024-01-27

    C++ is worse, and the data structure should be able to be learned, but most of the current data structure textbooks are described in C or C++ languages, so there are some relationships, but it won't affect too much, as long as you can understand the general statements.

  11. Anonymous users2024-01-26

    There is no direct connection between the two, but it will be beneficial to you if you learn, if you don't learn, you can also learn data structures and algorithms, I suggest you learn C++, but don't take him too seriously, as long as you can pass, don't fail the course...

  12. Anonymous users2024-01-25

    Select Sort.

    Insert sorting: Removes up to one reverse order after each comparison, so it's as efficient as bubbling sorting. But it's still a bit higher in terms of speed, because in bubbling sort is value swapping, and in insert sort is value shifting, so direct insert sort will be better than bubbling sorting.

    The direct insertion method is also an algorithm that is very sensitive to the orderliness of data. In the order case, only n-1 comparisons will be required, and in the worst case, n(n-1) 2 comparisons will be required.

    Choice sorting: Simple selection sorting, which has a certain number of comparisons: n(n-1) 2. Therefore, it will not perform well in any case of the sequence (from the upper 100k to the positive and reverse ordinals.

    It can be found that it takes about the same time, only the data movement time), which shows that it is not sensitive to the orderliness of data. Although it has many comparisons, it has very little data exchange. So we will find it in the general situation.

    will be faster than bubbling sorting.

    Bubbling sorting: In the optimal case, the result can be obtained only after n-1 comparisons (in this optimal case, the sequence is already in normal order, which is exactly what can be seen from the positive order of 100k), but in the worst case, i.e., in reverse order (or a smaller value at the end), the sinking algorithm will need n(n-1) 2 comparisons. So in general, especially in reverse order, it's not ideal.

    It is a sorting algorithm that is very sensitive to the orderliness of data.

    Heap sorting: Since it is formed on the basis of direct selection sorting using the results of comparison. The efficiency has improved a lot.

    The total number of comparisons it completes sorting is o(nlog2n). It is an algorithm that is not sensitive to the orderliness of data. But heap sorting will require two steps:

    It is to build the pile, and the second is to sort (adjust the pile). Therefore, it is generally not suitable for small-scale sequences, but for larger sequences, it will show superior performance.

    Cardinal sorting: In the program, it is decomposed in decimal bits of numeric values, and then the space is allocated at one time, so it requires more auxiliary space (10*n+10), but we can do other decompositions, such as decomposition by one byte, and the space will only need auxiliary space n+256 if the space is linked. The timing of cardinality sorting is linear (i.e., o(n)).

    It can be seen that cardinality sorting is very attractive, but it is not in-place sorting, and it is appropriate to change to index sorting when the node has a large amount of data. However, there is a premise for cardinality sorting, which is that keywords can be decomposed like integers and strings, but not if they are floating-point.

  13. Anonymous users2024-01-24

    Select Sort.

    The principle of the algorithm of selection sorting is: the first trip finds the smallest keyword from the n keywords to be sorted and puts it in the first position, if you want to find the smallest keyword, all elements must be compared, so the first trip should be compared n-1 times; The second trip is to find out the smallest element ......... from the remaining n-1 elements by n-2 comparisonsBy analogy, regardless of whether there is an initial order or not, it will be compared n-1 times for a total of n(n-1) 2 times, and the time complexity is always o(n squared).

    For the rest, let's take the example of insert sorting: the basic idea of insertion sorting is to insert one record at a time into the previously ordered subsequence by its keyword size. Imagine, if the ordered subsequence is 123, and the record to be sorted is 45, when inserting 4, you only need to compare it with 3 once to know that it is ranked after 3, and when sorting 5, you only need to compare it with 4 once to know that it is ranked after 4, and compare it 2 times in total.

    If the ordered subsequence is 234, and the record to be sorted is 15, when inserting 1, it needs to be compared 3 times from back to front to find its position, and when sorting 5, it only needs to be compared with 4 once, for a total of 4 comparisons. As can be seen from the above example, the number of comparisons varies depending on the order of the initial dataset.

    BTW, cardinality sorting is not a sorting algorithm based on keyword comparison.

  14. Anonymous users2024-01-23

    Come here to see if it's all SDU. Why do I think that the selection sort can be terminated in time and n-1 in the best case???

  15. Anonymous users2024-01-22

    Data structure + algorithm = program.

  16. Anonymous users2024-01-21

    It's all very basic conceptual stuff, the first linear rehash, and then the position calculated by the hash function already has an element, just find an empty position backwards and put it, so the result is:

    Address 0 1 2 3 4 5 6 7 8 9 Elements 16 48 9 82 1 5 7 39 The second insert sort is nothing more, just look at this yourself, every time it is the correct order of the first few elements, for example.

    First: 89

    The second: 12,89

    The third time: 12, 34, 89

    Once, to the last, is an ordered array of arranged arrays.

Related questions
7 answers2024-02-09

The Huffman tree is:

The weighted path length of a tree is the sum of the weighted path lengths of all leaf nodes in the tree, and the weighted path length of a node is the product of the path length from the node to the root node and the weights on the node. >>>More

5 answers2024-02-09

The algorithm is similar, but the language description is different, C is the basic! However, the C++ language is relatively simple, so it's good to get used to which one!! The data structure is mostly used in C++, it depends on which version of the textbook you use, if you learn C++, then use the C++ version of the textbook, the problem is not very big!! >>>More

13 answers2024-02-09

Another way to look: select ,select zy ,sum(zy as yjjefrom zy tbkk,zy brry >>>More

12 answers2024-02-09

Seagate's reputation is better, and Western Digital's reputation is poor, but the actual performance often varies little. >>>More

17 answers2024-02-09

First of all, do you have similar symptoms after going out to bathe or swim? If so, you can apply oils and fats such as petroleum jelly, olive oil or urea cream after bathing, and if it works, it is generally not a big problem. >>>More