Difference between SOAP and REST Web Service.

Difference between SOAP and REST Web Service. OR
SOAP Vs REST Web Service.


SOAP Vs REST Web Service, when to use SOAP, When to use REST, Which to choose, What are the benefits. 
when to use soap and when to use rest web services
When to use soap and when to use rest web services

SOAP stands for Simple Object Access Protocol, whereas REST stands for REpresentational State Transfer.

lets see what exactly is the need of SOAP and REST and then we will see the difference between them.

For communication between language and platform independent applications over internet, we need some standard protocol for exchanging information, SOAP and REST protocol mainly defines a way though which messages should be exchanged.

Let's see important difference between SOAP and REST Service which will help you decide which to choose among both.

Verify Preorder Sequence Of Binary Search Tree(BST)

Check if a given array can represent Preorder Traversal of Binary Search Tree. OR
Check if given Preorder traversal is valid BST (Binary Search Tree). OR
Given an array of numbers, verify whether it is the correct Preorder traversal sequence of a binary search tree.


You are given an array of numbers which represents Preorder traversal of Binary Search Tree.
Verify whether it is a correct Preorder sequence or not.


Lets understand what is the input and the expected output.

Input: [40, 30, 35, 20, 80, 100] Output: Invalid Preorder traversal
 

Input: [45, 25, 15, 35, 75]
Output: Valid Preorder traversal

Input: [50, 39, 44, 28, 85]
Output: Invalid Preorder traversal
 

Input: [10, 25, 5]
Output: Invalid Preorder traversal
 


Input: [30, 20, 10, 40, 50]
Output: Valid Preorder traversal

Bubble Sort

Bubble Sort (Sinking sort)


Given a array of integers, Sort it.
Lets understand what is the input and the expected output.


Insertion Sort

Insertion Sort


Given a array of integers, Sort it using Insertion sort. Lets understand what is the input and the expected output.

Selection Sort

Selection Sort


Given a array of integers, Sort it.
Lets understand what is the input and the expected output.

Infinite loop in HashMap

Why HashMap should not be used in multi threaded environment?
Can it cause infinite loop as well?
When get method go to infinite loop in HashMap?


If HashMap is used in Multi threading environment, there are chances that Get and Put operation can lead you to Infinite loop.
 

Sort Linked list using Merge sort.

Sort Linked List using Merge Sort.


Given a Linked list, Sort it using Merge Sort Algorithm.

Merge sort is preferred algorithm for sorting a linked list, lets see why,
The way linked list is structured which doesn't allow random access makes some other algorithms like Quicksort perform poorly, So Merge sort is often preferred algorithm for sorting linked list.
 
Lets understand what is the input and the expected output.


Tower Of Hanoi

Tower Of Hanoi


Lets understand what is the input and the expected output.

So the question is, You have given a 3 Peg (Start peg, Auxiliary/helper peg and End Peg)
Start peg contains 3 disks of different sizes as shown. You have to move all the disk from Start peg to End peg using Auxiliary peg.


There are few rules that need to keep in mind,

1. Only one disk can be moved at a time.
2. Large size disk can't be placed on top of small sized disk.

Find Nth node from last in a linked list


Find Nth node from last in a linked list


Lets understand what is the input and the expected output.


Find middle element of the Linked list

Reverse a Linked list

Reverse a Linked list


Lets understand what is the input and the expected output.