• edited by
313 views
0 0 votes

ISI2025-MCS-PCB (Non-CS) | Question-3

Suppose $X=\left(x_{1}, x_{2}, \ldots, x_{n}\right)$ is an array of numbers (not necessarily integers) sorted in the ascending order, and $Y=\left(y_{1}, y_{2}, \ldots, y_{n}\right)$ is the array constructed as $y_{i}=f\left(x_{i}\right)$ for $i=1,2, \ldots, n$, where
\[
f(x)=(x+1)(x-1)(x-3)
\]

  1. Describe an algorithm to sort $Y$ using $O(n)$ comparisons.
  2. Provide justification for the correctness and the number of comparisons used by your algorithm.

Please log in or register to answer this question.

Position:
Show:

Related questions

1 1 vote
2 2 answers
370
370 views
Shubham Sharma 2 asked Jun 12, 2025
370 views
Given an array $A=\left(a_{0}, a_{1}, \ldots, a_{n-1}\right)$ of integers, your task is to determine the maximum possible sum\[\operatorname{maxsum}(A)=\max _{0 \leq s \l...
0 0 votes
0 0 answers
259
259 views
Shubham Sharma 2 asked Jun 12, 2025
259 views
Suppose $X=\left(x_{1}, x_{2}, \ldots, x_{n}\right)$ is an array of numbers (not necessarily integers) sorted in the ascending order, and $Y=\left(y_{1}, y_{2}, \ldots, y...
1 1 vote
0 0 answers
465
465 views
Shubham Sharma 2 asked Jun 12, 2025
465 views
Consider the following function job(), which takes two positive integers $x$ and $y$, and returns another integer.int job(int x, int y) {if (x y) return x;else if (x y) ...
0 0 votes
1 1 answer
265
265 views
Shubham Sharma 2 asked Jun 12, 2025
265 views
Let $b_{n} b_{n-1} \cdots b_{1}$ be the decimal representation of an $n$ digit number $m$. Let $b_{n} b_{n-1} \cdots b_{2}$ be the integer $a$ obtained from $m$ by stripp...