data Structures, computer science homework help
data Structures, computer science homework help
1. Prove the following formulas:
a. log x < x for all x > 0
b. log(ab) = b log a
2. Evaluate the following sums:
3. What is 2100 (mod 5)?
4. Order the following functions by growth rate: n, n1.5, n2, n log n, n log log n, n log2
n, n log(n2), 2/n, 2n/2, 37, n2 log n, n3. Indicate which functions grow at the same rate.
5. Suppose Tl(n) = O(f(n)) and T2(n) = O(f(n)). Which of the following are true?
a. T1(n) + T2(n) = O(f(n))
b. T1(n) – T2(n) = o(f(n))
6. Consider the following algorithm (known as Horner’s rule) to evaluate
poly = 0;
for( i=n; i>=0; i– )
poly = x * poly + ai
a. Show how the steps are performed by this algorithm for x = 3, f(x) = 4x + 8x + x + 2.
b. Explain why this algorithm works.
c. What is the running time of this algorithm?
7. For each node in the tree of following Figure:
a. Name the parent node.
b. List the children.
c. List the siblings.
d. Compute the depth.
e. Compute the height.
8. What is the depth of the tree in above Figure?
9. a. Show the result of inserting 3, 1, 4, 6, 9, 2, 5, 7 into an initially empty binary search tree.
10. Given input {4371, 1323, 6173, 4199, 4344, 9679, 1989} and a hash function h(x) = x(mod 10), show the resulting
a. open hash table
b. closed hash table using linear probing
c. closed hash table using quadratic probing
d. closed hash table with second hash function h2(x) = 7 – (x mod 7)
11. Show the result of rehashing the hash tables in question 10.
12. A large number of deletions in an open hash table can cause the table to be fairly empty, which wastes space. In this case, we can rehash to a table half as large. Assume that we rehash to a larger table when there are twice as many elements as the table size. How empty should an pen table be before we rehash to a smaller table?
13. Suppose that we replace the delete_min function with find_min. Can both insert and find_min be implemented in constant time?
14. a. Show the result of inserting 10, 12, 1, 14, 6, 5, 8, 15, 3, 9, 7, 4, 11, 13, and 2, one at a time, into an initially empty binary heap.
b. Show the result of using the linear-time algorithm to build a binary heap using the same input.
15. Show the result of performing three delete_min operations in the heap of the previous exercise.
16. Sort the sequence 3, 1, 4, 1, 5, 9, 2, 6, 5 using insertion sort.
17. Show the result of running Shellsort on the input 9, 8, 7, 6, 5, 4, 3, 2, 1 using the increments { 1, 3, 7 }.
part 2
1. Look carefully at the definition of a graph. In one respect, graphs are more specific than trees. What is it?
2. What is the relationship between the sum of the degrees of all vertices and the number of edges of graph G = (V,E)?
3. What is the complexity of breadthFirstSearch()?
4. Show that a simple graph is connected if it has a spanning tree.
Textbook Adam Drozdek, Data Structures and Algorithms in C++, Course Technolo
"You need a similar assignment done from scratch? Our qualified writers will help you with a guaranteed AI-free & plagiarism-free A+ quality paper, Confidentiality, Timely delivery & Livechat/phone Support.
Discount Code: CIPD30
Click ORDER NOW..


