1. Let A = {a1, ..., an} and B = {b1, ..., bm} be two sets of numbers. Consider the problem of finding their intersection, i.e., the set C of all the numbers that are in both A and B.
a. Design a presorting based algorithm for solving this problem and determine its efficiency class.
2. Estimate how many searches will be needed to justify time spent on presorting an array of 103 elements if sorting is done by mergesort and searching is done by binary search.
3. Solve the following system by Gaussian elimination:
x1 + x2 + x3 = 2
2x1 + x2 + x3 = 3
x1 - x2 + 3x3 = 8
4. Solve the system of problem #3 by computing the inverse of its coefficient matrix and then multiplying it by the vector on the right-hand side.
5. For each of the following lists, construct an AVL tree by inserting their elements successively, starting with the empty tree.
a. 1, 2, 3, 4, 5, 6
b. 6, 5, 4, 3, 2, 1
c. 3, 6, 5, 1, 2, 4
6. Construct a heap for the list 1, 8, 6, 5, 3, 7, 4 by the bottom-up algorithm.
7. Construct a heap for the list 1, 8, 6, 5, 3, 7, 4 by successive key insertions (top-down algorithm).
8. Apply Horner's rule to evaluate the polynomial
p(x) = 3x4 - x3 + 2x + 5 at x = -2.












Design and Analysis of Algorithms 1. For each of the following lists, construct an AVL tree by inserting their elements successively, starting with the empty tree. 3, 2, 1, 4, 5, 6, 7 2. Construct a 2-3 tree for the list W, E, L, C, O, M, E, Y, O, U. Use the alphabetical order of the letters and insert them successively starting with the empty tree.
Not asking for code.
For each of the following lists, construct both an AVL tree and a 2-3 tree by inserting their elements successively, starting with the empty tree. 1, 2, 3, 4, 5, 6 6, 3, 2, 1, 4, 5
ALGORITHM AND DATA STRUCTURES Question Question 1: Convert the following binary tree into a heap using the Heapify algorithm. Draw the diagrams of the tree step by step after every alteration. Question 2: Show the heap that results when the items are inserted into the heap one by one, starting with one that is empty. 7, 3, 8, 1, 4, 20, 11, 33, 45, 23, 6 Question 3. Draw the 2-3-4 tree that results when values are inserted in the...
Solve the linear program using
the simplex algorithm method
maximize Z = 5x1 + x2 + 3x3 + 4x4 subject to: x1 – 2 x2 + 4 x3 + 3x4 s 20 –4x1 + 6 x2 + 5 X3 – 4x4 = 40 2x1 – 3 x2 + 3 x3 + 8x4 5 50 X1, X2, X3 , X4 20
6. Draw a diagram of the double RL-rotation in its general form. A partial solution is given. Fill in the missing parts inside the box. (pt) For the following list of numbers, construct an AVI tree by inserting their elements successively, starting with the empty tree. 1.2.3.4.5.6. The insertions of the first 4 numbers are given. Draw diagrams to show the rest of the process. Note that you need to indicate the balance factor of each node, diagrams before and...
Trees and Heaps 1. Show that the maximum number of nodes in a binary tree of height h is 2h+1 − 1. 2. A full node is a node with two children. Prove that the number of full nodes plus one is equal to the number of leaves in a nonempty binary tree. 3. What is the minimum number of nodes in an AVL tree of height 15? 4. Show the result of inserting 14, 12, 18, 20, 27, 16,...
Data structures Exercises: For the following binary tree (Index-Value): 0 1 2 3 4 5 6 7 8 9 A C E G B P D X F H Give the pre-order traversal. Give the post-order traversal. Give the in-order traversal. Determine the height of the tree. Using these values: 8 6 4 3 5 9 2 1 6 Build a binary search tree. Build an AVL Tree. Build a 2-3 Tree. Build a min-heap. Build a max-heap. Apply a...
A. Construct a heap for the list ( 2, 5, 6, 4, 3, 1, 8, 7 ) by the bottom-up algorithm B. Construct a heap for the list ( 2, 5, 6, 4, 3, 1, 8, 7 ) by successive key imsertions (top-down algorithm) C. Is is true that the bottom-up and top-dowj alogorthms yield the same heap for the same input?
2x1 − x2 − 3x3 − 2x4 = 1 x1 − x2 − 4x3 − 2x4 = 5 3x1 − x2 − x3 − 3x4 = −2 x1 + 2x3 − x4 = −4
1. Construct an AVL tree for the list C, S, U, M, B, W, I, N. Use the alphabetical ascending order of the letters and insert them successively starting with the empty tree. Your answer should present the rotation operations clearly for each letter addition. 2. Present an insertion order for the keys C, S, U, M, B, W, I, and N that leads to a 2-3 tree of height 1. In the problem, you should use the alphabetical ascending...