GATE CSE
First time here? Checkout the FAQ!
x
+1 vote
85 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 | 85 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 Junior (977 points)  
Do you hav any algorithm/ code ?

Related questions



Top Users Mar 2017
  1. rude

    4768 Points

  2. sh!va

    3054 Points

  3. Rahul Jain25

    2920 Points

  4. Kapil

    2734 Points

  5. Debashish Deka

    2592 Points

  6. 2018

    1544 Points

  7. Vignesh Sekar

    1422 Points

  8. Akriti sood

    1342 Points

  9. Bikram

    1312 Points

  10. Sanjay Sharma

    1126 Points

Monthly Topper: Rs. 500 gift card

21,508 questions
26,832 answers
61,091 comments
23,146 users