levo

Data Structures

Manipulating arrays

  • 3 things to know
  • AS Unit 1

Overview

Algorithm for finding the largest value in an array and how an array is reversed in place.

What you need to know

Answer each one before you reveal it.

Your recallNot started
Key term

Describe the algorithm for finding the largest value in an array.

Key term

How is a new item inserted into the middle of an array while keeping the order?

Key term

How is an item deleted from the middle of an array while keeping the order?

Questions from this subtopic

Each one with the model answer underneath.

  1. 1

    How is a value written into a particular position of an array?

    Model answer

    By assigning to the indexed element, as in marks[4] ← 72, which replaces whatever that position previously held.

  2. 2

    Write pseudocode for a linear search of an array for a target value.

    Model answer

    Set found to false, then FOR i FROM the lower bound TO the upper bound, IF a[i] equals the target THEN set found to true and record i as the position and leave the loop, END IF, END FOR.

  3. 3

    Describe the algorithm for finding the largest value in an array.

    Model answer

    Take the first element as the largest so far, then compare every remaining element with it in turn, replacing the largest so far whenever a bigger value is met.

  4. 4

    Write pseudocode to count how many elements of an array called marks are greater than 50.

    Model answer

    Set count to 0, then FOR i FROM the lower bound TO the upper bound, IF marks[i] > 50 THEN set count to count + 1, END IF, END FOR.

  5. 5

    How is a new item inserted into the middle of an array while keeping the order?

    Model answer

    Every element from the insertion point onwards is shifted one place towards the end to open a gap, and the new value is written into it, which is only possible if a spare position exists.

  6. 6

    How is an item deleted from the middle of an array while keeping the order?

    Model answer

    Every element after it is shifted one place towards the front to close the gap, and the count of items in use is reduced by one.

Other ways to work this

The same content, four other ways.

What is inside Levo

Six ways to work the same material.

1Closed book
2Open book
3Closed book

The 3-step method, run for you

Answer cold, learn it, then prove it stuck. Levo tracks the jump between your first attempt and your last.

Hardware: Architecture, Memory and Storage
Networks and Data Transmission
Logic Gates and Boolean Algebra
Data Representation and Data Types

Cram a whole paper in one sitting

Sort every topic into what you know and what you do not, then drill only the weak ones.

Fetch, , execute.
decodecompilestore

Blank Blitz makes facts automatic

Rapid timed gap-fills on the terms and numbers you need to recall without thinking.

AEncryption is reversible.
BThe stored form could be decrypted.
CA hash cannot be reversed.

Build It gets the exam shape right

Assemble a full-mark answer from its marking points, in the order an examiner wants them.

A bit is a single binary digit.
TrueFalse

Test It catches misconceptions

Spot the fault in a statement. The traps are the mistakes students actually make.

721941163128510

Brain Breaks between sessions

Short focus games to reset attention, so the next set lands better than the last.

Every question in Data Structures, on a schedule.

Attempt a question from memory, write the correct version, then attempt it again. Levo records the jump between your first attempt and your last, and brings each question back on the day you are due to forget it.

Or £46 a year, about £3.83 a month. Cancel anytime.