Questions
You are to write a short program asking the user to input a single character. Specifically,...

You are to write a short program asking the user to input a single character. Specifically, your prompt should be to ask the user to input a vowel - A, E, I , O or U. (We will not use Y ).       Your program should then determine if they did indeed type in a vowel (upper or lower case is acceptable for user input for the vowel). You should use data type char   for input!

If they did, you print a short message thanking them for following directions.

If they did NOT input a vowel, you print out a short message telling them that they did NOT follow the instructions.  

You should use the switch statement construct to solve this problem.

I need help writing this in C++

In: Computer Science

Don't attempt if you can't attempt fully, i will dislike and negative comments would be given...

Don't attempt if you can't attempt fully, i will dislike and negative comments would be given Please it's a request.

c++
We will read a CSV files of a data dump from the GoodReads 2 web site that contains information
about user-rated books (e.g., book title, publication year, ISBN number, average reader rating,
and cover image URL). The information will be stored and some simple statistics will be
calculated. Additionally, for extra credit, the program will create an HTML web page based on
the top n highest rated books. As is typical of many subject matter information sources, the data
in the file contains various errors. As such, we will track the errors and create an exceptions files
to track the lines with data errors.
Develop a class, bookDataType, to provide functionality for reading and storing book
information. The UML class specifications are provided below. A main will be provided that
uses the bookDataType class.

Book Data Type Class
The class will implement the functions.
bookDataType
-COL_LIMIT = 23: static constexpr unsigned int
-TOP_LIMIT = 20: static constexpr unsigned int
-booksFileName: string
-webPageFileName: string
-exceptionsFileName: string
-bookCount: unsigned int
1 For more information, refer to: https://en.wikipedia.org/wiki/Comma-separated_values
2 See: www.goodreads.com-topBooksLimit: unsigned int
-*topBooks: unsigned int
-struct bookErrsStruct
-bookIDErrors: unsigned int
-bookYearErrors: unsigned int
-AveRatingErrors: unsigned int
-duplicateDataErrors: unsigned int
-bookErrInfo: bookErrsStruct
-struct bookStruct
-bookTitle: string
-isbn: string
-pubYear: short
-aveRating: float
-imageURL: string
-bookID: unsigned int
-*bookInfo: bookStruct
+bookDataType()
+~bookDataType()
+getBookArguments(int, char *[], string &, bool &): bool
+getBookFileName() const: string
+getWebPageFileName() const: string
+getExceptionsFileName() const: string
+getReadBookIDErrors() const: unsigned int
+getReadBookYearErrors() const: unsigned int
+getReadBookAveRatingErrors() const: unsigned int
+getReadBookDuplicateErrors() const: unsigned int
+getTopBooksLimit() const: unsigned int
+showBookData(unsigned int) const: void
+getBookCount() const: unsigned int
+getAverageOverallRating() const: float
+showHighestRatedBooks() const: void
+readBookData(const string): bool
+buildWebPage(const string="CS 202 Top Books") const: bool
+findHighestRatedBooks(): void
+setWebPageFileName(const string): void
+setExceptionsFileName(const string): void
+setTopBooksLimit(unsigned int): void
-parseLine(string, string []) const: void
Note, points will be deducted for insufficient commenting, poor style, or inefficient coding. The
error messages should be prefixed with the function name (to help better identify the source of
the error). Refer to the sample execution for error message examples.Function Descriptions

The bookDataType() constructor should set the books filename to the empty string, the
bookCount to 0, the topLimit to a default value of 5, the error counts to 0, the web page
file name to a default value of “index.html”, and the exceptions file to a default value of
“errors.txt”, and the pointers to the nullptr.

The ~bookDataType() destructor should delete the dynamically allocated arrays, set the
other class variables to their default values (noted above).

The getBookArguments() function should read the command line qualifiers in the
required format ( -i <booksFileName> [<-show|-noshow>] ) to obtain the file
name and set the show extra information flag (true/false). The data file and show extra
flag may be in either order. The show extra flag is optional and the “-noshow” is the
default if not specified. This includes a usage message and error messages for both the
input file specifier and the input file name. The file name must be at least one letter and
include a “.csv” extension (thus, the minimum length is 5). If the file name is incorrect or
does not exist, an appropriate error message should be displayed, the class variable
should remain unchanged, and the function should return false. To determine if a file
exists (without opening it), you can use the access() function (i.e,
( access(fn.c_str(), F_OK) ) which returns a 0 if the file exists and returns a -1 if
the files does not exist. Note, the access() function requires the #include <unistd.h>
statement. If there is an error, the function should output one of the following error
messages:
cout
cout
cout
cout
cout









<<
<<
<<
<<
<<
"Usage:
"Error,
"Error,
"Error,
"Error,
./books -i <bookDataFileName> [<-show|-noshow>]" << endl;
invalid input file name specifier." << endl;
invalid command line options." << endl;
book data file name must be '.csv' extension." << endl;
invalid show extra information specifier." << endl;
based on the specific error.
The getBookFileName() function should return the current book file name.
The getWebPageFileName() function should return the current web page file name.
The getReadBookIDErrors(), getReadBookYearErrors(),
getReadBookAveRatingErrors(), and getReadBookDuplicateErrors() functions should
return the applicable structure field.
The getExceptonsFileName() function should return the current exceptions file name.
The setBookFileName() function should set the class variable for the books file name to
the passed file name. The file name must be at least one letter and include a “.csv”
extension (thus, the minimum length is 5). If the passed file name is correct and the file
exists, the class variable should be set and a true returned. If the file name is incorrect or
does not exist, an appropriate error message should be displayed, the class variable
should remain unchanged, and the function should return false. To determine if a file
exists (without opening it), you can use the access() function (i.e,
( access(fn.c_str(), F_OK) ) which returns a 0 if the file exists and returns a -1 if
the files does not exist..
The setWebPageFileName() function should set the class variable for the web page file
name to the passed file name. The file name must be at least one letter and include a
“.html” extension (thus, the minimum length is 6).
The setExceptonsFileName() function should set the class variable for the file name to
the passed file name. The file name must be at least one letter and include a “.txt”
extension (thus, the minimum length is 5).
The getTopBooksLimit() function should return the value for the current number of
highest rated books to be found.
The setTopBooksLimit() function should set the class variable for the current number of
highest rated books to be found. The value must not exceed the TOP_LIMIT constant. If
the passed value is out of range, nothing should be changed.•


The getBookCount() should return the current number of books in the data set.
The getAverageOverallRating() function should return the overall average of book rating
in the entire current data set.
The showBookData() function should display the formatted book information to the
screen in the specified format (see output example).
cout
cout
cout
cout
cout
cout
cout





<<
<<
<<
<<
<<
<<
<<
"Book Information:" <<
offset << "Title:
"
offset << "Book ID
"
offset << "ISBD:
"
offset << "Year:
"
offset << "Ave Rate: "
endl;
endl;
<< bookInfo[idx].bookTitle << endl;
<< bookInfo[idx].bookID << endl;
<< bookInfo[idx].isbn << endl;
<< bookInfo[idx].pubYear << endl;
<< bookInfo[idx].aveRating << endl;
The showHighestRatedBooks() function should show the topBooksLimit number of
highest rated books using the showBookData() function from the topBooks array. As
such, the findHighestRatedBooks() function must have been previously called.
The findHighestRatedBooks() function should find the topBooksLimit number of highest
rated books. This will require dynamic creation and population of the topBooks[] array
of topBooksLimit size. The array will hold the index of the book into the bookInfo[]
array. Due to the data size, a sort is not appropriate. The topBooksLimit number of
highest rated books should be determined with out performing a sort.
The parseLine() function will accept a string in comma-separated format and break the
string into its individual comma separated fields. This includes handling quoted fields
that may contain commas which are not field separators when inside quotes. The
function should populate the passed array with the COL_LIMIT fields in string format.
If the line contains more than COL_LIMIT fields, only the first COL_LIMIT should be
returned (thus, do not over-write the array).
The readBookData() function should read the books file (CSV format). This function
will call the private parseLine() function. From the returned string array, the following
fields should be placed into the applicable fields of bookInfo[] array.

Book title (first title), string
◦ note, of first title is empty, use second title

ISBN (10 digit), string

ImageURL (first of two), string

Publication Year, short

Book ID (good reads book ID, which is first), unsigned integer

Average Rating, float
Note, since some data field may be invalid, try/catch blocks must be used for the
conversion. The first line is a header line and must be skipped. Blank lines should be
skipped. In order to size the bookInfo[] struct array, you will need to read the file twice;
once to count the data lines and again to read the data. To reset the file to the beginning,
use inFile.clear(); followed by inFile.seekg(0, ios::beg); . To convert
string values into floats or integers, use the stoi() and stof() functions. In order to check
for errors, these should be performed within a try/catch block. Errors should be written
to the exceptions file with a line of 60 ‘-’s, the specific error, the line number (from the
source data file), and on the next line the title “Row Data:”, and on the next line the
complete row followed by a blank line. Refer to the examples for formatting. Duplicate
rows are determined by the same book ID number and the second occurrence written to
the exceptions file. See examples for formatting.
EXTRA CREDIT (up to 25 pts) → The buildWebPage() function should build an HTML
web page of the top topBooksLimit number of highest rated books including a link to the
image and the book information on the GoodReads web site. The Good Reads link is
generated by appending the book ID to the URL" https://www.goodreads.com/book/show/ " within an HREF tag along with the
title. For example, <a
href=https://www.goodreads.com/book/show/24812>The Complete
Calvin and Hobbes</a> for book ID 24812. The passed string is the web page title
(using <title>CS 202 Top Books Page</title> in the header block) and the initial we page
label (using an <h1>title</h1> tag) with a subtitle of “Top Rated Books” (using an
<h2>subtitle</h2> tag). The minimum requirements for the web page include the
title and subtitle headers, followed by the books. The books must be numbered (1, 2, ...),
include the good reads book information link, the book cover image, the ISBN number
(10 digit), and the book average rating. See the provided example for a minimal required
format. The full 25 points will only be awarded if the final web page exceeds the
minimal formatting (see example).
Refer to the example executions for output formatting. Make sure your program includes the
appropriate documentation. See Program Evaluation Criteria for CS 202 for additional
information.
Make File:
You will need to develop a make file. You should be able to type:
make
Which should create the executable. The makefile will be very similar to the previous
assignment makefiles.
Submission:
● Submit a zip file of the program source files, header files, and makefile via the on-line
submission. All necessary files must be included in the ZIP file.
The grader will download, extract, and type make (so you must have a valid, working makefile).
CSV Format
Fields in a CSV file are comma-separated. Typically (but not always), the first line of the file
contains a row showing the field names. This is the case for our data files. A field may contain
a number or may be quoted (that is, enclosed within double-quote characters) indicating string
fields such as book titles. Such strings (names/titles) may have embedded commas and
embedded quote characters (which must be double-quoted). For example,
,"J.K. Rowling, Mary GrandPré, Rufus Beck",
,"A Child Called ""It"": One Child's Courage to Survive",
,"""M"" is for Malice",
,"""Who Could That Be at This Hour?""",
The double-quotes are used to mark a string field and are not actually part of the string. For
example, the first line (above) is actually J.K. Rowling, Mary GrandPré, Rufus Beck .
Where the double-quotes mark only the start and end. Since the double-quote is used to mark the
start and end of a field, a double double-quote is used to signify an actual double-quote. For
example, the second line is A Child Called "It": One Child's Courage to
Survive , the second line is "M" is for Malice , and the third line is "Who Could That
Be at This Hour?" .These requirements can make the reading of CSV files a challenge. In addition, may data
sources in CSV format have imperfect data with various errors include invalid numeric values,
too few fields, or too many fields.
Try/Catch Block Example
Below is an example of how to use the try/catch block for conversion using the C++ stoi()
function.
unsigned int
unsigned long
string
try {
someNumber = 0;
size = 0;
badNum = "12-34";
someNumber = stoi(badNum, &size);
if (size != columns[8].size())
throw
invalid_argument("Conversion Error");
}
catch (exception &err) {
errFile << err.what() << endl;
}

In: Computer Science

In-Class coding exercise: (try - catch) (pass / fail) The purpose of this in-class coding exercise...

In-Class coding exercise: (try - catch) (pass / fail)

The purpose of this in-class coding exercise is to simulate various exception conditions using the program provided.

package com.InClass;
/*
* This program demonstrates the ability of catching different types of exceptions"
* You will have to modify the method() codes to trigger various/different exceptions.
* inClass Coding ( you will have to remove (comment out) the previous error condition before moving to trigger the next)
* 1) throw a myExcept exception (this is defined with an extends to Exception (see code)
* 2) use method () to trip a Arithmetic exception
* 3) use method () to trip a nullPointException
* 4) use method () call to trip a runtime exception
* 5) inside the myExcept error to inject an arithmetic error and watch it behave differently from step1 22
*
*/
public class TestExceptions {
   public static void main(String[] args) {
       try {
           // throw myException() first.
  
             
            method();
            System.out.println(" after the method call");
       }
       catch (MyExcept ex){
           System.out.println(" MyExcept error");
             
       }
       catch (ArithmeticException ex){
           System.out.println(" ArithmeticEx error");
             
       }
       catch (NullPointerException ex) {
           System.out.println(" nullPointException !!! ");
       }
       catch (IndexOutOfBoundsException e) {
           System.out.println(" index out of bounds...");
       }
       catch (RuntimeException ex ) {
           System.out.println(" Runtime exception");
           System.out.println(ex.getMessage());
             
       }
       catch (Exception e ) {
           System.out.println(" Exception");     
       }

       finally {
       System.out.println(" finally After the catch");
       }
   }
     
   static void method() throws Exception {

// create ArithmeticException
         
         
         
// create RuntimeExceptiom         
         

         
         
// create a null point exception here -- fix the exception above first

         
         
         
// create a ClassCastException here which is NOT on catch "watch" listed above


//   throw new Exception(); // trigger an Exceptiom
   }
}
class MyExcept extends Exception { // creating your custome error
   MyExcept(){
//       int y = 1/0; // uncomment this line to introduce an aritmetic exception inside your MyExcept
   System.out.println(" inside my custome MyExcept");
   }

}

Please complete the missing exceptions. Ignore the spellings mistakes/grammer, it's how the professor writes.

Instructions might be a bit hard to follow so please bear that in mind. Complete as much as possible.

Thank you.

In: Computer Science

Please write a conclusion about data structure and algorithm i need an conclusion for my Data...

Please write a conclusion about data structure and algorithm

i need an conclusion for my Data Structure and algorithm thesis

i am writing a thesis i need conclusion topic is Data Structure and algorithm

In: Computer Science

Could you include little explanation. What is a system call to replace the process image? If...

Could you include little explanation.

What is a system call to replace the process image? If successful, what is its effect on the process that calls it?

When scheduling processes, provide an example of how round-robin which is known as one of the fairer systems, can be unfair on a multi-user system.

What is the difference between a semaphore and mutex? When would you use one over the other?

In: Computer Science

So I'm writing a function in javaScript that will take a user full name in one...

So I'm writing a function in javaScript that will take a user full name in one text box. "first" space "last name" But if the user does not enter the space then there should be an error. So I'm looking for a way to validate this so the user needs to enter the space.

In: Computer Science

In C programming, Thank you Declare an array that can contain 5 integer numbers. Use a...

In C programming, Thank you

Declare an array that can contain 5 integer numbers.

Use a for loop to ask the user for numbers and fill up the array using those numbers.

Write a program to determine the 2 largest integers in the array, and print those numbers.

Hint: You can declare integer variables “largest” and “secondLargest” to keep track as you make comparisons using the if...elseif statement.

The following is an example of how your program should look when you execute it:

Enter a number to store in the array: 10
Enter a number to store in the array: 91
Enter a number to store in the array: 145
Enter a number to store in the array: 94
Enter a number to store in the array: 97

The largest number is 145
The second largest number is 97

In: Computer Science

Python Language Only! Python Language Only! Python Language Only! Python 3 is used. When doing this...

Python Language Only!

Python Language Only!

Python Language Only!

Python 3 is used.

When doing this try to use a level one skill python, like as if you just learned this don't use anything advanced if you can please. If not then do it as you can.

Assume you have a file on your disk named floatnumbers.txt containing float numbers. Write a Python code that reads all the numbers in the file and display their average. Your code must handle any IOError (for example, file does not exist) and ValueError (for example, alphanumeric data found in the file such as letters) exceptions.

In: Computer Science

Due to some bug in cache control module of ARP package, it increments the time out...

Due to some bug in cache control module of ARP package, it increments the time out value instead of decrementing it. How does it affect the performance of the cache tablein following scenarios?a.Number of different destination IP addresses are less than size of cache tableb.Number of different destination IP addresses aresignificantly larger than size of cache table.

In: Computer Science

2. Create a class called Invoice that a store might use to represent an invoice for...

2. Create a class called Invoice that a store might use to represent an invoice for an item sold at the store. An Invoice should include four data members—the ID for the item sold (type string), name of item (type string), item description (type string) and the price of the item (type int). Your class should have a constructor that initializes the four data members. A constructor that receives multiple arguments. Example: ClassName( TypeName1 parameterName1, TypeName2 parameterName2, ... ) Provide a set and a get function for each data member. SearchbyNameAndAdd(): Ask the user which item he/she wants to purchase, if the item is found in the list then store the price of the item in a temporary array or variable. This function will keep adding the amount of items being selected by the user. Once the user has selected all the item he/she needs exit from this function and display the total amount by using the function below: o A function named getTotalAmount () that displays the total amount/bill as an int value.

write it in C++

In: Computer Science

I am working on exercise 5.48 from Introduction to Computing using python (Author: Perkovic). Problem Question:...

I am working on exercise 5.48 from Introduction to Computing using python (Author: Perkovic).

Problem Question: Let list1 and list2 be two lists of integers. We say that list1 is a sublist of list2 if the elements in list1 appear in list 2 in the same order as they appear in list1, but not necessarily consecutively. For ex, if list1 is defined as [15,1,100] and list2 is defined as [20,15,30,50,1,100]. Then list 1 is a sublist of list 2 because the numbers in list1 (15,1, and 100) appear in the same order. However, list [15,20,20] is not a sublist of list2. Implement function sublist() that takes as input lists list1 and list2 and returns True if list1 is a sublist of list2 and False otherwise.

I've gotten so far with the below code, but the code is not returning anything when I run it. I'm not sure what I am doing wrong here. Any hints of next steps would be great!


def sublist(lst1, lst2):
i = 0

for n in lst1:
while i < len(lst2):
if lst2[i] == n:
i+=1
return True
  
return False

  
print(sublist([15,1,100],[20,15,30,50,1,100]))
print(sublist([15,50,20],[20,15,30,50,1,100]))

In: Computer Science

Exception handling to detect input string vs. int The given program reads a list of single-word...

Exception handling to detect input string vs. int

The given program reads a list of single-word first names and ages (ending with -1), and outputs that list with the age incremented. The program fails and throws an exception if the second input on a line is a string rather than an int. At FIXME in the code, add a try/catch statement to catch ios_base::failure, and output 0 for the age.

Ex: If the input is:

Lee 18 
Lua 21 
Mary Beth 19 
Stu 33 -1

then the output is:

Lee 19
Lua 22
Mary 0
Stu 34

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

#include
#include

using namespace std;

int main(int argc, char* argv[]) {
string inputName;
int age;
// Set exception mask for cin stream
cin.exceptions(ios::failbit);

cin >> inputName;
while(inputName != "-1") {
// FIXME: The following line will throw an ios_base::failure.
// Insert a try/catch statement to catch the exception.
// Clear cin's failbit to put cin in a useable state.
cin >> age;
cout << inputName << " " << (age + 1) << endl;

cin >> inputName;
}

return 0;
}

In: Computer Science

Select 3 different sized (order lg lg n, lg n, n, n lg n, n2 ,...

Select 3 different sized (order lg lg n, lg n, n, n lg n, n2 , n3 , nk , cn , n!) algorithms to code using a compiler of choice (VB, C++, Java, , etc…). An example would be an algorithm to search for a number in a list of n numbers → (n), and a second algorithm to sort a list of numbers using a bubble sort → (n2 ). You could also choose to just calculate a open form expression like 1 + 2 + 3 + 4 + 5 + 6 + … n for a size n algorithm. Once the algorithms are coded and working (10pts. will be awarded on complexity/substance of algorithms), add a timer to the crucial section of the code that will correspond to the  analysis. I have included some sample Java and C++ timer code below that should work. Show me the programs running/working with the time elapsed outputted for a run. 5pts. Run and time the three algorithms for n = 10, 100, 1000, 10000, etc… and chart the different times on a column, bar, or line chart. Turn in a word processed report listing the three algorithms code and the charts displaying the timed results of the runs. 5pts. Use long (16 bit) in Java and long long (16 bit) in C++ for your variables to avoid a memory problem.

In: Computer Science

2.     Modify assignment 1 solution code I posted to do the following: a.     Change car class to bankAccount...

2.     Modify assignment 1 solution code I posted to do the following:

a.     Change car class to bankAccount class and TestCar class to TestBank class

b.     Change mileage to balance

c.     Change car info (make, model, color, year, fuel efficiency) to customer first and last name and account balance

d.     Change add gas to deposit (without limit)

e.     Change drive to withdraw cash

f.  Change test car menu to the following Bank Account Menu choices

1 - Deposit

2 - Withdraw

3 - Display account info

4 - Exit


public class Car {
   //Attributes
   private double fuelEfficiency, mileage, fuelCapacity, fuelLevel;
   private String make, model, color, year;
   /**
   * @return the make
   */
   public String getMake() {
       return make;
   }

   /**
   * @param make the make to set
   */
   public void setMake(String make) {
       this.make = make;
   }

   /**
   * @return the model
   */
   public String getModel() {
       return model;
   }

   /**
   * @param model the model to set
   */
   public void setModel(String model) {
       this.model = model;
   }

   /**
   * @return the color
   */
   public String getColor() {
       return color;
   }

   /**
   * @param color the color to set
   */
   public void setColor(String color) {
       this.color = color;
   }

   /**
   * @return the year
   */
   public String getYear() {
       return year;
   }

   /**
   * @param year the year to set
   */
   public void setYear(String year) {
       this.year = year;
   }

   /**
   * @return the fuelEfficiency
   */
   public double getFuelEfficiency() {
       return fuelEfficiency;
   }

   /**
   * @param fuelEfficiency the fuelEfficiency to set
   */
   public void setFuelEfficiency(double fuelEfficiency) {
       this.fuelEfficiency = fuelEfficiency;
   }

   /**
   * @return the mileage
   */
   public double getMileage() {
       return mileage;
   }

   /**
   * @param mileage the mileage to set
   */
   public void setMileage(double mileage) {
       this.mileage = mileage;
   }

   /**
   * @return the fuelCapacity
   */
   public double getFuelCapacity() {
       return fuelCapacity;
   }

   /**
   * @param fuelCapacity the fuelCapacity to set
   */
   public void setFuelCapacity(double fuelCapacity) {
       this.fuelCapacity = fuelCapacity;
   }

   /**
   * @return the fuelLevel
   */
   public double getFuelLevel() {
       return fuelLevel;
   }

   /**
   * @param fuelLevel the fuelLevel to set
   */
   public void setFuelLevel(double fuelLevel) {
       this.fuelLevel = fuelLevel;
   }

   public Car() {
       fuelLevel = 0;
       fuelCapacity = 0;
       mileage = 0;
       fuelEfficiency = 0;
   }
  
   public Car (double fuelEfficiency, double mileage, double fuelCapacity) {
       this.fuelEfficiency = fuelEfficiency;
       this.mileage = mileage;
       this.fuelCapacity = fuelCapacity;
   }
  
   public void drive(double distance) {
       double gallons = distance/fuelEfficiency;
       if(fuelLevel <gallons){
           System.out.println("Not enough gas!");
       }
       else {
           mileage = mileage + distance;
           fuelLevel = fuelLevel - gallons;
           System.out.println("You have driven " +distance+ " mile(s).");
           System.out.println();
           return;
       }
   }
  
   public void addGas(double fuel) {
       if (fuel + fuelLevel < fuelCapacity){
           fuelLevel = fuelLevel + fuel;
           System.out.println("You have added " +fuel+ " gallon(s) of fuel.");
           System.out.println();
           return;
       }
       else {
           System.out.println("Please enter an amount of fuel less than it's capacity.");
       }
   }
  
   public void displayCar(){
       System.out.println();
       System.out.println("Make: " + getMake());
       System.out.println("Model: " + getModel());
       System.out.println("Color: " + getColor());
       System.out.println("Year: " + getYear());
       System.out.println("You have driven " + getMileage() + " miles.");
       System.out.println("Your fuel level is: " + getFuelLevel() + " gallon(s)");
       System.out.println("Your fuel efficiency is " + getFuelEfficiency() + " mpg.");
       System.out.println("Your fuel tank capacity is " + getFuelCapacity() + " gallons.");  
       System.out.println();
       }
      
   }
  
  

In: Computer Science

Usually, Djikstra’s shortest-path algorithm is not used on graphs with negative-weight edges because it may fail...

Usually, Djikstra’s shortest-path algorithm is not used on graphs with negative-weight edges because it may fail and give us an incorrect answer. However, sometimes Djikstra’s will give us the correct answer even if the graph has negative edges.
You are given graph G with at least one negative edge, and a source s. Write an algorithm that tests whether Djikstra’s algorithm will give the correct shortest paths from s. If it does, return the shortest paths. If not, return ‘no.’ The time complexity should not be longer than that of Djiksta’s algorithm itself, which is Θ(|E| + |V | log |V |).
(Hint: First, use Djikstra’s algorithm to come up with candidate paths. Then, write an algorithm to verify whether they are in fact the shortest paths from s.)

In: Computer Science