Вы находитесь на странице: 1из 3

SECTION A: CHOOSE THE MOST CORRECT ANSWERS (1)What happens when you push a new node onto a stack?

(a)The new nod is placed at a front of the linked list. (b)The new node is placed at the back of the linked list The new node is placed at the middle of the linked list (d)No changes happens (2)The pop() member function determines if the stark is empty by calling themember function. (a)removeback() (b)isempty() (c)removedfront() (d) hasNext() (3)In an array queue, data is stored in an .. element. (a)Node (b)linked list (c)array (d)Constructor (4) A .. is a data structure that organizes data similar to a line in the supermarket, where the first one in line is the first one out. (a) queue linked list (b) stacks linked list (c) both of them (d) neither of them (5)New nodes are added to the of the queue. (a) front (b) back (c)middle (d) Both 1 and 2 (6).. form of access is used to add and remove nodes from a stack (a) LIFO (b) FIFO (c)Both 1 and 2 (d) None of these (7). Form of access is used to add and remove nodes from a queue (a)LIFO (b)FIFO (c) Both 1 and 2 (D) None of these (8) A linked list index is . that represents the position of a node in a linked list (a) An integer (b) a variable (c) a character (d) a Boolean (9)Value of the first linked list is .. (a) One (b) Zero (c)-1 (d) None of these (10)Which of the following abstract data types are NOT used by Integer Abstract Data types (a)Short (b)Int (c) float (d)long SECTION B (1)Write algorithms for performing the following actions. (a)Pushing the element into a stack (b)Popping an element from the stack Enqueue an element to the queue (d)Dequeue an element from the queue

(2)Write the output of the following program #include<iostream.h> #define QUEUE_SIZE 100 class Queue { int q[QUEUE_SIZE]; int first, last; int count; public: Queue(); void enqueue(int x); int dequeue(); int getsize(); }; Queue::Queue() { first=0; last=QUEUE_SIZE-1; count=0; } void Queue::enqueue(int x) { last=(last+1)%QUEUE_SIZE; q[last]=x; count++; } int Queue::dequeue() { int x=q[first]; first=(first+1)%QUEUE_SIZE; count--; return x; } int Queue::getsize() { return count; } int main() { Queue q; q.enqueue(1); q.enqueue(2); q.enqueue(3); while(q.getsize()) cout<<q.dequeue()<<endl;

return 0; } (3)Modify the program above to make it accept the value from the keyboard and you must use the loop. (4)Extract all error from the following program #include<iosream.h> #include<conio.h> int billy []={16, 2, 77, 40, 12071}; int n, result=0; int main() { for(n=0; n<5; n++); { result=+billy[n]; } cout>>result; return o; } (5)Write the program for calculating the factorial of a number n (n!) using a recursive function (6)Sort the given values using bubble sort. 65 70 75 80 85 60 55 50 45 (7)What are the major data structures used in the following areas: RDBMS, Network data model and Hierarchical data model. &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& &&&

Вам также может понравиться