# Efficient algorithm for determining if any single

• Notes
• 10

This preview shows 3 out of 8 pages.

efficient algorithm for determining if any single number in the array makes up  more than 50% of the array? Given a binary search tree, what is the algorithm to print it out in reverse  order?  What is the big-oh of this algorithm? What is the big-oh of the algorithm if the tree is not bushy (e.g. if the values  were inserted into the tree in alphabetical order)

Subscribe to view the full document.

Review Problem #1 What does the following recursive function print out? int test(int n){ if(n<=0) return 0; cout << n; if(n%2==0) return 1+test(n-3); else return 2+test(n-1); } void main(){ cout << endl << test(5) << endl; }
Review Problem #2 If you were to perform a pre-order traversal of this binary tree and insert  each node, in the order it is processed, into a closed hash table of size 7,  show the resulting hash table.  10 7 12 3 11 14 3

Subscribe to view the full document.

Review Problem #3 Show the resulting binary search tree after deleting node 10.  10 7 12 3 11 14 3
Review Problem #4 What is the big-oh of the following algorithm? void func(int arr[], int n) {     set<int> s;     for (int i=0;i<n;i++)     {        for (int j=0;j<i;j++)             s.insert(arr[i] * arr[j]);     } } What happens if you change the set to an STL list?

Subscribe to view the full document.

You've reached the end of this preview.
• Winter '08
• DavidSmallBerg
• Recursion, Sort, Big O notation, Self-balancing binary search tree, Review Problem

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern