0% found this document useful (0 votes)
11 views4 pages

DSA MCQs

The document contains multiple-choice questions (MCQs) on data structures and algorithms, specifically focusing on linear data structures such as linked lists, stacks, and queues. It includes questions about memory allocation, time complexity, and various operations related to these data structures. The document serves as a study guide for students at the Saveetha Institute of Medical and Technical Sciences.

Uploaded by

Sivakumar muthu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views4 pages

DSA MCQs

The document contains multiple-choice questions (MCQs) on data structures and algorithms, specifically focusing on linear data structures such as linked lists, stacks, and queues. It includes questions about memory allocation, time complexity, and various operations related to these data structures. The document serves as a study guide for students at the Saveetha Institute of Medical and Technical Sciences.

Uploaded by

Sivakumar muthu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

SIMATS SCHOOL OF ENGINEERING

SAVEETHA INSTITUTE OF MEDICAL AND TECHNICAL SCIENCES


CHENNAI-602105

DATA STRUCTURES AND ALGORITHMS


TOPIC WISE – MCQs
1. LINEAR DATA STRUCTURES (Linked list, Stack, Queue)

S.N Questions Answer


o
An array is a ——— type of data structure
1 (a).linear
(a) linear (c) dynamic (b) non-linear (d) (a) and (b)
The data type defined by the user is known as ———.
(d).none of
2 (a) abstract data type (c) classic data type (b) built-in data type
these
(d) none of the above
The elements of linked lists are stored in (b).random
3 (a) successive memory locations (c) alternate memory locations memory
(b) random memory locations (d) all of the above. allocation
Name the function that is used for memory allocation in
4 implementation of linked list (a).malloc
(a) malloc() (b) realloc() (c) free() (d) both (a) and (c).
If it is decided to create the linked list in C++, function that allocates
5 memory is
(b) new
(a) malloc() (b) new (c) delete (d) both (a) and (b).
The free() function is used to (a). release the
6 (a) release the memory (b) to unlink the node (c) to unlink the first and
memory
last node (d) none of the above.
This type of linked list does not have null value in the last node (a) circular
7 (a) circular linked list (b) singly linked list (c) static list
linked list
(d) None of the above.
The first node of this type of linked list has NULL value (a) doubly
8 (a) doubly linked list (b) doubly circular linked list (c) singly linked list
linked list
(d) all of the above.
This type of linked list does not have first and last node
9 (a) circular linked list (c) doubly linked list (b) singly linked list (d) static list
(d) static list.
Which of the following can be done with Linked List?
(a).Implementation of Stacks and Queues (d).All of the
10
(b).Implementation of Binary Trees (c).Implementation of Data Structures above
that can simulate Dynamic Arrays (d).All of the above
What is the time complexity of a program to reverse a linked list?
11 (a) O(n)
(a) O(n) (b) O(1) (c) O(n^2) (d) None of these
What is the time complexity to insert an element to the front of a
12 Linked List(head pointer given)? (b)O(1)
(a) O(n) (b)O(1) (c) O(log n) (d)None of these
13 (a) 1 2 3 4 5
Page 1 of 4
What will be the output of the following code snippet for 1->2->3-
>4->5?
void solve (ListNode* head) {
while(head != NULL) {
cout << head -> data << " ";
head = head -> next;
}
}
(a) 1 2 3 4 5 (b) 5 4 3 2 1 (c) 1 3 5 2 4 (d) 2 4 1 3 5
What will be the output of the following code snippet for the list 1-
>2->3->4->5->6?
void solve(struct node* start)
{
if(start == NULL)
return;
14 (b) 1 3 5 5 3 1
printf("%d ", start->data);
if(start->next != NULL )
solve(start->next->next);
printf("%d ", start->data);
}
(a) 1 2 3 4 5 6 (b) 1 3 5 5 3 1 (c) 1 3 5 1 3 5 (d) 2 4 6 1 3 5
Which data structure is used in a compiler for managing
information about variables and their attributes? (b) Symbol
15
(a) Abstract Syntax Tree (b) Symbol Table (c) Semantic Tack Table
(d) Parse Table
Which of the following algorithms is not feasible to implement in a (d) Binary
16 linked list?
Search
(a) Linear Search (b) Merge Sort (c) Insertion Sort (d) Binary Search
Which of the following are applications of linked lists? (d) All of the
17 (a)Implementing file systems (b) Chaining in hash tables (c) Binary
above
Tree Implementation (d) All of the above
Which of the following is optimal to find an element at kth position (d) Array
18 at the linked list? implementation
(a) Singly (b) Doubly (c) Circular (d) Array implementation of linked list of linked list
Which of the following linked list operation takes O(1) time? (a) Insert
19 (a) Insert element at start (b) Insert element at last (c) Find length element at
(d) None of these start
Which of the following variations of linked lists can we use to
20 search a sorted list in better than amortized O(n) complexity? (c) Skip list
(a)Singly linked list (b) Doubly linked list (c) Skip list (d) None of these
In a circular linked list insertion of a record requires the
21 modification of? (b) 2 pointer
(a) 1 pointer (b) 2 pointer (c) 3 pointer (d) 4 pointer
Polynomial addition can be implemented using which of the
22 following data structure? (a) Linked list
(a)Linked list (b) Stack (c) Queue (d) None of these
23 What does the following code snippet do? (a) Find middle
int solve (ListNode* list) { element in the
ListNode* fast = list; linked list
ListNode* slow = list;

Page 2 of 4
while(fast -> next != NULL && fast -> next -> next != NULL) {
fast = fast -> next -> next;
slow = slow -> next;
}
return slow -> data;
}
(a) Find middle element in the linked list (b) Find last element in the
linked list (c) Find first element in the linked list (d) None of these
What is the optimal time complexity to count the number of nodes
24 in a linked list? (a) O(n)
(a) O(n) (b) O(1) (c) O(log n) (d) None of these
A stack holding elements equal to its capacity and if push is
performed then such situation is called (a) stack
25
(a) stack overflow (b) stack underflow (c) illegal operation overflow
(d) None of the above.
The postfix expression corresponding to the infix expression a + b ×
c - d ^ e ^ f is (a) abc × + def
26
(a) abc × + def ^ ^ - (b) abc × + de ^ f ^ - (c) ab + c × d - e ^ f ^ ^^-
(d) - + a × bc ^ ^ def
To evaluate an expression without any embedded function calls :
(a) As many stacks as the height of the expression tree are needed (b) One stack
27
(b) One stack is enough (c) Two stacks are needed (d) A Turing is enough
machine is needed in the general case
The result evaluating the postfix expression 10 5 + 60 6 / * 8 – is
28 (c) 142
(a) 284 (b) 213 (c) 142 (d) 71
Which of the following permutation can be obtained in the same
order using a stack assuming that input is the sequence 5, 6, 7, 8,
29 (c) 7, 8, 9, 6, 5
9 in that order?
(a) 7, 8, 9, 5, 6 (b) 5, 9, 6, 7, 8 (c) 7, 8, 9, 6, 5 (d) 9, 8, 7, 5, 6
The best data structure to check whether an arithmetic expression
30 has balanced parenthesis is a (b) Stack
(a) Queue (b) Stack (c) Tree (d) List
31 (a) (b) (c) (d)
32 (a) (b) (c) (d)
33 (a) (b) (c) (d)
34 (a) (b) (c) (d)
35 (a) (b) (c) (d)
36 (a) (b) (c) (d)
37 (a) (b) (c) (d)
38 (a) (b) (c) (d)
39 (a) (b) (c) (d)
40 (a) (b) (c) (d)
41 (a) (b) (c) (d)
42 (a) (b) (c) (d)
43 (a) (b) (c) (d)

Page 3 of 4
44 (a) (b) (c) (d)
45 (a) (b) (c) (d)
46 (a) (b) (c) (d)
47 (a) (b) (c) (d)
48 (a) (b) (c) (d)
49 (a) (b) (c) (d)
50 (a) (b) (c) (d)

Page 4 of 4

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy