What is sequence of numbers in a after first partition

Assignment Help Data Structure & Algorithms
Reference no: EM131650846

Data Structures Assignment

• Question 1: Asymptotic Notations

(a) Which one of the following is wrong?

1. Θ(n) + O(n) = Ω(n)
2. O(n) + Ω(n) = Θ(n)
3. Θ(n) + O(n) = O(n)
4. f (n) = O(g(n)) implies g(n) = Ω(f (n))

(b) Which one of the following sorting algorithms will have the best best-case running time?

1. Selection sort
2. Insertion sort
3. Heap sort
4. Quick sort

(c) Explain why the statement, "The running time of an algorithm is at most Ω(n)," is meaningless.

• Question 2: Running Time and Growth of Functions

(a) Assume evaluating a function f (n) in the pseudocode below takes Θ(n) time.

i = 1;
sum = 0;
while (i <= n)
do if (f(i) > k)
then sum += f(i);
i = 2*i;

What is the running time (use an asymptotic notation) of the above code? Justify your answer.

(b) For the following functions, please list them again but in the order of their asymptotic growth rates, from the least to the greatest. For those functions with the same asymptotic growth rate, please underline them together to indicate that.

(log2 n)n, (log2 nn), n2, (log2 n2), n1/2, 2n, (√2)2, log10 n

• Question 3: Sorting

(a) For a given input array A : < 3, 7a, 5, 9, 8, 11, 7b, 12, 13 >, what is the sequence of numbers in A after calling Build-Max-Heap(A) ? (please show the intermediate trees).

(b) For a given input array A : < 2a, 9, 3, 1, 8, 5, 2b, 7, 4 >, what is the sequence of numbers in A after the first partition (by calling Partition(A, 1, 9))? Note that 1 and 9 in Partition(A, 1, 9) function call are array indexes.

(c) By using the Max-Heap data structure to implement a priority queue, some applications may need to change the data (priority) of a specific node i. That is, given an index i, change the priority of node i to a new priority t. Please write a pseudocode for this procedure.

Max-Heap-update(A, i, t)
{

 

 

}

(d) Please describe how to use a priority queue to implement a queue.

• Question 4: Linear Time Sorting

(a) Please describe the reason(s) why we choose the counting sort algorithm to sort each digit in the Radix Sort?

(b) What is the best running time to sort n integers in the range [0, n3 - 1], and How?

(c) Given an input array A with n integers in [0, k], we can use the array C in the counting sort to find out how many integers in A are in a range [a, b]. Write a pseudocode for this query. Assume C[i] already contains the number of input integers ≤ i.

FindNumIn(a, b) // both a and b are integers.

Reference no: EM131650846

Questions Cloud

Security challenges in emerging networks : MN502 - Overview of Network Security - Identify and report network threats, select and implement appropriate countermeasures for network security
National welfare of a large country : Show that an import tariff can increase the national welfare of a large country. What is the source of the gain?
Explain the personal values and professional codes of ethics : Explain two conflicts between personal values and professional code of ethics that social workers encounter when working with the client in the video segment.
Written communication is free of errors that detract : Written communication is free of errors that detract from the overall message
What is sequence of numbers in a after first partition : what is sequence of numbers in A after first partition (by calling Partition(A, 1, 9))? Note that 1 and 9 in Partition(A, 1, 9) function call are array indexes.
What would be some implicit costs : What would be some explicit costs of starting the business? What would be some implicit costs?
Fit a model predicting the second midterm score from first : Grades? The professor teaching the Introductory Statistics class discussed in Exercise wonders whether performance on homework can accurately predict midterm.
Write the letter to a child who is important in your life : What personal characteristics do you hope your young adult son or daughter will possess, and why?
Bitcoin and other crypto-currencies : Bitcoin and other crypto-currencies are earning much attention right now. Given what you know about the functions of money do you think that Bitcoin.

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Implement an open hash table

In this programming assignment you will implement an open hash table and compare the performance of four hash functions using various prime table sizes.

  Use a search tree to find the solution

Explain how will use a search tree to find the solution.

  How to access virtualised applications through unicore

How to access virtualised applications through UNICORE

  Recursive tree algorithms

Write a recursive function to determine if a binary tree is a binary search tree.

  Determine the mean salary as well as the number of salaries

Determine the mean salary as well as the number of salaries.

  Currency conversion development

Currency Conversion Development

  Cloud computing assignment

WSDL service that receives a request for a stock market quote and returns the quote

  Design a gui and implement tic tac toe game in java

Design a GUI and implement Tic Tac Toe game in java

  Recursive implementation of euclids algorithm

Write a recursive implementation of Euclid's algorithm for finding the greatest common divisor (GCD) of two integers

  Data structures for a single algorithm

Data structures for a single algorithm

  Write the selection sort algorithm

Write the selection sort algorithm

  Design of sample and hold amplifiers for 100 msps by using n

The report is divided into four main parts. The introduction about sample, hold amplifier and design, bootstrap switch design followed by simulation results.

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