Data structures: lists, arrays and tables
플레이하며 배우기
이 문제들을 풀어 에너지를 얻은 뒤 낚시하고 탐험하세요. 계정이 필요 없어요.
교육자를 위해: Data structures: lists, arrays and tables(KS3 Computing, Computer Science)을(를) 위한 바로 쓸 수 있는 수업 슬라이드, 복습 노트 — 수업에 사용하거나, 학습자들이 실시간 게임으로 즐기는 인터랙티브 클래스 활동으로 진행하세요.
수업 노트
What are Data Structures?
- A data structure is a way of organising and storing data so it can be used efficiently.
- Common data structures include lists, arrays, and tables.
- Choosing the right structure makes programs simpler and faster.
- In programming, a list is a collection of items in a particular order.
- An array is a type of list where all elements are of the same data type and stored in contiguous memory.
- A table (or two-dimensional array) stores data in rows and columns, like a spreadsheet.
An array is an ordered collection of same-type values stored under one name and reached by index.

Lists and Arrays
- A list is a mutable, linear collection of elements.
- An array is a collection of elements of the same type, each identified by an index.
- Arrays are stored in memory so that the address of each element can be calculated from its index.
- For example, an array of 10 integers starting at address 2000 uses addresses 2000, 2004, 2008, ... (each integer takes 4 bytes).
- The address of element with index i is: base address + (i × size of each element).
- The first element's address is called the base address.
Indexing
- Indexing is how you access individual elements in a list or array.
- Most programming languages use zero-based indexing: the first element is at index 0.
- Some languages (like Lua) use one-based indexing: the first element is at index 1.
- The index is usually a non-negative integer.
- Using the index, you can read or change the value at that position.
Adding and Removing Items
- Lists are mutable, meaning you can add, remove, or change items.
- To add an item, you can use methods like `append()` (add to end) or `insert()` (add at a specific index).
- To remove an item, you can use `remove()` (by value) or `pop()` (by index).
- In arrays, the size is often fixed, but in dynamic lists (like Python lists) the size can change.
- When you add or remove items, the indices of later items may change.
Iterating Over a List
- Iterating means going through each element of a list one by one.
- You can use a for loop to iterate over a list.
- Example in Python: `for item in mylist:` processes each item.
- You can also use a loop with an index: `for i in range(len(mylist)):`.
- Iteration is useful for calculating totals, finding items, or transforming data.
Traversal visits each indexed cell in turn, from the first index to the last.

Two-Dimensional Arrays (Tables)
- A two-dimensional array (or table) is like a grid with rows and columns.
- It is sometimes called a matrix.
- You access an element using two indices: `table[row][column]`.
- Tables are useful for representing data like a spreadsheet, a chessboard, or a timetable.
- You can iterate over a table using nested loops (one for rows, one for columns).
Choosing the Right Structure
- Use a list/array when you have a sequence of items that you need to access by position.
- Use a table when your data naturally has two dimensions, like rows and columns.
- Consider whether you need to add/remove items frequently; lists are flexible, arrays may be fixed-size.
- Think about the data type: arrays usually require all elements to be the same type.
- Choosing the right structure makes your code clearer and more efficient.
Real-World Applications
- Arrays are used to implement vectors and matrices in mathematics.
- Databases often store records in arrays.
- Arrays are used to implement other data structures like stacks, queues, and strings.
- Lookup tables are arrays used to quickly find values.
- Almost every program uses arrays in some way.
슬라이드
연습 문제
무료 미리 보기 — 60개 중 8개 문제. 가입하면 전부 볼 수 있어요.
1.What is an array in computer science?
Easy- AA data structure consisting of a collection of elements, each identified by at least one index
- BA type of computer memory that stores programs
- CA programming language used for web development
- DA single variable that can hold only one value
2.In zero-based indexing, the first element of an array has index 1.
EasyTrue or false?
3.Which of the following is a correct way to describe a two-dimensional array?
Easy- AA collection of elements arranged in rows and columns, like a grid
- BA collection of elements all stored in a single row
- CA list that can only store numbers
- DA data structure that cannot be indexed
4.Which of the following are common uses of arrays? (Select all that apply)
Easy- AImplementing mathematical vectors and matrices
- BStoring a single value in a program
- CImplementing other data structures such as lists and strings
- DReplacing all conditional statements in a program
- ECreating lookup tables
5.Which of the following is a reason why arrays are efficient for computers?
Easy- AThey can store elements of different sizes
- BThe position of each element can be computed from its index using a mathematical formula
- CThey do not require memory allocation
- DThey can only be accessed sequentially
6.Match each indexing convention to its description.
Easy- Zero-based indexing
- One-based indexing
- Base address
- First element has index 0
- First element has index 1
- Address of the first element
7.Arrange the following steps to compute the address of an array element using the formula: address = base + (index × size).
Medium- Multiply the index by the size of each element
- Add the result to the base address
- Identify the base address and the size of each element
8.Arrays are used to implement many other data structures such as lists, stacks, and queues.
EasyTrue or false?
기출 문제
이 주제의 기출 문제 연습이 곧 나와요.
곧 출시