CS2112: Data Structures & Algorithms Practice Questions


 Q1. Consider the Quick Sort Algorithm that chooses the first element of the array as a Pivot. Then manually sort the first two levels of following numbers by applying Merge Sort / Quick Sort.


Q2. Implement the singly linked list which has Head as Node type pointers and 3 functions as isEmpty, Add and Remove.

Q3. (a) Consider a Stack that is implemented using Linked List and has public functions as isEmpty, Push and Pop. 

    (b) Write a function Remove_Larger(...) that receives a stack ("S1") and an integer ("vat") as parameters to the function. Your function then deletes all elements from "S1" those are larger than the "var" value.

Q4. Consider the infix expression: A + (A+B) * (C - D)/(E+F) * (E + F) -G.

    Convert it into equivalent
    (A) postfix expression.

    (B) prefix expression.

Q5. Consider the array base implementation Queue with size = 4 and initially "Front" and "Rare" indexes are zero. The Queue has public functions as isEmpty, Isfull, EnQueue and Dequeue.

Note that on DeQueue the "Front" index will move to the next index and cannot return to zero on full (the algorithm is not optimized). On full Queue will not EnQueue any number. The functions isEmpty and IsFull will output the empty or full messages respectively. 

Perform the following operations and fill "Output" columns with DE Queued numbers or error message.



Comments