sivaramaiah  
 
  Broadcasting 04/26/2024 4:06am (UTC)
   
 

/* PROGRAM TO IMPLEMENT BROADCAST ROUTING ALGORITHM*/

#include<stdio.h>

int a[10][10],n;

main()

{

  int i,j,root;

  clrscr();

  printf("Enter no.of nodes:");

  scanf("%d",&n);

  printf("Enter adjacent matrix\n");

  for(i=1;i<=n;i++)

    for(j=1;j<=n;j++)

    {

      printf("Enter connecting of %d-->%d::",i,j);

      scanf("%d",&a[i][j]);

    }

  printf("Enter root node:");

  scanf("%d",&root);

  adj(root);

}

adj(int k)

{

  int i,j;

  printf("Adjacent node of root node::\n");

  printf("%d\n\n",k);

  for(j=1;j<=n;j++)

  {

    if(a[k][j]==1 || a[j][k]==1)

      printf("%d\t",j);

  }

  printf("\n");

  for(i=1;i<=n;i++)

  {

    if((a[k][j]==0) && (a[i][k]==0) && (i!=k))

      printf("%d",i);

  }

}

 

OUTPUT

 

Enter no.of nodes:5

Enter adjacent matrix

Enter connecting of 1-->1::0

Enter connecting of 1-->2::1

Enter connecting of 1-->3::1

Enter connecting of 1-->4::0

Enter connecting of 1-->5::0

Enter connecting of 2-->1::1

Enter connecting of 2-->2::0

Enter connecting of 2-->3::1

Enter connecting of 2-->4::1

Enter connecting of 2-->5::0

Enter connecting of 3-->1::1

Enter connecting of 3-->2::1

Enter connecting of 3-->3::0

Enter connecting of 3-->4::0

Enter connecting of 3-->5::0

Enter connecting of 4-->1::0

Enter connecting of 4-->2::1

Enter connecting of 4-->3::0

Enter connecting of 4-->4::0

Enter connecting of 4-->5::1

Enter connecting of 5-->1::0

Enter connecting of 5-->2::0

Enter connecting of 5-->3::0

Enter connecting of 5-->4::1

Enter connecting of 5-->5::0

Enter root node:2

Adjacent node of root node::

2

 

1       3       4

5

 
  Menu Items
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

  add
HOT TOPICS
MCA PROJECT DETAILS ------------------------------------- Jntu all Lab manuals ------------------------------------- Jntu Syllabus Books ------------------------------------- Paper presentations ------------------------------------- Seminars ------------------------------------- Campus Papers ------------------------------------- Competetive Exams GATE ------------------------------------- GRE ------------------------------------- TOEFL ------------------------------------- IELTS ------------------------------------- CAT ------------------------------------- GMAT ------------------------------------- Templates ------------------------------------- Students Resume Preparation tips ------------------------------------- Job zone(Interview questions) ------------------------------------- Google Adsence html code ------------------------------------- Web sites --------x--------------x-----------
  Advertisement

 


-----------------------------
  Offline Messages
  Adds
  Visitors Information
Today, there have been 119886 visitors (281813 hits) on this page!
-------------------------------------------------- This website was created for free with Own-Free-Website.com. Would you also like to have your own website?
Sign up for free