<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>optimal binary search tree | Student Projects</title>
	<atom:link href="https://studentprojects.in/tag/optimal-binary-search-tree/feed/" rel="self" type="application/rss+xml" />
	<link>https://studentprojects.in</link>
	<description>Microcontroller projects, Circuit Diagrams, Project Ideas</description>
	<lastBuildDate>Thu, 11 Mar 2010 17:39:44 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.7</generator>
	<item>
		<title>C++ program that uses dynamic programming algorithm to solve the optimal binary search tree problem</title>
		<link>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-that-uses-dynamic-programming-algorithm-to-solve-the-optimal-binary-search-tree-problem/</link>
					<comments>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-that-uses-dynamic-programming-algorithm-to-solve-the-optimal-binary-search-tree-problem/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Thu, 11 Mar 2010 17:39:44 +0000</pubDate>
				<category><![CDATA[Data structure]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[C Programs]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[binary tree]]></category>
		<category><![CDATA[optimal binary search tree]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=1042</guid>

					<description><![CDATA[<p>/* Write a C++ program that uses dynamic programming algorithm to solve the optimal binary search tree problem */ #include #include #include using namespace std; #define MAX 10 int find(int i,int j); void print(int,int); int p[MAX],q[MAX],w[10][10],c[10][10],r[10][10],i,j,k,n,m; char idnt[7][10]; main() { cout >n; cout</p>
<p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-that-uses-dynamic-programming-algorithm-to-solve-the-optimal-binary-search-tree-problem/">C++ program that uses dynamic programming algorithm to solve the optimal binary search tree problem</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>/* Write a C++ program that uses dynamic programming algorithm to solve the optimal binary search tree problem */</p>
<pre lang="cpp">
#include<iostream>
#include<conio.h>
#include<stdio.h>
using namespace std;
#define MAX 10
int find(int i,int j);
void print(int,int);
int p[MAX],q[MAX],w[10][10],c[10][10],r[10][10],i,j,k,n,m;
char idnt[7][10];

main()
{
	cout << "enter the no, of identifiers";
	cin >>n;
	cout <<"enter identifiers";
	for(i=1;i<=n;i++)
	gets(idnt[i]);
	cout <<"enter success propability for identifiers";
	for(i=1;i<=n;i++)
		cin >>p[i];
	cout << "enter failure propability for identifiers";
	for(i=0;i<=n;i++)
		cin >> q[i];
	for(i=0;i<=n;i++)
	{
		w[i][i]=q[i];
		c[i][i]=r[i][i]=0;
		w[i][i+1]=q[i]+q[i+1]+p[i+1];
		r[i][i+1]=i+1;
		c[i][i+1]=q[i]+q[i+1]+p[i+1];
	}
	w[n][n]=q[n];
	r[n][n]=c[n][n]=0;
	for(m=2;m<=n;m++)
	{
		for(i=0;i<=n-m;i++)
		{
		     j=i+m;
		     w[i][j]=w[i][j-1]+p[j]+q[j];
		     k=find(i,j);
		     r[i][j]=k;
		     c[i][j]=w[i][j]+c[i][k-1]+c[k][j];
		}
	}
       cout <<"\n";
       print(0,n); }

int find(int i,int j)
{
int min=2000,m,l;
for(m=i+1;m<=j;m++)
if(c[i][m-1]+c[m][j]<min)
{
min=c[i][m-1]+c[m][j];
l=m;
}
return l;
}
void print(int i,int j)
{
if(i<j)
puts(idnt[r[i][j]]);
else
return;
print(i,r[i][j]-1);
print(r[i][j],j);
}
</pre>
<p><strong>OUTPUT</strong></p>
<p>enter the no, of identifiers4<br />
enter identifiers<br />
do<br />
if<br />
int<br />
while<br />
enter success propability for identifiers3 3 1 1<br />
enter failure propability for identifiers2 3 1 1 1</p>
<p>tree in preorder form<br />
if<br />
do<br />
int<br />
while</p><p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-that-uses-dynamic-programming-algorithm-to-solve-the-optimal-binary-search-tree-problem/">C++ program that uses dynamic programming algorithm to solve the optimal binary search tree problem</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-that-uses-dynamic-programming-algorithm-to-solve-the-optimal-binary-search-tree-problem/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
	</channel>
</rss>
