Lesson 7th functions, arrays, strings, and search algorithms-2011.10.25
For example, a phishing hacker can copy an HTML page and modify a link to upload username and passwd to another server. For encryption and decoding, the same key is vulnerable to attacks. For example, the rot13 shift mode of caesor can increase the key. For example, if the shift of each location is different, https uses the non-symmetric encryption mode, that is, the public key encryption method. For privacy and security, refer to cs105.
The program has three aspects: Correct, design and style.
Next, I went on to talk about functions, arrays, and strings, and introduced linear search and binary search algorithms.
Lesson 8th GDB, recursive, and Bubble Sorting-2011.10.26
Use of GDB: Add-ggdb to the GCC command, you can set a breakpoint in the program to execute gdbxxx <program name>. Run the breakmain command to specify the breakpoint of a function, break23, and set the breakpoint on line 23. Run: run the command and stop it at the breakpoint. You can run the command from the breakpoint to the breakpoint. You can use continue to run the command to the next breakpoint, continue98, and stop the command at 99th breakpoints (which is helpful for the loop ); you can use "Next" for step-by-step execution, which can be abbreviated to "N". Use printx (a parameter to be tracked) to print the value of the parameter and use "Step" to enter the function for single-step execution, after entering the function, you can use next for single-row execution. Use List to display the executed code. Backtrace is used to view the execution location.
Introduction to sorting algorithms
- Bublesort: Compares two adjacent locations and sorts them by size. For example, if learning is used, the maximum (or minimum) values will be in the correct position, and the two adjacent locations will be sorted as much as possible to make them more orderly, the next processing of n --; the maximum value is n (n-1)/2, and the minimum value is n, which is more efficient than the following algorithm.
- Selctionsore: or locate the maximum (or minimum) position for each time and process n -- next time --. Each processing is n (n-1)/2, but the number of exchanges is small.
The above algorithms are n × n sorting efficiency. When the number is large, the consumption is huge. The efficiency of the algorithm. The final algorithm is implemented by logn convergence in search, such as the binary method. Therefore, the efficiency of nlogn can be obtained in an orderly manner at the beginning.
- Mergesort, the merge algorithm, divides the array into two parts for sorting, and then merges the two parts. Each 1/2 of parts can also be sorted in this way. The time complexity is O (nlogn), and the space complexity is O (n ). It can be implemented through recursion. Next we will introduce recursive recursion, and pay attention to convergence.
Related Links: My articles related to programming ideas