Download CS214 * Data Structures Lecture 01: A Course Overview

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Stream processing wikipedia , lookup

Distributed computing wikipedia , lookup

Quicksort wikipedia , lookup

Travelling salesman problem wikipedia , lookup

Program optimization wikipedia , lookup

Dijkstra's algorithm wikipedia , lookup

Corecursion wikipedia , lookup

Algorithm characterizations wikipedia , lookup

Expectation–maximization algorithm wikipedia , lookup

Fast Fourier transform wikipedia , lookup

K-nearest neighbors algorithm wikipedia , lookup

Factorization of polynomials over finite fields wikipedia , lookup

Selection algorithm wikipedia , lookup

Algorithm wikipedia , lookup

Transcript
Data Structures
Dr Emad Nabil
Lec#1
Slides from Dr. Mohmaed Elramly
Course Administration
Course page :
http://www.acadox.com/class/45818#resources
Course Code:
CS214
Course Name:
Data Structures
Instructor
Dr. Emad Nabil
Coursework:
Assignments, Projects, Midterm, lab practice, practical exams
Assignments
policy:
No late submissions
cheating policy:
cheaters will be graded by –ve marks
Contents
• Introduction to data structures and the importance of data organization
• performance measures.
• Searching Algorithms
 [Linear Search, Binary Search]
• Sorting Algorithms
 [quick sort, and merge sort, Bubble Sort, Selection Sort, Insertion Sort]
•
•
•
•
•
•
•
Lists (single, doubly, and circular)
Stacks & Queues (using static arrays, dynamic arrays, and linked lists)
Hash Tables
Trees (General trees, Binary trees, BST, Tree Traversal
Graphs
Priority Queue
Heap, and Heap sort
Algorithms
• People use different ways to solve their problems, so we
may design different algorithms to solve a particular
problem, e.g. there are so many ways to sort an array
• An algorithm is a sequence of precise instructions that
specify how to solve a problem in a finite number of steps
(time)
Properties of Algorithms
●
Algorithm + Algorithm = Algorithm
●
Part of Algorithm = Algorithm
●
Several algorithms may solve the same problem, but in differrent time
●
●
Much of Computer Science research is to develop efficient algorithms to solve difficult
problems
●
Then implementing them in a programming language
●
Believe it or not, it can take seconds or decades
The question is how to select the best algorithm to solve a particular problem?
What is this course about?
• This is the third in a series of courses on software
development.







Programming 1 (CS112)
Programming 2 (CS213)
Algorithms and Data Structures (CS214)
File Organization (CS215)
Databases Systems 1 (IS211)
Software Engineering 1 (CS251)
Software Engineering 2 (CS352)
What is this course about?
• This is the third in a series of courses on
software development.
 Programming 1 (CS112)
 Programming 2 (CS213)





Algorithms and Data Structures (CS214)
File Organization (CS215)
Databases Systems 1 (IS211)
Software Engineering 1 (CS251)
Software Engineering 2 (CS352)
Course Objectives
• Understand the basic ADT and their characteristics
• Learn how to decide on the suitable data structure for an application.
• Implement basic data structures in C++
• Use existing data structures effectively in applications.
• Learn algorithm complexity and efficiency
• It is efficient to:
 minimize the run time of code.
 minimize the memory / storage needs of code.
 recognize that there may be a trade-off between speed and memory requirements.
 re-use code, instead of re-writing code.
Textbook
http://goo.gl/THfPJk
D/S vs. Algorithms vs. ADT
ADT specifies a collection of data values in terms of
the operations that can be performed on these data.
ADT is written in programming languages using classes
Algorithms define the set of operations that can
be performed on data to produce information. Their
efficiency depend on the selected data structures
Data Structures : specifies how the data exist
in the ADT is stored in memory.
What is an algorithm?
●
Algorithms can be non computer based
●
Cake recipe, instructions to get to from here to there, find a number
in a phonebook
–
●
Or how back up your contact list on a cell phone
Algorithms are much
computers
older than
Algorithms are everywhere ..
5-12
I. Math Revision
2. Logarithm
• Definition:
3. Summation
4. Recursion
• An algorithm is recursive if it calls itself
to do part of its work.
• Example: Compute n!
5. Mathematical Proof
• Three templates for mathematical proof
1. Proof by mathematical induction
2. Proof by Counterexample
3. Proof by Contradiction
Introduction to Algorithm
Complexity
Lecture Objectives
• To precisely define the term algorithm
• To specify the main characteristics of algorithms
• To estimate the time and space complexity of algorithms
• To get familiar with asymptotic rate growth of functions and algorithms
• To introduce the big-oh, Theta, and Omega operators to measure the worst,
average and best time complexity of algorithms
Algorithms
• An algorithm is a finite sequence of instructions that, if followed, accomplishes a
particular task
• Algorithms must satisfy the following criteria:
1) Input – Zero or more quantities are externally supplied.
2) Output – At least one quantity is produced.
3) Definiteness – Each instruction is clear and unambiguous.
4) Finiteness – If we trace out the instructions of an algorithm, then for all cases,
the algorithm terminates after a finite number of steps.
5) Efficiency – The algorithm must consume a reasonable amount of resources
and takes a reasonable of time. It must be feasible to run the algorithm.
Solving Problems by Computers
• So, we use algorithms to solve problems
• A problem is defined in principle as a task that to be solved by a computer, e.g.
 Sorting a list of numbers
 Searching for a particular key value in a collection of items
 Finding the shortest distance between two cities in a map
• Not all problems are solved by computers, computer scientists discovered that
 Some problems are easy to solve
 Other problems are hard to solve since they take a lot of time
Problem vs. Problem Instance
We should differentiate between a problem (general description of a task) and its
instances (a particular case with specific set of input data)
Example #1:
 Problem: Sort a collection
 Problem instance: sort the list [5,2,1,7,3] in ascending order
Example #2:
 Problem: Search for a key value in a collection
 Problem instance: given key=3, find this key in the sorted list [1,2,6,9,10,45,78]
Evaluating Algorithms here
• Suppose someone presents you with an algorithm
and asks whether it is good. How are you going to
answer this question?
• You may decide that the algorithm should be:
 Correct – which means solve the problem we face (not
a particular set of problem instances)
 Fast – which means it does not take too much time to
solve the problem instance
 .Memory-phobic – which means it does not require
unnecessary memory space to complete the solution
of a problem instance