Subtopic Notes

G - Arrays, Linear Search, Bubble Sort

9-11. Data Types and Structures, Programming

Arrays

  • Stores a collection of elements of the same data type
  • Contiguous block of memory
  • Widely used in programming because they allow efficient access and manipulation of a large number of values
  • Elements can be accessed using index
  • Advantages: Fast insertion, Fast access of elements
  • Disadvantages: Slow search, Slow deletion, Fixed size
  • Ordered Arrays: Elements are arranged in a specific order based on values
    • Advantage: More efficient search algorithm
    • Disadvantage: Slow deletion, slow insertion, fixed size
  • Arrays are 0 indexed: Index of 1st element is 0, 2nd element is 1
  • Index of last element: length - 1
  • In Pseudocode, Arrays index might start from 0 or 1

PYTHON

Python can be executed directly in the browser.

Editor — Python
Output
No output yet.

PSEUDOCODE

Pseudocode uses basic Cambridge-style keyword highlighting. Execution is not supported yet.

Editor — Pseudocode

Common Array Operations

PYTHON

Python can be executed directly in the browser.

Editor — Python
Output
No output yet.

PSEUDOCODE

Pseudocode uses basic Cambridge-style keyword highlighting. Execution is not supported yet.

Editor — Pseudocode

Linear Search

Simple searching algorithm that checks each element in a list or array sequentially until it finds the desired value

PYTHON

Python can be executed directly in the browser.

Editor — Python
Output
No output yet.

PSEUDOCODE

Pseudocode uses basic Cambridge-style keyword highlighting. Execution is not supported yet.

Editor — Pseudocode

Bubble Sort

Sorting algorithm that repeatedly swaps adjacent elements if they are in the wrong order and iterates until the list is sorted.

PYTHON

Python can be executed directly in the browser.

Editor — Python
Output
No output yet.

PSEUDOCODE

Pseudocode uses basic Cambridge-style keyword highlighting. Execution is not supported yet.

Editor — Pseudocode