Questions: 11 448

Answers by our Experts: 10 707

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

Implement the following algorithm for finding the Minimum Spanning Tree in an undirected weighted graph. You must implement the disjoint set yourself. You must take input from the user.

MST-KRUSKAL(G,w):
A = ∅
For each vertex v ∈ G.V:
    MAKE-SET(v)
sort the edges of G,E into non decreasing order by weight w
For each edge (u, v) ∈ G.E taken in nondecreasing order by weight 
    if FIND-SET(u) ≠ FIND-SET(v):       
    A = A ∪ {(u, v)}
    UNION(u, v)
return A

sample input

V

E

u v weight(u,v)

6

9

0 1 4

1 2 5

0 3 10

1 3 3

1 5 6

1 4 7

2 4 1

3 5 9

4 5 8

Sample output:

MST

2 - 4

1 - 3

0 - 1

1 - 2

1 - 5

Weight:1+3+4+5+6 = 19

sample input:

4

5

0 1 10

0 2 6

0 3 5

1 3 15

2 3 4

sample output

MST

2 – 3

0 – 3

0 – 1

Weight: 4+5+10 = 19


specify a class item having data members item number and item cost also specify two member function getdata() and putdata() create object of item class and called the function


Spspecify a class item having data members item number and item cost also specify two member function getdata() and putdata() create object of item class and called the function


INTELLIGENCENODE CONSULTING PRIVATE LIMITED

Write a C++ Program in which Create a class called 'Matrix' containing constructor that initializes the number of rows and the number of columns of a new Matrix object. The Matrix class has the following information: 1 - number of rows of matrix 2 - number of columns of matrix 3 - elements of matrix (You can use 2D vector) The Matrix class has functions for each of the following: 1 - get the number of rows 2 - get the number of columns 3 - set the elements of the matrix at a given position (i,j) 4 - adding two matrices. 5 - multiplying the two matrices You can assume that the dimensions are correct for the multiplication and addition

Design a class named Record that includes

· A data member named rollNo for student roll number

· Two data fields i.e. course1Name and course2Name of type string

· A parameterized constructor to initialize rollNo, course1Name, and course2Name data fields

· Three getter functions to get the value of rollNo, course1Name, and course2Name, respectively

Derive a class named CourseRecord inherited from Record class and contains

· Two additional data members i.e. marksCourse1 and marksCourse2

· A parameterized constructor to initialize its own data fields along with the inherited data fields

· Two getter functions that return the value of marksCourse1 and marksCourse2, respectively

Derive a class named CourseResult inherited from class CourseRecord and has

· A data field named totalMarks

· A function named marksObtained that returns totalMarks (i.e. marksCourse1 + marksCourse2) of a student.



  1. How many “bugs” do you see in this C++ code? Give an enumerated list of the errors that you spot in the program, including why you think there is something wrong with it, and how you would fix it.


#include <iostream>

using namespace std

int main(); 

int test1;

int test2;

int test3;

float av;

test1=1;

test2=2;

ave=(test+test2+test3)/2;

cout<<”The average is <<ave; 

return 0;




A c++ program that analyzes a set of numbers can be very useful. Create an Analysis application that prompts the user for numbers in the range 1 through 50, terminated by a sentinel, and then performs the following analysis on the numbers:

• Determine the average number

• Determine the maximum number

• Determine the range (maximum – minimum)

• Determine the median (the number that occurs the most often)




Write a program that declare an array of size 25 consisting of students’ test scores in the range 0–200. The user may input any score in the array. It should then determine the number of students having scores in each of the following ranges: 0–24, 25–49, 50–74, 75–99, 100–124, 125–149, 150–174, and 175–200. Output the score ranges and the number of students. (Run your program with the following input data: 76, 89, 150, 135, 200, 76, 12, 100, 150, 28, 178, 189, 167, 200, 175, 150, 87, 99, 129, 149, 176, 200, 87, 35, 157)




The maximum weight y (in pounds) for a man in the United States Marine Corps can be approximated by the mathematical model

y=0.040x2 −0.11x+3.9, 58≤x≤80

where x is the man’s height (in inches).

Design an algorithm and write a C++ program that prompts the user to input the height in inches. The program calculates and outputs the weight in pounds.


  


LATEST TUTORIALS
APPROVED BY CLIENTS