Professor Ghyam

Professor Ghyam

Recursion

Slide Duration:

Table of Contents

Section 1: Introduction to Programming
Introduction to Java

32m 57s

Intro
0:00
Process of Programming
0:07
Computer Systems
0:38
Object Oriented Programming
3:57
Procedural Programming
7:05
Key Benefits of java
9:56
Using Java
13:44
Defining and Running Java Programs
15:53
Simple Application
19:12
Compiling
21:34
Executing Applications on the Command Line
23:10
Creating, Compiling, and Running a Program
24:25
Applets
25:25
Java File Structure
29:39
Section 2: Java Syntax from the Ground Up
Java Syntax

34m 57s

Intro
0:00
Primitive Data Types
0:13
Numeric Data Types
4:00
Character Data Type
5:14
Boolean Data Type
8:20
Unicode Formats
10:25
Comments
15:26
Reserved Words
18:17
Identifiers
23:17
Declaring and Initializing Variables
25:28
Constants
33:31
Operators

51m 20s

Intro
0:00
Operators
0:32
Assignment Statements
7:14
Unary Operators
11:05
Arithmetic Operators
14:12
More Operators
24:10
Mixed/Similar Mode of Operation
29:29
Type Conversion (Cast)
31:54
Relational Operators
35:30
Boolean Operators
37:37
Operator Precedence
43:30
Examples
44:29
Statements

49m 20s

Intro
0:00
Java Statements
0:27
Statements and Expressions
4:25
Arithmetic Expressions
9:58
Operator Precedence
10:52
Storing Data to Primitive Data Types
18:38
Input Output
20:49
Reading Numeric Values
37:44
Complete Simple Program
42:41
Control Statements

55m 36s

Intro
0:00
Control Statements
0:10
One Way Selection
17:53
Examples
24:11
If Else Statement
27:21
Nested If
32:00
Multi-Alternative
37:33
Switch Statement
44:33
Loop Statements

41m 32s

Intro
0:00
While Loop
0:11
Counter Controlled While Loops
10:36
Sentinel Controlled While Loops
15:35
For Loop
20:31
Do While Loop
31:22
Nested Loop
35:34
Recursion

33m 17s

Intro
0:00
Recursion
0:10
Factorials
4:28
Java Methods
7:24
Method Declarations
11:39
Method Example
13:14
Factorial Problem
19:47
Complete Example
22:35
Arithmetic Series Example
30:10
Section 3: Object-Oriented Programming in Java
Classes and Objects

40m 5s

Intro
0:00
Object Oriented Programming
0:23
Encapsulation
2:31
Computer Memory
3:28
Objects
6:41
Unified Modeling Language (UML)
9:18
Visibility
11:32
Example
14:26
Classes and Objects
18:34
Using Objects

38m 27s

Intro
0:00
Employee Objects
0:25
Assignment
16:43
Types
21:50
Constructor
29:13
Methods

38m 27s

Intro
0:00
Structure
0:32
Formal and Actual Parameters
5:46
Local Variables
12:24
Helper Methods
15:02
Scope and Lifetime of Variables
18:44
Block Scope
26:50
Example: Methods
32:19
Example: Parameter Passing
38:05
Static Variables/Classes/Methods
48:27
Inner Classes

18m 26s

Intro
0:00
Overview of Inner Classes
0:44
Examples
7:11
Compositions

29m 51s

Intro
0:00
Using Compositions
0:38
Example: Date
2:55
Example: Person
11:42
Inheritance

39m 39s

Intro
0:00
Terminology
2:13
Example: Employee
5:27
Class Header
33:56
Variables
34:39
Interface

21m 57s

Intro
0:00
Java Interfaces
1:35
Classes vs Interfaces
3:45
Example: Interface
6:29
Summary
20:04
Platform

57m 30s

Intro
0:00
System and User
0:09
String Class
1:24
Examples: Strings
10:21
Math Class
17:23
Numeric Class
24:52
Class Date
31:07
I/O Streams
35:23
Scanner Class
44:28
Vector Class
48:24
Swing Class
53:56
Arrays

29m 45s

Intro
0:00
Java Syntax
0:27
Declaring an Array
2:18
Accessing Array Components
4:57
Example: Array Sort
18:17
Two Dimensional Array
23:33
Packages

32m 13s

Intro
0:00
Destroying and Finalizing Objects
0:16
Creating and Using Packages
5:44
Naming Conventions
17:40
Documentation Comments
23:04
Section 4: Analysis of Programs
Program Analysis, Part I

34m 18s

Intro
0:00
Correctness
0:52
Debugging
11:18
Error Handling
16:51
Exceptions
22:48
Fixing Exceptions
28:58
Program Analysis, Part II

44m 30s

Intro
0:00
Program Complexity and Efficiency
0:18
Big-O Notation
8:59
Common Big-O Values
27:38
Complexity
41:57
Section 5: Additional Data Structures
Linked List

52m 51s

Intro
0:00
Java Syntax
0:09
Types of Lists
2:39
Objects
8:56
Adding to a Linked List
14:54
Traversing a Linked List
21:00
Deleting from a Linked List
23:44
Example: Class Node
29:13
Tracing
34:55
Review
36:20
Stacks

22m 9s

Intro
0:00
What is a Stack?
0:29
Creating a Stack
5:27
Stack Operations
8:20
Examples
14:21
Queue

24m 19s

Intro
0:00
What is a Queue?
0:13
Creating a Queue
3:55
Queue Operations
7:42
Java Queue
13:57
Examples
16:05
Trees

43m 52s

Intro
0:00
Binary Tree
0:49
Binary Search Tree
3:01
Binary Search Tree Operations
13:14
Binary Search Tree Examples
28:25
Priority Queue and Heap

19m 58s

Intro
0:00
Priority Queue
0:31
Priority Queue Interface
6:05
Priority Queue Examples
8:17
Heap
10:13
Heap Examples
13:36
Maps and Sets

19m 54s

Intro
0:00
What is a Map?
0:26
Map Interface
2:18
Map Example
5:16
What is a Set?
10:13
Set Interface
12:09
Set Example
14:21
Section 6: Algorithms
List Operations

26m 27s

Intro
0:00
Container Traversal
0:27
Explicit Traversal Operations
4:03
Cursor Traversals
6:53
Enumerations
12:43
Iterators
17:52
Searching

48m 26s

Intro
0:00
Sequential Search
0:23
Binary Search
12:46
Search Using Hashing
31:25
Sorting, Part I

20m 23s

Intro
0:00
Bubble Sort
1:16
Insertion Sort
10:22
Sorting, Part II

20m 23s

Intro
0:00
Quicksort
0:12
Mergesort
15:00
Heap Sort
28:15
Loading...
This is a quick preview of the lesson. For full access, please Log In or Sign up.
For more information, please see full course syllabus of Java
Bookmark & Share Embed

Share this knowledge with your friends!

Copy & Paste this embed code into your website’s HTML

Please ensure that your website editor is in text mode when you paste the code.
(In Wordpress, the mode button is on the top right corner.)
  ×
  • - Allow users to view the embedded video in full-size.
Since this lesson is not free, only the preview will appear on your website.
  • Discussion

  • Study Guides

  • Table of Contents

Lecture Comments (3)

0 answers

Post by Jorge Guerrero on April 5, 2012

Dr. Ghyam. At 15.32, the code as presented does not work at all. It has inconsistencies in variable types and the way you are declaring the method calcSalary. Here's how I got the code to work:


public class Recurse //it is common to capitalize the name of the class
{
//Create BufferedREader object from Standard input device (keyboard).
public static void main (String args[])
{
//Declare variables
float grossSalary;
grossSalary = calcSalary(45.00f,12.90f);
System.out.println("Gross salary: " + grossSalary);
} //end method main
public static float calcSalary(float hours, float payRate) {
float overTime=0.0f,salary=0.0f;
if(hours>40)
overTime=(hours-40)*payRate*1.5f;
salary=overTime+40*payRate;
return salary;} //end method
} // end program

I believe, you are knowledgeable, but the fact that you're not running the examples either in the command prompt or in an IDE leads to many errors. This is the first I struggled with, as we have not seen static vs non-static methods.

Same deal for the factorial problem. Add the word "static" without the double quotation marks after the word public in the factorial method.

For the Complete Example at 27:03 you need to place static in front of void this time.

Here's the Arithmetic code, folks:
//First bring in HELP by all the imports. Import means include or bring in and declare the packages you need
import java.io.*;

public class Arithmetic //it is common to capitalize the name of the class
{
//Create BufferedREader object from Standard input device (keyboard).
static BufferedReader KB=new BufferedReader(new InputStreamReader(System.in));
public static void main (String args[]) throws IOException //has to have one class as main, it tells java where to start executing the code.
{
//Declare variables
long sum;
sum=sigma(5);
System.out.println("Sum of terms = " + sum);
} //end method main
public static long sigma(int n) {
if(n<=1)
return n;
else
return(n+sigma(n-1));}
} // end program

0 answers

Post by Demaro Jones on December 1, 2011

Dear Professor,
In the Recursion Example...shouldn't the method "void printRecursive(int num)" be static in order for it to be referenced in the main method?
Thanks

0 answers

Post by William Lee on July 18, 2010

yea... there is a problem with the video...

Recursion

  • Recursion: Is a method of repeating a task without using a looping statement, which is accomplished with a call to the function itself with a value different than the one used before.

  • Advantages: Short , Simple to implement, Elegant solutions using divide & conquer algorithms

  • Disadvantages: Recursion requires more memory, More processor power, More Time, Sometimes more complex algorithms are required

  • Recursive functions: Require 2 steps; base case and recursive step.

  • Example: To implement N! in Java using recursion:

  •  public int factorial(int n) {    if (n == 0)    return 1; else    return n * factorial(n - 1);    //tail recursion }
  • Intro 0:00
  • Recursion 0:10
  • Factorials 4:28
  • Java Methods 7:24
  • Method Declarations 11:39
  • Method Example 13:14
  • Factorial Problem 19:47
  • Complete Example 22:35
  • Arithmetic Series Example 30:10
Educator®

Please sign in to participate in this lecture discussion.

Resetting Your Password?
OR

Start Learning Now

Our free lessons will get you started (Adobe Flash® required).
Get immediate access to our entire library.

Membership Overview

  • Available 24/7. Unlimited Access to Our Entire Library.
  • Search and jump to exactly what you want to learn.
  • *Ask questions and get answers from the community and our teachers!
  • Practice questions with step-by-step solutions.
  • Download lecture slides for taking notes.
  • Track your course viewing progress.
  • Accessible anytime, anywhere with our Android and iOS apps.