1 / 42

Data Structures & Algorithms

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++ 2008. Exponents الاس (القوى)

tender
Télécharger la présentation

Data Structures & Algorithms

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Data Structures &Algorithms Week1

  2. Contents • Textbook • Grade • Software

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

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

  5. software • Visual C++ 2008

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

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

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

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

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

  11. Determine the value of x in the following equation. اوجدي قيمة X في المعادلة التالية : log7 x + log713 = 3 Determine the value of x in the following equation. اوجدي قيمة X في المعادلة التالية : log8 4 - log8 x = log8 5 + log16 6 Logarithm practice problemsتدريبات على اللوغاريتمات Data Structures

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

  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)= 1 + 3 + 5 + 7 + 9= 25 Math review: Arithmetic seriesمراجعة رياضية : السلاسل الحسابية Data Structures

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

  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. More series identitiesالمزيد من متطابقات السلاسل : Data Structures

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

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

  18. sum of powers of 2 مجموع قوى الـ 2 1 + 2 + 4 + 8 + 16 + 32 = 64 - 1 = 63 when the series doesn't start at 0: عندما لاتبدا السلاسل بالصفر Geometric Seriesالسلاسل الهندسية Data Structures

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

  20. 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.

  21. 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.

  22. 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.

  23. Basic Data Structures • Structures include • linked lists • Stack, Queue • binary trees • …and others

  24. 2 4 6 1 3 5 7 1 2 3 4 5 6 7 What is Algorithm? • Algorithm: • A computable set of steps to achieve a desired result • Ralationship to Data Structure • Example: Find an element

  25. Sumary

  26. 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 لانها مبنية وجاهزة في اللغة ولكن المثال لتقريب المعنى ADT Data Structures

  27. Chapter 0: C LANGUAGE • ADDRESS • POINTERS • ARRAYS • PASS ARRAY TO FUNCTION • ADDRESS OF EACH ELEMENT IN AN ARRAY • ACCESSING & MANIPULATING AN ARRAY USING POINTERS • TWO-DIMENSIONAL ARRAY • POINTER ARRAYS • STRUCTURES • STRUCTURE POINTERS

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

  29. Chapter 0: C LANGUAGE 2. POINTERS • is a variable whose value is also an address. • 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

  30. 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);

  31. 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 &.

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

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

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

  35. Chapter 0: C LANGUAGE العلاقة مابين المصفوفات والمؤشرات (relation between array and pointer) يمكن الوصول الى عناصر المصفوفة باستخدام المؤشرات ملاحظة مهمة / اسم المصفوفة هو عبارة عن مؤشر ثابت يشير الى اول عنصر في المصفوفة 6. ACCESSING & MANIPULATINGAN 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

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

  37. 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. مصفوفة المؤشرات : هي عبارة عن مصفوفة عناصرها عبارة عن مؤشرات لقيم في الذاكرة أي ان عناصر المصفوفة تحتوي عناوين .

  38. 8. POINTER ARRAYS

  39. 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

  40. Chapter 0: C LANGUAGE

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

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

More Related