---
title: "Delete Kth node from doubly linked list"
subject: "Data Structure and Algorithm"
chapter: 4
key: "semester_4/data_structure_and_algorithm:doubly-delete-kth"
source: https://www.bctengineer.com/q/semester_4/data_structure_and_algorithm/doubly-delete-kth
site: BCT Engineering
---

# Delete Kth node from doubly linked list

Data Structure and Algorithm · Chapter 4: Linked lists

- Asked in: 2069 Poush, 3 marks
- Video: [Delete a node from Doubly Linked List(start / middle/ end node)](https://www.youtube.com/watch?v=LvUgew66zOQ) — Vivekanand Khyade - Algorithm Every Day
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_4/data_structure_and_algorithm/doubly-delete-kth
- Whole chapter: https://www.bctengineer.com/md/semester_4/data_structure_and_algorithm/chapter-4

## Question

Write an algorithm for deleting Kth node from the doubly linked list.

## Short answer

If list empty, underflow. Traverse to Kth node p. If p->prev != NULL, set p->prev->next = p->next else start = p->next. If p->next != NULL, set p->next->prev = p->prev. Free p and return its info.

## Answer

With node `(prev, info, next)` and `start` pointing to the first node:

#### Algorithm DELETE_K(start, k)
1. If `start == NULL` print "underflow" and stop.
2. Set `p = start`; repeat k-1 times: `p = p->next`; if `p` becomes NULL print "invalid position" and stop.
3. If `p->prev != NULL` then `p->prev->next = p->next`; else `start = p->next`.
4. If `p->next != NULL` then `p->next->prev = p->prev`.
5. `x = p->info`; `free(p)`; return x.

```text
Before: [a] <-> [p(K)] <-> [b]
After : [a] <-> [b]
```

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. How is the K-th node reached?
   A. Move K times
   B. Starting from start, move p = p->next K-1 times
   C. Use prev from the end only
   D. Jump using index arithmetic
   Answer: B. Linked lists need sequential traversal; K-1 moves give the K-th node. (Key point: Locate)

2. Which assignments unlink p when it is in the middle?
   A. p->next = p->prev
   B. start = p->next
   C. p->prev->next = p->next and p->next->prev = p->prev
   D. free only, without link changes
   Answer: C. Neighbours are linked to each other before p is freed. (Key point: Bypass)

3. If p->prev is NULL, what is done?
   A. p->next->next = NULL
   B. Nothing
   C. p->prev = start
   D. start = p->next
   Answer: D. Deleting the first node moves the head to the second node. (Key point: First node)

## Related in Data Structure and Algorithm

- [Insert and delete kth node in doubly linked list](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Adoubly-insert-delete-kth) — Data Structure and Algorithm, chapter 4, asked 2×
- [Insert before Kth node in doubly linked list](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Adoubly-insert-before-kth) — Data Structure and Algorithm, chapter 4
- [Delete last node of doubly linked list](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Adelete-end-node-doubly) — Data Structure and Algorithm, chapter 4
- [Insert and delete before a node, singly linked](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Asingly-insert-delete-before) — Data Structure and Algorithm, chapter 4
- [Delete employee from doubly linked list](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Adoubly-employee-delete) — Data Structure and Algorithm, chapter 4
