The first section, depth and breadth first refers to whatFor the traversal of the graph.The main idea of depth-first traversal is to traverse one of the branches of the graph until the end, then back up, and then do the same traversal along another line until all the vertices have been accessed.The main idea of breadth-first traversal is to first access all of its adjacent vertices with an unused vertex, and then to each adjacent vertex, and then access their adjacent, inaccessible vertices unti
-mentioned judgments, we need special judgment, the child is the root node of the number of subtrees, then V1 is a cut point is the necessary condition is, child = 2.The simple reference code is as follows.#include #includeusing namespacestd;intN, M, e[9][9], root;intnum[9], low[9], flag[9],index;intMinintAintb) { returnA a:b;}voidDfsintCur,intfather) { intChild =0, I, J; Index++; Num[cur]=index; Low[cur]=index; for(i =1; I ) { if(E[cur][i] = =1) {
happens to have n-1 edges.3. Adding an edge to a tree will form a loop.Tree-based abstract model, we actually use this structure in all aspects of life, such as the genetic pedigree of the organism, the organization composition of the company, the catalogue of books, the Match of the World Cup football team, etc., through this basic data structure, we can make the life of a lot of messy data organized, logical and form a system, This is the abstraction of things to our real life brought about b
The following describes the Bubble Sorting Algorithm of the AHA algorithm:
# Include
The time complexity of Bubble Sorting is O (n2), which is not a good sorting algorithm.
language Books, study a bit, feel well written, and the word "Getting Started" is really appropriate.@ Sunshine Rain: Not only teach everyone how to do, the key is to tell everyone the principle! The language is humorous and lively, with a very cordial feeling. The Biot number is interesting and interesting, which can enhance the child's logical thinking ability.@ Parents 100 Fish small fertilizer: Easy to understand, can be used as a child's programming enlightenment books, is a good science b
= 1; I
You can enter the following data for verification:
5huhu 5haha 3xixi 5hengheng 2gaoshou 8
The running result is
gaoshouhuhuxixihahahengheng
The core of Bubble Sorting is a dual nested loop. The time complexity of Bubble Sorting is O (N2 ). This is a very high time complexity. Some people started to study the Bubble Sorting as early as 1956, and many people tried to improve the Bubble sorting, but the results were dis
Today began the study of the "AHA algorithm" book. Generally speaking, this book is the algorithm of the small petition, the language is very popular, the introduction of the algorithm is relatively simple, now back to see the simple things will seem to waste time? Otherwise, I recently feel that the competition is not the ultimate way, the direction of learning is also changed to book as the object ("Specific mathematics" a column of the establishmen
Quick sorting of Aha AlgorithmsEfficiency issues
The Bubble Sorting mentioned above can be said to be our first real algorithm, it solves the problem that bucket sorting occupies a large amount of space (because bucket sorting requires a specified memory according to the number of sorted data), but Bubble Sorting sacrifices a lot of efficiency, suppose we want to sort the number of 0.1 billion, because the time complexity of Bucket sorting is O (M + N
converted number of outputs for each test instance, with one row for each output. If R is greater than 10, then the corresponding number rules refer to 16 binary (for example, 10 is indicated by a, 11 is represented by B, etc.).
Sample Input
7 223 12-4 3
Sample Output
1111b-11
Source
Freshman Practice Competition (2013.11.16)
Author
[Email protected]This time with the stack to do, the
reference value K.Problem: Sort unordered Series 6 1 2 7 9 3 4 5 10 8.Problem-solving ideas: Determine the base number K (set to 6 in the book), define I j two variables, respectively, from the sequence ends (A[0] and a[9]) to the middle, when JIf descending, the judging condition is changed to, when J>k,iGraphic Interpretation:K I J6 1 2 7 9 3 4 5 10 8K I J6 1 2 7 9 3 4 5 10 8K I J at this point the j6 1 2 7 9 3 4 5 10 8K I J6 1 2 7 9 3 4 5 10 8K I J6 1 2 7 9 3 4 5 10 8 variable I found a numb
will not continue to find? In fact, we set E[I][J] to record the shortest path of VI->VJ, and VI->VK, VK->VJ is also based on E[i][k], e[k][j], so we actually enumerate a series of relatively optimal cases, Then we find the current optimal solutions in these relative optimal solutions, and this is the place that the dynamic programming idea embodies.Essentially, the algorithm is a clever combination of enumeration and dynamic programming.#include using namespacestd;intMain () {inte[Ten][Ten], K
Sentinel J point to the far right of the sequence (that is, j = 10), pointing to the number 8. Solution:
Example code: Summary: In fact, the quick sort is based on a thought called "dichotomy".notes:fast sorting is faster because each exchange is a jump-through compared to a bubbling sort. Every time I sort.sets a datum point that places a number less than or equal to the datum point to the left of the Datum point, and a number greater than or equal to the datum pointto the right of t
the kitten fishing game
Part II: 4-5 Chapters, 9 knots, total 75 pagesReading time: 1 weeks, remember to operate the machine.Key content
Depth-First Search Dfs
Breadth First search BFS
The concept of graphs
Difficult content
Plumber's Game (SELECT, do not make mandatory)
Treasure Island Adventure (seed filling method)
Part III: 6-7 Chapters, 9 knots, total 64 pagesReading time: 1 weeks, remember to operate the machine.Key content
Dijkstra al
randomly select a number when the base number, of course, if the base number on the left, which starts from the right, if the right to start from the left, the only way to make the base number can be correctly returned, it is important to understand.About efficiencyfast sorting is faster than the bubbling sort of each swap location is a jumping, each sorting set a base number, the less than the base number on the left, greater than the number of the base to the right, so that it does not have t
Section 3 heap sorting
Create a heap of n elements. First, encode the N nodes from 1 to n in the top-down and left-right mode, in this way, N nodes can be converted into a Complete Binary Tree.
Then, from the last non-leaf node (node number is n/2)
It sounds really bad at noon. Obviously it was very hot, but I felt like I caught a cold during my lunch break. I have no plans for this afternoon. I will continue to struggle with the courseware and questions left by teacher Cao.
I just flipped
Problem Description:
Xiao-hum and Xiao-ha are playing a rather strange poker game--kitty fishing. Game rules: Divide a deck of cards evenly into two parts, no one points. Xiao Hum first took out the hands of the first card on the table, and then
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.