In: Psychology
In: Computer Science
Assume that attributes with the same name in different relations represent the same domain and that the primary key attributes in each relation are underlined. Answer the following questions given the relational schema below:
R(A,D) S(A,B,C,D) T(C,D,A,H)
In: Computer Science
In: Computer Science
Develop a program to maintain a Linked List of homework assignments name and due date. When an assignment is assigned, add it to the list, and when it is completed, remove it. You should keep track of the due date. Your program should provide the following services each contained within its own method:
-The commands are input from the user keyboard as well as the Assignment Names and the Assignment Due Dates. All entered by the user.
-Coded with comments
In: Computer Science
Code is only reading the last line from the text files. How would I resolve? This is for the Name Search problem in Starting out with Python book. def main(): #open a file for reading infile = open('GirlNames.txt' , 'r') #Read the contents into a list Girls = infile.readlines() #open another file for reading infile = open('BoyNames.txt', 'r') #Read the contents into a lits Boys = infile.readlines() #Get a name to search for Name = input('Enter a name: ') #Determine if name is in list if Name in Girls or Name in Boys: print( Name, "is one of the popular names.") else: print(Name, "was not found in the list.") main()
In: Computer Science
During the audit of derivatives, investments, and hedges, a
number of misstatements were detected by the auditor. For each
misstatement, select from List I the assertion affected by the
misstatement. Select from List II the audit procedure that most
likely detected the misstatement. Each choice may be used once,
more than once, or not at all.
List 1
List 2
1. Confirm securities and other assets held by third parties.
2. Obtain and review minutes of meetings of those charged with governance.
3. Obtain prices at year end from an independent source and compare with recorded amounts.
4. Inspect securities on hand.
5. Read and evaluate available contracts for effects on the financial statements.
6. Review the financial statements and inquire of management about investments and derivatives.
|
Misstatement |
List I - assertion affected |
List II - audit procedure used to detect misstatement |
|
1. A derivative used as a fair value hedge was reported at less than fair value. |
||
|
2. A contract for a future delivery of a commodity used as a hedge was not clearly described in the notes to the financial statements. |
||
|
3. A contract approved by the board of directors creating and defining a derivative was not recorded in the financial statements. |
||
|
4. A cash flow hedge created to protect against an interest rate increase was ineffective and resulted in a loss that was unrecognized in the current year. |
||
|
5. A derivative security being reported at year end had been sold by the client’s broker earlier in the year. |
In: Accounting
// This program demonstrates a Binary Search
//PLACE YOUR NAME HERE
#include<iostream>
using namespace std;
int binarySearch(int [], int, int); // function prototype
const int SIZE = 16;
int main()
{
int found, value;
int array[] = {34,19,19,18,17,13,12,12,12,11,9,5,3,2,2,0}; // array to be searched
cout << "Enter an integer to search for:" << endl;
cin >> value;
found = binarySearch(array, SIZE, value); //function call to perform the binary search
//on array looking for an occurrence of value
if (found == -1)
cout << "The value " << value << " is not in the list" << endl;
else
{
cout << "The value " << value << " is in position number "
<< found + 1 << " of the list" << endl;
}
return 0;
}
//*******************************************************************
// binarySearch
//
// task: This searches an array for a particular value
// data in: List of values in an orderd array, the number of
// elements in the array, and the value searched for
// in the array
// data returned: Position in the array of the value or -1 if value
// not found
//
//*******************************************************************
int binarySearch(int array[],int numElems,int value) //function heading
{
int first = 0; // First element of list
int last = numElems - 1; // last element of the list
int middle; 0 // variable containing the current
// middle value of the list
while (first <= last)
{
middle = first + (last - first) / 2;
// write statement to determine if value is in the middle, then we are done
else if (array[middle]<value)
last = //what would the last be? // toss out the second remaining half of
// the array and search the first
else
first = //what would the first be? // toss out the first remaining half of
// the array and search the second
}
return -1; // indicates that value is not in the array
}
In: Computer Science
python
Write a function pack_to_5(words) that takes a list of string objects as a parameter and returns a new list containing each string in the title-case version. Any strings that have less than 5 characters needs to be expanded with the appropriate number of space characters to make them exactly 5 characters long. For example, consider the following list:
words = ['Right', 'SAID', 'jO']
The new list would be:
['Right', 'Said ', 'Jo ']
Since the second element only contains 4 characters, an extra space must be added to the end. The third element only contains 2 characters, so 3 more spaces must be added.
Note:
For example:
| Test | Result |
|---|---|
words = ['Right', 'SAID', 'jO'] result = pack_to_5(words) print(words) print(result) |
['Right', 'SAID', 'jO'] ['Right', 'Said ', 'Jo '] |
words = ['help', 'SAID', 'jO', 'FUNNY'] result = pack_to_5(words) print(words) print(result) |
['help', 'SAID', 'jO', 'FUNNY'] ['Help ', 'Said ', 'Jo ', 'Funny'] |
result = pack_to_5([]) print(result) |
[] |
In: Computer Science
Write a method, twoSumSorted2, that solves the following variant of the Two-Sum problem:
Given a sorted array of integers where each element is unique and a target integer, return in an Array List, the indices of all pairs of elements that sum up to the target. Each pair of indices is also represented as an Array List (of two elements). Therefore, the method returns an Array List of an Array List of size 2. If no pair in the input array sums up to the target, then the method should return an empty list.
public class Hw2_p1 {
// HW2 Problem 1 Graded Method
public static
ArrayList<ArrayList<Integer>> twoSumSorted(int[] A, int
target) {
ArrayList<ArrayList<Integer>> ans = new
ArrayList<>();
// Your code starts
// Your code ends
return ans;
}
// Test driver for twoSumSorted2
public static void main(String[] args) {
}
}
The following are two sample runs:
Input: ? = [−7, −5, −2, 0, 1, 6, 7, 8, 9], ?????? = 1
Return value: [0,7], [1, 5], [3, 4]
Explanation: The pairs in the input array that sum up to 1 are [−7, 8], [−5, 6] and [0, 1]. Their indices are [0, 7], [1, 5] and [3, 4] respectively.
Input: ? = [−2, 0, 1, 6, 7, 8], ?????? = 3
Return value: [ ]
Explanation: No pair of elements in input array sums up to 3. The returned list is thus empty.
Your method must have time complexity ?(?), where ? is the length of the input array.
In: Computer Science