You are on page 1of 4

DATA STRUCTURE AND ALGORITHM

PREFINALS EXAMINATION

NAME:___________________________________________________ DATE:________
PROGRAM/YR&SEC.:________________________________________ SCORE:_______

PART 1: APPLICATION OF SINGLY LINKED LIST


GIVEN:

00H
ROBERT 01H
HEAD 01H
RYAN 02H

02H
ROBERTO NULL

TAIL

PERFORM THE FOLLOWING OPERATION:


A. INSERT
ROSELLE 03H AT THE MIDDLE OF THE LIST.

B. INSERT ARMINA 04H AT THE TAIL OF THE LIST

C. DELETE “ROBERT” AS THE HEAD OF THE LIST

D. INSERT AS NEW HEAD OF THE LIST.


PAUL 05H

E. INSERT KATHLENE 06H AT THE TAIL OF THE LIST.

F. DELETE “RYAN” FROM LIST.

F. UPDATE THE CONTENTS OF MY LIST.


PART 2:

A. Given the operation, perform the simulation for STACK using LIFO (Last-In-First-Out) Algorithm.
Operation in Stacks Stack Contents (10) Return Value
Initialize(S) TI,T3,T5 -
POP (T1)
POP(T3)
PUSH(T4)
PUSH(T6)
PUSH(T8)
STACKTOP(S)
PUSH(T10)
ISFULL(S)
POP(T8)
DESTROY(S)

B. Given the operation, perform the simulation for QUEUE using FIFO (First-In-First-Out) Algorithm.
Operation in Queues Queue Contents Return Value
Initialize(S) Q2,Q4,Q6 -
REMOVE(S)
REMOVE(S)
ADD(Q1)
ADD(Q3)
ADD(Q5)
ADD(Q7)
ISFULL(S)
REMOVE(S)
DESTROY(S)
ISEMPTY(S)
PART 3: MULTIPLE CHOICE (2 PTS. EACH)

CHOOSE THE BEST ANSWER THAT ______6. Queue is also known as:
CORRESPONDS THE GIVEN STATEMENTS. a) Last in first out list
b) First in first out list
______1. A linear collection of data elements c) both a and b
where the linear node is given by means of d) none of the above
pointer is called? ______7. Which data structure allows deleting
a) Linked list data elements from and inserting at rear?
b) Node list a) stacks
c) Primitive list b) queues
d) None of the mentioned c) dequeues
_______2. In linked list each node contains d) binary search tree
minimum of two fields. One field is data field to ______8 which of the following data structure is
store the data second field is. linear type?
a) Pointer to character a) stack
b) Pointer to integer b) graph
c) Pointer to node c) trees
d) Node d) binary tree
______9. Which of the following is not a stack
_______3. Linked list is considered as an operation?
example of ___________ type of memory a) push
allocation. b) unstack
a) Dynamic c) pop
b) Static d) top
c) Compile time ______10. Which one the following is not an
d) None of the mentioned application of a stack?
_______4. What does the following function do a) Keeping track of command history for an
for a given Linked List with first node as head? “undo” feature.
void fun1(struct node* head)
{ b) Keeping track of function calls in a running
if(head == NULL) program.
return; c) Checking for proper nesting of parentheses.
fun1(head->next); d) All of the above are stack applications.
printf("%d ", head->data);
}
a) Prints all nodes of linked lists
b) Prints all nodes of linked list in reverse order
c) Prints alternate nodes of Linked List
d) Prints alternate nodes in reverse order
_______5. The act of adding the values into a
stack is called.
a) popping
b) polling
c) pushing
d) none
PART 4: TRUE OR FALSE (2 PTS. EACH)
1. STACK IS USED FOR RECURSION.
2. PUSH () AND POP () FUNCTION ARE FOUND
IN LISTS.
3. A QUEUE DATA STRUCTURE CAN BE USED
FOR RESOURCE ALLOCATION
4. QUEUES DATA STRUCTURE WORK ON FILO.
5. QUEUE IS A PILE IN WHICH ITEMS ARE ADDED
AT ONE END AND REMOVED FROM THE OTHER
6. INSERTION IS NOT THE OPERATION THAT
CAN BE PERFORMED ON QUEUE
7. FUNCTION CALLS, LARGE NUMBER
ARITHMETIC AND EVALUATION OF ARITHMETIC
EXPRESSIONS ARE THE APPLICATION OF STACKS
8. THE PROCESS OF INSERTING AN ELEMENT IN
STACK IS CALLED CREATE
9. IN A STACK, ALL INSERTIONS TAKE PLACE AT
TOP ENDS
10. IN A QUEUE, INSERTIONS TAKE PLACE AT
FRONT

You might also like