College Of Computer Al-Lith

Slides:



Advertisements
Similar presentations
Overview of Data Structures and Algorithms
Advertisements

Lecture 12: Revision Lecture Dr John Levine Algorithms and Complexity March 27th 2006.
January 11, Csci 2111: Data and File Structures Week1, Lecture 1 Introduction to the Design and Specification of File Structures.
Data Structures Data Structures Topic #13. Today’s Agenda Sorting Algorithms: Recursive –mergesort –quicksort As we learn about each sorting algorithm,
CSCE 210 Data Structures and Algorithms
Midterm 2 Overview Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
DAST, Spring © L. Joskowicz 1 Data Structures – LECTURE 1 Introduction Motivation: algorithms and abstract data types Easy problems, hard problems.
CS 315 Data Structures B. Ravikumar Office: 116 I Darwin Hall Phone: Course Web site:
Review for Test 2 i206 Fall 2010 John Chuang. 2 Topics  Operating System and Memory Hierarchy  Algorithm analysis and Big-O Notation  Data structures.
CS 206 Introduction to Computer Science II 04 / 29 / 2009 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 12 / 10 / 2008 Instructor: Michael Eckmann.
B + -Trees (Part 1) COMP171. Slide 2 Main and secondary memories  Secondary storage device is much, much slower than the main RAM  Pages and blocks.
DAST, Spring © L. Joskowicz 1 Data Structures – LECTURE 1 Introduction Motivation: algorithms and abstract data types Easy problems, hard problems.
By D.Kumaragurubaran Adishesh Pant
C o n f i d e n t i a l Developed By Nitendra NextHome Subject Name: Data Structure Using C Title: Overview of Data Structure.
CSC220 Data Structure Winter
Instructor: Dr. Sahar Shabanah Fall Lectures ST, 9:30 pm-11:00 pm Text book: M. T. Goodrich and R. Tamassia, “Data Structures and Algorithms in.
Teaching Teaching Discrete Mathematics and Algorithms & Data Structures Online G.MirkowskaPJIIT.
File Organization Techniques
Copyright © Wondershare Software Introduction to Data Structures Prepared by: Eng. Ahmed & Mohamed Taha.
CS223 Algorithms D-Term 2013 Instructor: Mohamed Eltabakh WPI, CS Introduction Slide 1.
Sorting. Background As soon as you create a significant database, you’ll probably think of reasons to sort it in various ways. You need to arrange names.
9/17/20151 Chapter 12 - Heaps. 9/17/20152 Introduction ► Heaps are largely about priority queues. ► They are an alternative data structure to implementing.
Design and Analysis of Algorithms CSC201 Shahid Hussain 1.
January 11, Files – Chapter 1 Introduction to the Design and Specification of File Structures.
CHAPTER 09 Compiled by: Dr. Mohammad Omar Alhawarat Sorting & Searching.
Lecture 10: Class Review Dr John Levine Algorithms and Complexity March 13th 2006.
Introduction to the course. Objectives of the course  To provide a solid introduction to the topic of file structures design.  To discuss a number of.
DATA STRUCTURES (CS212D) Week # 1: Overview & Review.
CS212: DATA STRUCTURES Lecture 1: Introduction. What is this course is about ?  Data structures : conceptual and concrete ways to organize data for efficient.
External data structures
Database Management Systems,Shri Prasad Sawant. 1 Storing Data: Disks and Files Unit 1 Mr.Prasad Sawant.
CS246 Data & File Structures Lecture 1 Introduction to File Systems Instructor: Li Ma Office: NBC 126 Phone: (713)
File Organization Lecture 1
Storage Structures. Memory Hierarchies Primary Storage –Registers –Cache memory –RAM Secondary Storage –Magnetic disks –Magnetic tape –CDROM (read-only.
Data Structures and Algorithms Dr. Tehseen Zia Assistant Professor Dept. Computer Science and IT University of Sargodha Lecture 1.
3 – SIMPLE SORTING ALGORITHMS
Review for Final Exam – cs411/511 Definitions (5 questions, 2 points each) Algorithm Analysis (3 questions, 3 points each) General Questions (3 questions,
Sorting and Searching by Dr P.Padmanabham Professor (CSE)&Director
Course Code #IDCGRF001-A 5.1: Searching and sorting concepts Programming Techniques.
ICS201 Lecture 21 : Sorting King Fahd University of Petroleum & Minerals College of Computer Science & Engineering Information & Computer Science Department.
Searching Topics Sequential Search Binary Search.
Course Info Instructor U.T. Nguyen Office: CSEB Office hours: Tuesday, 14:30-15:30 Thursday, 12:00-12:45 By.
Data Structures and Algorithms in Java AlaaEddin 2012.
DATA STRUCTURES (CS212D) Overview & Review Instructor Information 2  Instructor Information:  Dr. Radwa El Shawi  Room: 
 Saturday, April 20, 8:30-11:00am in B9201  Similar in style to written midterm exam  May include (a little) coding on paper  About 1.5 times as long.
Onlinedeeneislam.blogspot.com1 Design and Analysis of Algorithms Slide # 1 Download From
Chapter 5 Record Storage and Primary File Organizations
CENG 3511 CENG 351 Introduction to Data Management and File Structures Nihan Kesim Çiçekli Department of Computer Engineering METU.
CSC 143T 1 CSC 143 Highlights of Tables and Hashing [Chapter 11 p (Tables)] [Chapter 12 p (Hashing)]
COMP 103 Course Review. 2 Menu  A final word on hash collisions in Open Addressing / Probing  Course Summary  What we have covered  What you should.
Mohammed I DAABO COURSE CODE: CSC 355 COURSE TITLE: Data Structures.
CSCE 210 Data Structures and Algorithms
File Organization and Processing
Welcome to ….. File Organization.
Course Developer/Writer: A. J. Ikuomola
Top 50 Data Structures Interview Questions
Data Structure Interview Question and Answers
Lecture 1 Introduction/Overview Text: Chapters 1, 2 Wed. 1/28/04
External Sorting Chapter 13
Introduction of ECE665 Computer Algorithms
Cse 373 April 26th – Exam Review.
CS 583 Fall 2006 Analysis of Algorithms
Definition In simple terms, an algorithm is a series of instructions to solve a problem (complete a task) We focus on Deterministic Algorithms Under the.
Searching and Sorting Topics Sequential Search on an Unordered File
External Sorting Chapter 13
Manipulating lists of data
CENG 351 Introduction to Data Management and File Structures
External Sorting Chapter 13
COMP 122 – Design and Analysis of Algorithms
Presentation transcript:

College Of Computer Al-Lith 1431227-3 File Organization and Processing “Advanced Data Structres” “Algorithms” Lecturer DR.Ali Al Najjar Umm Al Qura University College Of Computer Al-Lith

Books and Materials REQUIRED TEXTBOOK: Introduction to Algorithms by T.H. Cormen, C.E. Leiserson, R.L. Rivest, and C. Stein, Second Edition, MIT Press, 2001. ISBN 0-262-03293-7 RECOMMENDED MATERIALS: Data Structure and Algorithms in Java, Robert Lafore, Sams Publications- Online copy (I will provide) Data Structures and Algorithms in Java, 2nd Edition, Michael T. Goodrich and Roberto Tamassia, John Wiley and Sons Inc. 2007 ISBN: 81-265-1226-1 I will try to provide everything in the lecture slides

Secondary Storage Hard Disk Graphs Course Outline Trees Binary Search Trees - AVL trees - B-Tree -Black Red - Heaps Secondary Storage Hard Disk Graphs Depth first search Breadth first search

Grading Scheme Attendance 10% Homework 10% Midterm 20% Quizzes 10% Final exam 50% Total 100%

OVERVIEW OF ADS AND FILE STRUCTURE AND PROCESSING

Topics Already Covered in ADS Course: Asymptotic complexity Big O, small o, big omega, small omega Linear data structures Arrays, linked list, stacks, ADT, queue ADT, a notion of dynamic arrays Sorting Insertion sort, merge sort (randomized), quick sort Sorted sequence Dictionary ADT and important operations, trees, binary search trees, AVL trees, in-order traversal Hash tables Hashing concepts, open hashing, closed hashing, probing, rehashing, implementing dictionary operations using hash tables Priority queue Binary heaps, implementation, dictionary operations in pririoty queue, heapsort

Refreshing ADS Basic Concepts Data Structure? Algorithms? File Structure?

Basic Concepts- Data Structures A data Structures is the organization of data in a computer’s memory or in a disk file. Examples: Arrays, stacks, linked list Algorithms are the procedure a software program uses to manipulate the data in these structure. Example: Printing address labels Array to store the address- Data Structure For loop – sequential access to the array- Algorithm

Characteristics of Data Structures Array Advantages: quick insertion, very fast access if index is known Disadvantages: Slow search, slow deletion, fixed size Ordered Array Advantages: Quicker search than unsorted array Disadvantages: Slow insertion and deletion, fixed size Stack Advantages: Provides LIFO access Disadvantage: Slow access to other items

Characteristics of Data Structures Queue Advantages: Provides FIFO access Disadvantages: Slow access to other items Linked List Advantages: Quick insertion, quick deletion Disadvantages: Slow search Binary Tree Advantages: Quick search, insertion, deletion (if tree remains balanced) Disadvantages: Deletion algorithm is complex

Overview of Algorithms Basic operations: Insert a new data item Search for a specified item Delete a specified item Definitions: Database All the data that will be dealt within a particular situation Stored on a disk- File Records Units into which database is divided Provide format for storing information Fields Records are usually divided into several fields Field holds a particular kind of data In Java records are usually represented by objects of an appropriate class

Data Structure vs. File Structure Both involve: Representation of Data + Operations for accessing data Difference: Data Structures deal with data in main memory File Structures deal with data in secondary storage device (File).

Computer Architecture CPU RAM ─ Fast ─ Small ─ Expensive ─ Volatile Registers Cache Disk, Tape, DVD-R Main Memory Secondary Storage ─ Slow ─ Large ─ Cheap ─ Stable

Memory Hierarchy directly referenced in main memory. ►On systems with 32-bit addressing, only 232 bytes can be directly referenced in main memory. ►The number of data objects may exceed this number! ►Data must be maintained across program executions. This requires storage devices that retain information when the computer is restarted. – We call such storage nonvolatile. – Primary storage is usually volatile, whereas secondary and tertiary storage are nonvolatile.

How Fast? Typical times for getting info Main memory: ~120 nanoseconds =120x10-09 Magnetic Disks: ~30 milliseconds = 30x10-03 An analogy keeping same time proportion as above Looking at the index of a book: 20 seconds versus Going to the library: 1 hour

Comparison Main Memory Secondary Storage Fast (since electronic) Small (since expensive) Volatile (information is lost when power failure occurs) Secondary Storage Slow (since electronic and mechanical) Large (since cheap) Stable, persistent (information is preserved longer)

Goals of this course Advanced data structure and algorithm that builds the student’s knowledge in the areas of search tree structures (Red-Black Trees, B- Trees, Splay Trees), advanced heap structures (Fibonacci Heaps), graphs and graphs algorithm (Depth-first, Breadth- first, Minimum Spanning Trees, Shortest path, Maximum flow, Matching) and geometric algorithm (Intersection of line segments, convex hull).

Goals of this course (Cont’d) The successful student, learning these concepts, will be able to analyze algorithms for different data structures and file structures. The objective of Data Structures and Algorithm was to teach ways of efficiently organizing and manipulating data in main memory. In this course you will learn equivalent techniques for organization and manipulation of data in secondary storage.

Algorithm Analysis- Big O Notation Example: automobile Large, medium, economy (compacts, subcompacts, midsize) Provide quick idea about the size. Don’t need actual dimension Useful to have a shorthand way to say how efficient a computer algorithm is. In CS, rough measure is called Big O notation Alg. A is twice as fast as alg. B- not meaningful Why? Proportion can change radically as the number of items change Need a measure that is related to the number of items BIG O IS THE SOLUTION!!!

Big O Notation Insertion in an unsorted array Linear search Does not depend on how many items in an array, no matter how big is array N Item placed in the next available position a[nElems] and nElems++; Constant time , T=K, O(1) Real situation: time depends on speed of the microprocessor, how efficiently the compiler generated the program code and other factors; Constant K account for all such factors Linear search No. of comparisons that must be made to find that item Average time: half of the total number of items T=K*N/2 How to calculate K? k= K/2; T=k*N Proportional to the size of the array O(N)

Running Times in Big O Notation Algorithm Running time- Big O Comment Linear search O(N) Fair Binary search O(log N) Good Insertion in unordered array O(1) Best Insertion in an ordered array Deletion in an unordered array Deletion in an ordered array Sorting O(N2) Very bad Why Not Use Arrays for Everything?

Sorting Examples: students by grade, customers by zip code, home sales by price, cities in order of increasing population, countries by GNP, stars by magnitude, and so on. Sorting data may also be a preliminary step to searching it. Binary search, which can be applied only to sorted data, is much faster than a linear search. Because sorting is so important and potentially so time-consuming, it has been the subject of extensive research in computer science, and some very sophisticated methods have been developed.

How would you do Sorting? Two Steps: Compare two items. Swap two items or copy one item. Move one position right Problem: Imagine that kids-league baseball team is lined up on the field. The regulation nine players, plus an extra, have shown up for practice. You want to arrange the players in order of increasing height (with the shortest player on the left), for the team picture. How would you go about this sorting process?

How would you do Sorting? Unsorted Sorted

Bubble Sort Notoriously slow but conceptually simplest Solution: You start at the left end of the line and compare the two kids in positions 0 and 1. If the one on the left (in 0) is taller, you swap them. If the one on the right is taller, you don't do anything. Then you move over one position and compare the kids in positions 1 and 2. Again, if the one on the left is taller, you swap them. Beginning of the 1st Pass

Bubble Sort After 1st pass tallest kid is on the right. Biggest item bubble up to the top end of the array as the algorithm progresses End of 1st Pass

Bubble Sort- Observation After this first pass through all the data, you've made N–1 comparisons and somewhere between 0 and N–1 swaps, depending on the initial arrangement of the players. The item at the end of the array is sorted and won't be moved again. Now you go back and start another pass from the left end of the line. Again you go toward the right, comparing and swapping when appropriate. However, this time you can stop one player short of the end of the line, at position N–2, because you know the last position, at N–1, already contains the tallest player. This rule could be stated as: When you reach the first sorted player, start over at the left end of the line. You continue this process until all the players are in order.

Efficiency of the Bubble Sort Examples: 10 items Comparisons: 9+8+7+-----+1= 45 General formula : (N-1)+(N-2)+(N-3)+--------+1=N*(N-1)/2~N2/2 ~O(N2) Practice Problems Define the following terms: data structure, algorithm, file structure, Big O notation Why array is not used in everything? What are the major steps in sorting? Compare the run time in terms of Big O notation for different algorithm Implement bubble sort using Java