---
title: "Bresenham: line (10,20) to (15,2)"
subject: "Computer Graphics"
chapter: 2
key: "semester_5/computer_graphics:digitize-line-10-20-15-2"
source: https://www.bctengineer.com/q/semester_5/computer_graphics/digitize-line-10-20-15-2
site: BCT Engineering
---

# Bresenham: line (10,20) to (15,2)

Computer Graphics · Chapter 2: Scan-Conversion

- Asked in: 2079 Baisakh, 5 marks
- Video: [Bresenham’s Line Drawing Algorithm :Problem Solving](https://www.youtube.com/watch?v=3p7-thBl00E) — Namitha Ramachandran
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_5/computer_graphics/digitize-line-10-20-15-2
- Whole chapter: https://www.bctengineer.com/md/semester_5/computer_graphics/chapter-2

## Question

Digitize a line with end points (10,20) and (15,2) using Bresenham's algorithm.

## Short answer

Use Bresenham with |m|>1 negative. p0 = 2*5 – 18 = –8. y decrements each step; when p<0, x stays, p+=10; when p≥0, x+=1, p–=26. Resulting pixels: (10,20), (10,19), (11,18), (11,17), (11,16), (11,15), (12,14), (12,13), (12,12), (13,11), (13,10), (13,9), (13,8), (14,7), (14,6), (14,5), (14,4), (15,3), (15,2).

## Answer

**Given:** (10,20) to (15,2). Δx = 5, |Δy| = 18, the slope is negative with |m| = 3.6 > 1. So y is decremented by 1 at each step and the decision parameter decides whether x stays or increases.

```text
p0 = 2Δx − |Δy| = 10 − 18 = −8
If p < 0: x same,  p = p + 2Δx = p + 10
If p ≥ 0: x + 1,   p = p + 2Δx − 2|Δy| = p − 26
```

| k | p_k | (x_k, y_k) |
|---|---|---|
| 0 | -8 | (10,20) |
| 1 | 2 | (10,19) |
| 2 | -24 | (11,18) |
| 3 | -14 | (11,17) |
| 4 | -4 | (11,16) |
| 5 | 6 | (11,15) |
| 6 | -20 | (12,14) |
| 7 | -10 | (12,13) |
| 8 | 0 | (12,12) |
| 9 | -26 | (13,11) |
| 10 | -16 | (13,10) |
| 11 | -6 | (13,9) |
| 12 | 4 | (13,8) |
| 13 | -22 | (14,7) |
| 14 | -12 | (14,6) |
| 15 | -2 | (14,5) |
| 16 | 8 | (14,4) |
| 17 | -18 | (15,3) |
| 18 | -8 | (15,2) |

Pixels:

```text
(10,20) (10,19) (11,18) (11,17) (11,16) (11,15) (12,14) (12,13)
(12,12) (13,11) (13,10) (13,9) (13,8) (14,7) (14,6) (14,5)
(14,4) (15,3) (15,2)
```

**Answer: 19 pixels from (10,20) to (15,2) as listed.**

## Check yourself

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

1. For the line (10,20) to (15,2), which axis is stepped by 1 each time?
   A. y (decreasing), since |Δy| = 18 > Δx = 5
   B. x (increasing), since Δx is the smaller change
   C. x (decreasing)
   D. y (increasing)
   Answer: A. The slope magnitude is 3.6 > 1, so y is the unit-step axis and goes down. (Key point: Driving axis)

2. The initial decision parameter p0 is:
   A. 8
   B. −8
   C. −13
   D. 28
   Answer: B. p0 = 2Δx − |Δy| = 10 − 18 = −8. (Key point: Initial parameter)

3. At a step where p = 2 (≥ 0), what happens?
   A. x stays and the new p = 12
   B. x increases by 1 and the new p = 2 + 10 = 12
   C. x increases by 1 and the new p = 2 − 26 = −24
   D. x stays and the new p = −24
   Answer: C. For p ≥ 0: x+1 and p += 2Δx − 2|Δy| = 10 − 36 = −26. (Key point: Update rule)

4. How many pixels are plotted from (10,20) to (15,2)?
   A. 18
   B. 5
   C. 20
   D. 19
   Answer: D. y goes from 20 to 2 in steps of 1, giving 18 steps plus the start point = 19 pixels. (Key point: Number of pixels)

## Close variants set in other exams

- [Bresenham: line (20,10) to (30,18)](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Adigitize-line-20-10-30-18) — Computer Graphics, chapter 2, asked 4×

## Related in Computer Graphics

- [Bresenham: line (25,20) to (15,10)](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Adigitize-line-25-20-15-10) — Computer Graphics, chapter 2
- [Bresenham: endpoints (10,18),(15,8)](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Adigitize-point-10-18-15-8) — Computer Graphics, chapter 2
- [DDA versus Bresenham line algorithm](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Adda-vs-bresenham-line) — Computer Graphics, chapter 2, asked 6×
- [Write Bresenham's line algorithm](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Abresenham-line-algorithm) — Computer Graphics, chapter 2, asked 3×
- [Bezier points at u=0.25,0.5,0.75: (10,15)...](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Abezier-points-control-10-15) — Computer Graphics, chapter 5, asked 4×
- [Bresenham's algorithm for all slopes](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Abresenham-all-slopes) — Computer Graphics, chapter 2

## Related in other subjects

- [Laplace: 2x2 grid 10/15/20](https://www.bctengineer.com/question.md?key=semester_4%2Fnumerical_method%3Alaplace-2x2-10-15-20-25) — Numerical Method, chapter 7, asked 6×
- [Fault at far end of 33 kV line](https://www.bctengineer.com/question.md?key=semester_5%2Fpower_system_analysis_ii%3Afault-far-end-33kv-line) — Power System Analysis II, chapter 3
- [Fault at load end of overhead line](https://www.bctengineer.com/question.md?key=semester_5%2Fpower_system_analysis_ii%3Afault-load-end-33kv-line) — Power System Analysis II, chapter 3
- [Reactance diagram: 20 MVA generator, 15 kV/25 MVA base](https://www.bctengineer.com/question.md?key=semester_4%2Fpower_system_analysis_i%3Areactance-diagram-20mva-15kv-25mva) — Power System Analysis I, chapter 3
