Unsorted list containing integer values with duplicates

Assignment Help Chemistry
Reference no: EM13912139

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<right do

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. 

Reference no: EM13912139

Questions Cloud

Using the tax tables-what is the amount : Sheniqua, a single taxpayer, had taxable income of $75,053. Her employer withheld $14,290 in federal income tax from her paychecks throughout the year. Using the tax tables, would Sheniqua receive a refund or would she be required to pay additional t..
Break-even sales and sales mix for a service company : Zero Turbulence Airline provides air transportation services between Los Angeles, California, and Kona, Hawaii. A single Los Angeles to Kona round-trip flight has the following operating statistics:
Parent-subsidiary liquidation : In terms of the rules applying to a Section 332 parent-subsidiary liquidation, comment on each of the following:
Calculate firm js margin turnover and return : Firm J has net income of $72,000, sales of $960,000, and average total assets of $480,000.
Unsorted list containing integer values with duplicates : 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.
Purchased new stamping machine with list price : On March 1, Bunker Hill Company purchased a new stamping machine with a list price of $76,000. The company paid cash for the machine; therefore, it was allowed a 5% discount. Other costs associated with the machine were: transportation costs, $1,900;..
Prepare a balance sheet for clear view park : Loren satina is the sole owner of clear view park a public camping ground near the lake mead national recreation area. Loren compiled the following financial information as of December 31, 2017. Determine Loren Satina's net income from clear view par..
Prepare statement of changes in equity for the same period : You are presented with the following extract from the business accounts at 30 June 2015. Note that the information provided represents an extract from the business accounting records only. Prepare an Income Statement for the year ended 30 June 2015. ..
The earnings per share of common stock was : Archer Company had net income of $40,000 last year. The company has 5,000 shares of common stock and 2,500 shares of preferred stock outstanding. There was no change in the number of common or preferred shares outstanding during the year. Preferred d..

Reviews

Write a Review

Chemistry Questions & Answers

  Evaluate the mass of water produced from 9.47g of methane

Calculate the mass of water produced from 9.47g of methane, CH4, reacts with an excess of oxygen in the following unbalanced reaction. 2C8H18(g)+25O2(g)=16CO2(g)+18H2O(g)

  Explain methylammonium ion and chloride ion

The methylamine hydrochloride dissociates completely in water to form methylammonium ion (CH3NH3+) and chloride ion.

  Compute the solubility of ce

Calculate the solubility of Ce(IO3)3 (pKsp=10.86) in: a) distilled H20 b) 0.300 M Ce(NO3)3 solutiom c) 0.200 M KIO3 solution

  State the draction of cec due to organic matter

its clay concentration and the CEC of the clay be able to estimate the draction of CEC due to organic matter in the sample

  Compute the molarity of a solution by dissolving

Calculate the molarity of a solution by dissolving 0.710 grams of Na2SO4 in enough water to form exactly 900 mL of solution

  State the concentration of a dye and concentration of bleach

The concentration of a dye and concentration of bleach (NaOH) was determined experimentally by using Beer's Law. The rate constant is unknown. How do you calculate the reaction rate based on the graph of the reaction and the 2 concentrations of th..

  A chemistry student needs of chloroform for an experiment

a chemistry student needs of chloroform for an experiment. by consulting the crc handbook of chemistry and physics the

  Calculate the mole fraction of each gas

A tank at is filled with of sulfur hexafluoride gas and of carbon monoxide gas. You can assume both gases behave as ideal gases under these conditions.

  Explain m cyanide ion cn- and 0.85 m hydrocyanic acid hcn

What is the pH of the resulting solution when 17.25 mL of 18.00 M HCl is added to a 1.9 liter solution that has 0.74 M cyanide ion CN- and 0.85 M hydrocyanic acid HCN

  Explain the difference in mass was identify the gas

To identify a diatomic gas (\rm X_2), a researcher carried out the following experiment: She weighed an empty 1.00-\rm L bulb, then filled it with the gas at 1.10 \rm atm and 23.0 ^\circ\rm C and weighed it again.

  A sample of gas changes from p1v1 and t1 to p2v2 and t2 by

a sample of gas changes from p1v1 and t1 to p2v2 and t2 by one path and then back to p1v1 and t1 by another path.which

  Hypothesize on the possible physiological effects

Hypothesize on the possible physiological effects of the mutation or loss of one of the enzymes in the Beta-Oxidation pathway.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd