Questions
Lab Assignment Write a Java program that implements a queue in a hospital. I want your...

Lab Assignment

Write a Java program that implements a queue in a hospital. I want your program to ask the user to enter the number of patients then enter the patient number starting from 110 till the end of the queue then print number of patients waiting in the queue.

Suppose you have a queue D containing the numbers (1,2,3,4,5,6,7,8), in this order. Suppose further that you have an initially empty Stack S. Give a code fragment that uses S, to store the elements in the order (8,7,6,5,4,3,2,1) in D.

Q. What values are returned during the following sequence of queue operations, if executed on an initially empty queue?

enqueue(5), enqueue(3), dequeue(),

enqueue(2), enqueue(8), dequeue(), dequeue(), enqueue(9), enqueue(1),

dequeue(), enqueue(7), enqueue(6), dequeue(), dequeue(), enqueue(4),

dequeue(), dequeue().

In: Computer Science

Sub: cloud computing Based on below scenario answer the question With DTGOV’s client portfolio expanding to...

Sub: cloud computing

Based on below scenario answer the question

With DTGOV’s client portfolio expanding to include public-sector organizations, many of it cloud computing policies have become unsuitable and require modification. Considering that public-sector organizations frequently handle strategic information, security safeguards needs to be established to protect data manipulation and to establish a means of auditing activities that may impact government operations.
What security measures would have been implemented by DTGOV to resolve this?

In: Computer Science

Write a program in java that asks the name of the buyer and the number of...

Write a program in java that asks the name of the buyer and the number of shares bought. Your program must then calculate and display the following. sold stock/shares to the general public at the rate of $24.89 per share. Theres a 2 percent (2%) commission for the transaction.

Outputs need

Amount paid for buying the stock ($)

Amount paid for the commission ($)

Total amount ($)

In: Computer Science

Subject: cloud computing Based on below case, answer the question The migration of applications to ATN’s...

Subject: cloud computing

Based on below case, answer the question

The migration of applications to ATN’s new PaaS platform was successful, but also raised a number of new concerns pertaining to the responsiveness and availability of PaaS-hosted IT resource. ATN intends to move more applications to a PaaS platform, but decides to do so by establishing a second PaaS environment with a different cloud provider. This will allow them to compare cloud providers during a three month assessment period. Discuss on what different features the organization will consider when planning to make a comparison

In: Computer Science

AverageGrade. Assume the professor gives five exams during the semester with grades 0 through 100 and...

AverageGrade. Assume the professor gives five exams during the semester with grades 0 through 100 and drops one of the exams with the lowest grade. Write a program to find the average of the remaining four grades. The program should use a class named Exams that has

1. An instance variable to hold a list of five grades,

2. A method that calculate and return average.

3. A string that return the “exams Average” for printing.

Your program output should prompt for an input for each grade. Use any number between 0 and 100. Your submission should include compiled output.

In: Computer Science

Discuss the importance of SCM for Travelfast. Evaluate few SCM solutions available, and suggest which solution...

Discuss the importance of SCM for Travelfast. Evaluate few SCM solutions available, and suggest which solution would be appropriate for Travelfast. What are some of the possible challenges Travelfast will face in implementing for adoption of SCM in Travelfast.travel fast is an imaginary based on transport company this is for essay so provide a long answer

I have to write 2500 words so could you plz provide like around 1500 words answer it would be great

In: Computer Science

The signature of each function is provided below, do not make any changes to them otherwise...

The signature of each function is provided below, do not make any changes to them otherwise the tester will not work properly. The following are the functions you must implement:

mashup(lst) [20pts]

Description: Creates a new string that is based on the provided list. Each number in the list specifies how many characters from the string that follows belong in the resulting string. Parameters: lst is a list of variable size, that contains alternating ints and strings Assumptions: When a pair of values doesn’t make sense, throw out that pair. When you have an empty string in the list, move on to the next pair. When you have a number that is larger than the length of the string, move on to the next pair, etc. Return value: the new string that is generated from the replacements Examples: mashup([2, 'abc', 1, 'def']) → 'abd' mashup([3, 'rate', 2, 'inside', 1, 'goat']) → 'rating'

expand(numbers, amount) [20pts]

Description: Given a list of numbers it returns that same list that has been expanded with a certain amount of zeroes around all of the numbers, including at the beginning and end of the list. Parameters: numbers is a list of mixed int and float Assumptions: You will always have at least one element in numbers. amount will be >= 0 Return value: Nothing is returned. The swapping occurs in-place, i.e. you modify numbers itself Examples: ls = [1,2,3] expand(ls, 1) # nothing is returned! print(ls) # prints [0,1,0,2,0,3,0] ls = [1.5, -6, 4, 0] expand(ls, 2) # nothing is returned! print(ls) # prints [0, 0, 1.5, 0, 0, -6, 0, 0, 4, 0, 0, 0, 0, 0]

Assumptions for the following two problems: There will be at least one row and one column in the matrix. All rows will have the same number of elements.

squarify(matrix) [25pts]

Description: Determine the size of the largest square that can be made with the given matrix. Construct a new square matrix of this size using the elements from the original matrix in their original order. Parameters: matrix (list of lists of int) Return value: A new matrix (list of lists of int) Examples: ls = [[1,2,3,4],[5,6,7,8],[9,10,11,12]] new_ls = squarify(ls) print(new_ls) # prints [[1, 2, 3], [5, 6, 7], [9, 10, 11]]

apply(mask, matrix) [25pts]

Description: Given a matrix, apply the mask. The matrix is some MxN list of list of ints, and the mask is exactly a 2x2 list of lists of ints. Imagine you overlay the mask on top of the matrix, starting from the top left corner. There will be 4 places that overlap. Add each pair of numbers that are overlapped, and update the original matrix with this new value. Shift the mask down the row of the matrix to the next 2x2 that hasn't been updated already, and continue this process. Keep doing this down the columns as well. If you are on an edge and only a piece of the mask overlaps, you can ignore the other numbers and only update the overlapping portion. Parameters: matrix (MxN list of list of ints) and mask (2x2 list of list of ints) Return value: Nothing is returned. The updating occurs in-place, i.e. you modify matrix itself Examples: ls = [[1,2],[3,4]] apply([[1,1],[1,1]], ls) # nothing is returned! print(ls) # prints [[2, 3], [4, 5]] ls = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] apply([[1,1],[1,1]], ls) # nothing is returned! print(ls) # prints [[2, 3, 4], [5, 6, 7], [8, 9, 10]] ls = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]] apply([[1,0],[0,1]], ls) # nothing is returned! print(ls) # prints [[2, 2, 4], [4, 6, 6], [8, 8, 10], [10, 12, 12]]

In: Computer Science

Write down an algorithm in pseudo-code whose running time where input is an array whose length...

  1. Write down an algorithm in pseudo-code whose running time where input is an array whose length defines the problem size. Take the cost of execution of each line of the algorithm as 1.

  1. Make comment about the following paragraph:

“You are given two independent algorithms and whose running time complexities are and , respectively. If we add a new line to our algorithm in which it calls the algorithm then the running time complexity of the modified algorithm becomes ”.

In: Computer Science

1. What will print? int[][] numbers = { { 1, 2, 3, 4 },{ 5, 6,...

1. What will print?
int[][] numbers = { { 1, 2, 3, 4 },{ 5, 6, 7, 8 },{ 9, 10, 11, 12 } };
System.out.println(numbers[1][3]);

a) 13

b) 4

c) 8

d) 12

2. With what value does currYear = yearsArr[2] assign currYear?
int[ ] yearsArr = new int[4];
yearsArr[0] = 1999;
yearsArr[1] = 2012;
yearsArr[2] = 2025;         

a) 4

b) 1999

c) 2012

d) 2025

3. What will print?
String [][] names = { { "Elliot", "Darlene", "Angela", "Tyrell" },
{ "Joanna", "Phillip", "Tomero", "Trenton" },
{ "Mobley", "Whiterose", "Cisco", "Leon", "Mr. Robot" } };
System.out.println(names[2][4]);

a) Elliot

b) Angela

c) Joanna

d) Mr. Robot

4. What will print?
int[][] myNumbers = { {1, 2, 3, 4}, {5, 6, 7, 8}, {1, 2, 3, 4} };
int x = myNumbers[2][2];
System.out.println(x);

a) 5

b) 3

c) 7

d) 8

5. What will print?
int[][] myNumbers = { {1, 2, 3, 4}, {5, 6, 7, 8} };
int x = myNumbers[1][2];
System.out.println(x);

a) 5

b) 3

c) 7

d) 8

In: Computer Science

Consider two sets of integers represented in arrays, X = [x1, x2, . . . ,...

Consider two sets of integers represented in arrays, X = [x1, x2, . . . , xn] and Y =
[y1, y2, . . . , yn]. Write two versions of a FindSetUnion(X, Y ) algorithm to find the union of X
and Y as an array. An element is in the union of X and Y if it appears in at least one of X and Y .
You may make use any algorithm introduced in the lectures to help you develop your solution. That
is, you do not have to write the ‘standard’ algorithms – just use them. Therefore, you should be able
to write each algorithm in about 10 lines of code. You must include appropriate comments
in your pseudocode.

question:

(a) [2 Marks] Write a pre-sorting based algorithm of FindSetUnion(X, Y ). Your algorithm
should strictly run in O(n log n).
(b) [2 Marks] Write a Hashing based algorithm of FindSetUnion(X, Y ). Your algorithm should
run in O(n).

In: Computer Science

Python language!!!!! №1 The translation from the Berland language into the Birland language is not an...

Python language!!!!!

№1

The translation from the Berland language into the Birland language is not an easy task. Those languages are very similar: a berlandish word differs from a birlandish word with the same meaning a little: it is spelled (and pronounced) reversely. For example, a Berlandish word code corresponds to a Birlandish word edoc. However, it's easy to make a mistake during the «translation». Vasya translated word s from Berlandish into Birlandish as t. Help him: find out if he translated the word correctly.

Input

The first line contains word s, the second line contains word t. The words consist of lowercase Latin letters. The input data do not consist unnecessary spaces. The words are not empty and their lengths do not exceed 100 symbols.

Output

If the word t is a word s, written reversely, print YES, otherwise print NO.

Examples

input

code
edoc

output

YES

№2

Anton likes to play chess, and so does his friend Danik.

Once they have played n games in a row. For each game it's known who was the winner — Anton or Danik. None of the games ended with a tie.

Now Anton wonders, who won more games, he or Danik? Help him determine this.

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of games played.

The second line contains a string s, consisting of n uppercase English letters 'A' and 'D' — the outcome of each of the games. The i-th character of the string is equal to 'A' if the Anton won the i-th game and 'D' if Danik won the i-th game.

Output

If Anton won more games than Danik, print "Anton" (without quotes) in the only line of the output.

If Danik won more games than Anton, print "Danik" (without quotes) in the only line of the output.

If Anton and Danik won the same number of games, print "Friendship" (without quotes).

Examples

input

6
ADAAAA

output

Anton

№3

You can not just take the file and send it. When Polycarp trying to send a file in the social network "Codehorses", he encountered an unexpected problem. If the name of the file contains three or more "x" (lowercase Latin letters "x") in a row, the system considers that the file content does not correspond to the social network topic. In this case, the file is not sent and an error message is displayed.

Determine the minimum number of characters to remove from the file name so after that the name does not contain "xxx" as a substring. Print 0 if the file name does not initially contain a forbidden substring "xxx".

You can delete characters in arbitrary positions (not necessarily consecutive). If you delete a character, then the length of a string is reduced by 11. For example, if you delete the character in the position 22 from the string "exxxii", then the resulting string is "exxii".

Input

The first line contains integer nn (3≤n≤100)(3≤n≤100) — the length of the file name.

The second line contains a string of length nn consisting of lowercase Latin letters only — the file name.

Output

Print the minimum number of characters to remove from the file name so after that the name does not contain "xxx" as a substring. If initially the file name dost not contain a forbidden substring "xxx", print 0.

Examples

input

6
xxxiii

output

1

In: Computer Science

write a persuasive essay of 250 words about the use of technology .

write a persuasive essay of 250 words about the use of technology .

In: Computer Science

Implement a dictionary application using C++ with the following features: Load a dictionary file. Given a...

Implement a dictionary application using C++ with the following features:

  • Load a dictionary file.

  • Given a prefix string that the user specifies, print the first word or all words in the dictionary with that string as their prefix.

  • Given two strings A and B that the user specifies, replace all occurrences of A in the dictionary file with B.

  • Spawning a new editor (e.g., vim) to allow the user to modify the dictionary file. Save the dictionary file afterwards.

You must use either C or C++ to implement your dictionary application. All your source code must be put within one (1) file. You will only submit that one file.

Your program should not have any extra library dependencies.

Please provide the coding in C++.

In: Computer Science

Person class You will implement the Person Class in Visual Studio. A person object may be...

Person class
You will implement the Person Class in Visual Studio. A person object may be associated with multiple accounts. A person initiates activities (deposits or withdrawal) against an account that is captured in a transaction object.
A short description of each class member is given below:

Person
Class
Fields
-   password : string

Properties
+   «C# property, setter private» IsAuthenticated : bool
+   «C# property, setter absent» SIN : string
+   «C# property, setter absent» Name : string

Methods
+   «Constructor» Person(name : string, sin : string)
+   Login(password : string) : void
+   Logout() : void
+   ToString() : string


Fields:
⦁   password – this private string field represents the password of this person.
(N.B. Password are not normally stored as text but as a hash value. A hashing function operates on the password and the result is stored in the field. When a user supplies a password it is passed through the same hashing function and the result is compared to the value of the field.).
Properties:
⦁   SIN – this string property represents the sin number of this person. This getter is public and setter is absent.
⦁   IsAuthenticated – this property is a bool representing if this person is logged in with the correct password. This is modified in the Login() and the Logout() methods. This is an auto-implemented property, and the getter is public and setter is private
⦁   Name – this property is a string representing the name of this person. The getter is public and setter is absent.
Methods:
⦁   public Person( string name, string sin ) – This public constructor takes two parameters: a string representing the name of the person and another string representing the SIN of this person. It does the following:
⦁   The method assigns the arguments to the appropriate fields.
⦁   It also sets the password to the first three letters of the SIN. [use the Substring(start_position, length) method of the string class]
⦁   public void Login( string password ) – This method takes a string parameter representing the password and does the following:
⦁   If the argument DOES NOT match the password field, it does the following:
⦁   Sets the IsAuthenticated property to false
⦁   Creates an AccountException object using argument AccountEnum.PASSWORD_INCORRECT
⦁   Throws the above exception
⦁   If the argument matches the password, it does the following:
⦁   Sets the IsAuthenticated property is set to true
This method does not display anything
⦁   public void Logout( ) – This is public method does not take any parameters nor does it return a value.
This method sets the IsAuthenticated property to false
This method does not display anything
⦁   public override string ToString( )– This public method overrides the same method of the Object class. It returns a string representing the name of the person and if he is authenticated or not.
ITransaction interface
You will implement the ITransaction Interface in Visual Studio. The three sub classes implement this interface.
A short description of each class member is given below:

ITransaction
Interface
Methods
   Withdraw(amount : double, person : Person) : void
   Deposit(amount : double, person : Person) : void


Methods:
⦁   void Withdraw(double amount, Person person).
⦁   void Deposit(double amount, Person person).

Transaction class
You will implement the Transaction Class in Visual Studio. The only purpose of this class is to capture the data values for each transaction. A short description of the class members is given below:
All the properties are public with the setter absent.
Transaction
Class
Properties
+   «C# property, setter absent » AccountNumber : string
+   «C# property, setter absent» Amount : double
+   «C# property, setter absent» Originator : Person
+   «C# property, setter absent» Time : DateTime

Methods
+   «Constructor» Transaction(accountNumber : string, amount : double, endBalance : double, person : Person, time : DateTime)
+   ToString() : string

Properties:
All the properties are public with the setter absent
⦁   AccountNumber – this property is a string representing the account number associated with this transaction. The getter is public and the setter is absent.
⦁   Amount – this property is a double representing the account of this transaction. The getter is public and the setter is absent.
⦁   Originator – this property is a Person representing the person initiating this transaction. The getter is public and the setter is absent.
⦁   Time – this property is a DateTime (a .NET built-in type) representing the time associated with this transaction. The getter is public and the setter is absent.
Methods:
⦁   public Transaction( string accountNumber, double amount, Person person, DateTime time ) – This public constructor takes five arguments. It assigns the arguments to the appropriate fields.
⦁   public override string ToString( ) – This method overrides the same method of the Object class. It does not take any parameter and it returns a string representing the account number, name of the person, the amount and the time that this transition was completed. [you may use ToShortTimeString() method of the DateTime class]. You must include the word Deposit or Withdraw in the output.
A better type would have been a struct instead of a class.
ExceptionEnum enum
You will implement this enum in Visual Studio. There are seven members:
ACCOUNT_DOES_NOT_EXIST,
CREDIT_LIMIT_HAS_BEEN_EXCEEDED,
NAME_NOT_ASSOCIATED_WITH_ACCOUNT,
NO_OVERDRAFT,
PASSWORD_INCORRECT,
USER_DOES_NOT_EXIST,
USER_NOT_LOGGED_IN
The members are self-explanatory.
AccountException class
You will implement the AccountException Class in Visual Studio. This inherits from the Exception Class to provide a custom exception object for this application. It consists of seven strings and two constructors:
AccountException
Class
→ Exception
Fields

Properties

Methods
+   «Constructor» AccountException(reason : ExceptionEnum)


Fields:
There are no fields
Properties:
There are no properties
Methods:
⦁   AccountException( ExceptionEnum reason )– this public constructor simply invokes the base constructor with an appropriate argument. Use the ToString() of the enum type.

In: Computer Science

M = [4,3,7,6,5,2,4,1,0,7] Construct a binary search tree for M. Then traverse it (post order)

M = [4,3,7,6,5,2,4,1,0,7]

Construct a binary search tree for M. Then traverse it (post order)

In: Computer Science