• For Individuals
  • For Businesses
  • For Universities
  • For Governments
Coursera
Online Degrees
Careers
Log In
Join for Free
Coursera
Princeton University
Computer Science: Programming with a Purpose
  • About
  • Modules
  • Recommendations
  • Testimonials
  • Reviews
  1. Browse
  2. Computer Science
  3. Software Development

This Labor Day, enjoy $120 off Coursera Plus. Unlock access to 10,000+ programs. Save today.

Princeton University

Computer Science: Programming with a Purpose

Robert Sedgewick
Kevin Wayne

Instructors: Robert Sedgewick

Instructors

Instructor ratings

We asked all learners to give feedback on our instructors based on the quality of their teaching style.

4.7 (539 ratings)
Robert Sedgewick
Robert Sedgewick
Princeton University
7 Courses•1,980,005 learners
Kevin Wayne
Kevin Wayne
Princeton University
5 Courses•1,931,860 learners

470,062 already enrolled

10 modules
Gain insight into a topic and learn the fundamentals.
4.7

(1,301 reviews)

Beginner level
No prior experience required
Flexible schedule
2 months at 10 hours a week
Learn at your own pace
93%
Most learners liked this course

10 modules
Gain insight into a topic and learn the fundamentals.
4.7

(1,301 reviews)

Beginner level
No prior experience required
Flexible schedule
2 months at 10 hours a week
Learn at your own pace
93%
Most learners liked this course
  • About
  • Modules
  • Recommendations
  • Testimonials
  • Reviews

Skills you'll gain

  • Object Oriented Programming (OOP)
  • Java
  • Program Development
  • Algorithms
  • Programming Principles
  • Data Structures
  • Computer Programming
  • Computer Science
  • Performance Tuning
  • Computational Thinking
  • Java Programming
  • Animations
  • Debugging

Details to know

Assessments

10 assignments

Taught in English

See how employees at top companies are mastering in-demand skills

Learn more about Coursera for Business
 logos of Petrobras, TATA, Danone, Capgemini, P&G and L'Oreal

There are 10 modules in this course

The basis for education in the last millennium was “reading, writing, and arithmetic;” now it is reading, writing, and computing. Learning to program is an essential part of the education of every student, not just in the sciences and engineering, but in the arts, social sciences, and humanities, as well. Beyond direct applications, it is the first step in understanding the nature of computer science’s undeniable impact on the modern world. This course covers the first half of our book Computer Science: An Interdisciplinary Approach (the second half is covered in our Coursera course Computer Science: Algorithms, Theory, and Machines). Our intent is to teach programming to those who need or want to learn it, in a scientific context.

We begin by introducing basic programming elements such as variables, conditionals, loops, arrays, and I/O. Next, we turn to functions, introducing key concepts such as recursion, modular programming, and code reuse. Then, we present a modern introduction to object-oriented programming. We use the Java programming language and teach basic skills for computational problem solving that are applicable in many modern computing environments. Proficiency in Java is a goal, but we focus on fundamental concepts in programming, not Java per se. All the features of this course are available for free. People who are interested in digging deeper into the content may wish to obtain the textbook Computer Science: An Interdisciplinary Approach (upon which the course is based) or to visit the website introcs.cs.princeton.edu for a wealth of additional material. This course does not offer a certificate upon completion.

Why program? This lecture addresses that basic question. Then it describes the anatomy of your first program and the process of developing a program in Java using either virtual terminals or a program development environment, with some historical context. Most of the lecture is devoted to a thorough coverage of Java's built-in data types, with example programs for each.

What's included

4 videos2 readings1 assignment1 programming assignment

4 videos•Total 74 minutes
  • Why programming?•15 minutes
  • Program development•16 minutes
  • Built-in data types•32 minutes
  • Type conversion•10 minutes
2 readings•Total 20 minutes
  • Supplements for Lecture 1•10 minutes
  • Optional Enrichment on Basic Programming Concepts•10 minutes
1 assignment
  • Basic Programming Concepts•0 minutes
1 programming assignment•Total 480 minutes
  • Hello, World•480 minutes

The if, while, and for statements are Java's fundamental control structures. This lecture is built around short programs that use these constructs to address important computational tasks. Examples include sorting, computing the square root, factoring, and simulating a random process. The lecture concludes with a detailed example illustrating the process of debugging a program.

What's included

5 videos2 readings1 assignment1 programming assignment

5 videos•Total 56 minutes
  • Conditionals: the if statement•6 minutes
  • Loops: the while statement•11 minutes
  • An alternative: the for loop•6 minutes
  • Nesting•11 minutes
  • Debugging•20 minutes
2 readings•Total 20 minutes
  • Supplements for Lecture 2•10 minutes
  • Optional Enrichment on Conditionals and Loops•10 minutes
1 assignment
  • Conditionals and Loops•0 minutes
1 programming assignment•Total 480 minutes
  • Conditionals and Loops•480 minutes

Computing with a large sequence of values of the same type is extremely common. This lecture describes Java's built-in array data structure that supports such applications, with several examples, including shuffling a deck of cards, the coupon collector test for randomness, and random walks in a grid.

What's included

3 videos2 readings1 assignment1 programming assignment

3 videos•Total 56 minutes
  • Basic concepts•16 minutes
  • Typical array-processing code•23 minutes
  • Two-dimensional arrays•16 minutes
2 readings•Total 20 minutes
  • Supplements for Lecture 3•10 minutes
  • Optional Enrichment on Arrays•10 minutes
1 assignment
  • Arrays•0 minutes
1 programming assignment•Total 480 minutes
  • Arrays•480 minutes

To interact with our programs, we need mechanisms for taking information from the outside world and for presenting information to the outside world. This lecture describes several such mechanisms: for text, drawings, and animation. Detailed examples covered include fractal drawings that model natural phenomena and an animation of a ball bouncing around in the display window.

What's included

4 videos2 readings1 assignment1 programming assignment

4 videos•Total 48 minutes
  • Standard input and output•22 minutes
  • Standard drawing•9 minutes
  • Fractal drawings•10 minutes
  • Animation•6 minutes
2 readings•Total 20 minutes
  • Supplements for Lecture 4•10 minutes
  • Optional Enrichment on Input and Output•10 minutes
1 assignment
  • Input and Output•0 minutes
1 programming assignment•Total 480 minutes
  • Input and Output•480 minutes

Modular programming is the art and science of breaking a program into pieces that can be individually developed. This lecture introduces functions (Java methods), a fundamental mechanism that enables modular programming. Motivating examples include functions for the classic Gaussian distribution and an application that creates digital music.

What's included

4 videos2 readings1 assignment1 programming assignment

4 videos•Total 60 minutes
  • Basic concepts•15 minutes
  • Case study: Digital audio•17 minutes
  • Application: Gaussian distribution•12 minutes
  • Modular programming and libraries•14 minutes
2 readings•Total 20 minutes
  • Supplements for Lecture 5•10 minutes
  • Optional Enrichment on Functions and Libraries•10 minutes
1 assignment
  • Functions and Libraries•0 minutes
1 programming assignment•Total 480 minutes
  • Functions•480 minutes

A recursive function is one that calls itself. This lecture introduces the concept by treating in detail the ruler function and (related) classic examples, including the Towers of Hanoi puzzle, the H-tree, and simple models of the real world based on recursion. We show a common pitfall in the use of recursion, and a simple way to avoid it, which introduces a different (related) programming paradigm known as dynamic programming.

What's included

5 videos2 readings1 assignment1 programming assignment

5 videos•Total 58 minutes
  • Foundations•12 minutes
  • A classic example•11 minutes
  • Recursive graphics•11 minutes
  • Avoiding exponential waste•9 minutes
  • Dynamic programming•14 minutes
2 readings•Total 20 minutes
  • Supplements for Lecture 6•10 minutes
  • Optional Enrichment on Recursion•10 minutes
1 assignment
  • Recursion•0 minutes
1 programming assignment•Total 480 minutes
  • Recursion•480 minutes

When you develop a program, you need to be aware of its resource requirements. In this lecture, we describe a scientific approach to understanding performance, where we develop mathematical models describing the running time our programs and then run empirical tests to validate them. Eventually we come to a simple and effective approach that you can use to predict the running time of your own programs that involve significant amounts of computation.

What's included

5 videos2 readings1 assignment1 programming assignment

5 videos•Total 66 minutes
  • The challenge•16 minutes
  • Empirical analysis•11 minutes
  • Mathematical models•12 minutes
  • Doubling method•16 minutes
  • Familiar examples•9 minutes
2 readings•Total 20 minutes
  • Supplements for Lecture 7•10 minutes
  • Optional Enrichment on Performance•10 minutes
1 assignment
  • Performance•0 minutes
1 programming assignment•Total 480 minutes
  • Performance•480 minutes

In Java, you can create your own data types and use them in your programs. In this and the next lecture, we show how this ability allows us to view our programs as abstract representations of real-world concepts. First we show the mechanics of writing client programs that use data types. Our examples involve abstractions such as color, images, and genes. This style of programming is known as object-oriented programming because our programs manipulate objects, which hold data type values.

What's included

4 videos2 readings1 assignment1 programming assignment

4 videos•Total 53 minutes
  • Overview•7 minutes
  • Color•17 minutes
  • Image processing•12 minutes
  • String processing•15 minutes
2 readings•Total 20 minutes
  • Supplements for Lecture 8•10 minutes
  • Optional Enrichment on Abstract Data Types•10 minutes
1 assignment
  • Abstract Data Types•0 minutes
1 programming assignment•Total 180 minutes
  • Using Data Types•180 minutes

Creating your own data types is the central activity in modern Java programming. This lecture covers the mechanics (instance variables, constructors, instance methods, and test clients) and then develops several examples, culminating in a program that uses a quintessential mathematical abstraction (complex numbers) to create visual representations of the famous Mandelbrot set.

What's included

4 videos2 readings1 assignment1 programming assignment

4 videos•Total 58 minutes
  • Overview•5 minutes
  • Point charges•20 minutes
  • Turtle graphics•10 minutes
  • Complex numbers•22 minutes
2 readings•Total 20 minutes
  • Supplements for Lecture 9•10 minutes
  • Optional Enrichment on Creating Data Types•10 minutes
1 assignment
  • Creating Data Types•0 minutes
1 programming assignment•Total 480 minutes
  • Creating Data Types•480 minutes

We conclude the course with an overview of important issues surrounding programming languages. To convince you that your knowledge of Java will enable you to learn other programming languages, we show implementations of a typical program in C, C++, Python, and Matlab. We describe important differences among these languages and address fundamental issues, such as garbage collection, type checking, object oriented programming, and functional programming with some brief historical context.

What's included

5 videos1 reading1 assignment1 programming assignment

5 videos•Total 66 minutes
  • Popular languages•28 minutes
  • Java in context•8 minutes
  • Object-oriented programming•8 minutes
  • Type checking•8 minutes
  • Functional programming•12 minutes
1 reading•Total 10 minutes
  • Supplements for Lecture 10•10 minutes
1 assignment
  • Programming Languages•0 minutes
1 programming assignment•Total 480 minutes
  • Bar Chart Racer•480 minutes

Earn a career certificate

Add this credential to your LinkedIn profile, resume, or CV. Share it on social media and in your performance review.

Instructors

Instructor ratings

Instructor ratings

We asked all learners to give feedback on our instructors based on the quality of their teaching style.

4.7 (539 ratings)
Robert Sedgewick
Robert Sedgewick
Princeton University
7 Courses•1,980,005 learners
Kevin Wayne
Kevin Wayne
Princeton University
5 Courses•1,931,860 learners

Offered by

Princeton University

Offered by

Princeton University

Princeton University is a private research university located in Princeton, New Jersey, United States. It is one of the eight universities of the Ivy League, and one of the nine Colonial Colleges founded before the American Revolution.

Explore more from Software Development

  • Status: Free Trial
    Free Trial
    D

    Duke University

    Programming Fundamentals

    Course

  • Status: Free Trial
    Free Trial
    U

    University of London

    Introduction to Computer Programming

    Course

  • Status: Free
    Free
    P

    Princeton University

    Computer Science: Algorithms, Theory, and Machines

    Course

  • Status: Free Trial
    Free Trial
    U

    University of London

    Introduction to Computer Science and Programming

    Specialization

Why people choose Coursera for their career

Felipe M.
Learner since 2018
"To be able to take courses at my own pace and rhythm has been an amazing experience. I can learn whenever it fits my schedule and mood."
Jennifer J.
Learner since 2020
"I directly applied the concepts and skills I learned from my courses to an exciting new project at work."
Larry W.
Learner since 2021
"When I need courses on topics that my university doesn't offer, Coursera is one of the best places to go."
Chaitanya A.
"Learning isn't just about being better at your job: it's so much more than that. Coursera allows me to learn without limits."

Learner reviews

4.7

1,301 reviews

  • 5 stars

    83.17%

  • 4 stars

    11.29%

  • 3 stars

    2.15%

  • 2 stars

    1.07%

  • 1 star

    2.30%

Showing 3 of 1301

N
NK
5

Reviewed on Jun 15, 2021

Can't wait to get into the second part of the course. The best programming course ever provided for free of cost. The techniques used are backed by mathematical thinking. It is just awesome.

A
A
5

Reviewed on Apr 5, 2024

Computer Science: Programming with a Purpose" is highly recommended for those seeking a solid foundation in computer science and programming, regardless of their level of experience.

H
HT
5

Reviewed on Nov 25, 2021

This is my first course in Coursera. If you are beginner, you should watch videos, read the booksite and the book that covering this course. It simply needs a lot of hard work !

View more reviews
Coursera Plus

Open new doors with Coursera Plus

Unlimited access to 10,000+ world-class courses, hands-on projects, and job-ready certificate programs - all included in your subscription

Learn more

Advance your career with an online degree

Earn a degree from world-class universities - 100% online

Explore degrees

Join over 3,400 global companies that choose Coursera for Business

Upskill your employees to excel in the digital economy

Learn more

Frequently asked questions

Once you enroll, you’ll have access to all videos and programming assignments.

No. The lecture videos, exercises, and programming assignments are all available for free.

No. As per Princeton University policy, no certificates, credentials, or reports are awarded in connection with this course.

This course is aimed at first-year college students, high school students, and professionals in all fields who are interested in learning basic programming skills. It is a self-contained treatment intended for people with little or no previous experience in programming. It is also appropriate for people who know another programming language but want to learn Java.

At Princeton, over 50% of all undergraduates take the course, including students majoring in engineering, biology, physics, chemistry, economics, and many other fields, not just computer science.

Multiple-choice exercises, in-video quizzes, and programming assignments. The programming assignments are evaluated using a sophisticated autograder that provides detailed feedback about style, correctness, and (sometimes) efficiency.

We supply a streamlined version of IntelliJ that is easy to install and suitable for novices. However, you are free to use any programming environment that you like.

More questions

Visit the learner help center

Coursera Footer

Technical Skills

  • ChatGPT
  • Coding
  • Computer Science
  • Cybersecurity
  • DevOps
  • Ethical Hacking
  • Generative AI
  • Java Programming
  • Python
  • Web Development

Analytical Skills

  • Artificial Intelligence
  • Big Data
  • Business Analysis
  • Data Analytics
  • Data Science
  • Financial Modeling
  • Machine Learning
  • Microsoft Excel
  • Microsoft Power BI
  • SQL

Business Skills

  • Accounting
  • Digital Marketing
  • E-commerce
  • Finance
  • Google
  • Graphic Design
  • IBM
  • Marketing
  • Project Management
  • Social Media Marketing

Career Resources

  • Essential IT Certifications
  • High-Income Skills to Learn
  • How to Get a PMP Certification
  • How to Learn Artificial Intelligence
  • Popular Cybersecurity Certifications
  • Popular Data Analytics Certifications
  • What Does a Data Analyst Do?
  • Career Development Resources
  • Career Aptitude Test
  • Share your Coursera Learning Story

Coursera

  • About
  • What We Offer
  • Leadership
  • Careers
  • Catalog
  • Coursera Plus
  • Professional Certificates
  • MasterTrack® Certificates
  • Degrees
  • For Enterprise
  • For Government
  • For Campus
  • Become a Partner
  • Social Impact
  • Free Courses
  • ECTS Credit Recommendations

Community

  • Learners
  • Partners
  • Beta Testers
  • Blog
  • The Coursera Podcast
  • Tech Blog

More

  • Press
  • Investors
  • Terms
  • Privacy
  • Help
  • Accessibility
  • Contact
  • Articles
  • Directory
  • Affiliates
  • Modern Slavery Statement
  • Do Not Sell/Share
Learn Anywhere
Download on the App Store
Get it on Google Play
Logo of Certified B Corporation
© 2025 Coursera Inc. All rights reserved.
  • Coursera Facebook
  • Coursera Linkedin
  • Coursera Twitter
  • Coursera YouTube
  • Coursera Instagram
  • Coursera TikTok
Coursera

Sign up

Learn on your own time from top universities and businesses.

​
​
Between 8 and 72 characters
Your password is hidden
​

or

Already on Coursera?


Having trouble logging in? Learner help center

This site is protected by reCAPTCHA Enterprise and the Google Privacy Policy and Terms of Service apply.