GATE CSE
First time here? Checkout the FAQ!
x
+1 vote
98 views

Write C Program using Recursive Funtions for the Problem Described below and Analyse the Complexity Of the Code

Problem

Given an unordered array  arr[]  which contains n distincct numbers .  Propose a method which output the number which is neither maximum nor minimum . The algorithm / code  you propose should take minimum running time only. (Writte the code in C language)

[ hint : Do not spent time in sorting the array . Go for a direct method using Recursive Functions  ]

asked in Programming by Active (1.2k points)  
edited by | 98 views

2 Answers

0 votes
time complexity will be o(1) because we have to check only first three or any random three numbers present in array. thus the problem is independent of n.
answered by (51 points)  
if elements are repeating?
if elements are repeating then in wrost case there may be only one distinct element or two elements then it is impossible to find a third no. which is neither maximum nor minimum
Please do write the code and explain.
0 votes
answered by Active (1k points)  
Do you hav any algorithm/ code ?


Top Users Jun 2017
  1. Bikram

    3686 Points

  2. Hemant Parihar

    1480 Points

  3. junaid ahmad

    1432 Points

  4. Arnab Bhadra

    1334 Points

  5. Niraj Singh 2

    1311 Points

  6. Rupendra Choudhary

    1194 Points

  7. rahul sharma 5

    1110 Points

  8. Arjun

    916 Points

  9. srestha

    898 Points

  10. Debashish Deka

    896 Points

Monthly Topper: Rs. 500 gift card
Top Users 2017 Jun 19 - 25
  1. Bikram

    1942 Points

  2. Niraj Singh 2

    1306 Points

  3. junaid ahmad

    502 Points

  4. sudsho

    410 Points

  5. just_bhavana

    368 Points


23,347 questions
30,050 answers
67,326 comments
28,372 users