Join Simon Allardice for an in-depth discussion in this video Using built-in search behavior, part of Foundations of Programming: Data Structures.
- View Offline
…It's true that as with most of the languages beginning…with fixed signs arrays and then offering resizable behavior, or adding…sort functionality, we will often find that functionality is provided that…lets us to search through an array for a particular value.…Now sometimes you just want to know, does a value exist?…Yes or no.…True or false.…And sometimes you want to know, does that value…exist, and if so where is it in the array?…Now across languages, the most common term for the first piece of…functionality, where we want just a yes or no result is contains.…
Being able to write something along…the lines of this, myArray.contains some value.…And just returning a Boolean.…But it is more typical that we don't just want to know if a…value exists in the array, we want to know what position it's at, what index.…And the most common term for this method or function is indexOf.…Now once again I'm writing non-specific code here.…This behavior might be part of the array…object itself, so you could write something like myArray.indexOf.…
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