Posts

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...