Answered step by step
Verified Expert Solution
Link Copied!

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... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Structures And Algorithms In C++

Authors: Michael T. Goodrich, Roberto Tamassia, David M. Mount

2nd Edition

978-0470383278, 0470383275

More Books

Students also viewed these Programming questions

Question

Was it ethical to deny treatment to the control group?

Answered: 1 week ago

Question

Implement the deque ADT with a doubly linked list.

Answered: 1 week ago