Find/ search String object from arraylist collection of objects – stream lambda java 8 (example)
Given an arraylist collection of String objects, We would like to find object from arraylist. We will iterate through the list of […]
Given an arraylist collection of String objects, We would like to find object from arraylist. We will iterate through the list of […]
Multipart file upload client is capable of uploading different kind of files to RESTFul web service using Jersey framework. 1. What
Multipart file upload client: File upload client is capable of uploading different kind of files using apache httpclient. File upload
Given the code or functional block of program , we would like to find elapsed time, to execute the code
Given a the list of objects, we need to sort the objects by their multiple properties. We have used java 8 streams to sort the objects. In below example, we have take the Person object. We will sort the list of person objects by their firstName. Also we have shown the cascaded sorting wherein we have sorted the list on multiple fields.We have performed the following operations.
Given the strings of array containing nulls and empty string. We will be using Java 8 streams to filter out null and empty string in strings of array. Let us take a complete example to filter out null and empty string
Suppose we are given the List collection containing the String values, we will remove the null values from list collections using filter of Java 8. Let us take a look into the below example
Generally in our application we need to convert one object into another type. We can not directly transform one object to another. In traditional way we need to iterate source object and convert to destination object. We will be using Java 8 lamdas to translate one object into another.
Jersey framework REST Service to catch user defined exception using ExceptionMapper to catch application exceptions in java (example)
Given the sorted linked list, we need to remove duplicates from the linked list. There should not be any duplicate nodes in the linked linked list. Suppose we are given the linked list as shown in Fig 1, there are some duplicate elements in the sorted linked list.
Given the sorted linked list, we need to insert the element or node in the linked list such that linked list remains sorted. Suppose the sorted linked list as shown in Fig 1, We need to find the proper place before we need to insert the new element in the linked list, so that sorted order remains intact.
Given the two sorted linked lists, we need to merge these linked lists into single linked list. The resultant linked list should also in sorted one. Let us take a look into the examples to clear our problem statement.
Given a single linked list, we will delete all nodes of single linked list i.e. We want to delete the
Given a single linked list, count number of times given element exist in a single linked list. e.g. if we want
Given the linked list, we need to reverse a linked list in pairs. We need to reverse the nodes in pair. We need to swap the references of alternate nodes, as a result we will get reversed linked list in pairs.
Given the linked list, we need to find out whether the loop exist in the linked list. We need to find if there is any cycle in the linked list. Let us take an example to elaborate the problem statement. We have shown the linked list in Fig 1.
Given the two linked list, they are intersected at some node. We need to find out the intersection point of these two linked list. We have shown two linked list Linked list 1 and linked list 2, both linked lists are intersected at node 50. We need to find out the node 50 as per our problem statement.
Given the linked list, we need to find the nth node from the end of linked list. The n can be any arbitrary number within the range of number of nodes in linked list. Let us understand our problem statement. Let us take a look into the linked list as shown in Fig 1.
Given the linked list we need to find the centre or middle node. Let us take an example to understand our problem statement.
Given the lined list, we need to print the linked list in reverse order i.e. we need to start printing the linked list from last to first node. Let us take an example to understand the problem statement.
Given the linked list, we need to reverse the linked list. The linked list is shown in Fig 1, the head is location at node 1. Each node in a list have reference to next node in the list. The node 1 will have reference to node 2 and node 2 will have reference to node 3 and so on. The linked list is null terminated or marker for end of linked list.
In this post we are going to discuss about the exception mapper implementation using jersey framework. Exception handling is need for our applications. The jersey ExceptionMapper provide cross cutting concern, where in we can able to catch all application exception at one place. we do not need to handle the exceptions in each and every function. In this post, we will throw and catch following exceptions.
What is level in binary tree?
Level is distance or hops of node with respect to root node. The root node is considered to be at level 0, so children of root node will be at level 1 (level of root node + 1). So, we can calculate the level of all the nodes in binary tree.
As an example, consider the tree:
Given the binary search tree, we need to find the Ceil value of given input data.
What is Ceil value ? The smallest value just greater than or equal to given input data. We have already discussed about Floor of input data in BST. The logical flow of ceil value in BST is exactly same as that floor value. Let us find Ceil value for BST shown in Fig 1.
Given a binary search tree (BST), find out the floorl value of input data using recursive algorithm. Traverse the binary
Given a binary tree, we need to connect the nodes lying at same level. We have already discussed about the tree traversal using breadth first search algorithm, where we are printing the nodes level by level. By the end of this article we will achieve the same result using next sibling reference. In binary tree, we generally have following information.
Given a binary search tree (bst), we would like to find out K smallest element in BST. Traverse the binary
We are given two binary tree, we need to find out whether one binary tree is Quasi Isomorphic of other binary tree. Quasi Isomorphic tree? Trees are considered to Quasi isomorphic where we concerned about the structures. The structure of both tree either should be identical or obtained by swapping (or Mirror) its children.
We are given two binary tree, we need to find out whether one binary tree is Isomorphic of other binary tree. What is Isomorphic meaning? As per English dictionary meaning is “being of identical or similar form, shape, or structure”. By apply above definition to our problem statement, If given binary have identical or similar form or shape or structure to another binary tree, we can say that trees are isomorphic.
What is level in binary tree?
Level is distance or hops of node with respect to root node. The root node is considered to be at level 0, so children of root node will be at level 1 (level of root node + 1). So, we can calculate the level of all the nodes in binary tree.
As an example, consider the tree: