
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 26504 Articles for Server Side Programming

484 Views
A doubly linked list node contains three items, where two items point to the next and previous nodes, and the third item contains the value of that node.ExampleApproachStep 1 − Define a method that accepts the head of a doubly linked list.Step 2 − Initialize temp:=head.Step 3 − Iterate temp until it becomes nil.Step 4 − Print temp.value.Example Live Demopackage main import "fmt" type Node struct { prev *Node value int next *Node } func CreateNewNode(value int) *Node{ var node Node node.next = nil node.value = value node.prev = nil return &node } ... Read More

167 Views
ExamplesExampleApproach to solve this problem Live Demopackage main import "fmt" type Node struct { value int next *Node } func NewNode(value int, next *Node) *Node{ var n Node n.value = value n.next = next return &n } func TraverseLinkedList(head *Node){ temp := head for temp != nil { fmt.Printf("%d ", temp.value) temp = temp.next } fmt.Println() } func InsertNodeAtIthIndex(head *Node, index, data int) *Node{ if head == nil{ head = NewNode(data, nil) return head } if ... Read More

368 Views
ExampleSuppose we have the following tree.Inorder Tree Traversal Output − 4 2 5 1 6 3 7Approach to solve this problemStep 1 − If the root node of the given tree is nil, then return; else, follow the steps given below.Step 2 − Traverse the Left sub-tree.Step 3 − Print the root node data.Step 4 − Traverse the Right sub-tree.Example Live Demopackage main import "fmt" type Node struct { data int left *Node right *Node } func (root *Node)InOrderTraversal(){ if root !=nil{ root.left.InOrderTraversal() fmt.Printf("%d ", root.data) root.right.InOrderTraversal() ... Read More

119 Views
ExamplesExample Live Demopackage main import "fmt" type Node struct { value int next *Node } func NewNode(value int, next *Node) *Node{ var n Node n.value = value n.next = next return &n } func TraverseLinkedList(head *Node){ temp := head for temp != nil { fmt.Printf("%d ", temp.value) temp = temp.next } fmt.Println() } func InsertNodeAtIthIndex(head *Node, index, data int) *Node{ if head == nil{ head = NewNode(data, nil) return head } if index == 0{ ... Read More

112 Views
ExamplesExample Live Demopackage main import "fmt" type Node struct { value int next *Node } func NewNode(value int, next *Node) *Node{ var n Node n.value = value n.next = next return &n } func TraverseLinkedList(head *Node){ temp := head for temp != nil { fmt.Printf("%d ", temp.value) temp = temp.next } fmt.Println() } func InsertNodeAtIthIndex(head *Node, index, data int) *Node{ if head == nil{ head = NewNode(data, nil) return head } if index == 0{ ... Read More

401 Views
ExamplesApproach to solve this problemStep 1 − Define a method that accepts the head of a linked list.Step 2 − If head == nil, create a new node and make it head and return it as the new head.Step 3 − When index == 0, then update the head.Step 4 − Iterate the given linked list from its head. Also, initialize preNode that will keep the store address of the previous node.Step 5 − If index i matches with the given index, then then delete that node.next, break the loop.Step 6 − Return, at the end of loop.Example Live Demopackage main ... Read More

191 Views
ExampleApproach to solve this problemStep 1 − Define a method that accepts the head of a linked list.Step 2 − If head == nil, return the head.Step 3 − When index == 0, then return head.nextStep 4 − Else, iterate the given linked list from its head.Step 5 − If index i matches with the given index (to be deleted), then delete that node.next, break the loop.Step 6 − Return, at the end of the loop.Example Live Demopackage main import "fmt" type Node struct { value int next *Node } func NewNode(value int, next *Node) *Node{ var n ... Read More

111 Views
ExamplesApproach to solve this problemStep 1 − Define a method that accepts the head of a linked list.Step 2 − If head == nil, return the head.Step 3 − When index == 0, then return head.nextStep 4 − Else, iterate the given linked list from its head.Step 5 − If index i matches with the given index (to be deleted), then delete that node.next, break the loop.Step 6 − Return at the end of the loop.Example Live Demopackage main import "fmt" type Node struct { value int next *Node } func NewNode(value int, next *Node) *Node{ var n ... Read More

142 Views
ExampleApproach to solve this problemStep 1 − Define a method that accepts the head of a linked list.Step 2 − If head == nil, return the head.Step 3 − When index == 0, then return head.nextStep 4 − Else, iterate the given linked list from head.Step 5 − If index i matches with the given index (to be deleted), then delete that node.next, break the loop.Step 6 − Return at the end of the loop.Example Live Demopackage main import "fmt" type Node struct { value int next *Node } func NewNode(value int, next *Node) *Node{ var n Node ... Read More

110 Views
ExamplesApproach to solve this problemStep 1 − Define a method that accepts head of the linked list.Step 2 − If head == nil, return the head.Step 3 − When index == 0, then return head.nextStep 4 − Else, Iterate given linked list from head.Step 5 − If index i matches with given index(to be delete) then delete that node.next, break the loop.Step 6 − Return, at the end of loop.Example Live Demopackage main import "fmt" type Node struct { value int next *Node } func NewNode(value int, next *Node) *Node{ var n Node n.value = value ... Read More