Question

In: Computer Science

Please post all code in Pseudo code. Please post ORIGINAL answers do not copy from similar...

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

Solutions

Expert Solution

1

5lg(n+100)10,

ln2 n,

√3 n,

0.001n4 +3n3 +1,

3n,

22n,

(n−2)!.

2

a. An unsorted array:

Algorithm:

  • Initialize two variables namely min and max to 9999 and -9999 respectively
  • Traverse through the array until we find min and max
  • print the difference between max and min

Time complexity is O(n)

b. A sorted array:

Algorithm:

  • As the array is already sorted store the first element in min and last element in max
  • print the difference between max and min

Time complexity is O(1)

c. A sorted single linked List:

Algorithm:

  • As the linked list is already sorted, store the first element of the list in min and the last element in max.
  • print the difference between min and max

Time complexity is O(1)

d. A binary search tree

Algorithm:

  • Traverse until the Left most element is reached and store the value in min.
  • Traverse until the Right most element is reached and store the value in max.
  • print the difference between max and min

Time complexity is O(n)

Hope this helps


Related Solutions

Please do not copy from other post or the copy from the web Creating Sunburst: Legal...
Please do not copy from other post or the copy from the web Creating Sunburst: Legal and Organizational Considerations Ravi, who has a degree from State University in mechanical engineering, was previously employed by a start-up firm in New York City. He worked long hours for little pay, but when the business sold, his stock options paid off. As a result, he now has some time and $100,000 to invest in Sunburst. More importantly, Ravi has the knowledge and know-how...
Please dont copy from other answers. Do as simole as possible (C programming). code 1: create...
Please dont copy from other answers. Do as simole as possible (C programming). code 1: create a program that will copy the contents of a text file called (input.txt) to a file called (copied.txt). After the program runs the contents of both files should be the same. (im creating the input manually) code 2: Change the code from fist part so that instead of always copying from input.txt to copied.txt it instead asks the user to provide both file names....
*Please give the answers in pseudo code 1) Design an algorithm that will receive two integer...
*Please give the answers in pseudo code 1) Design an algorithm that will receive two integer items from a terminal operator, and display to the screen their sum, difference, product and quotient. Note that the quotient calculation (first integer divided by second integer) is only to be performed if the second integer does not equal zero. 2) Design an algorithm that will read two numbers and an integer code from the screen. The value of the integer code should be...
**Please fill out the chart post at the bottom and please do not copy and paste...
**Please fill out the chart post at the bottom and please do not copy and paste a previous answer that has been used on CHegg. Lehighton Chalk Company manufactures sidewalk chalk, which it sells online by the box at $24 per unit. Lehighton uses an actual costing system, which means that the actual costs of direct material, direct labor, and manufacturing overhead are entered into work-in-process inventory. The actual application rate for manufacturing overhead is computed each year; actual manufacturing...
please don't copy from previous post and answer all Chapter 4 - Discussion Question (DQ) #...
please don't copy from previous post and answer all Chapter 4 - Discussion Question (DQ) # 2, 7, 11, 13, 21, 25, 30, 34 (DQ2) What is the difference between purchasing and strategic sourcing? (DQ7) In what ways is corporate social responsibility different from business ethics? (DQ11) What are the benefits of sustainable sourcing? Can firms actually make money from sustainable sourcing? Do you think it is a good practice? Why ? (DQ13) How could you apply sustainability to a...
TASK: ( answers should be computerized and in details - please do not copy and paste...
TASK: ( answers should be computerized and in details - please do not copy and paste - about 1500 words ) Select an organization of your choice and carry out the following tasks. Conduct a research on the marketing and promotional strategies of the organization selected. Your Report should include the following: 1. Introduction 2. Summarize the various promotional strategies used by the organization in implementing an Integrated Marketing Strategy. Identify the risks associated with promotional campaigns and discuss how...
In C++ Please comment in all-new lines of code, thank you DO NOT USE ANSWERS THAT...
In C++ Please comment in all-new lines of code, thank you DO NOT USE ANSWERS THAT ALREADY BEEN POSTED, please use code from the assignment Copy-paste will be reported Write a program to compare those two searching algorithms and also compare two sorting algorithms. You need to modify those codes in the book/slides to have some counters to count the number of comparisons and number of swaps. In the main function, you should have an ordered array of 120 integers...
Please do not reply to this question by copy pasting the code that someone wrote for...
Please do not reply to this question by copy pasting the code that someone wrote for this question because it is incorrect. The code written before for this messes up two vectors. Please make sure you write a new code without that error. 8.10 Project 4 - Help me Sort My Roster About The class roster program is working really well. However, it would be nice to be able to sort students based on first name, last name, or their...
Please don't copy and paste answers from several sources. Write in your own words! Do you...
Please don't copy and paste answers from several sources. Write in your own words! Do you feel teams help or hurt creativity? Give specific examples. How should you handle a freeloader (someone not willing to do their share of the work) on a team where you are a member? Be specific. For an organization where you have worked, list three ways the organization helped you do your job. (This can be any type of organization if you have never worked.)...
R studio questions Write up your answers and paste the R code Copy and paste all...
R studio questions Write up your answers and paste the R code Copy and paste all plots generated. First create a sample drawn from a normal random variable. R has many distributions for which you can get probabilities and draw random numbers. We are going to use the normal. Go to help in R and type in rnorm. You will see a write up for functions associated with the normal distribution. dnorm is the density; pnorm is the probability distribution...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT