Language Bar

Wednesday, December 12, 2012

CS301 MIDTERM EXAMINATION 2010 july


MIDTERM EXAMINATION 2010

Question No: 17    ( Marks: 1 )
Give the names of basic Queue Operations
Answer:- (page 88)
Queue Operations
The queue data structure supports the following operations:

Operation Description
enqueue(X)       Place X at the rear of the queue.
dequeue()         Remove the front element and return it. front()                         Return front element without removing it.
isEmpty()          Return TRUE if queue is empty, FALSE otherwise

6


Question No: 18    ( Marks: 1 ) Give one benefit of using Stack. Answer:- (Page 53)
In computer science, a stack is a last in, first out (LIFO) abstract data type and data structure. A stack can have
any abstract data type as an element, but is characterized by only two fundamental operations: push and pop.the
data structure itself enforces the proper order of calls.




Question No: 21    ( Marks: 5 )
Give short answers of the following questions:
1.   Why List wastes less memory as compared to Arrays. Answer:-
1.  Linked lists do not need contiguous blocks of memory; extremely large data sets stored in an array might not
be able to fit in memory.
2. Linked list storage does not need to be preallocated (again, due to arrays needing contiguous memory blocks).
3. Inserting or removing an element into a linked list requires one data update, inserting or removing an element into an array requires n (all elements after the modified index need to be shifted).

Array is a collection of same data type. In linked list there are two field one is address and other is pointer. In array elements are arranged in a specific order

2.   Why we can change the size of list after its creation when we can not do that in simple arrays? Answer:-
Some how the answer will be same as part 1 because Inserting or removing an element into a linked list
requires one data update, inserting or removing an element into an array requires n (all elements after the modified index need to be shifted).

Array is a collection of same data type. The size of array is mentioned with its declaration. in arrays the elements are in contiguous position. One must after another. While in linked list we gave the address of next element in the next part of node.

No comments:

Post a Comment

CONTACT US FORM