Unit summary
- A data structure organises data and its operations; structures are primitive or non-primitive, linear or non-linear, static or dynamic.
- Algorithms are compared by time and space complexity, using Big-O notation.
- An array stores elements of one type contiguously, with O(1) access and O(n) insertion and deletion.
- Linear search is O(n) on any data, and binary search is O(log n) on sorted data.
- Bubble, selection and insertion sort are simple O(n²) sorting methods.
- Two-dimensional arrays are stored in row-major or column-major order, and sparse matrices are stored as triples.
Glossary
| Term | Meaning |
|---|---|
| Abstract data type | A type described by its operations only. |
| Algorithm | A finite sequence of well-defined steps. |
| Array | Elements of one type in contiguous memory. |
| Big-O | An upper bound on growth rate. |
| Binary search | Halving a sorted range at each step. |
| Bubble sort | Sorting by swapping adjacent pairs. |
| Data structure | An organisation of data with its operations. |
| Insertion sort | Sorting by inserting into a sorted part. |
| Linear search | Checking elements one by one. |
| Linear structure | Elements arranged in a sequence. |
| Merging | Combining two sorted lists into one. |
| Non-linear structure | Elements arranged as a tree or graph. |
| Row-major order | Storing a 2D array row by row. |
| Selection sort | Sorting by selecting the minimum. |
| Space complexity | Memory used as a function of input size. |
| Sparse matrix | A matrix with mostly zero elements. |
| Time complexity | Steps taken as a function of input size. |
| Time-space tradeoff | Exchanging memory for speed or the reverse. |
| Traversal | Visiting each element once. |
Question bank
Short Answer Questions (2 marks each)
- Define a data structure.
- Distinguish linear and non-linear data structures.
- What is time complexity?
- What is the time-space tradeoff?
- Write the address formula of a 1D array.
- Compare linear and binary search.
- What is the complexity of bubble sort?
- What is row-major order?
- Define a sparse matrix.
- What is merging?
Medium Answer Questions (5 marks each)
- Explain the classification and operations of data structures.
- Explain Big-O notation with examples.
- Write an algorithm to insert and delete an element in an array.
- Write and trace the binary search algorithm.
- Explain insertion sort with an example.
- Explain the representation of 2D arrays and sparse matrices.
Long Answer Questions (15 marks each)
- Explain data structures, their classification, operations, and the complexity of algorithms.
- Explain arrays, their representation in memory, and the operations of traversal, insertion, deletion and merging.
- Explain and compare linear search and binary search, and the bubble, selection and insertion sorts.
- Explain two-dimensional and multi-dimensional arrays, matrix operations and sparse matrices.
Sources
- Official BCA syllabus Data Structures, course code 25BCA402DS02, Unit I
