levo

Data Structures

Manipulating arrays

  • 3 things to know
  • AS Unit 1
Start revising · £5/month

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.

Everything in your subscription

Runs, plus a mode for every other kind of session.

1Flash
2Imposter
3Fade
4Brain dump

Learn every subtopic in runs of four questions

Facts flash and fade, a wrong word hides in some of them, and a brain dump decides which questions are locked in.

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

Cram the night before, weakest topic first

A quick scan finds your weakest topics. Recall each fact you missed three times in a row.

Fetch, , execute.
decodecompilestore

Blank Blitz consolidates the facts

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

✓What it iscovered
~Why it happenspartly there
How long it lastsnot there yet

Explain It tests your understanding

Explain a concept in your own words and see which of its points you covered.

A bit is a single binary digit.
TrueFalse

Test It catches misconceptions

Spot the fault in a statement. The faults are the mistakes students make most often.

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.

Learn it in runs of four questions, each ending on a brain dump against the clock. Every question you lock in comes back the next day, then at longer gaps, each time just before you would forget it.

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