Display Forward And Backward In Doubly Linkedlist
1. You are given a partially written DoublyLinkedList class.Input Format
2. You are required to complete the body of displayForw and displayBack function. This function is supposed to print linkedlist in forward and backward manner respectively.
3. If size of list is zero then return "ListIsEmpty: -1".
4. If Index is Invalid then return "IndexIsInValid: -1".
5. If Location which we want to remove is null then return "LocationIsInvalid: -1".
6. You are required to update head, tail and size as required.
7. Input and Output is managed for you. Just update the code in incomplete function.
Note -> Use the code snippet and follow the algorithm discussed in question video. The judge can't
force you but the intention is to teach a concept. Play in spirit of the question.
input in managed for you.Output Format
output in managed for you.Question Video
0 <= N <= 10^6Sample Input
addFirst 4Sample Output
addFirst 4
addLast 5
addFirst 7
getAt 4 3
addAt 4 34
addAt 0 43
removeAt 4
addAfter 2 33
addAfter 0 33
addAfter 4 33
removeNode 0
removeAt 0
removeAfter 3
removeBefore 3
addAt 8 545
addLast 1
removeFirst
removeFirst
displayForw
displayBack
size
isEmpty
getFirst
removeFirst
removeLast
getLast
removeFirst
removeFirst
addAt 0 345
stop
IndexIsInValid: -1
LocationIsInvalid:
-1
33
4
IndexIsInValid: -1
33
7
[33, 4, 34, 1]
[1, 34, 4, 33]
4
false
33
33
1
34
4
34
[345]
-
Asked in Companies
-
Related Topics
Video Solution
Code Solution
{ }
{ }
Run