Sail E0 Webinar

MCQs

Total Questions : 15 | Page 1 of 2 pages
Question 1. Given pointer to a node X in a singly linked list. Only one pointer is given, pointer to head node is not given, can we delete the node X from given linked list?
  1.    Possible if X is not last node
  2.    Possible if size of linked list is even
  3.    Possible if size of linked list is odd
  4.    Possible if X is not first node
 Discuss Question
Answer: Option A. -> Possible if X is not last node


Following are simple steps.
struct node *temp = X->next;
X->data = temp->data;
X->next = temp->next;
free(temp);


Question 2. Which of the following is not an inherent application of stack?
  1.    Reversing a string
  2.    Evaluation of postfix expression
  3.    Implementation of recursion
  4.    Job scheduling
 Discuss Question
Answer: Option D. -> Job scheduling




Question 3. Which data structure is needed to convert infix notation to postfix notation?
  1.    Branch
  2.    Tree
  3.    Queue
  4.    Stack
 Discuss Question
Answer: Option D. -> Stack




Question 4. What is the space complexity for deleting a linked list?
  1.    O(1)
  2.    O(n)
  3.    Either O(1) or O(n)
  4.    O(logn)
 Discuss Question
Answer: Option A. -> O(1)


You need a temp variable to keep track of current node, hence the space complexity is O(1).


Question 5. Which of the following applications may use a stack?
  1.    A parentheses balancing program.
  2.    Tracking of local variables at run time.
  3.    Compiler Syntax Analyzer.
  4.    All of the mentioned
 Discuss Question
Answer: Option D. -> All of the mentioned


All are applications of stack.


Question 6. What is the output of the following piece of code?public class array{ public static void main(String args[]) { int []arr = {1,2,3,4,5}; System.out.println(arr[5]); }}
  1.    4
  2.    5
  3.    ArrayIndexOutOfBoundsException
  4.    InavlidInputException
 Discuss Question
Answer: Option C. -> ArrayIndexOutOfBoundsException


Trying to access an element beyond the limits of an array gives ArrayIndexOutOfBoundsException.


Question 7. Which of the following can be used to delete an element from the rear end of the queue?
  1.    public Object deleteRear() throws emptyDEQException{
  2.    public Object deleteRear() throws emptyDEQException{
  3.    public Object deleteRear() throws emptyDEQException{
  4.    None of the mentioned
 Discuss Question
Answer: Option C. -> public Object deleteRear() throws emptyDEQException{


Traverse till the end of the list with a pointer 'temp' and another 'cur' which is trailing behind temp, make 'cur' point to trail, this removes all reference for 'temp'.


Question 8. What is the time complexity of inserting a node in a doubly linked list?
  1.    O(nlogn)
  2.    O(logn)
  3.    O(n)
  4.    O(1)
 Discuss Question
Answer: Option C. -> O(n)


In the worst case, the position to be inserted maybe at the end of the list, hence you have to traverse through the entire list to get to the correct position, hence O(n).


Question 9. What is not a disadvantage of priority scheduling in operating systems?
  1.    A low priority process might have to wait indefinitely for the CPU
  2.    If the system crashes, the low priority systems may be lost permanently
  3.    Interrupt handling
  4.    None of the mentioned
 Discuss Question
Answer: Option C. -> Interrupt handling


It is in fact an advantage, interrupts should be given more priority than the task at hand so that the interrupt can be serviced.


Question 10. Choose the code snippet which inserts a node to the head of the list?
  1.    public void insertHead(int data){
  2.    public void insertHead(int data){
  3.    public void insertHead(int data){
  4.    public void insertHead(int data){
 Discuss Question
Answer: Option A. -> public void insertHead(int data){


If the list is empty make the new node as 'head', otherwise traverse the list to the end and make its 'next' pointer point to the new node, set the new node's next point to the current head and make the new node as the head.


Latest Videos

Latest Test Papers