Questions
In C++ Question 1) Theoretical Questions 1.1) Why is it better to store the tail pointer...

In C++

Question 1) Theoretical Questions

1.1) Why is it better to store the tail pointer rather than the head pointer in a circular singular linked list?

1.2) What are the main advantages of a doubly linked list compared to a singularly linked list?

Question 2) Practical Questions

Suppose a doubly-linked list makes use of a class called DLNode, defined as follows:

template<class T>

struct DLNode

{

T data;

DLNode<T> * next;

DLNode<T> * prev;

};

Further suppose the linked list class maintains a pointer to the first node in the list as a member variable called DLNode<T> *head.

2.1) Suppose left and right are variables of type DLNode<int>* pointing to two nodes that are adjacent in a doubly-linked list, i.e left->next points to right. Both nodes have predecessors and successors in the list. Write the code taht will swap the nodes in the list by adjusting pointers. Do not change the value of the data field of either nodes.

2.2) Given a circular doubly-linked list of 5 integers (1,2,3,4,5), write a function printAll() to output the list in the following order: (1,5,2,4,3). The function should work on any odd number of nodes.

In: Computer Science

5) Write a JavaScript script that will ask the user to enter in the length of...

5) Write a JavaScript script that will ask the user to enter in the length of the side of a
cube. (all the sides of a cube are equal) Based on the value that is entered by the user
from the keyboard, calculate each of the following and assign your results to variables.
1. volume of the cube
2. surface area of the cube
3. volume of the largest sphere that could fit in the box.
4. surface area of the largest sphere that could fit in the box.
5. volume of the space in between the cube and the sphere.
HINT: the largest sphere that could fit in the box will have a diameter equal to the side
of the cube.
ANOTHER HINT: to find the volume in between the cube and sphere you should subtract
volumes. in case you forgot the sphere formulas, they are:
volume of sphere = 4/3 Pi r3
surface area of sphere = 4 Pi r2
Your script should output HTML text that displays the results of your calculations.

In: Computer Science

(Please write in C++) Write a program that reads in a line consisting of a student’s...

(Please write in C++) Write a program that reads in a line consisting of a student’s name, Social Security number, user ID, and password. The program outputs the string in which all the digits of the Social Security number and all the characters in the password are replaced by x. (The Social Security number is in the form 000-00-0000, and the user ID and the password do not contain any spaces.) Your program should not use the operator [ ] to access a string element. Use the appropriate functions described in Table 7-1 below.

Expression
strVar.at(index)
strVar[index]
strVar.append(n, ch)
strVar.append(str)
strVar.clear()
strVar.compare(str)
strVar.empty()
strVar.erase()
strVar.erase(pos, n)
strVar.find(str)
strVar.find(str, pos)
strVar.find_first_of(str, pos)
strVar.find_first_not_of(str, pos)
strVar.insert(pos, n, ch)
strVar.insert(pos, str)
strVar.length()
strVar.replace(pos, n, str)
strVar.substr(pos, len)
strVar.size()
strVar.swap(str1)

With an input of: John Doe 333224444 DoeJ 123Password

The results should be: John Doe xxxxxxxxx DoeJ xxxxxxxxxxx

In: Computer Science

Write a program in java which randomly generates two integer number n1 and n2 (suppose the...

Write a program in java which randomly generates two integer number n1 and n2 (suppose the range for each integer is [1, 100]), then asks the user what is the value of n1*n2, if the user’s answer is correct, call method printGoodComment to print out something nice, otherwise, call printBadComment to print out something “mean”.

The method signatures are:

                  public static void printGoodComment()

and

                  public static void printBadComment()

in your printGoodComment method, it will randomly print one sentence from the following lists:

                              good job

                              excellent

                              terrific

                              nice work

in your printBadComment method, it will randomly print one sentence from the following lists:

                              sorry, try next time

                              oops, you need more work

                              hmm, it is not correct

Hint: use Math.random and a switch statement in the printGoodComment and printBadComment methods.

  • In the printGoodComment method, use Math.random( ) to generate a random int in the rage of [0, 3] and use a switch statement to select one of the four good moments based on the value of the random int.
  • In the printBadComment method, use Math.random( ) to generate a random int in the rage of [0, 2] and use a switch statement to select one of the three bad moments based on the value of the random int.

In: Computer Science

Write a program in java which randomly generates two integer number n1 and n2 (suppose the...

Write a program in java which randomly generates two integer number n1 and n2 (suppose the range for each integer is [1, 100]), then asks the user what is the value of n1*n2, if the user’s answer is correct, call method printGoodComment to print out something nice, otherwise, call printBadComment to print out something “mean”.

The method signatures are:

                  public static void printGoodComment()

and

                  public static void printBadComment()

in your printGoodComment method, it will randomly print one sentence from the following lists:

                              good job

                              excellent

                              terrific

                              nice work

in your printBadComment method, it will randomly print one sentence from the following lists:

                              sorry, try next time

                              oops, you need more work

                              hmm, it is not correct

Hint: use Math.random and a switch statement in the printGoodComment and printBadComment methods.

  • In the printGoodComment method, use Math.random( ) to generate a random int in the rage of [0, 3] and use a switch statement to select one of the four good moments based on the value of the random int.
  • In the printBadComment method, use Math.random( ) to generate a random int in the rage of [0, 2] and use a switch statement to select one of the three bad moments based on the value of the random int.

In: Computer Science

Instructions The included program found in main.cpp is designed to find the area of a rectangle,...

Instructions

The included program found in main.cpp is designed to find the area of a rectangle, the area of a circle, or the volume of a cylinder.

However:

  • the statements are in the incorrect order;
  • the function calls are incorrect;
  • the logical expression in the while loop is incorrect;
  • the function definitions are incorrect;
  • You may assume that the value of π = 3.14159.

Rewrite the program so that it works correctly. Your program must be properly indented. (Note that the program is menu driven and allows the user to run the program as long as the user wishes.)

Format your output with setprecision(2) to ensure the proper number of decimals for testing!

I have tried previous answers on site, but they are all incorrect and fail in the Mindtap cite used for the class.

In: Computer Science

How Non-monotonic reasoning deals with incomplete and uncertain model? subject: Artificial Intelligence  

How Non-monotonic reasoning deals with incomplete and uncertain model?

subject: Artificial Intelligence  

In: Computer Science

In Java Write a method called findMax that accepts three floating-point number as parameters and returns...

In Java Write a method called findMax that accepts three floating-point number as parameters and returns the largest one.(hints: use conditional statement in the method)

In: Computer Science

Implement Radix Sort using PYTHON programming language. Use one of the two options for the algorithm...

Implement Radix Sort using PYTHON programming language. Use one of the two options for the algorithm to sort

the digits: Use Counting Sort or Bucket Sort.

• Assume the numbers are maximum 4-digit numbers.

• If using Counting Sort, you can see that your digit range is between 0 and 9 ([0…9]).

• If using Bucket Sort, you will have ten buckets labeled from 0 to 9.

Please add comments and explain every step carefully.

In: Computer Science

In C++, Convert the math expression (2+3)+4*(6-5) to post fix form and evaluate the post fix...

In C++, Convert the math expression (2+3)+4*(6-5) to post fix form and evaluate the post fix expression “3 2 * 3 – 2 /” to a value.

In: Computer Science

C++ You are going to implement your own vector class. Actually, we are using the following...

C++ You are going to implement your own vector class. Actually, we are using the following small and simplified subset of the interface from std::vector to keep things manageable:

template class DiyVector{
    public:
        DiyVector();
        ~DiyVector();

        T& at(unsigned int index) const;
        // item at index
        // throws OutOfRange

        unsigned int size() const;
        // number of items in the vector

        void pushBack(const T& item);
        // append item at the end of vector

        void popBack();
        // remove item at the end of vector
        // throws OutOfRange

        void erase(unsigned int index);
        // remove element at index
        // throws OutOfRange

        void insert(unsigned int index, const T& item);
        // insert item before element at index, with:
        // 0 <= index <= size()
        // throws OutOfRange

        class OutOfRange{};

    private:

        // your implementation goes here!
};
Your DiyVector will store items of type T in an array that is dynamically allocated on the heap, using new[].

We only expand this array, but never shrink it:

when adding an item (using pushBack or insert), if there is no currently unused element in the array, create a new array, able to hold one more element, and copy over the old items. Of course, you delete[] the old, too-short array afterwards.

when deleting an item (using popBack or erase), you simply "pack" the array by copying all items behind the erased one to close the gap (and adjust the bookkeeping of used elements). Later, when a new item is to be added (using pushBack or insert), you re-use an old space at the end of the array, instead of creating a whole new array.

Your program must not use any item storage but arrays that are created by new[]. (No statically created arrays, no vectors, no other container classes from std::)

You deliver your DiyVector as a header file called diyvector.h.

It will be automatically tested by the following program( create a seperate file named vector-tester.cpp using code below) :

#include

#include "diyvector.h"

class TestFailed{

public:

TestFailed(int seq){

sequenceNumber = seq;

}

int sequenceNumber;

};

int testNumber = 0;

#define check(CALL) { testNumber++; if ( !(CALL) ) throw TestFailed(testNumber); }

#define checkException(CALL){ \

testNumber++; \

bool exceptionRaised = false; \

try{ \

CALL; \

}catch(DiyVector::OutOfRange& o){ \

exceptionRaised = true; \

} \

if ( !exceptionRaised ) throw TestFailed(testNumber); \

}

int main(){

try{

DiyVector v;

check(v.size() == 0); // test 1

checkException(v.at(0));

v.pushBack(42);

check(v.size() == 1);

check(v.at(0) == 42);

checkException(v.at(1)); // test 5

v.pushBack(43);

check(v.size() == 2);

check(v.at(1) == 43);

check(v.at(0) == 42);

v.popBack();

v.popBack();

check(v.size()==0);

checkException(v.popBack()); // test 10

v.pushBack(142);

v.pushBack(143);

v.pushBack(144);

check(v.size()==3);

check(v.at(0)==142);

check(v.at(1)==143);

check(v.at(2)==144);

checkException(v.at(3)); // test 15

v.at(0) = 17;

check(v.at(0)==17);

checkException(v.erase(3));

checkException(v.erase(42));

v.erase(1);

check(v.size()==2);

check(v.at(0)==17); // test 20

check(v.at(1)==144);

v.pushBack('A');

v.pushBack('B');

check(v.size()==4);

check(v.at(2)==65);

check(v.at(3)==66);

v.insert(2, 22);

check(v.at(0)==17); // test 25

check(v.at(1)==144);

check(v.at(2)==22);

check(v.at(3)==65);

check(v.at(4)==66);

check(v.size()==5); // test 30

DiyVector v2;

v2.insert(0,42);

v2.pushBack(11);

v2.insert(0,44);

check(v2.size()==3);

check(v2.at(0)==44);

check(v2.at(1)==42);

check(v2.at(2)==11);

v2.popBack();

v2.insert(0,99);

check(v2.size()==3); // test 35

check(v2.at(0)==99);

check(v2.at(1)==44);

check(v2.at(2)==42);

DiyVector v3;

v3.pushBack(1);

v3.erase(0);

checkException(v3.at(0));

check(v3.size()==0); // test 40

checkException(v3.insert(1,-5));

check(v3.size()==0); // test 42

std::cout << "All tests passed!\n";

}

catch(TestFailed& tf){

std::cerr << "Test number " << tf.sequenceNumber << " failed.\n";

return 1;

}

catch(...){

std::cerr << "an unexpected exception occured\n";

std::cerr << "Tests passed so far: " << testNumber << std::endl;

return 2;

}

return 0;

}

In: Computer Science

Describe what a database is. Explain components of a database management system - (DBMS). Setup a...

Describe what a database is. Explain components of a database management system -

(DBMS). Setup a database to manage a hypothetical business. Create between 5 – 7 categories/ groups of functional areas for your business. For e.g., Personnel, Suppliers, Products, Fleet, Customers Add 20 entries. You may build this database in MS Excel, or MS Access.


please with no plagrism

In: Computer Science

in Java Write a method called randomNumber that returns a random floating-point number in the range...

in Java Write a method called randomNumber that returns a random floating-point number in the range of [-20.0, 50.0). (hints: use Random class in the method)

In: Computer Science

Examine the role of IT governance and why it is important in the IT industry. Analyze...

Examine the role of IT governance and why it is important in the IT industry.

Analyze key aspects of IT governance, including enterprise resource planning and transaction processing systems.

In: Computer Science

in c++: The area of an arbitrary triangle can be computed using the formula where a,...

in c++:

The area of an arbitrary triangle can be computed using the formula
where a, b, and c are the lengths of the sides, and s is the semiperimeter :
s = (a + b + c) / 2
1. (5 points) Write a void function that uses five parameters :
three value parameters that provide the lengths of the edges and
two reference parameters that compute the area and perimeter(not the semiperimeter).
Make your function robust.Note that not all combinations of a, b, and c produce a triangle.
Your function should produce the correct results for legal data and reasonable results for illegal combinations.

In: Computer Science