0% found this document useful (0 votes)
12 views

CourseOverview - Java

KAIST Data Structure ppt

Uploaded by

[HA] Nights
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

CourseOverview - Java

KAIST Data Structure ppt

Uploaded by

[HA] Nights
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 49

CS 206

First day of Class


Today’s topics
• Course overview

• Java in this course

• Your first program in Java

• [Built-in data types]

2
Course Topics
What is this course about?

• Building blocks of Java


• OOP & Data Abstraction
• Arrays, Linked Lists
• Analysis of Algorithms
• Recursion
• Stacks, Queues
• Lists, Iterators
• Trees
• PQs, Heaps
• Hash tables
• BSTs
• Sorting algorithms 3
Why Study Data Structures?
To become a proficient programmer.

“ I will, in fact, claim that the difference between a bad programmer and
a good one is whether he considers his code or his data structures
more important. Bad programmers worry about the code. Good
programmers worry about data structures and their relationships. ”
— Linus Torvalds (creator of Linux)

“ Algorithms + Data Structures = Programs. ” — Niklaus Wirth

4
About Me
Professor Eunyoung Moon (Prof. Moon)
Ph.D., University of Texas at Austin

Email: [email protected]
Office hour: Mon & Wed 4:00 pm – 5:30 pm (@ E11 #304)

5
Course Materials
Textbooks
• Goodrich, M. T., Tamassia, R., & Goldwasser, M.
H. (2014). Data structures and algorithms in
Java. John Wiley & Sons.

• Sedgewick, R., & Wayne, K. (2011). Algorithms,


4th Edition, Addison-Wesley Professional.
https://algs4.cs.princeton.edu/home/

e-book or paperback @ Publisher website | Amazon

• https://introcs.cs.princeton.edu/java/home/

Learning Platforms
• kaist.elice.io (Check my email regarding how to get in)
• KLMS will record your grades & attendance at exercise 6
sessions.
Grading
Each component weight in final grade

Attendance 100 points


In-class exercises 350 points
2 Quizzes (by hand) 100 points
Homework programming assignments 250 points
Final exam (by hand) 200 points
Total 1000 points

7
Course Organization
One chapter per week:
• Check the weekly schedule on KLMS!

1. Lecture sessions (once per week)


• A blend of lecture, check point questions, and interactive
activities.

2. In-class exercise sessions (once per week)


• 10 exercises (worth 350 points)

• Exercises aim to help you keep up with the weekly topics.


• Exercises aim to help you check basic understandings, as well as
develop further understandings of course materials
• Format: short answers, brief descriptions, and filling in the code.

• How is each exercise session organized?—see the next slide! 8


In-class exercise sessions
1) You will sit in your group area.

2) Your TA will take attendance, matching your student ID card.

3) You will work on the exercises individually. Discussion with


classmates is allowed; however, you MUST make your own
submission.

4) You must submit your complete answers to KLMS.

5) Your TA will grade & record your scores on KLMS.

6) If you have questions about grading, contact your TA.


**If you can’t bring your laptop to the exercise sessions, it is imperative that you 10
should let your TA know in advance (no later than the day before the exercise
session). We will provide you a hard copy.
CS 206 C : Group formation
• We will have a total of 8 groups.
• Each group can have up to 23 students.
• You will sit in your group area for every in-class exercise
session, quizzes, and a final exam.

Due: Monday, September 9th, 2019 11:55pm


• Please sign up the group which you want to belong to.
• If you do not sign up by yourself, you will be randomly assigned
to one of the groups.
• If you sign up the group that has more than 23 students, you
will be randomly assigned to another group with less students.
• Link will become available tomorrow (check KLMS>1st week).

12
Attendance
Your TA will take attendance at exercise sessions & quizzes.

Tardiness
• Two tardies will be counted as one absence.

Illness and medical appointments


• Effort should be made to arrange medical appointments outside
class hours.

• In the case when you should miss the exercise session for medical
reasons or emergency, you must let me & your TA know.
• You must submit the proof of document such as a medical note by
your doctor. In that case, you can make up.

13
Two quizzes
• 50 points @ each
Scope Date
Quiz 1 Chapter 7 October 28th, 2019 class time
Quiz 2 Chapter 9 November 11th, 2019 class time

• Closed-book, Closed-discussion, Closed-internet


• Open-note: You can bring an A4-size note (one sheet, front &
back) and have your note during the quiz.
• No programmable & communication devices are allowed.

• Traditional sit-down/limited-time quiz


• You will take the exam by hand.
• Question types:
• Multiple-choices, TRUE/FALSE, short answer, and short text.
14
Mark your calendar!
Homework assignments
There will be four homework programming assignments.
• Submission platform: elice
• I will announce when each homework becomes available.

Possible points Due


HW 1 50 Sunday, September 22nd, 2019 11:55 pm
HW 2 60 Sunday, October 6th, 2019 11:55 pm
HW 3 75 Sunday, October 27th, 2019 11:55 pm
HW 4 65 Wednesday, December 11th, 2019 11:55 pm
Total 250

15
Final exam
200 points

• Cumulative (cover everything we will have studied during this


semester)
• Closed-book, Closed-note, Closed-discussion, Closed-internet
• No programmable & communication devices are allowed.

• Traditional sit-down/limited-time exam


• You will take the exam by hand.
• Question types:
• Multiple-choices, TRUE/FALSE, multiple-choice, short answer, short text.

Find more information on KLMS>16th week.


Mark your calendar! 16
Course Policy (1)
Late submission

• Any submission received after the deadline will be


docked 20% per 24-hour period.
• If your submission is five days late, you will get a zero.
• If your submission is late 1 second, 20% will be deducted.

• No excuses for computer malfunctions.


• No excuses for accidental mistakes.

17
Check point
Let’s say your submission is 1 second late;
what percentage will be deducted because of late submission?

A. 20%
B. 40%
C. 60%
D. 80%
E. 100%

Plan ahead.
Make a plan to submit early.
18
Check point
Let’s say your submission is two days late;
what percentage will be deducted because of late submission?

A. 20%
B. 40%
C. 60%
D. 80%
E. 100%

Plan ahead.
Make a plan to submit early.
19
Course Policy (2)
Penalties for submission mistakes.

• If you realize that you made a submission mistake, you can


request a regrade with a penalty of 20% per 24-hour period.

• Example:
• “I accidentally submitted an empty file.”

• “I accidentally submitted an incorrect version of a file.”

While working on the exercises, regularly save your answers in multiple places—
in your USB, Dropbox, Google drive, and send it to your email etc.

20
Course Policy (2)
Penalties for submission mistakes.

• Please follow the instructions.


• e.g., Please give your answers in English for in-class exercises,
quizzes, and a final exam.

• If your submission does not follow instructions, 20% will be


deducted.

21
Course Policy (3)
Academic Integrity
• Both the student who copied work from another student and
the student who gave material to be copied will both
automatically receive a zero on the assignment.

• You MUST make your own version of work for all individual
submissions.

• For the programming assignments on elice, code plagiarism


detector will be run.
• Do not copy and refactor the code from former students
who took this course.
• Do not copy and refactor the code from the students who
are currently taking this course.
22
Check point
Your classmate asks you to share the code you have
written for the individual homework submission.

What should you do?


A. Sure thing! Here is my code. Go ahead and submit my code
as your submission.

B. Hey, you can copy part of my code and change variable


names. Here it is!!

C. I can’t share my code with you. We can discuss the


homework, based on what we have done so far. I can also
direct you to which part you should study.
23
Regrading policy
To request a regrade, write a brief note that indicates the
perceived mistake by the grader; send it to the grader.

• Regrading requests can be made within two weeks of


when the score was posted on KLMS.

24
Constructive contribution to class
• Be on time.
• Do not come in and out of the classroom during the lecture as
it interrupts your classmates & the professor who is giving a
lecture.

• Please do not use your mobile phone in the classroom.


✓ Turn off your ringers.
✓ Do not text.

• In case you should use your laptop during the lecture session,
please do NOT:
✓ Surf the Internet.
✓ Check Instagram, Facebook, Twitter, and other social media.
✓ Check email.
✓ Work on assignments of other courses. 25 25
When you email me
Please title your email with the course number & course
section:

Which one would you use?

A. [ CS 206 ]
B. [ CS 206 A ]
C. [ CS 206 B ]
D. [ CS 206 C ]
E. None of the above.

26
Final grades
Will be based on relative grading;
Letter grade cutoff
A+ cutoff Average + 1.5* stdev
A0 cutoff Average + 1.0* stdev
A- cutoff Average + 0.5* stdev
B+ cutoff Average
B0 cutoff Average – 0.5*stdev
B- cutoff Average – 1.0*stdev
C+ cutoff Average – 1.5*stdev
C0 cutoff Average – 2.0*stdev
C- cutoff Average – 2.5*stdev
27
Questions?

28
Course overview quiz
Take a course overview quiz!

• KLMS>1st week>Course overview quiz


• Will be available from Monday September 2nd 2019, 16:00
• Due: Monday September 9th 2019, 11:55 pm

• You have 3 minutes to answer 5 questions.


• Open-book; Open-discussion

• This quiz is not included in your final grade.

Why are we doing this?


• The quiz will also help you double check course policies.
• In-class exercises will use the same feature; thus, this quiz
29
will help you familiarize yourself with how to submit your
answers to KLMS.
Java in this course
You need to know how to program
in order to be able to tell a computer what you want it to do.

Naive ideal: Natural language instructions.


“Please simulate the motion of N heavenly bodies,
subject to Newton’s laws of motion and gravity.”

Prepackaged solutions (apps) are great when what they do is what you want.

Programming enables you to make a computer d o al m ost anything you want.

first programmer first computer

Ada Lovelace Analytical Engine 31

Robert Sedgewick | Kevin Wayne


Programming:
Telling a computer what to do

Programming
• Is not just for experts.
• Is a natural, satisfying and creative experience.
• Enables accomplishments not otherwise possible.
• The path to a new world of intellectual endeavor.

Challenges Telling a computer what to do


• Need to learn what computers can do.
• Need to learn a programming language.

Naive ideal: A single programming language for all purposes.

32

Robert Sedgewick | Kevin Wayne


The Tower of Babel
A story about the origins of multiple languages

• [After the flood]


“The whole earth was of one language and
one speech.”

• They built a city and tower at Babel,


believing that with a single language, people
will be able to do anything they imagine.

• Yahweh disagrees and


“confounds the language of all the earth”

• Why?

Proliferation of cultural differences (and multiple languages) is one basis of civilization.

33

Robert Sedgewick | Kevin Wayne


Several ways to solve a transportation problem

34

Robert Sedgewick | Kevin Wayne


Telling a computer what to do
Machine language Natural language High-level language
• Easy for computer. • Easy for human. • Some difficulty for both.
• Error-prone for human. • Error-prone for computer. • A n acceptable tradeoff.

for (int t = 0; t < 2000; t++)


10: 8A00 RA ← mem[00] {
11: 8B01 RB ← mem[01] a[0] = a[11] ^ a[9];
12: 1CAB RC ← RA + RB System.out.print(a[0]);
13: 9C02 mem[02] ← RC for (int i = 11; i > 0; i--)
Police Squad Helps Dog Bite Victim. a[i] = a[i-1];
14: 0000 halt
}
Adding two numbers

Actual newspaper headlines


— Rich Pattis

But which high-level language?

Naive ideal: A single programming language for all purposes.


35

Robert Sedgewick | Kevin Wayne


Several ways to solve a programming problem

36

Robert Sedgewick | Kevin Wayne


Our Choice: Java
Java features
• Widely used.
• Widely available.
• Continuously under development since early 1990s.
• Embraces full set of modern programming abstractions.
• Variety of automatic checks for mistakes in programs. James Gosling

millions of developers
Java economy billions of devices

• Ma rs rover.
• Cell phones.
• Blu-ray Disc.
• Web servers.
• Medical devices.
• Supercomputers.
•…
37

Robert Sedgewick | Kevin Wayne


Our Choice: Java
Facts of life “ There are only two
• No language is perfect. kinds of programming
• You need to start with some languages: those
language . people always [gripe]
about and those
nobody uses.” − Bjarne Stroustrup

Our approach
• Use a minimal subset of Java.
• Use Java to study how to efficiently organize data.
• Develop general programming skills that are applicable to many languages.

It’s not about the language!

38

Robert Sedgewick | Kevin Wayne


Why learn another programming language?
Good reasons to learn a programming language
• Offers something new.
• Need to interface with co-workers.
• Provides an intellectual challenge
• Opportunity to learn something about computation.
• Introduces a new programming style.

Learning a new programming language will make it easy


for you to learn other programming languages.

39

Robert Sedgewick | Kevin Wayne


The Tower of Babel

Image from cover of


Programming Languages by
Jean Sammet (1969).
Already 120+ languages!

An apt metaphor.
• Would a single programming language enable us to do anything that we imagine?
• Is the proliferation of languages a basis of civilization in programming?
40

Robert Sedgewick | Kevin Wayne


Check point

41
Your first program in Java

https://introcs.cs.princeton.edu/java/11hello/
Program development in Java
is a three-step process, with feedback

1.EDIT your program


• Create it by typing on your computer's keyboard.
• Result: a text file such as HelloWorld.java.
EDIT
2.COMPILE it to create an executable file
• Use the Java compiler
• Result: a Java bytecode file such as HelloWorld.class
• Mistake? Go back to 1. to fix and recompile. COMPILE RUN

not a legal Java program


3.RUN your program
• Use the Java runtime.
• Result: your program’s output.
• Mistake? Go back to 1. to fix, recompile, and run.
a legal Java program that does the wrong thing
44

Robert Sedgewick | Kevin Wayne


Software for program development
Any creative process involves cyclic refinement/development.

EDIT
COMPOSE

COMPILE RUN
REHEARSE PLAY

A significant difference with programs: We can use our computers to facilitate the process.

Program development environment: Software for editing, compiling and running programs.

Virtual terminals Integrated development environment


• Same for many languages and systems. •Often language- or system-specific.
• Effective even for beginners. •Can be helpful to beginners.
Bottom line: Extremely simple and concise. Bottom line: Variety of useful tools.

45

Robert Sedgewick | Kevin Wayne


A rich subset of
the Java language vocabulary
built-in operations on String object Math
types numeric types operations assignment oriented methods

int + + = static Math.sin()


long - "" class Math.cos()
double length() flow control public Math.log()
System
char / charAt() if private Math.exp() methods
String % compareTo() else new Math.pow() System.print()
boolean ++ matches() for final Math.sqrt() System.println()
-- while toString() Math.min() System.printf()
boolean main()
punctuation comparisons Math.max()
operations
Scanner
{ < true arrays Math.abs()
hasNext()
} <= false a[] Math.PI
Next()
( > ! length type conversion methods
hasNextLine()
) >= && new Integer.parseInt() nextLine()
, == ||
Double.parseDouble() findInLine(String s)
; !=

Your programs will primarily consist of these plus identifiers (names) that you make up.
46

Robert Sedgewick | Kevin Wayne


Anatomy of your first program
HelloWorld.java
program name
main() method
text file named
public class HelloWorld {
HelloWorld.java
public static void main(String[] args){

System.out.println("Hello, World");
}
}

body of main()
(a single statement)

elice> Week 1-1> First program in Java


47

Robert Sedgewick | Kevin Wayne


Anatomy of your next several programs

program name
main() method
text file named public class MyProgram {
MyProgram.java
public static void main(String[] args) {

...

}
}

body of main()
(a sequence of statements)
48

Robert Sedgewick | Kevin Wayne


Check point
I typed in the following program.

When I execute it, I get an error message.


What am I doing wrong?

public class HelloWorld {


public static void main() {
System.out.println("Hello, World");
}
}

49
Three versions of the same program.
public class HelloWorld
{
public static void main(String[] args)
{
System.out.println("Hello, World");
} /*************************************************************************
} * Compilation: javac HelloWorld.java
* Execution: java HelloWorld
*
* Prints "Hello, World". By tradition, this is everyone's first program.
*
* % java HelloWorld
* Hello, World
*
Provide a brief statement of the program’s *************************************************************************/

overall purpose, and test cases—input and public class HelloWorld {


public static void main(String[] args) {
output. }
System.out.println("Hello, World");

public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World"); }
}

Fonts, color, comments, and extra white space are not relevant in Java
language. However...
50

Robert Sedgewick | Kevin Wayne


Note on program style
Consistent style can
• Make it easier to spot errors.
• Make it easier for others to read and use code.
• Enable development environment to provide visual cues.
• Using white spaces can visually enhance your program by
spreading your code out, improving your program’s readability.

Bottom line for you: Follow the convention.

51

Robert Sedgewick | Kevin Wayne


Basic building blocks
• Built-in types of data
• Conditionals and loops
• Functions
• OOP
• Data Abstraction

52

You might also like