Given a list of numbers ( fixed list) Now given any other
list, how can you efficiently find out if there is any
element in the second list that is an element of the
first list (fixed list)

Answers were Sorted based on User's Feedback



Given a list of numbers ( fixed list) Now given any other list, how can you efficiently find out if..

Answer / ajay

@Karan Verma
as stated in the question, you can not sort the first list
(fixed list)

Is This Answer Correct ?    9 Yes 1 No

Given a list of numbers ( fixed list) Now given any other list, how can you efficiently find out if..

Answer / karan verma

Above method will be most efficient in terms of time
complexity that is O(n).
If we desire space complexity O(1)

--> sort the two lists O(nlogn)
--> find the missing no. O(n)

O(n+nlogn)=O(nlogn)
space complexity=O(1)

Is This Answer Correct ?    11 Yes 7 No

Given a list of numbers ( fixed list) Now given any other list, how can you efficiently find out if..

Answer / raghuram.a

Use a hash table for storing the no.s of 1st list.
now using hash function check whether there is a no. of 2nd
list in the 1st list.(no. of comparisons=no. of elements in
the list!!efficient?)

Is This Answer Correct ?    7 Yes 5 No

Post New Answer

More C Code Interview Questions

¦void main() ¦{ ¦int i=10,j; ¦ j=i+++i+++i; ¦printf("%d",j); ¦getch(); ¦} ¦ output:-30 but in same question if we write as- ¦void main() ¦{ ¦int i=10; ¦ int j=i+++i+++i; ¦printf("%d",j); ¦getch(); ¦} ¦ output:-33 why output is changed from 30 to 33. Can any body answer...

3 Answers  


main() { int i=10; void pascal f(int,int,int); f(i++,i++,i++); printf(" %d",i); } void pascal f(integer :i,integer:j,integer :k) { write(i,j,k); }

1 Answers  


programming in c lanugaue programm will errror error with two header file one as stdio.h and other one is conio.h

1 Answers  


Write a routine that prints out a 2-D array in spiral order

3 Answers   Microsoft,


int DIM(int array[]) { return sizeof(array)/sizeof(int ); } main() { int arr[10]; printf(“The dimension of the array is %d”, DIM(arr)); }

2 Answers   CSC,






In the following pgm add a stmt in the function fun such that the address of 'a' gets stored in 'j'. main(){ int * j; void fun(int **); fun(&j); } void fun(int **k) { int a =0; /* add a stmt here*/ }

1 Answers  


main() { int i=3; switch(i) { default:printf("zero"); case 1: printf("one"); break; case 2:printf("two"); break; case 3: printf("three"); break; } }

1 Answers  


main ( ) { static char *s[ ] = {“black”, “white”, “yellow”, “violet”}; char **ptr[ ] = {s+3, s+2, s+1, s}, ***p; p = ptr; **++p; printf(“%s”,*--*++p + 3); }

1 Answers  


main() { struct date; struct student { char name[30]; struct date dob; }stud; struct date { int day,month,year; }; scanf("%s%d%d%d", stud.rollno, &student.dob.day, &student.dob.month, &student.dob.year); }

1 Answers  


Is the following code legal? struct a { int x; struct a b; }

1 Answers  


what is oop?

3 Answers  


‎#define good bad main() { int good=1; int bad=0; printf ("good is:%d",good); }

2 Answers  


Categories