@abhi
we can do it without passing the address to a function. just store the
address of const variable in another variable and change the value...
On Mon, Jul 18, 2011 at 11:56 AM, Abhi abhi123khat...@gmail.com wrote:
Perhaps the only way to alter the value of a variable declared constant in
C
1.Calculate XOR of all the array elements.
2.XOR the result with all numbers from 1 to n =x1
3.After 2nd step, all elements would nullify each other except 2 missing
elements(let x and y) and x1 will contain XOR of x and y
4.All the bits that are set in x1 will be set in either x or y. Get the
@ankit...i m assuming that array of size n contains n-2 elements with 2
elements missing
On Mon, Jul 18, 2011 at 6:07 PM, SAMMM somnath.nit...@gmail.com wrote:
#includestdio.h
int main()
{
int a[]={1,2,3,5,2}; // 2 isrepeated and 4 is missing
int i=0,x=0,j=0,bit;
while(i5)
{
ok then 1st remove duplicates from the array in O(n) then apply my algo...
On Mon, Jul 18, 2011 at 6:13 PM, ankit sambyal ankitsamb...@gmail.comwrote:
@Nishant: Read the question carefully. It says Each number is present
at least once except for 2 numbers.
--
You received this message
@SkRiPt KiDdIe... I think you need to analyze my algo again it will work
for both the cases...
On Mon, Jul 18, 2011 at 6:33 PM, SkRiPt KiDdIe anuragmsi...@gmail.comwrote:
Nishant. Your algorithm works for finding repeated nos. in a [n+2] array
where [1-n] are present atleast once and the
@ankit for removing duplicates=O(n)+O(n)
On Mon, Jul 18, 2011 at 6:36 PM, ankit sambyal ankitsamb...@gmail.comwrote:
@nishant : Time complexity ?? will increase too much
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to
and for finding missing 2 elements= O(n)+O(n)+O(n)+O(n)
so total will be O(n)
but there will be no overflow
On Mon, Jul 18, 2011 at 6:41 PM, Nishant Mittal
mittal.nishan...@gmail.comwrote:
@ankit for removing duplicates=O(n)+O(n)
On Mon, Jul 18, 2011 at 6:36 PM, ankit sambyal
@SkRiPt KiDdIe... see my 3rd post...i've mentioned that 1st we have to
remove duplicate numbers
On Mon, Jul 18, 2011 at 6:56 PM, SkRiPt KiDdIe anuragmsi...@gmail.comwrote:
@Nishant:
1 4 5 4 5n=5
1 2 3 4 5
after xor i.e. your x1 answer contains (2^3^4^5).The missing elements
are
start from top right corner... if a[i][j] x then move left, else if
a[i][j] x then move down and if a[i][j] == x then print i and j
On Mon, Jul 18, 2011 at 11:30 PM, sivaviknesh s sivavikne...@gmail.comwrote:
-- Forwarded message --
From: sivaviknesh s
value of the static variable persists between different function call
On Mon, Jul 18, 2011 at 11:43 PM, geek forgeek geekhori...@gmail.comwrote:
int main()
{
static int var = 5;
printf(%d ,var--);
if(var)
main();
}
y output is 5 4 3 2 1
not 5 5 5 5 5 5 5 5 5
1st convert base 5 to base 10 and then base 10 to base 9
On Mon, Jul 18, 2011 at 11:54 PM, sivaviknesh s sivavikne...@gmail.comwrote:
convert a number in base 5 to base 9
--
Regards,
$iva
--
You received this message because you are subscribed to the Google Groups
Algorithm
void rev_recursion(NODE **head)
{
if(*head==NULL)
return;
NODE *first, *rest;
first=*head;
rest=first-next;
if(!rest)
return;
rev_recursion(rest);
first-next-next=first;
first-next=NULL;
*head=rest;
}
On Sun, Jul 17, 2011 at 2:53 PM, vaibhav shukla
take 2 arrays before and after... before[i] contains the product of all the
numbers before i and after[i] contains product of all the numbers after i
something like this
before[0]=1;
after[n-1]=1;
for(i=1;in;i++)
{
before[i]=a[i-1]*before[i-1];
1.while typing it must show most popular searches starting from the string
which we have typed so far
2.it must show most popular websites first
3.it must show related searches
there can be many more
On Sun, Jul 17, 2011 at 8:05 PM, swetha rahul swetharahu...@gmail.comwrote:
Write
will be O(n) this won't work for large numbers...
On Sat, Jul 16, 2011 at 1:58 AM, Nishant Mittal
mittal.nishan...@gmail.com wrote:
@sagar... I know this solution but it was strictly asked to do in O(n)
time and O(1) space complexity and what if range of numbers is very
large
value of b = 10 (in binary) and since b is a signed integer and also MSB is
1 so final value of b is 2's complement of 10 i.e. -2
On Sun, Jul 17, 2011 at 12:55 AM, Kamakshii Aggarwal
kamakshi...@gmail.comwrote:
@gaurav :y it is -2?y not +2?
On Sat, Jul 16, 2011 at 2:13 PM, sukhmeet singh
delete all the numbers found in list2 from list1 recursively or iteratively
Also optimize ur algo when list1 is sorted in ascending order and list2 is
sorted in descending order
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this
How will you delete duplicate odd numbers from a linked list in O(n) time
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
to do it in O(n)... rather not even in
O(nlogn) without modifying the list
On Fri, Jul 15, 2011 at 11:23 PM, Nishant Mittal
mittal.nishan...@gmail.com wrote:
How will you delete duplicate odd numbers from a linked list in O(n)
time
--
You received this message because you are subscribed
number of elements from both lists and reverse list with minimum
number of elements, go ahead with checking and deleting linearly
surender
On Fri, Jul 15, 2011 at 10:38 PM, Nishant Mittal
mittal.nishan...@gmail.com wrote:
delete all the numbers found in list2 from list1 recursively
segregate even and odd nodes in a singly linked list.Order of even and
odd numbers must be same...
e.g:-
i/p list is 4-1-3-6-12-8-7-NULL
o/p list 4-6-12-8-1-3-7-NULL
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send
how to find kth smallest element in BST...
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
plz recommend me some good sites for OS interview questions...
Thanx in advance
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
do inorder traversal of tree and store values in an array.
Now find pairs by applying binary search on array..
On 6/27/11, manish kapur manishkapur.n...@gmail.com wrote:
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this
WAP to sort an array of character strings on the basis of last
character of each string
eg:- {xxxc , yyya, zzzb} = {yyya , zzzb, xxxc}
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
space
On Mon, Jun 27, 2011 at 1:40 AM, Nishant Mittal
mittal.nishan...@gmail.com wrote:
do inorder traversal of tree and store values in an array.
Now find pairs by applying binary search on array..
On 6/27/11, manish kapur manishkapur.n...@gmail.com wrote:
--
You received
@Harshal... ur solution is nt correct.it is nt printing the
characters in order as given in i/p...
i know the solution using auxiliary array and using an extra character
array to hold the o/p string but if any1 knows inplace solution then
plz rply...
On 6/22/11, Harshal hc4...@gmail.com wrote:
It does *not* prevent deadlock so i think (D) is definitely true.
On Sun, Jun 19, 2011 at 5:15 PM, Akshata Sharma
akshatasharm...@gmail.comwrote:
Two processes, P1 and P2, need to access a critical section of code.
Consider the following synchronization construct used by the processes:
/* P1
//Prog 1
#includestdio.h
int main()
{
float a=75.7;
printf(%.10f\n,a); //prints 75.669482
if(75.7a)
printf(Hi);
else
printf(Hello);
return 0;
}
//Prog 2
#includestdio.h
int main()
{
float a=275.7;
printf(%.10f\n,a);//prints 275.7000122070 *WHY???*
if(275.7a)
printf(Hi);
else
29 matches
Mail list logo