CE221 – Data Structures & Algorithms Lab Introduction

Slides:



Advertisements
Similar presentations
 Control structures  Algorithm & flowchart  If statements  While statements.
Advertisements

ITEC113 Algorithms and Programming Techniques
5-1 Flow of Control Recitation-01/25/2008  CS 180  Department of Computer Science  Purdue University.
Introduction to Computers and Programming Lecture 5 New York University.
CS 106 Introduction to Computer Science I 02 / 12 / 2007 Instructor: Michael Eckmann.
Introduction to Computers and Programming Lecture 10: For Loops Professor: Evan Korth New York University.
Introduction to Computers and Programming Lecture 10: For Loops Professor: Evan Korth New York University.
Introduction to Computers and Programming Lecture 5 Boolean type; if statement Professor: Evan Korth New York University.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
Relational Operators Control structures Decisions using “if” statements  2000 Prentice Hall, Inc. All rights reserved. Modified for use with this course.
© 2004 Pearson Addison-Wesley. All rights reserved5-1 Iterations/ Loops The while Statement Other Repetition Statements.
The switch Statement, DecimalFormat, and Introduction to Looping
UNIT II Decision Making And Branching Decision Making And Looping
Computer Science 102 Data Structures and Algorithms V Fall 2009 Lecture 1: administrative details Professor: Evan Korth New York University 1.
Python Control Flow statements There are three control flow statements in Python - if, for and while.
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
Lecture 4 C Program Control Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education Inc.
COMPUTER PROGRAMMING. Control Structures A program is usually not limited to a linear sequence of instructions. During its process it may repeat code.
CS 101E – Exam 2 Review Spring 2007 Michele Co. Announcements Review Session Tonight, 7/7:30 p.m., OLS 009 Will be announced via In-class Exam Wednesday.
CSCI 51 Introduction to Computer Science Dr. Joshua Stough January 20, 2009.
5-1 Repetition Statements Repetition statements allow us to execute a statement multiple times Often they are referred to as loops Like conditional statements,
Programming in Java Unit 4. Learning outcome:  LO2: Be able to design Java solutions  LO3: Be able to implement Java solutions Assessment criteria:
CPS120: Introduction to Computer Science Decision Making in Programs.
Expressions An expression is a series of variables, operators, and method calls (constructed according to the syntax of the language) that evaluates to.
COMPUTER PROGRAMMING. Iteration structures (loops) There may be a situation when you need to execute a block of code several number of times. In general,
Chapter 3 - Structured Program Development Outline 3.1Introduction 3.2Algorithms 3.3Pseudocode 3.4Control Structures 3.5The If Selection Structure 3.6The.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Control Statements I.
Using Java MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE Lecture 9 & 10 Repetition Statements.
Lecture 2 Conditional Statement. chcslonline.org Conditional Statements in PHP Conditional Statements are used for decision making. Different actions.
CSC 212 Object-Oriented Programming and Java Part 2.
The while-statement. The loop statements in Java What is a loop-statement: A loop-statement is a statement that repeatedly executes statements contained.
Java Basic Syntax. Object - Objects have states and behaviors. –Example: A dog has states-color, name, breed as well as behaviors -wagging, barking, eating.
 Control Flow statements ◦ Selection statements ◦ Iteration statements ◦ Jump statements.
Written by: Dr. JJ Shepherd
COMP Loop Statements Yi Hong May 21, 2015.
A High Flying Overview CS139 – Fall 2006 How far we have come.
LECTURE # 8 : REPETITION STATEMENTS By Mr. Ali Edan.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
CISC105 – General Computer Science Class 4 – 06/14/2006.
Control structures in C by Dr P.Padmanabham Professor (CSE)&Director Bharat Institute of Engineering &Technology Hyderabad Mobile
Basic Syntax อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา Chapter 2.
Loop Control อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา Chapter 8.
Introduction to Programming G50PRO University of Nottingham Unit 6 : Control Flow Statements 2 Paul Tennent
Chapter 7 Control Structures. Java has very flexible three looping mechanisms. You can use one of the following three loops:  while Loop  do...while.
C Program Control September 15, OBJECTIVES The essentials of counter-controlled repetition. To use the for and do...while repetition statements.
A High Flying Overview CS139 – Fall 2010 How far we have come.
Introduction to Computers and Programming Lecture 10: For Loops Professor: Evan Korth New York University.
CS 106 Introduction to Computer Science I 02 / 15 / 2008 Instructor: Michael Eckmann.
Information and Computer Sciences University of Hawaii, Manoa
Chapter 10 Programming Fundamentals with JavaScript
Michele Weigle - COMP 14 - Spr 04 Catie Welsh February 21, 2011
CprE 185: Intro to Problem Solving (using C)
CSc 1302 Principles of Computer Science II
Yanal Alahmad Java Workshop Yanal Alahmad
Control Structures.
Computer Science 102 Data Structures CSCI-UA
CiS 260: App Dev I Chapter 4: Control Structures II.
Ch 7: JavaScript Control Statements I.
JavaScript: Control Statements.
JavaScript: Control Statements I
CS139 – Fall 2010 How far we have come
Loop Control Structure.
MSIS 655 Advanced Business Applications Programming
3 Control Statements:.
Lab5 PROGRAMMING 1 Loop chapter4.
Computer Science Core Concepts
2.6 The if/else Selection Structure
CE221 – Data Structures & Algorithms Lab Introduction
Control Statements Loops.
Loops CGS3416 Spring 2019 Lecture 7.
Presentation transcript:

CE221 – Data Structures & Algorithms Lab Introduction Course Assistants: A. Teoman Unay, Yiğit Oktar

LAB Introduction Teoman Unay Office : MB166 Please do not visit the office for asking questions about the lecture. There will be recitation hours for that purpose. Our office is not suitable for lecturing. E-mail : teoman.unay@ieu.edu.tr Website : http://homes.ieu.edu.tr/tunay Website is for your grades, attendances and required lab-files. Check it regularly.

What are we going to do? Selected book questions will be solved 4 Quizes 6 Coding Assignments All assignments are going to be in lab. Every lab material (quiz or assignment) worths 3 points. There will be 10 materials. 3 x 10 = 30 points total.

Java - Coding assignments are going to be in Java language. - In Java, it is very important to keep in mind the following points.

Java Case Sensitivity − Java is case sensitive, which means identifier Hello and hello would have different meaning in Java. Class Names − For all class names the first letter should be in Upper Case. If several words are used to form a name of the class, each inner word's first letter should be in Upper Case. Example: class MyFirstJavaClass public static void main(String args[]) − Java program processing starts from the main() method which is a mandatory part of every Java program.

Java Program File Name − Name of the program file should exactly match the class name. When saving the file, you should save it using the class name (Remember Java is case sensitive) and append '.java' to the end of the name (if the file name and the class name do not match, your program will not compile). Example: Assume 'MyFirstJavaProgram' is the class name. Then the file should be saved as 'MyFirstJavaProgram.java'

Creating an Object In Java, the new keyword is used to create new objects. There are three steps when creating an object from a class − Declaration − A variable declaration with a variable name with an object type. Instantiation − The 'new' keyword is used to create the object. Initialization − The 'new' keyword is followed by a call to a constructor. This call initializes the new object.

Creating an Object Output:

Accessing Instance Variables and Methods Instance variables and methods are accessed via created objects. Output:

Source File Declaration Rules There can be only one public class per source file. The public class name should be the name of the source file as well which should be appended by .java at the end. For example: the class name is public class Employee{} then the source file should be as Employee.java. If the class is defined inside a package, then the package statement should be the first statement in the source file. If import statements are present, then they must be written between the package statement and the class declaration. If there are no package statements, then the import statement should be the first line in the source file.

Variable Types Following are valid examples of variable declaration and initialization in Java There are three kinds of variables in Java − Local variables Instance variables Class/Static variables

Loop Control A loop statement allows us to execute a statement or group of statements multiple times and following is the general form of a loop statement in most of the programming languages

while loop Repeats a statement or group of statements while a given condition is true. It tests the condition before executing the loop body. Example: Output:

for loop A for loop is a repetition control structure that allows you to efficiently write a loop that needs to be executed a specific number of times. Example: Output:

do…while loop A do...while loop is similar to a while loop, except that a do...while loop is guaranteed to execute at least one time. Example: Output:

Desicion Making Decision making structures have one or more conditions to be evaluated or tested by the program, along with a statement or statements that are to be executed if the condition is determined to be true, and optionally, other statements to be executed if the condition is determined to be false.

if…else.. statement If the condition is true, then the if block of code will be executed, otherwise else block of code will be executed. Example: Output:

switch statement A switch statement allows a variable to be tested for equality against a list of values. Each value is called a case, and the variable being switched on is checked for each case. Example: Output:

Loop Control Statements Loop control statements change execution from its normal sequence. When execution leaves a scope, all automatic objects that were created in that scope are destroyed. break statement Terminates the loop or switch statement and transfers execution to the statement immediately following the loop or switch. continue statement Causes the loop to skip the remainder of its body and immediately retest its condition prior to reiterating.

Logarithm Let’s also refresh our memory about logarithms: The idea of logarithms is to reverse the operation of exponentiation, that is, raising a number to a power: 23 = 8 It follows that the logarithm of 8 with respect to base 2 is 3 log28 = 3 In computer science (complexity analysis), binary logarithm is used. Common logarithm -> logx = log10x Binary logarithm -> logx = log2x

Series Easiest formulas to remember are:

Cheating Following actions will be considered as cheating: Submiting same or very similar lab material (quiz/codework) with another student. «We have prepared this together!» is not an excuse. You need to prepare your assignments alone. «My friend has submitted my work without my knowledge» is not an excuse. Your work is in your responsibility. Copying all/some of the work from the internet. Of course you can get help but copying the core parts from an external source is cheating. Cheating is strictly forbidden. Submissions that includes any of the conditions above will be graded as 0 and related professors will be informed.

Recitation Hours Recitation Hours for your questions about the lecture will be announced soon. You can ask your course assistant anything about the course within these hours. Please e-mail me and specify the topic or the question you need to ask before coming. Of course you can also just drop by but in that case, the process might be slower.

That is all for this week Have a nice semester!

References https://www.tutorialspoint.com/java/ M. A. Weiss, Data Structures and Algorithm Analysis in Java, 3/e, Pearson, 2012