create a regular expression in Java that defines the
following.
A "Stir" is a right brace '}' followed by zero or more
lowercase letters 'a' through 'z' and decimal digits '0'
through '9', followed by a left parenthesis '('.
In: Computer Science
Define a regular expression in JAVA for the following
An "Ent" is an at sign '@', followed by one or more
decimal
digits '0' through '9' or uppercase letters 'R' through 'W',
followed by an octothorpe sign '#'
In: Computer Science
Using STL stack class, implement in C++ the following pseudocode function
checkBraces(aString: string) that checks for balanced braces { } in a given string /
arithmetic expressions. Write a main() program to test the function.
// Checks the string aString to verify that braces match.
// Returns true if aString contains matching braces, false otherwise.
checkBraces(aString: string): boolean{
aStack = a new empty stack
balancedSoFar = true
i =0
// Tracks character position in string
while (balancedSoFar and i < length of aString) {
ch = character at position i in aString i++
// Push an open brace
if (ch is a '{')
aStack.push('{')
// Close brace
else if (ch is a '}')
{ if (!aStack.isEmpty())
aStack.pop() // Pop a matching open brace
else
balancedSoFar = false
}
// No matching open brace // Ignore all characters other than braces
}
if (balancedSoFar and aStack.isEmpty())
aString has balanced braces else
aString does not have balanced braces
}
In: Computer Science
I have an access link to the internet (Institutional Router to Internet Router) that is 1 Gbps access link. Suppose that on my network there are typically 1000 Requests/second going to the Internet that are each 1 Mbits. Calculate the traffic intensity on the access link. What does this number imply about delays on my network?
In: Computer Science
using c++
E2b: Design a class named Rectangle to represent a rectangle. The class contains:
(1) Two double data members named width and height which specifies the width and height of the rectangle .
(2) A no-arg constructor that creates a rectangle with width 1 and height 1.
(3) A constructor that creates a rectangle with the specified width and height .
(4) A function named getArea() that returns the area of this rectangle .
(5) A function named getPerimeter() that returns the perimeter of this rectangle .
Your solution:
Output:
In: Computer Science
Unix/Linux
Turn in the following commands and any output from the commands.
1) ll to show the original 3 files
2) run the tar command to stuff three files
3) ll to show the 'tar archive'
4) mkdir newdir to create a new directory to unstuff the 'tar
archive'
In: Computer Science
Unix/Linux
1)
Use the find command to find all directories under /pub/cs/ whose
name is cs160a. Be sure to only display the results that match, do
not display any error output.
Hint: use: 2>/dev/null.
2)
Create a one-line command, using he famous.dat file, to add the
word " STREET" to the address, for all who live on 2nd or
3rd.
For example: '2nd' becomes "2nd STREET" and '3rd' becomes "3rd
STREET".
Display only the first 9 lines.
Hint: use 2 sed statements with pipes.
3)
Display all lines in famous.dat that end in 0 or 1, and have a 1 in
the 3rd from the last column.
For example lines ending in 120 and 131 would be displayed.
4)
Display all lines in famous.dat that have only 4, 5, 6, 7 and 9 in
the zip code.
HINT: this is the same as NOT 0,1,2,3 or 8.
5)
Using only the grep command, search all files with names that end
in either .html or .htm under the$HOME/public_html directory and
display any lines that contain body tags (containing
''). No other output should be displayed even if there
is no public_html directory.
Hint: use two command arguments and 2>
In: Computer Science
Lara owns a flower shop, where she sells only two types of flower bouquets Type 1: The first type of bouquet contains three roses and costs p dollars. Type 2: The second type of bouquet contains one cosmos and one rose and costs q dollars Lara grows these flowers in her own garden in a single row. Consider the row as a one-dimensional array where each cell either contains a rose or a cosmos. For example array 001101011 here 0 indicates rose and 1 indicates cosmos. Lara follows an important rule when she makes the bouquets: she makes each bouquet with only consecutive flowers from the array. For example, in a bouquet, the flower from consecutive indices (i, i+1, and i+2) in the array can be present, but not from non-consecutive indices (i and i+2). In the array above, Lara cannot make any bouquets of type 1 but she can make 3 bouquets of type 2 Now she wonders what is the maximum profit she can make if she makes these bouquets optimally. You are given a binary string representing her garden row. Calculate the maximum profit Lara can make. Remember that it is not necessary to use every flower. Function Description Complete the flowerBouquets function in the editor below. The function must return an integer that denotes the maximum profit Lara can make if she makes her bouquets optimally flowerBouquets has three parameters: p: integer denoting the cost of a bouquet of type 1 q: integer denoting the cost of a bouquet of type 2 s: string denoting the garden pattern, where zero indicates rose and one indicates cosmos Constraints 1 sp, q s1000
In: Computer Science
Project Title: Creating Company E-mail and WIFI / Internet Use Policies Attached you will find a description of your final project assignment
In: Computer Science
Algorithm and Data Structures
Suppose the unweighted graph graph G = (V, E), represents connections between cities in a country. Salesman wants to get from city A to city P using the unweighted graph G = (V, E) of cities.
a) Explain how the salesman use BFS algorithm to get from city A to city P passing smallest number of cities. (all steps required)
b) Now the salesman likes to visit city R on his way to city P. Describe an efficient algorithm that would determine an optimal number of cities that the salesman would pass to get from city A to city P through city R. (Consider all the possible cases) (using BFS/Dijkstra's, ALL CASES AND STEPS REQUIRED)
c) What is the total running time of each of your algorithms above? (there may be 2 different running times)
In: Computer Science
Question 3: What do the following vim commands do in command mode?
ZZ
:w!
i
dd
x
yy
p
Question 4: Review the following code. If you were to print out all the dereferenced values of the three pointer variables and the array, what is the output?
(note: if possible explain how the output changed.)
int array[] = { 30, 40, 50, 60, 70, 80 };
int *ptrA = array;
int *ptrB = ptrA + 4;
int *ptrC = ptrB--;
array[ 1 ] = 2;
*ptrB = *ptrC - 2;
*ptrC = 100;
array[ 3 ] = *ptrA++;
ptrC = ptrB + 2;
In: Computer Science
(IN C)
What are the contents of the array after the for-loop in the following code?
int array[ SIZE ][ SIZE ] = { { 4, 5, 6, 7, 8 },
{ 1, 2, 3, 4, 5 },
{ 3, 6, 7, 8, 9 },
{ 2, 3, 4, 5, 6 },
{ 5, 6, 7, 8, 9 } };
int i;
int *ptr = array[ 0 ];
for( i = 0; i < SIZE * SIZE; i++ ) {
if( i % SIZE < 2 ) {
*( ptr + i ) = 0;
}
else if( i % SIZE == 2 ) {
*( ptr + i * SIZE ) = 100;
}
}
In: Computer Science
(IN C)
Program Question 2: Write a program that solves for c in the Pythagorean Theorem: a2 + b2 = c2 The user will enter values for a and b, and you will calculate c. All of this code will go in just one source file.
In: Computer Science
A set of hypothesis and a conclusion are given. Use the valid argument forms to deduce the conclusion from the hypothesis.
(i) p v q,
(ii) q ->r,
(iii)(p^s) ->t,
(iv) not r,
(v) (not q) -> (u ^ s)
(vi) t
In: Computer Science
(Salary Calculator) Develop a Java application that determines the gross pay for each of three employees. The company pays straight time for the first 40 hours worked by each employee and time and a half for all hours worked in excess of 40. You’re given a list of the employees, their number of hours worked last week and their hourly rates. Your program should input this information for each employee, then determine and display the employee’s gross pay. Use class Scanner to input the data.
In: Computer Science