0% found this document useful (0 votes)
11 views10 pages

تلخيص

Uploaded by

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

تلخيص

Uploaded by

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

Best case Average Worst case

case
Bubble sort O(n) O(n2) O(n2)
Selection sort O(n2) O(n2) O(n2)
Insertion sort O(n) O(n2) O(n2)
Merge sort O(n logn) O(n logn) O(n logn)
Quick sort O(n logn) O(n logn) O(n2)
The worst-case time complexity of Quick Sort is________.
A. O(n2)
B. O(log n)
C. O(n)
d. O(n logn)

The best-case time complexity of merge Sort is________.


A. O(n2)
B. O(log n)
C. O(n)
d. O(n logn)
Question
Based on Master Theorem, find the order of growth for solutions of the following
recurrences and indicate the class name T(n) belongs to (if exist):

A) T(n) = T(n/2) + 3n+9, T(n)ϵ ?


B) T(n)= 16 T(n/4)+n3+5n2+9 T(n)ϵ ?
C) T(n)= 3T(n/3)+5n+2 T(n)ϵ ?
D) T(n)= 9 T(n/3)+7n2+1 T(n)ϵ ?
E) T(n)= 16 T(n/4) T(n)ϵ ?
Time Complexity of Breadth First Search is? (V – number of vertices, E –
number of edges)

a) O(V + E)
b) O(V)
c) O(E)
d) O(V*E)
The Data structure used in standard implementation of Breadth First
Search is?
a) Stack
b) Queue
c) Linked List
d) Tree

Breadth First Search is equivalent to which of the traversal in the Binary


Trees?
a) Pre-order Traversal
b) Post-order Traversal
c) Level-order Traversal
d) In-order Traversal

How many cases are there under Master’s theorem?


a) 2
b) 3
c) 4
d) 5

Solve the following recurrence using Master’s theorem.


T(n) = 4T (n/2) + n2
a) T(n) = O(n)
b) T(n) = O(log n)
2
c) T(n) = O(n log n)
d) T(n) = O(n2)
THIS diagram is AVL tree property?

A) TRUE
B) FALSE
THIS diagram is AVL tree property?

A)TRUE
B) FALSE

THIS diagram is AVL tree property?

A)TRUE
B) FALSE

THIS diagram is AVL tree property?

A)TRUE
B) FALSE
THIS diagram is AVL tree property?
THIS diagram is AVL tree property?

A)TRUE
B)FALSE

Preorder  root - left - right


Inorder - left - root - right
Postorder - left -right -root

The main measure for efficiency algorithm are


a) Processor and Memory
b) Complexity and Capacity

c) Time and space

1- For the following program gives Big O analysis of the running time.
For (i=0; i<n*n*n; i++)
A[i] = i+2;
a) O(n)
b) O(n2)
c) O(log n)
d) O(n3)

For the following program gives Big O analysis of the running time.
For (i=0; i< n; i++)
For (j=i; j< n; j++)
For (k=j; k< n; k=k/2)
S++;
a) O(n-1)
b) O(n2)
c) O(n3)
d) O(n2 log n)

- For each of the following functions, indicate the class Θ(g(n)) the function
belongs to n(n + 1) / 2
g(n)=.................................

A. linear
B. Quadratic
C. cubic
D. factorial

13- For each of the following functions, indicate the class Θ(g(n)) the function
belongs to 2000 n3 + 3/ 2
g(n)=.................................

A. linear
B. exponential
C. cubic
D. factorial

14- For each of the following functions, indicate the class Θ(g(n)) the function
n
belongs 150! +2 +50
g(n)=.................................

A. cubic
B. exponential
C. Constant
D. factorial

15- For each of the following functions, indicate the class Θ(g(n)) the function
belongs 5! + 2 log n +100
g(n)=.................................

A. logarithmic
B. exponential
C. Constant
D. factorial

16- For each of the following functions, indicate the class Θ(g(n)) the function
3
Belongs to 8! +2
g(n)=.................................

A. cubic
B. exponential
C. Constant
D. linear

n3 + 2n2+100 ∈ Θ(n2).
a) True
b) False
2n+ 5 n3 ∈ Ω(n!)

a) True
b) False

2n+ 5 n3 ∈ O(n!)
a) True
b) False

nlog n+ 5 n ∈ Ω(n+5)

a) True
b) False

You might also like