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

    5386 Points

  2. Bikram

    4230 Points

  3. Habibkhan

    3952 Points

  4. Aboveallplayer

    3086 Points

  5. Debashish Deka

    2564 Points

  6. sriv_shubham

    2318 Points

  7. Smriti012

    2236 Points

  8. Arnabi

    2008 Points

  9. mcjoshi

    1696 Points

  10. sh!va

    1684 Points

Monthly Topper: Rs. 500 gift card

20,863 questions
26,021 answers
59,689 comments
22,131 users