0% found this document useful (0 votes)
8 views

Data Structue Sec 1

Uploaded by

aboalianamedo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Data Structue Sec 1

Uploaded by

aboalianamedo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Notes and Tricks

of Sec 1 Data
Structure:
Things affects program speed:
1-Space Complexity: Not in our topic currently.
2-Time Complexity: Represents it Big O Notation that refers to
O -as a function for defining algorithm time- in Order of (‫)بداللة‬
an input size (As: number of array's elements)
________________________________

Note: Big O expresses the worst case or upper bound of


time for performing the program-->
‫متشائم دايمًا‬
‫وبياخد أسوأ حالة البرنامج وصل فيها للحل أو حقق النتيجة الصح‬
Important functions for defining
more efficient( faster)in
performance:
1-O(1):Refers to constant functions that input size don’t affect it .
2-O(log n): in product and division cases in counter of loops(for,while,…).
3-O(n)=O(n/2)=O(2n)=O(kn+x) such as k and x are: constants--> ‫أكبر ُأس‬
‫ بغض النظر عن الثوابت ألن بيتجاهل الثوابت في هذه‬1 ‫في الدالة كلها هو‬
‫ الحاالت‬Big O
4-O(nlog n): Log-Linear function .
5-O(n^2): Quadratic function .
6-O(n^3):Cubic function and other polynomials such by increasing
exponent degree the time increase and speed decrease.
7-O(2^n):Exponential function.
8-O(n!):Factorial function--->
‫ في الحالة دي ماتعملش‬Algorithm ‫أفضل‬
Notes:

1- All of previous, we opposite it in case of defining the


more in time.
2- In calculating Big O, We don't be interested in declaration of
variables and printing statements --> As example:
int I;//no time as it is declartion
I=1;// time =1 unit as it is performed in one step.
for (I;I<n;I++){// done for n-times by increase 1 in every step.
cout<< I;}// no time as it is printing statement.

-->The total time complexity=1+n but Big O = O(n)-->Worst


case or upper bound in time(n>1 in time).
Notes:
Operations like: % * ^ + - -- ++ = *= += -= /=
/ > < >= <= !=
Condition : if else else if
Statement "return" .
All of these take Constant Time (1 unit of
time).
Nested loops--> multiply time of
n(‫ )عددهم‬nested-loop.
Unnested loops--> summtion of n loops.
I*=2--> Big O =log n for base 2 --> log n for
base: ‫المضروب فيه أو المقسوم عليه‬
I/=4--> Big O =log n for base 4 --> log n for
base: ‫المصروب فيه أو المقسوم عليه‬
for(I=n/2;I<n;I++)//explain this line in this case:
n/2+n+n =n -->O(n(
Thank you

Fatma Alzahraa Salama


‫‪Most‬‬
‫‪important‬‬
‫‪note:‬‬
‫المالحظات دي فقط توضيحات‬
‫لمعلومات تكاد تكون فيها نسبة إبهام‬
‫في السيكشن الخاص بمهندسة‬
‫نورهان لكن قبل ما تتجه ليها‪،‬‬
‫اسمع السيكشن كويس أوًال واقرأ‬
‫الملف المرفق معاه‬

You might also like