Linked List
Work In Progress
Singly Linked List
Node: every node has 2 parts data and pointer to the next node
{data}{pointer to next node}
Last Node: {Data}{ None}- None To indicate last node
root node : pointer to the beginning of the list
size
Number of nodes in List
operations
find(data)
add(data): add a number to the start , put the root node as next node and make the new node as root node example : root-> [[3][4]][[4][5]][[5][.]] add 2 [[2][rootnode]]=root->[[2][3]][[3][4]][[4][5]][[5][.]]
remove(data): remove a node :first find a number than replace the pre node next node as the found node next node exampleroot->[[2][3]][[3][4]][[4][5]][[5][.]] remove [4]=>[[3][4/next node next node]][ *fyi- it wont dlete the node it will d=be dekted from linked list we wont have axis to it
print_list()
Print_list: Iterates the list and prints each node
Example question
where each node will have information suvh as walkable path/noth walkable path,signals,tyope-indoor/outdoor, n1-n2-n3-n4
Doubly Linked List
Example Question:
where each node will have information suvh as walkable path/noth walkable path,signals,tyope-indoor/outdoor, n1-n2-n3-n4
We solved the issue of accessing node but if there comes a scenario where we have to access the previous node. its difficult using previous method so we could use doubly linked list
advantages( over regular linked list)
can iterate the list in either directions
can delete a node without iterating through the list (if given a pointer)