SlideShare a Scribd company logo
Program 1 :
public class QueueUsingArray {
private static final int queueCapacity = 20;
int arr[] = new int[queueCapacity];
int size = 0;
int top = -1;
int rear = 0;
public void pushinQueue(int pushedElement) {
if (top < queueCapacity - 1) {
top++;
arr[top] = pushedElement;
System.out.println("Element " + pushedElement
+ " is pushed to Queue !");
display();
} else {
System.out.println("Overflow !");
}
}
public void pop() {
if (top >= rear) {
rear++;
System.out.println("Pop operation done !");
display();
} else {
System.out.println("Underflow !");
}
}
public void display() {
if (top >= rear) {
System.out.println("Elements in Queue : ");
for (int i = rear; i <= top; i++) {
System.out.println(arr[i]);
}
}
}
public static void main(String[] args) {
QueueUsingArray obj = new QueueUsingArray();
obj.pop();
obj.pushinQueue(20);
obj.pushinQueue(18);
obj.pushinQueue(67);
obj.pushinQueue(343);
obj.pop();
obj.pushinQueue(203);
obj.pushinQueue(348);
obj.pushinQueue(637);
obj.pushinQueue(343);
obj.pop();
obj.pop();
obj.pop();
}
}
Result 1 :
348
Element 637 is pushed to Queue !
Elements in Queue :
18
67
343
203
348
637
Element 343 is pushed to Queue !
Elements in Queue :
18
67
343
203
348
637
343
Pop operation done !
Elements in Queue :
67
343
203
348
637
343
Pop operation done !
Elements in Queue :
343
203
348
637
343
Pop operation done !
Elements in Queue :
203
348
637
343
Program 2:
import java.util.Random;
public class InsertionSort {
public static void main(String str[]){
Random rand = new Random();
int arr[] = new int[20];
for(int i=0;i<20;i++){
arr[i]=rand.nextInt(100);
System.out.print(arr[i]+" ");
}
System.out.println("");
insertionSOrt(arr);
for(int i=0;i<20;i++){
System.out.println("arr["+i+"] : "+arr[i]);
}
}
public static void insertionSOrt(int arr[]){
for(int i=1;i=0 && temp
Solution
Program 1 :
public class QueueUsingArray {
private static final int queueCapacity = 20;
int arr[] = new int[queueCapacity];
int size = 0;
int top = -1;
int rear = 0;
public void pushinQueue(int pushedElement) {
if (top < queueCapacity - 1) {
top++;
arr[top] = pushedElement;
System.out.println("Element " + pushedElement
+ " is pushed to Queue !");
display();
} else {
System.out.println("Overflow !");
}
}
public void pop() {
if (top >= rear) {
rear++;
System.out.println("Pop operation done !");
display();
} else {
System.out.println("Underflow !");
}
}
public void display() {
if (top >= rear) {
System.out.println("Elements in Queue : ");
for (int i = rear; i <= top; i++) {
System.out.println(arr[i]);
}
}
}
public static void main(String[] args) {
QueueUsingArray obj = new QueueUsingArray();
obj.pop();
obj.pushinQueue(20);
obj.pushinQueue(18);
obj.pushinQueue(67);
obj.pushinQueue(343);
obj.pop();
obj.pushinQueue(203);
obj.pushinQueue(348);
obj.pushinQueue(637);
obj.pushinQueue(343);
obj.pop();
obj.pop();
obj.pop();
}
}
Result 1 :
348
Element 637 is pushed to Queue !
Elements in Queue :
18
67
343
203
348
637
Element 343 is pushed to Queue !
Elements in Queue :
18
67
343
203
348
637
343
Pop operation done !
Elements in Queue :
67
343
203
348
637
343
Pop operation done !
Elements in Queue :
343
203
348
637
343
Pop operation done !
Elements in Queue :
203
348
637
343
Program 2:
import java.util.Random;
public class InsertionSort {
public static void main(String str[]){
Random rand = new Random();
int arr[] = new int[20];
for(int i=0;i<20;i++){
arr[i]=rand.nextInt(100);
System.out.print(arr[i]+" ");
}
System.out.println("");
insertionSOrt(arr);
for(int i=0;i<20;i++){
System.out.println("arr["+i+"] : "+arr[i]);
}
}
public static void insertionSOrt(int arr[]){
for(int i=1;i=0 && temp

More Related Content

Similar to Program 1 public class QueueUsingArray { private static final i.pdf

Im having an issue with the simulateOPT() methodthis is the p.pdf
Im having an issue with the simulateOPT() methodthis is the p.pdfIm having an issue with the simulateOPT() methodthis is the p.pdf
Im having an issue with the simulateOPT() methodthis is the p.pdf
stopgolook
 
import java.util.Scanner;public class Main {private static i.pdf
import java.util.Scanner;public class Main {private static i.pdfimport java.util.Scanner;public class Main {private static i.pdf
import java.util.Scanner;public class Main {private static i.pdf
stopgolook
 
Write the program in MIPS that declares an array of positive integer.pdf
Write the program in MIPS that declares an array of positive integer.pdfWrite the program in MIPS that declares an array of positive integer.pdf
Write the program in MIPS that declares an array of positive integer.pdf
arihanthtoysandgifts
 
ArrayTest.java import java.util.Arrays; import java.util.Scann.pdf
ArrayTest.java import java.util.Arrays; import java.util.Scann.pdfArrayTest.java import java.util.Arrays; import java.util.Scann.pdf
ArrayTest.java import java.util.Arrays; import java.util.Scann.pdf
deepua8
 

Similar to Program 1 public class QueueUsingArray { private static final i.pdf (20)

Stack array
Stack arrayStack array
Stack array
 
Stack and Queue.pptx university exam preparation
Stack and Queue.pptx university exam preparationStack and Queue.pptx university exam preparation
Stack and Queue.pptx university exam preparation
 
stack and queue array implementation in java.
stack and queue array implementation in java.stack and queue array implementation in java.
stack and queue array implementation in java.
 
stack and queue array implementation, java.
stack and queue array implementation, java.stack and queue array implementation, java.
stack and queue array implementation, java.
 
java assignment
java assignmentjava assignment
java assignment
 
Im having an issue with the simulateOPT() methodthis is the p.pdf
Im having an issue with the simulateOPT() methodthis is the p.pdfIm having an issue with the simulateOPT() methodthis is the p.pdf
Im having an issue with the simulateOPT() methodthis is the p.pdf
 
import java.util.Scanner;public class Main {private static i.pdf
import java.util.Scanner;public class Main {private static i.pdfimport java.util.Scanner;public class Main {private static i.pdf
import java.util.Scanner;public class Main {private static i.pdf
 
ISCP internal.pdf
ISCP internal.pdfISCP internal.pdf
ISCP internal.pdf
 
Write the program in MIPS that declares an array of positive integer.pdf
Write the program in MIPS that declares an array of positive integer.pdfWrite the program in MIPS that declares an array of positive integer.pdf
Write the program in MIPS that declares an array of positive integer.pdf
 
14 thread
14 thread14 thread
14 thread
 
ArrayTest.java import java.util.Arrays; import java.util.Scann.pdf
ArrayTest.java import java.util.Arrays; import java.util.Scann.pdfArrayTest.java import java.util.Arrays; import java.util.Scann.pdf
ArrayTest.java import java.util.Arrays; import java.util.Scann.pdf
 
Stack
StackStack
Stack
 
CODE Data Structures
CODE Data StructuresCODE Data Structures
CODE Data Structures
 
What is Stack, Its Operations, Queue, Circular Queue, Priority Queue
What is Stack, Its Operations, Queue, Circular Queue, Priority QueueWhat is Stack, Its Operations, Queue, Circular Queue, Priority Queue
What is Stack, Its Operations, Queue, Circular Queue, Priority Queue
 
#includeiostream#includecctypeusing namespace std;cl.docx
#includeiostream#includecctypeusing namespace std;cl.docx#includeiostream#includecctypeusing namespace std;cl.docx
#includeiostream#includecctypeusing namespace std;cl.docx
 
Sam wd programs
Sam wd programsSam wd programs
Sam wd programs
 
Stack.pptx
Stack.pptxStack.pptx
Stack.pptx
 
CS8391-Data Structures Unit 2
CS8391-Data Structures Unit 2CS8391-Data Structures Unit 2
CS8391-Data Structures Unit 2
 
DS- Stack ADT
DS- Stack ADTDS- Stack ADT
DS- Stack ADT
 
VTU Data Structures Lab Manual
VTU Data Structures Lab ManualVTU Data Structures Lab Manual
VTU Data Structures Lab Manual
 

More from Ankitchhabra28

ublic class Elevator { private static final String DOWN = down.pdf
  ublic class Elevator {     private static final String DOWN = down.pdf  ublic class Elevator {     private static final String DOWN = down.pdf
ublic class Elevator { private static final String DOWN = down.pdf
Ankitchhabra28
 
What are the financial markets and what purposes do they serveA f.pdf
What are the financial markets and what purposes do they serveA f.pdfWhat are the financial markets and what purposes do they serveA f.pdf
What are the financial markets and what purposes do they serveA f.pdf
Ankitchhabra28
 
VI) Instruction set Architecture-      Instruction set is a colle.pdf
VI) Instruction set Architecture-      Instruction set is a colle.pdfVI) Instruction set Architecture-      Instruction set is a colle.pdf
VI) Instruction set Architecture-      Instruction set is a colle.pdf
Ankitchhabra28
 
The evolution of one species is driven by the evolution of the other.pdf
The evolution of one species is driven by the evolution of the other.pdfThe evolution of one species is driven by the evolution of the other.pdf
The evolution of one species is driven by the evolution of the other.pdf
Ankitchhabra28
 
S(sulfur) atom Glucose molecule and compound Oxygen atom DN.pdf
S(sulfur) atom Glucose molecule and compound Oxygen atom DN.pdfS(sulfur) atom Glucose molecule and compound Oxygen atom DN.pdf
S(sulfur) atom Glucose molecule and compound Oxygen atom DN.pdf
Ankitchhabra28
 
Note             Given Code modified as required and required met.pdf
Note             Given Code modified as required and required met.pdfNote             Given Code modified as required and required met.pdf
Note             Given Code modified as required and required met.pdf
Ankitchhabra28
 
Listing.javaimport java.util.Scanner;public class Listing {   .pdf
Listing.javaimport java.util.Scanner;public class Listing {   .pdfListing.javaimport java.util.Scanner;public class Listing {   .pdf
Listing.javaimport java.util.Scanner;public class Listing {   .pdf
Ankitchhabra28
 

More from Ankitchhabra28 (20)

frequency tableSolution frequency table.pdf
 frequency tableSolution frequency table.pdf frequency tableSolution frequency table.pdf
frequency tableSolution frequency table.pdf
 
ublic class Elevator { private static final String DOWN = down.pdf
  ublic class Elevator {     private static final String DOWN = down.pdf  ublic class Elevator {     private static final String DOWN = down.pdf
ublic class Elevator { private static final String DOWN = down.pdf
 
[Al+] [OH-]^3 = Ksp0.2 [OH-]^3 = 210^-32[OH-] = 4.64210^-1.pdf
[Al+]  [OH-]^3 = Ksp0.2  [OH-]^3 = 210^-32[OH-] = 4.64210^-1.pdf[Al+]  [OH-]^3 = Ksp0.2  [OH-]^3 = 210^-32[OH-] = 4.64210^-1.pdf
[Al+] [OH-]^3 = Ksp0.2 [OH-]^3 = 210^-32[OH-] = 4.64210^-1.pdf
 
As a CFO environment of internal control needs to put in place t.pdf
    As a CFO environment of internal control needs to put in   place t.pdf    As a CFO environment of internal control needs to put in   place t.pdf
As a CFO environment of internal control needs to put in place t.pdf
 
What are the financial markets and what purposes do they serveA f.pdf
What are the financial markets and what purposes do they serveA f.pdfWhat are the financial markets and what purposes do they serveA f.pdf
What are the financial markets and what purposes do they serveA f.pdf
 
VI) Instruction set Architecture-      Instruction set is a colle.pdf
VI) Instruction set Architecture-      Instruction set is a colle.pdfVI) Instruction set Architecture-      Instruction set is a colle.pdf
VI) Instruction set Architecture-      Instruction set is a colle.pdf
 
waitSolutionwait.pdf
waitSolutionwait.pdfwaitSolutionwait.pdf
waitSolutionwait.pdf
 
The OSI(Open System Interconnection) contains 7 layers.1.Physica.pdf
The OSI(Open System Interconnection) contains 7 layers.1.Physica.pdfThe OSI(Open System Interconnection) contains 7 layers.1.Physica.pdf
The OSI(Open System Interconnection) contains 7 layers.1.Physica.pdf
 
the following statements are true Ubiquinone is a small, hydrophob.pdf
the following statements are true Ubiquinone is a small, hydrophob.pdfthe following statements are true Ubiquinone is a small, hydrophob.pdf
the following statements are true Ubiquinone is a small, hydrophob.pdf
 
The evolution of one species is driven by the evolution of the other.pdf
The evolution of one species is driven by the evolution of the other.pdfThe evolution of one species is driven by the evolution of the other.pdf
The evolution of one species is driven by the evolution of the other.pdf
 
Student choosed wrong subject. Question was not showning.Solutio.pdf
Student choosed wrong subject. Question was not showning.Solutio.pdfStudent choosed wrong subject. Question was not showning.Solutio.pdf
Student choosed wrong subject. Question was not showning.Solutio.pdf
 
S(sulfur) atom Glucose molecule and compound Oxygen atom DN.pdf
S(sulfur) atom Glucose molecule and compound Oxygen atom DN.pdfS(sulfur) atom Glucose molecule and compound Oxygen atom DN.pdf
S(sulfur) atom Glucose molecule and compound Oxygen atom DN.pdf
 
Question not visible..please post the imageSolutionQuestion no.pdf
Question not visible..please post the imageSolutionQuestion no.pdfQuestion not visible..please post the imageSolutionQuestion no.pdf
Question not visible..please post the imageSolutionQuestion no.pdf
 
PrimeRange.java import java.util.Scanner;public class PrimeRan.pdf
PrimeRange.java import java.util.Scanner;public class PrimeRan.pdfPrimeRange.java import java.util.Scanner;public class PrimeRan.pdf
PrimeRange.java import java.util.Scanner;public class PrimeRan.pdf
 
opps no format is there...Solutionopps no format is there....pdf
opps no format is there...Solutionopps no format is there....pdfopps no format is there...Solutionopps no format is there....pdf
opps no format is there...Solutionopps no format is there....pdf
 
Note             Given Code modified as required and required met.pdf
Note             Given Code modified as required and required met.pdfNote             Given Code modified as required and required met.pdf
Note             Given Code modified as required and required met.pdf
 
No, weight is not the measure of quantity of matter.Quantity of ma.pdf
No, weight is not the measure of quantity of matter.Quantity of ma.pdfNo, weight is not the measure of quantity of matter.Quantity of ma.pdf
No, weight is not the measure of quantity of matter.Quantity of ma.pdf
 
Two. The pyruvate with carbons 4-6 will go throu.pdf
                     Two.  The pyruvate with carbons 4-6 will go throu.pdf                     Two.  The pyruvate with carbons 4-6 will go throu.pdf
Two. The pyruvate with carbons 4-6 will go throu.pdf
 
Listing.javaimport java.util.Scanner;public class Listing {   .pdf
Listing.javaimport java.util.Scanner;public class Listing {   .pdfListing.javaimport java.util.Scanner;public class Listing {   .pdf
Listing.javaimport java.util.Scanner;public class Listing {   .pdf
 
is rightSolutionis right.pdf
is rightSolutionis right.pdfis rightSolutionis right.pdf
is rightSolutionis right.pdf
 

Recently uploaded

Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Accounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdfAccounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdf
YibeltalNibretu
 
Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training Report
Avinash Rai
 

Recently uploaded (20)

Matatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxMatatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptxJose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
 
Accounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdfAccounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdf
 
Benefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational ResourcesBenefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational Resources
 
Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training Report
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
 
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptxSolid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
NLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptxNLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptx
 
Forest and Wildlife Resources Class 10 Free Study Material PDF
Forest and Wildlife Resources Class 10 Free Study Material PDFForest and Wildlife Resources Class 10 Free Study Material PDF
Forest and Wildlife Resources Class 10 Free Study Material PDF
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
Salient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxSalient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptx
 
Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"
Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"
Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"
 

Program 1 public class QueueUsingArray { private static final i.pdf

  • 1. Program 1 : public class QueueUsingArray { private static final int queueCapacity = 20; int arr[] = new int[queueCapacity]; int size = 0; int top = -1; int rear = 0; public void pushinQueue(int pushedElement) { if (top < queueCapacity - 1) { top++; arr[top] = pushedElement; System.out.println("Element " + pushedElement + " is pushed to Queue !"); display(); } else { System.out.println("Overflow !"); } } public void pop() { if (top >= rear) { rear++; System.out.println("Pop operation done !"); display(); } else { System.out.println("Underflow !"); } } public void display() { if (top >= rear) { System.out.println("Elements in Queue : "); for (int i = rear; i <= top; i++) { System.out.println(arr[i]); } } }
  • 2. public static void main(String[] args) { QueueUsingArray obj = new QueueUsingArray(); obj.pop(); obj.pushinQueue(20); obj.pushinQueue(18); obj.pushinQueue(67); obj.pushinQueue(343); obj.pop(); obj.pushinQueue(203); obj.pushinQueue(348); obj.pushinQueue(637); obj.pushinQueue(343); obj.pop(); obj.pop(); obj.pop(); } } Result 1 : 348 Element 637 is pushed to Queue ! Elements in Queue : 18 67 343 203 348 637 Element 343 is pushed to Queue ! Elements in Queue : 18 67 343 203 348 637 343
  • 3. Pop operation done ! Elements in Queue : 67 343 203 348 637 343 Pop operation done ! Elements in Queue : 343 203 348 637 343 Pop operation done ! Elements in Queue : 203 348 637 343 Program 2: import java.util.Random; public class InsertionSort { public static void main(String str[]){ Random rand = new Random(); int arr[] = new int[20]; for(int i=0;i<20;i++){ arr[i]=rand.nextInt(100); System.out.print(arr[i]+" "); } System.out.println(""); insertionSOrt(arr); for(int i=0;i<20;i++){ System.out.println("arr["+i+"] : "+arr[i]); }
  • 4. } public static void insertionSOrt(int arr[]){ for(int i=1;i=0 && temp Solution Program 1 : public class QueueUsingArray { private static final int queueCapacity = 20; int arr[] = new int[queueCapacity]; int size = 0; int top = -1; int rear = 0; public void pushinQueue(int pushedElement) { if (top < queueCapacity - 1) { top++; arr[top] = pushedElement; System.out.println("Element " + pushedElement + " is pushed to Queue !"); display(); } else { System.out.println("Overflow !"); } } public void pop() { if (top >= rear) { rear++; System.out.println("Pop operation done !"); display(); } else { System.out.println("Underflow !"); } } public void display() { if (top >= rear) { System.out.println("Elements in Queue : "); for (int i = rear; i <= top; i++) {
  • 5. System.out.println(arr[i]); } } } public static void main(String[] args) { QueueUsingArray obj = new QueueUsingArray(); obj.pop(); obj.pushinQueue(20); obj.pushinQueue(18); obj.pushinQueue(67); obj.pushinQueue(343); obj.pop(); obj.pushinQueue(203); obj.pushinQueue(348); obj.pushinQueue(637); obj.pushinQueue(343); obj.pop(); obj.pop(); obj.pop(); } } Result 1 : 348 Element 637 is pushed to Queue ! Elements in Queue : 18 67 343 203 348 637 Element 343 is pushed to Queue ! Elements in Queue : 18 67 343
  • 6. 203 348 637 343 Pop operation done ! Elements in Queue : 67 343 203 348 637 343 Pop operation done ! Elements in Queue : 343 203 348 637 343 Pop operation done ! Elements in Queue : 203 348 637 343 Program 2: import java.util.Random; public class InsertionSort { public static void main(String str[]){ Random rand = new Random(); int arr[] = new int[20]; for(int i=0;i<20;i++){ arr[i]=rand.nextInt(100); System.out.print(arr[i]+" "); } System.out.println("");
  • 7. insertionSOrt(arr); for(int i=0;i<20;i++){ System.out.println("arr["+i+"] : "+arr[i]); } } public static void insertionSOrt(int arr[]){ for(int i=1;i=0 && temp