Docsity

Algorithm and Data Structures - Sample Problems | ITCS 6114, Assignments of Computer Science

Toggle sidebar
bg1
Sample Problems (ITCS 6114)
Problem 1
Sort the following file by heapsort, mergesort, and quicksort algorithms:
[50, 12, 24, 30, 20, 6, 21, 18, 3, 5]. List all intermediate steps.
Problem 2.
List the functions below from the lowest asymptotic order to highest asymptotic order.
n2, nlog(n), n2 + nlog(n), [log(n)]2, log(n3 + n2), n5 + log(n3)
Problem 3.
Assuming that the tree has the preorder and inorder representations given below,
reconstruct the tree.
Preorder: [ D, B, A, C, I, E, G, F, H]
Inorder: [ A, B, C, D, E, F, G, H, I]
Problem 4.
Follow Prim’s algorithm (Kruskal’s algorithm) to find a minimum spanning tree for the
graph represented by the following set of edges: [(a,b),2], [(a,c),4], [(b,c),3], [(b,d),4],
[(b,e),1], [(c,e),5], [(d,e),2], [(e,f),5], [(d,f),3].
Remark: [(a,b),2] means that there is an edge (a,b) and its weight is 2.
Problem 5.
Construct an AVL tree (red-black tree) for the list: C, O, M, P, U, T, I, N, G. Use the
alphabetical order of the letters and insert them successively starting with the empty tree.
Problem 6.
Use the preprocessing of coefficient method to evaluate the polynomial
p(x) = 2x7 + 6x6 + 7x5 + 12x4 + 2x2 - 3x – 8 at x=2.
Problem 7.
Find the minimal number of multiplications needed to compute the product of four
matrices A1 A2 A3 A4. Matrix A1 has the size 35, matrix A2 has the size
52,
matrix A3 has the sisze 24, matrix A4 has the size 43.

Partial preview of the text

Download Algorithm and Data Structures - Sample Problems | ITCS 6114 and more Assignments Computer Science in PDF only on Docsity!

Sample Problems (ITCS 6114) Problem 1 Sort the following file by heapsort, mergesort, and quicksort algorithms: [50, 12, 24, 30, 20, 6, 21, 18, 3, 5]. List all intermediate steps. Problem 2. List the functions below from the lowest asymptotic order to highest asymptotic order. n^2 , nlog(n), n^2 + nlog(n), [log(n)]^2 , log(n^3 + n^2 ), n5 + log(n^3 ) Problem 3. Assuming that the tree has the preorder and inorder representations given below, reconstruct the tree. Preorder: [ D, B, A, C, I, E, G, F, H] Inorder: [ A, B, C, D, E, F, G, H, I] Problem 4. Follow Prim’s algorithm (Kruskal’s algorithm) to find a minimum spanning tree for the graph represented by the following set of edges: [(a,b),2], [(a,c),4], [(b,c),3], [(b,d),4], [(b,e),1], [(c,e),5], [(d,e),2], [(e,f),5], [(d,f),3]. Remark: [(a,b),2] means that there is an edge (a,b) and its weight is 2. Problem 5. Construct an AVL tree (red-black tree) for the list: C, O, M, P, U, T, I, N, G. Use the alphabetical order of the letters and insert them successively starting with the empty tree. Problem 6. Use the preprocessing of coefficient method to evaluate the polynomial p(x) = 2x^7 + 6x^6 + 7x^5 + 12x^4 + 2x^2 - 3x – 8 at x=2. Problem 7. Find the minimal number of multiplications needed to compute the product of four matrices A1  A2  A3  A4. Matrix A1 has the size 35, matrix A2 has the size 5 2, matrix A3 has the sisze 24, matrix A4 has the size 43.