Questions
Before you read or reread this section in your text, make a list of all of...

Before you read or reread this section in your text, make a list of all of the qualities and characteristics that attract you to someone. Be honest and do not censor yourself. After you have made your list, read what psychologists have discovered about what attracts people to one another. How are these things reflected in your list? Did you learn something about why it is you view others the way you do? Can you illustrate these factors with personal experiences with attraction? Is there any aspect of attraction that you did not realize influenced you?

In: Psychology

write a javascript function called cal_modes that will take a List of numbers or strings as...

write a javascript function called cal_modes that will take a List of numbers or strings as input and returns a List of the most frequent values. If there's only one most-frequent value, it returns a single-element List.

example

cal_modes([3,4,5,5]) should return [5]
cal_modes([8.9, 1, 1]) should return [1]
cal_modes([2.5, -2, -2, 2.5]) should return [2.5]
cal_modes([3,3,4,4]) should return [3,4]
cal_modes([3,4,5]) should return [3,4,5], because all occur with equal frequency
cal_modes(["hi", "what", "where", "hi"]) should return ["hi”]

In: Computer Science

Assume that attributes with the same name in different relations represent the same domain and that...

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)
  1. List all potential foreign keys in the three relations. (1 mark)
  2. List all superkeys of S. (1 mark)
  3. List all candidate keys of T. (1 mark)
  4. What is the degree and cardinality of S? (1 mark)
  5. If the cardinality of T is N, what is the cardinality of πC,H(T)? (1 mark)

In: Computer Science

Design and implement an algorithm that gets as input a list of k integer values N1,...

Design and implement an algorithm that gets as input a list of k integer values N1, N2, …., Nk, as well as a special value SUM. Your algorithm must locate a pair of values in the list N 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 would output either of the two values (2, 18) or (3, 17). If your algorithm cannot find any pair of values that sum to the value of SUM, then it should print the message ‘Sorry there is no such pair of values.’

In: Computer Science

Develop a program to maintain a Linked List of homework assignments name and due date. When...

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:

  • Add a new assignment.
  • Remove an assignment.
  • Provide a list of the assignments in the order they were assigned.
  • Find the assignment(s) with the earliest due date

-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...

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...

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       

  1. Classification & understandability                                                        
  2. Completeness
  3. Cutoff   
  4. Existence
  5. Occurrence
  6. Rights and Obligations
  7. Valuation and allocation   

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...

  1. // 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...

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:

  • Title case means that the first letter of each word is uppercase and the rest lower-case. You may want to use the .title() string function. (e.g. 'SMITH'.title() returns 'Smith')
  • You should not modify the original list of string objects.
  • You may assume that each word in the list does not have more than 5 characters.
  • You may want to use the format string: '{:<5}' in this question.

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...

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