Friday, 25 September 2015

MAX HEAP IN JAVA




  • There are two types of heap and one of that is Max heap.
  • In Max heap, we have to add element such that parent has maximum value than it’s child value.
  • Here we represent Max heap as binary tree and we are going to implement it with static array in which zero index has no value. We add value in array starting from index one as show in figure.
  • Here we have same concept of queue that FIFO(first in – first out)
Functionality :-
  • Enqueue – Add element at last.
  • Dequeue – Delete from first position.
  • Peek – Display First Element 
Advantage of Max heap :- Sorting become more efficient.
Enqueue :-
  • Suppose if we want to add 25 in upper Max heap than we have to add 25 at index 11 (suppose index 11 is there.).But as we know Max heap means child has minimum value that it’s parent but here 7<25, which is not possible that we have to swap that two value for that what can do that Number[i/2]<->Number[i] means as we can here we have index 11 if take 11/2=5(in integer) than you can directly jump at it’s parent value and exchange that value.After exchanging that two value you will again find that 14<25 that again you can change that value with upper logic like this we have to move till we don’t find that Number[i/2]>Number[i].
Dequeue:-
  • As we know for for dequeue, we have remove element from root or from first position for that we have to move last element of array (here we have 1) at first position but still parent should have maximum value than child for that we have compare Number[i] with Number[2*i] and Number[2*i+1] because of you again go through upper image than you will that parent (Number[i]) has two child Number[2*i] and Number[2*i+1].So we have to compare that value and if you find and maximum value of child than parent that swap those two value.
Peek:-
  • In peek we have where first element of array or tree.
Algorithm Of Max heap

Download :- Max Heap

MIN HEAP USING JAVA


  • In Min heap, we have to add element such that parent has minimum value than it’s child value.
  • Here we represent Min heap as tree and we are going to implement it with static array in which zero index has no value. We add value in array starting from index one as show in figure.
  • Here we have same concept of queue that FIFO(first in – first out)
Functionality :-
  • Enqueue – Add element at last.
  • Dequeue – Delete from first position.
  • Peek – Display First Element 
Advantage of Min heap:- Sorting become more efficient.

Enqueue :-
  • Suppose if we want to add 1 in upper Min heap than we have to add 1 at index 11 (suppose index 11 is there.).But as we know Min heap means child has maximum value that it’s parent but here 1<3, which is not possible that we have to swap that two value. For that what can do that Number[i/2]<->Number[i], means as we can here we have index 11 if take 11/2=5(in integer) than you can directly jump at it’s parent value and exchange that value. After exchanging that two value you will again find that 1<2 that again you can change that value with upper logic like this we have to move untill we don’t find that Number[i/2]>Number[i].
Dequeue:-
  • As we know for dequeue, we have to remove element from root or from first position for that we have to move last element of array (here we have 1) at first position but still parent should have minimum value than child for that we have compare Number[i] with Number[2*i] and Number[2*i+1] because of you again go through upper image than you will that parent (Number[i]) has two child Number[2*i] and Number[2*i+1].So we have to compare that value and if you find and minimum value of child than parent that swap those two value.
Peek:-
  • In peek we have where first element of array or tree.
Algorithm Of Min heap



Download :- Min Heap

Sunday, 20 September 2015

Algorithm For Findind LU Factorization of Given Matrix in Java



Algorithm For Finding LU Factorization of Given Matrix in Java


  • Here given matrix can be decompose into two part L and U. 
  • Here I have Algorithm for solving LU Factorization for given matrix. 
  • You have to keep in mind that L part of given m * n matrix has dimension of m * m where as U part has dimension of m * n. 



    Main Class


Saturday, 8 August 2015

Algorithm For Solving Determinant Using Echelon Form







Algorithm Of solving Determinant using Echelon Form


  • As we there is general method available for solving determinant of given matrix but that is not efficient. But if we solve that through Echelon form method that it is quite easier to get determinant.
  • Because if your able to get Echelon form of given matrix that just multiply diagonal element of that echelon form matrix and that is answer of given matrix determinant.


  • As we can see in graph that if you take general algorithm for solving determinant than it take too much time for higher dimension matrix at that time it is efficient to use EF algorithm for solving determinant computerized.



Main Class


Algorithm Of Finding Inverse Of Matrix Using Row Reduced Echelon Method






Algorithm Of Finding Inverse Of Matrix Using Row Reduced Echelon Form Method

  • Here I have one nice algorithm for solving inverse of square matrix with help of echelon form algorithm which i have available on this blog which is quite efficient than any other method.  

Main Class

Doubly Link-List in Java






Doubly Link List

  • As we can see here two nodes are connected among themselves with two links between them. 
  • For first Node node0, next Node is node1 and node1 is connected with previous link between node0 and node1.
  • Here first node is head and the last Node is tail. Both have value null and we same logic which we have in singly link list.  

ArrayList in java






ArrayList


  • Here we are going to implement List program with help of ArrayList Algorithms
  • Main function should be Add_At_Position,Delete_From_Position,Display,GetSize,Sorting,etc.



Generic Class in Java






Generic Class

  • In this picture as we can see we have three different clots for driver, if you put slotted than you can fix that pin, if you put crossed on driver than you can fix that pin and so on.
  • Just like we have generic class which says that you build class one time and that class for all different object like String, Int, Float etc.
  • Suppose, we have one list program define for int object but now you are in need of same list for String Object or double Object than every time define same thing for different Object is difficult for us.So what we should do that create generic class.
  • Create generic class and use that for different datatypes or Object.How we can implement that is as below.

  • Generic class

    Main class

Link-List in Java








LinkedList


  • Graph Of linking between Nodes
  • Here we are going to implement List program with help of LinkedList Algorithms
  • Main function should be Add_At_Position,Delete_From_Position,Display,GetSize,Sorting,etc.
  • Main advantage of using link list is that it is dynamic.
  • Here first we are going to make Node with help of Node class



Algorithm Of Solving Echelon Form Of Matrix







Algorithm Of Solving Echelon Form Of Matrix

  • Here I have one nice algorithm for solving matrix Echelon form which is very helpful finding determinant of matrix, for RREF, for LU factorization etc.

  • Main Class


Algorithm Of Solving Row Reduced Echelon Form Of Matrix




Algorithm Of Solving Row Reduced Echelon Form Of Matrix

  • As this guy say, no one have time for solving Row Reduce Echelon Form for Matrix.
  • Here I have Algorithm for solving RREF for your Matrix


  • Main Class


Friday, 1 May 2015

VERILOG CODE FOR ALU




Here i put verilog code for ALU designing. Here I design ALU different part like Adder-subtractor block, Logic block, Shifter block and comparacter block with behavioural and stractural logic.

Here i provide one link from which you are able to download whole verilog code of ALU.

Download here

Open this file in your text editor and i also provide logic of block with commented part so you can understand.
If you find any query that please commented that I try to solve that.

Saturday, 28 March 2015

HOW TO CLEAN BOOTABLE USB



Open your command prompt and type code as under

1.    From Command prompt type ‘diskpart‘


If window ask for administrator permission than click on YES. 
2.    type list disk


3.    it should then look something like this:

               DISKPART> list disk
               Disk ### Status    Size          Free     Dyn     Gpt
               ——– ————- ——- ——- — —
               Disk 0     Online    465 GB    3072 KB
               Disk 1      Online    7728GB    0 B
           
4. Once we see which Disk is your USB drive, you will want to type ‘select disk‘  (change “disk 1″ to the number of your drive):

        5. DISKPART> select disk 1


               Disk 1 is now the selected disk.
           6. DISKPART> clean
                DiskPart succeeded in cleaning the disk.
        7. DISKPART> create partition primary
               DiskPart succeeded in creating the specified partition.
        8. DISKPART> select partition 1
               Partition 1 is now the selected partition.
        9. DISKPART> active
                DiskPart marked the current partition as active.
      10. DISKPART> format fs=ntfs quick
             100 percent completed
             DiskPart successfully formatted the volume.
      11. DISKPART> assign
             DiskPart successfully assigned the drive letter or mount point.
COMPLETE!