Posts

Showing posts from April, 2021

Data Structures - Merge Sort

Image
  Merge sort Merge sort is the algorithm which follows divide and conquer approach. Consider an array A of n number of elements. The algorithm processes the elements in 3 steps. If A Contains 0 or 1 elements then it is already sorted, otherwise, Divide A into two sub-array of equal number of elements. Conquer means sort the two sub-arrays recursively using the merge sort. Combine the sub-arrays to form a single final sorted array maintaining the ordering of the array. The main idea behind merge sort is that, the short list takes less time to be sorted. Example : Consider the following array of 7 elements. Sort the array by using merge sort.  A = { 10 ,  5 ,  2 ,  23 ,  45 ,  21 ,  7 }   Algorithm Step 1 : [INITIALIZE] SET I = BEG, J = MID + 1, INDEX = 0 Step 2 : Repeat while (I <= MID) AND (J<=END) IF ARR[I] < ARR[J] SET TEMP[INDEX] = ARR[I] SET I = I + 1 ELSE SET TEMP[INDEX] = ARR[J] SET J = J + 1 [END OF IF] SET INDEX = INDEX + 1 [END OF LOOP] Step 3: [Copy the remaining ele

Classification by Backpropagation

Image
  “ What is backpropagation? “  Backpropagation is a neural network learning algorithm. The neural networks field was originally kindled by psychologists and neurobiologists who sought to develop and test computational analogs of neurons. Roughly speaking, a  neural network  is a set of connected input/output units in which each connection has a weight associated with it. During the learning phase, the network learns by adjusting the weights so as to be able to predict the correct class label of the input tuples. Neural network learning is also referred to as  connectionist learning  due to the connections between units. How does backpropagation work? Let us take a look at how backpropagation works. It has four layers: input layer, hidden layer, hidden layer II and final output layer. So, the main three layers are: Input layer Hidden layer Output layer Each layer has its own way of working and its own way to take action such that we are able to get the desired results and correlate the