Sorted out the 2017 NetEase front-end pen test questions, attached to their own answers, only for reference, welcome to discuss and exchange. If there is anything wrong, please correct me.
Title finishing (excluding answers)
Network disk Sharing:
Link: https://pan.baidu.com/s/1dEYkyKp
Password: hxec
Single selection:
1. Which of the following is not a pseudo element selector:
A. First-line
B. Before
C. First-letter
D. Behind
Reference: D (should be after)
CSS pseudo element:
Unlike the typical element style in the DOM, it does not change any DOM content. Only the elements of the decorated class are inserted, which are visible to the user, but are not visible to the DOM. The effect of a pseudo class can be achieved by adding an actual class.
Because the state is dynamically changing, an element can get a pseudo class style when it reaches a particular state, and it loses that style when the state changes. It can be seen that its function and class are somewhat similar, but it is based on the abstraction outside the document, so called Pseudo class.
Pseudo element Selector, the effect of a pseudo element is to be achieved by adding an actual element.
/* Use styles for the first line of text for an element. */
: First-line
/* Use styles for the first letter or first word of text in an element. */
: First-letter
/* Inserts some content before an element. */
: Before
/* Inserts some content after an element. */
: After
2. Which of the following do not belong to the HTML INPUT element type:
A. Search
B. Range
C. DateTime
D. bool
Reference: D
The html<input> label sets the input fields where the user can enter data. <input> elements are used in <form> elements to declare input controls that allow users to enter data. The input field can be changed in a variety of ways, depending on the Type property.
References: http://www.runoob.com/tags/att-input-type.html
value |
Description |
button |
Defines a clickable button (usually used with JavaScript to start a script). |
CheckBox |
Define the check box. |
Color |
Define color picker. |
Date |
Define the date control (including year, month, day, excluding time). |
Datetime |
Defines the date and time controls, including year, month, day, time, minutes, seconds, and minutes, based on the UTC timezone. |
Datetime-local |
Defines the date and time controls, including year, month, day, time, minutes, seconds, minutes, and times. |
Email |
Defines the fields used for e-mail addresses. |
File |
Define File Selection field and "Browse ..." button for file upload. |
Hidden |
Defines a hidden input field. |
Image |
Define the image as the submit button. |
Month |
Define month and year controls (without time zone). |
Number |
Defines the fields used to enter numbers. |
Password |
Define the password field (the characters in the field are obscured). |
Radio |
Define radio buttons. |
Range |
Defines a control (such as a slider control) that is used for an input number that is not important for an exact value. |
Reset |
Defines the reset button (resets all the form values as defaults). |
Search |
Defines the text field used to enter a search string. |
Submit |
Define the Submit button. |
Tel |
Defines a field for entering phone numbers. |
Text |
Default. Defines a single line of text fields (the default width is 20 characters). |
Time |
Defines the control that is used to enter time (without the time zone). |
Url |
Defines a field for entering a URL. |
Week |
Define week and year controls (without time zone). |
3. The two-point lookup algorithm cannot be used in any of the following data structures.
A. Sorted LinkedList
B. Sorted Lineararray
C. Sorted binary Trees
D. Sorted Pointerarray
Reference: A
The binary search algorithm is a more frequent algorithm used in ordered arrays. The binary search algorithm, also known as binary lookup algorithm, is a commonly used algorithm in the search algorithm. The basic idea of its algorithm is: in ordered table, take the middle record as the comparison keyword, if the given value is equal to the keyword of the intermediate record, the search succeeds; If the given value is less than the key of the intermediate record, the search continues in the left half of the intermediate record; If the given value is greater than the middle record keyword, Continues the search in the left half of the intermediate record, repeating the process until the search succeeds. Otherwise, the lookup fails.
Using the binary lookup method, this "pile of numbers" must have characteristics:
• Stored in arrays
• Orderly arrangement
So if it's stored in a linked list, you can't use the binary lookup method on it.
4. Given that the 4th layer of a fully binary tree with a height of 4 (set to the 1th layer) has 3 leaf nodes, the number of leaf nodes in the 3rd layer of the complete binary tree is
A. 1
B. 3
C. 2
D. 4
Reference: C
Complete binary tree: Leaf nodes can only be present at the lowest and lower levels, and the bottom layer of the node is concentrated in the left-most of the location of the two-fork tree. If the depth of the two-fork tree is H, except the H layer, the number of nodes in all other layers (1~h-1) reaches the maximum, and all nodes in the H layer are continuously concentrated on the leftmost, which is the complete binary tree.
As shown in the figure, the 3,4,5 is the 4th layer of three leaf nodes, then the 3rd layer has 1, 22 leaf nodes.
5. What is the execution result of the following code?
settimeout (function () {
console.log (1);
},)
settimeout (function () {
console.log (2);
}, 0)
Console.log (3);
A. 1,2,3
B. 2,1,3
C. 3,2,1
D. 2,3,1
Reference: C
SetTimeout ()
Definition and Usage: the settimeout () method is used to call a function or evaluate an expression after a specified number of milliseconds.
Syntax: settimeout (CODE,MILLISEC)
Parameters: Code (required): The JavaScript code string to execute after the function to be invoked. Millisec (required): The number of milliseconds to wait before executing code.
Tip: settimeout () executes only one code at a time. If you want to call more than once, use SetInterval () or let code itself call SetTimeout () again.
Log (1) Set the 100ms delay, log (2) set the 0ms delay, log (3) direct execution.
As to what is the effect of the 0ms delay.
JavaScript is single-threaded, that is, you cannot execute multiple pieces of code at the same time, when a piece of code is executing, all subsequent tasks must wait, form a queue, once the current task is finished, and then remove the next task from the queue. This is also often referred to as "blocking execution." So one mouse click, or timer arrival point, or Ajax request completion triggers the callback function, these event handlers or callback functions do not immediately run, but immediately queued, once the thread is free to execute. If the current JavaScript process is executing a time-consuming code and a mouse click occurs, the event handler is blocked and the user cannot immediately see the feedback, and the event handler is placed in the task queue until the previous code is finished. If a settimeout is set in the code, then the browser inserts the code into the task queue at the right time, and if this time is set to 0, it means inserting the queue immediately, but not immediately, and still waiting for the previous code to finish. So settimeout does not guarantee the time of execution and whether the JavaScript thread is busy or idle.
References: http://blog.csdn.net/xingxing1828/article/details/28424591
6. The following is not part of the TCP protocol Congestion control is ()
A. Rapid retransmission
B. Out-of-band data
C. Slow start
D. Rapid recovery
Reference: B
TCP congestion control consists of 4 core algorithms: "Slow start" (slow start), "congestion avoidance" (congestion voidance), fast retransmission (fast retransmit), quick Restore (fast Recovery).
TCP Blocking Control Reference:
http://blog.csdn.net/sicofield/article/details/9708383
Http://www.cnblogs.com/hupp/p/4856134.html
The correct use of the section element in 7.HTML5 is ()
A. A page container that typically uses a section element as a setting style
B. You should use a section element in a content block without a title
C. It is recommended to use a section element instead of a article element, aside element, or NAV element
D. If you want to divide a piece of content into pieces, you should use the section element
Reference: D
<section> label defines sections (section, section) in a document. such as chapters, headers, footers, or other parts of a document. A section label is usually made up of content and its headings. div rather than section label is recommended when a content needs to be directly defined or defined by a script. The contents of the section label can be stored separately in the database or exported to a Word document.
Generally, it is not recommended to use the section label for content that does not have a title, and you can use the HTML5 Contour tool to check whether a page has a heading section, and if you use the tool to check that there is "untitiled section" in the description of one of the sections (without the title section), this section is likely to be improperly used.
The role of the Section label is to block the content on the page, or to segment the article, do not confuse the article element with its own complete, independent content. The article tag represents a separate, complete, externally referenced content in a document, page, or application.
Resources:
https://www.douban.com/group/topic/79128577/
Http://www.w3school.com.cn/html5/html5_section.asp
8. To estimate the spatial complexity of the algorithm, the concern is ()
A. Space occupied by program code
B. Total space occupied by the operation of the program
C. Auxiliary space used by the program
D. Data space used by the program
Reference: C
Spatial complexity (space complexity) is a measure of the amount of storage space temporarily occupied by an algorithm during its operation. The storage space occupied by an algorithm on the computer memory, including the storage space occupied by the storage algorithm itself, the storage space occupied by the input and output data of the algorithm and the storage space temporarily occupied by the algorithm in the process of operation. THREE aspects. Temporarily occupied storage space is the auxiliary space used by the program.
9.var arr = []
The results of the TypeOf arr are:
A. Array
B. function
C. Object
D. undefined
Reference: C
5 Simple data types (also called basic data types): Undefined, Null, Boolean, number, String
1 Complex data types: object (basically in addition to the above 5 kinds, the rest are object)
The following options in 10.JavaScript for this description are correct ()
A. When instantiating an object with new, this points to this instance object
B. When the function is defined, this points to the global variable
C. When an object calls a function or method, this points to the object
D. In the global scope under the browser, this points to global variables
Reference: A/C
This is used in the constructor, this is the new instantiation of the object.
Test code:
var x = 2;
function test () {
this.x = 1;
}
var ob = new test ();
alert (ob.x);//1
alert (x);//2
When the function is defined, this represents the automatic generation of an internal object when the function runs and is valid only within the function, so this point is not global when defined, and is not the case when the function is called.
When an object calls its own method, this points to the current object.
Test code:
function test () {
alert (this.x);
}
var ob = {};
ob.x = 1;
OB.M = test;
OB.M (); 1
When this function is called when the function is not a property of an object, this points to the global object.
The value of this will change as the function is used differently. But there is a general principle, and that is this refers to the object that invokes the function. There are four different forms of invocation.
① as a function call, this corresponds to window
② as the object's method, this corresponds to the object
③ as a constructor call, this is the equivalent of an instantiated object
④apply () and call () calls, this can be specified.
11. The most common operation in a single linked list is to insert an element after the last element and delete the given element in the list, the following options are correct ()
A. If there is only a head pointer, then the insert operation and the delete operation are all O (n)
B. Both the head pointer and the tail pointer, the insert operation and the delete operation are all O (1)
C. Increasing the tail pointer can increase the efficiency of the insert operation and improve the efficiency of the delete operation.
D. Both the head pointer and the tail pointer, then the insert operation and the delete operation are all O (n)
Reference: A
Both the find operation and the delete operation need to traverse the list and move the pointer to determine the position of the element, so the time complexity is O (n), and whether the trailing pointer has no effect. No lookup, the time complexity of the direct operation is O (1). So the complexity of Time is O (n).
12. What is the execution result of the following code?
var string = ' string ';
var number = 0;
var bool = true;
Console.log (number | | string);
Console.log (number && string);
Console.log (bool | |);
Console.log (bool && number);
A. ' String ', 0, true,0
B. ' String ', true,0, 0
C. ' String ', ' string ', True, 0
D. ' String ', 0, True,true
Reference: A
expression a && expression B: Computes the result of the operation of expression A (also can be a function),
If true, executes an expression B (or function) and returns the result of B;
If False, returns the result of A;
Expression A | | Expression B: Computes the result of an expression a (which can also be a function)
If False, executes an expression B (or function) and returns the result of B;
If true, returns the result of A;
Conversion rules:
Object is True
Non 0 number is true
Non-empty string is true
Other is False
13. Which of the following intentions is used to describe the adapter (adapter). ()
A. Define an interface for creating objects, let subclasses decide which class to instantiate
B. Encapsulate a request as an object so that you can parameterize clients with different requests, queue or log request logs for requests, and support revocable operations
C. Converting the interface of one class into another that the customer expects, this mode makes it possible for those classes that would otherwise not work together because of incompatible interfaces
D. Represents a manipulation of elements acting on the structure of an object, which allows you to make new operations for these elements without altering the classes of the elements
Reference: C
Adapter mode (Adapter) is the transformation of an interface (a method or a property) of a Class (object) into another interface (method or property) that the customer wishes, and the adapter pattern makes it possible for those classes (objects) that would otherwise not work together because of incompatible interfaces to work. Express Wrapper (wrapper).
14. A stack of the stack order is 1,2,3,4,5, then the stack of the Impossible output order is:
A. 12345
B. 54321
C. 43512
D. 45321
Reference: C
Stacks have two principles, "advanced first Out" and "advanced later out".
A. Advanced first out, 12345 in order into the stack, in the separate stack
B. Advanced after out, 12345 in order into the stack, in the separate stack
C. Advanced out, 1 not possible before 2 before the stack
D. Advanced after out, 1234 into the stack, 4 out of the stack, 5 into the stack, 5321 out of the stack
15. The following statements about process and threading are incorrect.
A. A thread is an entity of a process that can be used as the basic unit of system independent Dispatch and Dispatch
B. Threads can accomplish the tasks that a process needs to accomplish by cooperating with each other
C. Multiple threads in a process can execute concurrently
D. Shared variables and parts of the environment are not shared between threads
Reference: D
Variables and parts of the environment are not shared between processes and are implemented through communication, but threads can be shared.
Resources:
http://blog.csdn.net/luoweifu/article/details/46595285
Http://www.cnblogs.com/lmule/archive/2010/08/18/1802774.html
16. It is convenient to select the smallest 20 numbers from 1 trillion books for the next sort algorithm.
A. Merge sort
B. Quick Sort
C. Insert sort
D. Heap Sequencing
Reference: D
Heap sorting is an appropriate sort problem for handling large numbers of data
Http://www.cnblogs.com/worldpasser/p/3148639.html
Not explained in detail, attach a very classic information
http://www.jianshu.com/p/7d037c332a9d
The child object of the Window object in 17.JavaScript does not contain any of the following objects.
A. Document
B. Self
C. History
D. Message
Reference: D
window, self, and window.self are equivalent.
The main objects of window are as follows:
Document Frames History Location Navigator Screen
18. An integer sequence is sorted into ascending order, and a sequence of two 10,12,21,9,7,3,4,25 is changed to a single order, and the sorting algorithm may be:
A. Insert Sort
B. Quick Sort
C. Choosing a sort
D. Heap Sequencing
Reference: C
Simple choice of the basic idea of sorting: Compare + Exchange.
From the sorted sequence, find the element with the smallest keyword;
If the smallest element is not the first element of the sorted sequence, it is interchanged with the first element;
From the remaining N-1 elements, find the element with the smallest keyword, repeat (1), (2) step until the sort ends.
So we can see that the simple selection sort is also implemented through a two-tier loop.
First loop: Iterate through each element of the sequence sequentially
Second-tier loop: The current element of the traversal is compared to the remaining elements in turn, and the minimum element condition is exchanged.
Not explained in detail, attach a very classic information
http://www.jianshu.com/p/7d037c332a9d
19. The following can be matched
</img>
The regular expression is.
A. </img>
B. </img>
C. </img>
D. </img>
Reference: D
Test
var a= ' '
var b=//gi
var s=a.match (b) for
( var i= 0;i<s.length;i++)
{
alert (s[i]);
Alert (regexp.$1)
}
20. There are 12 devices in a system, the K-process competitive use, each process requires up to 4 devices, the system may occur a deadlock of the minimum value of K is ()
A. 3
B. 5
C. 4
D. 6
Reference: C
Each process allocates (4-1=) 3 devices First, 3*k + 1≤12,k≤3.67, so the minimum lock value is 3 + 1 = 4.
Programming Questions:
Example of a single input output:
Topic Description: ask for a+b and.
Import Java.util.Scanner;
public class Sample {public
static void Main (string[] args) {
scannerin= newscanner (system.in);
while (In.hasnextint ()) {
int a = In.nextint ();
int b = In.nextint ();
System.out.println (A + b);}}
Multi-line input and Output specification sample
Topic Description:
All the numbers in the N-order matrices are given, and all the numbers in the square are obtained.
Enter a description:
3
1 2 3
2 1 3
3 2 1
Output:
18
Import Java.util.Scanner;
public class Sample2 {public
static void Main (string[] args) {
scannerin= newscanner (system.in);
int n = in.nextint ();
int ans = 0,x;
for (int i = 0; i< N; i++) {for
(int j = 0; J < N; j +) {
x = In.nextint ();
ans = x;
}
}
System.out.println (ANS);
}
1. Title Description:
Small easy to have some colored bricks, each color is represented by an uppercase letter, each color brick looks exactly the same, now has a given string s,s each character represents the color of a small block of bricks. The little Yi wants to line up all his bricks, and if there are at most a pair of adjacent bricks of different colors, then the bricks are beautiful. Please help the little one calculate how many ways to put all his bricks into a beautiful line. (if the corresponding brick color sequence is the same in both ways, it is considered that the two methods are the same.) )
For example:
s = "ABAB", so the result of the small easily has 6 kinds of arrangement:
Aabb,abab,abba,baab,baba,bbaa
Only AABB and Bbaa meet up to only a pair of adjacent bricks of different colors.
Enter a description:
The input includes a string s, length of the string s (1≤length≤50), and each character in S is an uppercase letter (A through Z).
Output Description:
Output An integer that indicates how many ways the small is easy.
Example 1
Input:
ABAB
Output:
2
Ideas:
Calculate a total number of colors, only 1 colors, then the corresponding only 1 order, two colors, corresponding to 2 order, more than 2 colors are at least 2 adjacent to different colors of bricks, do not meet the requirements, then the corresponding 0.
Solution
Import Java.util.Scanner;
public class Main {public
static void Main (string[] args) {
scannerin= newscanner (system.in);
Strings = In.next ();
if (s = = NULL | | s.length () = = 0) {
System.out.print (0);
}
Int[] count = new int[26];
for (int i = 0;i < S.length (); i++) {
Count[s.charat (i)-' A ']++;
}
int record = 0;
for (int i = 0; i < count.length;i++) {
if (Count[i] > 0) {
record++
}
} if (Record > 2) {
System.out.print (0);
} else if (record = = 2) {
System.out.print (2);
} else {
System.out.print (1);}}}
2. Title Description:
If a 01 string of any two adjacent characters is not the same, we call this 01 string as a staggered string, for example, 1,10101,0101010 are staggered 01 strings. The Little Yi now has a 01 string s, the small one wants to find out a longest continuous substring, and this substring is a staggered 01 string. Small easy to ask you to help find the length of such a substring is how much.