Computing
Computer Science LearnITWithMrC ⛯ Year 7 Year 8 Year 9 GCSE
Responsive image

Lesson Video

21

Lesson Tasks

  • Watch the Lesson video
    Make notes if needed.
  • Open your Learning Journal
    Complete Task 1 in your Learning Journal
  • Complete the learning activities
    Make sure you complete the book tasks in your Unit Booklet
  • Complete End of Task Assessment
    Update your learning objectives

What do I need to Learn?

0 results forGuest
I need to learn how to understand and use a two dimensional array as a data structure.

Key Terms

Data structure Array List References 2D Array

There is no Powerpoint to go with this section. You can download the notes sheet from Task 1 and make some notes on the topic, however the main task is to be completed in your book. Don't forget to update your learning objectives at the end!

Task 1 - Getting organised - notes Click to see more


Task 1: Fill in the heading.

Open your cornell notes word document, if you would rather fill it in by hand then feel free to print it out. Fill in the video title and the topic at the top of the page. See example below.

Open a Cornell notes sheet by clicking on the image below.

Avatar

Remember good notes allow students to help each other problem solve

Good notes will help you organise and process data and information

Cornell notes help you retain and recall information by having three different ways/sections where you process the information.

Note taking is a way of helping you to remember things you would otherwise forget. It also stimulates our critical thinking skills.

Remember! whenever you see the notes icon this means the information is important and you should write it down on your notes sheet.


Task 2 - Complex data structures 2D Arrays Click to see more

Two- dimensional Arrays

A two-dimensional array is a data structure in computer science that stores a collection of items in a grid-like format, similar to a table in a spreadsheet. Imagine a grid of lockers, each locker is addressed by its row and column, and can store one item.

For example, in computer science, a two-dimensional array can be used to store a table of numbers or strings, where each element can be accessed by its row and column. They are useful when you need to organize information in a tabular format, like a table of scores or a map.


A chessboard example

Here's an example of how you could create a 2D array in Python that represents a chessboard, where the values in the array are strings representing the pieces on the chessboard:

chessboard = [ ["r", "n", "b", "q", "k", "b", "n", "r"], ["p", "p", "p", "p", "p", "p", "p", "p"], [" ", " ", " ", " ", " ", " ", " ", " "], [" ", " ", " ", " ", " ", " ", " ", " "], [" ", " ", " ", " ", " ", " ", " ", " "], [" ", " ", " ", " ", " ", " ", " ", " "], ["P", "P", "P", "P", "P", "P", "P", "P"], ["R", "N", "B", "Q", "K", "B", "N", "R"] ]

Here, the chessboard is represented as a list of lists, where each inner list represents a row on the chessboard, and the items in the list represent the pieces on the chessboard, with "r" representing a black rook, and "R" representing a white rook etc.

You can access an individual piece on the chessboard using two sets of square brackets, like this:

chessboard[i][j]

where i and j are the indices of the row and column of the piece you want to access. For example chessboard[0][0] would give you the piece on top left corner.

You can also use a nested for loop to iterate through all pieces on the chessboard, like this:

for row in chessboard: for piece in row: print(piece)

Task: Chess Moves

Complete the following task in python.

  1. Copy the code above to create the 2D Array for the chessboard
  2. Print out the board using the for loop
  3. Extension

    1. Can you move both of the kings black and white pawna two spaces forward?
    2. Can you do anything else with your chess board?

Use would print all the pieces of the chessboard in row major order.


Task 3 - Book Tasks Click to see more

Task: Two Dimensional arrays

Open your student workbook at page 51 Read through the notes and complete the following task:
  1. Task 28


Task 4 - Update Objectives Click to see more

Summing it all up

Lets look at the learning outcomes and decide which one best describes our current level of understanding :

Tick the one you feel is closest to your level

Learning Outcomes I need to learn how to understand and use a two dimensional array as a data structure.

  • I have a basic understanding of how I can understand and use a two dimensional array as a data structure. with a little help from my teacher
  • I can show my teacher that I can understand and use a two dimensional array as a data structure. without their help.
  • I can understand and use a two dimensional array as a data structure. independently and I can also explain it to others and can complete any extension tasks I am given.

🠜 Now update your learning objectivesClick on the Assessment image

Task 5 - End of Task Assessment Click to see more