Of the many subfields within computer science, algorithms and data structures may be the most fundamental—it seems to characterize computer science like perhaps no other. What is involved in the study of algorithms and data structures? data structures and algorithms were mentioned together. Why? It’s very helpful to think of the data type as the bridge between data structures and algorithms. So these data types are the key to everything right? What are they, exactly? First of all, note that programs manipulate information, and information in a program is represented with entities. Entities are things like numbers, text, lists, and so on. To help us understand entities, it helps to classify them into types. We have an intuition about what types are. As a first approximation, a type is just a set of values, for example: That’s not really good enough, though! The reason why entities have certain types is that they behave in certain ways: you can multiply numbers, reverse lists, capitalize text, block users, revoke credentials, promote employees, and so on. Properly specifying a type requires defining how the entities of that type behave. These behaviors are captured (algebraically 😮😮😮) as operations with zero or more inputs and a single output. For example: The same thing can be said without pictures, for example: Ah, now we have behaviors. A data type is a set of values together with operations that define their behavior. Abstract Data Types A useful exercise is to identify things in your world and try to list as many behaviors as you can. Here is a starter set: A data structure is an arrangement of data for the purpose of being able to store and retrieve information. Usually a data structure exists in order to provide a physical representation of a data type. For example, a list (a data type, which we saw above) can be represented by an array (a data structure) or by attaching a link from each element to its successor (another kind of data structure). Wait, what are arrays and links? Data structures are built with three primary structuring mechanisms: Let’s dive in. A object, also known as an record, struct, or named tuple, is a single entity that has many properties, where each property has a name and a value, which is another entity. Here is a simple object, can you guess what it represents? An array is an entity that has a number of constituent elements, packed tightly together in memory and indexable by small natural numbers. In most programming languages, the first index is 0, in others (Julia, Lua, MATLAB), the first index is 1. Here are some cities in Alaska to visit (in order, because arrays are ordered): Important: Note that were the properties of a object come together to make one conceptual thing; arrays are generally thought of as a collection of distinct things.
Why Must They Go Together?
How Do They Go Together?

Data Types

CLUBS: Suit
TEN: Rank
HEARTS: Suit
JACK: Rank
DIAMONDS: Suit
QUEEN: Rank
SPADES: Suit
KING: Rank
ACE: Rank
makeCard : Suit × Rank → Card
TWO: Rank
getSuit : Card → Suit
THREE: Rank
getRank : Card → Rank
FOUR: Rank
newDeck : Deck
FIVE: Rank
positionOf : Deck × Card → int
SIX: Rank
cardAt : Deck × int → Card
SEVEN: Rank
topCard : Deck → Card
EIGHT: Rank
shuffle : Deck → Deck
NINE: Rank
split : Deck → Deck
Not every operation is applicable to every type. Types provide constraints on what we can and cannot say.
As an aside: you will sometimes hear the term abstract data type, abbreviated “ADT.” People use this term to emphasize the fact that the “internal structure and internal workings of the operations” are somehow unknown to the outside world. Only the effects of the operations matter. To many people, though, saying “data type” is enough—all datatypes are “abstract” in that sense.
Data Structures
Building Blocks


