CS2468: Data Structures and Data Management Lecturer: Lusheng Wang · office:B6422 Phone:34429820 E-mail cswangl @cityu. edu. hk TA ( Assignment Marking and Tutorial) Chao shen chaoshen 2-c@my cityu. edu. hk, phone 3442 2546 ZichengZHAOshinaiderzhao@gmail.com Welcome to ask questions at any time The course Website: Canvas Some」 ava source code http:/inEt3.datastructures.net/download.html The course website Text Book: Michael T goodrich and roberto tamassia Data Structure and Algorithms in Java, John Wiley Sons, Inc. 5th Edition Stacks
CS2468: Data Structures and Data Management • Lecturer: Lusheng Wang • Office: B6422 • Phone: 3442 9820 • E-mail cswangl@cityu.edu.hk • TA (Assignment Marking and Tutorial) – Chao SHEN chaoshen2-c@my.cityu.edu.hk , Phone: 3442 2546 – Zicheng ZHAO shinaider.zhao@gmail.com Welcome to ask questions at ANY time. • The course Website: Canvas • Some Java Source code: http://net3.datastructures.net/download.html • The course Website: Text Book: Michael T. Goodrich and Roberto Tamassia, Data Structure and Algorithms in Java, John Wiley & Sons, Inc. 5th Edition Stacks 1
opicS to be covere Analysis of algorithms worst case time and space complexity Data structures stack, queue, linked list, tree, priority queue, heap, hash, and graph, Searching agorithms binary and avl search trees Sorting agorithms merge sort, quick sort, bucket sort and radix sort; (Reduce some contents Graph data structure depth first search and breadth first search ( add some interesting contents). shortest path Stacks 2
Topics to be covered • Analysis of Algorithms – worst case time and space complexity • Data Structures – stack, queue, linked list, tree, priority queue, heap, hash, and graph, • Searching algorithms – binary and AVL search trees; • Sorting algorithms – merge sort, quick sort, bucket sort and radix sort; (Reduce some contents) • Graph – data structure, depth first search and breadth first search. (add some interesting contents). • shortest path. Stacks 2
Why This Course? You will be able to evaluate the quality of program analysis of algorithms: Running time and memory space You will be able to write fast programs You will be able to solve new problems You will be able to give non-trivial methods to solve problems. (Your algorithm(program) will be faster than others. Stacks
Why This Course? • You will be able to evaluate the quality of a program (Analysis of Algorithms: Running time and memory space ) • You will be able to write fast programs • You will be able to solve new problems • You will be able to give non-trivial methods to solve problems. (Your algorithm (program) will be faster than others.) Stacks 3
Course evaluations · Course work:30% Final Exam: 70% Course Work Three assignments, 15% One quiz or lab test 3% One mid term exam 12% Stacks
Course Evaluations • Course work: 30% • Final Exam: 70% • Course Work: – Three assignments, 15% – One quiz or lab test 3% – One mid term exam 12% Stacks 4
OBL. Course Intended Learning Outcomes 1. Describe the functiona lity of a data structure as an abstract data type 2. Implement an abstract data type in a programming language 3. Implement and test data structures for common structures 4. Select an appropriate data structure from a given set of structures to solve a given problem 5. Design and implement data storage management with simple file structures Will be tested in quiz or assignment or midterm For each item you have to get 40%to pass
5 OBTL: Course Intended Learning Outcomes 1.Describe the functionality of a data structure as an abstract data type; 2.Implement an abstract data type in a programming language; 3.Implement and test data structures for common structures; 4.Select an appropriate data structure from a given set of structures to solve a given problem; 5.Design and implement data storage management with simple file structures. Will be tested in quiz or assignment or midterm. For each item, you have to get 40% to pass
Pre-requisites CS2360 Java Programming /or Not known java? Spend the rest of 8-10 days to study java Read textbook p1-p53 Design a class with two integers C1 and C2 and a method fo to calculate the average value of c1 and c2 If you cannot do that, you should worry Stacks 6
Pre-requisites: • CS2360 Java Programming /or • Not known java? – Spend the rest of 8-10 days to study Java. – Read textbook p1-p53 – Design a class with two integers C1 and C2 and a method f() to calculate the average value of c1 and c2. – If you cannot do that, you should worry… Stacks 6
Data structures a systematic way of organizing and accessing data No single data structure works well for ALl purposes Data stored operation on data Algorithms an effective method expressed as a finite list of well-defined instructions for calculating a function Algorithms are used for calculation, data processing and automated reasonIng In simple words an algorithm is a step-by-step procedure for calculations Stacks
• Data Structures – A systematic way of organizing and accessing data. --No single data structure works well for ALL purposes. – Data stored – operation on data • Algorithms – an effective method expressed as a finite list of well-defined instructions for calculating a function. – Algorithms are used for calculation, data processing, and automated reasoning. – In simple words an algorithm is a step-by-step procedure for calculations. Stacks 7
How to describe algorithm? Nature languages Chinese, english, etc Not accurate · Pseudo-code Codes close to computer languages Omits details that are not essential for human understanding Intended for human reading rather than machine reading Programs C/C++ programs, Java programs Pseudo-code is preferred Allow a well-trained programmer to be able to implement Stacks
How to describe algorithm? • Nature languages – Chinese, English, etc. – Not accurate. • Pseudo-code – Codes close to computer languages • Omits details that are not essential for human understanding – Intended for human reading rather than machine reading • Programs – C /C++ programs, Java programs. • Pseudo-code is preferred – Allow a well-trained programmer to be able to implement. – Allow an expert to be able to analyze the running time. Stacks 8
An Example of an algorithm Algorithm sorting(X, n Algorithm sorting(x, n) Input array X of n integers Input array X of n integers Output array X sorted in a non- Output array X sorted in a non- decreasing order ecreasing order for it0 to n-do forj←-计+ton-ldo for i fromo to n- do fori from i+l to n-1 do if (Xixlilthen if X/i is largerthan Xil S- swap(X/i,xn i/, return X return X lafter i-th round, the i-th smallest after i-th round, the i-th smallest number is at i-th position number is at i-th position Stacks
An Example of an Algorithm Algorithm sorting(X, n) Input array X of n integers Output array X sorted in a nondecreasing order for i 0 to n − 1 do for j i+1 to n-1 do if (X[i]>X[j])then { s=X[i]; X[i]=X[j]; X[j]=s; } return X // after i-th round, the i-th smallest number is at i-th position. Stacks 9 Algorithm sorting(X, n) Input array X of n integers Output array X sorted in a nondecreasing order for i from 0 to n − 1 do for j from i+1 to n-1 do if X[i] is larger than X[j] swap(X[i], X[j]) return X // after i-th round, the i-th smallest number is at i-th position
Variables. Primitives a variable has its value a type is associated, E. g, int, boolean, float, long, etc A value is assigned to the variable The value is stored in the memory The size of the value is determined umbigously; 64 bit machine, int 8 bytes, double 8 bytes, etc Examples int y=50; char, ZA; Stacks
Variables, Primitives • A variable has its value – A type is associated, • E.g., int, boolean, float, long, etc. – A value is assigned to the variable • The value is stored in the memory • The size of the value is determined umbigously; 64 bit machine, int 8 bytes, double 8 bytes, etc – Examples • int x; • int y=50; • char c, z=‘A’; Stacks 10