Given an unsorted array A of integers of any size, n1, and an integer value x,...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Given an unsorted array A of integers of any size, n1, and an integer value x, write an algorithm as a pseudo code (not a program!) that would find out the sum of all elements in the array that have values bigger than x, as well as the sum of all elements in the array that have values smaller than x. For instance, assume that array A is as follows: 10 14 3 22 35 92 5 9 64 Given x 9, the algorithm would find the two sums as 237 and 8. Your algorithm must handle possible special cases. Finally, the algorithm must use the smallest auxiliary/additional storage to perform what is needed. a) What is the time complexity of your algorithm, in terms of Big-O? b) What is the space complexity of your algorithm, in terms of Big-O? Given an unsorted array A of integers of any size, n1, and an integer value x, write an algorithm as a pseudo code (not a program!) that would find out the sum of all elements in the array that have values bigger than x, as well as the sum of all elements in the array that have values smaller than x. For instance, assume that array A is as follows: 10 14 3 22 35 92 5 9 64 Given x 9, the algorithm would find the two sums as 237 and 8. Your algorithm must handle possible special cases. Finally, the algorithm must use the smallest auxiliary/additional storage to perform what is needed. a) What is the time complexity of your algorithm, in terms of Big-O? b) What is the space complexity of your algorithm, in terms of Big-O?
Expert Answer:
Answer rating: 100% (QA)
Algorithm to find the sum of elements larger and smaller than x in an u... View the full answer
Related Book For
Data Structures And Algorithms In C++
ISBN: 9780470383278
2nd Edition
Authors: Michael T. Goodrich, Roberto Tamassia, David M. Mount
Posted Date:
Students also viewed these programming questions
-
Question 11 of 52 expected useful life of 12 years, a salvage value of zero, and is expected to increase net annual cash flows by McKnight Company is considering two different, mutually exclusive...
-
can someone solve this Modern workstations typically have memory systems that incorporate two or three levels of caching. Explain why they are designed like this. [4 marks] In order to investigate...
-
CANMNMM January of this year. (a) Each item will be held in a record. Describe all the data structures that must refer to these records to implement the required functionality. Describe all the...
-
Gandhi Ltd renders a promotional service to small retailing businesses. There are three levels of service: the basic, the standard and the comprehensive. On the basis of past experience, the business...
-
Which of the following is the horizontal asymptote of the graph of f (x) = ex-3 + 2? a. y = -2 b. y = -3 c. y = 3 d. y = 2
-
(2 points) (a) Let f(x, y) = xy' - re"+ r'. Find a function g(r, y) such that the vector field F(x,y) = (f(x, y), 9(r, y)) is conservative. (b) Let C be the piece of the curve y = va from (0, 0) to...
-
describe groupthink and ways to avoid it.
-
Green City Builders' balance sheet data at May 31, 2016, and June 30, 2016, follow: For each of the following situations with regard to common stock and dividends of a corporation, compute the amount...
-
Please help using the 2 documents accordingly and answering all questions. Thank you. Ann is looking to buy an office building in 2014. She plans to rent it out for 5 years (2015-2019) and sell it at...
-
In April 2005, the SEC announced settlement with Coca- Cola Company of charges of fraud and false and misleading financial reporting. The charges arose from gallon push-ing at Coca- Colas Japanese...
-
In reconciling a bank statement, the bank balance is $2,100, and the checkbook balance is $2,001. Which of the following is the most probable reason for the bank balance being larger than the book...
-
a) The Bank of Botswana (BOB) has set the following exchange rates for the Botswana Pula against the Australian dollar: BWP/$ 0.7980-90 A$/$ 0.8613-17 Required: i) An Australian firm asks the bank...
-
2. Suppose the number of steps required in the worst case for two algorithms are as follows: Algorithm 1: f(n)= 3n + 5 Algorithm 2: g(n) = 53n +9 Determine at what point algorithm 2 becomes more...
-
Consider a corporate bond with 10 years until maturity, trading at par (M=100,000). The modified duration of this bond is 14.2 periods. Also consider a Treasury bond with 7 years until maturity. The...
-
Question 2- Dynamic odds-and-evens Problem Definition Write a program called odds_evens01 that reads a (non-empty) sequence of integers. As for question 1 above, your program should first ask for the...
-
Evaluate two to three tasks that you perform on a regular basis that include repetitive motions. Summarize how you would determine the level of risk for developing a musculoskeletal disorder (MSD)...
-
hhhhhtgffnnnnn. three month forward exchange rate? 2) The expected inflation rate in the UK is 3% in one year's time in Russia over the same period the inflation rate is expected to be 12%. The spot...
-
Define the term utility software and give two examples.
-
Adelphi Video Store maintains the following policies with regard to purchases of new videotapes at each of its branch stores: 1. Employees are required to take vacations, and the duties of employees...
-
At the end of the fiscal year, August 31, 20x6, selected accounts from the adjusted trial balance for Mikhails Delivery, Inc., appeared as follows: Required 1. Using the information given, prepare an...
-
Using the relevant data in E 10, give the entries in T-account form to record each of the transactions under the periodic inventory system. Use of Accounting Records in Internal Control
Study smarter with the SolutionInn App