Kerala Plus Two Computer Science Chapter Wise Questions and Answers Chapter 3 Data Structures and Operations
Plus Two Computer Science Data Structures and Operations One Mark Questions and Answers
Question 1.
Write down the full form of FIFO.
Answer:
First In First Out
Question 2.
A queue is implemented in a ………… manner
(a) fifo
(b) filo
(c) life
(d) lilo
Answer:
(a) fifo
Question 3.
People waiting in a cinema theatre counter for taking tickets is an example for …………
(a) stack
(b) queue
(c) array
(d) none of these
Answer:
(b) queue
Question 4.
A linked list is a linear collection of data elements called ………….
Answer:
nodes
Question 5.
A stack can be grow or shrink, so it can be considered as ……………… data structure.
Answer:
dynamic
Question 6.
The data structure in which elements are arranged in non-sequence is named as type of data structure.
(a) Heterogeneous data structure
(b) Synthetic data structure
(c) Linear data structure
(d) Non-linear data structure
Answer:
(c) Linear data structure
Question 7.
Consider the following two statements.
(i). Memory of size dynamic data structures can be changed during execution.
(ii). Static data structures are associated with primary memory
(a) Statement (i) and statement (ii) are not true
(b) Statement (i) is true and statement (ii) is false
(c) Statement (i) is false and statement (ii) is true
(d) Statement (i) and statement (ii) are false
Answer:
(a) Statement (i) and statement (ii) are not true
Question 8.
……………… is a data structure in which items are added at one end and removed from the other,
(a) Stack
(b) Queue
(c) List
(d) None of the above
Answer:
(b) Queue
Question 9.
…………………. is very useful in situation when data have to be stored and then retrieved in reverse order,
(a) Stack
(b) Queue
(c) List
(d) Link list
Answer:
(a) Stack
Question 10.
Which of the following data structure is linear type?
(a) Graph
(b) Trees
(c) Binary tree
(d) Stack
Answer:
(d) Stack
Question 11.
Combining the elements of two sorted data structures to form a new one is referred as
(a) Merging
(b) Sorting
(c) Traversal
(d) Searching
Answer:
(a) Merging
Question 12.
Which term is applicable with stack data structure?
(a) LILO
(b) FILO
(c) LIFO
(d) FIFO
Answer:
(c) LIFO
Question 13.
Placing glasses one above another can be considered similar to ……….. data structure.
(a) Queue
(b) Stack
(c) Record
(d) Graph
Answer:
(b) Stack
Question 14.
Each node containing data and a pointerto the next node is applicable with …………. data structure.
(a) Array
(b) Linked List
(c) Stack
(d) Queue
Answer:
(b) Linked List
Question 15.
Identify and correct mistake in the following Stack – PUSH algorithm,
start
if stack is full
return null
endif
top = top -1
stack[top] = data
stop
Answer:
top = top – 1 is to be replaced by top = top + 1
Question 16.
People waiting in a cinema theatre counter for taking tickets is an example for ………………
(a) stack
(b) queue
(c) array
(d) none of these
Answer:
(b) queue
Plus Two Computer Science Concepts of Object-Oriented Programming Two Mark Questions and Answers
Question 1.
A word, say “computer” is stored in an array. Another array is to be created by storing the reverse of the word. How can stack support you to perform this task? Explain the algorithm.
Answer:
This can be performed by pushing each character of the word “computer” onto a stack as it is read. After the word is finished, then the characters are popped off the stack, so they will come in the reverse order such as “retupmoc” in the desired output.
Question 2.
Name the principle by which tickets are issued in a Cinema Ticket counter. Which data structure supports this principle?
Answer:
It is an example for Queue. Here the persons are added at the back end and tickets are issued to the front end. The FIFO method is used.
Question 3.
Define stack. Write down short notes about stack.
Answer:
A stack is a linear structure in which items can be added or removed only at one end called top. Add an item into the stack is called push and deleting an item from the stack is called pop.
Question 4.
Write short notes about queue.
Answer:
A queue is also a linear structure in which the items can be added at the back end called rear and the items are removed from the front end. There are two operations adding an item at the rear end and removing an item from the front end.
Question 5.
Write an algorithm for Push operation on a stack;
Answer:
- Step 1: If top = N. Then print “OVERFLOW” and return
- Step 2: Set top = top + 1
- Step 3: Set Stack[top] = item
- Step 4: stop
Question 6.
Write an algorithm for Pop operation on a stack;
Answer:
- Step 1: If top = Null. Then print “UNDERFLOW” and return
- Step 2: Set item=Stack[top]
- Step 3: Set-top = top – 1
- Step 4: stop
Question 7.
A linked list containing all the name of students in your class is to be created. Write its C++ structure to define the node.
Answer:
struct node
{
char name[15];
node *link;
}
Question 8.
Write a short note about circular queue.
Answer:
ClrcularQueue Is a linear data structure in which the operations are performed based on FIFO (First In First Out) principle and the last position is connected back to the first position to make a circle.
Question 9.
With suitable diagrams and notes, Explain the different classifications of data structures.
Plus Two Computer Science Concepts of Object-Oriented Programming Three Mark Questions and Answers
Question 1.
Write an algorithm for inserting an element into a queue
Answer:
- Step 1: If front = 1 and rear = N or front =rear + 1. Then print “OVERFLOW” and return
- Step 2: If front = Null then Set front = 1 and rear = 1 Else if rear = N then set rear * 1 Else Set rear* rear + 1 End if
- Step 3: Set Queue[rear] = item
- Step 4: stop
Question 2.
Write an algorithm for deleting an element from a queue
Answer:
- step 1: If front = Null then print “UNDERFLOW” and return
- Step 2: Set item = Queue[front]
- Step 3: If front = rearthen Set front = Null and rear = Null Else if front = N then set front = 1 Else Set front = front + 1 End if
- Step 4; stop
Question 3.
Write the steps for inserting a new element to a queue.
Answer:
- Step 1: If front = 1 and rear = N or front = rear +1 Then print “ OVERFLOW and return
- Setp 2: If front = Null then Setfront = 1 and rear = 1 Else if near = N then Set rear * 1 Else Set rear* rear + 1 End if
- Step 3: Set queue [rear] * item.
- Step 4: Stop
Question 4.
Write the steps for deleting an element from a queue
Answer:
Deletion operation
It is. the process of deleting(removing) a data item. from the queue from the front. If the queue is empty ‘ v ‘.and we try to delete an item from the queue makes 1 the queue underflow. Algorithm is given below
- Step 1: If front = Null then print “UNDERFLOW: and return
- Step 2: Set item = Queue [front]
- Step 3: If front = Null and rear = Null Else if front N then set front = 1 Else Set front = front + 1 End if
- Step 4: stop
Question 5.
Write the steps for deleting a node from a linked list?
Answer:
Deletion from a linked list
It is the removal of a node from the data structure.
- Step 1: Get the address of the previous node (POS – 1) and next node (POS + 1) in the pointers PreNode and PostNode respectively.
- Step 2: Copy the contents of PostNode into the link part of node at position (POS – 1).
- Step 3: Free the node at position POS.
Plus Two Computer Science Concepts of Object-Oriented Programming Five Mark Questions and Answers
Question 1.
Prepare a short note about all the operations associated with data structures:
Answer:
Operations on data structures
- Traversing – Accessing or visiting or reading all elements of a data structure is called Traversal.
- Searching – Searching is the process of finding elements in a data structure
- Inserting – It is the process of adding new data at particular location is called insertion.
- Deleting – It is the process of removing a particular element from the data structure.
- Sorting – Arranging elements in a particular order(ascending or descending) is called sorting. Examples are bubble sort and selection sort.
- Merging – This is the process of combining two sorted data structure and form a new one.
Question 2.
You are given a queue containing 50 students. Who will get the first chance and who will be irt the last position if the queue is in linear form.
- In which position you add a new student?
- In which problem you remove a student?
- Which operations are performed for this purpose?
- Write all steps for adding new students to a queue
- Write all steps for removing a student from the queue?
Answer:
1. At the back or rear position
2. From the front position
3. Add a new student to the queue is insertion and removing a student from the queue is called deletion
4.
- Step 1: If front =1 and rear=N or front =rear+1. Then print “OVERFLOW” and return
- Step 2: If front = Null then Set front = 1 and rear =1 Else if rear 3 N then set rear = 1 Else Set rear = rear+1 End if
- Step 3: Set Queue[rear]=item Step 4: Stop
5.
- Step 1: If front = Null then print “UNDERFLOW and return
- Step 2: Set item = Queue[front]
- Step 3: If front = rear then Set front Null and rear =Null Else if front N then set front = 1Else Set front = front + 1 End if
- Step 4: stop
Question 3.
Class teacher said to the class leader to collecting their observation books and place them in a table one by one. Teacher should take books one by one from this group always from the top. Suppose that books be arranged in linear form from bottom to top
- In which position a new book can be placed?
- How can a book be taken from this group?
- Which operations are performed for this purpose?
- Write all steps for adding new books to this group or
- Write all steps for removing books one by one from this group.
Answer:
1. At the top
2. From the top.
3. To place a new book it is push operation and taking books from the stack is pop operation
4.
- Step 1: If top = Null. Then print “UNDERFLOW” and return
- Step 2: Set item = Stack[top]
- Step 3: Set-top = top – 1
- Step 4: stop
5.
- Step 1: If front = 1 and rear=N or front =rear+1. Then print “OVERFLOW and return”
- Step 2: If front = Null then Set front = 1 and rear =1 Else if rear = N then set rear = 1 Else Set rear = rear + 1
End if