Convert Sorted Linked list to balanced BST

In previous problem, we discussed how to create a balanced binary search tree for a sorted array. Now we’ll see how to create the same from a sorted linked list. Method 1: This solution is similar to our previous solution but unlike array accessing middle element of linked list is not O(1). Approach : i. Read More →

final keyword in java

The final keyword in java is used to restrict the user. The final keyword can be used in many context. Final can be: 1. Vriable 2. Method 3. Class If you make any variable as final, you cannot change the value of final variable(It will be constant). There is a final variable speedlimit, we are Read More →

Convert sorted array to balanced binary search tree

Problem : Given a sorted array . Write a program to create balanced BST from the sorted array. We know that the in-order traversal of binary search tree gives the elements in sorted order. This tells us that the middle element of array will be the root. We can create left and right subtree by Read More →

Merge a linked list into another linked list at alternate positions

Given two linked lists, insert nodes of second list into first list at alternate positions of first list. eg. 1->5->7->3->9 6->10->2->4, the first list should become 1->6->5->10->7->2->3->4->9 and second list should become empty. The nodes of second list should only be inserted when there are positions available. If the first list is 1->2->3 and second Read More →

Nextag (Wize Commerce) Interview Questions

I apperaed for Nextag(wize Commerce) interview SSE profile recently.I would like to share my interview experience here. Round 1 Q1. Split the array into 2 arrays such that difference between sum is minimum? Q2. A long number ie 123956778 is given. Get the digit from position given as input? ie. 4th digit is 9. Q3. Read More →

Why doesn’t the Java language support multiple inheritance?

There are 2 reasons mentioned that will give you a idea why we don’t have multiple inheritance in java. 1st is ambiguity around Diamond problem, consider a class A has foo() method and then B and C derived from A and has there own foo() implementation and now class D derive from B and C Read More →

Probability of getting one rupee coin from bag

Problem: A bag contains (x) one rupee coins and (y) 50 paise coins. One coin is taken from the bag and put away. If a coin is now taken at random from the bag, what is the probability that it is a one rupee coin? Answers: Case I: Let the first coin removed be one Read More →

Netapp interview – Set 2

I appeared in Netapp interview recently and I would like to contibute to crazyforcode.com. This website is very helpful for interview preparation. First a written round was conducted. Written was based on Programming, Data structure, OS and Aptitude. There were 4 sections with a total of 50 questions to be done in 1 hour, with Read More →

Probability of finding a job

Problem: A candidate is selected for interview for 3 posts.The number of candidates for the first, second and third posts are 3,4 and 2 respectively. What is the probability of getting at least one post? Solution: The probability the candidate does not get an offer from the first interview is 2/3. The probability she doesn’t Read More →

Difference between static and final method in java

Static methods can be overriden, but they cannot be overriden to be non-static,Whereas final methods cannot be overridden. A static method is a method that’s invoked through a class, rather than a specific object of that class. Static methods can only access static variables – they can’t use anything that’s specific to a particular object. Read More →

Kth largest or smallest element in an array

Write an C program to find kth largest element in an array. Elements in array are not sorted. example, if given array is [1, 3, 12, 19, 13, 2, 15] and you are asked for the 3rd largest element i.e., k = 3 then your program should print 13. Method 1 Use sorting. Return first Read More →

Ebay interview – Set 1

Written Round:There were 30 questions out of which 50% was based on java and c++, the rest from verbal and quantitative stuff.The key areas to focus on are: · OOPS-all concepts, contructors etc · Database-sql queries and normal basics stuff about schemas etc · Networks- subnetting, various routing protocols, about mac address · Probability ans Read More →