Computer Science Homework Solutions

Matrix Identity in C++

Write a function in c++ Isidentity (t) t is two dimensional array. (int t[rwos] [columns] return true, if it is an identity matrix, return false if it is not like example square tolls colum all 1's on principal diagonal, otherwise 0's 1 0 0 0 1 0 0 0 1 Note: This is a c++ question. This is not a math questions.

Divide a group of people into two disjoint subgroups (of arbitrary size) such that the difference in the total ages of the members of the two subgroups is as large as possible.

Reword the question below so it's less ambiguous so I can understand the question and answer it on my own. maybe give example diagram/inputs/outputs (primitives if possible) but don't show any algorithms in the answer. I know big theta notation/sorting algorithms etc.. This question has been answered at brainmass but I don't w ...continues

Arrays in java

Write the definition of a method, isReverse , whose two parameters are arrays of integers of equal size. The method returns true if and only if one array is the reverse of the other. ("Reverse" here means same elements but in reverse order.) So, suppose you had two int arrays, forward and backward, each with 4 elements. N ...continues

Demo of Java array and code that assigns values based on the membership of the array

Given: an int variable k , an int array currentMembers that has been declared and initialized, an int variable memberID that has been initialized, and an boolean variable isAMember , write code that assigns true to isAMember if the value of memberID can be found in currentMembers , and that assigns fa ...continues

Demo of Java array and code that assigns values based on the membership of the array

Given: an int variable k , an int array currentMembers that has been declared and initialized, an int variable memberID that has been initialized, and an boolean variable isAMember , write code that assigns true to isAMember if the value of memberID can be found in currentMembers , and that assigns fa ...continues

Find the Largest and Smallest and Sort all the values in an Array in ascending order

Write two function in C++ with using arrays to find largest and smallest number. For example you have 1,43,42,9,8,5. You need arrange them smallest to highest and highest to smallest.

Efficiency of algorithm finding the second smallest of n elements

Prove that the second smallest of n elements can be found with n + cieling(log n) - 2 comparisons in the worst case.

Algorithm to find majority element

Let A be an array of n elements. An element x is said to be a majority element in A if it occurs in A more than n/2 times. Assume that the only comparisons allowed between elements are tests of equality. Give an algorithm that uses no more than 2n comparisons to determine whether the array A contains a majority element and, i ...continues

Rucurrence running time

Give asymptotic upper and lower running time bounds for T(n) for each of the recurrences. Assume that T(n) is constant for n <= 2. Make bounds as tight as possible, and justify solutions. a) T(n) = 2*T(n/2) + n^3 b) T(n) = T(9n/10) + n c) T(n) = 16*T(n/4)+n^2 d) T(n) = 7*T(n/3) + n^2 e) T(n) = 7*T(n/2) + n^2

Solving a recurrence

Using the same method in attachment #1, solve the recurrence in attachment #2. I increased the bid to 6 credits, but also could you repost the Rucurrence running time problem (MasterTheorem.doc) in PDF format (as well as the solution to this problem) because the .doc says it is corrupt when I try to open it.

Browse