CS Atlas GATE 2027
PDS course
0 / 103 complete

PDS/Phase 7 · Integration & Final Test

Chapter review L3.1 · Item 45 of 103

Arrays as a data structure

Read at your own pace. Try the questions before opening the answers.

On this page

ACompressed recap

🧾

An ADT fixes operations and behaviour; a data structure implements it. Arrays give O(1) access but O(n) insertion and deletion (shifting), O(n) unsorted search and O(log n) binary search on sorted data. Addresses: subtract lower bounds; row-major multiplies the row offset by the column count, column-major the column offset by the row count; 3-D row-major uses i·n₂n₃ + j·n₃ + k.

BMerged rule card

3.1 Arrays as a data structure: the ADT idea; address calculation (row-major, column-major, non-zero lower bounds); cost of insert, delete and search

  • ADT = operations + behaviour; data structure = an implementation.
  • Array: access O(1); insert/delete at p O(n − p); search O(n), sorted O(log n).
  • Row-major: B + ((i − l₁)·n₂ + (j − l₂))·w; column-major: B + ((j − l₂)·n₁ + (i − l₁))·w.
  • nₖ = uₖ − lₖ + 1; 3-D row-major: B + (i·n₂n₃ + j·n₃ + k)·w (from 0).
  • Binary search: sorted only; ⌊log₂ n⌋ + 1 probes.

CInterleaved GATE-style questions

Q1NAT2 marksAddress

int A[1..8][1..12] (4 bytes) row-major from 3000. Address of A[4][9]?

Numerical answer: ________

Q2NAT2 marksAddress

The same array column-major from 3000. Address of A[4][9]?

Numerical answer: ________

Q3NAT1 markElements

How many elements does A[−3 … 5][2 … 6] have?

Numerical answer: ________

Q4MCQ1 markCosts

Inserting at the front of an array of n elements costs:

  • (A) O(n)
  • (B) O(log n)
  • (C) O(1)
  • (D) O(n²)

Q5MCQ2 marksBinary search

Binary search for 11 in {1, 3, 5, 7, 9, 11, 13} probes which positions (0-based)?

  • (A) 0, 1, 2, 3, 4, 5
  • (B) 3, 4, 5
  • (C) 3, 5
  • (D) 6, 5

Q6NAT2 marks3-D

char C[4][5][6] (indices from 0, 1 byte) is row-major from 0. What is the address of C[3][2][1]?

Numerical answer: ________

Q7MSQ1 markFacts

Which are true?

  • (A) Binary search works on unsorted arrays.
  • (B) Column-major address uses the number of rows.
  • (C) C stores 2-D arrays in row-major order.
  • (D) Deleting the last element of an array needs no shifting.

Q8MCQ1 markADT vs structure

Which is a data structure rather than an ADT?

  • (A) “a list whose items have positions”
  • (B) an array of 100 ints in consecutive memory
  • (C) “a collection supporting insert, delete, search”
  • (D) “a collection where the last item added is removed first”

DAnswer Vault

Answer Vault

Try the questions first. Open when you are ready to check.

Q1 Answer: 31762 marks

((3)·12 + 8)·4 = 176 → 3176.

Re-read: Lesson 3.1 — Arrays as a data structure: the ADT idea; address calculation (row-major, column-major, non-zero lower bounds); cost of insert, delete and search

Q2 Answer: 32682 marks

((8)·8 + 3)·4 = 268 → 3268.

Re-read: Lesson 3.1 — Arrays as a data structure: the ADT idea; address calculation (row-major, column-major, non-zero lower bounds); cost of insert, delete and search

Q3 Answer: 451 mark

9 × 5 = 45.

Re-read: Lesson 3.1 — Arrays as a data structure: the ADT idea; address calculation (row-major, column-major, non-zero lower bounds); cost of insert, delete and search

Q4 Answer: (A)1 mark

All n elements shift.

  • (B) is wrong: Every element moves.
  • (C) is wrong: Shifting is needed.
  • (D) is wrong: One pass of shifting.

Re-read: Lesson 3.1 — Arrays as a data structure: the ADT idea; address calculation (row-major, column-major, non-zero lower bounds); cost of insert, delete and search

Q5 Answer: (C)2 marks

mid 3 (7 < 11) → range 4..6, mid 5 → found.

Output

found=1 at 5 after 2 probes
  • (A) is wrong: That is linear search.
  • (B) is wrong: The second mid is (4 + 6)/2 = 5.
  • (D) is wrong: The first probe is the middle, 3.

Re-read: Lesson 3.1 — Arrays as a data structure: the ADT idea; address calculation (row-major, column-major, non-zero lower bounds); cost of insert, delete and search

Q6 Answer: 1032 marks

3·30 + 2·6 + 1 = 103.

Re-read: Lesson 3.1 — Arrays as a data structure: the ADT idea; address calculation (row-major, column-major, non-zero lower bounds); cost of insert, delete and search

Q7 Answer: (B) (C) (D)1 mark

Binary search needs sorted data.

  • (A) is wrong: It relies on order.

Re-read: Lesson 3.1 — Arrays as a data structure: the ADT idea; address calculation (row-major, column-major, non-zero lower bounds); cost of insert, delete and search

Q8 Answer: (B)1 mark

A concrete memory layout.

  • (A) is wrong: Behaviour only.
  • (C) is wrong: A description of behaviour.
  • (D) is wrong: Behaviour only.

Re-read: Lesson 3.1 — Arrays as a data structure: the ADT idea; address calculation (row-major, column-major, non-zero lower bounds); cost of insert, delete and search

Ready for the next idea?

Mark this item complete when you’ve finished reading and working through it.