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

  Steps in the mechanism for the following reaction

Show all the steps in the mechanism for the following reaction, When benzene is mixed with deuterated sulfuric acid, deuterium is slowly incorporated onto the ring. Show the mechanism for this reaction and explain how this relates the sulfonation of ..

  Prior to placing piece of metal into the graduated cylinder

This assignment inhibits chemistry Laboratory Questions.

  Write the structures of the saytzeff elimination

Write the structures of the saytzeff elimination

  Calculate ph - chemistry questions

Chemistry Questions on Calculate P H

  How many mols of hydrogen can produce

how many mols of H 2 can produce

  Analysis of corrosion mechanisms

Analysis of corrosion mechanisms and preventative measures

  Chemical and pharmaceutical science

Write an equation for the formation of an acetal from reaction of excess methanol with benzaldehyde in the presence of an acid catalyst.

  Calculate the approximate sulphur

Calculate the approximate SO 2 mass emission in lb/day.

  What is the structure - stereochemistry

What is the structure (including functional groups)? Stereochemistry (racemic or single enantiomer)?

  Design a qualitative analysis scheme

Design a qualitative analysis scheme

  What will be the resultant pressure

What will be the resultant pressure when the stopcock is opened?

  The 1h nmr spectrum

Integrals for some of the resonances in the 1H NMR spectrum are higher than they should be due to the shear number of hydrogens in this compound

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