|
1: What is it? 1. What is a data structure: an arrangement of data in computer memory or disk (array, linked list, stack, binary tree, etc.). 2. What is an algorithm: various processing of data with those structures. 2: Function 1. Real-life data storage: HR enters the relevant information of an employee's file, enters the information of new products in the supermarket into the storage system, etc., and these systems are composed of many data structures. 2. Developer's tools: used by the program itself, data structures are used to simplify some operations of program development. 3. Modeling: The use of diagrams can create mountain road maps, aircraft flight route maps, etc. An array of data storage structures a. Arrays are the simplest data storage structures relative to other structures, and they are simple and easy to understand. A diagram will take you to analyze this structure. ![]()
Lookup: Here suppose an ascending ordered array is defined, when looking for a value of 80, the subscript will start from 0 until 7 finds the corresponding value. b. How to play Syntax 1: dataType[] arrayRefVar = new dataType[arraySize]; Syntax 2: dataType[] arrayRefVar = {value0, value1, ..., valuek}; ![]()
Another efficient search for array relative linear search - dichotomous search The premise of the dichotomous algorithm is that the array has been sorted in an orderly manner, and the most classic is the guessing game 1-100. The algorithm is as follows: 1. Determine the search range front=0, end=N-1, and calculate mid=(front+end)/2. 2. If a[mid]=x or front>=end, the search is ended; Otherwise, continue down. 3. If a[mid]x, the value of the element to be found can only be within a range smaller than the middle element, assign the value of mid-1 to end, recalculate the mid, and move to step 2. ![]()
|