1. Turn the two-dollar lookup tree into a sorted doubly linked list
Title: Enter a two-dollar lookup tree to convert the two-dollar lookup tree into a sorted doubly linked list. Requires that no new nodes be created, only the pointer is adjusted. 10/\ 6 14/\/\4 8 12 16 Convert to doubly linked list 4=6=8=10=12=14=16. First we define the data structure of the two-tuple lookup tree node as follows: struct bstreenode{int m_nvalue;//value of node Bstreenode *m_pleft;//left child of node Bstre Enode *m_pright; Right child of Node}; Thinking of solving problems: Middle sequence traversal
2. Design a stack that contains the Min function. Defines the data structure of the stack, requiring the addition of a min function to get the smallest element of the stack. The time complexity required for the function min, push, and Pop is O (1). Problem-Solving ideas: auxiliary stacks
3. Find the maximum and the sub-arrayTitle: Enter an array of shapes with positive and negative numbers in the array. One or more consecutive integers in an array make up a sub-array, each of which has a and. The maximum value for the and of all sub-arrays. Requires a time complexity of O (n). For example, the input array is 1,-2, 3, 10,-4, 7, 2,-5, and the largest sub-array is 3, 10,-4, 7, 2, so the output is the and 18 of that subarray. Solving ideas: Dynamic planning and Divide and conquer (merging)
4. Find and all paths to a value in the two-dollar TreeTitle: Enter an integer and a two-dollar tree. From the root node of the tree, access all the nodes that pass through to the leaf nodes to form a path. Prints out all paths equal to the input integers. For example, enter the integer 22 and the following two tree 10/\ 5 12/\ 4 7 prints out two paths: 10, 12 and 10, 5, 7. The data structure of a binary tree node is defined as: struct Binarytreenode//A node in the binary tree{int m_nvalue;//value of Nodebinarytreenode *m_pleft; Left child of Nodebinarytreenode *m_pright; Right child of Node};
5. Find the smallest element of KTitle: Enter n integers to output the smallest of the K. For example, enter 1,2,3,4,5,6,7 and 8 for these 8 numbers, then the smallest 4 digits are three-to-three and 4. Problem solving ideas: first sort, then output
6. Give you 10 minutes, according to the upper row to give 10 number, in its next row to fill out the corresponding 10 numbers
The number of rows that are required in the next row is the number of times that the previous 10 numbers appear in the row. The 10 numbers on the top row are as follows: "0,1,2,3,4,5,6,7,8,9" for example, value: 0,1,2,3,4,5,6,7,8,9 allocation: 6,2,1,0,0,0,1,0,0,00 in the next row appeared 6 times, 1 in the next row appeared 2 times, 2 in the lower row appeared 1 times, 3 appeared in the next row 0 times .... etc...
7. Determine if two linked lists intersectGive the head pointers of two unidirectional lists, such as H1,H2, to determine if the two lists intersect. To simplify the problem, we assume that both of the lists are not with loops. Problem extension: 1. If the list may have a ring? 2. If you need to find the first node where two linked lists intersect? Problem Solving Ideas:
8. Three switches1. There are two rooms, one room has three lights, the other room has three switches that control three lights, the two rooms are separated, and one cannot see the other in the same room. The trainees are now required to enter the two rooms one at a time, and then determine which switch controls the three lights respectively. Is there any way to do it? Switching temperature 2. You let some people work for you for seven days, you have to use a gold bar as a reward. The gold bars were divided into seven small pieces, given each day. If you could only cut the gold bars two times, how would you assign them to the workers? 3.★ uses an algorithm to reverse the order of a linked table. Now do it again without recursion. ★ Use an algorithm to insert a node in a loop's link table, but not through the linked tables. ★ Use an algorithm to organize an array. Why do you choose this method? ★ Use an algorithm to match the generic string. ★ Invert a string. Optimize speed. Optimize space. ★ Reverse the order of the words in a sentence, such as "I Call Chris" to "Alice called me", the fastest and least mobile. ★ Find a substring. Optimize speed. Optimize space. ★ Compare two strings with O (n) time and const space. ★ Suppose you have an array of 1001 integers that are arbitrarily arranged, but you know that all integers are between 1 and 1000 (including 1000). In addition, all other numbers appear only once, except that one number appears two times. Suppose you can only handle this array once, and use an algorithm to find the duplicate number. If you use secondary storage in your calculations, can you find an algorithm that doesn't work this way? ★ No multiplication or addition is added 8 times times. Now add 7 times times the same method.
9. Determining whether an integer sequence is a two-dollar lookup tree post-order traversal resultsTitle: Enter an array of integers to determine if the array is the result of a sequential traversal of a two-tuple lookup tree. Returns False if True is returned. For example, input 5, 7, 6, 9, 11, 10, 8, because this integer sequence is the following post-order traversal result of the tree: 8/\ 6 10/\/\ 5 7 9 11 therefore returns true. If you enter 7, 4, 6, 5, no tree has the result of a post-order traversal that is the sequence, and therefore returns false.
question 10th. Flip the order of the words in the sentence. Title: Enter an English sentence, flipping the order of the words in the sentence, but the order of the characters within the word is unchanged. Words are separated by spaces in sentences. For simplicity, punctuation is treated like ordinary letters. For example, enter "I am a student.", then output "student." A am I ".
question 11th. Finding the maximum distance of a node in a binary treeIf we look at the two-fork tree as a graph, and the connection between the parent and child nodes is two-way, let's define the number of edges between the two nodes as "distance". Write a program to find the distance between the two nodes farthest apart in a binary tree.
question 12th. Seeking 1+2+...+nRequirements cannot use multiplication, for, while, if, else, switch, case, and conditional judgment statements (A?). B:C).
question 13th: Enter a one-way list to output the penultimate K-node in the linked list. The bottom No. 0 node of the list is the tail pointer of the linked list. The linked list node is defined as follows: struct listnode{int m_nkey; Listnode* M_pnext;};
question 14th:Enter an array that has been sorted in ascending order and a number to find two numbers in the array so that they are exactly the number entered. The required time complexity is O (n). If there are many pairs of numbers and equals the input number, the output can be any pair. For example, input arrays 1, 2, 4, 7, 11, 15, and number 15. Because of the 4+11=15, the outputs are 4 and 11.
question 15th:Enter a two-dollar lookup tree to convert the tree to its image, which is in the converted two-tuple lookup tree, and the nodes of the Zuozi are larger than the nodes of the right subtree. Recursive and cyclic methods are used to complete the image transformation of the tree. For example input: 8/\ 6 10/\/\5 7 9 11 output: 8/\ 10 6/\/\11 9 7 5 definition Two-tuple the node for the Find tree is: struct Bstreenode//A node in the binary search T Ree (BST) {int m_nvalue;//value of node Bstreenode *m_pleft;//left child of node Bstreenode *m_pright; of node};
question 16th:Enter a two-dollar Tree to print each node of the tree from top to bottom, in the same layer, in the order from left to right. For example input 8/\ 6 10/\/\5 7 9 11 Output 8 6 10 5 7 9 11.
Question 17th:Title: Finds the first occurrence of a character in a string. If you enter Abaccdeff, then output B. Analysis: This problem is a 2006 Google pen test.
question 18th:Title: N Numbers (0,1,..., n-1) Form a circle, starting with the number 0, each time the number of m digits is removed from the circle (the first is the current number itself, the second is the next number of the current number). When a number is deleted, the next number from the deleted number continues to delete the first m digits. Find the last number left in this circle.
question 19th:Title: Define the Fibonacci sequence as follows:/0 n=0f (n) = 1 n=1 \ f (n-1) +f (n-2) n=2 input n, the quickest way to find the nth item of the sequence. Analysis: When we talk about recursive functions in many C language textbooks, we use Fibonacci as an example. So many programmers are very familiar with the recursive solution of this problem, but .... Oh, you know.
Question 20th:Enter a string representing an integer to convert the string to an integer and output. For example, the input string "345", the output integer 345.
question 21stEnter two integers n and M, and take a few numbers from the sequence 1,2,3.......N to make them equal to m, requiring all possible combinations of them to be listed.
question 22nd:There are 4 red cards and 4 blue cards, host first take any two, and then respectively in a, B, c three people on the forehead affixed any two cards, a, B, c three people can see the other two people on the forehead of the cards, after reading let them guess what color on their forehead card, A said do not know, B said do not know, C said do not know, Then a says yes. Ask how to reason, A is how to know. If you use the program, how to achieve it?
Question 23rd:The simplest and quickest way to calculate whether the following circle intersects a square. 3D coordinate system origin (0.0,0.0,0.0) Circle: radius r = 3.0 Center o = (*. *, 0.0, * *) Square: 4 angular coordinates; 1: (* *, 0.0, * *) 2: (* *, 0.0, * *) 3: (* *, 0.0, * *) 4: (* *, 0.0, * *)
Question 24th:List operation, (1). Single-linked list in-place reverse, (2) Merge linked list
Question 25th:Write a function whose prototype is the int continumax (char *outputstr,char *intputstr) function:
Find the longest consecutive number string in the string, and return the length of this string,and send this longest number string to one of the function parameters outputstr the memory. For example: After the first address of "abcd12345ed125ss123456789" is passed to Intputstr, the function returns a value of 123456789 that is referred to by 9,outputstr
26. Left rotation stringDefines the left rotation of a string: moves several characters in front of the string to the end of the string. If the string abcdef left rotation 2 bit to get the string cdefab. Please implement the function of string left rotation. The complexity of a string operation that requires time to be N is O (n), and auxiliary memory is O (1).
27. Stair Jumping ProblemTitle: A step has a total of n, if you can jump 1 levels at a time, you can jump 2 levels. How many total hops are in total, and the time complexity of the algorithm is analyzed.
28. The number of integers in the binary representation of 1Title: Enter an integer to find out how many 1 are in the binary representation of the integer. For example, enter 10, because the second binary is represented as 1010, there are two 1, so the output is 2. Thinking of solving problems: bit arithmetic
29. Stack push, pop sequenceTitle: Enter a sequence of two integers. One of the sequences represents the push order of the stack, judging whether another sequence is likely to be the corresponding pop order. For the sake of simplicity, we assume that any two integers of the push sequence are not equal. For example, the input push sequence is 1, 2, 3, 4, 5, then 4, 5, 3, 2, 1 may be a pop series. Because you can have the following push and pop sequence: Push 1,push 2,push 3,push 4,pop,push 5,pop,pop,pop,pop, so the resulting pop sequence is 4, 5, 3, 2, 1. But sequences 4, 3, 5, 1, 2 are not likely to be the sequence of pop sequences of the push sequence 1, 2, 3, 4, 5.
30. The number of occurrences of 1 in positive numbers from 1 to nTitle: Enter an integer n to find the number of decimal representations of the n integers from 1 to n in 1 occurrences. For example, enter 12, from 1 to 12 these integers contain 1 of the numbers have 1,10,11 and 12, 11 have appeared 5 times.
.A diagram similar to the structure of a honeycomb, searching the shortest path (requires 5 minutes)
.There are two sequences, a, B, the size is n, the values of the sequence elements are arbitrary integers, unordered; requirements:
minimizes the difference between the and of [sequence A and] and [sequence B elements] by exchanging the elements in A/b. For example: Var a=[100,99,98,1,2, 3];var b=[1, 2, 3, 4,5,40];
33. Implement a very advanced character matching algorithmGive a string of very long strings, asking to find a string that meets the requirements, such as the destination string: 1231******3***2, 12*****3 These are all to find out
34. Implement a queue. The scenario for a queue is: a producer thread into row the number of int types, and a consumer thread dequeue the number of type int
35. Find the largest two-dimensional matrix (element and maximum) in a matrix.1 2 0 3 42 3 4 5 11 1 5 3 0 The largest is: 4 55 3 Requirements: (1) write the algorithm, (2) Analyze the time complexity; (3) write the key code in C
.N team competition, respectively numbered 0,1,2 .... N-1, known for their strength-contrast relationships, are stored in a two-dimensional array w[n][n], and the value of W[i][j] represents a stronger one in the team numbered i,j. So W[i][j]=i or J, now give them the order of appearances, and store in the array order[n], such as order[n] = {4,3,5,8,1 ...}, then the first round is 4 to 3, 5 to 8. ....... Winners, losers eliminated, the same round of the elimination of all ranks no longer subdivided, that can be arbitrarily ranked, the next round by the winner in accordance with the order, followed by 22, for example, may be 4 to 5, until the first program implementation, give two-dimensional array w, one-dimensional array order and Used to output the match position array Result[n], to find the result.
The PNs.There are n strings of length m+1, if the last m characters of a string match the first m characters of a string, then two strings can be joined, asking if the n string can be a maximum of one long string, and if a loop occurs, an error is returned.
.1. Use the balance (can only compare, not weigh) from a pile of small balls to find out the only one of the lighter, using X-scale, up to the Y ball to find the lighter one, the relationship between Y and X. 2. There is a large and large input stream, large to no memory can be stored down, and only input once, how to get a random m record from this input stream. 3. A large number of URL strings, how to remove duplicates, optimize the complexity of time space
.
(1). Find the maximum distance between any two nodes in a binary treeThe two-node distance is defined as the number of edges between the two nodes, such as the distance between a child's node and the parent node is 1, and the distance between the adjacent sibling nodes is 2, optimizing the time space complexity.
(2). To find a cut point of a connected graphThe definition of a cut point is that if you remove this node and its associated edges, the graph is no longer connected and describes the algorithm.
.
1) A string of beads (m) connected to the end, having N colors (n<=10),Design an algorithm that takes out one segment, requires all n colors, and minimizes the length. and analyze the complexity of time and space.
2) Design a system to deal with the problem of Word collocationFor example, China and the people can match, the Chinese people of China are effective. Requirements: * The number of queries per second of the system may be thousands of times; * The number of words in the order of 10W; * Each word can be paired with a 1W word. When the user enters the Chinese people, it asks to return the information related to this collocation phrase.
41. Finding the Crystal Element Finder for solid crystal machineWafer disk by an unknown number of the same size of the crystal element, the crystal is not necessarily full of crystal plate, the camera each time this can match a crystal, if matched, then pick the crystal, if matched, but the camera is measured by the distance between the wafer to move to the next position. The algorithm of traversing wafer disk is used to find the idea.
42. Please modify the Append function to use this function:Two non-descending list of the 1->2->3, and 2->3->5 and for 1->2->3->5 can only output the results, can not modify the data of the two linked list.
43. Recursive and non-recursive two methods to achieve the two-fork tree of the pre-sequence traversal.
.1. Design a Rubik's Cube (six sides) of the program. 2. There are 10 million SMS, there are duplicates, in the form of a text file saved, one line, there are duplicates. Please use 5 minutes to find the top 10 duplicates. 3. I've got 10,000 URLs, and now I'm going to give you a URL, how to find a similar URL. (Interviewer does not explain what is similar)
.1. For an integer matrix, there is an operation, the matrix of any element plus a moment, need its adjacent (up and down) an element also added one, now give a positive matrix, to determine whether it can be obtained by a full 0 matrix through the above operation. 2. An array of integers, the length of N, divided into m parts, so that each part and equal, the maximum value of m such as {3,2,4,3,6} can be divided into {3,2,4,3,6} m=1; {3,6} {2,4,3} m=2 {3,3}{2,4}{6} m=3 so the maximum value for M is 3
.How many matching permutations can four pairs of parentheses have? For example, two pairs of parentheses can have two types: () () and (())
.Find the longest descending subsequence of an array, such as {9,4,3,2,5,4,3,2}, the longest descending subsequence of {9,5,4,3,2}
.An array is formed by moving a number of digits to the left of a descending sequence, such as {4,3,2,1,6,5} is formed by the left two bits of {6,5,4,3,2,1}, which finds a number in the array.
.How to sort n numbers, requiring time complexity O (n), Spatial complexity O (1)
51. And is a continuous positive sequence of N. Title: Enter a positive n, output all and n consecutive positive sequence. For example, input 15, because of 1+2+3+4+5=4+5+6=7+8=15, so output 3 sequential sequence 1-5, 4-6 and 7-8. Analysis: This is a question of netease.
52. The depth of the two-dollar Tree. Title: Enter the root node of a two-dollar tree to find the depth of the tree. A path from the root node to the leaf node followed by a node (with root and leaf nodes) to form a tree, the length of the longest path is the depth of the tree. Example: Enter a two-tuple tree: 10 / \ 6 14 / / \ 4 12 16 output The depth of the tree 3. The nodes of a binary tree are defined as follows: struct Sbinarytreenode//A node of the binary tree{ int M_nvalue; Value of node sbinarytreenode *m_pleft; //left child of node & nbsp; sbinarytreenode *m_pright; Right child of Node}; Analysis: The problem is still to examine the traversal of the two-dollar Tree.
53. The arrangement of strings. Title: Enter a string to print out all the permutations of the characters in the string. For example, the input string abc, the output of the characters A, B, C can be arranged out of all the strings of ABC, ACB, BAC, BCA, Cab and CBA. Analysis: This is a good test for recursive understanding of programming problems
54. Adjust the array order so that the odd digits are preceded by even numbers. Title: Enter an array of integers to adjust the order of the numbers in the array so that all the odd digits are in the first half of the array, and all the even digits are in the second half of the array. Requires a time complexity of O (n).
.Title: the Declaration of class cmystring is as follows: Class cmystring{public:cmystring (char* pData = NULL); cmystring (const cmystring& str); ~cmystring (void); cmystring& operator = (const cmystring& str); Private:char* m_pdata;}; Implement the overloaded function of its assignment operator, which requires exception security, that is, if an exception occurs when an object is assigned, the state of the object cannot be changed.
56. The longest common string. Title: If all characters of string one appear in the order of the strings in the other string two, then the string is called a substring of string two. Note that a character that does not require a substring (string one) must appear consecutively in string two. Write a function, enter two strings, ask for their longest common substring, and print out the longest common substring. For example: Enter two strings Bdcaba and Abcbdab, the strings BCBA and Bdab are their longest common substrings, output their length 4, and print any substring. Analysis: Finding the longest common substring (longest Common subsequence, LCS) is a very classic dynamic programming problem
58. Output the linked list from the tail to the head. Title: Enter the head node of a linked list, which in turn outputs the value of each node from the end of the tail point. The linked list node is defined as follows: struct listnode{int m_nkey; Listnode* M_pnext;};
59. Classes that cannot be inherited. Title: Design a class in C + + that cannot be inherited.
60. Delete the linked list node within O (1) time. Title: The head pointer of the given list and a node pointer, at O (1) Time to delete the node. The linked list node is defined as follows: struct listnode{int m_nkey; Listnode* M_pnext;}; The functions are declared as follows: void Deletenode (listnode* plisthead, listnode* ptobedeleted);
61. Find two occurrences of a number in an arrayTitle: In an integer array, except for two digits, the other numbers appear two times. Please write the program to find the two only occurrences of the number. The required time complexity is O (n), and the spatial complexity is O (1).
62. Find out the first common node of the list. Title: Two one-way lists to find their first common node. The node of a linked list is defined as: struct listnode{int m_nkey; Listnode* M_pnext;};
63. Remove a specific character from the string. Title: Enter two strings and remove all characters from the second string from the first string. For example, enter "they is students." and "Aeiou", the first string after deletion becomes "Thy R stdnts." Analysis: This is a Microsoft face test. In Microsoft's common interview questions, the string-related topics accounted for a large part of the problem, because the writing program operation string can reflect our programming basic skills well.
64. Look for the number of ugly. Title: We refer to numbers that contain only factors 2, 3, and 5 as ugly numbers (Ugly number). For example, 6, 8 are ugly numbers, but 14 is not, because it contains factor 7. We used to think of 1 as the first ugly number. Find the 1500th ugly number in order from small to large.
65. Output 1 to the maximum number of n digitsTitle: Enter the number n, output sequentially from 1 to the largest n bits of the 10 binary. For example, input 3, the output 1, 2, 31 until the maximum 3 digits is 999.
66. Reverse the stack. Title: Reverse a stack with recursion. For example, input stack {1, 2, 3, 4, 5},1 at the top of the stack. The stack after upside down is {5, 4, 3, 2, 1},5 at the top of the stack.
67. Two busy play entertainment. 1. Playing cards of the straight from playing cards randomly draw 5 cards, judging is not a straight, that is, the 5 cards are continuous. 2-10 is the number itself, A is 1,j to 11,q for 12,k to 13, and the size King can be regarded as any number. The number of points in 2.N dice. Throw n dice on the ground, and the sum of the points on the top side of the dice is S. Enter N to print out the probability that all possible values of s appear.
68. Arrange the array to the smallest number. Title: Enter an array of positive integers, concatenate them into a number, and output the smallest of all the numbers that can be drained. For example, the input array {32, 321}, the output of these two can be ranked as the smallest number 32132. Please give the algorithm to solve the problem and prove the algorithm.
69. Rotate the smallest element in the array. Title: Move a number of elements at the beginning of an array to the end of the array, which we call the rotation of the array. Enter a rotation of an ordered array, outputting the smallest element of the rotated array. For example, the array {3, 4, 5, 1, 2} is a rotation of {1, 2, 3, 4, 5}, and the minimum value of the array is 1. Analysis: The most intuitive solution to this problem is not difficult. By iterating through the array one time, you can find the smallest element, and the time complexity is obviously O (N). But this idea does not take advantage of the characteristics of the input array, we should be able to find a better solution.
70. Give a function to output all permutations of a string. ANSWER simple backtracking can be achieved. Of course there are many kinds of algorithms for the generation of permutations, to look at combinatorial mathematics, and to create permutations in reverse order and some methods that do not require recursive generation of permutations. The impression of Knuth in the first volume of the <TAOCP> in depth of the formation of the arrangement. The understanding of these algorithms requires a certain mathematical foundation,
71. The integer value of the number of square. Title: Implement the function double Power (double base, int exponent), to find the exponent of the base. There is no need to consider overflow. Analysis: This is a seemingly simple question. There may be a lot of people in the 30 seconds after seeing the topic write the following code: Double Power (double base, int exponent) {double result = 1.0; for (int i = 1; I <= exponent; ++i) result *= base; return result;}
72. To design a class, we can only generate one instance of the class. Analysis: A class that can generate only one instance is a type that implements the singleton pattern.
73. Maximum length of the action string. Enter a string that prints the maximum length of the symmetric substring in the string. For example, the input string "Google", because the longest symmetric substring in the string is "goog", so output 4. Analysis: Many people may have written a function that determines whether a string is symmetric, and this topic can be seen as a reinforced version of the function.
74. More than half the number of occurrences in the arrayTitle: There is a number in the array that appears more than half the length of the array to find this number. Analysis: This is a widely circulated face test, including Baidu, Microsoft and Google, and many companies have used this topic. It takes a few 10 minutes to answer this question well, in addition to better programming ability, but also need a faster response and strong logical thinking ability.
75. Minimum common parent node for two fork tree two nodesTitle: Two the node of the fork tree is defined as follows: struct treenode{int m_nvalue; treenode* M_pleft; Treenode* m_pright;}; Enter the two nodes in the binary tree, and output the two nodes at the lowest common parent node in the number. Analysis: Finding the lowest common node of two nodes in a number is a frequent problem in the interview. There are at least two variants of the problem.
76. Replication of complex linked listsTitle: There is a complex list of nodes, with the exception of a m_pnext pointer pointing to the next node, and a m_psibling pointing to any node in the list or null. The C + + definition of its node is as follows: struct complexnode{int m_nvalue; complexnode* M_pnext; Complexnode* m_psibling;}; is a complex list of this type that contains 5 nodes. The solid arrow in the figure represents the M_pnext pointer, and the dashed arrow indicates the m_psibling pointer. For simplicity, pointers to null are not drawn. Please complete the function complexnode* clone (complexnode* phead) to copy a complex linked list. Analysis: A slight change in the common data structure, this is a very new face test. To solve this type of problem in less than one hours, we need a quick response, a thorough understanding of the data structure, and a solid programming foundation.
77. The interview topics on linked list issues are as follows: 1. Given a single-linked list, detects if there is a ring. use two pointers p1,p2 from the linked list head, p1 each step forward, P2 each advance two steps. If the P2 arrives at the end of the list, description without ring, otherwise P1, P2 will inevitably meet at some point (P1==P2), thus detecting the link list in the ring. 2. Given two single-linked lists (Head1, head2), detects if there is an intersection of two linked lists, and returns the first intersection if there is one. if head1==head2, then apparently intersect, return directly to Head1. Otherwise, starting from Head1,head2 to traverse two linked list to get its length len1 and len2, assuming len1>=len2, then the pointer p1 from head1 start backward move len1-len2 step, pointer p2=head2, below P1, P2 Each backward and compares the p1p2 for equality, if the node is returned as equal, otherwise the two linked lists do not have an intersection point. 3. Given a single-linked list (head), if there is a ring, return to the first node of the ring from the start point. using one, we can check if there are rings in the list. If there is a ring, then the P1P2 coincident point P must be in the ring. Disconnect the ring from P point by: P1=p, P2=p->next, P->next=null. At this point, the original single-linked list can be regarded as two single-linked list, one from the head, the other starting from the P2, so the use of two methods, we find their first intersection is the request. 4. The node is removed only by a pointer to a node p (not the last node, or p->next!=null) in the order list. method is very simple, the first is to put the data in P, and then copy the P->next data into P, then delete the P->next can be. 5. Only one node p (non-empty node) in the order list is inserted, and a node in front of P. The approach is similar to the former, first assigning a node q, inserting Q into P, then copy the data in P into Q, and then record the data to be inserted in P.
78. What is the difference between a linked list and an array? Analysis: Mainly in the basic concept of understanding. But the best thing to think about is that the competition for hiring may be in the details, who is more careful and who wins.
.1. Write an algorithm for sorting the list. Explain why you would choose to use this method? 2. Write an algorithm that implements array sorting. Explain why you would choose to use this method? 3. Write code that directly implements the function of the STRSTR () function.
A .Problem Description: 12 tall and different people, lined up in two rows, each row must be from short to high, and the second parallelism corresponds to the first row of the person high, ask how many kinds of arrangement? recursion
Data structure and algorithm 80 channel