GATE CS 2024 Set 2 | Question 35

Algorithms › Algorithm Design Techniques · NAT · 1 mark · Answer: 3

  1. Question 35Algorithmsnat1 mark
    Distance of array = minimum number of elements to replace so becomes non-decreasing. The distance of [2,5,3,1,4,2,6] is __________

    Answer: 3

    Solution

    Answer: 3 Elements that can stay form a longest non-decreasing subsequence (LNDS); the rest must be replaced. For [2,5,3,1,4,2,6], an LNDS is (length 4). So replacements .

More GATE PYQ on Algorithm Design Techniques

All GATE CS Algorithms PYQ →

Attempt GATE CS 2024 Set 2 in real GATE exam mode

Full paper with a timer, the GATE interface and a topic-wise analysis — free.

Create free account →