We use cookies to distinguish you from other users and to provide you with a better experience on our websites. Close this message to accept cookies or find out how to manage your cookie settings.
To save content items to your account,
please confirm that you agree to abide by our usage policies.
If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account.
Find out more about saving content to .
To save content items to your Kindle, first ensure [email protected]
is added to your Approved Personal Document E-mail List under your Personal Document Settings
on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part
of your Kindle email address below.
Find out more about saving to your Kindle.
Note you can select to save to either the @free.kindle.com or @kindle.com variations.
‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi.
‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.
Learn with confidence with this hands-on undergraduate textbook for CS2 courses. Active-learning and real-world projects underpin each chapter, briefly reviewing programming fundamentals then progressing to core data structures and algorithms topics including recursion, lists, stacks, trees, graphs, sorting, and complexity analysis. Creative projects and applications put theoretical concepts into practice, helping students master the fundamentals. Dedicated project chapters supply further programming practice using real-world, interdisciplinary problems which students can showcase in their own online portfolios. Example Interview Questions sections prepare students for job applications. The pedagogy supports self-directed and skills-based learning with over 250 'Try It Yourself' boxes, many with solutions provided, and over 500 progressively challenging end-of-chapter questions. Written in a clear and engaging style, this textbook is a complete resource for teaching the fundamental skills that today's students need. Instructor resources are available online, including a test bank, solutions manual, and sample code.
This ground-breaking collection explores the ways in which digital information technologies form and influence human perception and experience. Defying technological determinism, it takes on board discursive perspectives from humanities, bringing digital media, affect and body studies into conversation with one another.
Emerging technologies eventually disappear into the atmosphere of everyday life - they become ordinary and enmeshed in ignored infrastructures and patterns of behaviour. This is how Mundania takes form. Based on original research, this book uses the concept of mundania to better understand our relationship with technology.
Java is one of the world’s most popular programming languages. Widely used in enterprise software development, Java’s strengths lie in its combination of performance and portability, as well as its large, robust library of built-in features, which allow developers to create complex applications entirely within the language. Java was developed in the early 1990s by a team from Sun Microsystems led by James Gosling. Initially called Oak (after a tree outside Gosling’s office), the new language was intended to be a development environment for interactive TV, but pivoted to the emerging World Wide Web after its public release in 1995. Since then, Java has expanded into almost every area of software development. It is the default programming language for Android mobile devices, the Hadoop large-scale data processing system, and Minecraft. Java is one of the most well-known object-oriented programming languages.
This chapter surveys the core elements of Java programming, assuming some familiarity with programming in any language. If you already have Java experience, it will be a refresher on important points. If your experience is with Python, JavaScript, or other languages, this chapter will help you understand how Java does things differently.
After the linear data structures and hash tables, we’re now ready to introduce the third major kind of structure: trees, which represent hierarchical data. Computer science, like nature, delights in trees: There are a huge number of tree-based structures customized for different problems. In particular, trees are used to construct map data structures that provide useful alternatives to hash tables.
A heap is a tree-based data structure that’s designed to quickly return the maximum or minimum of its items. Like a search tree, it maintains a special ordering among its nodes, and takes advantage of the hierarchical nature of binary trees to perform its operations in O(log n) time. Heaps are the primary implementation of the priority queue abstract data type. Like the first-in-first-out queues we studied in Chapter 13, a priority queue supports operations to insert and remove elements, but also maintains an ordering among its items. Polling the queue returns the next item according to the underlying ordering, rather than strictly returning items in FIFO order. Priority queues are used in applications that need to continually fetch the “next” item of a dynamic set that may change over time. A common application is ordering events by time in a simulation program.
Seymour Papert published Mindstorms in 1980. Subtitled Children, Computers, and Powerful Ideas, the book advocated for making computational thinking a core part of the curriculum for young children (Papert, 1980). Mindstorms was influential in computer education circles, and the approaches it described were the first exposure to programming and computer science for many children. LEGO later adopted the name for a line of programmable building sets.
The previous two chapters introduced hash functions and hash tables. In this chapter, we’ll combine hash tables with lists to construct a search engine index. Our index will map a search word to the list of locations where that word occurs in a set of text documents. The data for our example search engine will come from the plays of William Shakespeare, the most influential English-language dramatist in history. We’ll work primarily with the text of Macbeth. The play provides a good development example because the text is rich enough to be interesting, but the structured script format makes it easy to extract everything we need with a reasonable amount of code.
The stack is the Incredible Hulk of data structures: superficially dumb, but so strong that it doesn’t matter. Stacks have only a few basic operations and they’re easy to implement, but they unlock a number of algorithms that are both theoretically powerful and practically important. You may recall that we previously discussed the role of the stack in recursion, and there’s a connection between the stack as an explicit data structure and recursive methods that use a stack implicitly.
Up to this point we’ve focused on introducing the Java language and – starting with the previous chapter – the technique of algorithm analysis. We’re now ready to put that machinery to work by describing our first important new data structure: lists. A list is like an array, in that it represents an ordered sequence of data values, but lists are more flexible: They support operations for dynamically inserting and removing data as the program executes. We’ve already used Java’s built-in ArrayList class to manage a collection of values; now we’re ready to talk about how it’s implemented internally.
The last chapter ended on a down note, when we realized that the standard binary search tree can’t guarantee O(log n) performance if it isn’t balanced. This chapter introduces self-balancing search trees. All three of the trees we’ll examine – 2-3-4 trees, B-trees, and red–black trees – implement search tree operations, but perform extra work to ensure that the tree stays balanced.
Arrays are Java’s fundamental low-level data structure, used to manage fixed-size collections of items. Chapter 2 introduced ArrayList, which implemented a resizable sequential collection of data items, similar to Python’s lists. Arrays are lower-level, but they’re often the best choice for representing fixed-size collections of items, such as matrices. Arrays are also the basic building block of many higher-level data structures. Therefore, understanding how to create and manipulate basic arrays is an essential skill.
Recursion is a fundamental concept in computer science. A recursive algorithm is one that defines a solution to a problem in terms of itself. That is, recursive techniques solve large problems by building up solutions of smaller instances of the same problem. This turns out to be a powerful technique, because many advanced algorithmic problems and data structures are fundamentally self-similar.
Pinterest is a social media platform that allows users to assemble images or other media into customized lists, then share those lists with others. Pinterest calls these lists “pinboards” and the items added to each board “pins,” analogous to real-world physical bulletin boards. Like other social media systems, Pinterest wants to recommend new content to its users to keep them engaged with the service. In 2018, Pinterest introduced a system called Pixie as a component of their overall recommendation infrastructure (Eksombatchai et al., 2018). It uses a graph model to represent the connections among items, then explores that graph in a randomized way to generate recommendations. In this chapter, we’ll build our own system based on the graph algorithms used by Pixie.
We live in a networked world. Professional networks, social networks, neural networks – we’re all familiar with the idea that connections matter. This chapter introduces graphs, our last major topic. Graphs are the primary tool for modeling connections or relationships among a set of items; binary trees, for example, are a special type of graph. Graph models illustrate the power of abstraction: They capture the underlying structure of a network, independent of what the elements actually represent. Therefore, graph algorithms are flexible – they’re not tied to one particular application or problem domain.
So far, we’ve considered four data structures: arrays, lists, stacks, and queues. All four could be described as linear, in that they maintain their items as ordered sequences: arrays and lists are indexed by position, stacks are LIFO, and queues are FIFO. In this chapter, we’ll consider the new problem of building a lookup structure, like a table, that can take an input called the key and return its associated value. For example, we might fetch a record of information about a museum artifact given its ID number as the key. None of our previous data structures are a good fit for this problem.