Computer Science in Java

107 lessons

Click a lesson or an exercise to open it in a new tab.

Units 1, 2 — Fundamentals
Chapter 1 — Introduction to Computer Science
Demonstrating the importance of computer science through computational challenges across domains———
Understanding simple computational tasks: analyzing the task, formulating an algorithmic solution———
Understanding the concept of a programming language———
Understanding the concept of a program: reading, writing, running, testing, and fixing simple programsdownload
Class and main method as the basic framework for writing a programdownload
Understanding the concept of an objectdownload
Reading and understanding a simple class interface to create objects and call methods on themdownload
Creating objects using the new keyworddownload
Calling and executing methods on objectsdownload
Chapter 2 — Basic Programming Concepts
Algorithmdownload
Variable / Attributedownload
Class, attributes and methodsdownload
Basic data types: integer (int)download
Basic data types: decimal (double)download
Reading a decimal value from the user; constants (final)download
Value ranges of data typesdownload
Assignment statementsdownload
Defining and initializing variablesdownload
Arithmetic operators: addition, subtraction, multiplication, division, modulodownload
Basic math methods: abs, max, min, pow, round, sqrt, randomdownload
Arithmetic expressions: operator precedence and the role of parenthesesdownload
Basic type conversion between int and doubledownload
Methods as a tool for refining and dividing tasksdownload
Defining and writing a helper method (private method)download
Defining parameters, passing by value (call by value)download
Return valuedownload
Logic errors, syntax errors, runtime errorsdownload
Simple input/output operations and string concatenationdownload
Trace table———
Animate Line, keyboard Inputdownload
Chapter 3 — Conditional Execution
The boolean data typedownload
Relational operators: equal, not equal, greater, less, greater or equal, less or equaldownload
Pitfalls of using == and != with decimal valuesdownload
Boolean operators (and, or, not) and their truth tablesdownload
Simple and complex boolean expressions, and boolean operator precedencedownload
Conditional execution: ifdownload
Conditional execution: if .. elsedownload
Algorithms with conditional executiondownload
Nested conditionsdownload
Boolean methods: calling them on objects, writing them, and using the returned value in an ifdownload
Input validation, simple input filter using a conditiondownload
Chapter 4 — Repetitive Execution
Repetitive execution———
The for loopdownload
The while loopdownload
The equivalence of the for and while loopsdownload
Persistent input filterdownload
Typical computation tasks: counters, accumulators, extreme valuesdownload
Termination conditiondownload
Infinite executiondownload
Correctness analysis using a trace table———
Efficiency analysis by counting iterationsdownload
Nesting and combining if, for, while structuresdownload
Documentationdownload
Chapter 5 — Sequential Data Structures
Arrays of basic data typesdownload
Core concepts: index, length, element access (x[i])download
Defining and initializing arraysdownload
The memory model of an array: new, null and referencesdownload
Going out of the bounds of an arraydownload
Array processing methods: sum, count, average, max/min, property checkdownload
For-each loop (enhanced for)download
Sequential searchdownload
Binary searchdownload
Insertion sortdownload
Merge (with and without duplicates)download
Discussion and comparison of algorithm efficiencydownload
Array of objectsdownload
Building an array of objects (using new)download
Two-dimensional array: diagonals and transpositiondownload
Two-dimensional array: scanning by rows and by columnsdownload
Two-dimensional array: scanning in a spiral; flippingdownload
Accessing an object's attribute in a two-dimensional arraydownload
Chapter 6 — Object-Oriented Programming
Review: creating and operating objects using a given class interfacedownload
Core concepts: class as a template for creating and operating objects; use vs. implementationdownload
Core concepts: attributes, constructors, methods (queries / commands)download
Object state, valid statedownload
Encapsulation: importance of the principle and how it is implemented via access modifiers and appropriate methodsdownload
Immutable objectsdownload
Trace table of objectsdownload
Pre-condition / post-conditiondownload
Classes that use other classesdownload
Implementing a class in a programming language according to a given interfacedownload
Documenting interfacesdownload
Writing test programsdownload
Inheritance In APIdownload
2D Animationdownload
Unit 4 — Data Structures
Chapter 1 — Recursion
Recursive definition, stop condition, recursive calldownload
Tracing a recursive process at the level of f(n) and f(n-1)download
Recursive operations on numbers; operations that return a value and operations that do notdownload
Types of recursion: tail recursion, going-and-returning recursiondownload
From an iterative solution to a recursive onedownload
Double recursion, mutual recursiondownload
Recursive operations on one-dimensional and two-dimensional arraysdownload
The role of the parameters: parameters that change between calls and parameters that do notdownload
The importance of the stop conditiondownload
Advantages of recursion (a simple solution, a proof of correctness) and its disadvantages (memory and time)download
Chapter 2 — Introduction to Efficiency
A review of arrays and algorithms from the fundamentals: sequential search, binary search, insertion sortdownload
Input size, basic step, operations that depend on the input size and operations that do notdownload
Run time: the worst case, the best case, the average casedownload
Efficiency as a function of the input size; order of growth (big O): constant, logarithmic, linear, quadratic, exponentialdownload
Improving the order of growth, and improving by a constantdownload
Merge sort, and its analysisdownload
Chapter 3 — Stack
Using the library of the unit: compiling it, and running a lesson with itdownload
Abstract data typedownload
Stack, LIFOdownload
Class interface: constructors, operations that return a value, update operationsdownload
Solving problems with the StackInt interface: size, sum and copydownload
Solving problems with the StackInt interface: the bottom of a stack, reversingdownload
Genericitydownload
Solving problems with the Stack<T> interface: balanced brackets, undodownload
Solving problems with the Stack<T> interface: splitting by a range, recursion on a stackdownload
Chapter 4 — Queue
Queue, FIFO, common usesdownload
The Queue<T> interface, and working with itdownload
Problems with a FIFO pattern, and writing code that solves them: size, copy, splitting by a rangedownload
Problems with a FIFO pattern, and writing code that solves them: merging sorted queues, recursion on a queuedownload
Choosing the model for solving a problem: a queue or a stack?download
Chapter 5 — Linked List
Pointer, reference; static and dynamic memory allocationdownload
Node and list; the class Node<T>download
Building and processing lists: going over a list, insertion, deletion, search by value or by positiondownload
Recursive algorithms on lists; their efficiency; a list compared with an arraydownload
The class BinNode<T>: a list of binary nodesdownload
The implementation of Node and BinNodedownload
Encapsulation and exposuredownload
Chapter 6 — Implementing Data Structures
Implementing abstract data types: one abstraction, several implementationsdownload
Implementing a stack with an arraydownload
Implementing a stack with a listdownload
The efficiency of the implementationsdownload
Implementing a queue with a listdownload
Implementing compound data structures: an array of lists, an array of queuesdownload
Implementing an abstract data type with a compound structure: a line by urgency, as an array of queuesdownload
Chapter 7 — Binary Trees
The structure of trees, and their termsdownload
The binary node as the building block of binary treesdownload
The interface of BinNode, and building trees with itdownload
Traversing trees: pre-order, in-order, post-orderdownload
Recursive implementation of algorithms on trees, and their efficiencydownload
Depth-first and breadth-first traversaldownload
Representing an arithmetic expression in a binary treedownload
Binary search tree: insertiondownload
Binary search tree: search, and the efficiency of search and insertiondownload
Algorithms on binary search trees: insertion with a loop, the path of a search, tree sortdownload