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, 49, 66, 75, 82, 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.
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..
|