Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PLEASE HELP! Problem 2: NOTE: NO CODING JUST EXPLANATIONS 1) Determine if 2 arra

ID: 3697383 • Letter: P

Question

PLEASE HELP!

Problem 2:

NOTE: NO CODING JUST EXPLANATIONS

1) Determine if 2 arrays contain the same elements

2) Counting total number characters that have a duplicate within a string (i.e. "gigi the gato" would result in 7 (g x 3 + i x 2 + t x 2)

3) Finding an empty row in a 2-D array where empty is defined as an element with a 0 entry.

For each problems segment given above, do the following:

- Create an algorithm(PSEUDOCODE) to solve the problem - Identify the factors that would influence the running time, and which can be known before the algorithm or code is executed. Assign names (such as n) to each factor.

- Identify the operations that must be counted. You need not count every statement separately. If a group of statements always executes together, treat the group as a single unit. If a method is called, and you do not know the running time of that method, count it as a single operation.

- Count the operations performed by the algorithm or code. Express the count as a function of the factors you identified in Step 2. If the count cannot be expressed as a simple function of those factors, define the bounds that can be placed on the count: the best case (lower bound) and worst case (upper bound).

- Determine what the Best Case Inputs are, and the Worst Case Inputs are, and the efficiency of your implementation - Transform your count formula into big-O notation by:

- Taking the efficiency with worst case input

- Dropping insignificant terms.

- Dropping constant coefficients.

Explanation / Answer

Question: 1) Determine if 2 arrays contain the same elements

We can say that 2 arrays having the sam elements if it satisfy following given two conditions:

Pseudo Code:
i) calculate the sum of all the elements of 1st array.
ii) calculate the sum of all the elements of 2nd array.
iii) calculate multiplication of all the elements of 1st array
iv) calculate multiplication of all the elements of 2nd array
v) if Multiplication of all the elements of 1st array = Multiplication of all the elements of 2nd array and if
Total sum of all the elements of 1st array = Total sum of all the elements of 2nd array
vi) if conditions given in step (v) are true, then 2 array will contain the same elements.

Qustion: 3) Finding an empty row in a 2-D array where empty is defined as an element with a 0 entry.

Pseudo Code:

i) First of all identifiy the rows and columns of a 2-d array.
ii) Now iterate to the each row with all colums
iii) compare each rows column value with zero.
iv) if all the columns of a row is zero then we can say that a row is empty row

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote