Questions
1. How do VLANs differ from standard switching? Are all hardware switches (focus on Cisco) VLAN...

1. How do VLANs differ from standard switching? Are all hardware switches (focus on Cisco) VLAN capable?

2. Is a VLAN capable switch more expensive than a standard switch?

3. What criteria might an organization use when determining whether or not to deploy VLANs as part of their networking strategy?

4. Are there circumstances where implementing a router solution instead of a VLAN could be justified on a local area network (LAN)? If so, what are those circumstances?

In: Computer Science

In plain English explain each of the template sections and what goes in it { “AWSTemplateFormatVersion”...

In plain English explain each of the template sections and what goes in it

{
“AWSTemplateFormatVersion” : “2010-09-09”,

“Description” : “Cloudformation Template Review”,

“Parameters” : {
   …  

},

“Mappings” : {
   …
},

“Conditions” : {
   …
},

“Resources” : {
   …
},

“Outputs” : {
   …
}
}

In: Computer Science

Given a sorted array with lot of duplicates, write a problem to search specific element m....

Given a sorted array with lot of duplicates, write a problem to search specific element m. If it’s included in the A, return its minimal index, otherwise return -1. For example A = {0, 0, 1, 1, 1, 2, 3, 3, 4, 4, 4, 4, 4}, if we search 4, you program should return 8. You are only allowed to use binary search. Linear search is not allowed here.

In: Computer Science

Just to be clear, I only want the answer to the third part The typedset question...

Just to be clear, I only want the answer to the third part

The typedset question pls.

Implement a class Box that represents a 3-dimensional box. Follow these guidelines:


constructor/repr

A Box object is created by specifying calling the constructor and supplying 3 numeric values
for the dimensions (width, height and length) of the box.
These measurements are given in inches.
Each of the three dimensions should default to 12 inches.
The code below mostly uses integers for readability but floats are also allowed.
You do not need to do any data validation.
See below usage for the behaviour of repr.
There are no set methods other than the constructor.


>>> b = Box(11,12,5.5)
>>> b
Box(11,12,5.5)
>>> b2 = Box()
>>> b2
Box(12,12,12)

calculations
Given a Box , you can request its volume and cost.
volume - return volume in cubic inches
cost - returns the cost of a box in dollars. A box is constructed out of cardboard that costs
30 cents per square foot. The area is the total area of the six sides (don't worry about
flaps/overlap) times the unit cost for the cardboard.
If you look up formulas, cite the source in a comment in your code.

>>> b.volume()
726.0
>>> b.volume() == 726
True
>>> b.cost()
1.0770833333333334
>>> b2.volume()
1728
>>> b2.cost()
1.8
>>> b2.cost() == 1.8
True

comparisons

Implement the == and <= operators for boxes.
== - two boxes are equal if all three dimensions are equal (after possibly re-orienting).
<= - one box is <= than another box, if it fits inside (or is the same) as the other (after
possibly re-orienting). This requires that the boxes can be oriented so that the first box has
all three dimensions at most as large as those of the second box.

The above calculations must allow the boxes to be re-oriented. For example
Box(2,3,1)==Box(1,2,3) is True . How many ways can they be oriented? What is a good
strategy to handle this?
You may need to look up the names of the magic/dunder methods. If so, cite the source.
warning: I will run more thorough complete tests, so make sure you are careful!

>>> Box(1,2,3)==Box(1,2,3)
True
>>> (Box(1,2,3)==Box(1,2,3)) == True
True
>>> Box(2,3,1)==Box(1,2,3)
True
>>> Box(4,3,1)==Box(1,2,6)
False
>>> Box(1,2,3) <= Box(1,2.5,3)
True
>>> Box(1,3,3) <= Box(1,2.5,3)
False
>>> Box(3,1,2) <= Box(1,2.5,3)
True
>>> Box(1,2,3)<=Box(1,2,3)
True
>>>

boxThatFits

Write a standalone function boxThatFits that is a client of (uses) the Box class.
This function will accept two arguments, 1) a target Box and, 2) a file that contains an
inventory of available boxes.
The function returns the cheapest box from the inventory that is at least as big as the target
box.
If no box is large enough, None is returned.
If there is more than one that fits available at the same price, the one that occurs first in the
file should be returned.

>>> boxThatFits(Box(10,10,10),"boxes1.txt")
Box(10,10,10)
>>> b = boxThatFits(Box(10,10,10),"boxes1.txt")
>>> b.cost()
1.25
>>> boxThatFits(Box(12,10,9),"boxes2.txt")
Box(10,10,13)
>>> boxThatFits(Box(14,10,9),"boxes2.txt")
Box(11,15,10)
>>> boxThatFits(Box(12,10,13),"boxes2.txt")
Box(12,14,10)
>>> boxThatFits(Box(16,15,19),"boxes1.txt")
>>>

TypedSet

Write a class TypedSet according to these specifications:
TypedSet must inherit from set . Remember that this means you may get some of the
required functionality for free.
TypedSet acts like a set (with limited functionality) except that once the first item is added,
its contents are restricted to items of the type of that first item. This could be str or int or
some other immutable type.

# this is helpful, not something you need to write any code for
>>> type("a")
<class 'str'>
>>> x = type(3)
>>> x
<class 'int'>
>>> x==str
False
>>> x==int
True

constructor/repr
Do not write __init__ or __repr__ . When you inherit from set you will get suitable
versions.
Assume that the constructor will always be used to create an empty TypedSet (no arguments
will be passed)

add/getType
add functions like set.add , except that
the first object added to a TypedSet determines the type of all items that will be
subsequently added to the set
after the first object is added, any attempt to add an item of any other type raises a
WrongTypeError
getType returns the type of the TypedSet or None if no item has ever been added
Note: the sorted function is used for the below examples (and doctest) to make sure that
the results always appear in the same order.
Hint: you will need to make use of Python's type function. It returns the type of an object.
Of course, the value it returns can also be assigned to a variable/attribute and/or compared
to other types like this:

>>> ts = TypedSet()
>>> ts.add("a")
>>> ts.add("b")
>>> ts.add("a")
>>> ts.add(3) #doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
WrongTypeError: 3 does not have type <class 'str'>
>>> sorted(ts)
['a', 'b']
>>> ts = TypedSet()
>>> ts.getType()
>>> ts.add(2)
>>> ts.add("a") #doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
WrongTypeError: a does not have type <class 'int'>
>>> ts.getType()
<class 'int'>
>>> ts.getType()==int
True
>>>

remove
remove functions as it would with a set

>>> ts = TypedSet()
>>> ts.add(4.3)
>>> ts.add(2.1)
>>> ts.add(4.3)
>>> ts.remove(4.3)
>>> ts.remove(9.2) #doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
KeyError: 9.2
>>> ts
TypedSet({2.1})

update
update functions like set.update , given a sequence of items, it adds each of the them
but, this update will raise a WrongTypeError if something is added whose type does not
match the first item

keep in mind that the TypedSet may not yet have been given an item when update is called

>>> ts = TypedSet()
>>> ts.add(3)
>>> ts.update( [3,4,5,3,4,4])
>>> sorted( ts )
[3, 4, 5]
>>> ts.update(["a","b"]) #doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
WrongTypeError: a does not have type <class 'int'>
>>>
>>>
>>> ts = TypedSet()
>>> ts.update( ["a","b",3]) #doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
WrongTypeError: 3 does not have type <class 'str'>
>>>

The | operator is the "or" operator, given two sets it returns their union, those elements
that are in one set or the other. (It is already defined for the set class.)
accepts two arguments, each a TypedSet , neither is changed by |
returns a new TypedSet whose contents are the mathematical union of the supplied
arguments
as usual, raises a WrongTypeError if the two TypedSet 's do not have the same type
remember to cite anything you need to look up

>>> s1 = TypedSet()
>>> s1.update([1,5,3,1,3])
>>> s2 = TypedSet()
>>> s2.update([5,3,8,4])
>>> sorted( s1|s2 )
[1, 3, 4, 5, 8]
>>> type( s1|s2 ) == TypedSet
True
>>> sorted(s1),sorted(s2)
([1, 3, 5], [3, 4, 5, 8])
>>>
>>> s1 = TypedSet()
>>> s1.update([1,5,3,1,3])
>>> s2 = TypedSet()
>>> s2.update( ["a","b","c"] )
>>> s1|s2 #doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
WrongTypeError: b does not have type <class 'int'>

>>> sorted(s1),sorted(s2)
([1, 3, 5], ['a', 'b', 'c'])

Just to be clear, I only want the answer to the third part

The typedset question pls.

In: Computer Science

There are two programming questions for you to do. Please submit two.s or .asm files. You...

There are two programming questions for you to do. Please submit two.s or .asm files. You can use the usual settings as the previous homework. But if you want to use pseudo-instructions, you will need to uncheck "Bare Machine" and check "Accept Pseudo Instructions"

(10 points) Declare an array of integers, something like: . data size : . word 8 array : . word 23 , -12 , 45 , -32 , 52 , -72 , 8 , 13 Write a program that computes the sum of all the odd integers in the array. Put the sum in register $1

In: Computer Science

#python. Explain code script of each part using comments for the reader. The code script must...

#python. Explain code script of each part using comments for the reader. The code script must work without any errors or bugs.
Ball moves in a 2D coordinate system beginning from the original point (0,0). The ball can
move upwards, downwards, left and right using x and y coordinates. Code must ask the
user for the destination (x2, y2) coordinate point by using the input x2 and y2 and the known
current location, code can use the euclidean distance formula to work out the distance
to the destination. Code should repeatedly ask the user to input the destination
coordinates to shift the ball further but, once the user types the value 999, the code
should print all previous movements of the ball by showing the distance of each step. Also trace function
prints the total distance travelled by the ball.

In: Computer Science

C++ code Derive a new subclass of MyClass, name it "MySubClass" and define a private "int"...

C++ code

Derive a new subclass of MyClass, name it "MySubClass" and define a private "int" type data member named "subClassData" in this new class. What do you need to do is to ensure that the correct copy constructor and assignment operators are called. Verify that your new class works correctly.

Take Away: When to and how to call super class constructors/methods

Here are source codes of Driver.cpp file, MyClass.h, and MyClass.cpp

CopyAssignTest.cpp file

#include

#include "MyClass.h"

using namespace std;

int main(int argc, char** argv)

{

// create object m1 using default constructor

MyClass m1;

// update data members

m1.setD(3.14159);

m1.setI(42);

m1.setS("This is a test");

m1.setIp(7);

cout << "m1 values:" << endl;

cout << '\t' << m1.getD() << ", " << m1.getI() << ", " << m1.getS()

   << ", " << m1.getIp() << endl;

// create object m2 from m1 using copy constructor

MyClass m2(m1);

cout << "m2 values:" << endl;

cout << '\t' << m2.getD() << ", " << m2.getI() << ", " << m2.getS()

   << ", " << m2.getIp() << endl;

// create object m3 from m1 using assignment operator

MyClass m3 = m1;

cout << "m3 values:" << endl;

cout << '\t' << m3.getD() << ", " << m3.getI() << ", " << m3.getS()

   << ", " << m3.getIp() << endl;

// update m2's data

m2.setD(1.7172);

m2.setI(100);

m2.setS("This is a NEW test");

m2.setIp(8);

// copy m2 to m1

m1 = m2;

cout << "m1 values:" << endl;

cout << '\t' << m1.getD() << ", " << m1.getI() << ", " << m1.getS()

   << ", " << m1.getIp() << endl;

// only update m2's data IP which is using dynamically allocated memory

m2.setIp(23);

cout << "m1 values:" << endl;

cout << '\t' << m1.getD() << ", " << m1.getI() << ", " << m1.getS()

   << ", " << m1.getIp() << endl;

cout << "m2 values; last should be different:" << endl;

cout << '\t' << m2.getD() << ", " << m2.getI() << ", " << m2.getS()

   << ", " << m2.getIp() << endl;

return 0;

}

MyClass.h file

#pragma once

#include

using namespace std;

class MyClass

{

public:

// default constructor

MyClass();

// copy constructor

MyClass(const MyClass& orig);

// destructor

~MyClass(void);

// assignment operator

MyClass& operator=(const MyClass& rhs);

// setters

void setI(int newI);

void setD(double newD);

void setS(string newS);

void setIp(int newIp);

// getters

int getI(void) const;

double getD(void) const;

string getS(void) const;

int getIp(void) const;

private:

// a couple useful utility functions

void copy(const MyClass& other);

void clear(void);

// an assortment of test data members

int i; // primitive

double d; // primitive

string s; // object

int* ip; // primitive, pointer

};

MyClass.cpp file

#include "MyClass.h"

#include

using namespace std;

MyClass::MyClass() : i(0), d(0.0)

{

ip = new int;

*ip = 0;

}

MyClass::MyClass(const MyClass& orig) : ip(nullptr)

{

// Note that this is a new object; no dynamic memory has been allocated

copy(orig);

}

MyClass& MyClass::operator=(const MyClass& rhs)

{

// we have seen this before: a = a is a legal assignment, and shouldn't do anything

if (this != &rhs) {

copy(rhs);

}

return *this;

}

MyClass::~MyClass()

{

clear();

}

void MyClass::setI(int newI)

{

i = newI;

}

void MyClass::setD(double newD)

{

d = newD;

}

void MyClass::setS(string newS)

{

s = newS;

}

void MyClass::setIp(int newIp)

{

*ip = newIp;

}

int MyClass::getI() const

{

return i;

}

double MyClass::getD() const

{

return d;

}

string MyClass::getS() const

{

return s;

}

int MyClass::getIp() const

{

return *ip;

}

void MyClass::copy(const MyClass& other)

{

i = other.i;

d = other.d;

s = other.s;

// assert(ip == nullptr);

ip = new int;

*ip = *(other.ip);

}

void MyClass::clear()

{

i = 0;

d = 0.0;

s = "";

assert(ip != nullptr);

*ip = 0;

delete ip;

ip = nullptr;

}

In: Computer Science

Using your downloaded DBMS (MS SQL Server or MySQL), write SQL queries that inserts at least...

Using your downloaded DBMS (MS SQL Server or MySQL), write SQL queries that inserts at least three rows in each table.

    1. For the On-Demand Streaming System,
      1. First, insert information for multiple users, at least three video items and insert the three different types of subscriptions (Basic, Advanced, Unlimited) into the database.
      2. Then insert at least three user subscriptions.
  1. Execute the queries and make sure they run correctly

In: Computer Science

Write in javaScript: User input 5 words in one input, and print out the longest word.

Write in javaScript: User input 5 words in one input, and print out the longest word.

In: Computer Science

Using c++, write a program that reads a sequence of characters from the keyboard (one at...

Using c++, write a program that reads a sequence of characters from the keyboard (one at a
time) and creates a string including the distinct characters entered and displays the
string on the screen. The input terminates once the user enters a white-space
character or the user has entered 50 distinct characters.

Do not use C-Strings.
2. Use the following function to append character “ch” to the string “s”:
s.push_back(ch);
3. Read the input characters one by one, i.e. do not read the input as a string.
4. Do not use arrays.

In: Computer Science

Java For this project, we want to build a calculator program that can perform simple calculations...

Java

For this project, we want to build a calculator program that can perform simple calculations and provide an output. If it encounters any errors, it should print a helpful error message giving the nature of the error.

You may use any combination of If-Then statements and Try-Catch statements to detect and handle errors.

Program Specification

Input

Our program should accept input in one of two ways:

  1. If a command-line argument is provided, it should read input from the file given as that argument. If it cannot open the file, it should print the error message specified below and exit.
  2. If no command-line arguments are provided, the program should read input directly from the terminal.

Correct input will consist of a single line following the format:

<number> <symbol> <number>

The numbers can be any valid number, either integer or floating point. For simplicity, our program will treat all numbers as floating point.

The symbol can be any of the following: +, -, *, / or % representing the five common mathematical operations.

State

This project does not require any internal state. However, it should store all numbers as floating point values.

Output

The calculator should output the correct result of the requested calculation, provided that it is possible to do so. Output should be presented as a floating point number.

However, if the program encounters an error when parsing the input, it should print the most appropriate of these helpful error messages:

  • Error: Unable to open file! - if the file provided as a command-line argument cannot be opened
  • Error: No input provided! - if the input is blank
  • Error: Unable to convert first operand to a number! - if the first token is not a number
  • Error: Unknown mathematical symbol! - if the second token is not a recognized symbol
  • Error: Unable to convert second operand to a number! - if the third token is not a number
  • Error: Input format is invalid or incomplete! - if there are not exactly three tokens separated by spaces
  • Error: Division or modulo by 0! - if the second operand is 0 and the symbol is either % or /

Sample Input and Output

Input 1

8 + 5

Output 1

13.0

Input 2

3 / 0

Output 2

Error: Division or modulo by 0!

Input 3

5.0 +- 3

Output 3

Error: Unknown mathematical symbol! 

Input 4

18.125+3

Output 4

Error: Input format is invalid or incomplete!

Input 5

42.5 * 12.34.5

Output 5

Error: Unable to convert second operand to a number!

In: Computer Science

Define three integer variables (number1, number2, and number3). We also define two other storage spaces for...

Define three integer variables (number1, number2, and number3). We also define two other storage spaces for storing sum as well as averageValue. The storage space (sum) is used to store the sum of three integer numbers. The storage space (averageValue) is used to store the average of the three numbers.

***************************************************************************************/

#include <stdio.h> // standard input and output functions library

#include <stdlib.h> // include library to execute command (system ("pause"); )

/*
The purpose of this program is to calculate the average of three numbers
*/

int main ( void )
{ // Program start here
int number1, number2, number3, averageValue;
int sum ;

number1= 35; // assign value to number1
number2= 45; //assign value to the number2
number3 = 55; // assign value to the number3

sum = number1+ number2+ number3; // add all three numbers

averageValue = sum / 3 ;

fprintf(stdout, "\n\n\t\tValue of first number is:\t%d", number1);
// %d is format specifier to represent number1

fprintf(stdout, "\n\n\t\tValue of second number is:\t%d", number2);
// %d is format specifier to represent number2

fprintf(stdout, "\n\n\t\tValue of third number is:\t%d", number3);
// %d is format specifier to represent number3

/*
Print sum and average values of these numbers

   */

fprintf(stdout, "\n\n\t\tSum of three Numbers is:\t%d", sum);
// prints the sum of three numbers

fprintf (stdout, "\n\n\t\tAverage of three numbers is:\t%d", averageValue);
// prints the average of three numbers

fprintf(stdout,"\n\n"); // bring the cursor on the new line

system("pause"); // this statement holds the display until any key is pressed

} // end of program

Type the source code given above. The output of the application is given below:
(Change the background of the display to white – this saves black   ink for printing)

The output of your program must look as shown above.
Calculate sum and average manually (calculator) for these three numbers (26, 35 and 45);

Sum : ________________
Average : ________________

What is the difference in actual value as well as the value calculated by C application?

If the two values are different, why are they different?

Make the relevant changes in the program so that the values displayed are correct.
Show what changes are made in the program.

Exercise: 2:
Objective:
Purpose of this assignment is to learn use of reading and writing data into specific format.
Use of fprintf or printf statements
a. Use of escape sequence in C Programming
b. Use of different variables
c. Use of format specifier

/****************************************************************************************
Name : Enter your Name here and Student # : Student number
Date:

*****************************************************************************************/

#include <stdio.h> // Directive to include the standard input/output library

int main (void)
{ // Program begins here

//Define data type variable here

int books_quantity;
float book_price;
float total_amount;
char name_initial;

// Print my name and student number

fprintf(stdout, "\n\t\t\t\tName:\t\t\\tYour Name\n\t\t\t\tStudent Number:\t\\tYour student Number");

// Now print message to enter quantity of books

printf ("\n Enter the quantity of books:\t\t");

// read the quantity of books

scanf("%d", &books_quantity);

// print the message to enter price of each book

fprintf(stdout, "\n\n Enter the price per book:\t\t$");

// read the price per book

scanf ("%f", &book_price);

// print the message to enter the initial of my first name

fprintf (stdout, "\n\n Enter the initial of your first name:\t\t");

// Before reading a character ensure that keyboard buffer does not have any
// redundant characters

fflush (stdin);

// Now read character representing your first name's initial

scanf("%c",&name_initial); // Calculate the total amount of books

total_amount = book_price * books_quantity; // Now Display all values

printf ("\n\n Quantity of Books:\t\t%d", books_quantity);
printf ("\n\n Price per book:\t\t$%.2f", book_price);
fprintf (stdout, "\n\n Total Amount of all the Books: $%.2f", total_amount);

fprintf(stdout, "\n\n Initial of First Name:\t\t %c", name_initial);

// flush any redundant character in the keyboard buffer

fflush(stdin); // hold the display
getchar(); // All ends well so return 0

return 0;

} // main block ends here

Attach your output here after building the application and execute the program – attach the output of your application below:

Now comment out the first fflush(stdin); (or remove the fflush(stdin) )statement in the application. Rebuild the code and execute the application. Input the data and attach the output of your application below:


What do you observe? What happened when fflush(stdin); was commented/removed?

Remove comment (//) (or add the first fflush(stdin); statement) from the first fflush(stdin); statement. Comment out the second fflush(stdin); (or remove statement (the statement just before the getchar() statement).
Rebuild your application, execute the application and enter the relevant inputs. What is your observation and explain? Attach your output now.

In: Computer Science

WRITE USING C++ CODE, TOPIC :Analysis of Algorithms Computer Science. PLEASE DONT FORGET RUNNING TIME In...

WRITE USING C++ CODE, TOPIC :Analysis of Algorithms Computer Science. PLEASE DONT FORGET RUNNING TIME

In this lab, you will implement Heap Sort algorithm for the same inputs.

For each algorithm, and for each n = 100, 200, 300, 400, 500, 1000, 4000, 10000, measure its running time and number of steps when the input is (1) already sort, i.e. n, n-1, …, 3, 2,1; (2) reversely sorted 1, 2, 3, … n; (3) random permutation of 1, 2, …, n; (4) 50 instances of n random numbers generated in the range of [1..n].

Note:

(1) You may have to repeat the algorithm many times, each time you need to initialize the array.

(2) Your running time should exclude the time for initialization.

(3) All measurement should be done in a single run, i.e. you do not need to run once for n=100, another time for n=200, etc

In: Computer Science

What is A- Atomic Action B- Critical Section . in OS in your own words with...

What is

A- Atomic Action

B- Critical Section .

in OS

in your own words with examples.

In: Computer Science

CSS Write a document wide style block (include the correct HTML tag) to set all <p>...

CSS

Write a document wide style block (include the correct HTML tag) to set all <p> tags to be double spaced and justified (not ragged left / right text)

In: Computer Science