20172310 Blue Ink Cloud ASL Test 2018-1938872 Topics:
The known linear table has the element {5,13,19,21,37,56,64,75,80,88,92}, what is the ASL if using the binary lookup method?
Answer: (Today because go to cheerleading rehearsal, so now finish this blog)
First of all, because there is no class, so oneself to understand binary search method
In computer science, binary search (English: Half-interval search), also known as binary searching (English: binary searches), logarithmic search (English: Logarithmic search), is a search algorithm that finds a particular element in an ordered array. Binary lookup applies only to sequential storage structures. To maintain the order of the table, it is necessary to move a large number of nodes to insert and delete in the sequential structure. As a result, binary search is especially useful for linear tables that are rarely modified and often need to be found once created.
For those linear tables that find little and often need to be changed, a chain list can be used as a storage structure for sequential lookups. Binary lookups cannot be implemented on a linked list.
The original binary search is two-point search. ASL is the average lookup length for binary lookups. The binary search process can be described using a two-fork tree: The nodes in the middle of the current search interval as the root, and the nodes in the Zoozi and right child tables as the Saozi right subtree of the root.
For a table with 11 nodes, if the found node is the 6th node in the table, only one comparison is required, and if the found node is the 3rd or 9th node in the table, two comparisons are needed, and the first 1,4,7,10 node needs to be compared three times, and the 2,5,8,11 node needs to be compared four times.
20172310 Blue Ink Cloud ASL Test 2018-1938872