Distribucion del Aceite de Oliva segn su uso
9. Barreras de entrada al mercado
9.2. Legislación a aplicar
2.5.1 ABSTRACT DATA TYPES AND DATA STRUCTURES
The remaining part of this chapter is devoted to basics of search. We start with an informal review for some important abstract data types. The purpose of this review is to make our discussion somewhat self-contained. Abstract data types (ADTs) are conceptual description of data elements, including a set of operations. For example, the ADT stack has a "last-in-first-out" feature, and is characterized by operations such as push and pop. An ADT can be considered as a primitive form of the concept "object" (in the context of object-oriented paradigm). The implemented form of ADTs is usually referred to as data structures. For example, stacks can be implemented using arrays or linked lists. Examples of using these data structures can be found later in this chapter.
2.5.2 LINEAR STRUCTURES: LISTS, STACKS, QUEUES AND PRIORITY QUEUES
In linear data structures, a strict order is defined for all elements: one element is followed by another (except for the first and the last elements). The most popular linear structure is a list. Two restricted formats of linear structures are stacks (featured by last-in-first-out) and queues (featured by first-in-first-out). Although linear structures are simple, they are useful in modeling real-world problems. For example, the rate at which fund managers buy and sell stocks -- known as the turnover rate -- can be high, generating substantial capital gains and taxes. To combat this, tax-managed mutual funds often employ the old "buy and hold" strategy, lowering the number of transactions until a later date. Under most circumstances, a fund manager will sell the earliest-bought shares of a stock first, since they probably had the lowest purchase price and will bring the greatest profit. This is generally known on Wall Street as "first in, first out." However, managers of tax- managed funds do something more like "last in, first out." They're often careful to trade shares they purchased more recently, which will tend to sell for less capital gains.
A special kind of queue is called priority queue, where the order is not determined by time of each element entering the queue, but rather, by the priority associated with each element. The use of a priority queue will be illustrated in solving the 8-puzzle problem (Section 2.8.2).
2.5.3 TREES
A tree can be considered as a generalization of a list. A list is like a chain, while a tree allows branches. In fact, a tree is a hierarchical structure consisting of nodes (where data are stored) connected by edges. There is a designated node called the root of the tree. It would be beneficial if we view a tree as a root connected to several subtrees (each subtree is itself a tree). This perspective allows us to define a tree recursively. Of all kinds of trees, binary trees are of particular interest, where at most two subtrees (left subtree and right subtree) are allowed for each node. The nodes in a binary tree can be visited using various ways, including preorder (the root of a tree is visited first, followed by left and right subtrees), inorder (the root of a tree is visited after left subtree but before the right subtree) and postorder (the root of a tree is visited after left and right subtrees). There is also a lever-order traversal, where the nodes can be reached from the root (called the children of the root) are visited after the root itself. The children of these nodes are then visited in turn. Tree structures used for storage and search purpose are called search trees. In reality, binary search trees are a popular search structure. A binary search tree has an order property: for any node, keys stored in the left subtree are smaller than the key stored in the node itself and the keys stored the right subtree are larger than the key stored in the node itself (note that the term key refers to search key which is a variable whose value is used to guide the search). Another useful tree structure is heap. A binary heap is a binary tree
which has a balanced structure and has a heap order property: the key of the parent is always smaller than its children. There is an interesting relationship between a priority queue (which is usually conceived as a linear structure) and a heap (which is a tree). This is because in a priority queue, so long as we can always easily find the element with the highest priority, we do not have to worry about the exact order of other elements. This way of thinking leads to the heap implementation of the priority queue [Weiss 1998].
2.5.4 INDEX STRUCTURES FOR DATA ACCESS
For huge amounts of data, data structures for external storage are needed so that we can efficiently access data stored in secondary memory. A database stores structured data (usually in secondary memory) such as student information records, course information records, as well as others. Indexing techniques are needed to assist the search of the data. There are two basic kinds of indices: Ordered indices (based on a sorted ordering of the values) and hash indices (based on the values being distributed uniformly across a range of buckets. The bucket to which a value is assigned is determined by a hash function, which is a content-to-address mapping.) Extendible hashing is a technique used to guarantee a find operation is performed in two disk accesses for database input/output processing. A useful index structure is B tree, which has many variations [Weiss 1998, Silberschatz, Korth and Sudarshan 1998].
2.5.5 DISCRIMINATION TREES FOR INFORMATION RETRIEVAL
Search structures would become much more complex if what to be accessed is not structured data. Accessing such kind of data is studied in the field of information retrieval (IR). A discrimination tree (or network) is a data structure used for storing and retrieving large numbers of symbolic objects. The basic idea behind discrimination networks is to recursively partition a set of objects. Each partition divides the set of objects into subsets based on some simple rule. In a problem solving approach called case-based reasoning [Kolodner 1993], previously acquired cases are stored in a discrimination network for convenience of later retrieval.
2.5.6 GRAPHS
A graph G = (V, E) consists of a set of vertices (or nodes), V, and a set of edges (or arcs), E. Each edge is a pair (v, w), where v, w ∈V. Various graph search algorithms have been developed. A path through a graph connects a sequence of nodes through successive arcs. Graphs serve as a useful vehicle to model many real-world problems. State space search (to be discussed later in this chapter) can usually be conducted through graph search algorithms, where the states form the vertices of a graph. Among the most fundamental graph search algorithms are depth-first and breadth-first search, which will be briefly reviewed in Section 2.8. The graph is a very general concept and many other data structures can be considered as special cases of a graph. For example, a
tree can be viewed as a graph in which two nodes have at most one path between them. A network can also be considered as a graph. Graphs play an important role in computational intelligence problem solving. Various problem solving constructs to be introduced in the next few chapters are all variations of graphs, such as entity-relationship diagrams for conceptual data modeling (Chapter 6), conceptual graphs and frame systems for knowledge representation (Chapter 6), as well as others.
2.5.7 REMARKS ON SEARCH OPERATION
One of the very important operations in many data structures is search, which is the operation of looking for a specific item in a data structure. It is interesting to note that relationship between search operation and operations under other names. For example, a "find" operation frequently means searching the data structure. Retrieval of information usually involves search, but may also involve some additional operations (for example, perform reasoning based on the result of search). Searching a tree or a graph may require visiting all the elements in that data structure (if the target of search is not there), in this case the search operation actually has the same effect of the traversal operation. For example, the depth first search (DFS) algorithm in graphs is an extension of the preorder traversal in trees. It can be considered as an extension of pre-order traversal for (ordered) trees. The search follows a particular direction (usually the leftmost), going as far as possible, until a dead end is reached. A backtrack then occurs and search continues in the same fashion until all the vertices have been visited. Breadth first search (BFS) in a graph can be considered as an extension of level order traversal for the trees. One thing we should keep in mind about graph search algorithms is that we should avoid visiting the same node more than once.