Skip to content
← Computer Science

Computer Science · Class 12 Optional

Ch 5Sorting — Class 12 Computer Science, concept-first.

Sorting is the process of arranging a given collection of elements in a specific order. This order can be ascending or descending for numbers, or alphabetical for strings. The core idea is to bring order to a set of items so that they become easier to work with.

12

Q&A

6

Concepts

40m

Section weightage

Computational Thinking and Programming – 2 · across all 7 lessons

Start learning — read this chapter →

Key concepts

Hover a concept to preview it and jump to its most relevant Q&A.

Chapter contents

The NCERT structure, section by section. Open a section to see its questions, then read the concept-first solution.

5.1

Introduction

Sorting is the process of arranging a given collection of elements in a specific order. This order can be ascending or descending for numbers, or alphabetical for strings.

5.2

Bubble Sort

3 Q

Bubble sort works by repeatedly stepping through a list, comparing adjacent elements, and swapping them if they are in the wrong order.

5.3

Selection Sort

Selection sort works on a simple idea: repeatedly pick the smallest element from the unsorted part of the list and put it at the beginning.

5.4

Insertion Sort

Insertion sort is a sorting algorithm that builds the final sorted list one element at a time. Like selection sort, it divides the list into two parts: a sorted section and an unsorted section.

5.5

Time Complexity of Algorithms

When you write a program to solve a problem, there is often more than one way to do it. You saw this in Class XI when you compared four different algorithms to check whether a given number is prime.

Summary

- Sorting: The process of arranging a collection of elements in a particular order — ascending or descending for numbers, alphabetical for strings — making the elements easier to search and retrieve.

Exercises