GATE CSE
First time here? Checkout the FAQ!
x
+1 vote
73 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 | 73 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 Jan 2017
  1. Debashish Deka

    8322 Points

  2. sudsho

    5166 Points

  3. Habibkhan

    4718 Points

  4. Vijay Thakur

    4468 Points

  5. Bikram

    4420 Points

  6. saurabh rai

    4212 Points

  7. Arjun

    4072 Points

  8. santhoshdevulapally

    3732 Points

  9. Sushant Gokhale

    3514 Points

  10. GateSet

    3336 Points

Monthly Topper: Rs. 500 gift card

19,155 questions
24,065 answers
52,872 comments
20,288 users