ADS
Algorithms and Data Structures
Toggle main menu visibility
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
80
namespace
ADS
81
{
82
86
template
<
class
T >
87
struct
OptimalSearchTree
88
{
89
T
cost
;
90
int
root
;
91
std::vector< int >
left
;
92
std::vector< int >
right
;
93
};
94
123
template
<
class
T >
124
OptimalSearchTree< T >
optimalSearchTree
(
const
std::vector< T > & p ,
125
const
std::vector< T > & q );
126
136
template
<
class
T >
137
OptimalSearchTree< 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
/*--------------------------------------------------------------------------*/
Contract.h
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
ADS::optimalSearchTree
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
ADS
Definition
ADT.h:96
ADS::OptimalSearchTree
an optimal binary search tree on the keys : its cost, its root and the children of each key,...
Definition
OptimalSearchTree.h:88
ADS::OptimalSearchTree::cost
T cost
the weighted path length
Definition
OptimalSearchTree.h:89
ADS::OptimalSearchTree::left
std::vector< int > left
the left child of each key
Definition
OptimalSearchTree.h:91
ADS::OptimalSearchTree::right
std::vector< int > right
the right child of each key
Definition
OptimalSearchTree.h:92
ADS::OptimalSearchTree::root
int root
the key at the root
Definition
OptimalSearchTree.h:90
ADS
optimization
OptimalSearchTree.h
Generated by
1.17.0