Arrays, lists and records
Apréndelo jugando
Responde estas preguntas para ganar energía, luego pesca y explora. Sin cuenta.
Para educadores: diapositivas de la lección, apuntes de repaso listos para usar sobre Arrays, lists and records (Computer Science, Programming) — úsalos en tu lección, o presenta el tema como una actividad interactiva de clase que tus aprendices juegan como un juego en vivo.
Apuntes de la lección
Arrays and lists
- An array stores multiple values of the same data type under one name. Each item has an index (usually starting at 0). Example: scores = [12, 8, 15]; scores[0] is 12.
- One-dimensional (1D) arrays are lists; two-dimensional (2D) arrays are tables with rows and columns: grid[row][column].
- Arrays have a fixed size in many languages; lists may grow.
Indexed array

Using arrays
- Traversal visits elements using their valid indices. For total = 0 and scores = [12, 8, 15], an inclusive FOR loop from 0 to 2 adds all three elements to give 35.
- Initialise an accumulator before adding values. For a maximum search, initialise from the first element of a non-empty array rather than assuming zero is a valid starting maximum.
Array traversal

Records
- A record groups named fields about one entity, such as a student’s name, age and grade. Fields may have different types.
- Collections of records may be held in files or database tables; not every record file by itself is a database system.
When to use
- Use arrays for lists of the same type; records for related fields of different types.
Advantages
- Arrays avoid many separate variables, make code shorter and loops possible.
Two-dimensional arrays
- grid[row][column]
- Rows and columns
- Nested loops
Accessing a two-dimensional array

Diapositivas
Sign up free to view the lesson slides
Step through every slide for this topic — plus flashcards and revision notes — with a free account.
Preguntas de práctica
Vista previa gratis — 8 de 33 preguntas. Regístrate para verlas todas.
1.What is an array?
Easy- Aa data structure storing multiple values under one name
- Ba variable only
- Ca loop
- Da function
2.What is an index?
Easy- Athe position of an item in an array
- Bthe value
- Cthe size
- Dan error
3.With zero-based indexing, which index selects the first item?
Easy- A0
- B1
- C-1
- D2
4.What is a record?
Easy- Aa collection of fields about one thing
- Ba list of numbers
- Ca loop
- Da file name
5.What is a field?
Easy- Aone item of data in a record
- Ba loop
- Ca function
- Dan array
6.If names = ["Ali","Bo","Cy"], what is names[2]?
Easy- A"Cy"
- B"Bo"
- C"Ali"
- Derror
7.What is the length of [4, 7, 9, 2]?
Easy- A4
- B3
- C5
- D2
8.a is a zero-based array of three numbers. What does this inclusive loop do? total = 0; FOR i = 0 TO 2; total = total + a[i]; NEXT i
Easy- Aadds all three elements
- Bdeletes elements
- Csorts them
- Dfinds the largest
Unlock all 33 questions & more
Crea una cuenta gratis para ver todas las preguntas, las diapositivas, las tarjetas y los apuntes de repaso de este tema.
Exámenes anteriores
La práctica con exámenes anteriores de este tema llegará pronto.
Próximamente
