Cmpe 160 Introduction to Object Oriented Programming
 More Sample Exam Questions C++ Programming & Data Structures class IntArray { public: IntArray(int sz=Arraysize); IntArray(const int*, int); ~IntArray(){delete []ia;} int& operator[](int); private: int size; int *ia; }; Modify the class definition and provide the implementation for the operation a-=b on given IntArray objects a and b. This should delete all elements of a that exist in b. Modify the class definition and provide the implementation for the operation a-b on given IntArray objects a and b. The result should be an IntArray with all the elements of a that do not exist in b. How would you modify the class definition and implementation to provide subscript operator for constant class objects. Write a recursive algorithm Fib(n) that computes the n’th Fibonacci number. Show the operation of the recursion stack for Fib(4). Given two Doubly Linked Circular Lists L and M, write an algorithm for the function add(L,M) which adds M to the tail of L. Write an algorithm that merges two given ordered Linear Linked Lists. How can we implement two seperate stacks (S1 and S2) in an efficient fashion using a single array of size N?. Provide the algorithms for push(S1,x) and push(S2,x). Considering the class definition given below, what is the difference between functions Raise( ) and SRaise( ). Explain providing sample C++ code. class X{ public: void Raise(double Z) { Y += Z;} static void SRaise(double Z) { Y += Z;} ... private: static double Y; ... } Provide the Class definitions for 2 geometric objects, namely, Circle and Cylinder such that the first one is a base class and the second is a derived class. ( Provision of data members and the constructors is sufficient ) Circle C ( radius, centrex, centrey); Cylinder Cy (height, radius, centrex, centery); Consider two ascending ordered Linear Linked Lists L1 and L2 with the node structure: INFO | NEXT | UNUSED where UNUSED is an unused pointer field. Write an algorithm to create a new ordered list L3 (utilising the unused pointer field) containing the nodes of both lists L1 and L2 in ascending order. Also provide a logical diagram of your solution. Note that the lists L1 and L2 should not be destroyed. Assume that you are given a Linear Linked List where each node keeps a Stack and an integer named NodeType. Write an algorithm for the following functions: PushStack ( Ntype, x ) to push an element x on to the stack of all nodes with NodeType = Ntype. ListPop ( ) to pop every stack on the list and return the number of popped stack values and an array containing them.