Data Structures & Algorithms Week1. Contents Textbook Grade Software.

Slides:



Advertisements
Similar presentations
Introduction to Programming Lecture 15. In Today’s Lecture Pointers and Arrays Manipulations Pointers and Arrays Manipulations Pointers Expression Pointers.
Advertisements

Engineering Problem Solving with C Fundamental Concepts Chapter 6 Pointers.
Kernighan/Ritchie: Kelley/Pohl:
CSSE 332 Functions, Pointers in C. 2 Functions - why and how ? If a problem is large If a problem is large Modularization – easier to: Modularization.
This set of notes is adapted from that provided by “Computer Science – A Structured Programming Approach Using C++”, B.A. Forouzan & R.F. Gilberg, Thomson.
Divide-and-Conquer1 7 2  9 4   2  2 79  4   72  29  94  4.
1 TCSS 342, Winter 2005 Lecture Notes Course Overview, Review of Math Concepts, Algorithm Analysis and Big-Oh Notation Weiss book, Chapter 5, pp
1 ES 314 Advanced Programming Lec 2 Sept 3 Goals: Complete the discussion of problem Review of C++ Object-oriented design Arrays and pointers.
The Distributive Property
CSE 373 Data Structures and Algorithms Lecture 4: Asymptotic Analysis II / Math Review.
Pointers (Continuation) 1. Data Pointer A pointer is a programming language data type whose value refers directly to ("points to") another value stored.
TCSS 342 Lecture Notes Course Overview, Review of Math Concepts,
CSE 373: Data Structures and Algorithms Lecture 4: Math Review/Asymptotic Analysis II 1.
Chapter 10 Review: Matrix Algebra
Divide-and-Conquer 7 2  9 4   2   4   7
Data Structures Lecture 1: Introduction Azhar Maqsood NUST Institute of Information Technology (NIIT)
Exponential & Logarithmic Equations MATH Precalculus S. Rook.
Logarithmic and Exponential Equations
Data Structures Week 5 Further Data Structures The story so far  We understand the notion of an abstract data type.  Saw some fundamental operations.
1 CE 221 Data Structures & Algorithms Chapter 1 Introduction Text: Read Weiss, §1.1 – 1.3 Izmir University of Economics.
1 Pointers in C. 2 Pre-requisite Basics of the C programming language Data type Variable Array Function call Standard Input/Output e.g. printf(), scanf()
Chapter 1 Introduction. Goals Why the choice of algorithms is so critical when dealing with large inputs Basic mathematical background Review of Recursion.
The Distributive Property allows you to multiply each number inside a set of parenthesis by a factor outside the parenthesis and find the sum or difference.
Recursion Textbook chapter Recursive Function Call a recursive call is a function call in which the called function is the same as the one making.
Chapter 9 Pointers Fall 2005 Csc 125 Introduction to C++
Pointers Chapter 9. Getting The Address Of A Variable Each variable in program is stored at a unique address Use address operator & to get address of.
Computer Science Department Data Structure & Algorithms Lecture 8 Recursion.
COMP2012 Object-Oriented Programming and Data Structures Fall 2015.
1 INTRODUCTION TO PROBLEM SOLVING AND PROGRAMMING.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 11 Structured Data.
CSC 107 – Programming For Science. Today’s Goal  When lecture over, start understanding pointers  What a pointer is and what it is not  Why pointers.
Mathematical Background and Linked Lists. 2 Iterative Algorithm for Sum Find the sum of the first n integers stored in an array v : sum (v[], n) temp_sum.
Data Structures Lecture 1: Introduction. Course Contents Data Types   Overview, Introductory concepts   Data Types, meaning and implementation  
CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis Nicki Dell Spring 2014.
Data Structures and Algorithm Analysis Introduction Lecturer: Ligang Dong, egan Tel: , Office: SIEE Building.
1 Chapter 7 Arrays. 2 Topics 7.1 Arrays Hold Multiple Values 7.2 Accessing Array Elements 7.3 No Bounds Checking in C Array Initialization 7.5 Processing.
Review 1 List Data Structure List operations List Implementation Array Linked List.
Functions: Part 2 of /11/10: Lecture 16 CMSC 104, Section 0101 John Y. Park 1.
CSE 373: Data Structures and Algorithms
Solving Logarithmic Equations
CSE 373: Data Structures and Algorithms Lecture 4: Math Review/Asymptotic Analysis II 1.
1 2/2/05CS250 Introduction to Computer Science II Pointers.
1 CSE 373 Algorithm Analysis and Runtime Complexity slides created by Marty Stepp ©
ENEE150 – 0102 ANDREW GOFFIN More With Pointers. Importance of Pointers Dynamic Memory (relevant with malloc) Passing By Reference Pointer Arithmetic.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the relationship between arrays and pointers ❏ To understand the.
Array Size Arrays use static allocation of space. That is, when the array is created, we must specify the size of the array, e.g., int[] grades = new int[100];
C++ Programming Lecture 14 Arrays – Part I The Hashemite University Computer Engineering Department (Adapted from the textbook slides)
REEM ALMOTIRI Information Technology Department Majmaah University.
TCSS 342 Autumn 2004 Version TCSS 342 Data Structures & Algorithms Autumn 2004 Ed Hong.
ARRAYS IN C/C++ (1-Dimensional & 2-Dimensional) Introduction 1-D 2-D Applications Operations Limitations Conclusion Bibliography.
Simplifying Algebraic Expressions 11-1 Warm Up Simplify  20     
Pointers. Addresses in Memory Everything in memory has an address. C allows us to obtain the address that a variable is stored at. scanf() is an example.
A FIRST BOOK OF C++ CHAPTER 8 ARRAYS AND POINTERS.
Pointers. Addresses in Memory Everything in memory has an address. C allows us to obtain the address that a variable is stored at. scanf() is an example.
Functions and Pointers Dr. Sajib Datta Oct 6, 2014.
CS Class 04 Topics  Selection statement – IF  Expressions  More practice writing simple C++ programs Announcements  Read pages for next.
CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis Linda Shapiro Winter 2015.
6 th grade Math Vocabulary Word, Definition, Model Emery UNIT 2.
Pointers A variable that holds an address value is called a pointer variable, or simply a pointer.  What is the data type of pointer variables? It’s not.
Data Structures Dr. Abd El-Aziz Ahmed Assistant Professor Institute of Statistical Studies and Research, Cairo University Springer 2015 DS.
The Distributive Property
Algebra.
Functions and Pointers
© 2016 Pearson Education, Ltd. All rights reserved.
CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis Catie Baker Spring 2015.
Functions and Pointers
Distributive Property
CSE 373: Data Structures & Algorithms
Warm Up Simplify      20  2 3.
Introduction to Pointers
Presentation transcript:

Data Structures & Algorithms Week1

Contents Textbook Grade Software

Textbook C & Data Structures – P. S. Deshpande, O. G. Kakde

Grade Midterm test (20%) Final test (50%) Quizzes (25%) Attendance (5%)

software Visual C

Math background: Exponents مراجعة لبعض الخصائص الرياضية : الاسس 6 Exponents الاس (القوى) – X Y, or "X to the Y th power"; X multiplied by itself Y times (الـ X تُضرب في نفسها y مرة) Some useful identities (بعض المتطابقات المفيدة ) – X A X B = X A+B – X A / X B = X A-B – (X A ) B = X AB – X N +X N = 2X N – 2 N +2 N = 2 N+1 Fall 2010Data Structures

Math background: Logarithms مراجعة لبعض الخصائص الرياضية: اللوغاريتمات 7 Logarithms (اللوغاريتمات) – definition: X A = B log X B = A تعريف : X A = B اذا وفقط اذا كان log X B = A – intuition: log X B means: "the power must raised X to it, to get B" بديهيا ً: log X B تعني : القوة التي يجب ان نرفع X اليها حتى يعطينا B. – In this course, a logarithm with no base implies base 2. log B means log 2 B في هذا الكورس, اللوغاريتمات المكتوبة بدون اساس تعني الاساس 2 log B تعني log 2 B Examples – log 2 16 = 4(because 2 4 = 16) – log = 3(because 10 3 = 1000) Fall 2010Data Structures

Properties of Logarithms (خصائص اللوغاريتمات) 8 Identities for logs with addition, multiplication, powers: متطابقات اللوغاريتمات للجمع والضرب والاسس : log (AB) = log A + log B log (A/B) = log A – log B log (A B ) = B log A Fall 2010Data Structures

Data Structures - Introduction 9 Identity for converting bases of a logarithm: متطابقة لتحويل اساسات اللوغاريتمات : – example: log 4 32 = (log 2 32) / (log 2 4) = 5 / 2 Properties of Logarithms خصائص اللوغاريتمات))

Logarithm problem solving (استخدام اللوغاريتمات لحل المشاكل) 10 When presented with an expression of the form: – log a X = Y and trying to solve for X, raise both sides to the a power. – X = a Y When presented with an expression of the form: عند عرض تعبير رياضي بالشكل التالي : log a X = log b Y and trying to solve for X, find a common base between the logarithms using the identity on the last slide. لايجاد قيمة X, نحاول ايجاد اساس مشترك ما بين اللوغاريتمات باستخدام المتطابقة الموجودة في الشريحة السابقة – log a X = log a Y / log a b Fall 2010Data Structures

Logarithm practice problems تدريبات على اللوغاريتمات 11 Determine the value of x in the following equation. اوجدي قيمة X في المعادلة التالية : log 7 x + log 7 13 = 3 Determine the value of x in the following equation. اوجدي قيمة X في المعادلة التالية : – log log 8 x = log log 16 6 Fall 2010Data Structures

Data Structures - Introduction 12 Proof that 16n 3 log 8 (10n 2 ) + 100n 2 = O(n 3 log n) – Eliminate low-order terms – Eliminate constant coefficients 16n 3 log 8 (10n 2 ) + 100n 2  16n 3 log 8 (10n 2 )  n 3 log 8 (10n 2 )  n 3 (log 8 (10) + log 8 (n 2 ))  n 3 log 8 (10) + n 3 log 8 (n 2 )  n 3 log 8 (n 2 )  2n 3 log 8 (n)  n 3 log 8 (n)  n 3 log 8 (2)log(n)  n 3 log(n)/3  n 3 log(n) Logarithm practice problems تدريبات على مشاكل اللوغاريتمات

Math review: Arithmetic series مراجعة رياضية : السلاسل الحسابية 13 Series – for some expression Expr (possibly containing i ), means the sum of all values of Expr with each value of i between j and k inclusive الرمز يعني مجموع القيم الناتجة من التعبير الرياضي Expr بالتعويض بقيم i والتي تبدا من j وتنتهي بالـ K Example: = (2(0) + 1) + (2(1) + 1) + (2(2) + 1) + (2(3) + 1) + (2(4) + 1) = = 25 Fall 2010Data Structures

Series identities متطابقات السلاسل 14 Arithmetic Series is there an intuition for this identity? – sum of all numbers from 1 to N (N-2) + (N-1) + N – how many terms are in this sum? Can we rearrange them? Fall 2010Data Structures

More series identities المزيد من متطابقات السلاسل : 15 sum from a through N inclusive (when the series doesn't start at 1) مجموع القيم مابين a و N (في حالة السلاسل التي لاتبدا بـ 1) is there an intuition for this identity? – The sum of all numbers from 4 to 10 is just the sum of all numbers from 1 to 10, minus the sum of 1 through 3. Fall 2010Data Structures

Series of constants سلاسل الثوابت 16 sum of constants (when the body of the series doesn't contain the counter variable such as i) مجموع القيم الثابتة (عندما يكون جسم السلسلة لايحتوي على متغير عداد, مثلا i) example: Fall 2010Data Structures

Splitting series السلاسل المجزاة 17 for any constant k, splitting a sum with addition تجزئة التجميع باستخدام + moving out a constant multiple تحريك المضروب الثابت الى الخارج Fall 2010Data Structures

Geometric Series السلاسل الهندسية 18 sum of powers of 2 مجموع قوى الـ 2 – = = 63 when the series doesn't start at 0: عندما لاتبدا السلاسل بالصفر Fall 2010Data Structures

Series practice تدريبات على السلاسل 19 Solve each of the following summation. – i.e Find the expression without the  or "…". Fall 2010Data Structures

CHAPTER 0: INTRODUTION What is Data Structures? – A data structure is defined by (1) the logical arrangement of data elements, combined with (2) the set of operations we need to access the elements.

Atomic Variables Atomic variables can only store one value at a time. int num; float s; A value stored in an atomic variable cannot be subdivided.

What is Data Structures? Example:library – is composed of elements (books) – Accessing a particular book requires knowledge of the arrangement of the books – Users access books only through the librarian the logical arrangement of data elements, combined with the set of operations we need to access the elements.

Basic Data Structures Structures include – linked lists – Stack, Queue – binary trees – …and others

What is Algorithm? Algorithm: – A computable set of steps to achieve a desired result – Ralationship to Data Structure Example: Find an element

Sumary

ADT ADT = Abstract Data Types ADT is A logical view of the data objects together with specifications of the operations required to create and manipulate these objects. ADT=user-defined data taype بمعنى االمبرمج هو الذي يبنيها تبعا لاحتياجاته مثال int لا يعتبر ADT لانها مبنية وجاهزة في اللغة ولكن المثال لتقريب المعنى Fall Data Structures

Chapter 0: C LANGUAGE 1. ADDRESS 2. POINTERS 3. ARRAYS 4. PASS ARRAY TO FUNCTION 5. ADDRESS OF EACH ELEMENT IN AN ARRAY 6. ACCESSING & MANIPULATING AN ARRAY USING POINTERS 7. TWO-DIMENSIONAL ARRAY 8. POINTER ARRAYS 9. STRUCTURES 10. STRUCTURE POINTERS

Chapter 0: C LANGUAGE 1. ADDRESS For every variable there are two attributes: address and value cout << "Value of 'y' is: " << y << "\n"; cout << "Address of 'y' is: " << &y << "\n\n"; In memory with address 3: value: 45. In memory with address 2: value "Dave"

Chapter 0: C LANGUAGE 2. POINTERS 1. is a variable whose value is also an address. 2. A pointer to an integer is a variable that can store the address of that integer ia: value of variable &ia: address of ia *ia means you are printing the value at the location specified by ia

Chapter 0: C LANGUAGE int i; //A int * ia; //B printf("The address of i is %p\n", &i); printf("The address of ia is %p\n", &ia); i = 10; //C ia = &i; //D printf("after assigning value:\n"); printf("The address of i is %p value= %d\n", &i,i); printf("The address of ia is %p value= %p point to %d\n", &ia,ia,*ia);

Chapter 0: C LANGUAGE Points to Remember Pointers give a facility to access the value of a variable indirectly. You can define a pointer by including a * before the name of the variable. You can get the address where a variable is stored by using &.

Chapter 0: C LANGUAGE 3. ARRAYS 1. An array is a data structure 2. used to process multiple elements with the same data type when a number of such elements are known. 3. An array is a composite data structure; that means it had to be constructed from basic data types such as array integers. 1. int a[5]; 2. for(int i = 0;i<5;i++) 1. {a[i]=i; }

Chapter 0: C LANGUAGE 4. نستطيع تمرير المصفوفة كمعامل في الدالة 4. WE CAN PASS ARRAY AS ARGUMNET IN A FUNCTION

Chapter 0: C LANGUAGE 5. عناوين عناصر المصفوفة 5. ADDRESS OF EACH ELEMENT IN AN ARRAY Each element of the array has a memory address.

Chapter 0: C LANGUAGE العلاقة مابين المصفوفات والمؤشرات (relation between array and pointer) يمكن الوصول الى عناصر المصفوفة باستخدام المؤشرات ملاحظة مهمة / اسم المصفوفة هو عبارة عن مؤشر ثابت يشير الى اول عنصر في المصفوفة 6. ACCESSING & MANIPULATING AN ARRAY USING POINTERS – You can access an array element by using a pointer. – If an array stores integers->use a pointer to integer to access array elements. int a[5]; int *p; a=b; //error b=a; //OK

Chapter 0: C LANGUAGE 7. المصفوفة ذات البعدين. 7. TWO-DIMENSIONAL ARRAY int a[3][2];

Chapter 0: C LANGUAGE 8. POINTER ARRAYS You can define a pointer array (similarly to an array of integers). In the pointer array, the array elements store the pointer that points to integer values. مصفوفة المؤشرات : هي عبارة عن مصفوفة عناصرها عبارة عن مؤشرات لقيم في الذاكرة أي ان عناصر المصفوفة تحتوي عناوين.

8. POINTER ARRAYS

Chapter 0: C LANGUAGE 9. STRUCTURES Structures are used when you want to process data of multiple data types But you still want to refer to the data as a single entity Access data: structureveriable.membername

Chapter 0: C LANGUAGE

Chapter 1: C LANGUAGE 10. STRUCTURE POINTERS Process the structure using a structure pointer

End ملاحظة : الاسبوع القادم سيكون الكويز (1)