please tell me whats wrong with this code/ please fix it ( in C)   #include    #include    #define MAXIMUM 100    #define intial 1    #define waitng 2    #define visiited 3    int n;    int adj[MAXIMUM][MAXIMUM];    int state[MAXIMUM];    void create_Graph();    void breadth_First_Search_Traversal();    void breadth_First_Search(int v);    int que[MAXIMUM], frnt = -1,rearr = -1;    void insert-Queue(int vertex);    int delete_Queue();    int is_Empty_Queue();    int main()    {    create_Graph();    breadth_First_Search_Traversal();    return 0;    }    void breadth_First_Search_Traversal()    {    int h;    for(h=0; h rearr)    return 1;    else    return 0;    }    int delete_Queue()    {    int deleteitem;    if(frnt == -1 || frnt > rearr)    {    printf("Queue Underflow\n");    exit(1);    }    deleteitem = que[frnt];    frnt = frnt+1;    return deleteitem;    }    void create_Graph()    {    int cnt,max_Edge,orgn,destn;    printf("Enter number of vertices : ");    scanf("%d",&n);    max_Edge = n*(n-1);    for(cnt=1; cnt<=max_Edge; cnt++)    {    printf("Enter edge %d( -1 -1 to quit ) : ",cnt);    scanf("%d %d",&orgn,&destn);    if((orgn == -1) && (destn == -1))    break;    if(orgn>=n || destn>=n || orgn<0 || destn<0)    {    printf("Invalid edge!\n");    cnt--;    }    else    {    adj[orgn][destn] = 1;    }    }    }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

please tell me whats wrong with this code/ please fix it ( in C)

 

#include<stdio.h>

   #include<stdlib.h>

   #define MAXIMUM 100

   #define intial 1

   #define waitng 2

   #define visiited 3

   int n;

   int adj[MAXIMUM][MAXIMUM];

   int state[MAXIMUM];

   void create_Graph();

   void breadth_First_Search_Traversal();

   void breadth_First_Search(int v);

   int que[MAXIMUM], frnt = -1,rearr = -1;

   void insert-Queue(int vertex);

   int delete_Queue();

   int is_Empty_Queue();

   int main()

   {

   create_Graph();

   breadth_First_Search_Traversal();

   return 0;

   }

   void breadth_First_Search_Traversal()

   {

   int h;

   for(h=0; h<n; h++)

   state[h] = intial;

   printf("Enter Start Vertex for breadth_First_Search: \n");

   scanf("%d", &h);

   breadth_First_Search(h);

   }

   void breadth_First_Search(int h)

   {

   int i;

   insert-Queue(h);

   state[h] = waitng;

   while(!is_Empty_Queue())

   {

   h= delete_Queue( );

   printf("%d ",h);

   state[h] = visiited;

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

   {

   if(adj[h][i] == 1 && state[i] == intial)

   {

   insert-Queue(i);

   state[i] = waitng;

   }

   }

   }

   printf("\n");

   }

   void insert-Queue(int vertex)

   {

   if(rearr == MAXIMUM-1)

   printf("Queue Overflow\n");

   else

   {

   if(frnt == -1)

   frnt = 0;

   rearr = rearr+1;

   que[rearr] = vertex ;

   }

   }

   int is_Empty_Queue()

   {

   if(frnt == -1 || frnt > rearr)

   return 1;

   else

   return 0;

   }

   int delete_Queue()

   {

   int deleteitem;

   if(frnt == -1 || frnt > rearr)

   {

   printf("Queue Underflow\n");

   exit(1);

   }

   deleteitem = que[frnt];

   frnt = frnt+1;

   return deleteitem;

   }

   void create_Graph()

   {

   int cnt,max_Edge,orgn,destn;

   printf("Enter number of vertices : ");

   scanf("%d",&n);

   max_Edge = n*(n-1);

   for(cnt=1; cnt<=max_Edge; cnt++)

   {

   printf("Enter edge %d( -1 -1 to quit ) : ",cnt);

   scanf("%d %d",&orgn,&destn);

   if((orgn == -1) && (destn == -1))

   break;

   if(orgn>=n || destn>=n || orgn<0 || destn<0)

   {

   printf("Invalid edge!\n");

   cnt--;

   }

   else

   {

   adj[orgn][destn] = 1;

   }

   }

   }

 

 

Expert Solution
steps

Step by step

Solved in 4 steps with 5 images

Blurred answer
Knowledge Booster
Lists
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education