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.

10 questions
Filter by
Sorted by
Tagged with
1 vote
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 ...
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 ...
• 299
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 ...
• 243
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,...
• 303
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?
• 113
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 ...
• 1,925
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, ...
• 33.9k
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 ...
• 9,102
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 ...
• 9,102
1 vote