1. Multiple Choice questions (50 points)
1, of the following four sorting algorithms, only () is an unstable sort
A. Bubble sort
B. Selection sort
C. Insertion sort
D. merge sort
2. Sorting an array with a large number of repeating elements using () is a reasonable choice **
A, quicksort
B. Dual-path quicksort
C. Three-way quicksort
D. Hill sort
3. Yang Hui’s triangle, a geometric arrangement of binomial coefficients in triangles, appeared in the book () written by Yang Hui, a mathematician in the Southern Song Dynasty of China in 1261. The first () and () in LeetCode are related to Yang Hui’s triangle.
A. Detailed Explanation of the Algorithm in Eight Chapters, 118, 119
B. Detailed Explanation of the Algorithm in Nine Chapters, 118, 119
C. Detailed Explanation of the Algorithm in Eight Chapters, 139, 140
D. Detailed Explanation of the Algorithm in Nine Chapters, 139, 140
4. Zhang SAN wants to perform a destructive operation, such as quickly deleting system elements. Using () can help me better complete this task
A. Prior traversal of binary trees
B. Middle order traversal of binary tree
C. Post-order traversal of binary trees
D. Sequence traversal of binary tree
5. An inefficient recursive sorting algorithm is mentioned in chapter 7 (Quicksort) of The second edition of Introduction to Algorithms (Page 95). Professors Howard, Fine et al. call this algorithm () **
A. Garbage sorting
B. Perfect order
C. Quick sorting of variants
D, HF sequencing
6. (multiple choices) If Programmer Zhang SAN finishes writing the article in the following picture, it will ()
A. Received the lawyer’s letter
B. Learn to play basketball
C. Learn RAP
D, article reading 100,000 plus
7. Which of the following abbreviations is not an abbreviation for certain algorithms commonly used by programmers
A, KMP
B, MMP
C, DP
D, A *
8. There is a glass whose quality is certain but unknown and needs to be tested. There’s a 100-story building right now, and the glass just breaks when dropped from a certain floor. Now give you two cups, ask how to detect the quality of this cup, that is to find out which floor will just break? Now, one way to do it is from the point of view of a mathematical equation. Assuming a minimum of x attempts, the first cup must be dropped from the x floor, because if it breaks, there are x-1 floors to try, and if it doesn’t break, there are x-1 more chances.
-
If it doesn’t break, the first cup, the second time I can try it from the x plus (x minus 1) layer, plus x minus 1, because at this point, the first cup breaks, and the second cup I can try it from the x plus 1 to the x plus (x minus 1) minus 1 layer, so I have x minus 2 chances.
-
If it hasn’t broken, then the first cup, the third time from the x + (x-1) + (x-2) layer. Whether the cup breaks or not, there are x minus 3 attempts, and so on.
After x attempts, the highest floor is x + (x-1) + (x-2) +… Plus 1 is equal to x times x plus 1 over 2.
Excuse me, what is x?
A, 2
B, 10
C, 14
D, 25
9. Suppose you are taking part in a Chinese New Year lucky draw. The host puts 1 yuan, 1 yuan and 1000 yuan into three red packets. Whichever one you choose, you get the corresponding money. When you choose a red envelope, the host alone open the remaining two red envelopes, and then there will be a red envelope for you to see. At this point, you are given a chance to choose another red envelope. Excuse me: should I change it?
A, in
B, don’t change
C. You can, but it’s not necessary
D. Either will do
10. Problem No. 9 of LeetCode is palindrome solution, which has many solutions. The solution in the figure below belongs to ().
A, Language solution
B. Mathematical solution
C, English solution
D. Sports solution
Ii. Fill in the blanks (20 points)
11. The first binary search paper was published in 1946, but the first bug-free binary search method appeared in (), which took () years.
12, We often say that there are five algorithms, they are divide-and-conquer, dynamic programming, (), (), branch bound.
13. Srinivasa Ramanujan, an Indian mathematical prodigy, was one of the most legendary mathematicians of the 20th century. He independently discovered nearly 3,900 mathematical formulas and propositions. The notes he left behind led to much later research.
Here’s one of his discoveries.
When k = 0, the value of π is ()
3. Programming Questions (30 points in total)
Pleasant Goat and Big Wolf are playing with some stones. An even number of piles were laid out in a row, with positive integer stones in each pile. The game is decided by who has the most stones in his hand. We have an odd number of pebbles, so there’s no draw. Pleasant goat and Big Wolf take turns. Pleasant Goat starts first. Each turn, the player takes the entire stack of stones from the beginning or end of the row. This continues until there are no more pebbles, at which point the player with the most pebbles wins. Assuming both Pleasant and Big Wolf play their best, return true when Pleasant wins and false when Big Wolf wins.
Now you need to design an algorithm to analyze how they win or lose.
Requirements: Please complete the following code with as little code as possible, no more than two lines.
/ / @ author: programmers zhang class Solution {public Boolean stoneGame (int [] piles) {/ / here, please complete the code}}Copy the code
The original address: www.cnblogs.com/fivestudy/p…
Previous hot articles:
- Summary of Java basic knowledge
- Performance Tuning Series topics (JVM, MySQL, Nginx, and Tomcat)
- From being kicked out to 5 offers of 30K+, I have come a long way
- 100 Java project parsing, with source code and learning documentation!
end