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

More C Code Interview Questions

why do you use macros? Explain a situation where you had to incorporate macros in your proc report? use a simple instream data example with code ?

main() { char *p; printf("%d %d ",sizeof(*p),sizeof(p)); }

Is it possible to type a name in command line without ant quotes?

void func1(int (*a)) { printf("Ok it works"); } void func2(int a[]) { printf("Will this work?"); } main() { int a; func1(a); func2(a); } a. Ok it works b. Will this work? c. Ok it worksWill this work? d. None of the above

#include<stdio.h> main() { int a = { {10,2,3,4}, {5,6,7,8} }; int *p,*q; p=&a; *q=***a; printf("%d..%d",*p,*q); }

main() { char *str1="abcd"; char str2[]="abcd"; printf("%d %d %d",sizeof(str1),sizeof(str2),sizeof("abcd")); }

Given n nodes. Find the number of different structural binary trees that can be formed using the nodes.

Cluster head selection in Wireless Sensor Network using C programming language.

main() { char c=' ',x,convert(z); getc(c); if((c>='a') && (c<='z')) x=convert(c); printf("%c",x); } convert(z) { return z-32; }

main() { char *p = “ayqm”; printf(“%c”,++*(p++)); }

main() { char i=0; for(;i>=0;i++) ; printf("%d\n",i); }

C statement to copy a string without using loop and library function..

Categories
• C Code (421)
• C++ Code (127)
• VC++ Code (17)
• Java Code (84)
• Dot Net Code (114)
• Visual Basic Code (11)
• Programming Code AllOther (56)