Homework1 - 11, 10, 17, 5, 9, 1 Illustrate the Selection...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Homework 1: CMP 425 Due Date: Tuesday, 02/15/2011 1. Algorithm A uses 10NlgN and algorithm B uses N 2 operations. Determine the value of N 0 , such that A is better than B for all values of N >= N 0 . 2. Given the following list of functions. Group together those functions which are big-Theta of one another. 6nlogn, loglogn, log 2 n, 2 logn , 2 n , √n, n 3 , nlog 4 n, n 2 logn, 4 logn 3. For the given function below express the runtime T(n) in terms of n: void Example3(int n) { int a = 0; for (int I = 0; I < N*N; I++) { for (int j = 0; j <= I; j++) a = a + 2; } } 4. a) Write a function GCD(int a, int b) to find the GCD of two integers a and b (assuming a > b) using the Iterative method. [In the class we developed the recursive function]. b) Illustrate the GCD algorithm to find the GCD of 3178 and 420. 5. Using the limit concept of calculus, find out the largest and the smallest function between N 5 , (1.2) N and 2 lnN 6. Given the following unsorted data: 31, 15, 12, 2,
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 11, 10, 17, 5, 9, 1 Illustrate the Selection Sort algorithm and clearly state each step. 7. a) Given the unsorted array, S = {F, D, K, H, J, C, E}, show all the steps to sort this array using Merge sort. b) What is the best and worst case running time for Merge sort. If the data S is given to you in increasing order, like S = {C, D, E, F, H, J, K}, will the number of operations you have to do be the same, more than or less than that of case (a). Explanation to your answer is required. 8. a) Explain the insertion sort algorithm using the following keys: 12 pts 3 0 4 6 -4 15 -1 Is this the best case data arrangement for insertion sort, why or why not? (b) If you have to use Selection sort on the same data, will the number of steps needed be same, less or more than insertion sort. Explain your answer....
View Full Document

This note was uploaded on 02/15/2011 for the course CMP 425 taught by Professor Anonymous during the Spring '11 term at Alabama A&M University.

Ask a homework question - tutors are online