Questions
Please complete following c++ code asap using following prototypes complete each missing part / Linked list...

Please complete following c++ code asap

using following prototypes complete each missing part

/ Linked list operations
int getLength() const {return length;}
void insertNode(College);
bool deleteNode(string);
void displayList() const;
bool searchList(string, College &) const;
};

main.cpp

/*
  Build and procees a sorted linked list of College objects.
The list is sorted in ascending order by the college code.
Assume that the college code is unique.
*/
#include <iostream>
#include <fstream>
#include <string>
#include "LinkedList.h"

using namespace std;

void buildList(const string &filename, LinkedList &list);
void deleteManager(LinkedList &list);
void searchManager(const LinkedList &list);
void displayManager(const LinkedList &list);

int main()
{

string inputFileName = "colleges.txt";
LinkedList list;

buildList(inputFileName, list);
displayManager(list);
searchManager(list);
deleteManager(list);
displayManager(list);
return 0;
}

/*****************************************************************************
This function reads data about colleges from a file and inserts them
into a sorted linked list. The list is sorted in ascending order by code
*****************************************************************************/
void buildList(const string &filename, LinkedList &list)
{
ifstream fin(filename);
cout << "Reading data from \"" << filename << "\"";

if(!fin)
{
cout << "Error opening the input file: \""<< filename << "\"" << endl;
exit(EXIT_FAILURE);
}

int rank, cost;
string code, name;

while(fin >> rank)
{
fin >> code;
fin.ignore(); // to ignore space in front of name
getline(fin, name, ';');
fin >> cost;
// create a College object and initialize it with data from file
College aCollege(rank, code, name, cost);
/* Write your code here: call insertNode */
}

fin.close();
}

/*****************************************************************************
Delete manager: delete items from the list until the user enters Q to quit
deleting
Input Parameter: list
*****************************************************************************/
void deleteManager(LinkedList &list)
{
string targetCode = "";

cout << "\n Delete\n";
cout << "=======\n";

while(targetCode != "Q")
{
cout << endl << "Enter a college code (or Q to stop deleting) : \n";
cin >> targetCode;
cout << endl;

if(targetCode != "Q")
{
if(/* Write your code here: call deleteNode */)
cout << targetCode << " has been deleted!\n";
else
cout << "College \"" << targetCode << "\" was not found in this list." << endl;
}
}
cout << "___________________END DELETE SECTION_____\n";
}

/*****************************************************************************
Search manager: search the list until the user enters Q to quit searching
Input Parameter: list
*****************************************************************************/
void searchManager(const LinkedList &list)
{
string targetCode = "";
College aCollege;

cout << "\n Search\n";
cout << "=======\n";

while(targetCode != "Q")
{
cout << "\nEnter a college code (or Q to stop searching) : \n";
cin >> targetCode;

if(targetCode != "Q")
{
if(/* Write your code here: call searchList */)
aCollege.vDisplay();
else
cout << "College \"" << targetCode << "\" was not found in this list." << endl;
}
}
cout << "___________________END SEARCH SECTION _____\n";
}

/*****************************************************************************
Display manager: diplay a header, formatted list content, and footer,
depending on the user's choice;
displays the number of nodes (always)
Input Parameter: list
*****************************************************************************/
void displayManager(const LinkedList &list)
{
string action;
  
cout << "\nDisplay list [Y/N]? ";
cin >> action;

if(action == "Y" || action == "y")
{
cout << "\n====== ==== ============================= =========\n"
<< " Code Rank Name Cost \n"
<< "====== ==== ============================= =========\n";
  
/* Write your code here: call displayList */
  
cout << "====== ==== ============================= =========\n";
}
cout << "Number of colleges in this list: " << /* Write your code here: call getLength */ endl;
}

In: Computer Science

Hello, I need to divide my code in this different parts. Use a standard approach to...

Hello, I need to divide my code in this different parts.

Use a standard approach to source files in this assignment: a .cpp for each function (you have at least two – main and ageCalc) a header file for the student struct, properly guarded

Code:

#include <iostream>

#include <string>

#include <fstream>

#include <algorithm>

#include <vector>

#include <iomanip>

using namespace std;

#define nullptr NULL

#define MAX_SIZE 100

struct Student

{

    string firstName;

    char middleName;

    string lastName;

    char collegeCode;

    int locCode;

    int seqCode;

    int age;

};

struct sort_by_age

{

    inline bool operator()(const Student *s1, const Student *s2)

    {

        return (s1->age < s2->age);

    }

};

int ageCalc(Student *studs[], Student *&youngest);

int main()

{

    Student *students[MAX_SIZE] = {nullptr};

    ifstream Myfile;

    Myfile.open("a2data.txt");

    if (!Myfile.is_open())

    {

        cout << "Could not open the file!";

        return 1;

    }

    vector<string> words;

    string line;

    while (!Myfile.eof())

    {

        getline(Myfile, line);

        line.c_str();

        int i = 0;

        string word = "";

        while (line[i] != '\0')

        {

            if (line[i] != ' ')

            {

                word = word + line[i];

                i++;

            }

            else

            {

                if (word != "")

                    words.push_back(word);

                word = "";

                i++;

            }

        }

        words.push_back(word);

    }

    Myfile.close();

    int count = 0;

    string fname = words.at(count);

    count++;

    int n = 0;

    while (count < words.size() - 2)

    {

        Student *s = new Student;

        s->firstName = fname;

        string mname = words.at(count);

        s->middleName = mname[0];

        count++;

        s->lastName = words.at(count);

        if (words.at(count).size() >= 12)

        {

            if (words.at(count)[1] >= '0' && words.at(count)[1] <= '9')

            {

                count--;

                s->middleName = ' ';

                s->lastName = words.at(count);

            }

        }

        count++;

        string id = words.at(count);

        count++;

        s->collegeCode = id[0];

        string loc = "";

        loc = loc + id[1];

        loc = loc + id[2];

        s->locCode = stoi(loc);

        string seq = "";

        for (int j = 3; j < 9; j++)

        {

            seq = seq + id[j];

        }

        s->seqCode = stoi(seq);

        string age = "";

        age = age + id[9];

        age = age + id[10];

        age = age + id[11];

        s->age = stoi(age);

        fname = id.erase(0, 12);

        students[n] = s;

        n++;

    }

    words.clear();

    sort(students, students + n, sort_by_age());

    cout << setw(15) << left << "Last Name";

    cout << setw(15) << left << "Midlle Name";

    cout << setw(15) << left << "First Name";

    cout << setw(15) << left << "College Code";

    cout << setw(12) << left << "Location";

    cout << setw(12) << left << "Sequence";

    cout << setw(12) << left << "Age" << endl;

    cout << "=======================================================================================" << endl;

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

    {

        cout << setw(15) << left << students[i]->lastName;

        cout << setw(15) << left << students[i]->middleName;

        cout << setw(20) << left << students[i]->firstName;

        cout << setw(13) << left << students[i]->collegeCode;

        cout << setw(10) << left << students[i]->locCode;

        cout << setw(12) << left << students[i]->seqCode;

        cout << students[i]->age << endl;

    }

    cout << endl;

    Student *youngest = NULL;

    int avg_age = ageCalc(students, youngest);

    cout << "Average age is: " << avg_age << endl;

    cout << "Youngest student is " << youngest->firstName << " " << youngest->middleName << " " << youngest->lastName << endl;

    return 0;

}

int ageCalc(Student *studs[], Student *&youngest)

{

    youngest = studs[0];

    int i = 0;

    int avg_age = 0;

    while (studs[i] != NULL)

    {

        avg_age += studs[i]->age;

        if (youngest->age > studs[i]->age)

            youngest = studs[i];

        i++;

    }

    return avg_age / i;

}

File needed:

https://drive.google.com/file/d/15_CxuGnFdnyIj6zhSC11oSgKEYrosHck/view?usp=sharing

In: Computer Science

Hello, I need to divide my code in this different parts. Use a standard approach to...

Hello, I need to divide my code in this different parts.

Use a standard approach to source files in this assignment: a .cpp for each function (you have at least two – main and ageCalc) a header file for the student struct, properly guarded

Code:

#include <iostream>

#include <string>

#include <fstream>

#include <algorithm>

#include <vector>

#include <iomanip>

using namespace std;

#define nullptr NULL

#define MAX_SIZE 100

struct Student

{

    string firstName;

    char middleName;

    string lastName;

    char collegeCode;

    int locCode;

    int seqCode;

    int age;

};

struct sort_by_age

{

    inline bool operator()(const Student *s1, const Student *s2)

    {

        return (s1->age < s2->age);

    }

};

int ageCalc(Student *studs[], Student *&youngest);

int main()

{

    Student *students[MAX_SIZE] = {nullptr};

    ifstream Myfile;

    Myfile.open("a2data.txt");

    if (!Myfile.is_open())

    {

        cout << "Could not open the file!";

        return 1;

    }

    vector<string> words;

    string line;

    while (!Myfile.eof())

    {

        getline(Myfile, line);

        line.c_str();

        int i = 0;

        string word = "";

        while (line[i] != '\0')

        {

            if (line[i] != ' ')

            {

                word = word + line[i];

                i++;

            }

            else

            {

                if (word != "")

                    words.push_back(word);

                word = "";

                i++;

            }

        }

        words.push_back(word);

    }

    Myfile.close();

    int count = 0;

    string fname = words.at(count);

    count++;

    int n = 0;

    while (count < words.size() - 2)

    {

        Student *s = new Student;

        s->firstName = fname;

        string mname = words.at(count);

        s->middleName = mname[0];

        count++;

        s->lastName = words.at(count);

        if (words.at(count).size() >= 12)

        {

            if (words.at(count)[1] >= '0' && words.at(count)[1] <= '9')

            {

                count--;

                s->middleName = ' ';

                s->lastName = words.at(count);

            }

        }

        count++;

        string id = words.at(count);

        count++;

        s->collegeCode = id[0];

        string loc = "";

        loc = loc + id[1];

        loc = loc + id[2];

        s->locCode = stoi(loc);

        string seq = "";

        for (int j = 3; j < 9; j++)

        {

            seq = seq + id[j];

        }

        s->seqCode = stoi(seq);

        string age = "";

        age = age + id[9];

        age = age + id[10];

        age = age + id[11];

        s->age = stoi(age);

        fname = id.erase(0, 12);

        students[n] = s;

        n++;

    }

    words.clear();

    sort(students, students + n, sort_by_age());

    cout << setw(15) << left << "Last Name";

    cout << setw(15) << left << "Midlle Name";

    cout << setw(15) << left << "First Name";

    cout << setw(15) << left << "College Code";

    cout << setw(12) << left << "Location";

    cout << setw(12) << left << "Sequence";

    cout << setw(12) << left << "Age" << endl;

    cout << "=======================================================================================" << endl;

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

    {

        cout << setw(15) << left << students[i]->lastName;

        cout << setw(15) << left << students[i]->middleName;

        cout << setw(20) << left << students[i]->firstName;

        cout << setw(13) << left << students[i]->collegeCode;

        cout << setw(10) << left << students[i]->locCode;

        cout << setw(12) << left << students[i]->seqCode;

        cout << students[i]->age << endl;

    }

    cout << endl;

    Student *youngest = NULL;

    int avg_age = ageCalc(students, youngest);

    cout << "Average age is: " << avg_age << endl;

    cout << "Youngest student is " << youngest->firstName << " " << youngest->middleName << " " << youngest->lastName << endl;

    return 0;

}

int ageCalc(Student *studs[], Student *&youngest)

{

    youngest = studs[0];

    int i = 0;

    int avg_age = 0;

    while (studs[i] != NULL)

    {

        avg_age += studs[i]->age;

        if (youngest->age > studs[i]->age)

            youngest = studs[i];

        i++;

    }

    return avg_age / i;

}

File needed:

https://drive.google.com/file/d/15_CxuGnFdnyIj6zhSC11oSgKEYrosHck/view?usp=sharing

In: Computer Science

Hello, I need to divide my code in this different parts. Use a standard approach to...

Hello, I need to divide my code in this different parts.

Use a standard approach to source files in this assignment: a .cpp for each function (you have at least two – main and ageCalc) a header file for the student struct, properly guarded

Code:

#include <iostream>

#include <string>

#include <fstream>

#include <algorithm>

#include <vector>

#include <iomanip>

using namespace std;

#define nullptr NULL

#define MAX_SIZE 100

struct Student

{

    string firstName;

    char middleName;

    string lastName;

    char collegeCode;

    int locCode;

    int seqCode;

    int age;

};

struct sort_by_age

{

    inline bool operator()(const Student *s1, const Student *s2)

    {

        return (s1->age < s2->age);

    }

};

int ageCalc(Student *studs[], Student *&youngest);

int main()

{

    Student *students[MAX_SIZE] = {nullptr};

    ifstream Myfile;

    Myfile.open("a2data.txt");

    if (!Myfile.is_open())

    {

        cout << "Could not open the file!";

        return 1;

    }

    vector<string> words;

    string line;

    while (!Myfile.eof())

    {

        getline(Myfile, line);

        line.c_str();

        int i = 0;

        string word = "";

        while (line[i] != '\0')

        {

            if (line[i] != ' ')

            {

                word = word + line[i];

                i++;

            }

            else

            {

                if (word != "")

                    words.push_back(word);

                word = "";

                i++;

            }

        }

        words.push_back(word);

    }

    Myfile.close();

    int count = 0;

    string fname = words.at(count);

    count++;

    int n = 0;

    while (count < words.size() - 2)

    {

        Student *s = new Student;

        s->firstName = fname;

        string mname = words.at(count);

        s->middleName = mname[0];

        count++;

        s->lastName = words.at(count);

        if (words.at(count).size() >= 12)

        {

            if (words.at(count)[1] >= '0' && words.at(count)[1] <= '9')

            {

                count--;

                s->middleName = ' ';

                s->lastName = words.at(count);

            }

        }

        count++;

        string id = words.at(count);

        count++;

        s->collegeCode = id[0];

        string loc = "";

        loc = loc + id[1];

        loc = loc + id[2];

        s->locCode = stoi(loc);

        string seq = "";

        for (int j = 3; j < 9; j++)

        {

            seq = seq + id[j];

        }

        s->seqCode = stoi(seq);

        string age = "";

        age = age + id[9];

        age = age + id[10];

        age = age + id[11];

        s->age = stoi(age);

        fname = id.erase(0, 12);

        students[n] = s;

        n++;

    }

    words.clear();

    sort(students, students + n, sort_by_age());

    cout << setw(15) << left << "Last Name";

    cout << setw(15) << left << "Midlle Name";

    cout << setw(15) << left << "First Name";

    cout << setw(15) << left << "College Code";

    cout << setw(12) << left << "Location";

    cout << setw(12) << left << "Sequence";

    cout << setw(12) << left << "Age" << endl;

    cout << "=======================================================================================" << endl;

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

    {

        cout << setw(15) << left << students[i]->lastName;

        cout << setw(15) << left << students[i]->middleName;

        cout << setw(20) << left << students[i]->firstName;

        cout << setw(13) << left << students[i]->collegeCode;

        cout << setw(10) << left << students[i]->locCode;

        cout << setw(12) << left << students[i]->seqCode;

        cout << students[i]->age << endl;

    }

    cout << endl;

    Student *youngest = NULL;

    int avg_age = ageCalc(students, youngest);

    cout << "Average age is: " << avg_age << endl;

    cout << "Youngest student is " << youngest->firstName << " " << youngest->middleName << " " << youngest->lastName << endl;

    return 0;

}

int ageCalc(Student *studs[], Student *&youngest)

{

    youngest = studs[0];

    int i = 0;

    int avg_age = 0;

    while (studs[i] != NULL)

    {

        avg_age += studs[i]->age;

        if (youngest->age > studs[i]->age)

            youngest = studs[i];

        i++;

    }

    return avg_age / i;

}

File needed:

https://drive.google.com/file/d/15_CxuGnFdnyIj6zhSC11oSgKEYrosHck/view?usp=sharing

In: Computer Science

Hello, I need to divide my code in this different parts. Use a standard approach to...

Hello, I need to divide my code in this different parts.

Use a standard approach to source files in this assignment: a .cpp for each function (you have at least two – main and ageCalc) a header file for the student struct, properly guarded

Code:

#include <iostream>

#include <string>

#include <fstream>

#include <algorithm>

#include <vector>

#include <iomanip>

using namespace std;

#define nullptr NULL

#define MAX_SIZE 100

struct Student

{

    string firstName;

    char middleName;

    string lastName;

    char collegeCode;

    int locCode;

    int seqCode;

    int age;

};

struct sort_by_age

{

    inline bool operator()(const Student *s1, const Student *s2)

    {

        return (s1->age < s2->age);

    }

};

int ageCalc(Student *studs[], Student *&youngest);

int main()

{

    Student *students[MAX_SIZE] = {nullptr};

    ifstream Myfile;

    Myfile.open("a2data.txt");

    if (!Myfile.is_open())

    {

        cout << "Could not open the file!";

        return 1;

    }

    vector<string> words;

    string line;

    while (!Myfile.eof())

    {

        getline(Myfile, line);

        line.c_str();

        int i = 0;

        string word = "";

        while (line[i] != '\0')

        {

            if (line[i] != ' ')

            {

                word = word + line[i];

                i++;

            }

            else

            {

                if (word != "")

                    words.push_back(word);

                word = "";

                i++;

            }

        }

        words.push_back(word);

    }

    Myfile.close();

    int count = 0;

    string fname = words.at(count);

    count++;

    int n = 0;

    while (count < words.size() - 2)

    {

        Student *s = new Student;

        s->firstName = fname;

        string mname = words.at(count);

        s->middleName = mname[0];

        count++;

        s->lastName = words.at(count);

        if (words.at(count).size() >= 12)

        {

            if (words.at(count)[1] >= '0' && words.at(count)[1] <= '9')

            {

                count--;

                s->middleName = ' ';

                s->lastName = words.at(count);

            }

        }

        count++;

        string id = words.at(count);

        count++;

        s->collegeCode = id[0];

        string loc = "";

        loc = loc + id[1];

        loc = loc + id[2];

        s->locCode = stoi(loc);

        string seq = "";

        for (int j = 3; j < 9; j++)

        {

            seq = seq + id[j];

        }

        s->seqCode = stoi(seq);

        string age = "";

        age = age + id[9];

        age = age + id[10];

        age = age + id[11];

        s->age = stoi(age);

        fname = id.erase(0, 12);

        students[n] = s;

        n++;

    }

    words.clear();

    sort(students, students + n, sort_by_age());

    cout << setw(15) << left << "Last Name";

    cout << setw(15) << left << "Midlle Name";

    cout << setw(15) << left << "First Name";

    cout << setw(15) << left << "College Code";

    cout << setw(12) << left << "Location";

    cout << setw(12) << left << "Sequence";

    cout << setw(12) << left << "Age" << endl;

    cout << "=======================================================================================" << endl;

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

    {

        cout << setw(15) << left << students[i]->lastName;

        cout << setw(15) << left << students[i]->middleName;

        cout << setw(20) << left << students[i]->firstName;

        cout << setw(13) << left << students[i]->collegeCode;

        cout << setw(10) << left << students[i]->locCode;

        cout << setw(12) << left << students[i]->seqCode;

        cout << students[i]->age << endl;

    }

    cout << endl;

    Student *youngest = NULL;

    int avg_age = ageCalc(students, youngest);

    cout << "Average age is: " << avg_age << endl;

    cout << "Youngest student is " << youngest->firstName << " " << youngest->middleName << " " << youngest->lastName << endl;

    return 0;

}

int ageCalc(Student *studs[], Student *&youngest)

{

    youngest = studs[0];

    int i = 0;

    int avg_age = 0;

    while (studs[i] != NULL)

    {

        avg_age += studs[i]->age;

        if (youngest->age > studs[i]->age)

            youngest = studs[i];

        i++;

    }

    return avg_age / i;

}

File needed:

https://drive.google.com/file/d/15_CxuGnFdnyIj6zhSC11oSgKEYrosHck/view?usp=sharing

In: Computer Science

Python Problem Problem 1: In this problem you are asked to write a Python program to...

Python Problem

Problem 1:

In this problem you are asked to write a Python program to find the greatest and smallest elements in the list.

The user gives the size of the list and its elements (positive and negative integers) as the input.

Sample Output:

Enter size of the list: 7

Enter element: 2

Enter element: 3

Enter element: 4

Enter element: 6

Enter element: 8

Enter element: 10

Enter element: 12

Greatest element in the list is: 12

Smallest element in the list is: 2

Hit enter to end program

------------------------------------------------------------------------------------------

Problem 2:

In this problem you are asked to write a Python program you are asked to perform multiple operations on a list.

What you need to do:

  1. Ask the user what is the length of the list.

  2. Ask the user to enter string values into a list.

  3. Print the first 4 and last 4 elements in the list.

  4. Ask the user if he/ she wants to insert elements to the list or delete the elements from the list.

  5. Repeat step 4 until the user chooses a ‘NO’.

Sample Output:

Enter size of list: 5
Enter a string value: john Enter a string value: mary

Enter a string value: steve

Enter a string value: julia

Enter a string value: jake

The elements in the list:
['john', 'mary', 'steve', 'julia', 'jake']

The first four elements in the list: ['john', 'mary', 'steve', 'julia']

The last four elements in the list: ['mary', 'steve', 'julia', 'jake']

Want to insert (i) or delete (d) elements in the list: i Enter the position to insert: 5
Enter the value to insert: lara

The modified list:
['john', 'mary', 'steve', 'julia', 'jake', 'lara']

Want to insert or delete more elements (y/n): y

Want to insert (i) or delete (d) elements in the list: i Enter the position to insert: 2
Enter the value to insert: Jacob

The modified list:
['john', 'mary', 'jacob', 'steve', 'julia', 'jake', 'lara']

Want to insert or delete more elements (y/n): y

Want to insert (i) or delete (d) elements in the list: d Enter the index of the value to be deleted: 4

The modified list:
['john', 'mary', 'jacob', 'steve', 'jake', 'lara']

Want to insert or delete more elements (y/n): n

Hit enter to end program

In: Computer Science

In this assignment we are not allowed to make changes to Graph.h it cannot be changed!...

In this assignment we are not allowed to make changes to Graph.h it cannot be changed! I need help with the Graph.cpp and the Driver.cpp.

Your assignment is to implement a sparse adjacency matrix data structure Graph that is defined in the header file Graph.h. The Graph class provides two iterators. One iterator produces the neighbors for a given vertex. The second iterator produces each edge of the graph once.

Additionally, you must implement a test program that fully exercises your implementation of the Graph member functions. Place this program in the main() function in a file named Driver.cpp.

The purpose of an iterator is to provide programmers a uniform way to iterate through all items of a data structure using a forloop. For example, using the Graph class, we can iterate thru the neighbors of vertex 4 using:

Graph::NbIterator nit ; for (nit = G.nbBegin(4); nit != G.nbEnd(4) ; nit++) { cout << *nit << " " ; } cout << endl ;

The idea is that nit (for neighbor iterator) starts at the beginning of the data for vertex 4 in nz and is advanced to the next neighbor by the ++ operator. The for loop continues as long as we have not reached the end of the data for vertex 4. We check this by comparing against a special iterator for the end, nbEnd(4). This requires the NbIterator class to implement the ++, !=and * (dereference) operators.

Similarly, the Graph class allows us to iterate through all edges of a graph using a for loop like:

Graph::EgIterator eit ; tuple<int,int,int> edge ; for (eit = G.egBegin() ; eit != G.egEnd() ; eit++) { edge = *eit ; // get current edge cout << "(" << get<0>(edge) << ", " << get<1>(edge) << ", " << get<2>(edge) << ") " ; } cout << endl ;

Note that each edge should be printed only once, even though it is represented twice in the sparse adjacency matrix data structure.

Since a program may use many data structures and each data structure might provide one or more iterators, it is common to make the iterator class for a data structure an inner class. Thus, in the code fragments above, nit and eit are declared asGraph::NbIterator and Graph::EgIterator objects, not just NbIterator and EgIterator objects.

Here are the specifics of the assignment, including a description for what each member function must accomplish.

Requirement: your implementation must dynamically resize the m_nz and m_ci arrays. See the descriptions of Graph(constructor) and addEdge, below.

Requirement: other than the templated tuple class, you must not use any classes from the Standard Template Library or other sources, including vector and list. All of the data structure must be implemented by your own code.

Requirement: your code must compile with the original Graph.h header file. You are not allowed to make any changes to this file. Yes, this prevents you from having useful helper functions. This is a deliberate limitation of this project. You may have to duplicate some code.

Requirement: a program fragment with a for loop that uses your NbIterator must have worst case running time that is proportional to the number of neighbors of the given vertex.

Requirement: a program fragment with a for loop that uses your EgIterator must have worst case running time that is proportional to the number of vertices in the graph plus the number of edges in the graph.

Graph.h:

#ifndef _GRAPH_H_
#define _GRAPH_H_

#include <stdexcept>  // for throwing out_of_range exceptions
#include <tuple>      // for tuple template

class Graph {

public:

  // Graph constructor; must give number of vertices
  Graph(int n);

  // Graph copy constructor
  Graph(const Graph& G);

  // Graph destructor
  ~Graph();

  // Graph assignment operator
  const Graph& operator= (const Graph& rhs);

  // return number of vertices
  int numVert();

  // return number of edges
  int numEdge();

  // add edge between u and v with weight x
  void addEdge(int u, int v, int x);

  // print out data structure for debugging
  void dump();

  // Edge Iterator inner class
  class EgIterator {

  public: 
    // Edge Iterator constructor; indx can be used to
    // set m_indx for begin and end iterators.
    EgIterator(Graph *Gptr = nullptr, int indx = 0);

    // Compare iterators; only makes sense to compare with
    // end iterator
    bool operator!= (const EgIterator& rhs);
         
    // Move iterator to next printable edge
    void operator++(int dummy);   // post increment

    // return edge at iterator location
    std::tuple<int,int,int> operator*();

  private:
    Graph *m_Gptr;    // pointer to associated Graph
    int m_indx;       // index of current edge in m_nz
    int m_row;        // corresponding row of m_nz[m_indx]
  };

  // Make an initial edge Iterator
  EgIterator egBegin();

  // Make an end iterator for edge iterator
  EgIterator egEnd();

  // Neighbor Iterator inner class
  class NbIterator {
    
  public: 
    // Constructor for iterator for vertices adjacent to vertex v;
    // indx can be used to set m_indx for begin and end iterators
    NbIterator(Graph *Gptr = nullptr, int v = 0, int indx = 0);

    // Compare iterators; only makes sense to compare with
    // end iterator
    bool operator!=(const NbIterator& rhs);

    // Move iterator to next neighbor
    void operator++(int dummy);

    // Return neighbor at current iterator position
    int operator*();

  private:
    Graph *m_Gptr;  // pointer to the associated Graph
    int m_row;      // row (source) for which to find neighbors
    int m_indx;     // current index into m_nz of Graph
  };

  // Make an initial neighbor iterator
  NbIterator nbBegin(int v);

  // Make an end neighbor iterator
  NbIterator nbEnd(int v);

private:

  int *m_nz;  // non-zero elements array
  int *m_re;  // row extent array
  int *m_ci;  // column index array
  int m_cap;  // capacity of m_nz and m_ci

  int m_numVert;  // number of vertices
  int m_numEdge;  // number of edges

};
#endif

Graph.cpp outline:

#include "Graph.h"

Graph::Graph(int n) {
}

Graph::Graph(const Graph& G) {
}

Graph::~Graph() {
}

const Graph& Graph::operator= (const Graph& rhs) {
  
}
// This Function will return the number of vertices in the graph
int Graph::numVert() {
  
}

int Graph::numEdge() {
  
}

void Graph::addEdge(int u, int v, int x) {
  
}

void Graph::dump() {
  
}

Graph::EgIterator::EgIterator(Graph *Gptr = nullptr, int index = 0) {
  
}

bool Graph::EgIterator::operator!= (const EgIterator& rhs) {
  
}

void Graph::EgIterator::operator ++(int dummy) {
  
}

std::tuple<int, int, int> Graph::EgIterator::operator *() {
  
}

Graph::EgIterator Graph::egBegin() {
  
}

Graph::EgIterator Graph::egEnd() {
  
}

Graph::NbIterator::NbIterator(Graph *Gptr = nullptr, int v = 0, int indx = 0) {
  
}

bool Graph::NbIterator::operator !=(const NbIterator& rhs) {
  
}

void Graph::NbIterator::operator ++(int dummy) {
  
}

int Graph::NbIterator::operator *() {
  
}

Graph::NbIterator Graph::nbBegin(int v) {
  
}

Graph::NbIterator Graph::nbEnd(int v) {
  
}

In: Computer Science

The demand for subassembly S is 100 units in week 7. Each unit of S requires...

The demand for subassembly S is 100 units in week 7. Each unit of S requires 1 unit of T and 2 units of U. Each unit of T requires 1 unit of V, 2 units of W, and 1 unit of X. Finally, each unit of U requires 2 units of Y and 3 units of Z. One firm manufactures all items. It takes 2 weeks to make S, 1 week to make T, 2 weeks to make U, 2 weeks to make V, 3 weeks to make W, 1 week to make X, 2 weeks to make Y, and 1 week to make Z.

On-hand inventory information is given as below:

ITEM

ON-HAND INVENTORY

ITEM

ON-HAND INVENTORY

S

20

W

30

T

20

X

25

U

40

Y

240

V

30

Z

40

  1. Construct a product structure. Identify all levels, parents, and components.
  2. Construct a net material requirements plan (Hint. Use on-hand inventory table for this question)

In: Other

a) Mario Barnotoli wants to buy designer furniture from Poland for his mansion in Roma, Italy....

a) Mario Barnotoli wants to buy designer furniture from Poland for his mansion in Roma, Italy. Current spot rate is PLN 4.2555/EUR and the price for each set of designer furniture is PLN30,000. The annual inflation over the coming year for Poland and Italy are expected to be 6.5% and 2.5% per annum respectively. Assume purchasing power parity holds. How much EUR would Mario needs if he intends to purchase three sets of Polish designer furniture one year from now?

b) S. Krisnamoorthy is planning to purchase his dream motorcycle, a Harley V-twin next year. The Harley V-twin is currently selling at USD 12,500 in United States. However, S.Krisnamoorthy can directly purchase his dream motorcycle in MYR from Harley Davidson of Kuala Lumpur. The current spot rate is MYR4.200/USD and the current inflation rate in United States is 2% whilst in Malaysia is 5%. Assuming 60% complete pass through, what will the price of Harley V-twin be in MYR one year from now?

In: Accounting

Please assist with the following question: 5. A simple linear regression equation relates V and S...

Please assist with the following question:

5.

A simple linear regression equation relates V and S as follows:

V = a + b*S   

The linear regression in problem 1 is estimated using 62 observations on V and S. The least-squares estimate of b is –21.749, and the standard error of the estimate is 9.10. Perform a t-test for statistical significance at the 5 percent level of significance

a. There are ______degrees of freedom for the t-test.

b. The value of the t-statistic is ______. The critical t-value for the test is ______.

c. Is statistically significant? Explain.

d. The p-value for the t-statistic is ______. (Hint: In this problem, the t-table provides the answer.) The p-value gives the probability of rejecting the hypothesis that ______(b = 0, b > 0, b < 0) when b is truly equal to ______. The confidence level for the test is ______ percent.

e. What does it mean to say is statistically significant at the 5 percent significance level?

f. What does it mean to say is statistically significant at the 95 percent confidence level?

g. Explain the difference between the level of confidence differ from the level of significance?

In: Statistics and Probability