Write, in Python, a recursive algorithm that takes, as input, a positive integer n, and returns, as output, the sum of the first n positive odd integers. Your solution should be recursive, and it should not contain any "for" loops or "while" loops.
In: Computer Science
You want to use a packet firewall to protect the Hospital network but you are hesitant to choose the right location among the following: putting it on the web server at DMZ, putting it along with the IDS server, putting it on the screened subnet with DMZ, or putting it on the domain boundary. Recommend the right answer with justification as to why or why not.
In: Computer Science
A Retail company is extending the company network to support extra branches in another country. Answer the following questions:
1. You want to mitigate internal and external threats facing the company network by using different security network components. Choose among the use of static IP addressing, NAT, securing and analysing the system access logs. Choose the most appropriate option and rationalize your answer.
2. Evaluate the use of VPN and propose an alternate solution for a company to expand their existing VPN network to another country e.g. New Zealand. In proposing an alternate VPN network design, consider the following factors: 150 new users added 5 users in New Zealand 20% growth of users in 4 years for the entire network
3. Discuss key aspects of this scenario in terms of a) efficiency, b) security, and c) scalability for future expansion.
In: Computer Science
Consider the University Database with the following relations:
Professors (pid, pname, dept, ext)
Students (sid, sname, major-dept, year)
Courses (cid, cname, dept, credithours)
Enrollment (sem-year, sid, cid, grade)
Teaches (pid, cid, sem-year, class-size)
where,
Professors: All professors have professor id (pid), name (pname), department that they work (dept), and a phone number extension for their office (ext).
Students: All students have id (sid), name (sname), department for their major (major-dept), and a year (year i.e, freshman, sophomore, junior, etc). Courses: All courses have a course id (cid), course name (cname), department (dept), and total credit hours (credithours).
Enrollment: has a semester year (sem-year), enrolled student id (sid), course id (cid), and grade that student earns (grade).
Teaches: has a professor id (pid), course id (cid), semester year (sem-year), and class size (class-size).
Attributes “dept” in relations Professors and Courses, and attribute “major-dept” in relation Students have the same domain, and have values like “CDS”, “EE”, “CE”, etc. Attribute “sem-year” has values like “Spring2016”, “Fall2015”, etc. Assume that cids are unique, i.e. if there are multiple sections of a course, each section has a unique cid.
Express the queries below using Relational Algebra.
1. Find sids, names and major-dept of students who enrolled in a course that is taught by professor James.
2. Find pid and names of professors who teach no courses in “Fall2015”.
3. Find cid and cname of courses that are offered by “CDS” department that are taught by professors who are from another department in “Fall2015".
4. Find pid and names of professors who teach only courses offered by “CDS” department.
5. Find pnames and pids of professors who teach every course offered by “CDS” dept.
6. Find sids of students who enroll in “Fall2015” every 3 credit hour course offered by “CDS” department.
7. Find cids and names of courses in which every student majoring in “CDS” enrolled in “Fall2015”.
In: Computer Science
11. Write an application case study with network design diagram including the following topics: [10 Marks] - IoT -
Bluetooth - Fog Computing - Redundant - Resilient and measures of resilience - Troubleshooting with half split and move method Highlight in bold each of the above keywords.
In: Computer Science
You are an IT company and want to get a daycare's network design, hardware, software, and security. Project resources allocation. List all types of resources (e.g. human and non-human) you will use them in the enterprise network project. How are you planning to use those resources cost-effectively?
In: Computer Science
Write a Java program (use JDBC to connect to the database) that implements the following function (written in pseudo code): (20 points) CALL RECURSION ( GIVENP# ) ; RECURSION: PROC ( UPPER_P# ) RECURSIVE ; DCL UPPER_P# ... ; DCL LOWER_P# ... INITIAL ( ' ' ) ; EXEC SQL DECLARE C CURSOR FOR SELECT MINOR_P# FROM PART_STRUCTURE WHERE MAJOR_P# = :UPPER_P# AND MINOR_P# > :LOWER_P# ORDER BY MINOR_P# ; print UPPER_P# ; DO "forever" ; EXEC SQL OPEN C ; EXEC SQL FETCH C INTO :LOWER_P# ; EXEC SQL CLOSE C ; IF no "lower P#" retrieved THEN RETURN ; END IF ; IF "lower P#" retrieved THEN CALL RECURSION ( LOWER_P# ) ; END IF ; END DO ; END PROC ; Given the value of the input parameter ‘P1’, it should print out the following sequence (in the exact same order) for the table in Q1: P1 P2 P3 P5 P6 P4 P5 P6 P3 P5 P6
In: Computer Science
A company sells a product for a retail price of $100. It offers quantity discounts based on the table below
Quantity | Discount |
10-19 |
10% |
20-49 | 20% |
50-99 | 30% |
100 or more | 40% |
Write a program that asks user for enter the quantity of product they want to purchase. It should then display the discount amount (if any) and the total purchase amount after the discount. The output should be displayed with 2 decimal points as shown below.
See a sample output
Enter the quantity of the product you want to purchase: 30
Discount Amount: $ 600.00
Total Purchase Amount: $ 2400.00
Refer the rubric and coding standards documents. Make sure you submit by 11:59 pm of the due date. Make sure you write the analysis/design algorithm along with properly documented code. Do not forget to attach your SDM as either another document or as a submission text when you submit your homework
In: Computer Science
In Java:
int[] A = new int[2];
A[0] = 0; A[1] = 2;
f(A[0],A[A[0]]);
void f(int x, int y) {
x = 1; y = 3;
}
For each of the following parameter-passing methods, saw what the final values in the array A would be, after the call to f. (There may be more than one correct answer.)
a. By value. b. By reference. c. By value-result.
In: Computer Science
'''
Problem 1: Formin' Functions
Define and complete the functions described below.
The functions are called in the code at the very bottom. So you
should be
able simply to run the script to test that your functions work as
expected.
'''
'''
* function name: say_hi
* parameters: none
* returns: N/A
* operation:
Uhh, well, just say "hi" when called. And by "say" I mean
"print".
* expected output:
>>> say_hi()
hi
'''
'''
* function name: personal_hi
* parameters: name (string)
* returns: N/A
* operation:
Similar to say_hi, but you should include the name argument in the
greeting.
* expected output:
>>> personal_hi("Samantha")
Hi, Samantha
'''
'''
* function name: introduce
* parameters: name1 (string)
name2 (string)
* returns: N/A
* operation:
Here you are simply including the two names in a basic
introduction.
* expected output:
>>> introduce("Samantha","Jerome")
Samantha: Hi, my name is Samantha!
Jerome: Hey, Samantha. Nice to meet you. My name is Jerome.
'''
# FUNCTIONS ARE CALLED BELOW HERE...NO NEED TO TOUCH ANYTHING
# UNLESS YOU WANT TO COMMENT SOMETHING OUT TO TEST THINGS
# ALONG THE WAY...
say_hi()
personal_hi("Larry")
personal_hi("Naomi")
introduce("Larry","Naomi")
In: Computer Science
Q3. Networking commands – ping, mount, hosts, netstat
HINT: Remember the IP address of the UNIX server.
In: Computer Science
Question - Write a Client class with a main method that tests the data structures as follows:
public class ArrayStack<E> implements Stack<E>
{
public static final int CAPACITY=1000; // default array
capacity
private E[ ] data; // generic array used for storage
private int t = -1; // index of the top element in stack
public ArrayStack( ) { this(CAPACITY); } // constructs stack with
default capacity
public ArrayStack(int capacity) { // constructs stack with given
capacity
data = (E[ ]) new Object[capacity]; // safe cast; compiler may give
warning
}
public int size( ) { return (t + 1); }
public boolean isEmpty() {return (t == -1); }
public void push(E e) throws IllegalStateException {
if (size( ) == data.length) throw new IllegalStateException("Stack
is full");
data[++t] = e; // increment t before storing new item
}
public E top( ) {
if (isEmpty( )) return null;
return data[t];
}
public E pop( ) {
if (isEmpty( )) return null;
E answer = data[t];
data [t] = null; // dereference to help garbage collection
t--;
return answer;
}
}
LinkedStack code:
public class LinkedStack<E> implements Stack<E>
{
private SinglyLinkedList<E> list = new
SinglyLinkedList<>( ); // an empty list
public LinkedStack( ) { } // new stack relies on the initially
empty list
public int size( ) { return list.size( ); }
public boolean isEmpty( ) { return list.isEmpty( ); }
public void push(E element) { list.addFirst(element); }
public E top( ) { return list.first( ); }
public E pop( ) { return list.removeFirst( ); }
}
public class ArrayQueue<E> implements Queue<E>
{
// instance variables
private E[ ] data; // generic array used for storage
private int f = 0; // index of the front element
private int sz = 0;
private static int CAPACITY = 1000;
// current number of elements
// constructors
public ArrayQueue( ) {this(CAPACITY);} // constructs queue with
default capacity
public ArrayQueue(int capacity) { // constructs queue with given
capacity
data = (E[ ]) new Object[capacity]; // safe cast; compiler may give
warning
}
// methods
/** Returns the number of elements in the queue. */
public int size( ) { return sz; }
/** Tests whether the queue is empty. */
public boolean isEmpty( ) { return (sz == 0); }
/** Inserts an element at the rear of the queue. */
public void enqueue(E e) throws IllegalStateException {
if (sz == data.length) throw new IllegalStateException("Queue is
full");
int avail = (f + sz) % data.length; // use modular arithmetic
data[avail] = e;
sz++;
}
/** Returns, but does not remove, the first element of the queue
(null if empty). */
public E first( ) {
if (isEmpty( )) return null;
return data[f];
}
/** Removes and returns the first element of the queue (null if
empty). */
public E dequeue( ) {
if (isEmpty( )) return null;
E answer = data[f];
data[f] = null; // dereference to help garbage collection
f = (f + 1) % data.length;
sz--;
return answer;
}
}
LinkedQueue code:
public class LinkedQueue<E> implements Queue<E>
{
private SinglyLinkedList<E> list = new
SinglyLinkedList<>( ); // an empty list
public LinkedQueue( ) { } // new queue relies on the initially
empty list
public int size( ) { return list.size( ); }
public boolean isEmpty( ) { return list.isEmpty( ); }
public void enqueue(E element) { list.addLast(element); }
public E first( ) { return list.first( ); }
public E dequeue( ) { return list.removeFirst( ); }
}
ArrayList Code:
public class ArrayList<E> implements List<E> {
// instance variables
public static final int CAPACITY=16; // default array
capacity
private E[ ] data; // generic array used for storage
private int size = 0; // current number of elements
// constructors
public ArrayList( ) { this(CAPACITY); } // constructs list with
default capacity
public ArrayList(int capacity) { // constructs list with given
capacity
data = (E[ ]) new Object[capacity]; // safe cast; compiler may give
warning
}
// public methods
/** Returns the number of elements in the array list. */
public int size( ) { return size; }
/** Returns whether the array list is empty. */
public boolean isEmpty( ) { return size == 0; }
/** Returns (but does not remove) the element at index i. */
public E get(int i) throws IndexOutOfBoundsException {
checkIndex(i, size);
return data[i];
}
/** Replaces the element at index i with e, and returns the
replaced element. */
public E set(int i, E e) throws IndexOutOfBoundsException {
checkIndex(i, size);
E temp = data[i];
data[i] = e;
return temp;
}
/** Inserts element e to be at index i, shifting all subsequent
elements later. */
public void add(int i, E e) throws IndexOutOfBoundsException,
IllegalStateException {
checkIndex(i, size + 1);
if (size == data.length) // not enough capacity
throw new IllegalStateException("Array is full");
for (int k=size-1; k>= i; k--) // start by shifting
rightmost
data[k+1] = data[k];
data[i] = e; // ready to place the new element
size++;
}
/** Removes/returns the element at index i, shifting subsequent
elements earlier. */
public E remove(int i) throws IndexOutOfBoundsException {
checkIndex(i, size);
E temp = data[i];
for (int k=i; k< size-1; k++) // shift elements to fill
hole
data[k] = data[k+1];
data[size-1] = null; // help garbage collection
size--;
return temp;
}
// utility method
/** Checks whether the given index is in the range [0, n−1].
*/
protected void checkIndex(int i, int n) throws
IndexOutOfBoundsException {
if (i < 0 || i >= n)
throw new IndexOutOfBoundsException("Illegal index: " + i);
}
/** Resizes internal array to have given capacity >= size.
*/
protected void resize(int capacity) {
E[ ] temp = (E[ ]) new Object[capacity]; // safe cast; compiler may
give warning
for (int k=0; k < size; k++)
temp[k] = data[k];
data = temp; // start using the new array
}
/** Inserts element e to be at index i, shifting all subsequent
elements later. */
}
In: Computer Science
Suppose a manager has write permission only for the usmUserOwnAuthKeyChange column in usmUserTable, which allows change of only that manager’s password. However, the manager has full write access to the VACM tables. Explain how the manager can modify the local keys of other managers.
In: Computer Science
Write C++ program
Consider the following SimpleString class:
class simpleString
{
public:
simpleString( ); // Default constructor
simpleString(int mVal ); // Explicit value constructor
~simpleString() { delete [ ] s;} // Destructor
void readString(); // Read a simple string
void writeString() const; // Display a simple string
char at(int pos) const; // Return character at (pos)
int getLength() const; // Return the string length
int getCapacity() const; // Return the string capacity
void copyContents(char[ ]) const; // Copy the contents into an array
private:
int capacity; // maximum size
char *s; // pointer to a dynamic storage array
int length; // current length
};
Add to the above class the following two public member function:
Hint:
Consider the problem of searching in a string of text T[0 .. n-1] for a substring that matches a pattern P[0..m-1]. A simple Brute Force algorithm is:
ALGORITHM StringMatch (T[0..n-1], P[0..m-1])
{
for i = 0 to n-m
{
j = 0;
while ( (j < m) AND (P[j] == T[i + j]) ) j++;
if ( j == m) return i;
}
return -1;
}
Implement the function findsub (SimpleString sub) using the above algorithm.
Provide the implementation of the above two functions.
In: Computer Science
data structure class:
a. syntax for generics
b. comparable interface
c.how do you implement interface
answer for all of them please.
answer for all of them please
In: Computer Science