Directi Interview Questions
- 0of 0 votes
AnswersThere's a function named BiasedRandom which returns '0' with probability 'P' and returns '1' with probability '(1-P)'.
- gohil90 June 22, 2012 in India
So define a Random function which surely returns '0' and '1' both with probability 0.5 using the above mentioned function(BiasedRandom).
Note:
-The BiasedRandom function can be used any times in the Random function as you want.
-And on each call of BiasedFunction from the Random function returns '0' and '1' with same probability(say P and 1-P resp.) on single run.| Report Duplicate | Flag | PURGE
Directi Algorithm - 0of 0 votes
AnswersThere's an array of length N. For every element of array, say 'X' , find a element 'Y' in the same array such that,
- gohil90 June 22, 2012 in India
1. Value of Y<Value of X
2. Position of Y<Position of X
3. Position of Y should be as large as possible.
Note: If there's no such element 'Y' fro particular 'X' return NULL. Also give algorithm with time complexity less than O(N*N).| Report Duplicate | Flag | PURGE
Directi Algorithm - 0of 0 votes
AnswersConstruct a BST and do its zigzag traversal.
- souptikpro June 03, 2012 in India| Report Duplicate | Flag | PURGE
Directi Software Engineer / Developer Data Structures - 0of 0 votes
AnswersYou are given a string of ‘n’ characters where n is even. The string only consist of 6 type of characters: (){}[]. The task is to form a well formed expression. A well formed expression consist of proper nesting of braces and their is no priority between the braces like [ > } > ). You can edit any bracket and change it to remaining types for accomplishing the task.
- nk May 02, 2012 in India
Example
A. "(){}" is valid
B. "({[]})” is valid
C. “((})” is invalid| Report Duplicate | Flag | PURGE
Directi Software Engineer / Developer Algorithm - 0of 0 votes
Answersgiven a three character a,b,c.find the total no of N length string formed by there three character.
- spider March 28, 2012 in India
condition
1. no more than 2 consecutive 'a' appear in string.
2 .only one "b" present in string.
3 no condition on "c".| Report Duplicate | Flag | PURGE
Directi Software Engineer / Developer Algorithm - 0of 0 votes
AnswersYou are given 100 stations and distance between each adjacent stations. Now you have to select 10 stations(means 10 hops) among those 100 stations in such a way that maximum of distance between any 2 hops will be minimised. By default 1 and 100 stations are selected , so you need to choose only 8 more stations.
- nitatbit September 19, 2011 in India
The solution to this problem seems like Dynamic programming.| Report Duplicate | Flag | PURGE
Directi Software Engineer / Developer Algorithm - 0of 0 votes
AnswersThere is a drought situation in Agrabah.King got worried and called Aladdin for helping him out. As he is a modern Aladdin he took printouts of places around Agrabah from google maps.For analyzing the map properly, he converted the map into a M x N grid. Each point is represented by either ‘0’ or ‘1’.
- newbie September 12, 2011 in India for Ads
‘1’ represents the unit area of water and ‘0’ represents the unit area of land. King told him to find the largest continuous patch of water so that he can send his people over there.
As our Aladdin is modern, but not a good programmer, he wants your help. Help him out by printing out the largest area water patch available on map.| Report Duplicate | Flag | PURGE
Directi Software Engineer / Developer Algorithm - 0of 0 votes
Answerswrite a code which will receive as input a matrix (int[][] matrix) and which should find all local maximum from the matrix. A local maximum is such a number in the matrix that is greater than all its immediate neighbors. The method should return the List of locations of all local maximum numbers found.
- Ankit August 23, 2011| Report Duplicate | Flag | PURGE
Directi Software Engineer / Developer Algorithm - 0of 0 votes
AnswersImagine a goat placed at upper-left corner of a matrix A[i,j ]and the goat has to go to the lower-right corner of matrix . Now the goat can move only right or down such that when it moves to a different point it eats the grass at that point . If A[i,j] = Acres of grass at the point then write a code in C++ such that the goat eats maximum grass and also moves closer to its destination .
- Ankur November 03, 2010| Report Duplicate | Flag | PURGE
Directi Software Engineer / Developer Coding - 0of 0 votes
Answerswrite a program to find the center of the tree.
- SCARLET October 05, 2010| Report Duplicate | Flag | PURGE
Directi Software Engineer / Developer Algorithm - 0of 0 votes
Answergiven a complete binary tree (either a node is a leaf node or has two children)
- Anonymous August 03, 2010
every leaf node has value 0 or 1.
every internal node has value as the AND gate or OR gate.
you are given with the tree and a value V.
you have to output the minimum number of flips (AND to OR or OR to AND) if the evaluated value is not equal to V, if it is equal return 0, if not possible return -1.
you can just change the value of internal nodes i.e can make and to or , or to and to get the desired output
give the minimum number of flips required to get the desired output.| Report Duplicate | Flag | PURGE
Directi Software Engineer / Developer Data Structures - 0of 0 votes
AnswersWhat are hash tables? What is collision ? How can collision be resolved (He asked me all the methods and still wanted some more :P )?
- game January 11, 2010
When should a Hash table be used and when should a BST?
Do Hash Tables always give constant time 'find' complexity? If yes, why would I ever prefer to use BST over Hash table ?| Report Duplicate | Flag | PURGE
Directi Software Engineer / Developer Hash Table - 0of 0 votes
AnswersYou r given a large string of characters lets call it Sbig. Then there is a small set of characters lets call it Ssmall. You have to find smallest substring of Sbig which contains all characters in Ssmall.
- GoogleInterview January 10, 2010
For example you are given Sbig = "hello what are you doing"
Ssmall= "eo"
answer is "ello"| Report Duplicate | Flag | PURGE
Google Directi Software Engineer / Developer Algorithm - 0of 0 votes
AnswersConsider a complete 'tree'. Find an equality relation between number of internal nodes and external nodes (leaf nodes) in that tree. He started with a binary tree and then extended this question further to 'n'ary tree.
- game January 07, 2010| Report Duplicate | Flag | PURGE
Directi Software Engineer / Developer - 0of 0 votes
AnswersYou are given 2 arrays of size 'n' each. You need to stable-merge these arrays such that in the new array sum of product of consecutive elements is maximized.
- game January 07, 2010
eg
A= { 2, 1, 3}
B= { 3, 7, 9}
Stable merging A and B will give an array C with '2n' elements say C={c1, c2, c3, c4, c5, c6}
You need to find a new array C by merging (stable) A and B such that sum= c1*c2 + c3*c4 + c5* c6..... n terms is maximum.| Report Duplicate | Flag | PURGE
Directi Software Engineer / Developer - 0of 0 votes
AnswersGive some important differences between threads and processes.
- game January 07, 2010
When should I use thread and when should I use processes?
You are given a single processor. Will it be still beneficial if I use threads to parallelize my work? Explain with reasons. If yes, give me a case.| Report Duplicate | Flag | PURGE
Directi Software Engineer / Developer - 0of 0 votes
AnswersGiven 2 sorted arrays A and B, sorted in increasing order, find the minimum value of |A[i]-B[j]| for all i belonging to A and all j belonging to B. Preffered order O(M+n) in the worst case. m being size of array A and n being size of array B.
- game January 07, 2010
Then he extended the same question to n sorted arrays with k elements each. I was required to find the minimum range in which the values fall.| Report Duplicate | Flag | PURGE
Directi Software Engineer / Developer - 0of 0 votes
AnswersHe gave me an array of Integers, each integer allows me to make at max its value jumps. If i am at zero, i'm stuck i cannot move forword. He asked me to find,
- game January 07, 2010
1). If the last index was reachable from the first index.
2). Minimum number of jumps required to reach the last index, given any index as the starting index.
3). Total number of ways one can reach the last index.
I was asked to write a code for this.
ex: 1 3 5 8 9 2 6 7 6 8 9
initially at one i can make only one jump to 3, from 3 i can jump either 1 step reaching 5, or 2 steps reaching 8, or 3 steps reaching 9. Carrying on in the same way till i can hit the last index.| Report Duplicate | Flag | PURGE
Directi Software Engineer / Developer - 0of 0 votes
AnswersA binary tree is given with a positive weight attached to each node. Find the subset of nodes in the tree whose sum give you the maximum weight such that if a node is in the subset, none of its children can be in that subset.
- game January 07, 2010| Report Duplicate | Flag | PURGE
Directi Software Engineer / Developer Algorithm