Join Simon Allardice for an in-depth discussion in this video Jagged arrays, part of Foundations of Programming: Data Structures.
…The typical two-dimensional array is sometimes…referred to as a rectangular array.…Because it's a grid, a matrix, a table, always…to the same number of elements in every row.…And many languages have simplified syntax to create…a multi dimensional array that is a uniform size.…For example, five rows with six columns each,…allowing you to think about it that way.…And using the two numbers just to get to each element in this uniform grid.…But this isn't our only option.…Imagine that we're writing an application for some local tourist attraction.…
So we're going to have a two dimensional array, and array of…arrays, representing the number of tickets sold for every day in every month.…So, the first dimension, 0 through 11, will represent January through December.…And inside each of those we will have another array for each day in that month.…So we begin with January, which has 31 days.…We need 31 elements.…So it's 0 through 30.…Then February comes along.…But it only has 28, or sometimes 29 days.…So if we keep the array at a uniform size, we will have three unused elements.…
Starting with simple ways of grouping data like arrays and structs, together you'll explore gradually more complex data structures, like dictionaries, sets, hash tables, queues and stacks, links and linked lists, and trees and graphs. Simon keeps the lessons grounded in the real world and answers the "why" behind many data-structuring decisions: Why use a hash table? Why is a set useful? Why avoid arrays? When you're finished with the course, you'll have a clear understanding of data structures and understand how to use them in whatever language you're programming in, today or 5 years from now.
- What is a data structure?
- Using C-style structs and arrays
- Sorting and searching arrays
- Working with singly and doubly linked lists
- Using stacks for last-in, first-out (LIFO) structures
- Using queues for first-in, first-out (FIFO) structures
- Working with hash tables
- Understanding binary search trees (BSTs)
- Learning about graphs