JAVA CODE PLEASE 2. Linked List Quiz by CodeChum Admin Write a function printNodes that takes in the head of a linked list and prints all the values of that linked list using a while loop. Print the values separated by a [space]->[space] Create a program that accepts 10 integer inputs. Assign each input into a node and link them in ascending order then print the linked list. Create another two linked lists: One for nodes with even numbers and the other one for odd numbers. Print them respectively using the printNodes function. Input 1. One line containing an integer 2. One line containing an integer 3. One line containing an integer 4. One line containing an integer 5. One line containing an integer 6. One line containing an integer 7. One line containing an integer 8. One line containing an integer 9. One line containing an integer 10. One line containing an integer Output Enter·number·1:·1 Enter·number·2:·2 Enter·number·3:·3 Enter·number·4:·4 Enter·number·5:·5 Enter·number·6:·6 Enter·number·7:·7 Enter·number·8:·8 Enter·number·9:·9 Enter·number·10:·10 All·nodes: 1·->·2·->·3·->·4·->·5·->·6·->·7·->·8·->·9·->·10 All·even·nodes: 2·->·4·->·6·->·8·->·10 All·odd·nodes: 1·->·3·->·5·->·7·->·9
Types of Linked List
A sequence of data elements connected through links is called a linked list (LL). The elements of a linked list are nodes containing data and a reference to the next node in the list. In a linked list, the elements are stored in a non-contiguous manner and the linear order in maintained by means of a pointer associated with each node in the list which is used to point to the subsequent node in the list.
Linked List
When a set of items is organized sequentially, it is termed as list. Linked list is a list whose order is given by links from one item to the next. It contains a link to the structure containing the next item so we can say that it is a completely different way to represent a list. In linked list, each structure of the list is known as node and it consists of two fields (one for containing the item and other one is for containing the next item address).

Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images









