Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Given an unsorted array A of integers of any size, n1, and an integer value x, write an algorithm as a pseudo code (not
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?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Algorithm to find the sum of elements larger and smaller than x in an u...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started