tag:blogger.com,1999:blog-8712770457197348465.post5954818268460046146..comments2015-11-28T10:04:31.318-08:00Comments on Javarevisited: Top 15 Data Structures and Algorithm Interview Questions for Java programmer - AnswersJavin Paulhttps://plus.google.com/114528699166048052030noreply@blogger.comBlogger33125tag:blogger.com,1999:blog-8712770457197348465.post-61469179311890626192015-03-12T11:27:54.206-07:002015-03-12T11:27:54.206-07:00sorry for it I didn't see breaksorry for it I didn't see breakAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-10550085147842454812015-03-12T11:26:13.922-07:002015-03-12T11:26:13.922-07:00this code never print its an infinite while loop u...this code never print its an infinite while loop u madeAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-60626368318421366712014-12-17T01:50:04.506-08:002014-12-17T01:50:04.506-08:00Some more algorithm interview questions for true c...Some more algorithm interview questions for true coders :<br /><br />- write code to implement radix sort <br />- write code for two pivot quicksort algorithmAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-53044637733505481712014-12-10T16:20:54.038-08:002014-12-10T16:20:54.038-08:00Your solution for finding the 3rd node from the en...Your solution for finding the 3rd node from the end of the list while may work is not a solution that will get a pass in an interview. Using two pointers shows a fundamental lack of understanding of how to properly traverse lists.<br /><br />There's two ways I would accept as 'correct'. One using a loop and a pointer. Or the even better way of using recursion. Both of them would The Pesthttp://www.blogger.com/profile/00651309390317454552noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-60533594504683156472014-09-23T14:35:04.021-07:002014-09-23T14:35:04.021-07:00anybody help
visual c++
define structuer employee ...anybody help<br />visual c++<br />define structuer employee with name,salary,employmantday then define array of 4 employees then print name of the employee with highst salary and names of all employees who works more than 10 yearsAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-88624701513071922102014-09-18T08:39:59.498-07:002014-09-18T08:39:59.498-07:00@Taurun
Once again(parser kills my code)
Here is O...@Taurun<br />Once again(parser kills my code)<br />Here is O(n) solution:<br /><br />http://pastebin.com/Ez7QQRfHalponhttp://www.blogger.com/profile/04023300126357549281noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-4117256807614411722014-07-26T21:34:23.789-07:002014-07-26T21:34:23.789-07:00I was asked this question at Deutsche bank.
If yo...I was asked this question at Deutsche bank. <br />If you were given all the prices of a stock for a given day in an array of double, you need to find the best buy and sell price. <br />You can only buy stock first and then sell it after that (short-selling is not allowed). <br /><br />The hint is to find the buy and sell prices that give you maximum profit.<br /><br />I've a solution that is Tarunhttp://www.tarun.comnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-8977117974750440902014-07-11T10:39:07.839-07:002014-07-11T10:39:07.839-07:00Thanks a lot for all the blogs. It helped me get a...Thanks a lot for all the blogs. It helped me get a job at major investment bank.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-54215872283562810102014-07-08T13:47:53.346-07:002014-07-08T13:47:53.346-07:00Whenever looping is blocked, the next resort is re...Whenever looping is blocked, the next resort is recursive and vice versa<br /><br />void printstararray(int N)<br />{<br /> if (n == 0) return;<br /> printNstars(N);<br /> printstararray(N-1);<br />}Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-15923559888816779052014-05-20T11:35:18.275-07:002014-05-20T11:35:18.275-07:00can any one help me
Write code in Java that prints...can any one help me<br />Write code in Java that prints:<br /><br />For n = 5<br />*****<br />****<br />***<br />**<br />*<br /><br />You are given this routine<br /><br />private static void printNstars(int n) {<br /> for (int i = 0; i < n; ++i) {<br /> System.out.print("*") ;<br /> }<br /> System.out.println() ;<br />}<br /><br />YOU NEED to write the routine below, whichAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-37278017028221113132014-05-20T11:32:53.721-07:002014-05-20T11:32:53.721-07:00Write a routine X in Java that takes an integer n ...Write a routine X in Java that takes an integer n and returns sum of 1+2+.. +n and square of number n<br /><br />If n = 5, sum = 15 and square is 25. <br /><br /> Write routine X in Java<br /><br />can any one,please give me the soloution<br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-91877098174625098502014-01-16T20:12:20.448-08:002014-01-16T20:12:20.448-08:00Regarding Q-2
we can do it by storing the next poi...Regarding Q-2<br />we can do it by storing the next pointer values of each node , if any duplicate comes then it's a loop.<br />or<br />we can also do with two pointers in O(n). simply say one slow pointer and one fast pointer. slow pointer will increase one time where as fast pointer will increase twice. so if we get fastpointer==slowpointer then there is loop , and if fastpointer==null thentech showhttp://newtechshow.blogspot.in/noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-6110010862065461582013-12-04T01:11:34.717-08:002013-12-04T01:11:34.717-08:00For Question number nine if we just have to find t...For Question number nine if we just have to find the Duplicate values and not their occurance below code is sufficient:<br /><br />import java.util.HashSet;<br />import java.util.Set;<br /><br />public class DuplicateFinder <br />{<br /> public Set getDuplicateValues(T[] arr)<br /> {<br /> Set duplictes = new HashSet();<br /> Set hashSet = new HashSet(arr.length);<br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-66227911847731532292013-10-31T06:29:25.269-07:002013-10-31T06:29:25.269-07:00ans of q4 is not correct.
ans would be
int[] o = ...ans of q4 is not correct.<br />ans would be <br />int[] o = {1,2,3,4,5,6,2,8,9,10};<br />int[] n = new int[o.length+1];<br />for(int i= 0; i < o.length; i++){<br /> n[o[i]]++;<br />}<br /> <br />for(int i= 0; i < o.length; i++){<br /> System.out.println("no of "+ o[i] + " is "+ n[o[i]]);<br />}<br /> Tapan Kumar Dindahttp://www.blogger.com/profile/12717025826081992054noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-27786880319578678522013-10-19T07:23:15.008-07:002013-10-19T07:23:15.008-07:00can you help me:
Consider the file named cars.txt...can you help me:<br /><br />Consider the file named cars.txt, each line in the file contains information about a <br />car (Year, Company, Manufacture, ModelName, Type ). <br />1) Read the file. <br />2) Add each car which is represented using one line of the file to a singular link <br />list. Use an object of the following class. <br />Class node <br />{ <br />int year; <br />stringCompany; <brshouq alshammarihttp://www.blogger.com/profile/04900144961598230111noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-64764723052044825062013-10-17T07:18:45.091-07:002013-10-17T07:18:45.091-07:00HI gyuz, I want to check the two strings are match...HI gyuz, I want to check the two strings are matching 70% or not. Can anyone help me out?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-38576256031559564862013-06-19T22:32:25.522-07:002013-06-19T22:32:25.522-07:00Given a string S, and a list of strings of positiv...Given a string S, and a list of strings of positive length, F1,R1,F2,R2,...,FN,RN, proceed to find in order the occurrences (left-to-right) of Fi in S and replace them with Ri. All strings are over alphabet { 0, 1 }. Searching should consider only contiguous pieces of S that have not been subject to replacements on prior iterations. An iteration of the algorithm should not write over any previousAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-68865247237971823792013-04-30T00:28:21.744-07:002013-04-30T00:28:21.744-07:00Which data-structure should I use to detect deadlo...Which data-structure should I use to detect deadlock between threads? This was asked as write a routine to detect deadlock from a pool of threads to me in a Java interview.Venkynoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-69019990698975151002013-04-28T09:51:41.137-07:002013-04-28T09:51:41.137-07:00In one interview i was asked to write a function t...In one interview i was asked to write a function to print below. input to the function is 3.<br /> *<br /> * * *<br />* * * * Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-48708375150551713522013-04-25T07:26:15.350-07:002013-04-25T07:26:15.350-07:00@Vishnu, I think binary tree is right choice to im...@Vishnu, I think binary tree is right choice to implement a LIMIT order book, where order can match either to exact price or better price, which is lower than specified for buy orders and higher than specified for sell orders. For that reason, you need to navigate to tree, whose node should be price, but they should also contain Queue of Orders to maintain time priority. In short, your Orderbook Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-61201208963765996692013-04-23T04:44:47.898-07:002013-04-23T04:44:47.898-07:00Can you also suggest Which data structure is suita...Can you also suggest Which data structure is suitable for parking lot, imagine you have millions of parking lots?Vishnunoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-3312243061271787262013-04-23T04:43:09.280-07:002013-04-23T04:43:09.280-07:00In one of interview with Credit Suisse, I was aske...In one of interview with Credit Suisse, I was asked to that which data structure will you use to represent and OrderBook in financial market? I wasn't sure, but I replied that Binary tree will be better choice because Orders are always sorted on time, in a particular price bracket for a particular instrument. Can any one please advise on below question, Though I think I tried in hard, still Vishnunoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-55183584405253523342013-04-17T11:38:49.394-07:002013-04-17T11:38:49.394-07:00For the question on identifying the duplicate in t...For the question on identifying the duplicate in the array containing numbers 1 to 100, the difference in actual and expected sums may not give you the duplicate. <br /><br />For instance, if I have an array containing three elements in the range 1-3, with 2 being the duplicate, i.e., the array is 1, 2 and 2, then the actual sum is 5 and the expected sum is 6. The difference is 1, which isn'tAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-67890655373475268412013-04-16T00:37:35.829-07:002013-04-16T00:37:35.829-07:00We can have one more way to solve the first questi...We can have one more way to solve the first question :: using queue. <br /><br />We can maintain a queue and insert the element as we encounter in the linked list. While we are inserting elements, we need to make sure that queue represent the middle element at the beginning. We can do this as follows :: <br />Inserting 3 elements out of n at first allows us to appreciate that it will be the Abhishek Guptahttp://www.blogger.com/profile/17206516251585577992noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-90134672720885154402013-03-29T05:08:04.627-07:002013-03-29T05:08:04.627-07:00Some more codes..1) Find middle element 2) find nt...Some more codes..1) Find middle element 2) find nth element 3) Find and remove loop in list<br /><br />package example.datastructure;<br /><br />public class LinkedlistExample {<br /><br /> public static void main(String[] args) {<br /> <br /> Node head = new Node();<br /> <br /> for (int i =3;i<=10;i++)<br /> {<br /> insertAtTail(head, new Node(""+i, null));<br /> }<br /> Anonymousnoreply@blogger.com