Write a C++ program that reads integers from standard input until end of file.
Print out the largest integer that you read in, on a line by itself.
Any erroneous input (something that is not an integer) should be detected and ignored.
In the case where no integers are provided at all, print NO INTEGERS and stop
Remember, try not to do the entire job all at once! First try input of a single number and make sure it works. Make sure that you detect eof correctly. Then add the error checks. Then add the loop...
In: Computer Science
Explain the concept of Key Logging:
a/ Why do Key Loggers exist? What good things are they useful for?
b/ Why do software and hardware key loggers useful for?
c/ Are there ethical reasons to use a key logger?
In: Computer Science
Given the following Scheme definition:
(define x '(define (fac n) (if (= n 0) 1 (* n (fac (- n 1))))))
(This does not define the factorial function fac, but the variable x.)
Write Scheme expressions in terms of x that would have the effect of extracting the following expressions:
E.g., the expression (car x) would extract define.
In: Computer Science
Consider the following Scheme function foo:
(define (foo x) (cond ((null? x) 0) ((not (list? (car x))) (cond ((eq? x '()) (foo (car x))) (else (+ 1 (foo (cdr x)))))) (else (+ (foo (car x)) (foo (cdr x))))))
(8 pts)
Explain what the function computes and how. Don’t just restate the function definition in English — explain the algorithm. Hint: not all the code in this function does something useful.
(2 pts)
Show the result of executing the expression
(foo '(((a (b c) d) (((d) e) f) g)))
In: Computer Science
Given an array ? of numbers and a window size ?, the sliding
window ending at index ? is the subarray ?[? − ? + 1],⋯,?[?] if ? ≥
? − 1, and ?[0],⋯,?[?] otherwise. For example, if ? = [0,2,4,6,8]
and ? = 3, then the sliding windows ending at indices 0, 1, 2, 3
and 4 are respectively [0], [0,2], [0,2,4], [2,4,6], and [4,6,8].
Write a method, movingAverage, that given as input an array ? of
numbers and a window size ?, returns an array ? with the same
length as ?, such that for every index ?, ?[?] is the average of
the numbers in the sliding window ending at index ?. The skeleton
for the method is provided in the file MovingAverage.java.
The following is a sample run.
Input: ? = [0,2,4,6,8], ? = 3 Return: [0,1,2,4,6] Explanation: As
explained above, the sliding windows at indices 0, 1, 2, 3 and 4
are respectively [0], [0,2], [0,2,4], [2,4,6], and [4,6,8]. The
average of the numbers in these sliding windows are respectively =
0, = 1, = 2, = 4, and = 6.
Your method must have time complexity ?(?), where ? is the length
of the input array ?.
Hint: You may find a queue useful.
public class MovingAverage {
/**
* Given an array of integers and a window size,
computes the average of the integers in
* the sliding window ending at each index.
*
* Time Complexity: O(n), where n is the length of the
input array
*
* @param A an array of integers
* @param w a window size
* @return an array of doubles with the same length as
A, whose element at index i is the
* average of the integers in the sliding window ending
at index i in the input array A
*/
public double[] movingAverage(int[] A, int w) {
//Replace this line with your
return statement
return null;
}
}
In: Computer Science
By definition, each relational database table must contain exactly one candidate key.
Select one:
a. True
b. False
Values appearing in a key column must always be unique, regardless of the type of key.
Select one:
a. True
b. False
Which of the following statements about well-formed relations is FALSE?
Select one:
a. A relation is well-formed if it is in third normal form (3NF)
b. Every determinant in a well-formed relation is also a candidate key
c. Any table that meets all of the necessary criteria to be classified as a relation can be considered well-formed
d. Well-formed relations are generally not susceptible to modification anomalies
Each table in a relational database must be related to at least ________ other table(s).
Select one:
a. Zero
b. One
c. Two
d. Three
Data contained within a relational database are stored in two-dimensional ________.
Select one:
a. Folders
b. Lists
c. Catalogs
d. Tables
In: Computer Science
a) Design in pseudocode an algorithm that gets as input an integer k, and a list of k integers N1, .., Nk, as well as a special value SUM. Your algorithm must locate a pair of values in the list that sum to the value SUM. For example, if your list of values is 3, 8, 13, 2, 17, 18, 10, and the value of SUM is 20, then your algorithm should output "either" the two values 2 and 18, "or" the two values 3 and 17. If your algorithm cannot find any pair of values that sum to the value SUM, then it should print out the message "sorry, there is no such pair of values".
b) What is the number of comparisons performed by your algorithm in the Best case? In the Worst case?
c) Express these numbers in the theta (θ) notation.
In: Computer Science
Name the project pa3 [Method 1] In the Main class, write a static void method to print the following text by making use of a loop. Solutions without a loop will receive no credit. 1: All work and no play makes Jack a dull boy. 2: All work and no play makes Jack a dull boy. 3: All work and no play makes Jack a dull boy. 4: All work and no play makes Jack a dull boy. [Method 2] In the Main class, write a static method that accepts an array of floating point parameters. The three elements in the array can be labeled as a, b, and c from first to last. The method computes and returns the results of the quadratic equation in a separate two-element array given by the following equation: −b ± √( b^2 − 4 · a · c) / (2 · a), as long as the discriminant (b^2 − 4 · a · c) is non-negative. Otherwise, return a reference to an array object with zeros in both elements. [Method 3] In the Main class, write a static void method that receives three Strings and prints them in reverse dictionary order, Z to A. Tips: Should the result of the following example be positive: callingString.compareTo(otherString), callingString will appear after otherString in the dictionary. There are six possible orderings of 3 items, so you should not need more than 5 nested if statements. Another option is to place the Strings into an array, use the Arrays.sort static method, and traverse the array backwards. [Method 4] In the Main class, write a static method that receives a String parameter named option. The method then returns one of the following String literals based on the return value of option’s length() function. When option has fewer than 10 characters, return “too small”. When option has more than 10 characters, return “too big”. When option has exactly 10 characters, return “just right”. In the main method, write the Java code to receive the needed actual parameters from the user for each method and call each method. For instance, the three numbers required for Method 2 should be read from the user. Also include the appropriate prompts instructing the user what to enter. Requirements 1) A reference variable and instance object of class java.util.Scanner must be used to read the input from the user. 2) Identifiers must be descriptive (i.e., must self document). 3) Indention of all code blocks (compound statements, code inside braces), including single statements following selection or while statements, is required.
In: Computer Science
(Programming Language: Python)
Complete the function remove number such that given a list of
integers and an integer n, the function removes every instance
of
n from the list. Remember that this function needs to modify the
list, not return a new list.
# DO NOT ADD ANY OTHER IMPORTS from typing import List
def remove_number(lst: List[int], number: int) -> None:
"""
Remove every instance of number in lst. Do this *in-place*, i.e. *modify* the list. Do NOT return a new list.
>>> lst = [1, 2, 3]
>>> remove_number(lst, 3)
>>> lst
[1, 2]
"""
pass
In: Computer Science
Write an implementation of the ADT stack that uses a resizeable array to represent the stack items. Anytime the stack becomes full, double the size of the array. Maintain the stack's top entry at the beginning of the array.
Use c++ to write this code.
In: Computer Science
In: Computer Science
Information Technology (IT) is an application of computers and telecommunications which stores, retrieves, transmits and manipulates data. It also encompasses other information technologies of a ubiquitous nature.
Describe using appropriate examples the ubiquitous nature of IT in the following cases. Clearly explain the input-output mechanism.
1. Wearable Computer
2. In the New Metro Express Project
In: Computer Science
Data must possess some key characteristics. Using example of a wearable computer, elaborate on the following: RELIABLE, TIMELY, And COMPLETE
In: Computer Science
I'm trying to convert between different number representations in C++ , I have the prototype but im not sure what do do from here
bool convertU(unsigned & n, const string & bits);
bits should have size exactly 5, and each char of bits should be '0' or '1'; otherwise
return false.
If bits is ok, set n to the number that bits represents as an unsigned and return true.
For example, convertU(n, "0101") and convertU(n, "10210") should return false;
convertU(n, "10011") should set n to 19 and return true.
In: Computer Science
In data normalization, the removal of partial dependencies is associated with the transition from ________.
Select one:
a. Poorly structured data to first normal form (1NF)
b. First normal form (1NF) to second normal form (2NF)
c. Second normal form (2NF) to third normal form (3NF)
d. Third normal form (3NF) to Boyce-Codd normal form (BCNF)
Although the idea of a foreign key is useful for conceptual data modeling purposes, it is not actually possible to implement a foreign key in a real-world DBMS.
Select one:
a. True
b. False
Compared to the non-normalized design from which it was derived, a normalized database design will typically contain ________ inter-table relationships.
Select one:
a. More
b. Fewer
c. An equal number of
d. Zero
All of the following anomalies EXCEPT ________ can arise when using a list to store data.
Select one:
a. Deletion problems
b. Update problems
c. Query problems
d. Insertion problems
A referential integrity constraint can be used to verify that the values of a column in one table are valid in light of the values of a column in another table
Select one:
a. True
b. False
In: Computer Science