Equivalent Serial Schedule of Conflict Serializable Schedule in DBMS

#include
using namespace std;
  
class PrecedenceGraph {
  
    
    int V;
  
    
    
    vector* adj;
  
    
    vector serialSchedule;
  
    
    void computeIndegree(int* indegree);
    int findZeroIndegree(int* indegree,
                         bool* visited);
  
public:
    
    PrecedenceGraph(int V);
  
    
    void addEdge(int v, int w);
    void topologicalSort();
    void printSchedule();
};
  

PrecedenceGraph::PrecedenceGraph(int V)
{
    this->V = V;
    adj = new vector[V];
}
  

void PrecedenceGraph::addEdge(int v,
                              int w)
{
    adj[v].push_back(w);
}
  

void PrecedenceGraph::computeIndegree(
    int* indegree)
{
    for (int i = 1; i < V; i++) {                              for (int j = 0;              j < adj[i].size(); j++) {             int node = adj[i][j];                                          indegree[node]++;         }     } }    int PrecedenceGraph::findZeroIndegree(     int* indegree, bool* visited) {     for (int i = 1; i < V; i++) {                              if (!visited[i]             && indegree[i] == 0) {                             visited[i] = true;                             return i;         }     }             return -1; }    void PrecedenceGraph::topologicalSort() {               bool* visited = new bool[V]();                  int* indegree = new int[V]();        computeIndegree(indegree);                  int node = findZeroIndegree(         indegree, visited);        bool nodeAvailable = false;        if (node != -1) {         nodeAvailable = true;     }     while (nodeAvailable) {                     serialSchedule.push_back(node);            for (int i = 0;              i < adj[node].size(); i++) {                                          indegree[adj[node][i]]--;         }                     node = findZeroIndegree(indegree,                                 visited);            if (node == -1) {                                          nodeAvailable = false;         }     } }    void PrecedenceGraph::printSchedule() {     for (int i : serialSchedule) {         cout