## Posts

Showing posts from January, 2020

### Converting Integers to Roman Numerals - Java

Roman Number are a system of numerical notations used by the Romans.

1= I5= V10= X50= L100= C500= D1000= M = I5000= V10,000= X50,000= L100,000= C = I500,000= D = V1,000,000= M = X5,000,000= V = L10,000,000= X = C50,000,000= L = D100,000,000 = C = M500,000,000 = D1,000,000,000= Mnn = 1000×nnnn = 100,000×nnnn = 1,000,000×nn

### Count the Occurrence of Character in the Linked List

~ Create an array. ~ One By One place the  character on array  on based on ASCII Value . ~ then, check the value of every index and find greater value/Occurence of Character. public class LinkedlistOperation { Node head; class Node{ int data; Node next; Node(int d){ data =d; next = null; } }
public void OccurrenceNumber(){ Node current= head; int arr[] = new int; while(current!=null){ (arr[current.data])++; current =current.next; } System.out.println("Occurrence of all character are :"); for(int i=0;i<256;i++){ if(arr[i]>0){ System.out.println(i+":" +arr[i]+" "); } } }
public static void main(String ...args){ LinkedlistOperation list = new LinkedlistOperation(); list.push(1); list.push(1); list.push(3); list.push(4); list.push(2); list.push(2); list.push(15); list.push(20); list.pu…

### Insertion Node in the Linkelist.

In this post, methods to insert a new node in linked list are discussed. A node can be added in three ways
1) At the front of the linked list
2) After a given node.
3) At the end of the linked list
public class Linkedlist { Node head; class Node{ int data; Node next; Node(int d){ data =d; next=null; } } // INSERT THE NODE AT THE BEGIN OF LINKEDLIST. public void insertAtfront(int new_data){ // Node temp = head; Node new_node = new Node(new_data); new_node.next = head; head = new_node; }  // INSERT THE NODE AT THE GIVEN POSITION IN LINKEDLIST.
public void insertAtGiven(Node prev_node,int new_data) { if(prev_node == null){ System.out.print("previous node can't be null"); return; } Node new_node = new Node(new_data); new_node.next = prev_node.next; prev_node.next = new_node; } // INSERT THE NODE  AT THE END OF THE LINKEDLIST.   public void insertAtEnd(int new_data){ Node new_node = new Node(new_data); new_node.nex…