PROGRAMMING FOR PROBLEM SOLVING
Unit IV · Arrays, Searching and Sorting
Learn arrays, searches, sorting and matrices through clear answers and worked examples.
Array Basics
- 01What is an array?2 marks
- 02Define an array and explain its advantages and limitations.5 marks
- 03What values are stored by int a[5] = {2, 4};?2 marks
- 04Explain array declaration and initialisation with examples.5 marks
- 05What is the valid index range for int a[10]?2 marks
- 06Explain array subscripts, valid bounds and off-by-one errors.5 marks
- 07Why should the element count be checked before reading an array?2 marks
- 08Write a C program to read and display an array using loops.5 marks
- 09What is array traversal?2 marks
- 10Explain array traversal and write a program to find the sum of its elements.5 marks
- 11Why initialise minimum and maximum from the first element?2 marks
- 12Write a C program to find minimum, maximum and average in an integer array.5 marks
Arrays and Functions
Searching
- 17What does linear search do when values are unsorted?2 marks
- 18Explain linear search and write a non-recursive C function to implement it.5 marks
- 19What prerequisite must hold for this binary-search function?2 marks
- 20Explain binary search and write a non-recursive C function to implement it.5 marks
- 21Which search is suitable for a small unsorted array without preprocessing?2 marks
- 22Compare linear search and binary search.5 marks
Sorting
- 23What does one left-to-right bubble-sort pass achieve?2 marks
- 24Explain bubble sort and write a C program to sort integers in ascending order.5 marks
- 25What is selected during each ascending selection-sort pass?2 marks
- 26Explain selection sort and write a C program for ascending order.5 marks
- 27How does insertion sort extend its sorted prefix?2 marks
- 28Explain insertion sort and write a C program for ascending order.5 marks
- 29What does a stable sorting algorithm preserve?2 marks
- 30Compare bubble sort, selection sort and insertion sort.5 marks
Matrices and Dimensions
- 31How is an element of int a[2][3] selected?2 marks
- 32Explain the declaration, initialisation and access of two-dimensional arrays.5 marks
- 33When can two matrices be added?2 marks
- 34Write a C program using a function to add two matrices.5 marks
- 35When is A × B defined, and what is the result size?2 marks
- 36Write a C program using a function to multiply two matrices.5 marks
- 37How many int elements are in int a[2][3][4]?2 marks
- 38Explain the declaration and access of multidimensional arrays.5 marks
- 39Why must the row width match in a two-dimensional array parameter?2 marks
- 40Explain how a two-dimensional array is passed to a function.5 marks
No matching questions. Clear the search or change the marks filter.
The 2- and 5-mark badges are practice allocations. Previous-paper questions retain their printed marks.