What does the data structure and algorithm do?
A data structure is an arrangement on the computer's memory (and sometimes on disk). Data results include arrays, linked lists, stacks, binary trees, hash tables, and so on. The algorithm handles the data in these structures in various ways, such as finding a particular item of data or sorting the data.
Can be used in the following three categories of situations:
-
Real-World data storage
-
Programmer's Tools
-
Modeling
Features of the data structure:
Data |
Advantages |
Disadvantages |
Array |
Insert fast, and if you know the subscript, you can access it very quickly |
Find slow, delete slow, fixed size |
Ordered array |
Faster than unordered array lookups |
Delete and insert slow, fixed size |
Stack |
Provide last-in-first-out method access |
Access to other items is slow |
Queue |
Provides first-in, out-of-the-way access |
Access to other items is slow |
Linked list |
Insert Fast, delete slow |
Find Slow |
Two-fork Tree |
Find, INSERT, delete fast (if the tree remains balanced) |
Delete Algorithm Complex |
Red-Haishi |
Find, insert, delete are quick. The tree is always balanced. |
Algorithmic complexity |
2-3-4 Tree |
Find, insert, delete are quick. The tree is always balanced. Similar trees are useful for disk storage |
Algorithmic complexity |
Hash table |
If the keyword is known, access is extremely fast. Insert Fast |
Delete slow, if you do not know the critical access is slow, the use of storage space is not sufficient |
Heap |
Insert, delete fast, access to the largest data items quickly |
Slow access to other data items |
Figure |
Modeling the real World |
Some algorithms are slow and complex |
The data structures in the table above can be considered abstract data structures (ADT) in addition to arrays.
An overview of the algorithm
For most data structures, you need to know how to:
-
Insert a new item of data
-
Looking for a particular item of data
-
Delete a specific item of data
You also need to know how to iterate through the data items in a data organization for display or other operations.
Another important category of algorithms is sorting, with many kinds of algorithms in order. Simple sorting and advanced sorting.
The concept of recursion is important when designing certain algorithms. Recursion means that a method calls itself.
Some definitions
databases (database)
Represents all the data that is consulted in a particular case, and each piece of data in the database is considered to be in the same format. For example, if you use an indexed watch to make an address book, all of the cards make up a single piece of data. This data also sometimes represents the same meaning.
Records (record)
Records are defined as cells in the database.
fields (field)
A record is often divided into several fields. A field holds a particular type of data.
Key Words
To find a record in the database, you need to make a field of the record a keyword (or find a keyword). Search by this particular keyword.
Object-Oriented Programming
the problems of procedural language
The first is the lack of correspondence between the procedure and the real world.
Using process language to abstract and conceptualize real-world problems is difficult: methods perform tasks, and data stores information, but things in the real world operate at the same time. For example, the thermostat on the stove performs the task (the switch of the stove) but also stores information (the current temperature and the desired temperature).
second, there is a problem in the internal structure of the program.
The internal organizational structure of the solution is a more nuanced and problematic issue.
Object Brief
Object
The key breakthrough of object-oriented programming idea is that an object includes both methods and variables.
class
A class is a description (or blueprint) for an object or multiple objects.
Creating Objects
The declaration of the class does not create any objects of this class, and Java uses the keyword new. While creating an object, you need to store a reference in a variable of a specific type that is appropriate.
Several important features of object-oriented:
-
Objects include both methods and fields (data).
-
Class is a description of any number of objects.
-
Create an object that you want to use with the name of the keyword new and the class.
-
Call the method of an object to use the dot operator.
class libraries for Java data structures
The Java.util package contains data structures such as vectors (an expandable array), stacks, Libraries (dictionary), and hash tables.
Summary
-
A data structure is a form of organization in a computer's memory space or on a disk.
-
The correct choice of data structure will greatly improve the efficiency of the program.
-
Examples of data structures are arrays, stacks, and linked lists.
-
An algorithm is the process of accomplishing a particular task.
-
In Java, algorithms are often implemented by means of classes.
-
Most of the data structures and algorithms in this book are often used to build databases.
-
Some of the data structures are used as programmers ' tools: they help execute algorithms.
-
Other data structures can mimic what is shown in the world, such as the telephone network between cities.
-
A record often indicates that one thing in the world, such as an employee or a car part, is displayed.
-
A record is divided into fields. Each field stores an attribute of the thing described by this record.
-
A keyword is a field in a record that allows you to perform many operations on the data. For example, a personnel record can be sorted by the LastName field.
-
You can search for data to find all the records that have a fixed value for the Keyword field, which is called the Find keyword.
Java Data Structures and algorithms (chapter I overview)