In: Computer Science
Please post all code in Pseudo code. Please post ORIGINAL answers do not copy from similar questions. Please post in a format that can be directly copied. Reasoning on answers would be most helpful but not required. Thank you in advance for your help.
1. List the following functions according to their order of growth from the lowest to the highest:
(n−2)!,
5lg(n+100)10,
22n,
0.001n4 +3n3 +1,
ln2 n,
√3 n,
3n.
2. The range of afinite nonempty set of n realnumbers S is defined as the differ- ence between the largest and smallest elements of S. For each representation of S given below, describe in English an algorithm to compute the range. Indi- cate the time efficiency classes of these algorithms using the most appropriate notation (O, ?Omega, or ?).
a. An unsorted array
b. A sorted array
c. A sorted singly linked list
d. A binary search tree
1
5lg(n+100)10,
ln2 n,
√3 n,
0.001n4 +3n3 +1,
3n,
22n,
(n−2)!.
2
a. An unsorted array:
Algorithm:
Time complexity is O(n)
b. A sorted array:
Algorithm:
Time complexity is O(1)
c. A sorted single linked List:
Algorithm:
Time complexity is O(1)
d. A binary search tree
Algorithm:
Time complexity is O(n)
Hope this helps