Docsity

Data Structures-Algorithms and Data Structures-Lecture Slides, Slides of Data Structures and Algorithms

Partial preview of the text

Download Data Structures-Algorithms and Data Structures-Lecture Slides and more Slides Data Structures and Algorithms in PDF only on Docsity!

7/7/2012 Introduction 1-

Welcome to EE 232

Data Structures

Kashif Javed [email protected] Department of Electrical Engineering UET Lahore

Introduction 1-

EE 232, Data Structures

Text Book:  Mark Allen Weiss, “Data Structures and Algorithm Analysis in C” , 2 nd^ Edition, Pearson Education

Reference Books:  Robert Sedgewick, “Algorithms in C”, 3 rd^ Edition, Pearson Education

 Cormen, Leiserson, Rivest, Stein, “Introduction to Algorithms”, 2 nd^ Edition, McGraw-Hill

7/7/2012 docsity.com

  • 7/7/2012 Introductiondocsity.com 1-

7/7/2012 Introduction 1-

Prerequisites

 Computer Fundamentals

 C language programming

  • Functions, Pointers, Arrays , Structures, Recursion

 Editors, Compilers , Linkers, Debuggers  User-level knowledge of Operating Systems

  • Windows
  • Linux

 Elementary Calculus and Algebra

7/7/2012 Introduction 1-

First some course terminology

 An algorithm is a well-defined computational procedure that takes some values, as input and produces some value, or set of values, as output

 Computing time of an algorithm and the space it requires in the memory determine its efficiency

 These are bounded resources and therefore should be used wisely

7/7/2012 Introduction 1-

Course Objectives

This course will help the students

 To understand the fundamental ways of organizing collections of data to be processed by a program  focus is on main-memory data structures

 To evaluate the efficiency of data structures and their algorithms

 To define, implement and use Abstract Data Types (ADTs)

7/7/2012 Introduction 1-

Chapter 1

Introduction

EE 232 Data Structures Session-05 , Spring-

7/7/2012 Introduction 1-

Chapter 1: Introduction

Our goals: we shall

 discuss the aims and goals of this course and briefly review programming concepts

 summarize the basic mathematical background

 also briefly review recursion

7/7/2012 Introduction 1-

What's the book about?

Selection Problem  Given a list of N numbers, determine the k th largest, where kN

 Algorithm 1

  • Read N numbers into an array
  • Sort the array in decreasing order by some simple algorithm
  • Return the element in position k

7/7/2012 Introduction 1-

What's the book about?...

 Algorithm 2

  • Read the first k elements into an array and sort them in decreasing order
  • Each remaining element is read one by one
    • If smaller than the kth element, then it is ignored
    • Otherwise, it is placed in its correct spot in the array, bumping one element out of the array
  • The element in the kth position is returned as the answer

7/7/2012 Introduction 1-

What's the book about?...

 We will learn

 How to estimate the running time of a program for large inputs

 How to compare the running times of two programs without actually coding them

 Techniques for drastically improving the speed of a program

 Techniques for determining program bottlenecks

7/7/2012 Introduction 1-

Chapter 1: roadmap

1.1 What’s the book about?

1.2 Mathematics review

1.3 A Brief Introduction to Recursion

7/7/2012 Introduction 1-

Mathematics review…

Properties of logarithms

 logAB = ; A,B,C > 0 , A  1

log AB = log A + log B ; A, B > 0log(A/B) = log(A) - log(B)log(AB) = B log(A)log(X) < X for all X > 0log(1)=0, log(2)=1, log(1,024)=10,log(1,048,576)=

logC B logC A

7/7/2012 Introduction 1-

Mathematics review…

Geometric Series

  2 i^ = 2 N+1^ - 1

i=0..N

  Ai^ =

i=0..N

 If 0 < A < 1,  Ai 

i=0..N

 If N   ,  Ai^ =

i=0..N

AN+1^ - 1
A - 1
A - 1
A - 1