Is the L(r1) = L(r2) where r1 = (ab*+c)(λ+∅) and r2 = (a+c)(b*+∅)? what are the languages of L(r1), L(r2)? show the definition's using regular expression, assume Σ = (a,b,c)
In: Computer Science
1. Which tag do you use to access an external style sheet? *
a) <a>
b) <head>
c) <style>
d) <link>
2. Which of the following CSS properties below specifies the name of the font to use? *
a) font-face
b) font-type
c) font-family
d) font-use
3. Choose the INVALID value for the area element’s shape attribute. *
a) square
b) rect
c) circle
d) poly
4. Which of these CSS properties DOES NOT have the top, right, left, and bottom specification? *
a) margin
b) border
c) padding
d) None of the above
c) circle
d) poly
5. The hover pseudo-class gives the author access to text styling under which situation? *
a) When the mouse is over an element.
b) When the mouse moves off of an element.
c) When the mouse is to the left of an element.
d) None of the above
6.CSS inline style requires _________ style in order to declare an individual element’s format. *
a) attribute
b) behaviour
c) tag
d) None of the above
7.Select the CORRECT CSS property in order to set image.jpg as the background image. *
a) background-image:url[image.jpg];
b) bground-image:url[image.jpg];
c) background-image:url(image.jpg);
d) bground-image:url(image.jpg);
8. In __________ positioning, elements are positioned relatively to other elements.
a) relative
b) absolute
c) surface
d) dynamic
In: Computer Science
Complete the code(in C) that inserts elements into a list. The list should always be in an ordered state.
#include <stdio.h>
#include <stdlib.h>
/* list of nodes, each with a single integer */
struct element {
struct element *next;
int value;
};
/* protypes for functions defined after main */
struct element *elementalloc(void);
struct element *listinitialize();
struct element *insertelement(struct element *, int);
void printlist(struct element *);
/* main
* Creates an ordered list
* Elements added to the list must be inserted maintaining the
list
* in an ordered state
*/
int main() {
struct element *listhead = NULL;
listhead = listinitialize();
for (int i = 3; i < 100; i+=11){
listhead = insertnewelement(listhead, i);
}
printlist(listhead);
}
/* allocate memory for a new list element */
struct element *elementalloc(void) {
return (struct element *)malloc(sizeof(struct element));
}
/* simple list initialization function */
struct element *listinitialize() {
const int numbers[7] = {4, 9, 13, 18, 27, 49, 60};
struct element *newlist = NULL;
struct element *tail = NULL;
struct element *temp = NULL;
for (int i = 0; i < 7; i++) {
if (newlist == NULL) {
newlist = elementalloc();
newlist->next = NULL;
newlist->value = numbers[i];
tail = newlist;
} else {
temp = elementalloc();
temp->value = numbers[i];
temp->next = NULL;
tail->next = temp;
tail = tail->next;
}
}
return newlist;
}
/* function to insert elements into an ordered list */
struct element *insertnewelement(struct element *listhead, int x)
{
struct element *newelement;
newelement = elementalloc();
struct element *iter = listhead;
while( ) {
}
return listhead;
}
/* print the list and the respective memory locations in list
order */
void printlist(struct element *listhead)
{
while (listhead != NULL) {
printf("Memory: %p contains value: %d\n", listhead,
listhead->value);
listhead = listhead->next;
}
}
In: Computer Science
Complete the code that inserts elements into a list. The list should always be in an ordered state.
#include <stdio.h>
#include <stdlib.h>
/* list of nodes, each with a single integer */
struct element {
struct element *next;
int value;
};
/* protypes for functions defined after main */
struct element *elementalloc(void);
struct element *listinitialize();
struct element *insertelement(struct element *, int);
void printlist(struct element *);
/* main
* Creates an ordered list
* Elements added to the list must be inserted maintaining the
list
* in an ordered state
*/
int main() {
struct element *listhead = NULL;
listhead = listinitialize();
for (int i = 3; i < 100; i+=11){
listhead = insertnewelement(listhead, i);
}
printlist(listhead);
}
/* allocate memory for a new list element */
struct element *elementalloc(void) {
return (struct element *)malloc(sizeof(struct element));
}
/* simple list initialization function */
struct element *listinitialize() {
const int numbers[7] = {4, 9, 13, 18, 27, 49, 60};
struct element *newlist = NULL;
struct element *tail = NULL;
struct element *temp = NULL;
for (int i = 0; i < 7; i++) {
if (newlist == NULL) {
newlist = elementalloc();
newlist->next = NULL;
newlist->value = numbers[i];
tail = newlist;
} else {
temp = elementalloc();
temp->value = numbers[i];
temp->next = NULL;
tail->next = temp;
tail = tail->next;
}
}
return newlist;
}
/* function to insert elements into an ordered list */
struct element *insertnewelement(struct element *listhead, int x)
{
struct element *newelement;
newelement = elementalloc();
struct element *iter = listhead;
while( ) {
}
return listhead;
}
/* print the list and the respective memory locations in list
order */
void printlist(struct element *listhead)
{
while (listhead != NULL) {
printf("Memory: %p contains value: %d\n", listhead,
listhead->value);
listhead = listhead->next;
}
}
In: Computer Science
Design and Requirements
In order to execute its task the program must compare character values. For instance, a character named symbol is an upper case letter if and only if the boolean expressions ‘A’ <= symbol and
symbol <= ‘Z’ both evaluate true. Analogous expressions can be used to check for lower case letters between ‘a’ and ‘z’ and for digits between ‘0’ and ‘9’. To see if symbol is the ‘$’ or ‘_’ character, the relational operator == shall be used.
Declare a String variable title to store the title of the window as shown in Figure 1 below.
Declare a String variable solicitation to store the input solicitation line, see the template in Figure 1.
Input is solicited on a dialog window as shown in Figure 1, follow the template layout including the icon. In the method that creates the window you must not use the String literals
Figure 1
Declare a String variable input and assign input the String value returned by the window
Validate the input: check out if input is null (the result of the Cancel button) or the empty string (OK button applied with no text written in the window). Empty Strings have zero length, thus input is not accepted if either input == null or input length == zero is true. Using the corresponding Java Boolean expression build an if block. Within the block print the message
No input to process
Program exits
to the console and apply the System.exit(0); statement to terminate the program (no else block is needed here).
Declare an int variable index and a char type variable symbol
Assign index 0 and symbol the the first character of input (use the index variable, not the 0 literal).
Declare two String variables named messageOK and messageNot_OK and assign the String values shown on the message dialogs of Figure 2 and Figure 3. Follow the output templates exactly, including the icons.
Figure 2 Figure 3
Apply an if-else structure to display Figure 2 or Figure 3 according to the cases of a correct or a wrong first character in input. Build a single boolean expression to control the if statement. In the JOptionPane method literals are not allowed, use the declared String variables messageOK or messageNot_OK.
In order to check the second character, re-assign index.
Before the check we have to see if there is a second character. Build and if – else structure, the if is controlled by the expression input.length()>=2
In the if block re-assign the variables symbol, messageOK and messageNot_OK
Copy the previous if – else code into this if block as a nested structure. The boolean expression that controls the nested if( ) must be fitted to the check of the second character (digits are allowed now)
In the else statement of the outer structure print the following message to the console:
There is no second character to check
In: Computer Science
Complete the code that inserts elements into a list. The list should always be in an ordered state.
#include <stdio.h>
#include <stdlib.h>
/* list of nodes, each with a single integer */
struct element {
struct element *next;
int value;
};
/* protypes for functions defined after main */
struct element *elementalloc(void);
struct element *listinitialize();
struct element *insertelement(struct element *, int);
void printlist(struct element *);
/* main
* Creates an ordered list
* Elements added to the list must be inserted maintaining the
list
* in an ordered state
*/
int main() {
struct element *listhead = NULL;
listhead = listinitialize();
for (int i = 3; i < 100; i+=11){
listhead = insertnewelement(listhead, i);
}
printlist(listhead);
}
/* allocate memory for a new list element */
struct element *elementalloc(void) {
return (struct element *)malloc(sizeof(struct element));
}
/* simple list initialization function */
struct element *listinitialize() {
const int numbers[7] = {4, 9, 13, 18, 27, 49, 60};
struct element *newlist = NULL;
struct element *tail = NULL;
struct element *temp = NULL;
for (int i = 0; i < 7; i++) {
if (newlist == NULL) {
newlist = elementalloc();
newlist->next = NULL;
newlist->value = numbers[i];
tail = newlist;
} else {
temp = elementalloc();
temp->value = numbers[i];
temp->next = NULL;
tail->next = temp;
tail = tail->next;
}
}
return newlist;
}
/* function to insert elements into an ordered list */
struct element *insertnewelement(struct element *listhead, int x)
{
struct element *newelement;
newelement = elementalloc();
struct element *iter = listhead;
while( ) {
}
return listhead;
}
/* print the list and the respective memory locations in list
order */
void printlist(struct element *listhead)
{
while (listhead != NULL) {
printf("Memory: %p contains value: %d\n", listhead,
listhead->value);
listhead = listhead->next;
}
}
In: Computer Science
Read the following specification and then answer the questions that follow. Specification:
A soccer league is made up of at least four soccer teams. Each soccer team is composed of seven(7) to eleven(11) players, and one player captains the team. A team has a name and a record of wins and losses. Players have a number and a position. Soccer teams play games against each other. Each game has a score and a location. Teams are sometimes lead by a coach. A coach has a level of accreditation and a number of years of experience, and can coach multiple teams. Coaches and players are people, and people have names and addresses.
Question: Carry out an initial object oriented design for the above specification.
You must identify and write down. Classes that you think will be required [5 marks]
Their attributes and behaviours [2 marks]
Any inheritance relationships you can identify [3 marks]
Any other relationships (aggregation or otherwise between the classes) [2 marks]
In: Computer Science
The questions in this assessment use the following.
class R { ... }
class A extends R { ... }
abstract class B extends R { ... }
final class C extends R { ...}
class D extends A { ... }
class E extends B { ... }
class F extends B { ... }
// none of the classes implement a toString() method
[0] Draw a class hierarchy for the classes defined above.
[1] No or Yes: class R extends Object
[2] class G extends C does not compile. Why?
[3] class G extends E, F does not compile. Why?
[4] B doh = new B(); does not compile. Why?
[5] System.out.println(new R()); prints: R@6bc7c054 Why?
[6] No or Yes: class D can have subclasses (children).
[7] If public String toString() { return "Arizona"; }
is added to class A, then System.out.println(new D());
prints what?
[8] Assume the following is added to class C.
public String toString() {
int azAgeIn2018 = 2018 - 1912;
return "Arizona is " + azAgeIn2018 + " years young!";
}
What does System.out.println(new C()); print?
[9] System.out.println(new R().hashCode()); prints: 1808253012.
No public int hashCode() method is implemented in class R.
Briefly explain why this compiles and runs?
[10] If public int hashCode() { return 48; } is added to
class R, then what does the following statement print?
System.out.println("Arizona is state# " + new R().hashCode());In: Computer Science
Write a Fortran program which simulates placing 100 molecules into the boxes of a 20 by 20 square grid. Each box can hold at most one molecule. Your program should count and report how many molecules in the final arrangement have no neighbors. Two molecules are considered neighbors if they are directly above or below or directly side by side (diagonals don't count). For instance, if molecules were placed at the locations labelled by letters in the following 5 by 5 grid:
* * * * b
a * d c *
* * * * *
* f * * e
* * * * g
we would say that d and c are neighbors and e and g are neighbors, but b and c are not. In this example, the three molecules a, b, and f have no neighbors. Your program would report that 3 of the 7 molecules are isolated. Your program should perform the experiment of placing 100 molecules into an empty lattice and reporting the results five times. The results should be neatly displayed in some readable format. Your final output should not include the full picture of the lattice (although that might be useful during debugging).
This problem has many natural opportunities to use subroutines and functions. In particular, I would like your program to use a subroutine MOLPUT to place the molecules into the grid. An easy way to represent the grid is an integer array where 0 represents empty and 1 represents a molecule at that location. MOLPUT should take a single argument, which is a 20 by 20 integer array, and return with one additional molecule added to the array. This subroutine, therefore, needs to generate random subscripts until it finds an empty position in the array and then mark that a molecule has been placed there. To perform an experiment, you can then just clear the array, call MOLPUT 100 times, and then check the results.
In: Computer Science
Complete the code that inserts elements into a list. The list should always be in an ordered state.
#include <stdio.h>
#include <stdlib.h>
/* list of nodes, each with a single integer */
struct element {
struct element *next;
int value;
};
/* protypes for functions defined after main */
struct element *elementalloc(void);
struct element *listinitialize();
struct element *insertelement(struct element *, int);
void printlist(struct element *);
/* main
* Creates an ordered list
* Elements added to the list must be inserted maintaining the
list
* in an ordered state
*/
int main() {
struct element *listhead = NULL;
listhead = listinitialize();
for (int i = 3; i < 100; i+=11){
listhead = insertnewelement(listhead, i);
}
printlist(listhead);
}
/* allocate memory for a new list element */
struct element *elementalloc(void) {
return (struct element *)malloc(sizeof(struct element));
}
/* simple list initialization function */
struct element *listinitialize() {
const int numbers[7] = {4, 9, 13, 18, 27, 49, 60};
struct element *newlist = NULL;
struct element *tail = NULL;
struct element *temp = NULL;
for (int i = 0; i < 7; i++) {
if (newlist == NULL) {
newlist = elementalloc();
newlist->next = NULL;
newlist->value = numbers[i];
tail = newlist;
} else {
temp = elementalloc();
temp->value = numbers[i];
temp->next = NULL;
tail->next = temp;
tail = tail->next;
}
}
return newlist;
}
/* function to insert elements into an ordered list */
struct element *insertnewelement(struct element *listhead, int x)
{
struct element *newelement;
newelement = elementalloc();
struct element *iter = listhead;
while( ) {
}
return listhead;
}
/* print the list and the respective memory locations in list
order */
void printlist(struct element *listhead)
{
while (listhead != NULL) {
printf("Memory: %p contains value: %d\n", listhead,
listhead->value);
listhead = listhead->next;
}
}
In: Computer Science
1. Implement the recursive factorial function given below (from the lecture notes on recursion). Develop a main program that allows the user to enter any integer (positive) integer value, and displays the factorial of that value. The program should allow the user to either keep entering another value, or quit the program. public static int factorial(int n) { if (n == 0 || n == 1) return (1); else return (n * factorial(n-1)); } 2. Determine the largest value for n that can be correctly computed. 3. Implement the recursive Towers of Hanoi function given below (from the lecture notes). Develop a main program that allows the user to enter any number of disks to solve. public static void towers(int numDisks, String startPeg, String destPeg, String sparePeg) { if (numDisks == 1) System.out.println("Move disk from " + startPeg + " to " + destPeg); else { towers(numDisks-1, startPeg, sparePeg, destPeg); System.out.println("Move disk from " + startPeg + " to " + destPeg); towers(numDisks-1, sparePeg, destPeg, startPeg); } } 4. Modify function towers so that all the print statements are disabled (i.e., comment them out). There needs to be a statement after if(numDisks …), so replace that with just numDisks = numDisks. (The compiler will actually remove this pointless statement.) Modify the main program so that “Starting towers …” is displayed right before the function is called, and “Finished towers” when completed (right after the function call). Run your program using this new version of the function (that does not display the moves) to determine how long it takes to complete for the following number of disks: 10, 20, 30, 32, 34, 36. Use your smart phone to determine each execution time to the nearest second. use java
In: Computer Science
Write a script that finds the smallest of several nonnegative integers. Assume that the first value read specifies the number of values to be input from the user.
Hint: No need for Array declaration. Think like a while loop and iterate as many number as users will input. Then keep a temporary variable to keep track of the minimum.
In: Computer Science
On your own words, define different types of Computer Networks and Network Topology and discuss how it work.
In: Computer Science
Write a C program that reads an integer value. Assume it is the number of a month of the year; print out the name of that month (Hint: months need to be captured in an array).
In: Computer Science
Python Programming Exercise Scenario:
Write a program that asks the user to enter scores the number is based on what the user wants to enter. The program will display a letter grade and associated message for each score, based on the table below, and the average score. The program will not contain any repeated code and have a minimum of two functions besides Main.
Score Letter Grade Message
90 – 100 A Excellent work
89 – 80 B Nice job
79 – 70 C Not bad
69 – 60 D Room for improvement
Below 60 F Go back and review
In: Computer Science