ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
OptimalSearchTree.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*------------------------ File OptimalSearchTree.h ------------------------*/
3/*--------------------------------------------------------------------------*/
58/*--------------------------------------------------------------------------*/
59/*----------------------------- DEFINITIONS --------------------------------*/
60/*--------------------------------------------------------------------------*/
61
62#ifndef __ADS_OptimalSearchTree
63 #define __ADS_OptimalSearchTree
64/* self-identification: #endif constant */
65
66/*--------------------------------------------------------------------------*/
67/*------------------------------ INCLUDES ----------------------------------*/
68/*--------------------------------------------------------------------------*/
69
70#include "ADS/Contract.h"
71
72#include <algorithm>
73#include <cstddef>
74#include <vector>
75
76/*--------------------------------------------------------------------------*/
77/*--------------------------- NAMESPACE ------------------------------------*/
78/*--------------------------------------------------------------------------*/
79
80namespace ADS
81{
82
86template< class T >
88{
89 T cost;
90 int root;
91 std::vector< int > left;
92 std::vector< int > right;
93 };
94
123template< class T >
124OptimalSearchTree< T > optimalSearchTree( const std::vector< T > & p ,
125 const std::vector< T > & q );
126
136template< class T >
137OptimalSearchTree< T > optimalSearchTree( const std::vector< T > & p );
138
139/*--------------------------------------------------------------------------*/
140
141} // end( namespace ADS )
142
143/*--------------------------------------------------------------------------*/
144/*-------------------------- IMPLEMENTATION --------------------------------*/
145/*--------------------------------------------------------------------------*/
146
147#include "ADS/optimization/impl/OptimalSearchTree.tpp"
148
149/*--------------------------------------------------------------------------*/
150
151#endif /* OptimalSearchTree.h included */
152
153/*--------------------------------------------------------------------------*/
154/*---------------------- End File OptimalSearchTree.h ----------------------*/
155/*--------------------------------------------------------------------------*/
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
OptimalSearchTree< T > optimalSearchTree(const std::vector< T > &p, const std::vector< T > &q)
the optimal binary search tree of the keys of weights and of the gaps of weights
Definition ADT.h:96
an optimal binary search tree on the keys : its cost, its root and the children of each key,...
Definition OptimalSearchTree.h:88
T cost
the weighted path length
Definition OptimalSearchTree.h:89
std::vector< int > left
the left child of each key
Definition OptimalSearchTree.h:91
std::vector< int > right
the right child of each key
Definition OptimalSearchTree.h:92
int root
the key at the root
Definition OptimalSearchTree.h:90