Data Structures and Algorithms. 2 3 Outline What is a data structure Examples –elementary data structures –hash tables Computer capabilities What is.

Slides:



Advertisements
Similar presentations
Data Structures Through C
Advertisements

Linear Lists – Array Representation
ADVANCED DATA STRUCTURES AND ALGORITHM ANALYSIS Chapter 3 Lists, Stacks, and Queues.
CPSC 335 Dr. Marina Gavrilova Computer Science University of Calgary Canada.
Lecture - 1 on Data Structures. Prepared by, Jesmin Akhter, Lecturer, IIT,JU Data Type and Data Structure Data type Set of possible values for variables.
CS Section 600 CS Section 002 Dr. Angela Guercio Spring 2010.
1 Module 2: Fundamental Concepts Problems Programs –Programming languages.
Lecture 2: Fundamental Concepts
Text Chapters 1, 2. Sorting ä Sorting Problem: ä Input: A sequence of n numbers ä Output: A permutation (reordering) of the input sequence such that:
1 Module 2: Fundamental Concepts Problems Programs –Programming languages.
CSE 830: Design and Theory of Algorithms
1 Data Structures A program solves a problem. A program solves a problem. A solution consists of: A solution consists of:  a way to organize the data.
C# Programming: From Problem Analysis to Program Design1 Advanced Collections C# Programming: From Problem Analysis to Program Design 3 rd Edition 8.
1 ES 314 Advanced Programming Lec 2 Sept 3 Goals: Complete the discussion of problem Review of C++ Object-oriented design Arrays and pointers.
EE Data Structures and Algorithms N Radhakrishnan Assistant Professor Anna University, Chennai.
Important Problem Types and Fundamental Data Structures
Chapter 1 Introduction Definition of Algorithm An algorithm is a finite sequence of precise instructions for performing a computation or for solving.
DATA STRUCTURE Subject Code -14B11CI211.
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.
Slides modified by Erin Chambers Problem Solving and Algorithm Design, part 2.
HOW TO SOLVE IT? Algorithms. An Algorithm An algorithm is any well-defined (computational) procedure that takes some value, or set of values, as input.
CHP - 9 File Structures. INTRODUCTION In some of the previous chapters, we have discussed representations of and operations on data structures. These.
Copyright © Wondershare Software Introduction to Data Structures Prepared by: Eng. Ahmed & Mohamed Taha.
Data Structures Winter What is a Data Structure? A data structure is a method of organizing data. The study of data structures is particularly important.
Lecture No.01 Data Structures Dr. Sohail Aslam
Introduction to Data Structures. Definition Data structure is representation of the logical relationship existing between individual elements of data.
Design and Analysis of Algorithms CSC201 Shahid Hussain 1.
Data Structures and Abstract Data Types "Get your data structures correct first, and the rest of the program will write itself." - David Jones.
Elementary Data Structures Data Structures and Algorithms A. G. Malamos.
PRESENTED BY: RAJKRISHNADEEPAK.VUYYURU SWAMYCHANDAN.DONDAPATI VINESHKUMARREDDY.LANKA RAJSEKHARTIRUMALA KANDURI ALAN.
Introduction Algorithms and Conventions The design and analysis of algorithms is the core subject matter of Computer Science. Given a problem, we want.
BY Lecturer: Aisha Dawood.  an algorithm is any well-defined computational procedure that takes some value, or set of values, as input and produces.
CS212: DATA STRUCTURES Lecture 1: Introduction. What is this course is about ?  Data structures : conceptual and concrete ways to organize data for efficient.
Prepared By Ms.R.K.Dharme Head Computer Department.
Chapter 9 (modified) Abstract Data Types and Algorithms Nell Dale John Lewis.
DATA STRUCTURES & C# GENERICS Trent Spangler | Greg Phelps.
Data structures Abstract data types Java classes for Data structures and ADTs.
DATA STRUCTURE & ALGORITHMS (BCS 1223) NURUL HASLINDA NGAH SEMESTER /2014.
Data Structures and Algorithms Lecture 3 Instructor: Quratulain Date: 8 th September, 2009.
Data Structure Introduction.
Foundation of Computing Systems Lecture 3 Stacks and Queues.
1 Linked-list, stack and queue. 2 Outline Abstract Data Type (ADT)‏ Linked list Stack Queue.
Standard Template Library The Standard Template Library was recently added to standard C++. –The STL contains generic template classes. –The STL permits.
Introduction to the Standard Template Library (STL) A container class holds a number of similar objects. Examples: –Vector –List –Stack –Queue –Set –Map.
Elementary Data Organization. Outline  Data, Entity and Information  Primitive data types  Non primitive data Types  Data structure  Definition 
Collections Data structures in Java. OBJECTIVE “ WHEN TO USE WHICH DATA STRUCTURE ” D e b u g.
Data Structures Chapter 6. Data Structure A data structure is a representation of data and the operations allowed on that data. Examples: 1.Array 2.Record.
Data Structures. Abstract Data Type A collection of related data is known as an abstract data type (ADT) Data Structure = ADT + Collection of functions.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI 240 Elementary Data Structures Array Lists Array Lists Dale.
Text Chapters 2 Analyzing Algorithms.  goal: predicting resources that an algorithm requires memory, communication bandwidth, hardware, memory, communication.
Onlinedeeneislam.blogspot.com1 Design and Analysis of Algorithms Slide # 1 Download From
Data Structure and Algorithms
ARRAYS IN C/C++ (1-Dimensional & 2-Dimensional) Introduction 1-D 2-D Applications Operations Limitations Conclusion Bibliography.
Mohammed I DAABO COURSE CODE: CSC 355 COURSE TITLE: Data Structures.
Introduction toData structures and Algorithms
Understanding Algorithms and Data Structures
Set Collection A Bag is a general collection class that implements the Collection interface. A Set is a collection that resembles a Bag with the provision.
September 29 – Stacks and queues
Data Structure Interview Question and Answers
Chapter 15 Lists Objectives
Ch. 8 File Structures Sequential files. Text files. Indexed files.
Data Structures Interview / VIVA Questions and Answers
Hashing Exercises.
structures and their relationships." - Linus Torvalds
Chapter 1.
structures and their relationships." - Linus Torvalds
Introduction to Data Structures
Introduction to Data Structure
Important Problem Types and Fundamental Data Structures
structures and their relationships." - Linus Torvalds
Presentation transcript:

Data Structures and Algorithms

2

3 Outline What is a data structure Examples –elementary data structures –hash tables Computer capabilities What is an algorithm Pseudocode/examples –naïve alignment (and debugging)

4 Data Structures Informal definition: an organization of information, usually in computer memory, to improve or simplify algorithm performance. Associated data structure algorithms typically exist to maintain the properties of data structures (search, insert, delete, push, pop, etc.)

5 Data Structures Elementary data structures –arrays linear replication of a data type useful for holding related items of identical type multi-dimensional conceptually, naturally maps to computer memory –Abstractions -- stacks and queues

6 Arrays – allocation of space An array of chars (bytes): A A A T G C T G A T An array of integers:

7 Languages In high level language such as C, data types are declared: int a, b, c; c = a+b; Perl: $c=$a+$b; Note that Perl does not require the specification of data type (however, as we will see later, this is useful for rapid prototyping, but can also be conducive to programming mistakes)

8 Examples of C/Perl arrays C: char Dna[6]; char tissue[4][6]; Dna[0] = 'A'; Dna[1] = 'A'; strcpy(tissue[0],"liver"); strcpy(tissue[1],"kidney"); = (A, A, A, T, C, = (“liver”, “kidney”, “heart”, “brain”); $tissue[0]=“liver”; $tissue[1]=“kidney”;

9 Java char myArray[]; // Note how the type declaration is de- coupled from the memory allocation myArray = new char[10]; myArray[0]='A';

10 Stack Example push 15 push 6 push 9 push 2 pop returns 2 LIFO

11 Queue Example Enqueue(15) Enqueue(6) Enqueue(9) Enqueue(2) DeQueue returns 15 FIFO

12 Linked List A linked list is a data structure in which the objects are arranged in a linear order, however, the order is encoded within the data structure itself by a “pointer” (as opposed to array indices). “dynamic” “sparse”

13 Linked List

14 Hash Table or Associative Array A hash table is similar to an array, in that it is a linear collection of data types, with individual elements selected by some index value (key). Unlike arrays, the index values (keys) are arbitrary. “hash function” maps keys to elements do not have to search for values, but there is overhead of “hash function” O(1) to examine an arbitrary position

15 Array VS Hash Keys Values

16 Hash Table Example %aminos = ( "TTT", "F", # Key Value pairs "TTC", "F", "TTA", "L", "TTG", "L", "CTT", "L", "CTC", "L", "CTA", "L", "CTG", "L", "ATT", "I", "ATC", "I", "ATA", "I", "ATG", "M", "GTT", "V", "GTC", "V", "GTA", "V", "GTG", "V", "TCT", "S", "TCC", "S", "TCA", "S", "TCG", "S“)

17 Objects or Records Complicated extensions drug_target –study_id –clone –date –gene_identity –id_technique –cell_source –pathology –special_conditions –regulation –confirmation_diff_expr ession –ocular_expr_profile –cytogenetics –genotyping_status –priority –reference

Data Structures and Abstraction 18 Data Objects API Objects Applications Communication and Data Sharing

19 What computers/software can and cannot do Can –simple (a=a+1) –fast (1 instruction in 1*10-9 s) –repetitive Cannot –associate (a cloud looks like Mickey Mouse) –vision –however, we can define sets of rules that can stratify (becomes very complicated and difficult) –algorithms (computers) are black and white, and the world is gray

20 Algorithms Informally, an algorithm is any well-defined computational procedure that takes some value, or set of values, as input and produces some value, or set of values, as output. –finite set of steps, one or more operations per step –An algorithm is correct if, for every input instance, it halts with the correct output. –Example: sorting Input: A sequence of n numbers (a1, a2, ….,an). Output: A permutation (reordering) (a1’, a2’, …,an’) of the input sequence such that a1’<=a2’<=…<=an’.

21 Algorithms How to validate? –Mathematically prove (usually impractical) –Case base proving/testing How to devise? –mimic a human procedure –follow a template –create How to analyze? –complexity analysis –profiling

22 Pseudocode An abstract, informal representation of algorithms as computational operations that is similar to C, Pascal, Perl (or other programming languages). Examples: –naïve sequence search/alignment –insertion sort (sort a hand of cards)

23 Naïve Alignment ATC AAATCG NO ATC AAATCG NO ATC AAATCG YES

24 Algorithms-- naïve alignment -- first try Example – naïve sequence search and alignment –align some small number (10 nucleotides) -- called the "query" to some large number (3 billion nts) -- called the "subject" –10 s with BLAT (uses significantly more efficient algorithm) snt[] = array of subject nucleotides qnt[] = array of query nucleotides for i = 0 to length(query) #i will be index for query sequence j=0 while (snt[i + j ] == qnt[j])# but here, j is index for query sequence??? j=j+1 if (j == length (query)) found sequence at position i end query = ATC subject = AAATCG

25 Algorithms- Refinement snt[] = array of subject nucleotides qnt[] = array of query nucleotides for i = 0 to length(subject) – length(query) j=0 while (snt[i + j ] == qnt[j]) j=j+1 if (j == length (query)) found sequence at position i end query = ATC subject = AAATCG Modern machine could do this, but what if query, subject are 100 nucleotides, and 30 billion? This can be done, but it will not scale to 100 seconds, because you can no longer hold 30 billion nucleotides in memory. You will have to swap portions of the 30 billion back to disk, and read in a new portion This overhead will adversely affect the performance of the algorithm

26 Naïve Alignment ATC AAATCG NO ATC AAATCG NO ATC AAATCG YES j=0 i=0 j=0 i=1 j=1 snt[] = array of subject nucleotides qnt[] = array of query nucleotides for i = 0 to length(subject) – length(query) j=0 while (snt[i + j ] == qnt[j]) j=j+1 if (j == length (query)) found sequence at position i end

27 End