Given a circular list of characters randomly ordered. For each character ‘’ in the list, it is requested to find the next greater character ‘’ in the list, and then to replace ‘’ by ‘’. If there is no greater character, replace ‘’ by ‘@’. Given that A
Given a circular list of characters randomly ordered. For each character ‘’ in the list, it is
requested to find the next greater character ‘’ in the list, and then to replace ‘’ by ‘’. If
there is no greater character, replace ‘’ by ‘@’.
Given that A<B<C<…<X<Y<Z
Example 1:
input: [E, D, B, A, K, W, G]
output: [K, K, K, K, W, @, K]
Explanation:
Considering each character and how it is replaced:
1) Consider E, it is requested to find the next greater
character. We can easily notice that D, B, A are not
greater than E, while K is the next greater
character. This is why E is replaced by K.
2) The same scenario happens with D, B, and A,
where they are all replaced by K.
3) Consider K, the next greater character is W, and
hence K is replaced by W.
4) Consider W, there is no character in such circular
list greater than W, and hence it is replaced by @.
5) Consider G, as this is a circular list, the next
character is E, which is not greater than G, while K
is the next greater character. This is why G is
replaced by K.
Similarly, here is another example:
Example 2, input: [K, M, Y, R, E, J, A]
output: [M, Y, @, Y, J, K, K]
a) Design a brute force
complexity. [explain your answer]
b) This problem belongs to which type of problems: P, NP, NP-Hard, NP-Complete? explain why
c) Design a more efficient algorithm to do the same task analyse the complexity
of your algorithm
[Important instruction to be followed: Create an arbitrary unsorted list of 7 characters and
use it to provide full explanation of how your proposed algorithm should work step by
step]
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)