edited by
254 views
0 0 votes

ISI2025-MCS-PCB (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_{1}\right)$ for $i=1,2, \ldots, n$, where
\[
f(x)=(x+1)(x-1)(x-3)
\]

  1. Describe an algorithm that sorts $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

0 0 votes
0 0 answers
310
310 views
Shubham Sharma 2 asked Jun 12, 2025
310 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
2 2 answers
364
364 views
Shubham Sharma 2 asked Jun 12, 2025
364 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...
1 1 vote
0 0 answers
457
457 views
Shubham Sharma 2 asked Jun 12, 2025
457 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
262
262 views
Shubham Sharma 2 asked Jun 12, 2025
262 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...