GATE CSE
First time here? Checkout the FAQ!
x
+1 vote
108 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 | 108 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 Aug 2017
  1. ABKUNDAN

    4654 Points

  2. Bikram

    4012 Points

  3. akash.dinkar12

    3136 Points

  4. rahul sharma 5

    2832 Points

  5. manu00x

    2644 Points

  6. makhdoom ghaya

    2370 Points

  7. just_bhavana

    2040 Points

  8. Tesla!

    1742 Points

  9. pawan kumarln

    1574 Points

  10. learner_geek

    1554 Points


24,864 questions
31,941 answers
74,060 comments
30,062 users