Kavish Dwivedi
BAN USER- 2of 2 votes
AnswersWAP to create a mirror of a binary tree. Extend the code or write a new code if not possible to do mirroring at alternate levels . Here in the second part , if the two trees are placed in front of each other , then odd levels should be exact mirror as a whole and even levels should be exactly same . Then write the iterative version for the above codes.
- Kavish Dwivedi in India for Bangalore| Report Duplicate | Flag | PURGE
Amazon SDE1 Trees and Graphs - 23of 23 votes
AnswersYou are given an array of n integers which can contain integers from 1 to n only . Some elements can be repeated multiple times and some other elements can be absent from the array . Write a running code on paper which takes O(1) space apart from the input array and O(n) time to print which elements are not present in the array and the count of every element which is there in the array along with the element number .
- Kavish Dwivedi in India for Bangalore
NOTE: The array isn't necessarily sorted.| Report Duplicate | Flag | PURGE
Amazon SDE1 Arrays - 0of 0 votes
Answerswrite the test cases for a chess application.
- Kavish Dwivedi in United States for mobile engineering| Report Duplicate | Flag | PURGE
Intern General Questions and Comments - 0of 0 votes
Answerswrite a running c program. When you compile the program another c program shud run and output of the 3rd command must be printed. give the UNIX xommands for the same.
- Kavish Dwivedi in United States for mobile engineering| Report Duplicate | Flag | PURGE
Intern Unix - 0of 0 votes
AnswersGiven N points in 3d space give the minimum number of points as the vertces of the figure and their coordinates which enclose the whole set of points within it.
- Kavish Dwivedi in United States for mobile engineering| Report Duplicate | Flag | PURGE
Intern Algorithm
How would we retireve .. suppose we have 11000111 as a binary representation for a particular string , then even if we trie it , won't it be difficult to get the word to which this string belongs ?
- Kavish Dwivedi August 24, 2013@someguy what does an array of N integers mean ?
- Kavish Dwivedi July 15, 2013campus placements for Blore team.
- Kavish Dwivedi July 15, 2013I had to clear 1 written 3 tech and 1 HR in total but I was ousted after the 2nd round of Interviews in which this question was asked .
- Kavish Dwivedi July 15, 2013I used the following algo in my code which the interviewer accepted at once ....
1.Start traversing the array . Let there be n elements and array be a[].
2.if a[a[i]-1] > 0 and a[i] >0 , then make a[a[i]-1] negative . This will help to keep track of absent nodes .
3.else if a[i]>0 and a[a[i]-1] <0 , subtract n from a[a[i]-1] . This will help to keep the count of multiple visited nodes.
4. else if a[i]<0 and a[i] >= -n , subtract n from a[-a[i]-1].
5. else if a[i] < -n , find subtract n from a[ (-a[i])%n-1 ] .
6. Now traverse the list and if any a[idx] is positive , that means number idx+1 isn't present in the array .
7. If a[idx] is between -n to -1 , that means idx+1 has occured only one time .
8. else if a[idx] is less than -n , that means idx+1 has occured ( int ) ( -a[idx]/n ) + 1 times .
P.S. I wasn't selected for the next round after telling this answer within 5 minutes .
sorry its output of the third program which shud be given
- Kavish Dwivedi July 21, 2012
This is surely not a O(n) algo ...
- Kavish Dwivedi August 24, 2013