---
title: "MapReduce max marks per college"
subject: "Big Data Technologies"
chapter: 3
key: "semester_8/big_data_technologies:mapreduce-max-marks-college"
source: https://www.bctengineer.com/q/semester_8/big_data_technologies/mapreduce-max-marks-college
site: BCT Engineering
---

# MapReduce max marks per college

Big Data Technologies · Chapter 3: Map-Reduce Framework

- Asked in: 2073 Magh, 10 marks
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_8/big_data_technologies/mapreduce-max-marks-college
- Whole chapter: https://www.bctengineer.com/md/semester_8/big_data_technologies/chapter-3

## Question

For following data, list the input to/output from both the map and reduce functions for getting maximum marks of each college.

| Student Name | College Name | Final Marks in % |
|---|---|---|
| Ram | ABC | 70 |
| Sita | ABC | 80 |
| Hari | ABC | 60 |
| Gita | XYZ | 90 |
| Rita | XYZ | 80 |
| Shyam | PQR | 90 |
| Laxmi | PQR | 70 |
| Gopal | PQR | 60 |

## Short answer

Map input: (byte offest, 'Ram,ABC,70') etc. for all eight rows. Mapper outputs (college, marks) pairs. Reducer input: (ABC,[70,80,60]), (PQR,[90,70,60]), (XYZ,[90,80]). Final output maximum marks: ABC 80%, PQR 90%, XYZ 90%.

## Answer

We use one MapReduce job. The **mapper** emits `(college, marks)` for each record. The framework groups values by key (shuffle and sort). The **reducer** takes the maximum of the list of marks for each college.

#### Mapper and reducer pseudocode

```text
map(key = byte offset, value = "Name,College,Marks"):
    fields = split(value, ",")
    emit(trim(fields[1]), int(trim(fields[2])))   // (college, marks)

reduce(key = college, values = list of marks):
    max = 0
    for v in values:
        if v > max: max = v
    emit(college, max)
```

#### Input to the map function

Each row is one `(key, value)` pair. The key is the byte offset of the line (not used), the value is the line.

| Key (offset) | Value |
|---|---|
| 0 | Ram, ABC, 70 |
| 1 | Sita, ABC, 80 |
| 2 | Hari, ABC, 60 |
| 3 | Gita, XYZ, 90 |
| 4 | Rita, XYZ, 80 |
| 5 | Shyam, PQR, 90 |
| 6 | Laxmi, PQR, 70 |
| 7 | Gopal, PQR, 60 |

(Offsets are shown as line numbers for simplicity.)

#### Output of the map function (input to shuffle)

```text
(ABC, 70)   (ABC, 80)   (ABC, 60)
(XYZ, 90)   (XYZ, 80)
(PQR, 90)   (PQR, 70)   (PQR, 60)
```

#### After shuffle and sort (input to the reduce function)

The framework groups all values of the same key and sorts keys:

| Key | List of values |
|---|---|
| ABC | [70, 80, 60] |
| PQR | [90, 70, 60] |
| XYZ | [90, 80] |

#### Output of the reduce function (final output)

| College | Maximum marks |
|---|---|
| ABC | 80 |
| PQR | 90 |
| XYZ | 90 |

#### Data flow

```text
 Input lines -> MAP -> (college,marks)
      -> SHUFFLE/SORT -> (college,[marks])
      -> REDUCE -> (college,max)
```

Since max is associative and commutative, the same reducer can also be used as a **combiner**, to reduce network traffic by sending only the local maximum from each mapper.

## Check yourself

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

1. What does the mapper emit for each student record?
   A. (student name, marks)
   B. (marks, college)
   C. (college, marks)
   D. (college, student name)
   Answer: C. The college is the key, so marks of the same college are grouped together. (Key point: Map output)

2. What is the input to the reducer for key PQR?
   A. [90, 70, 60]
   B. [90, 80]
   C. [70, 80, 60]
   D. 90
   Answer: A. PQR has Shyam 90, Laxmi 70 and Gopal 60. (Key point: Reduce input)

3. What is the final output of the job?
   A. ABC 70, PQR 70, XYZ 80
   B. ABC 80, PQR 90, XYZ 80
   C. ABC 80, PQR 60, XYZ 90
   D. ABC 80, PQR 90, XYZ 90
   Answer: D. Maximum per college: ABC 80, PQR 90, XYZ 90. (Key point: Reduce output)

4. Why can the reducer also be used as a combiner here?
   A. Max is associative and commutative, so local maximums can be sent
   B. Because there is only one college
   C. Because max needs all values together
   D. Because combiners sort the data
   Answer: A. Taking the max of local maxima gives the same result, reducing network traffic. (Key point: Combiner use)

## Related in Big Data Technologies

- [MapReduce data flow technique](https://www.bctengineer.com/question.md?key=semester_8%2Fbig_data_technologies%3Amapreduce-data-flow) — Big Data Technologies, chapter 3
- [Optimization and data locality in MapReduce](https://www.bctengineer.com/question.md?key=semester_8%2Fbig_data_technologies%3Amapreduce-optimization-data-locality) — Big Data Technologies, chapter 3
- [Max and min word occurrence with MapReduce](https://www.bctengineer.com/question.md?key=semester_8%2Fbig_data_technologies%3Amapreduce-max-min-word-occurrence) — Big Data Technologies, chapter 3
- [MapReduce worker failure tolerance](https://www.bctengineer.com/question.md?key=semester_8%2Fbig_data_technologies%3Amapreduce-fault-tolerance) — Big Data Technologies, chapter 3
- [MapReduce workflow with example](https://www.bctengineer.com/question.md?key=semester_8%2Fbig_data_technologies%3Amapreduce-workflow-example) — Big Data Technologies, chapter 3, asked 2×
- [Combiner function in MapReduce](https://www.bctengineer.com/question.md?key=semester_8%2Fbig_data_technologies%3Amapreduce-combiner-function) — Big Data Technologies, chapter 3

## Related in other subjects

- [AMC, RAM and interval: FC 80%, PWP 35%](https://www.bctengineer.com/question.md?key=semester_6%2Firrigation_and_drainage_engineering%3Amoisture-fc80-pwp35-root60) — Irrigation and Drainage Engineering, chapter 2, asked 2×
- [Student records with two functions](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Astruct-student-read-display-functions) — Computer Programming, chapter 8
- [Maximum peak input for undistorted output](https://www.bctengineer.com/question.md?key=semester_4%2Fadvanced_electronics%3Aslew-rate-max-peak-input) — Advanced Electronics, chapter 2
- [Principal stresses, max shear: 80, 60, 20 MPa](https://www.bctengineer.com/question.md?key=semester_3%2Fstrength_of_materials%3Aprincipal-stresses-60-20-80) — Strength of Materials, chapter 4
