Q. No.
Question Marks TL CO
1 What is mean by sorting? List any four sorting techniques.
Answer: Sorting is the process of arranging data in a specific order, usually ascending or descending, to make searching and retrieval easier. 2 R CO2
Four Sorting Techniques: 1) Bubble Sort 2) Selection Sort 3) Insertion Sort 4) Quick Sort.
2 What is mean by Searching? List types of Searching.
2 R CO2
Answer: Searching is the process of finding a particular element in a collection of data. Types of Searching: 1) Linear Search 2) Binary Search
3 Describe bubble sort with example. State its advantages and disadvantages.
Answer: Bubble Sort repeatedly compares adjacent elements and swaps them if they are in the wrong order. This process continues until the list
is sorted. Example: Sort {5, 3, 8, 4} in ascending order. - Pass 1: {3, 5, 4, 8} - Pass 2: {3, 4, 5, 8} - Pass 3: {3, 4, 5, 8} (Sorted) 4 U CO2
Advantages: (i) Simple and easy to implement, (ii) Works well for small datasets. Disadvantages: (i) Very slow for large data (O(n²)), (ii) Re-
quires many passes even if partially sorted.
4 Differentiate between linear data structure and non-linear data structure. (minimum 4 points each).
Answer:
Linear Data Structure:
1) Data arranged sequentially.
2) Traversal is done one by one. 3
) Examples: Array, Linked List, Stack, Queue.
4 U CO1
4) Memory use may be fixed (arrays) or dynamic (linked list).
Non-linear Data Structure:
1) Data arranged hierarchically or in interconnected manner.
2) Traversal is non-sequential (multiple paths).
3) Examples: Tree, Graph.
4) Efficient for representing relationships.
5 Sort the following numbers in ascending order using selection sort. {35, 14, 5, 102, 61, 10} and Write the output after
each iteration.
Answer: Selection Sort repeatedly finds the minimum and places it at the correct position.
Initial list: {35, 14, 5, 102, 61, 10}
Iteration 1: {5, 14, 35, 102, 61, 10} 4 A CO2
Iteration 2: {5, 10, 35, 102, 61, 14}
Iteration 3: {5, 10, 14, 102, 61, 35}
Iteration 4: {5, 10, 14, 35, 61, 102}
Iteration 5: {5, 10, 14, 35, 61, 102} (sorted)
6 Differentiate between Binary search and Linear search. (4 points)
Answer: Linear Search: 1) Checks each element one by one. 2) Works on unsorted or sorted data. 3) Time complexity: O(n). 4) Simple to imple-
4 U CO2
ment. Binary Search: 1) Divides list into halves, checks middle element. 2) Works only on sorted data. 3) Time complexity: O(log n). 4) Faster for
large datasets.
7 Find the position of element 29 using the Binary search method in an array given as {11, 5, 21, 3, 29, 17, 2, 43}.
Answer: Step 1: Sort array → {2, 3, 5, 11, 17, 21, 29, 43} Step 2: Middle = (0+7)/2 = 3 → arr[3] = 11 29 > 11 → Search right half. Step 3: New
4 A CO2
range = {17, 21, 29, 43}. Middle = 5 → arr[5] = 21 29 > 21 → Search right half. Step 4: New range = {29, 43}, middle = 6 → arr[6] = 29 →
FOUND. Position: 6 (in sorted array, 0-based index).
8 Describe the workings of linear search with an example.
Answer: Linear search checks each element sequentially until the key is found or list ends. Example: Search 21 in {10, 25, 21, 36, 40}. Step 1:
4 A CO2
Compare 21 with 10 → not match. Step 2: Compare 21 with 25 → not match. Step 3: Compare 21 with 21 → match found at index 2. Conclu-
sion: Linear search works on unsorted or sorted lists but is slower for large data (O(n)).
9 Explain Insertion sort with example.
Answer: Insertion Sort builds the sorted list one item at a time by inserting each element into its correct place.
Example: Sort {5, 3, 4, 1}.
Pass 1: {3, 5, 4, 1} 4 A CO2
Pass 2: {3, 4, 5, 1}
Pass 3: {1, 3, 4, 5} (Sorted).
Features: Simple, good for small datasets, O(n²) time in worst case.
10 Define Quick sort. And Sort the following numbers in ascending order using quick sort. {50, 2, 6, 22, 3, 39, 49, 25, 18, 4 4 A
5}
Answer: Quick Sort is a divide-and-conquer algorithm that chooses a pivot, partitions array around pivot, and recursively sorts subarrays.
Given array: {50, 2, 6, 22, 3, 39, 49, 25, 18, 5}
Step 1: Choose pivot (e.g., 50), partition → {2, 6, 22, 3, 39, 49, 25, 18, 5} {50}
Step 2: Sort left side recursively: {2, 6, 22, 3, 39, 25, 18, 5, 49}.
Final Sorted Output → {2, 3, 5, 6, 18, 22, 25, 39, 49, 50}.
Course Coordinator Module Coordinator