recategorized by
1,132 views
1 1 vote

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  ]

2 Answers

0 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.
Position:
Show:

Related questions

0 0 votes
2 answers 2 answers
1.9k
1.9k views
radha gogia asked Jul 7, 2018
1,945 views
foo(int n) { for(int i=0 ; i<n ;i++) for(int j=i ; j<=i*i ;j++) if(j%i==0) { for(int k=0;k<j;k++) printf("hii"); } } How to proceed here for analyzing the time complexity...
0 0 votes
1 answers 1 answer
507
507 views
aka 53 asked Nov 22, 2017
507 views
i = n;While(i 0){ i= i/2;}
0 0 votes
1 answers 1 answer
932
932 views
sumitr asked Jul 10, 2018
932 views
What will be time complexity of the program? Explain??#include<stdio.h>int main(){ int i,count=0; for(i=1 ; i<=n ; i++) { for(i=1 ; i<=$n^4$ ; i++) ...
0 0 votes
0 0 answers
520
520 views
usdid asked Apr 16, 2022
520 views
a) what is the iterative equation showing the running time of the algorithm whose pseudocode is given below? b) What is this repeated equation in asymptotic notation usin...