Explore topic-wise MCQs in Technical Programming.

This section includes 721 Mcqs, each offering curated multiple-choice questions to sharpen your Technical Programming knowledge and support exam preparation. Choose a topic below to get started.

651.

The following C function takes a simply-linked list as input argument.
It modifies the list by moving the last element to the front of the list and returns
the modified list. Some part of the code is left blank. Choose the correct alternative
to replace the blank line.

typedef struct node 
{
    int value;
    struct node *next;
}Node;
 
Node *move_to_front(Node *head) 
{
    Node *p, *q;
    if ((head == NULL: || (head->next == NULL)) 
    return head;
    q = NULL; p = head;
    while (p-> next !=NULL) 
    {
        q = p;
        p = p->next;
    }
   _______________________________
  return head;
}

A. q = NULL; p->next = head; head = p;
B. q->next = NULL; head = p; p->next = head;
C. head = p; p->next = q; q->next = NULL;
D. q->next = NULL; p->next = head; head = p;
Answer» E.
652.

What is the output of following function for start pointing to first node of following linked list?

1->2->3->4->5->6
void fun(struct node* start)
{
    if(start == NULL)
    return;
    printf("%d  ", start->data); 
    if(start->next != NULL )
    fun(start->next->next);
    printf("%d  ", start->data);
}

A. 1 4 6 6 4 1
B. 1 3 5 1 3 5
C. 1 2 3 5
D. 1 3 5 5 3 1
Answer» E.
653.

The following function reverse() is supposed to reverse a singly linked list. There is one line missing at the end of the function.

/* Link list node */
struct node
{
    int data;
    struct node* next;
};
 
/* head_ref is a double pointer which points to head (or start) pointer 
  of linked list */
static void reverse(struct node** head_ref)
{
    struct node* prev   = NULL;
    struct node* current = *head_ref;
    struct node* next;
    while (current != NULL)
    {
        next  = current->next;  
        current->next = prev;   
        prev = current;
        current = next;
    }
    /*ADD A STATEMENT HERE*/
}

What should be added in place of “/*ADD A STATEMENT HERE*/”, so that the function correctly reverses a linked list.

A. *head_ref = prev;
B. *head_ref = current;
C. *head_ref = next;
D. *head_ref = NULL;
Answer» B. *head_ref = current;
654.

Which of the following sorting algorithms can be used to sort a random linked list with minimum time complexity?

A. Merge Sort
B. Quick Sort
C. Heap Sort
D. Merge Sort
Answer» E.
655.

 Which of the following sorting algorithms can be used to sort a random linked list with minimum time complexity?

A. Insertion Sort
B. Quick Sort
C. Heap Sort
D. Merge Sort
Answer» E.
656.

What does the following function do for a given Linked List with first node as head?

void fun1(struct node* head)
{
    if(head == NULL)
    return;
    fun1(head->next);
    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
Answer» C. Prints alternate nodes of Linked List
657.

Which of the following points is/are true about Linked List data structure when it is compared with array

A. Arrays have better cache locality that can make them better in terms of performance
B. It is easy to insert and delete elements in Linked List
C. Random access is not allowed in a typical implementation of Linked Lists
D. All of the mentioned
Answer» E.
658.

 Linked list data structure offers considerable saving in

A. Computational Time
B. Space Utilization
C. Space Utilization and Computational Time
D. None of the mentioned
Answer» D. None of the mentioned
659.

In Linked List implementation, a node carries information regarding

A. Data
B. Link
C. Data and Link
D. None of the mentioned
Answer» C. Data and Link
660.

Linked list is considered as an example of ___________ type of memory allocation.

A. Dynamic
B. Static
C. Compile time
D. None of the mentioned
Answer» B. Static
661.

 Linked lists are not suitable to for the implementation of?

A. Insertion sort
B. Radix sort
C. Polynomial manipulation
D. Binary search
Answer» E.
662.

What kind of linked list is best to answer question like “What is the item at position n?”

A. Singly linked list
B. Doubly linked list
C. Circular linked list
D. Array implementation of linked list
Answer» E.
663.

Which of the following c code is used to create new node?

A. ptr = (NODE*)malloc(sizeof(NODE));
B. ptr = (NODE*)malloc(NODE);
C. ptr = (NODE*)malloc(sizeof(NODE*));
D. ptr = (NODE)malloc(sizeof(NODE));
Answer» B. ptr = (NODE*)malloc(NODE);
664.

The concatenation of two list can performed in O(1) time. Which of the following variation of linked list can be used?

A. Singly linked list
B. Doubly linked list
C. Circular doubly linked list
D. Circular doubly linked list
Answer» D. Circular doubly linked list
665.

What would be the asymptotic time complexity to insert an element at the second position in the linked list?

A. O(1)
B. O(n)
C. O(n2)
D. None of the mentioned
Answer» B. O(n)
666.

 What would be the asymptotic time complexity to find an element in the linked list?

A. O(1)
B. O(n)
C. O(n2)
D. None of the mentioned
Answer» C. O(n2)
667.

What would be the asymptotic time complexity to add an element in the linked list?

A. O(1)
B. O(n)
C. O(n2)
D. None of the mentioned
Answer» C. O(n2)
668.

What would be the asymptotic time complexity to add a node at the end of singly linked list, if the pointer is initially pointing to the head of the list?

A. O(1)
B. O(n)
C. θ(n)
D. θ(1)
Answer» D. θ(1)
669.

 In linked list each node contain minimum of two fields. One field is data field to store the data second field is?

A. Pointer to character
B. Pointer to integer
C. Pointer to node
D. Node
Answer» D. Node
670.

Consider an implementation of unsorted singly linked list. Suppose it has its representation with a head pointer only.
Given the representation, which of the following operation can be implemented in O(1) time?
i) Insertion at the front of the linked list
ii) Insertion at the end of the linked list
iii) Deletion of the front node of the linked list
iv) Deletion of the last node of the linked list

A. I and II
B. I and III
C. I, II and III
D. I, II and IV
Answer» C. I, II and III
671.

A linear collection of data elements where the linear node is given by means of pointer is called?

A. Linked list
B. Node list
C. Primitive list
D. None of the mentioned
Answer» B. Node list
672.

Which of the following is not the type of queue?

A. Ordinary queue
B. Single ended queue
C. Circular queue
D. Priority queue
Answer» C. Circular queue
673.

Queues serve major role in

A. Simulation of recursion
B. Simulation of arbitrary linked list
C. Simulation of limited resource allocation
D. All of the mentioned
Answer» D. All of the mentioned
674.

A normal queue, if implemented using an array of size MAX_SIZE, gets full when

A. Rear = MAX_SIZE – 1
B. Front = (rear + 1)mod MAX_SIZE
C. Front = rear + 1
D. Rear = front
Answer» B. Front = (rear + 1)mod MAX_SIZE
675.

A data structure in which elements can be inserted or deleted at/from both the ends but not in the middle is?

A. Queue
B. Circular queue
C. Dequeue
D. Priority queue
Answer» D. Priority queue
676.

 If the elements “A”, “B”, “C” and “D” are placed in a queue and are deleted one at a time, in what order will they be removed?

A. ABCD
B. DCBA
C. DCAB
D. ABDC
Answer» B. DCBA
677.

In Breadth First Search of Graph, which of the following data structure is used?

A. Stack
B. Queue
C. Linked list
D. None of the mentioned
Answer» C. Linked list
678.

A queue is a ?

A. FIFO (First In First Out) list
B. LIFO (Last In First Out) list
C. Ordered array
D. Linear tree
Answer» B. LIFO (Last In First Out) list
679.

The data structure required for Breadth First Traversal on a graph is?

A. Stack
B. Array
C. Queue
D. Tree
Answer» D. Tree
680.

A linear list of elements in which deletion can be done from one end (front) and insertion can take place only at the other end (rear) is known as a ?

A. Queue
B. Stack
C. Tree
D. Linked list
Answer» B. Stack
681.

If the elements “A”, “B”, “C” and “D” are placed in a stack and are deleted one at a time, what is the order of removal?

A. ABCD
B. DCBA
C. DCAB
D. ABDC
Answer» C. DCAB
682.

Assume that the operators +,-, X are left associative and ^ is right associative.
The order of precedence (from highest to lowest) is ^, X, +, -. The postfix expression for the infix expression a + b X c – d ^ e ^ f is

A. abc X+ def ^^ –
B. abc X+ de^f^ –
C. ab+c Xd – e ^f^
D. -+aXbc^ ^def
Answer» B. abc X+ de^f^ –
683.

 The type of expression in which operator succeeds its operands is?

A. Infix Expression
B. Prefix Expression
C. Postfix Expression
D. Postfix Expression
Answer» D. Postfix Expression
684.

Which of the following is not an inherent application of stack?

A. Reversing a string
B. Evaluation of postfix expression
C. Implementation of recursion
D. Job scheduling
Answer» E.
685.

Consider the following operation performed on a stack of size 5.
Push(1);
Pop();
Push(2);
Push(3);
Pop();
Push(4);
Pop();
Pop();
Push(5);
After the completion of all operation, the number of elements present in stack are

A. 1
B. 2
C. 3
D. 4
Answer» B. 2
686.

Which of the following statement(s) about stack data structure is/are NOT correct?

A. Linked List are used for implementing Stacks
B. Top of the Stack always contain the new node
C. Stack is the FIFO data structure
D. Null link is present in the last node at the bottom of the stack
Answer» D. Null link is present in the last node at the bottom of the stack
687.

Convert the following Infix expression to Postfix form using a stack
x + y * z + (p * q + r) * s, Follow usual precedence rule and assume that the expression is legal.

A. xyz*+pq*r+s*+
B. xyz*+pq*r+s+*
C. xyz+*pq*r+s*+
D. None of the mentioned
Answer» B. xyz*+pq*r+s+*
688.

Convert the following infix expressions into its equivalent postfix expressions

(A + B ⋀D)/(E – F)+G

A. (A B D ⋀ + E F – / G +)
B. (A B D ⋀ + E F – / G +)
C. (A B D ⋀ + E F/- G +)
D. None of the mentioned
Answer» B. (A B D ⋀ + E F – / G +)
689.

The result of evaluating the postfix expression 5, 4, 6, +, *, 4, 9, 3, /, +, * is?

A. 600
B. 350
C. 650
D. 588
Answer» C. 650
690.

Which data structure is used for implementing recursion?

A. Queue
B. Stack
C. Array
D. List
Answer» C. Array
691.

The prefix form of an infix expression p + q – r * t is?

A. + pq – *rt
B. – +pqr * t
C. – +pq * rt
D. – + * pqrt
Answer» D. – + * pqrt
692.

 What is the result of the following operation
Top (Push (S, X))

A. X
B. Null
C. S
D. None of the mentioned
Answer» B. Null
693.

The prefix form of A-B/ (C * D ^ E) is?

A. -/*^ACBDE
B. -ABCD*^DE
C. -A/B*C^DE
D. -A/BC*^DE
Answer» D. -A/BC*^DE
694.

Which data structure is needed to convert infix notation to postfix notation?

A. Branch
B. Tree
C. Queue
D. Stack
Answer» E.
695.

The postfix form of A*B+C/D is?

A. *AB/CD+
B. AB*CD/+
C. A*BC+/D
D. ABCD+/*
Answer» C. A*BC+/D
696.

The process of accessing data stored in a serial access memory is similar to manipulating data on a ________

A. Heap
B. Binary Tree
C. Array
D. Stack
Answer» E.
697.

What data structure would you mostly likely see in a non recursive implementation of a recursive algorithm?

A. Linked List
B. Stack
C. Queue
D. Tree
Answer» C. Queue
698.

The data structure required to check whether an expression contains balanced parenthesis is?

A. Stack
B. Queue
C. Array
D. Tree
Answer» B. Queue
699.

The postfix form of the expression (A+ B)*(C*D- E)*F / G is?

A. AB+ CD*E – FG /**
B. AB + CD* E – F **G /
C. AB + CD* E – *F *G /
D. AB + CDE * – * F *G /
Answer» B. AB + CD* E – F **G /
700.

Here is an infix expression: 4 + 3*(6*3-12). Suppose that we are using the usual stack algorithm to convert the expression from infix to postfix notation.
The maximum number of symbols that will appear on the stack AT ONE TIME during the conversion of this expression?

A. 1
B. 2
C. 3
D. 4
Answer» E.