How to traverse data in a linked list in forward and backward direction, write the algorithm?
Answer / Bhagat Singh
To traverse a LinkedList in forward direction:
1. Get the head of the list (first node).
2. Until the current node is not null, move to the next node by accessing its 'next' reference.
3. Print or perform an operation on each node as you visit it.
To traverse a LinkedList in backward direction:
1. Get the last node of the list (last node is the one with null 'next' reference).
2. Until the current node is not the head, move to the previous node by accessing its 'previous' reference (if available) or the current node's 'next' reference (if 'previous' is not available).
3. Print or perform an operation on each node as you visit it.
| Is This Answer Correct ? | 0 Yes | 0 No |
Write the syntax in c to create a node in the singly linked list.
What do you mean by sorting data?
Define a stack?
What is variable size arrays?and why we use it?
How do you declare A pointer to array of three chars
What is the difference between data types and data structures?
What is difference between arraylist and linkedlist?
Let the G be a graph with 100 vertices numbered 1 to 100 Two vertices i and j are adjecnt if | i-j| =8 or | i-j| =12. The Number of connected components in G is ?
Write the importance of hashing?
Give the example of validating the parenthesis of expression using stack.
What is bubble sort?
How do I sort a hashmap key?