Ask Chemistry Expert

Q1. You are given an unsorted list containing integer values with duplicates. Describe a most efficient algorithm to remove all duplicates from this list. Derive the time complexity (Big O) for your algorithm.

Q2. Let A be an array of n distinct integers. Assume that the integers in A are sorted, i.e. A[i] < A[j], where 0 <= i < j < n. The algorithm count(x, y) returns the number of integers in A which are greater than x and less than y, where x < y. For example, if A = {5, 10, 33, 49667582, 95, 100},then count(47, 85) returns 4.

Describe a most efficient algorithm to implement the algorithm for count(x, y). Derive the time complexity for your algorithm.

Q3. . The following array is to be sorted in ascending order. Use the QuickSort algorithm to rearrange the array. Clearly show the internal state of the array after each pass of the sorting process.

 

                                          

 

3

4

5

6

7

8

9

34

125

5

19

87

243

21

-3

117

36

Q4. Give a Big-Oh characterization, in terms of n, of the running firm of the following algorithm. A is an array of integer values. Explain your answer.

1) ()Algorithm Ex1(A) :

for i <- 2 to length[A] Key <- A[i]

j <=  i-l

while j> 0 and A[ j]> key

A[j+1] <-     A[j]

*- j-1 A[j+1] <- key

 

2) ()Algorithm Ex2(A, target) :

s <- 0

Left<-0

Right <-len(A)-1

while left

Mid <- (left+right)/2

if ( A[mid]=)

return true

else if (A[mid]>target) Right<-mid -1

else

Left< -mid+1

return false

 

Q5.Let T be a binary tree with n nodes (T may be realized with an array list or a linked structure). Give a linear algorithm that uses the methods of the binary tree interface to traverse the nodes of T in pre-order manner. Since operations associated with visiting each node is constant, the running time of the algorithm is O(n).

Q6. Insert the following values into an initially empty BST tree:

6 3 8 12 13 20 17 15 14

You must clearly show each step of the insertion and all actions needed to complete the insertion.

Q7. Use substitution method to show that the solution of T(n) = T(n/2)+1 is O(Ig n).

Q8. Let X[1::n] and Y [1::n] be two arrays, each containing n numbers already in sorted order.Give an O(lg n)-time algorithm to find the median of all 2n elements in arrays X and Y. 

Chemistry, Academics

  • Category:- Chemistry
  • Reference No.:- M91585061
  • Price:- $30

Priced at Now at $30, Verified Solution

Have any Question?


Related Questions in Chemistry

Question 1bonding energyi draw an energy level diagram for

Question 1: Bonding Energy i. Draw an energy level diagram for a single Na ion and Cl ion. ii. Explain what is happening to the energy level between these two ions in terms of the Potential Energy. iii. Which process uti ...

Wat is the molarity to the hundredths place of 50 g hpo3

What is the molarity, to the hundredths place, of 5.0 g HPO3 in 300. mL of solution?

Describe how to assign anbspoxidation number from

Describe how to assign a Oxidation number from the text: The oxidation number of an atom in an elemental substance is zero. The oxidation number of a monatomic ion is equal to the ion's charge. Oxidation numbers for comm ...

How many grams of h2so4 must be dissolved into 0709 l of

How many grams of H2SO4 must be dissolved into 0.709 L of solution to generate a concentration of 0.303 M?

What could a source of error be during a titration lab that

What could a source of error be during a titration lab that is not a humans fault?

How many moles of magnesium ion are present in 525g

How many moles of magnesium ion are present in 5.25g Mg 3 (PO 4 ) 2 ?

What is the volume of a solution with a concentration of 12

What is the volume of a solution with a concentration of 1.2 M that contains 12 g of NaOH?

What is the molarity of a solution made by dissolving 200 g

What is the molarity of a solution made by dissolving 20.0 g of CrCl2 in 0.150 L of solution?

What is the mass of naoh present in grams given that a 100

What is the mass of NaOH present in grams, given that a 100. mL solution has a concentration of 0.125 M?

What is the volume of a solution in milliliters that

What is the volume of a solution, in milliliters, that contains 1.5 g LiNO3 and has a concentration of 0.40 M?

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As