Final 2021
Final 2021
1. The essential condition which is checked before insertion in a linked queue is?
a) Underflow b) Overflow
c) Front value d) Rear value
2. In linked list implementation of a stack, from where is the item deleted?
a) the head of link list b) the centre position of link list
c) the tail of the link list d) Node before the tail
3. In linked list implementation of a queue, front and rear pointers are tracked. Which of these
pointers will change during an insertion into a NONEMPTY queue?
a) Only front pointer b) Only rear pointer
c) Both front and rear pointer d) No pointer will be changed
4. Minimum number of queues to implement stack is ___________
a) 3 b) 4 Eng. Moataz Said
c) 1 d) 2 Both answers are accepted
5. Linked list data structure offers considerable saving in _____________
a) Computational Time b) Space Utilization
c) Space Utilization and Computational Time d) Speed Utilization
6. What kind of linked list is best to answer questions like “What is the item at position n?”
a) Singly linked list b) Doubly linked list
c) Circular linked list d) Array implementation of linked list
7. Assume a single linked list with head pointer and its current content is 1->2->3->4->5. What will
the list be after executing the statement head->next->next->next = NULL?
a)1->2 b) 1->2->3
c) 1->2->3->4 d) 1->2->3->4
8. Templates are abstract recipe for producing a concrete code, and it is used for
a)Producing functions b) Producing classes
c) Both A and B d) none of the above
9. You want to declare an array of 200 Furniture class objects with the declaration, which of the
following declaration is correct?
a) Furniture=new Furniture[200]; b) Furniture[] =new Furniture[200];
c) Furniture[] myChairs=new Furniture[200]; d) Furniture myChairs[]=new Furniture[200];
10. While the performing of enqueue operation,
a) rear decrease b) front increase
c) front decrease d) rear increase
1|Page
Best Wishes
Dr. Shereen A. Hussien
Final Exam 2021
Preorder Traversal F B A E C D H J L
Postorder Traversal A D C E B J L H F
Inorder Traversal A B E D C F J H L
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
2|Page
Best Wishes
Dr. Shereen A. Hussien
Final Exam 2021
II. Consider the given linked list, Draw the impact of each the following segments with
clarifying where variables node1, node2, node3 referring to in the list
head
Adam Ali Baher Dalia Fady
3|Page
Best Wishes
Dr. Shereen A. Hussien
Final Exam 2021
II. Consider the following stack of characters, where STACK is allocated N=8 memory
cells STACK : A,C,D,F,K,_,_,_. What is the stack contents after performing these
sequence of operations:-
POP(STACK,ITEM)
POP(STACK,ITEM)
POP(STACK,ITEM)
PUSH(STACK,R) Stack Contents = --------------------------------
PUSH(STACK,L)
PUSH(STACK,S)
PUSH(STACK,P)
POP(STACK,ITEM)
III. Consider a given queue where Q: 1,2,3,4 What is the output of the following functions:-
void do (node* qfront)
{
If (qfront== NULL) if do was a different name
return;
do (qfront->next); The output = -------------------------------------
cout<< qfront->info;
}
but it will give error because do
Question 4:- can't be a function name (15 marks)
I. Fill in this table. Write the worst case complexity (Big-O) of each operation for each data
structure:-
4|Page
Best Wishes
Dr. Shereen A. Hussien
Final Exam 2021
II. Write a RemoveDuplicates() function that takes elements and returns elements after
deletting any duplicate using List Structure. Elements are not sorted.
Input:- 12->11->12->21->41->43->21
Output:- 12->11->21->41->43.
----------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------
III. Write a FindMin() function that takes a set of elements and returns the smallest element
using Stack linked list-based Structure. Elements are not sorted.
Input : 15->14->13->22->17
Output : Minimum element in linked list 13
----------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------
5|Page
Best Wishes
Dr. Shereen A. Hussien