[algogeeks] Re: MICROSOFT:Given a BST and a number. Find two node in a BST whose sum is equal to given number in O(n) time and O(1) space.

2017-09-05 Thread deepikaanand


using iterators: 


__author__ = 'deepika'

"""
This code will return iterator for inorder traversal of a BST
"""
class TreeNode(object):
 def __init__(self, x):
 self.val = x
 self.left = None
 self.right = None

 def __repr__(self):
 return str(self.val)

class InorderIterator:

def __init__(self, root):
self.root = root
self.stack = []
self.appendLeftTree()

def appendLeftTree(self, start=None):
temp = self.root if start is None else start
while temp:
self.stack.append(temp)
temp = temp.left


def next(self):
if self.stack:
next_item = self.stack.pop()
if next_item.right:
self.appendLeftTree(next_item.right)
return next_item.val
return None

class ReverseInOrderIterator:

def __init__(self, root):
self.root = root
self.stack = []
self.appendRightTree()

def appendRightTree(self, start=None):
temp = self.root if start is None else start
while temp:
self.stack.append(temp)
temp = temp.right


def next(self):
if self.stack:
next_item = self.stack.pop()
if next_item.left:
self.appendRightTree(next_item.left)
return next_item.val
return None

class Solution:

def binarySearchBST(self, root, key):
left_itr = InorderIterator(root)
right_itr = ReverseInOrderIterator(root)
left_val = left_itr.next()
right_val = right_itr.next()
while True:
if left_val >= right_val:
break
if left_val + right_val == key:
print " Found: ", left_val, " ", right_val
if left_val + right_val < key:
left_val = left_itr.next()
else:
right_val = right_itr.next()

root=TreeNode(10)
root.left=TreeNode(5)
root.right=TreeNode(11)
root.left.left=TreeNode(1)
root.left.right=TreeNode(8)
root.left.right.left=TreeNode(7)
root.right.right=TreeNode(14)
itr = InorderIterator(root)
result = []
for i in range(7):
result.append(itr.next())
print result

result = []
itr = ReverseInOrderIterator(root)
for i in range(7):
result.append(itr.next())
print result

s=Solution()
s.binarySearchBST(root, 18)


On Sunday, September 2, 2012 at 1:02:57 PM UTC-7, Navin Kumar wrote:
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to algogeeks+unsubscr...@googlegroups.com.


[algogeeks] Re: @Walmart Labs interview questions

2012-10-31 Thread deepikaanand
Hi I appeared for walmart .
the exam for for 90 min no negative marking
mcqs were pretty easy almost all form geeksforgeeks(gate corner). 1 
qsnetworking + 1qs on database(min and max number of rows possible in join 
table) , no of distinct colors required to color map of India .rest were 
from data structures and 2 coding qs 
q1 :to rotate array 1,2,3,4,5 to 4,5,1,2,3
q2 :Display row wise sum
They shortlisted 6 students from 100 students..
Interview round first qs :- Find subarray in array of given sum . 
Interviewer kept his mouth shut all the time.opened his mouth to say just 4 
words wrong , right,yes,no and yeah he gave me a hint to solve this 
qs(already given in geeksforgeeks) to use extra space .
and second qs about SESSION variables in PHP(I had written about my project 
implemented in PHP)
Other qs(asked from other students) was of riddle to find rand7() from 
rand5() ,LIS,LCS etc
.All the best :)




On Tuesday, October 30, 2012 9:42:27 PM UTC+5:30, Shyam Sundar wrote:

 Hi all,

 Has Walmart Labs visited any of your campuses this year? If so, can anyone 
 please provide the details about the interview process and the questions 
 that were asked?


 Thanks
 Shyam Sundar


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/sr5n77ynUgkJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Fwd: Snapdeal placement proceedure

2012-08-31 Thread deepikaanand


 1. some question on fish which has tail and head and a relation was given 
 between its length from head to tail ..It was required to find the complete 
 length of fish (ans : 72 inches) too easy

 2.How will you boil a egg for 9 min using timer of 4 min and 7 min

 3. odd one out OTTFFSS_ ans(E)

 4. four digit number was given . find odd one out (ans : one of them 
 didn't have sum = perfect square)

 5. a man goes to top of hill and returns next day 6am(something like that) 
 taking rest occasionaly probability he rests at same position at least once 
 (ans : 100%)

 6.a lady has eggs in the range of 300 to 400..When she divided them in two 
 buckets 1 egg was left . For 3 buckets 2 eggs were left . For 4 buckets 3 
 egss remained and for 5 buckets 4 egss remained .. find the number of eggs


 7.4 ppl A 1min,B 2min , C 7min and D 10 min ...need to cross a bridge 
 therefore require torch..Min time required to cross brifge

 8.Pick odd one out : 9D  8F  3E  6C

 9.priyank and ravi are playing in http://playing.in/ each turn they 
 pick  number from 1 to 6.they cannot skip there term.priyank started first 
 . suggest a stratergy to priyank to win the game . 50 number initially

 10.one and half egg are laid by one and half egg in one and half day . How 
 many hens are required to lay 6 eggs in 6 days 
 (ans : one and half)

 11 . 25,16,9,36 enjoy company of each other . therefore 11,13,17 will 
 enjoy comany of (ans : 19 , prime number)


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/W9zRSWMCQDEJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Fwd: Snapdeal placement proceedure

2012-08-31 Thread deepikaanand
coding qs (section B)

1. find subarray of 0's and 1's with equal number of 1's and 0's

2. convert link list such that all vowels come in the begining

3. one of the nodes in BST is corrupted find that node

4. to arrange link list such that all alternating are in one and 
others(that is remaining nodes) are in second link list

5. one more question on link list (simple one )



-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/Idt0JjB8i_cJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: CISCO Written Test ??

2012-08-26 Thread deepikaanand
written test will be  (apti + tech) no negative marking

apti from time , speed and distance, probablity , mixtures , profit
and loss (easy)
2 qs to infer from the passage given(critical reasoning)
1 DI set (too simple)
and technical qs 2 simple C o/p qs
A large %age of qs was from digital logic design , OS , networking
only 1 qs(which layer guarantees reliable end to end transmission)
do practice the qs given on various sites,most of the qs are just
repeated...
Interview process :- resume based

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] google paper

2012-08-10 Thread deepikaanand
Somebody from DCE plz tell the paper pattern of google...

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/BjLRVjRlekIJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Yahoo

2012-08-08 Thread deepikaanand
Has anyone appeared for Yahoo recentlyplz tell the pattern of the paper 

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/HL1OrE0BzxYJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] directi paper pattern

2012-07-31 Thread deepikaanand
can anyone tell me the pattern (selection procedure )followed by directi 
this year 

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/uaKshpROlGoJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Equal probability between 1-7

2012-07-28 Thread deepikaanand
int rand7()
{
 int x = 5*rand5() + rand5(); //enlarge the range from (0 to 5 )to 0
to 24 by multiplying with 5
if(x  20)
return rand7() ;//recursive call
else
return x%7;//this will result in uniform distribution of number
between 0-6


}

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] adobe aptitude test

2012-07-25 Thread deepikaanand
can anybody tell me which topics are asked in adobe apti test...and what is 
the usual level of qs asked in aptitude test...

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/hdqti4gC8igJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: output

2012-07-25 Thread deepikaanand
for the first o/p qs
as p1 is moving towards the NULL('\0') character so is p2...to avoid dis 
save the base address and den let p2 move forward with p1

char *p1=Name;
char *p2;
p2=(char *)malloc(20);
char *save;
save = (char *)malloc(20);
save = p2;
if(p2==NULL)
cout\n NOT ENOUGH SPACE;
else
{

while(*p2++=*p1++);

printf(%s\n,save);
}

for the second qs o/p = 25 
cz post incr means first use den incr  thererfore 5*5 



-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/lOll02QN_pwJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: [Amazon]

2012-07-25 Thread deepikaanand
every element in 3D array can be written in the form of *(*(*(a+i)+j)+k) = 
a[i][j][k]
ele = required element to be searched for 
say M = number of 3D matrices
R = number of row
C = number of col

First find the most probable matrix in which the element might be present
fix j = R-1
fix k = C-1 //as index starts from 0 
max = *(*(*(a+i)+j)+k) //which is a[i][R-1][C-1]
min = ***(a+i) //which is a[i][0][0]
where is varies from 0 to M-1 

now if ele =min  ele = max
then index = i; //index = required matrix number 
 Now search as u shall search in 2D matrix keeping i constant and varying j 
and k

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/Bo3X7D2XPPQJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: output

2012-07-25 Thread deepikaanand
@ jatin 
then there is something wrong I executed d same prog which I have pasted 
here...it was giving me the correct answer and for the second qs  has no 
absolute answer it depends on compiler 


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/TOSg6xbES24J.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: output

2012-07-25 Thread deepikaanand
sent... 

On Wednesday, July 25, 2012 9:18:46 PM UTC+5:30, jatin wrote:

 Trie ??if u have it to mail kardio...
 On Wednesday, 25 July 2012 21:10:55 UTC+5:30, deepikaanand wrote:

 @ jatin 
 then there is something wrong I executed d same prog which I have pasted 
 here...it was giving me the correct answer and for the second qs  has no 
 absolute answer it depends on compiler 



On Wednesday, July 25, 2012 9:18:46 PM UTC+5:30, jatin wrote:

 Trie ??if u have it to mail kardio...
 On Wednesday, 25 July 2012 21:10:55 UTC+5:30, deepikaanand wrote:

 @ jatin 
 then there is something wrong I executed d same prog which I have pasted 
 here...it was giving me the correct answer and for the second qs  has no 
 absolute answer it depends on compiler 




-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/fsXZTCbPuIgJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Finding the repeated element

2012-07-19 Thread deepikaanand
http://ideone.com/vuAse

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/rbiZjy8dcgEJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Amazon Interview Question

2012-07-12 Thread deepikaanand
If the assumption is that there is only one element which occurs
once , some elements repeat twice and only one element which repeats
thrice

then following is the code according to the assumption made 

http://ideone.com/yseYy

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Microsoft interview qs

2012-07-09 Thread deepikaanand
@Atul
thanx for the code its working for the example you took...Please check
the same for i/p abcmno,abcmnop

Algo displays:- mno
It should display mno
mnop...

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Given only a pointer to a node to be deleted in a singly linked list how you handle deleting last node

2012-07-09 Thread deepikaanand
No there is no way to delete the last node in such a situation
though u can replace the info part of such a last node with
'#'though it wont delete the node but now u know that u can
traverse the list while node-info != '#'

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Max sum circular array

2012-07-09 Thread deepikaanand
What is best approach to find max sum in a circular array...

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Inversion problem

2012-07-08 Thread deepikaanand
http://www.geeksforgeeks.org/archives/3968


On Jul 8, 11:01 am, Navin Kumar algorithm.i...@gmail.com wrote:
 Let A[n] be an array of n distinct number. If ij and A[i]  A[j] then the
 pair (i , j) is called inversion of A.

 Give an algorithm that determines the total number of inversions in
 O(nlogn) 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 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Write a C program to reconstruct a BST from a given array of preorder traversal.

2012-07-04 Thread deepikaanand
@Navin
I dont think der is any need to sort the preorder traversal
given ...it will cost u more
as sorting take O(n log n  ) and recursion alone will take O(n^2)
{mentioned in step 4 }

sO the overall complexity will be the sum of two..+ space of O(n) //to
store inorder traversal

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] trie display

2012-06-28 Thread deepikaanand
If there is a trie of following strings(say URLs)
abcde,abcegh,abcpqr,abcxyz,xyz

if input = abc
then output should be = de,egh,pqr,xyz

How can I code for this ???

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: trie display

2012-06-28 Thread deepikaanand
@Prem

I know the implementation of trie...But I have doubt that say I have
struct trie * current..
and input = abc...The last character matched with head-CHILDREN[i]-
letter will be 'c'... now current points to c

next step- there will be 4 branches from
'c'...de,xyz,efgh,pqr...

Now  if write
for(i=0;i26;i++)
{
if (current-CHILDREN[i]!=NULL  current-CHILDREN[i]-islast==0)
{
cout  current-CHILDREN[i]-letter; //d   e
current = current-CHILDREN[i];//head now points to 'e'
}
}



The problem I am facing is how to take back current pointer to 'c'
so that now I get efgh as output...and secondly how can I make sure
that this time 'd' node is not selected again???

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: trie display

2012-06-28 Thread deepikaanand
@Prem
I know the implementation of trie...But I have doubt that say I have
struct trie * current..
and input = abc...The last character matched with head-CHILDREN[i]-
letter will be 'c'... now current points to c




next step- there will be 4 branches from
'c'...de,xyz,efgh,pqr...
Now  if write
for(i=0;i26;i++)
{
if (current-CHILDREN[i]!=NULL  current-islast==0)
{
cout  current-CHILDREN[i]-letter; //d   e
current = current-CHILDREN[i];//head now points to 'e'
}
}




The problem I am facing is how to take back current pointer to
'c'
so that now I get efgh as output...and secondly how can I make sure
that this time 'd' node is not selected again???

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Microsoft interview qs

2012-06-28 Thread deepikaanand
//Taken from careercup.com

Design the autocomplete feature (ex:Google Suggest)

I assumed {abcde,abcegh,abcpqr,abcxyz,xyz ,abcmno} URLs
and stored them in trie...Such if the user enters abc ...the o/p will
be

abc is a prefix in 5 number of cases
  d e
  e g h
  m n o
  p q r
  x y z


Now say if I add more strings of the form abcdpqr,abcdprst..How can
I modify this code such that now thw o/p is

  d e
  e g h
  m n o
  p q r
  x y z
 d p q r
 d p r s t

code in c :-
http://ideone.com/rBvQb

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: trie display

2012-06-28 Thread deepikaanand
It is not working..Even i tried to solve the problem using recursion
but it didnt work

code :-

http://ideone.com/UhTTx

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Reverse Queue

2012-06-24 Thread deepikaanand
code:-
http://ideone.com/yMQSK

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Question asked in Amazon online test

2012-06-23 Thread deepikaanand

will bubble sort give number of swaps??

I tried the (bubble sort) code of 1,0,0,1,1,0,1 swapcount = 5
and for the array  (0,0,1,0,1,0,1,1)swapcount = 3

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Question asked in Amazon online test

2012-06-23 Thread deepikaanand
@saurabh..wat array r u getting finallyis it all 1's or in sorted
order for the input
 int a[8]={1,1,1,0,1,0,1,1};

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Sorting using array of pointer

2012-06-22 Thread deepikaanand
//To sort an array of integers by not moving the element itself ..we
can only use array of pointers...to adjust the pointers
I have used bubble sortbut it only runs for the first pass when i
= 0 ..but not for further values of i

void sort(int A[])
{
int i ;
  //int **a = ptr[0];
for(i=0;iMAX-1;i++)
{
cout\n case number = i;
for(int j = 0;jMAX-i;j++)
{
if((*(ptr[j])) (*(ptr[j+1]))) //this means A[j]  A[j+1]
{
int *a = ptr[j+1];
ptr[j+1] = ptr[j];
ptr[j] = a;
display();

}
}
}//end of outer loop
}//end of function


full code :
http://ideone.com/IeSRQ

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Sorting using array of pointer

2012-06-22 Thread deepikaanand
@vindhya thanx ..

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] How are strings stored in memory??

2012-06-14 Thread deepikaanand
If a string is input via stdin
char str[20];
cout\n Enter string ;
cinstr;   //say xyz\npqr

coutstr;   //output = xyz\npqr  because each character is stored in
ASCII format



where as if
str[] = xyz\npqr;
then
coutstr ; //output = xyz
pqr ???

Please explain

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Algorithm internship question paper NSIT

2012-04-26 Thread deepikaanand
28 questions 120 min +1/-0.25

3 programming qs
1.to add two numbers stored in link list
2.to test is the given tree is a sumtree or not
3.to store numbers from a tree to a file and then retrieve those
values and buld the tree

Objective type qs
1. rec= fork();
rec= fork();
rec= fork();
rec= fork();
if(!rec)
printf(one);
else
printf(two);


2).based Context free grammer

3.)given a heap of level order ()
a)add a number
b)extract 10
c)add 7
what is the new content of heap

4.)P1 - P2 ; means P1 should be executed before P2
Every processes takes 1 timestamp to complete ; and processes on
multiprocessor platform takes 2 timestamps ; as P1 should be executed
before P2...such 8 processes were given : how much timestamp will they
take if there were 2 processors and 4 processors

5.) Match the following to match complexeties of sorting algo with
their name

6.)Given a link list last node is selected and moved to first and  '3'
most appropriate statements had to be selected

7.)One question on IP ..dat if a host can take multiple IPs or a Lan
can share IP addresses

8.)One  question to select the false statement :
Emin and Emax are the two edges of a graph ...
a)Emin should be included in minimum spanning tree
b)Emax cannot be a part  of min spanning tree
c) A graph can have only minimum spanning tree

9)one qs on recursion and tree.. and o/p had to be chosen

10)if der is 5*5 grid and three identical coins in how many ways can
dey they be placed such that a coins have no common row or col are
repeated..find number of ways possible
11) 3-4 qs on probablity (difficult)

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: RBS internship paper

2012-03-10 Thread deepikaanand
NSIT

On Mar 10, 12:50 pm, saurabh arora saurabharora8...@gmail.com wrote:
 which college

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] RBS internship paper

2012-03-09 Thread deepikaanand
First Rounf :

Aptitude paper :-
 three section(Quant,aptitude,verabal)
20 qs each part
negative marking after 25 % of wrong attempts

quant was quite difficult :-
1.questions from area of triangle(two find a side if longest side and
other side along with area is given)
2.(loga + log b + log c)/log 6 = 6..find a+b+c..if a,b,c form an
increasing GP
3.)grandpa has 5 chocol,to be distributes among 3
grandchildren ...tell hw many ways can sweets be distributed if any no
of choc may be given to any child
4)time speed and distance problems
5)no question from probabilty
6)qs on basic algebra like find number of odd factors
7)no qs from interest , discounts
8) one problem related to time and work


aptitude :-(medium)
simple data sufficiency questions
qs on leap year..
1)If date of last sunday of last month is added to  first monday of
next month,the sum is 38..which yr can it be
2)If a leap year has 52 tues,52 thurs,52 saturdays find day on sunday
3)Question from deprecision ,taxes (a table was given fr steel
company) n qs based on profit percentage etc
4)if a circus has five members A,B,C,D,E and sirnames(Q,W,E,R,T,Y) not
respectively and five prof possibles(juggling,clown,ring
master,tightrope walker,unicyclist) and five possible year of
experience (9,10--13)
5 conditions were given to find the respective
names,sirnames,prof,year of experience

Verbal : - (quite easy)
2 qs on para jumbles
3 qs on fill in the blanks testing vocab and grammer rule of (has/have
been i.i singular,plural)
3 passages
1 based on game as in they may be sequential or simultaneous
1 based on medicine
1 based on computer worms..describing a new system designed to detect
worm and its shortcoming..

3-4 qs based on each passage.

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Qualcomm exam

2011-10-05 Thread deepikaanand
folowing is d internship paper of qualcomm (software position)
 3 sections analytical,programming skills and CSE

analytical paper had qs from relationships,to derive code ,pattern
matching,sets ,i found it a little bit tough in comparison to other
two sections
programming paper had input o/p qs ver easy.considerable number od qs
were asked from OS (virtual memory,multitasking computers,shallow
copy, OS used by IBM pc/2)
.ouptut qs from a given  flow chart.
in CSE section qs like to find avg waiting time for round robin,page
fault using FIFO technique,avg waiting time for FCFS scheduling.
time complexity for merging to sorted files of diff sizes
50,10,15,25 ;.Program to find reverse of a number as an o/p qs
This section ws easy too..
after switching over to another section,the previous attempted section
couldnt be accessed

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Qualcomm Internshhip Paper

2011-10-05 Thread deepikaanand
folowing is d internship paper of qualcomm (software position)
 3 sections analytical,programming skills and CSE

analytical paper had qs from relationships,to derive code ,pattern
matching,sets ,i found it a little bit tough in comparison to other
two sections
programming paper had input o/p qs ver easy.considerable number od qs
were asked from OS (virtual memory,multitasking computers,shallow
copy, OS used by IBM pc/2)
.ouptut qs from a given  flow chart.
in CSE section qs like to find avg waiting time for round robin,page
fault using FIFO technique,avg waiting time for FCFS scheduling.
time complexity for merging to sorted files of diff sizes
50,10,15,25 ;.Program to find reverse of a number as an o/p qs
This section ws easy too..
after switching over to another section,the previous attempted section
couldnt be accessed

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] thread qs

2011-09-28 Thread deepikaanand
PLz expalin the output of the following program :-


#includestdio.h
#includepthread.h
void *thread(void *);
int main()
{
pthread_t t1,t2;
char msg1[]=HELLO1;
char msg2[]=HELLO2;
printf(Before create1 \n);
pthread_create(t1,NULL,thread,(void *)msg1);
printf(after create1\n);
printf(before create2\n);
pthread_create(t2,NULL,thread,(void *)msg2);
printf(After create2\n);
printf(Before join1\n);
pthread_join(t1,NULL);
printf(After join1\n);
printf(Before join2\n);
pthread_join(t2,NULL);
printf(After join2\n);
return 0;


}
void *thread(void *message)
{
char *msg;
msg=(char *) message;
printf(%s\n,msg);
return NULL;

}

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: output expalnation?

2011-09-26 Thread deepikaanand
junk value cz b=6 will not get executed

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] royal bank of scotland

2011-09-14 Thread deepikaanand
wat is selection procedure of RBS (for internships or placements)

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: worst case complexity

2011-09-10 Thread deepikaanand
ans : O(n^5)

inner most loop rums for j times
then middle loop sums  'j ' from j=0 to j= i^2 so ans is proportional
to i^4
and outer loop again sums it for n times so ans : O(n^5)

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Questions --

2011-09-10 Thread deepikaanand
seed fill or flood fill is a technique to fill polygon of arbitrary
boundaries ..by selecting a point or a seed in the polygon and
recursively calling the function to fill the polygon

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: enum vs macro

2011-09-04 Thread deepikaanand
macro is a pre processor directive while enum is not

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] atrenta paper

2011-08-18 Thread deepikaanand
plz sm1 from NSIT upload Arenta qs paper

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Goldman sachs _ DCE _ 10 AUGUST

2011-08-13 Thread deepikaanand
+1 ...plz upload the qs

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] suffix tree and skip list

2011-08-13 Thread deepikaanand
 plz post the code for implementation of suffix tree and skip list in
C/C++

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: goldman sachs paper

2011-08-11 Thread deepikaanand
@UTKARSH i know the selection criteria but i want to know exactly the
qs asked...plzz post a few qs if u knw any...

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: goldman sachs paper

2011-08-11 Thread deepikaanand
 plzz post the paper  ! !

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: goldman sachs paper

2011-08-11 Thread deepikaanand
@Krishna can u plzz gv me hint what sort of aptitude qs are asked..as
i dont practise Quant analysis type qs frequently..so do I need to go
through aptitude books before the exam ?

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] goldman sachs paper

2011-08-10 Thread deepikaanand
can anyone please post the questions asked in goldman sachs this year

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] MS written test qs

2011-08-07 Thread deepikaanand
can any1 plz gv the solution of the following problem ;-
You have to make a package library which will do the calculation of
(a^b)mod(c), where a, b, c are very large size of 1 digits. (^-
power).
Design a data structure for the numbers' storage and suggest what
functions
will you be providing to user with them. Also mention the advantages
of
using that DS.

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: remove duplicate words in a string

2011-08-05 Thread deepikaanand
static int array[256];
removedupli(char s[],int n)
{
array[s[0]]=1;
for(i=1;in;i++)
{
if(array[s[i]]==0)
array[s[i]]=1;
else
{
for(pos=i;in;i++)
s[pos]=s[pos+1];
i--;
}
}



}

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: remove duplicate words in a string

2011-08-05 Thread deepikaanand
ya an array of 256 is surely a wastage of space but this was i couls
think in my microsoft interview as the result should have also been i
place that is
i/p : AAA BBB CCC
o/p:A BC//space should also be removed
::explanantion
s[0] is alwayz unique therfor array[s[0]] = 1 = this char has already
occured
if the encountered s[i] has corresponding array[s[i]]==0 =this char
has not occured yet
else
delete dat particular char at pos 'i' n decrement i

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Duplicates in a string

2011-08-05 Thread deepikaanand
static int array[256];
removedupli(char s[],int n)
{
array[s[0]]=1;
for(i=1;in;i++)
{
if(array[s[i]]==0)
array[s[i]]=1;
else
{
for(pos=i;in;i++)
s[pos]=s[pos+1];
i--;

-- 
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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.