SlideShare a Scribd company logo
1 of 3
Download to read offline
In Java write a menu driven program that implements the following linked list operations :
INSERT (at the beginning)
INSERT_ALPHA (in alphabetical order)
DELETE (Identify by contents, i.e. "John", not #3)
COUNT
CLEAR
Solution
sorting........................................
class LinkedList
{
Node head;
// link list
class Node
{
int data;
Node next;
Node(int d) {data = d; next = null; }
}
//function for sorted list
void sortedIns(Node new_node)
{
Node current;
if (head == null || head.data >= new_node.data)
{
new_node.next = head;
head = new_node;
}
else {
current = head;
while (current.next != null &&
current.next.data < new_node.data)
current = current.next;
new_node.next = current.next;
current.next = new_node;
}
}
// function for the creation of node
Node newNode(int data)
{
Node x = new Node(data);
return x;
}
public static void main(String args[])
{
LinkedList llist = new LinkedList();
Node new_node;
new_node = llist.newNode(5);
llist.sortedIns(new_node);
new_node = llist.newNode(10);
llist.sortedIns(new_node);
new_node = llist.newNode(7);
llist.sortedIns(new_node);
new_node = llist.newNode(3);
llist.sortedIns(new_node);
new_node = llist.newNode(1);
llist.sortedIns(new_node);
new_node = llist.newNode(9);
llist.sortedIns(new_node);
System.out.println("Created Linked List");
llist.printList();
}
}
if u have to delete an item
temp=head;
arr=head;
for(i=1;i<=link_list_len;i++)
{
arr++;
while(node->data==data1)
{
x=node;
arr=node->nxt;
}
}

More Related Content

Similar to In Java write a menu driven program that implements the following li.pdf

coding in C- Create a function called reverseList that takes the head.docx
coding in C- Create a function called reverseList that takes the head.docxcoding in C- Create a function called reverseList that takes the head.docx
coding in C- Create a function called reverseList that takes the head.docx
tienlivick
 
could you implement this function please, im having issues with it..pdf
could you implement this function please, im having issues with it..pdfcould you implement this function please, im having issues with it..pdf
could you implement this function please, im having issues with it..pdf
feroz544
 
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
 
How to do insertion sort on a singly linked list with no header usin.pdf
How to do insertion sort on a singly linked list with no header usin.pdfHow to do insertion sort on a singly linked list with no header usin.pdf
How to do insertion sort on a singly linked list with no header usin.pdf
arihantelehyb
 
PROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdf
PROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdfPROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdf
PROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdf
climatecontrolsv
 
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdfTHE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
fathimahardwareelect
 
Most Important C language program
Most Important C language programMost Important C language program
Most Important C language program
TEJVEER SINGH
 
in C++ , Design a linked list class named IntegerList to hold a seri.pdf
in C++ , Design a linked list class named IntegerList to hold a seri.pdfin C++ , Design a linked list class named IntegerList to hold a seri.pdf
in C++ , Design a linked list class named IntegerList to hold a seri.pdf
eyewaregallery
 
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdfInspect the class declaration for a doubly-linked list node in Node-h-.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
vishalateen
 
In C++Write a recursive function to determine whether or not a Lin.pdf
In C++Write a recursive function to determine whether or not a Lin.pdfIn C++Write a recursive function to determine whether or not a Lin.pdf
In C++Write a recursive function to determine whether or not a Lin.pdf
flashfashioncasualwe
 
Write a Java Class to Implement a Generic Linked ListYour list mus.pdf
Write a Java Class to Implement a Generic Linked ListYour list mus.pdfWrite a Java Class to Implement a Generic Linked ListYour list mus.pdf
Write a Java Class to Implement a Generic Linked ListYour list mus.pdf
rozakashif85
 
JAVA A double-ended queue is a list that allows the addition and.pdf
JAVA A double-ended queue is a list that allows the addition and.pdfJAVA A double-ended queue is a list that allows the addition and.pdf
JAVA A double-ended queue is a list that allows the addition and.pdf
amrishinda
 
Using the provided table interface table.h and the sample linked lis.pdf
Using the provided table interface table.h and the sample linked lis.pdfUsing the provided table interface table.h and the sample linked lis.pdf
Using the provided table interface table.h and the sample linked lis.pdf
connellalykshamesb60
 
C# code pleaseWrite a program that creates a link list object of 1.pdf
C# code pleaseWrite a program that creates a link list object of 1.pdfC# code pleaseWrite a program that creates a link list object of 1.pdf
C# code pleaseWrite a program that creates a link list object of 1.pdf
duttakajal70
 
Write the Java source code necessary to build a solution for the pro.pdf
Write the Java source code necessary to build a solution for the pro.pdfWrite the Java source code necessary to build a solution for the pro.pdf
Write the Java source code necessary to build a solution for the pro.pdf
fckindswear
 

Similar to In Java write a menu driven program that implements the following li.pdf (20)

coding in C- Create a function called reverseList that takes the head.docx
coding in C- Create a function called reverseList that takes the head.docxcoding in C- Create a function called reverseList that takes the head.docx
coding in C- Create a function called reverseList that takes the head.docx
 
could you implement this function please, im having issues with it..pdf
could you implement this function please, im having issues with it..pdfcould you implement this function please, im having issues with it..pdf
could you implement this function please, im having issues with it..pdf
 
Unit - 2.pdf
Unit - 2.pdfUnit - 2.pdf
Unit - 2.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
 
How to do insertion sort on a singly linked list with no header usin.pdf
How to do insertion sort on a singly linked list with no header usin.pdfHow to do insertion sort on a singly linked list with no header usin.pdf
How to do insertion sort on a singly linked list with no header usin.pdf
 
PROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdf
PROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdfPROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdf
PROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdf
 
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdfTHE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
 
Most Important C language program
Most Important C language programMost Important C language program
Most Important C language program
 
in C++ , Design a linked list class named IntegerList to hold a seri.pdf
in C++ , Design a linked list class named IntegerList to hold a seri.pdfin C++ , Design a linked list class named IntegerList to hold a seri.pdf
in C++ , Design a linked list class named IntegerList to hold a seri.pdf
 
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdfInspect the class declaration for a doubly-linked list node in Node-h-.pdf
Inspect the class declaration for a doubly-linked list node in Node-h-.pdf
 
In C++Write a recursive function to determine whether or not a Lin.pdf
In C++Write a recursive function to determine whether or not a Lin.pdfIn C++Write a recursive function to determine whether or not a Lin.pdf
In C++Write a recursive function to determine whether or not a Lin.pdf
 
Write a Java Class to Implement a Generic Linked ListYour list mus.pdf
Write a Java Class to Implement a Generic Linked ListYour list mus.pdfWrite a Java Class to Implement a Generic Linked ListYour list mus.pdf
Write a Java Class to Implement a Generic Linked ListYour list mus.pdf
 
Linked list
Linked listLinked list
Linked list
 
JAVA A double-ended queue is a list that allows the addition and.pdf
JAVA A double-ended queue is a list that allows the addition and.pdfJAVA A double-ended queue is a list that allows the addition and.pdf
JAVA A double-ended queue is a list that allows the addition and.pdf
 
Using the provided table interface table.h and the sample linked lis.pdf
Using the provided table interface table.h and the sample linked lis.pdfUsing the provided table interface table.h and the sample linked lis.pdf
Using the provided table interface table.h and the sample linked lis.pdf
 
C program to insert a node in doubly linked list
C program to insert a node in doubly linked listC program to insert a node in doubly linked list
C program to insert a node in doubly linked list
 
C# code pleaseWrite a program that creates a link list object of 1.pdf
C# code pleaseWrite a program that creates a link list object of 1.pdfC# code pleaseWrite a program that creates a link list object of 1.pdf
C# code pleaseWrite a program that creates a link list object of 1.pdf
 
C Exam Help
C Exam Help C Exam Help
C Exam Help
 
Write the Java source code necessary to build a solution for the pro.pdf
Write the Java source code necessary to build a solution for the pro.pdfWrite the Java source code necessary to build a solution for the pro.pdf
Write the Java source code necessary to build a solution for the pro.pdf
 
#include iostream using namespace std; const int nil = 0; cl.docx
#include iostream using namespace std; const int nil = 0; cl.docx#include iostream using namespace std; const int nil = 0; cl.docx
#include iostream using namespace std; const int nil = 0; cl.docx
 

More from arihantelehyb

Energy doing work Fuel of the cell Working part of an enzyme (2 w.pdf
Energy doing work  Fuel of the cell  Working part of an enzyme (2 w.pdfEnergy doing work  Fuel of the cell  Working part of an enzyme (2 w.pdf
Energy doing work Fuel of the cell Working part of an enzyme (2 w.pdf
arihantelehyb
 
• Define transcription• Define translation• What are the 3 steps.pdf
• Define transcription• Define translation• What are the 3 steps.pdf• Define transcription• Define translation• What are the 3 steps.pdf
• Define transcription• Define translation• What are the 3 steps.pdf
arihantelehyb
 
what is the marketSolutionAccording to Britannica Market, a .pdf
what is the marketSolutionAccording to Britannica Market, a .pdfwhat is the marketSolutionAccording to Britannica Market, a .pdf
what is the marketSolutionAccording to Britannica Market, a .pdf
arihantelehyb
 
Description of programYou are to write a program name InfixToPost.pdf
Description of programYou are to write a program name InfixToPost.pdfDescription of programYou are to write a program name InfixToPost.pdf
Description of programYou are to write a program name InfixToPost.pdf
arihantelehyb
 
Consider this you have two cell lines, a macrophage cell line and a.pdf
Consider this you have two cell lines, a macrophage cell line and a.pdfConsider this you have two cell lines, a macrophage cell line and a.pdf
Consider this you have two cell lines, a macrophage cell line and a.pdf
arihantelehyb
 
Required Summarize why revenue is such a critical account in most c.pdf
Required Summarize why revenue is such a critical account in most c.pdfRequired Summarize why revenue is such a critical account in most c.pdf
Required Summarize why revenue is such a critical account in most c.pdf
arihantelehyb
 

More from arihantelehyb (20)

for the normal distrbution, the proportion in the tail beyond z= 1.5.pdf
for the normal distrbution, the proportion in the tail beyond z= 1.5.pdffor the normal distrbution, the proportion in the tail beyond z= 1.5.pdf
for the normal distrbution, the proportion in the tail beyond z= 1.5.pdf
 
For a square matrix A, which vectors are orthogonal to the vectors i.pdf
For a square matrix A, which vectors are orthogonal to the vectors i.pdfFor a square matrix A, which vectors are orthogonal to the vectors i.pdf
For a square matrix A, which vectors are orthogonal to the vectors i.pdf
 
Five individuals, including A and B, take seats around a circular ta.pdf
Five individuals, including A and B, take seats around a circular ta.pdfFive individuals, including A and B, take seats around a circular ta.pdf
Five individuals, including A and B, take seats around a circular ta.pdf
 
Explain the experiments of Griffiths (1928) and Hershey Chase (1952).pdf
Explain the experiments of Griffiths (1928) and Hershey Chase (1952).pdfExplain the experiments of Griffiths (1928) and Hershey Chase (1952).pdf
Explain the experiments of Griffiths (1928) and Hershey Chase (1952).pdf
 
Energy doing work Fuel of the cell Working part of an enzyme (2 w.pdf
Energy doing work  Fuel of the cell  Working part of an enzyme (2 w.pdfEnergy doing work  Fuel of the cell  Working part of an enzyme (2 w.pdf
Energy doing work Fuel of the cell Working part of an enzyme (2 w.pdf
 
• Define transcription• Define translation• What are the 3 steps.pdf
• Define transcription• Define translation• What are the 3 steps.pdf• Define transcription• Define translation• What are the 3 steps.pdf
• Define transcription• Define translation• What are the 3 steps.pdf
 
Which of the following represents the internal environment of the bod.pdf
Which of the following represents the internal environment of the bod.pdfWhich of the following represents the internal environment of the bod.pdf
Which of the following represents the internal environment of the bod.pdf
 
why does venus experience so little temperature changes compared to .pdf
why does venus experience so little temperature changes compared to .pdfwhy does venus experience so little temperature changes compared to .pdf
why does venus experience so little temperature changes compared to .pdf
 
Who is considered the author of The Way of Life, which is Daoisms .pdf
Who is considered the author of The Way of Life, which is Daoisms .pdfWho is considered the author of The Way of Life, which is Daoisms .pdf
Who is considered the author of The Way of Life, which is Daoisms .pdf
 
Which of the following is not a function of proteinsa.         .pdf
Which of the following is not a function of proteinsa.         .pdfWhich of the following is not a function of proteinsa.         .pdf
Which of the following is not a function of proteinsa.         .pdf
 
what is the marketSolutionAccording to Britannica Market, a .pdf
what is the marketSolutionAccording to Britannica Market, a .pdfwhat is the marketSolutionAccording to Britannica Market, a .pdf
what is the marketSolutionAccording to Britannica Market, a .pdf
 
What happens when two shock waves collide What happens specifically.pdf
What happens when two shock waves collide What happens specifically.pdfWhat happens when two shock waves collide What happens specifically.pdf
What happens when two shock waves collide What happens specifically.pdf
 
What is input A. Any data or information that is processed and pres.pdf
What is input  A. Any data or information that is processed and pres.pdfWhat is input  A. Any data or information that is processed and pres.pdf
What is input A. Any data or information that is processed and pres.pdf
 
What are the main components of the chemiosmotic mechanism in mitoch.pdf
What are the main components of the chemiosmotic mechanism in mitoch.pdfWhat are the main components of the chemiosmotic mechanism in mitoch.pdf
What are the main components of the chemiosmotic mechanism in mitoch.pdf
 
Description of programYou are to write a program name InfixToPost.pdf
Description of programYou are to write a program name InfixToPost.pdfDescription of programYou are to write a program name InfixToPost.pdf
Description of programYou are to write a program name InfixToPost.pdf
 
Customers arrive at bakery at an average of 10 customers per hour. W.pdf
Customers arrive at bakery at an average of 10 customers per hour. W.pdfCustomers arrive at bakery at an average of 10 customers per hour. W.pdf
Customers arrive at bakery at an average of 10 customers per hour. W.pdf
 
Two different strains of a mutant phage infect a single bacterium. O.pdf
Two different strains of a mutant phage infect a single bacterium. O.pdfTwo different strains of a mutant phage infect a single bacterium. O.pdf
Two different strains of a mutant phage infect a single bacterium. O.pdf
 
Consider this you have two cell lines, a macrophage cell line and a.pdf
Consider this you have two cell lines, a macrophage cell line and a.pdfConsider this you have two cell lines, a macrophage cell line and a.pdf
Consider this you have two cell lines, a macrophage cell line and a.pdf
 
RNA splicing activities can be regulated in cells by various activat.pdf
RNA splicing activities can be regulated in cells by various activat.pdfRNA splicing activities can be regulated in cells by various activat.pdf
RNA splicing activities can be regulated in cells by various activat.pdf
 
Required Summarize why revenue is such a critical account in most c.pdf
Required Summarize why revenue is such a critical account in most c.pdfRequired Summarize why revenue is such a critical account in most c.pdf
Required Summarize why revenue is such a critical account in most c.pdf
 

Recently uploaded

會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
中 央社
 
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdf
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdfContoh Aksi Nyata Refleksi Diri ( NUR ).pdf
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdf
cupulin
 

Recently uploaded (20)

An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in Hinduism
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17
 
Supporting Newcomer Multilingual Learners
Supporting Newcomer  Multilingual LearnersSupporting Newcomer  Multilingual Learners
Supporting Newcomer Multilingual Learners
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
 
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdf
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdfContoh Aksi Nyata Refleksi Diri ( NUR ).pdf
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdf
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 

In Java write a menu driven program that implements the following li.pdf

  • 1. In Java write a menu driven program that implements the following linked list operations : INSERT (at the beginning) INSERT_ALPHA (in alphabetical order) DELETE (Identify by contents, i.e. "John", not #3) COUNT CLEAR Solution sorting........................................ class LinkedList { Node head; // link list class Node { int data; Node next; Node(int d) {data = d; next = null; } } //function for sorted list void sortedIns(Node new_node) { Node current; if (head == null || head.data >= new_node.data) { new_node.next = head; head = new_node; } else {
  • 2. current = head; while (current.next != null && current.next.data < new_node.data) current = current.next; new_node.next = current.next; current.next = new_node; } } // function for the creation of node Node newNode(int data) { Node x = new Node(data); return x; } public static void main(String args[]) { LinkedList llist = new LinkedList(); Node new_node; new_node = llist.newNode(5); llist.sortedIns(new_node); new_node = llist.newNode(10); llist.sortedIns(new_node); new_node = llist.newNode(7); llist.sortedIns(new_node); new_node = llist.newNode(3); llist.sortedIns(new_node); new_node = llist.newNode(1); llist.sortedIns(new_node);
  • 3. new_node = llist.newNode(9); llist.sortedIns(new_node); System.out.println("Created Linked List"); llist.printList(); } } if u have to delete an item temp=head; arr=head; for(i=1;i<=link_list_len;i++) { arr++; while(node->data==data1) { x=node; arr=node->nxt; } }