# Data Structure Questions and Answers updated daily – Computer Knowledge

Data Structure Questions: Solved 242 Data Structure Questions and answers section with explanation for various online exam preparation, various interviews, Computer Knowledge Category online test. Category Questions section with detailed description, explanation will help you to master the topic.

## Data Structure Questions

101. The efficient data structure to insert/delete a number in a stored set of numbers is

Explanation:
Workspace

102. The min. number of nodes in a binary tree of depth d (root at level 0) is

Correct Ans:d + 1
Explanation:
Workspace

103. Suppose that the splits at every level of Quicksort are in proportion 1-? to ?, where 0 < ? < = 0.5 is a constant. The number of elements in an array is n. The maximum depth is approximately

Correct Ans:? (Ig n)/Ig (1 ? ?)
Explanation:
Workspace

104. The amortized time complexity to perform ______ operation(s) in Splay trees is O(Ig n).

Correct Ans:Search,Insert & Delete
Explanation:
Workspace

105. Consider an undirected graph G with 100 nodes. The maximum number of edges to be included in G so that the graph is not connected is

Correct Ans:4851
Explanation:
Workspace

106. B+ trees are preferred to binary trees in databases because

Correct Ans:Disk access is much slower than memory access
Explanation:
Disk access is slow and B+ Tree provide search in less number of disk hits. This is primarily because unlike binary search trees, B+ trees have very high fanout (typically on the order of 100 or more), which reduces the number of I/O operations required to find an element in the tree.
Workspace

107. Let s be a sorted array of n integers. Let t(n) denote the time taken for the most efficient algorithm to determine if there are two elements with sum less than 1000 in s. which of the following statements is true?

Correct Ans:t (n) is 0 (1)
Explanation:
Let array be sorted in ascending order, if sum of first two elements is less than 1000 then there are two elements with sum less than 1000 otherwise not. For array sorted in descending order we need to check last two elements. For an array data structure, number of operations are fixed in both the cases and not dependent on n, complexity is O(1)
Workspace

108. The most appropriate matching for the following pairs is:

X: depth first search ------- 1: heap
Y: breadth-first search ------- 2: queue
Z: sorting ------- 3: stack

Correct Ans:X—3 Y—2 Z-1
Explanation:
Stack is used for Depth first Search
Queue is used for Breadth First Search
Heap is used for sorting
Workspace

109. Let LASTPOST, LASTIN and LASTPRE denote the last vertex visited in a postorder, inorder and preorder traversal. Respectively, of a complete binary tree. Which of the following is always true?

Correct Ans:None of these
Explanation:
It is given that the given tree is complete binary tree. For a complete binary tree, the last visited node will always be same for inorder and preorder traversal. None of the above is true even for a complete binary tree.
Workspace

110. A circularly linked list is used to represent a Queue. A single variable p is used to access the Queue. To which node should p point such that both the operations enQueue and deQueue can be performed in constant time?

Correct Ans:rear node
Explanation:
Workspace

111. A data structure is required for storing a set of integers such that each of the following operations can be done in (log n) time, where n is the number of elements in the set.

1) Selection of the smallest element
2) Insertion of an element if it is not already present in the set

Which of the following data structures can be used for this purpose?

Correct Ans:A balanced binary search tree can be used but not a heap
Explanation:
Workspace

112. The following numbers are inserted into an empty binary search tree in the given order: 10, 1, 3, 5, 15, 12, 16. What is the height of the binary search tree (the height is the maximum distance of a leaf node from the root)?

Correct Ans:3
Explanation:
Workspace

113. Consider the label sequences obtained by the following pairs of traversals on a labeled binary tree. Which of these pairs identify a tree uniquely ?

i) preorder and postorder
ii) inorder and postorder
iii) preorder and inorder
iv) level order and postorder

Correct Ans:(ii), (iii)
Explanation:
Workspace

114. Consider the function f defined below.

struct item
{
int data;
struct item * next;
};

int f(struct item *p)
{
return (
(p == NULL) ||
(p->next == NULL) ||
(( P->data <= p->next->data) && f(p->next))
);
}

For a given linked list p, the function f returns 1 if and only if

Correct Ans:the elements in the list are sorted in non-decreasing order of data value
Explanation:
The function f() works as follows
1) If linked list is empty return 1
2) Else If linked list has only one element return 1
3) Else if node->data is smaller than equal to node->next->data and same thing holds for rest of the list then return 1
4) Else return 0
Workspace

115. Postorder traversal of a given binary search tree, T produces the following sequence of keys
10, 9, 23, 22, 27, 25, 15, 50, 95, 60, 40, 29
Which one of the following sequences of keys can be the result of an in-order traversal of the tree T?

Correct Ans:9, 10, 15, 22, 23, 25, 27, 29, 40, 50, 60, 95
Explanation:
Inorder traversal of a BST always gives elements in increasing order. Among all four options, a) is the only increasing order sequence.
Workspace

116. Given the following input (4322, 1334, 1471, 9679, 1989, 6171, 6173, 4199) and the hash function x mod 10, which of the following statements are true?

i. 9679, 1989, 4199 hash to the same value
ii. 1471, 6171 has to the same value
iii. All elements hash to the same value
iv. Each element hashes to a different value

Correct Ans:i and ii only
Explanation:
Workspace

117. Level order traversal of a rooted tree can be done by starting from the root and performing

Explanation:
Workspace

118. The best data structure to check whether an arithmetic expression has balanced parentheses is a

Correct Ans:stack
Explanation:
There are three types of parentheses [ ] { } (). Below is an arbit c code segment which has parentheses of all three types.

void func(int c, int a[])
{
return ((c +2) + arr[(c-2)]) ;
}

Stack is a straightforward choice for checking if left and right parentheses are balanced.
Workspace

119. Suppose you are given an array s[1…n] and a procedure reverse (s,i,j) which reverses the order of elements in a between positions i and j (both inclusive). What does the following sequence

do, where 1 < k <= n:
reverse (s, 1, k);
reverse (s, k + 1, n);
reverse (s, 1, n);

Correct Ans:Rotates s left by k positions
Explanation:
Workspace

120. The time complexity of the following C function is (assume n > 0)

int recursive (mt n)
{
if (n == 1)
return (1);
else
return (recursive (n-1) + recursive (n-1));
}

Correct Ans:0(2^n)
Explanation:
Recursive expression for the above program will be.

T(n) = 2T(n-1) + c
T(1) = c1.

Let us solve it.

T(n) = 2(2T(n-2) + c) + c = 4T(n-2) + 3c
T(n) = 8T(n-3) + 6c + c = 8T(n-3) + 7c
T(n) = 16T(n-4) + 14c + c = 16T(n-4) + 15c
............................................................
.............................................................
T(n) = (2^(n-1))T(1) + (2^(n-1) - 1)c

T(n) = O(2^n)
Workspace

Are you seeking for good platform for practicing Data Structure questions in online. This is the right place. The time you spent in Fresherslive will be the most beneficial one for you.

## Online Test on Data Structure @ Fresherslive

This page provides important questions on Data Structure along with correct answers and clear explanation, which will be very useful for various Interviews, Competitive examinations and Entrance tests. Here, Most of the Data Structure questions are framed with Latest concepts, so that you may get updated through these Data Structure Online tests. Data Structure Online Test questions are granted from basic level to complex level.

## Why To Practice Data Structure Test questions Online @ Fresherslive?

Data Structure questions are delivered with accurate answer. For solving each and every question, very lucid explanations are provided with diagrams wherever necessary.
Practice in advance of similar questions on Data Structure may improve your performance in the real Exams and Interview.
Time Management for answering the Data Structure questions quickly is foremost important for success in Competitive Exams and Placement Interviews.
Through Fresherslive Data Structure questions and answers, you can acquire all the essential idea to solve any difficult questions on Data Structure in short time and also in short cut method.
Winners are those who can use the simplest method for solving a question. So that they have enough time for solving all the questions in examination, correctly without any tense. Fresherslive provides most simplest methods to answer any tough questions. Practise through Fresherslive test series to ensure success in all competitive exams, entrance exams and placement tests.

## Why Fresherslive For Data Structure Online Test Preparation?

Most of the job seekers finding it hard to clear Data Structure test or get stuck on any particular question, our Data Structure test sections will help you to success in Exams as well as Interviews. To acquire clear understanding of Data Structure, exercise these advanced Data Structure questions with answers.
You're Welcome to use the Fresherslive Online Test at any time you want. Start your beginning, of anything you want by using our sample Data Structure Online Test and create yourself a successful one. Fresherslive provides you a new opportunity to improve yourself. Take it and make use of it to the fullest. GOODLUCK for Your Bright Future.

## Online Test

Online Test for Aptitude
Online Test for Logical Reasoning
Online Test for Computer Knowledge
Online Test for General Knowledge
Online Test for Data Interpretation
Online Test for Verbal Ability
Online Test for C++
Online Test for Networking
Online Test for Java
Online Test for C Language
FreshersLive - No.1 Job site in India. Here you can find latest 2023 government as well as private job recruitment notifications for different posts vacancies in India. Get top company jobs for both fresher and experienced. Job Seekers can get useful interview tips, resume services & interview Question and answer. Practice online test free which is helpful for interview preparation. Register with us to get latest employment news/rojgar samachar notifications. Also get latest free govt and other sarkari naukri job alerts daily through E-mail...