second highest number in a given set of numbers
Answer Posted / suriya
put all nos. in an array and sort it using selection sort in
ascending order the last no. will be the second highest no.
| Is This Answer Correct ? | 6 Yes | 2 No |
Post New Answer View All Answers
You have given 2 array. You need to find whether they will
create the same BST or not.
For example:
Array1:10 5 20 15 30
Array2:10 20 15 30 5
Result: True
Array1:10 5 20 15 30
Array2:10 15 20 30 5
Result: False
One Approach is Pretty Clear by creating BST O(nlogn) then
checking two tree for identical O(N) overall O(nlogn) ..we
need there exist O(N) Time & O(1) Space also without extra
space .Algorithm ??
DevoCoder
guest
Posted 3 months ago #
#define true 1
#define false 0
int check(int a1[],int a2[],int n1,int n2)
{
int i;
//n1 size of array a1[] and n2 size of a2[]
if(n1!=n2) return false;
//n1 and n2 must be same
for(i=0;i
Why do we use pointer to pointer in c?
How can I determine whether a machines byte order is big-endian or little-endian?
Do you know the use of 'auto' keyword?
The number of bytes of storage occupied by short, int and long are a) 2, 2 and 4 b) 2, 4 and 4 c) 4, 4 and 4 d) none
Is using exit() the same as using return?
Explain how do you use a pointer to a function?
How main function is called in c?
Do pointers take up memory?
What does == mean in texting?
What are the key features in c programming language?
There seem to be a few missing operators ..
What is the difference between āgā and āgā in C?
Can we replace the struct function in tree syntax with a union?
What are enums in c?