13. Question 2
■الصفوف في الموجودة اإلضافية الخاصية هي ما(classes)البنية في موجودة وليست
(struct)
A. Data members
B. Member functions
C. Static data allowed
D. Public access specifier
2020 By Eng. Joud Khattab
14. Question 2
■الصفوف في الموجودة اإلضافية الخاصية هي ما(classes)البنية في موجودة وليست
(struct)
A. Data members
B. Member functions
C. Static data allowed
D. Public access specifier
2020 By Eng. Joud Khattab
15. Question 3
■للصفوف األفضل التعريف هو ما(class)
A. Parent of an object
B. Instance of an object
C. Blueprint of an object
D. Scope of an object
2020 By Eng. Joud Khattab
16. Question 3
■للصفوف األفضل التعريف هو ما(class)
A. Parent of an object
B. Instance of an object
C. Blueprint of an object
D. Scope of an object
2020 By Eng. Joud Khattab
17. Note
What Is a Class? (الصف هو )ما
■ In the real world, you'll often find many individual objects all of the same kind.
■ There may be thousands of other bicycles in existence, all of the same make and
model.
■ Each bicycle was built from the same set of blueprints and therefore contains the
same components.
■ In object-oriented terms, we say that your bicycle is an instance of the class of
objects known as bicycles.
■ A class is the blueprint from which individual objects are created.
2020 By Eng. Joud Khattab
18. Question 4
■مفهوم على وتركز توضح التي التوجه غرضيه البرمجة في الموجودة الخاصية هي ما
البرمجة في االستخدام إعادة(reusability)
A. Polymorphism
B. Abstraction
C. Encapsulation
D. Inheritance
2020 By Eng. Joud Khattab
19. Question 4
■مفهوم على وتركز توضح التي التوجه غرضيه البرمجة في الموجودة الخاصية هي ما
البرمجة في االستخدام إعادة(reusability)
A. Polymorphism
B. Abstraction
C. Encapsulation
D. Inheritance
2020 By Eng. Joud Khattab
20. Question 6
■التغليف مفهوم لشرح المناسب التعريف هو ما(Encapsulation)
A. It is a way of combining various data members into a single unit
B. It is a way of combining various member functions into a single unit
C. It is a way of combining various data members and member functions into a
single unit which can operate on any data
D. It is a way of combining various data members and member functions that
operate on those data members into a single unit
2020 By Eng. Joud Khattab
21. Question 6
■التغليف مفهوم لشرح المناسب التعريف هو ما(Encapsulation)
A. It is a way of combining various data members into a single unit
B. It is a way of combining various member functions into a single unit
C. It is a way of combining various data members and member functions into a
single unit which can operate on any data
D. It is a way of combining various data members and member functions that
operate on those data members into a single unit
2020 By Eng. Joud Khattab
22. Question 7
■البعض؟ بعضها مع تتناسب التالية الميزات من أي
A. Inheritance and Encapsulation
B. Encapsulation and Polymorphism
C. Encapsulation and Abstraction
D. Abstraction and Polymorphism
2020 By Eng. Joud Khattab
23. Question 7
■البعض؟ بعضها مع تتناسب التالية الميزات من أي
A. Inheritance and Encapsulation
B. Encapsulation and Polymorphism
C. Encapsulation and Abstraction
D. Abstraction and Polymorphism
2020 By Eng. Joud Khattab
24. Note
OOP Features (التوجه غرضية البرمجة )خصائص
■ Abstraction ()التجريد
– Abstraction is a process where you show only “relevant” data and “hide”
unnecessary details of an object from the user.
■ Encapsulation ()التغليف
– Encapsulation is binding the data with the code that manipulates it. It keeps the
data and the code safe from external interference.
■ Inheritance ()الوراثة
– Inheritance is the mechanism by which an object acquires the some/all properties
of another object. It supports the concept of hierarchical classification.
■ Polymorphism ( تعدداألوجه )
– Polymorphism means to process objects differently based on their data type.
2020 By Eng. Joud Khattab
27. Note
Polymorphism
■ Overloading (Static Polymorphism)
– Overloading in simple words means more than one method having the same
method name that behaves differently based on the arguments passed while
calling the method.
■ Overriding (Dynamic Polymorphism)
– Overriding means a derived class is implementing a method of its super class.
The call to overridden method is resolved at runtime, thus called runtime
polymorphism.
2020 By Eng. Joud Khattab
30. Question 8
■الصفوف تدعم التي اللغة تسمي ماذا(classes)االشكال تعدد تدعم وال
(polymorphism)؟
A. Class based language
B. Procedure oriented language
C. Object based language
D. If classes are supported, polymorphism will always be supported
2020 By Eng. Joud Khattab
31. Question 8
■الصفوف تدعم التي اللغة تسمي ماذا(classes)االشكال تعدد تدعم وال
(polymorphism)؟
A. Class based language
B. Procedure oriented language
C. Object based language
D. If classes are supported, polymorphism will always be supported
2020 By Eng. Joud Khattab
33. Question 9
■ If data members are private, what can we do to access them from the class object?
A. Create public member functions to access those data members
B. Create private member functions to access those data members
C. Create protected member functions to access those data members
D. Private data members can never be accessed from outside the class
2020 By Eng. Joud Khattab
34. Question 9
■ If data members are private, what can we do to access them from the class object?
A. Create public member functions to access those data members
B. Create private member functions to access those data members
C. Create protected member functions to access those data members
D. Private data members can never be accessed from outside the class
2020 By Eng. Joud Khattab
35. Question 10
■التغليف مفهوم ينتهك التالية الخيارات من أي(encapsulation)دائما؟
A. Local variables
B. Global variables
C. Public variables
D. Array variables
2020 By Eng. Joud Khattab
36. Question 10
■التغليف مفهوم ينتهك التالية الخيارات من أي(encapsulation)دائما؟
A. Local variables
B. Global variables
C. Public variables
D. Array variables
2020 By Eng. Joud Khattab
37. Question 11
■للبناة ضروريا شرطا ليس يلي مما أي(constructor)؟
A. Its name must be same as that of class
B. It must not have any return type
C. It must contain a definition body
D. It can contains arguments
2020 By Eng. Joud Khattab
38. Question 11
■للبناة ضروريا شرطا ليس يلي مما أي(constructor)؟
A. Its name must be same as that of class
B. It must not have any return type
C. It must contain a definition body
D. It can contains arguments
2020 By Eng. Joud Khattab
39. Question 12
■ How many types of constructors are available for use in general (with respect to
parameters)?
A. 2
B. 3
C. 4
D. 5
2020 By Eng. Joud Khattab
40. Question 12
■ How many types of constructors are available for use in general (with respect to
parameters)?
A. 2
B. 3
C. 4
D. 5
2020 By Eng. Joud Khattab
41. Question 13
■ Default constructor must be defined, if parameterized constructor is defined and the
object is to be created without arguments.
A. True
B. False
2020 By Eng. Joud Khattab
42. Question 13
■ Default constructor must be defined, if parameterized constructor is defined and the
object is to be created without arguments.
A. True
B. False
2020 By Eng. Joud Khattab
43. Question 14
■ If class C inherits class B. And B has inherited class A. Then while creating the object
of class C, what will be the sequence of constructors getting called?
A. Constructor of C then B, finally of A
B. Constructor of A then C, finally of B
C. Constructor of C then A, finally B
D. Constructor of A then B, finally C
2020 By Eng. Joud Khattab
44. Question 14
■ If class C inherits class B. And B has inherited class A. Then while creating the object
of class C, what will be the sequence of constructors getting called?
A. Constructor of C then B, finally of A
B. Constructor of A then C, finally of B
C. Constructor of C then A, finally B
D. Constructor of A then B, finally C
2020 By Eng. Joud Khattab
52. Complexity (الخوارزميات )تعقيد
T(n)
n n n log n n2
n3
n4
n10
2n
10 .01s .03s .1s 1s 10s 10s 1s
20 .02s .09s .4s 8s 160s 2.84h 1ms
30 .03s .15s .9s s 810s 6.83d 1s
40 .04s .21s 1.6s s 2.56ms 121d 18m
50 .05s .28s s s 6.25ms 3.1y 13d
100 .1s .66s 10s 1ms 100ms 3171y 41013
y
103
1s 9.96s 1ms 1s 16.67m 3.171013
y 3210283
y
104
s 130s 100ms 16.67m 115.7d 3.171023
y
105
s 1.66ms 10s 11.57d 3171y 3.171033
y
106
ms 19.92ms 16.67m 31.71y 3.17107
y 3.171043
y
2020 By Eng. Joud Khattab
53. Complexity (الخوارزميات )تعقيد
Exercise
// a simple loop to calculate the sum of numbers in an array
int i , sum;
for (i = sum = 0; i<n ; i++)
sum += a[i];
2020 By Eng. Joud Khattab
54. Complexity (الخوارزميات )تعقيد
Rule
If a loop iterates for i = initial value to final value in step of 1
then:
Number of iterations of the loop = final value – initial value + 1
2020 By Eng. Joud Khattab
55. Complexity (الخوارزميات )تعقيد
Exercise
int i = 0;
int sum = 0;
while (i < n)
{
sum = sum + a[i];
i = i + 1;
}
The body of this loop is
executed for i = 0, 1, 2, … n-1.
Hence, it is executed
((n-1) – 0) + 1 = n times
Therefore, these 2
assignments are
executed n times
Answer: Number of Assignment Operations =
2 + n + n = 2n + 2
2
assignments
2020 By Eng. Joud Khattab
58. Complexity (الخوارزميات )تعقيد
Question 2
int power (int x, int y) {
int p = 1;
for (int i = 1; i<=y; i++) {
p = p*x; }
return p; }
int power2 (int x, int y) {
int res = 1;
int factor = x;
while (y>0) {
if (y%2==1)
res = res*factor;
factor = factor*factor;
y = y / 2; }
return res; }
2020 By Eng. Joud Khattab
84. Recursive Functions ( الخوارزمياتالعودية )
Question 8
What does the following function do?
int fun(int x, int y)
{
if (y == 0) return 0;
return (x + fun(x, y-1));
}
1. x+y
2. x+x*y
3. x*y
4. x^y
2020 By Eng. Joud Khattab
85. Recursive Functions ( الخوارزمياتالعودية )
Question 8
What does the following function do?
int fun(int x, int y)
{
if (y == 0) return 0;
return (x + fun(x, y-1));
}
1. x+y
2. x+x*y
3. x*y
4. x^y
2020 By Eng. Joud Khattab
88. Recursive Functions ( الخوارزمياتالعودية )
Question 10
Consider the following: f(5)
int fun (int n)
{
int x=1, k;
if (n==1) return x;
for (k=1; k<n; ++k)
x = x + fun(k) * fun(n – k);
return x;
}
1. 0
2. 26
3. 51
4. 71
2020 By Eng. Joud Khattab
89. Recursive Functions ( الخوارزمياتالعودية )
Question 10
Consider the following: f(5)
int fun (int n)
{
int x=1, k;
if (n==1) return x;
for (k=1; k<n; ++k)
x = x + fun(k) * fun(n – k);
return x;
}
1. 0
2. 26
3. 51
4. 71
2020 By Eng. Joud Khattab
90. Recursive Functions ( الخوارزمياتالعودية )
Question 11
If get(6) function is being called. how
many times will the get() function be
invoked?
void get (int n) {
if (n < 1) return;
get(n-1);
get(n-3);
printf("%d", n); }
1. 15
2. 25
3. 35
4. 45
2020 By Eng. Joud Khattab
91. Recursive Functions ( الخوارزمياتالعودية )
Question 11
If get(6) function is being called. how
many times will the get() function be
invoked?
void get (int n) {
if (n < 1) return;
get(n-1);
get(n-3);
printf("%d", n); }
1. 15
2. 25
3. 35
4. 45
get(6) [25 Calls]
/
[17 Calls] get(5) get(3) [7 Calls]
/
get(4) get(2) [5 Calls]
/
[7 Calls] get(3) get(1) [3 Calls]
/
get(2) get(0)
/
[3 Calls] get(1) get(-1)
/
get(0) get(-2)
2020 By Eng. Joud Khattab
100. Stack ()المكدس
■ Infix to Postfix:
1. Scan the infix expression from left to right.
2. If the scanned character is an operand, output it.
3. Else,
1. If the precedence of the scanned operator is greater or equal than the precedence of the operator
in the stack (or the stack is empty), push it.
2. Else, pop the operator from the stack until the precedence of the scanned operator is less-equal to
the precedence of the operator residing on the top of the stack. Then push the scanned operator to
the stack.
4. If the scanned character is an ‘(‘, push it to the stack.
5. If the scanned character is an ‘)’, pop and output from the stack until an ‘(‘ is encountered.
6. Repeat steps 2 to 6 until infix expression is scanned.
7. Pop and output from the stack until it is not empty.
2020 By Eng. Joud Khattab
101. Stack ()المكدس
■ Infix to Prefix:
1. Reverse the infix expression i.e A+B*C will become C*B+A.
■ Note while reversing each ‘(‘ will become ‘)’ and each ‘)’ becomes ‘(‘.
2. Obtain the postfix expression of the modified expression i.e CB*A+.
3. Reverse the postfix expression. Hence in our example prefix is +A*BC.
2020 By Eng. Joud Khattab
102. Stack ()المكدس
■ Postfix Calculation:
1. Create a stack to store operands (values).
2. Scan the given expression and do following for every scanned element:
1. If the element is a number, push it into the stack.
2. If the element is a operator, pop operands for the operator from stack. Evaluate
the operator and push the result back to the stack.
3. When the expression is ended, the number in the stack is the final answer.
2020 By Eng. Joud Khattab
103. Stack ()المكدس
■ Prefix Calculation:
1. Put a pointer P at the end of the end.
2. If character at P is a number push it to Stack.
3. If the character at P is an operator pop two elements from the Stack. Operate
on these elements according to the operator, and push the result back to the
Stack.
4. Decrement P by 1 and go to Step 2 as long as there are characters left to be
scanned in the expression.
5. The Result is stored at the top of the Stack.
2020 By Eng. Joud Khattab
122. Binary Search Trees (الثنائية البحث )أشجار
AVL (Height-balanced Trees)
■ An AVL tree (or height-balanced tree) is a binary search tree such that:
– The height of the left and right subtrees of the root differ by at most 1
– The left and right subtrees of the root are AVL trees
2020 By Eng. Joud Khattab
139. Graphs ()البيانات
Minimum Spanning Tree
■االرتباط شجرةاألصغرية:الروابط من ممكنة كلفة بأقل البيان تربط شجرة هي.
■فقط المترابط البيان حالة في الشجرة هذه تتواجد.
■Prim’s algorithm
a
c
e
d
b
2
45
9
6
4
5
5
a
c
e
d
b
2
45
9
6
4
5
5
2020 By Eng. Joud Khattab
157. Hashing Tables V.S.
Other Data Structures
■ We want to implement the dictionary operations Insert(), Delete() and Search()/Find() efficiently.
■ Arrays:
– can accomplish in O(n) time
– but are not space efficient (assumes we leave empty space for keys not currently in
dictionary)
■ Binary search trees
– can accomplish in O(log n) time
– are space efficient.
■ Hash Tables:
– A generalization of an array that under some reasonable assumptions is O(1) for
Insert/Delete/Search of a key
2020 By Eng. Joud Khattab
158. Hashing Tables
(التقطيع )جداول
■المباشرة العنونة باستخدام المعلومات تخزين عن مثال:
■مفتاح لكل الجدول من موقع منح نستطيع عندما تستخدم(ت المتوقع العناصر عددخزينها
للعناصر الكلي العدد من قريب.
Anas - Mazzah
0000001
6131467
6131468
6131469
6131470
9999997
9999998
9999999
Each phone number
uniquely determines an
array element
0000000
Record for phone
number 6131496
For technical or
commercial reasons,
certain numbers may not
be assigned to any
subscriber
2020 By Eng. Joud Khattab
159. Hashing Tables
(التقطيع )جداول
■ For example, if we hash keys 0…1000 into a hash table with 5 entries and use
h(key) = key mod 5 , we get the following sequence of events:
0
1
2
3
4
key data
Insert 2
2 …
0
1
2
3
4
key data
Insert 21
2 …
21 …
0
1
2
3
4
key data
Insert 34
2 …
21 …
34 …
Insert 54
There is a
collision at
array entry
#4
???
2020 By Eng. Joud Khattab
162. Hashing Tables (التقطيع )جداول
Hashing with Chaining
■ What is the running time to insert/search/delete?
– Insert: It takes O(1) time to compute the hash function and insert at head of
linked list
– Search: It is proportional to max linked list length
– Delete: Same as search
2020 By Eng. Joud Khattab
166. Question 1
■ For a binary search algorithm to work, it is necessary that the array (list) must be?
A. sorted
B. unsorted
C. in a heap
D. popped out of stack
2020 By Eng. Joud Khattab
167. Question 1
■ For a binary search algorithm to work, it is necessary that the array (list) must be?
A. sorted
B. unsorted
C. in a heap
D. popped out of stack
2020 By Eng. Joud Khattab
168. Question 2
■ Which one of the below mentioned is linear data structure?
A. Queue
B. Stack
C. Arrays
D. All of the above
2020 By Eng. Joud Khattab
169. Question 2
■ Which one of the below mentioned is linear data structure?
A. Queue
B. Stack
C. Arrays
D. All of the above
2020 By Eng. Joud Khattab
170. Question 3
■ Binary search tree has best case run-time complexity of Ο(log n). What could the
worst case?
A. Ο(n)
B. Ο(n2)
C. Ο(n3)
D. None of the above
2020 By Eng. Joud Khattab
171. Question 3
■ Binary search tree has best case run-time complexity of Ο(log n). What could the
worst case?
A. Ο(n)
B. Ο(n2)
C. Ο(n3)
D. None of the above
2020 By Eng. Joud Khattab
172. Question 4
■ An algorithm is?
A. a piece of code to be executed.
B. a loosely written code to make final code.
C. a step by step procedure to solve problem.
D. all of the above.
2020 By Eng. Joud Khattab
173. Question 4
■ An algorithm is?
A. a piece of code to be executed.
B. a loosely written code to make final code.
C. a step by step procedure to solve problem.
D. all of the above.
2020 By Eng. Joud Khattab
174. Question 5
■ Quick sort running time depends on the selection of?
A. size of array
B. pivot element
C. sequence of values
D. none of the above!
2020 By Eng. Joud Khattab
175. Question 5
■ Quick sort running time depends on the selection of?
A. size of array
B. pivot element
C. sequence of values
D. none of the above!
2020 By Eng. Joud Khattab
176. Question 6
■ A queue data-structure can be used for?
A. expression parsing
B. recursion
C. resource allocation
D. all of the above
2020 By Eng. Joud Khattab
177. Question 6
■ A queue data-structure can be used for?
A. expression parsing
B. recursion
C. resource allocation
D. all of the above
2020 By Eng. Joud Khattab
178. Question 7
■ Program with highest run-time complexity is?
A. Tower of Hanoi
B. Fibonacci Series
C. Prime Number Series
D. None of the above
2020 By Eng. Joud Khattab
179. Question 7
■ Program with highest run-time complexity is?
A. Tower of Hanoi
B. Fibonacci Series
C. Prime Number Series
D. None of the above
2020 By Eng. Joud Khattab
180. Question 8
■ From a complete graph, by removing maximum _______________ edges, we can
construct a spanning tree?
A. e-n+1
B. n-e+1
C. n+e-1
D. e-n-1
2020 By Eng. Joud Khattab
181. Question 8
■ From a complete graph, by removing maximum _______________ edges, we can
construct a spanning tree?
A. e-n+1
B. n-e+1
C. n+e-1
D. e-n-1
2020 By Eng. Joud Khattab
182. Question 9
■ The worst case complexity of binary search matches with?
A. interpolation search
B. linear search
C. merge sort
D. none of the above
2020 By Eng. Joud Khattab
183. Question 9
■ The worst case complexity of binary search matches with?
A. interpolation search
B. linear search
C. merge sort
D. none of the above
2020 By Eng. Joud Khattab
184. Question 10
■ What is a hash table?
A. A structure that maps values to keys.
B. A structure that maps keys to values.
C. A structure used for storage.
D. A structure used to implement stack and queue.
2020 By Eng. Joud Khattab
185. Question 10
■ What is a hash table?
A. A structure that maps values to keys.
B. A structure that maps keys to values.
C. A structure used for storage.
D. A structure used to implement stack and queue.
2020 By Eng. Joud Khattab
186. Question 11
■ The recurrence relation capturing the optimal time of the Tower of Hanoi problem
with n discs is
A. T(n) = 2T(n – 2) + 2
B. T(n) = 2T(n – 1) + n
C. T(n) = 2T(n/2) + 1
D. T(n) = 2T(n – 1) + 1
2020 By Eng. Joud Khattab
187. Question 11
■ The recurrence relation capturing the optimal time of the Tower of Hanoi problem
with n discs is
A. T(n) = 2T(n – 2) + 2
B. T(n) = 2T(n – 1) + n
C. T(n) = 2T(n/2) + 1
D. T(n) = 2T(n – 1) + 1
2020 By Eng. Joud Khattab
188. Question 12
■ What does the following function do for a given Linked List with first node as head?
void fun1(struct node* head) {
if(head == NULL)
return;
fun1(head->next);
printf("%d ", head->data); }
A. Prints all nodes of linked lists
B. Prints all nodes of linked list in reverse order
C. Prints alternate nodes of Linked List
D. Prints alternate nodes in reverse order
2020 By Eng. Joud Khattab
189. Question 12
■ What does the following function do for a given Linked List with first node as head?
void fun1(struct node* head) {
if(head == NULL)
return;
fun1(head->next);
printf("%d ", head->data); }
A. Prints all nodes of linked lists
B. Prints all nodes of linked list in reverse order
C. Prints alternate nodes of Linked List
D. Prints alternate nodes in reverse order
2020 By Eng. Joud Khattab
190. Question 13
■ Which of the following points is/are true about Linked List data structure when it is
compared with array
A. Arrays have better cache locality that can make them better in terms of
performance
B. It is easy to insert and delete elements in Linked List
C. Random access is not allowed in a typical implementation of Linked Lists
D. All of the above
2020 By Eng. Joud Khattab
191. Question 13
■ Which of the following points is/are true about Linked List data structure when it is
compared with array
A. Arrays have better cache locality that can make them better in terms of
performance
B. It is easy to insert and delete elements in Linked List
C. Random access is not allowed in a typical implementation of Linked Lists
D. All of the above
2020 By Eng. Joud Khattab
192. Question 14
■ Which of the following sorting algorithms can be used to sort a random linked list
with minimum time complexity?
A. Insertion Sort
B. Quick Sort
C. Heap Sort
D. Merge Sort
2020 By Eng. Joud Khattab
193. Question 14
■ Which of the following sorting algorithms can be used to sort a random linked list
with minimum time complexity?
A. Insertion Sort
B. Quick Sort
C. Heap Sort
D. Merge Sort
2020 By Eng. Joud Khattab
194. Question 15
■ In the worst case, the number of comparisons needed to search a singly linked list
of length n for a given element is
A. log 2 n
B. n/2
C. log 2 n – 1
D. n
2020 By Eng. Joud Khattab
195. Question 15
■ In the worst case, the number of comparisons needed to search a singly linked list
of length n for a given element is
A. log 2 n
B. n/2
C. log 2 n – 1
D. n
2020 By Eng. Joud Khattab
196. Question 16
■ Which one of the following is an application of Stack Data Structure?
A. Managing function calls
B. The stock span problem
C. Arithmetic expression evaluation
D. All of the above
2020 By Eng. Joud Khattab
197. Question 16
■ Which one of the following is an application of Stack Data Structure?
A. Managing function calls
B. The stock span problem
C. Arithmetic expression evaluation
D. All of the above
2020 By Eng. Joud Khattab
198. Question 17
■ The result evaluating the postfix expression 10 5 + 60 6 / * 8 – is
A. 284
B. 213
C. 142
D. 71
2020 By Eng. Joud Khattab
199. Question 17
■ The result evaluating the postfix expression 10 5 + 60 6 / * 8 – is
A. 284
B. 213
C. 142
D. 71
2020 By Eng. Joud Khattab
200. Question 18
■ How many stacks are needed to implement a queue. Consider the situation where
no other data structure like arrays, linked list is available to you.
A. 1
B. 2
C. 3
D. 4
2020 By Eng. Joud Khattab
201. Question 18
■ How many stacks are needed to implement a queue. Consider the situation where
no other data structure like arrays, linked list is available to you.
A. 1
B. 2
C. 3
D. 4
2020 By Eng. Joud Khattab
202. Question 19
■ The most appropriate matching for the following pairs
X: depth first search 1: heap
Y: breadth-first search 2: queue
Z: sorting 3: stack
A. X—1, Y—2 ,Z –3
B. X—3, Y—1, Z –2
C. X—3, Y—2, Z—1
D. X—2 ,Y—3 , Z--1
2020 By Eng. Joud Khattab
203. Question 19
■ The most appropriate matching for the following pairs
X: depth first search 1: heap
Y: breadth-first search 2: queue
Z: sorting 3: stack
A. X—1, Y—2 ,Z –3
B. X—3, Y—1, Z –2
C. X—3, Y—2, Z—1
D. X—2 ,Y—3 , Z--1
2020 By Eng. Joud Khattab
204. Question 20
■ Aliasing in the context of programming languages refers to
A. multiple variables having the same memory location
B. multiple variables having the same value
C. multiple variables having the same identifier
D. multiple uses of the same variable
2020 By Eng. Joud Khattab
205. Question 20
■ Aliasing in the context of programming languages refers to
A. multiple variables having the same memory location
B. multiple variables having the same value
C. multiple variables having the same identifier
D. multiple uses of the same variable
2020 By Eng. Joud Khattab
206. Question 21
■ Randomized quicksort is an extension of quicksort where the pivot is chosen
randomly. What is the worst case complexity of sorting n numbers using randomized
quicksort?
A. O(n)
B. O(n Log n)
C. O(n^2)
D. O(n!)
2020 By Eng. Joud Khattab
207. Question 21
■ Randomized quicksort is an extension of quicksort where the pivot is chosen
randomly. What is the worst case complexity of sorting n numbers using randomized
quicksort?
A. O(n)
B. O(n Log n)
C. O(n^2)
D. O(n!)
2020 By Eng. Joud Khattab
208. Question 22
■ The number of leaf nodes in a rooted tree of n nodes, with each node having 0 or 3
children is:
A. n/2
B. (n - 1)/3
C. (n - 1)/2
D. (2n + 1)/3
2020 By Eng. Joud Khattab
209. Question 22
■ The number of leaf nodes in a rooted tree of n nodes, with each node having 0 or 3
children is:
A. n/2
B. (n - 1)/3
C. (n - 1)/2
D. (2n + 1)/3
2020 By Eng. Joud Khattab
210. Question 23
■ Suppose the numbers 7, 5, 1, 8, 3, 6, 0, 9, 4, 2 are inserted in that order into an
initially empty binary search tree. The binary search tree uses the usual ordering on
natural numbers. What is the in-order traversal sequence of the resultant tree ?
A. 7 5 1 0 3 2 4 6 8 9
B. 0 2 4 3 1 6 5 9 8 7
C. 0 1 2 3 4 5 6 7 8 9
D. 9 8 6 4 2 3 0 1 5 7
2020 By Eng. Joud Khattab
211. Question 23
■ Suppose the numbers 7, 5, 1, 8, 3, 6, 0, 9, 4, 2 are inserted in that order into an
initially empty binary search tree. The binary search tree uses the usual ordering on
natural numbers. What is the in-order traversal sequence of the resultant tree ?
A. 7 5 1 0 3 2 4 6 8 9
B. 0 2 4 3 1 6 5 9 8 7
C. 0 1 2 3 4 5 6 7 8 9
D. 9 8 6 4 2 3 0 1 5 7
2020 By Eng. Joud Khattab
212. Question 24
■ Consider the following graph. Among the following sequences, Which are depth first
traversals of the graph?
I) a b e g h f
II) a b f e h g
III) a b f h g e
IV) a f g h b e
A. I, II and IV only
B. I and IV only
C. II, III and IV only
D. I, III and IV only
2020 By Eng. Joud Khattab
213. Question 24
■ Consider the following graph. Among the following sequences, Which are depth first
traversals of the graph?
I) a b e g h f
II) a b f e h g
III) a b f h g e
IV) a f g h b e
A. I, II and IV only
B. I and IV only
C. II, III and IV only
D. I, III and IV only
2020 By Eng. Joud Khattab
214. Question 25
■ What is the weight of a minimum spanning tree of the following graph ?
A. 29
B. 31
C. 38
D. 41
2020 By Eng. Joud Khattab
215. Question 25
■ What is the weight of a minimum spanning tree of the following graph ?
A. 29
B. 31
C. 38
D. 41
2020 By Eng. Joud Khattab
216. Question 26
■ The best data structure to check whether an arithmetic expression has balanced
parentheses is a
A. Queue
B. Stack
C. Tree
D. List
2020 By Eng. Joud Khattab
217. Question 26
■ The best data structure to check whether an arithmetic expression has balanced
parentheses is a
A. Queue
B. Stack
C. Tree
D. List
2020 By Eng. Joud Khattab
218. Question 27
■ The elements 32, 15, 20, 30, 12, 25, 16 are inserted one by one in the given order
into a Max Heap. The resultant Max Heap is.
A. A
B. B
C. C
D. D
2020 By Eng. Joud Khattab
219. Question 27
■ The elements 32, 15, 20, 30, 12, 25, 16 are inserted one by one in the given order
into a Max Heap. The resultant Max Heap is.
A. A
B. B
C. C
D. D
2020 By Eng. Joud Khattab