I need a decision making application based on tree above. You can use any progra
ID: 3781249 • Letter: I
Question
I need a decision making application based on tree above. You can use any programming language. I just need you to provide me codes, screenshot of user interface and information about which tree generation technique you used.
1) Application should have simple user interface showing leaf nodes such as 14,15,16,17,18,19,20,21,22 to be selected
2) User selects any of these values and system provides solution chain of how to get selected result.
3) System should select best chain order according to recalculated object and decision tag values (like 0.9, 0.8, 0.7)
Note: PLEASE If you do not know how to program the system, Do not answer this question without codes for the system above!!
0.9 2 0,8 0.9 14 15 16 0.9 0.7 0.8 0.9 0.9 10 0.7 0.9 0.8 0.9 0.8- 17 18 19 12 0.7Explanation / Answer
this is the reverse of the shortest path problem..
in the shortest path problem you find the path between two nodes with the minimum weight (priority value = weight of an edge) , whereas here we have to find the path with the highest weight!
so , it thee user chooses the node 14 then you get the path with max weight of all edges as the answer ..
so for 14 , we start from root 1 , 0.9 to 2 then 0.9 to 5 then 0.9 to 14.
--------------------
let me explain the shortest path algorithm first -
1) crete an array that keeps track of vertices included in shortest path tree, i.e., whose minimum distance from source is calculated and finalized. we wiill initialize it to 0 .
2) initalize all distances to infinity and root node to 0 .
3) while the array created does not include all the nodes do -
i) inlcude the node which has the min value of all the neighbours .
ii) iterate through all adjacent vertices. For every adjacent node v, if sum of distance value of u (from source) and weight of edge u-v, is less than the distance value of v, then update the distance value of v.
in this algorithm, all we need to do is chnge min to max and we will have our answer!
---------------
#include "stdio.h"
#include <conio.h>
#define MAX_NODE 50
using namespace std;
struct fringe_node{
int vertex;
fringe_node *next;
};
struct node{
int vertex;
int weight; //priority value
node *next;
};
node *adj[MAX_NODE]; //For storing Adjacency list of nodes.int totNodes; //No. of Nodes in Graph.constint UNSEEN=1,FRINGE=2,INTREE=3; //status of node.int status[MAX_NODE];//status arr for maintaing status.
fringe_node *fringe_list;//singly link listvoid createGraph(){
node *newl,*last;
int neighbours;
printf("Decision Tree creation ");
printf("Enter total nodes in graph : ");
scanf("%d",totNodes);
for(int i=1;i<=totNodes;i++){
last=NULL;
printf("Total Neighbours of %d : ",i);
scanf("neighbours");
for(int j=1;j<=neighbours;j++){
newl=new node;
printf("Neighbour # %d :",j);
scanf("%d",newl->vertex);
printf("Weight # %d : ",j);
scanf("%d",newl->weight);
newl->next=NULL;
if(adj[i]==NULL)
adj[i]=last=newl;
else{
last->next = newl;
last = newl;
}
}
}
}
//Insert node in a fring_list at Begining.void Insert_Beg(int item){
fringe_node *newl;
newl = new fringe_node;
newl->vertex = item;
newl->next = NULL;
newl->next = fringe_list;
fringe_list = newl;
}
//Delete element at pos position from fringe_list.void del(int pos){
//to points to previous node from where//to insertint i;
fringe_node *tmp,*delnode;
for(i=1,tmp=fringe_list; i < (pos-1); tmp=tmp->next,i++);
delnode = tmp->next;
tmp->next = tmp->next->next;
delete(delnode);
}
void print_path(int s,int d,int parent[]){
if(d==s)
printf(" %d",s);
else{
print_path(s,parent[d],parent);
printf("---->%d",d);
}
}
void shortestPath(){
int i,x,parent[MAX_NODE],edge_count,w,wt,v;
int min_dist,y,dist[MAX_NODE],stuck;
int source,destination;
node *ptr1;
fringe_node *ptr2;
//source node is always 1 i,e root
printf("Enter Destination Node : ");
scanf("%d",destination);
fringe_list=NULL;
for(i=1;i<=totNodes;i++){
status[i]=UNSEEN;
parent[i]=0;
}
status[1]=INTREE;
dist[1]=0;
x=1;
stuck=0;
while( (x != destination) && (!stuck))
{
ptr1=adj[x];
while(ptr1!=NULL){
y=ptr1->vertex;
wt=ptr1->weight;
if((status[y]==FRINGE) && (dist[x]+wt < dist[y]))
{
parent[y]=x;
dist[y] = dist[y] + wt;
}
elseif(status[y]==UNSEEN){
status[y]=FRINGE;
parent[y]=x;
dist[y] = dist[y] + wt;
Insert_Beg(y);
}
ptr1=ptr1->next;
}
if(fringe_list==NULL)
stuck=1;
else{
x=fringe_list->vertex;
min_dist=dist[x];
ptr2=fringe_list->next;
while(ptr2!=NULL){
w=ptr2->vertex;
if(dist[w] > min_dist)
{
x=w;
min_dist=dist[w];
}
ptr2=ptr2->next;
}
del(x);
status[x]=INTREE;
}
}
if(parent[destination]==0)
//no path possible
else
{
printf(" Highest Priority Path ");
print_path(source,destination,parent);
}
}
void main(){
clrscr();
printf("Add a priority graph");
createGraph();
printf(" ===Max Priority Path for the node=== ");
shortestPath();
getch();
}
//we have simply used the shortest path algoritm to find the most weighted path in the place of the least weight
//and then added a user interface as required.
-------------------------
thank you
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.