Java program to create a singly linked list of n nodes and display it in reverse order17 Mar 2025 | 3 min read In this program, we need to create a singly linked list and display the list in reverse order. Original List ![]() Reversed List ![]() One of the approaches to solving this problem is to reach the end the of the list and display the nodes from tail to head recursively. Algorithm
a. reverse() will reverse the order of the nodes present in the list.
a. display() will display the nodes present in the list:
Program:Output: Original List: 1 2 3 4 Reversed List: 4 3 2 1 Next TopicJava Programs |
In this program, we need to find out the minimum and maximum value node in the given singly linked list. We will maintain two variables min and max. Min will hold minimum value node, and max will hold maximum value node. In the above example, 1...
6 min read
In this program, we need to find out the duplicate words present in the string and display those words. Example: big black bug bit a big black dog on his big black nose To find the duplicate words from the string, we first split the string into...
3 min read
In this program, we need to separate each character from the string. CHARACTERS C H A R A C T E R S In computer science, collection of characters including spaces is called as string. To separate an individual character from the string, individual characters are accessed through...
1 min read
Multiplication of matrix is a core concept in programming. We can perform matrix multiplication in Java using a simple nested for loop approach to advance approach. The nested for loop approach has a time complexity of O(n3). The time complexity of matrix multiplication can be improved...
17 min read
In this program, we create a doubly linked list, and then reverse the list by reversing the direction of the list and print out the nodes. Traverse through the list by swapping the ious pointer with pointer of each node. Then, swap the position of...
6 min read
In this program, we will find out the largest node in the given binary tree. We first define variable max that will hold root's data. Then, we traverse through the left sub-tree to find the largest node. Compare it with max and store the maximum...
5 min read
In this program, we will create a circular linked list and delete a node from the end of the list. If the list is empty, it will display the message "List is empty". If the list is not empty, we will loop through the list...
6 min read
Java Convert long to int We can convert long to int in java using typecasting. To convert higher data type into lower, we need to perform typecasting. Typecasting in java is performed through typecast operator (datatype). Here, we are going to learn how to convert long primitive type into...
1 min read
We can capitalize each word of a string by the help of split() and substring() methods. By the help of split("\\s") method, we can get all words in an array. To get the first character, we can use substring() or charAt() method. Let's see the example...
1 min read
In this program, we need to find out the maximum height of the binary tree. The height of the binary tree can be defined as the number of nodes between root and a leaf. Maximum height will be the number of levels between root and...
4 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India