Posts

Showing posts from 2018

Array in JAVA

Image
Using Of Array in JAVA with Example Array is a container or a collection which has the similar kind of data types. Array is stored in contiguous memory.  In JAVA, arrays behave as an object. We can find the length and do other manipulations using the in-build functions. For using array in the JAVA program we have to declare an array using the int data type and not long or not short. Decleration of array can be done by,

Merge Sort

Image
Merge Sort in C In  computer science ,  merge sort  (also commonly spelled  mergesort ) is an efficient, general-purpose,  comparison-based   sorting algorithm . Most implementations produce a  stable sort , which means that the implementation preserves the input order of  equal  elements in the sorted output. Mergesort is a  divide and conquer algorithm  that was invented by  John von Neumann  in 1945. Algorithm Conceptually, a merge sort works as follows: Divide the unsorted list into  n  sublists, each containing 1 element (a list of 1 element is considered sorted). Repeatedly merge sublists to produce new sorted sublists until there is only 1 sublist remaining. This will be the sorted list.

DFS(Depth First Search) & BFS(Breath First Search) in C

Image
DFS v/s BFS Depth First Search Depth First Search for a graph is similar to  Depth First Traversal of a tree . The only catch here is, unlike trees, graphs may contain cycles, so we may come to the same node again. To avoid processing a node more than once, we use a boolean visited array. Pseudocode: Input : A graph  G  and a vertex  v  of G Output : All vertices reachable from  v  labeled as discovered A recursive implementation of DFS:

Heap Sort

Heap Sort in C Heap-sort can be thought of as an improved selection sort:  like that algorithm, it divides its input into a sorted and an unsorted region, and it iteratively shrinks the unsorted region by extracting the largest element and moving that to the sorted region. The improvement consists of the use of a  heap  data structure rather than a linear-time search to find the maximum. The heapsort algorithm can be divided into two parts. In the first step, a heap is built out of the data. The heap is often placed in an array with the layout of a complete  binary tree . The complete binary tree maps the binary tree structure into the array indices; each array index represents a node; the index of the node's parent, left child branch, or right child branch are simple expressions. For a zero-based array, the root node is stored at index 0; if  i  is the index of the current node, then 

Currency Conversion(Rupees to Dollar And Vice-Versa)

Currency Converter Hi guys, today I had shared a code to convert the currency from rupees to dollar and vice-versa. Lets, check out the code.

C program of Bubble Sort

Image
Bubble Sort Algorithm Bubble sort , sometimes referred to as  sinking sort , is a simple  sorting algorithm  that repeatedly steps through the list to be sorted, compares each pair of adjacent items and  swaps  them if they are in the wrong order. The pass through the list is repeated until no swaps are needed, which indicates that the list is sorted. The algorithm, which is a  comparison sort , is named for the way smaller or larger elements "bubble" to the top of the list.

C# Program to Convert Decimal Number To Octal

C# Program for Decimal To Octal Number Conversion This C# program perform the number conversion from the decimal number to the equivalent octal number.  In this program the user enters the decimal value which is stored in the deciNum variable. The value is copied to the variable quotient. Now while the value of quotient is not equals 0, store the modulo of it in the array octNum and divide the quotient by 8. Now for output display the values stored in the array octNum. Lets have a view on the code...

C# Program To Convert Decimal Number to Binary

Decimal Number To Binary Conversion This C# program performs the number conversion from decimal number to its equivalent binary number. This program will read a decimal number from the user and stores it modulo by 2 in an array a[] and divide the same number by 2 and stores in same variable 'n'. Now for the input retrieve the numbers from the array a[] and print or display it on the screen. Lets have a look on the code...

C# program to convert Decimal Number to Hexadecimal

Conversion of Decimal To Hexadecimal Number in C# This C# Program Performs decimal to Hexadecimal Conversion. This C# Program converts the given decimal number into hexadecimal.  Store the decimal value in other variable (quotients) and store its modulo in temporary variable. Now compare the value of temporary variable. If it is less than 10 add 48 to it or else add 55 to it. and at last print the result.  Here is source code of the C# Program to Perform Decimal to Hexadecimal Conversion. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.

C# program for Currency Conversion

C# Program to Convert the Rupees Amount To other Currency Amount Today, I have shared a C# program that converts the rupees amount into equivalent Dollar, Franc and Euro amount. The amount of Dollar, Franc & Euro are changed daily. So as per your requirement you can change the amount to get the accurate result. Note:   Here I had used a goto statement to make a program in repeated mode as the user doesn't input the value for exit i.e. 4 in my case. Lets review the code...

C# program to convert Binary Number to Decimal

Conversion of Binary To Decimal Number in C# This C# Program Performs Binary to Decimal Conversion. This C# Program converts the given binary number into decimal. The program reads the binary number, does a modulo operation to get the remainder, multiples the total by base 2 and adds the modulo and repeats the steps. Here is source code of the C# Program to Perform Binary to Decimal Conversion.The C# program is successfully compiled and executed with Microsoft Visual Studio.The program output is also shown below.

Socket Programming for sharing content of file

Server-Client Program To Transfer Content Of File from Server To Client As we know that as search on any site we are treated as a Client and the the one who reply to our request is treated as Server. When we send any request to the server, it compute some program and gives the desired reply to us. Here I had posted one Client-Server program in which the content of the file is transfer from the server side to the client side. Here for the successful execution of the program we have to make 4 file in one folder namely,  Client.java: For client side coding Server.java: For server side coding Client.txt: Where the content are received from the server Server.txt: Where the content are already stored for giving response for the client request. Let take a view on the coding.

Socket Programming for sorting array

Server-Client Socket Program For Sorting Elements In this post, I had shared a program related to the socket programming in which the sorting of the elements of array can be done. In this code there should be two file namely server.java and client.java. In client.java code is created to take the size of the array and elements of array and it send to the server. In server.java the value of the size of array and elements of array is used for sorting the elements and sends back to the client. Let review the code for the above aim.