Skip to main content

Questions tagged [arrays]

For questions regarding the data storage structure of an Array. This can range from their standard indexing to their usage in comparison to other data structures. Arrays are an ordered list of elements which are usually all of the same type. Nested arrays can contain arrays as elements.

Filter by
Sorted by
Tagged with
1 vote
1 answer
59 views

Is there an array-like data type in Java that can cope with generic types better than the built-in array?

TL;DR I'm looking for a replacement for the primitive array data type in Java that works better with generic data types. Background: I'm teaching A level CS in the UK (age 16-18) and we're using Java ...
Andrew Stacey's user avatar
18 votes
10 answers
4k views

How to respond to the two-handed approach to swapping

I was introducing lists to someone young (in Scratch). Creating a list is boring, so I opted to introduce something that you can do with lists, but requires some thinking: swapping. I introduced it by ...
cocomac's user avatar
  • 299
11 votes
4 answers
3k views

Array or vector? Two dimensional array or matrix?

I'm from Brazil and I'm involved with programming language teaching for, at least, ten years. I have a background in computer science and my colleagues tend to use the term ...
davidbuzatto's user avatar
6 votes
5 answers
931 views

What is a good teaching example/application for jagged arrays (2d arrays with irregular row lengths)?

We are teaching an AP CS class and the topic of 2d-arrays is coming up. There are plenty of cool and approachable sample applications for standard rectanglular arrays - matrix math, MIDI music, sudoku,...
Matthew W.'s user avatar
-1 votes
1 answer
185 views

Why does array index not start from -1 why have indexes to be positive? [closed]

Arrays start from 0 then 1,2... But why are indexes positive, why are indexes not negative?
Iram Shah's user avatar
  • 113
188 votes
31 answers
43k views

Why do we count starting from zero?

In computer science, we usually count starting from 0. Is there any effective way to explain why, to new programmers who ask why? I've read a bunch of different sources that list several reasons for ...
D.W.'s user avatar
  • 1,925
7 votes
6 answers
455 views

Single-dimensional array and simple looping activities of significance

I give a lab on single-dimensional loops and arrays. By "single dimensional loops", I mean that there is no nesting of loops. (I will later give a second lab on multi-dimensional loops and arrays, ...
Ben I.'s user avatar
  • 33.9k
45 votes
21 answers
5k views

Real life examples of 0-indexing

It can be perplexing for students to begin counting at 0 when they enter a CS class. I made it a point over and over to talk about "Day 0" and "Week 0" in the opening days and weeks just to build ...
Peter's user avatar
  • 9,102
12 votes
7 answers
770 views

Lesson Idea: Arrays, Pointers, and Syntactic Sugar

One of the most challenging concepts to instill in new CS students is 0-indexing (indeed, the pedagogy of this fact probably merits its own discussion). Another difficult topic -- although a slightly ...
Peter's user avatar
  • 9,102
1 vote
2 answers
211 views

What kind of game (in Scratch) would require use of a list? [closed]

I teach an introductory Scratch class to a group of elementary-school students. Most of the focus is on having fun creating simple games, but i still try to introduce a little higher-level programming ...
Scimonster's user avatar