Data Structure... 1 To 5 Units
Data Structure... 1 To 5 Units
18. If the characters 'D', 'C', 'B', 'A' are placed in a queue (in that order), and then
removed one at a time, in what order will they be removed?
(a) ABCD (b) ABDC (c) DCAB (d) DCBA
Answer: d
19. What data structure is used to perform recursion?
(a) Stack (b) Queue (c) Linked List (d) Arrays
Answer: a
20. For the expression ((A + B) * C – (D – E)/(F + G)), the equivalent Postfix notation is
(a) AB + C * DE − − / FG + (b) AB + C * DE − FG + /−
(c) AB + C * DE − − FG + / (d) AB + C − DE − * FG + /
Answer: b
21. Which data structure allows deleting data elements from front and inserting at rear?
(a) Stacks (b) Queues
(c) Deques (d) Binary search tree
Answer: b
22. Identify the data structure which allows deletions at one end of the list but insertion
anywhere
(a) Input−restricted deque (b) Output−restricted deque
(c) Priority queues (d) None of above
Answer: c
23. One difference between a queue and a stack is _____.
(a) Queue can be implemented using linked lists, but stack cannot
(b) Stack can be implemented using linked lists, but queues cannot
(c) Queues use two ends of the structure; stacks use only one
(d) Stacks use two ends of the structure, queues use only one
Answer: d
24. Suppose we have a circular array implementation of the queue, with ten items in the
queue stored at data[2] through data[11], the current capacity is 12. Where does the
insert method place the new entry in the array?
(a) data[1] (b) data[0] (c) data[11] (d) data[12]
Answer: b
25. If we have implemented the queue with a linked list, keeping track of a front node
and a rear node with two reference variables. Which of these reference variables will
change during an insertion into a NONEMPTY queue?
(a) Neither changes (b) Only front changes
(c) Only rear changes (d) An exception is caused
Answer: c
Unit I | 1.3
DATA STRUCTURES AND FILES (SE IT) STACKS AND QUEUES
26. If we have implemented the queue with a linked list, keeping track of a front node
and a rear node with two reference variables. Which of these reference variables will
change during deletion into NONEMPTY queue?
(a) Neither changes (b) Only front changes
(c) Only rear changes. (d) An exception is caused
Answer: b
27. If we have implemented the queue with a linked list, keeping track of a front node
and a rear node with two reference variables. Which of these reference variables will
change during an insertion into a EMPTY queue?
(a) Neither changes (b) Only front changes
(c) Only rear changes (d) Both front and rear change
Answer: d
28. Queues and Stacks can be implemented using either arrays or linked lists.
(a) True (b) False
Answer: a
29. In order to input a list of values and output them in order, you could use a Queue.
(a) True (b) False
Answer: a
30. In order to input a list of values and output them in opposite order, you could use a
Stack.
(a) True (b) False
Answer: a
31. Which of the following is not the type of queue?
(a) Ordinary queue (b) Single ended queue
(c) Circular queue (d) Priority queue
Answer: a
32. Which is/are the application(s) of stack?
(a) Function calls (b) Parentheses check
(c) Evaluation of arithmetic expressions(d) All of the above
Answer: d
33. Stack is also called as _____.
(a) Last in first out (b) First in last out
(c) Last in last out (d) First in first out
Answer: a
Unit I | 1.4
DATA STRUCTURES AND FILES (SE IT) STACKS AND QUEUES
Unit I | 1.5
DATA STRUCTURES AND FILES (SE IT) STACKS AND QUEUES
Unit I | 1.6
DATA STRUCTURES AND FILES (SE IT) STACKS AND QUEUES
48. Which data structure is needed to convert infix notation to postfix notation?
(a) Branch (b) Queue (c) Tree (d) Stack
Answer: d
49. What is the result of the following operation done on stack S which is not full?
push (&S, 10); x = pop (&S); where S is a structure containing array and top
(a) x = −1 (b) x = 10 (c) x = Null (d) Error
Answer: b
50. The prefix form of an infix expression p + q − r * t is _____.
(a) + pq − *rt (b) − +pqr * t (c) − +pq * rt (d) − + * pqrt
Answer: c
51. The equivalent prefix expression for the following infix expression
(A+B)−(C+D*E)/F*G is
(a) −+AB*/+C*DEFG (b) /−+AB*+C*DEFG
(c) −/+AB*+CDE*FG (d) −+AB*/+CDE*FG
Answer: a
52. The result of evaluating the postfix expression 5, 4, 6, +, *, 4, 9, 3, /, +, * is _____.
(a) 600 (b) 350 (c) 650 (d) 588
Answer: b
53. The meaning of FIFO is _____ and it stands for _____.
(a) First In Fast Out, Stack (b) First In First Out, Stack
(c) First In First Out, Queue (d) First In Fast Out, Queue
Answer: c
54. The meaning of LIFO is _____ and it stands for _____.
(a) Last In First Out, Queue (b) Last In First Out, Stack
(c) Last In Fast Out, Stack (d) Last In First Out, Priority Queue
Answer: b
55. Adding data to stack is called _____.
(a) Push (b) Pop (c) Insert (d) Delete
Answer: a
56. Items can be removed from both ends of _____.
(a) queue (b) stack (c) tree (d) dequeue
Answer: d
Unit I | 1.7
DATA STRUCTURES AND FILES (SE IT) STACKS AND QUEUES
(a (b 5 (c (d) 9
4 4 9 3
6 6 6 2
Answer: d
Unit I | 1.8
DATA STRUCTURES AND FILES (SE IT) STACKS AND QUEUES
Unit I | 1.9
DATA STRUCTURES AND FILES (SE IT) STACKS AND QUEUES
Data Structures
Unit I
Introduction to C Programming
Q.8 Identify the wrong statement
A Subscripts are also known as indices
B Array variable and sub scripted variable are same
C Array name and sub scripted variable are different
D Array name and sub scripted variable are same
Answer D
if ( 3 + 2 - 5 )
printf ( "F" ) ;
if ( a = 10 )
printf ( "T1" ) ;
if ( -5 )
printf ( "T2" ) ;
A F, T1, T2
B T1, T2
C F, T1
D none of the above
Answer B
Data Structures
Unit I
Introduction to C Programming
int i = 200 ;
if ( i = 5 )
printf ( "True" ) ;
else
printf ( "false" ) ;
A false
B True
C syntax error
D none of the above
Answer B
int i = 200 ;
if ( i = 5 );
printf ( "false" ) ;
A false
B syntax error
C no output
D none of the above
Answer A
main( )
int i = 1 ;
while (i <= 10 ) ;
printf (i = i + 1) ;
}
A syntax error
B infinite loop
C prints values from 1to 10
Data Structures
Unit I
Introduction to C Programming
D none of the above
Answer B
main( )
for ( i = 10 ; i ; i -- )
printf ( "%d", i ) ;
}
A syntax error
B infinite loop
C prints values from 10 to 1
D prints values from 10 to 0
Answer C
i=1;
for ( i < 4 ; j = 5 ; j = 0 )
printf ( "%d", i ) ;
A syntax error
B infinite loop
C prints values
D none of the above
Answer C
main( )
int i = 1 ;
for ( ; i <= 10 ; )
printf ( "%d\n", i ) ;
i=i+1;
Data Structures
Unit I
Introduction to C Programming
}
A syntax error
B infinite loop
C prints values from 1to 10
D none of the above
Answer C
for( i=0;i<=10;i++)
if(i==5)
Break;
Printf(“try”);
}
A prints try four times
B prints try five times
C prints try ten times
D none of the above
Answer B
Q.29 Which of the following are themselves a collection of different data types?
A string
B structures
C char
D All of the mentioned
Answer B
Q.30 Which operator connects the structure name to its member name?
A -
B <-
C .
D Both (b) and (c)
Answer C
int no;
char name[20];
}
void main()
struct student s;
s.no = 8;
Data Structures
Unit I
Introduction to C Programming
printf("hello");
}
A Compile time error
B Nothing
C hello
D Varies
Answer A
int k;
char c;
};
A Multiple of integer size
B integer size+character size
C Depends on the platform
D Multiple of word size
Answer B
Q.35 The time complexities of thee algorithms is as given below. Choose the slowest
algorithm.
A O(n0.5)
B O(n)
C O(logn)
D None of these
Answer B
Q.36 The correct syntax to access the member of the ith structure in the array of
structures is?
Assuming: struct temp
{
int b;
}s[50];
A s.b.[i];
B s.b[i]
C s[i].b;
D none of these
Answer C
Q.38 What is the correct syntax to declare a function foo() which receives an array of
structure in function?
A void foo(struct *var);
B void foo(struct *var[]);
C void foo(struct var);
D None of the mentioned
Answer A
Q.39 What will happen if in a C program you assign a value to an array element whose
subscript exceeds the size of array?
A The element will be set to 0.
B The compiler would report an error.
C The program may crash if some important data gets overwritten.
D The array size would appropriately grow.
Answer C
Data Structures
Unit I
Introduction to C Programming
Q.43 What will be the output of the program if the array begins 1200 in memory?
#include<stdio.h>
int main()
{
int arr[]={2, 3, 4, 1, 6};
printf("%u, %u, %u\n", arr, &arr[0]);
return 0;
}
A 1200, 1202
B 1200, 1200
C 1200, 1204
D 1200, 1202
Answer B
Q.44 What will be the output of the program in Turb C (under DOS)?
#include<stdio.h>
int main()
{
int arr[5], i=0;
while(i<5)
arr[i]=++i;
for(i=0; i<5; i++)
printf("%d, ", arr[i]);
return 0;
}
A 1, 2, 3, 4, 5,
B Garbage value, 1, 2, 3, 4,
C 0, 1, 2, 3, 4,
D 2, 3, 4, 5, 6,
Answer B
Q.53 If the two strings are identical, then strcmp() function returns
A -1
B 1
C 0
D YES
Answer C
Q.54 The library function used to find the first occurrence of a character in a string is
A strnstr()
B laststr()
C strrchr()
D strstr()
Answer D
Q.55 Which of the following function is more appropriate for reading in a multi-word
string?
A printf();
B scanf();
C gets();
D getc()
Answer C
Q.57 Which of the following function is correct that finds the length of a string?
A int xstrlen(char *s)
{ int length=0;
while(*s!='\0')
{ length++;
Data Structures
Unit I
Introduction to C Programming
s++;
}
return (length);
}
B int xstrlen(char s)
{
int length=0;
while(*s!='\0')
length++;
s++;
return (length);
}
C int xstrlen(char *s)
{
int length=0;
while(*s!='\0')
length++;
return (length);
}
D int xstrlen(char *s)
{
int length=0;
while(*s!='\0')
s++;
return (length);
}
Answer A
Q.66 int long k[4] the total memory occupied by the array is ________.
A 16
B 8
C 4
D 32
Answer A
Q.67 Which of the following are themselves a collection of different data types?
A string
B structures
C char
D All of the mentioned
Answer B
Q.68 Which operator connects the structure name to its member name?
A -
B <-
C .
D Both (b) and (c)
Answer C
Data Structures
Unit I
Introduction to C Programming
Q.71 Which of the following uses structure?
A Array of structures
B Linked Lists
C Binary Tree
D All of the mentioned
Answer D
Q.72 What is the correct syntax to declare a function foo() which receives an array of
structure in function?
A void foo(struct *var);
B void foo(struct *var[]);
C void foo(struct var);
D None of the mentioned
Answer A
int k;
char c;
};
A Multiple of integer size
B integer size+character size
C Depends on the platform
D Multiple of word size
Answer B
Q.75 The correct syntax to access the member of the ith structure in the array of
structures is?
Data Structures
Unit I
Introduction to C Programming
Assuming: struct temp
{
int b;
}s[50];
A s.b.[i];
B s.b[i]
C s[i].b;
D none of these
Answer C
Q.88 Each array declaration need not give, implicitly or explicitly, the information
about
A the name of array
B the data type of array
C the first data from the set to be stored
D the index set of the array
Answer C
Q.89 The elements of an array are stored successively in memory cells because
A by this way computer can keep track only the address of the first element and the
addresses of other elements can be calculated
B the architecture of computer memory does not allow arrays to store other than
serially
C both of above
D none of above
Answer A
Q.90 From faster to slower, the correct ordering of the complexity classes O[1],O[n2],
O[log2 n], O[log2(n2)], O[n] is:
A O[1], O[log2(n2)], O[log2 n], O[n2], O[n]
B O[n], O[n2], O[log2 n], O[log2(n2)], O[1]
C O[log2 n], O[1], O[n], O[n2], O[log2(n2)]
D O[1], O[log2 n], O[log2(n2)], O[n], O[n2]
Answer D
Q.91 What kind of data structure would you use to store information about a set of
customers and to look up a customer's address knowing only the last name?
A structure
B array of structures
C two-dimensional ARRAY
D structure containing a string for each
customer
Answer B
Q.92 Which algorithm is most similar to the way many people would sort a hand of
cards?
A insertion sort
B Bubble sort
C selection sort
D None of above
Answer A
Data Structures
Unit I
Introduction to C Programming
Q.93 What will be output when you will execute following c code?
#include<stdio.h>
void main()
{
char arr[7]="Network";
printf("%s",arr);
}
A Network
B N
C Garbage value
D None of above
Answer C
Q.94 This function accepts a pointer to a string as an argument, and it returns the
length of the string (not including the null terminator).
A numchar
B strlength
C strlen
D countstring
Answer C
Q.96 This function concatenates the contents of one string with another string.
A strcopy
B strappend
C strcat
D stradd
Answer C
Q.97 To define an array that will store students' last names of up to 25 characters in
length, which is an appropriate statement?
A char lastName[25];
B string lastName[25];
C char lastName[26];
D string lastName[24];
Answer C
Q.99 If the address of A[1][1] and A[2][1] are 1000 and 1010 respectively and each
element
occupies 2 bytes then the array has been stored in _________ order.
A row major
B column major
C matix major
D A
Answer
Q.104 a short integer occupies 2 bytes, an ordinary integer 4 bytes and long integer
consists of 8 bytes of memory. A structure is defined as struct ABC
{ short x;
int y;
long z;
}abc[10];
total memory required for abc is
A 40
B 24
Data Structures
Unit I
Introduction to C Programming
C 15
D 140
Answer D
Q.105 a double occupies 8 bytes, an ordinary integer 4 bytes and char consists of 1 byte
of memory. A union is defined as
union test
{
double x;
int y[10];
char z;
}abc[10];
total memory required for test is
A 8
B 4
C 80
D 40
Answer D
A hi
B h
C compile time error
D none of these
Answer A
}
A he
B hh
C ee
D syntax error
Answer B
Q.121 A pointer is
A A keyword used to create variables
B A variable that stores address of an instruction
C A variable that stores address of other variable
D All of the above
Answer C
Q.122 The operator used to get value at address stored in a pointer variable is
A *
B &
C &&
D ||
Answer A
Q.127 11 ^ 5
What does the operation shown above produce?
A 1
B 6
C 8
D 14
Answer D
Q.128 From the following data structures which is Non primitive data structure?
A Int
B Stacks
C Char
Data Structures
Unit I
Introduction to C Programming
D Float
Answer B
Q.129 Variables that can be accessed by functions within its scope are called as
A Global
B Search
C Local
D Nonlocal
Answer C
B They carry two important things: the definitions and prototypes of functions
being used in a program
C stdio.h is a header file that contains definition and prototypes of commands like
printf and scanf
D All of above are correct
Answer D
A Single Alternative
B Double Alternative
C Multiple Alternative
Data Structures
Unit I
Introduction to C Programming
D No Alternative
Answer B
A Two
B As many as
C One
D Zero
Answer C
Q.138 Which statement of the following allocates memory to store forty real numbers.
A float a[40];
B float a(40);
C int a(40);
D float a{40};
Answer A
Data Structures
Unit I
Introduction to C Programming
Q.142 What will be output if you will compile and execute the
following ‘C’ code?
#include<stdio.h>
int main()
Data Structures
Unit I
Introduction to C Programming
{
int i=4,x;
x=++i + ++i + ++i;
printf("%d",x);
return (0);
}
A 21
B 18
C 12
D Compiler error
Answer A
}
ch can have data type as
A float
B User defined
C int or char
D int only
Answer C
A 1
B 2
C 4
D 8
Answer B
Q.148 What will happen if in a C program you assign a value to an array element whose
subscript exceeds the size of array?.
A The element will be set to 0.
#include<stdio.h>
int main()
{
int a[5] = {5, 1, 15, 20, 25};
int i, j, m;
i = ++a[1];
j = a[1]++;
m = a[i++];
printf("%d, %d, %d", i, j, m);
return 0;
}
A 2, 1, 15
B 1, 2, 5
C 3, 2, 15
D 2, 3, 20
Answer C
Q.150 What will be the output of the program in Turb C (under DOS)?
#include<stdio.h>
int main()
{
Data Structures
Unit I
Introduction to C Programming
int arr[5], i=0;
while(i<5)
arr[i]=++i;
return 0;
}
A 1, 2, 3, 4, 5
B 0, 1, 2, 3, 4
C Garbage Value, 1, 2, 3, 4
D 2, 3, 4, 5, 6
Answer C
Q.151 What will be the output of the program if the array begins 1200 in memory?
A 1200, 1202, 1204
B 1200, 1200, 1200
C 1200, 1204, 1208
D 1200, 1202, 1200
Answer B
Q.152 The keyword used to transfer control from a function back to the calling function
is.
A switch
B return
C go back
D go to
Answer B
Q.154 Which of the following case does not exist in complexity theory
A Best case
B Worst case
C Average case
D Null case
Answer D
Data Structures
Unit I
Introduction to C Programming
D Item is the last element in the array or is not there at all
Answer C
Q.158 The elements of an array are stored successively in memory cells because
A by this way computer can keep track only the address of the first element and the
addresses of other elements can be calculated by this way computer can keep
track only the address of the first element and the addresses of other elements can
be calculated
B the architecture of computer memory does not allow arrays to store other than
serially
C both of above
D none of above
Answer A
Q.159 When new data are to be inserted into a data structure, but there is no available
space; this situation is usually called.
A underflow
B overflow
C housefull
D saturated
Answer B
Q.161 The keyword used to transfer control from a function back to the calling function
is
Data Structures
Unit I
Introduction to C Programming
A switch
B goto
C go back
D return
Answer D
Q.162 Which of the following is the correct order of evaluation for the below
expression?
z=x+y*z/4%2-1
A */%+-=
B =*/%+-
C /*%-+=
D *%/-+=
Answer A
Q.167 The extra key inserted at the end of the array is called a,
A End key.
B Stop key.
C Sentinel.
D Transposition
Answer C
Data Structures
Unit I
Introduction to C Programming
A 01234
B 0000
C Infinite loop
D Compilation error
Answer B
Q.173 There are four different algorithm A1, A2, A3, A4 to solve the given problem
with the order log(n) , (nlogn),(log n)/n, n/logn respectively. Which is the best
algorithm ?
A A1
B A2
C A3
D A4
Answer D
Q.174 Time complexity of three algorithms given as :O(n), O(n¬2 ) and O(logn). Which
should execute slowest for large value of n?
A O(n¬2 )
B O(logn)
C O(n)
D None of these
Answer D
Data Structures
Unit I
Introduction to C Programming
Q.175 The space factor when determining the efficiency of algorithm is measured by
______
A Counting the maximum amount of memory needed by the algorithm
B Counting the minimum amount of memory needed by the algorithm
C Counting the average memory needed by the algorithm
D Counting maximum disk space needed by an algorithm
Answer D
Q.176 The time factor when determine by the efficiency of algorithm is measured by
_____
A Counting seconds
B Counting the kilobyte of algorithm
C Counting key operations
D Counting the number of statements
Answer C
Q.177 The worst case occur in linear search algorithm when searching_________
A Item is somewhere in the middle of the array
B Item is not in the array at all
C Item is the last element in the array
D Item is the last element in the array or not present in the array
Answer D
Q.178 Which of the following does not exist in the algorithmic complexity?
A Best case
B Worst case
C Average case
D Null case
Answer D
Q.181 For binary files, a ___ must be appended to the mode string.
A Nothing
Data Structures
Unit I
Introduction to C Programming
B “b”
C “binary”
D “01”
Answer B
Q.182 What will fopen will return, if there is any error while opening a file?
A Nothing
B EOF
C NULL
D Depends on compiler
Answer C
Q.185 If the mode includes b after the initial letter, what does it indicates?
A text file
B big text file
C binary file
D blueprint text
Answer C
Q.186 EOF is an integer type defined in stdio.h & has a value ____________
A 1
B 0
C NULL
D -1
Answer D
Data Structures
Unit II
Searching and Sorting Algorithms
Q.1 The worst case occurs in linear search algorithm when .......
A Item is somewhere in the middle of the array
B Item is not in the array at all
C Item is the last element in the array
D Item is the last element in the array or item is not there at all
Answer D
Q.2 If the number of records to be sorted is small, then ...... sorting can be efficient.
A Merge
B Heap
C Selection
D Bubble
Answer C
Data Structures
Unit II
Searching and Sorting Algorithms
Answer C
Q.4 The complexity of sorting algorithm measures the ...... as a function of the
number n of items to be sorter.
A average time
B running time
C average-case complexity
D case-complexity
Answer B
Q.5 What will be the output of the program in Turb C (under DOS)?
>
int main()
{
int arr[5], i=0;
while(i<5)
arr[i]=++i;
return 0;
}
A 1, 2, 3, 4, 5,
B Garbage value, 1, 2, 3, 4,
C 0, 1, 2, 3, 4,
D 2, 3, 4, 5, 6,
Answer B
Data Structures
Unit II
Searching and Sorting Algorithms
the same primary key occurs in the same order in the
sorted list as in the original unsorted list is said to be
A Stable
B Consistent
C External
D Linear
Answer A
Data Structures
Unit II
Searching and Sorting Algorithms
Answer A
Data Structures
Unit II
Searching and Sorting Algorithms
i)Internal sorting are applied when the entire collection if data to be sorted is
small enough that the sorting can take place within main memory.
ii)The time required to read or write is considered to be significant in evaluating
the performance of internal sorting.
A i-True, ii-True
B i-True, ii-False
C i-False, ii-True
D i-False, ii-False
Answer B
Q.15 What will be the output of the program in Turb C (under DOS)?
#include<stdio.h>
int main()
{
int arr[5], i=0;
while(i<5)
arr[i]=++i;
return 0;
}
A 1, 2, 3, 4, 5,
B Garbage value, 1, 2, 3, 4,
C 0, 1, 2, 3, 4,
D 2, 3, 4, 5, 6,
Answer B
Data Structures
Unit II
Searching and Sorting Algorithms
B O(logn)
C O(n2)
D O(n logn)
Answer D
Q.17 .......... is putting an element in the appropriate place in a sorted list yields a
larger sorted order list.
A Insertion
B Extraction
C Selection
D Distribution
Answer A
Q.18 ............order is the best possible for array sorting algorithm which sorts n item.
A O(n logn)
B O(n2)
C O(n+logn)
D O(logn)
Answer C
Q.19 ......... is rearranging pairs of elements which are out of order, until no such pairs
remain.
A Insertion
B Exchange
C Selection
D Distribution
Answer B
Data Structures
Unit II
Searching and Sorting Algorithms
C Heap
D Quick
Answer A
Q.21 Which of the following sorting algorithm is of divide and conquer type?
A Bubble sort
B Insertion sort
C Merge sort
D Selection sort
Answer C
Q.22 ........ sorting algorithm is frequently used when n is small where n is total
number of elements.
A Heap
B Insertion
C Bubble
D Quick
Answer B
Q.23 Which of the following sorting algorithm is of priority queue sorting type?
A Bubble sort
B Insertion sort
C Merge sort
D Selection sort
Answer D
Q.24 Which of the following is not the required condition for binary search
algorithm?
A The list must be sorted
B There should be the direct access to the middle element in any sub list
C There must be mechanism to delete and/or insert elements in list.
Data Structures
Unit II
Searching and Sorting Algorithms
D Number values should only be present
Answer C
Data Structures
Unit II
Searching and Sorting Algorithms
Q.29 The time complexity of a quick sort algorithm which makes use of median,
found by an O(n) algorithm, as pivot element is
A O(n2)
B O(nlogn)
C O(nloglogn)
D O(n)
Answer B
Answer C
Q.32 If the given input array is sorted or nearly sorted, which of the following
algorithm gives the best performance?
A Insertion Sort
B Selection Sort
C Quick Sort
D Merge Sort
Answer A
Data Structures
Unit II
Searching and Sorting Algorithms
Q.33 Which of the following algorithm pays the least attention to the ordering of the
elements in the input list?
A Insertion Sort
B Selection Sort
C Quick Sort
D None
Answer B
Q.34 Consider the situation in which assignment operation is very costly. Which of
the following sorting algorithm should be performed so that the number of
assignment operations is minimized in general?
A Insertion Sort
B Selection Sort
C Heap Sort
D None
Answer B
Q.36 Given a number of elements in the range [0….n3]. which of the following
sorting algorithms can sort them in O(n) time?
A Counting sort
B Bucket sort
C Radix sort
D Quick sort
Answer C
Data Structures
Unit II
Searching and Sorting Algorithms
Q.37 Which of the following algorithms has lowest worst case time complexity?
A Insertion Sort
B Selection Sort
C Quick Sort
D Heap Sort
Answer D
Marks 1
Q.39 What will be output if you will compile and execute the following c code?
#include<stdio.h>
#include<conio.h>
#define x 5+2
void main()
{
int i;
i=x*x*x;
printf("%d",i);
}
A 343
B 27
C 133
D compiler error
Answer B
Data Structures
Unit II
Searching and Sorting Algorithms
Q.40 What will be output if you will compile and execute the following c code?
#include<stdio.h>
#include<conio.h>
void main(){
int i=320;
char *ptr=(char *)&i;
printf("%d",*ptr);
}
A 320
B 1
C 64
D compiler error
Answer C
Q.41 Which of the following sorting method will be the best if number of swapping
done is the only measure of efficienty?
A bubble sort
B Selection sort
C insertion sort
D none of these
Answer B
Q.42 What is the time complexity of selection sort for n number of elements?
A O(n*n)
B O(n(logn))
C O(log n)
D O(2n)
Answer A
Q.43 The way a card game player arranges his cards as he picks them up one by one,
is an example of
Data Structures
Unit II
Searching and Sorting Algorithms
A bubble sort
B Selection sort
C insertion sort
D none of these
Answer C
Q.44 A sorting technique that guarantees that records with the same primary key
occurs in the same order in the sorted list as in the original unsorted list is said
to be
A Stable
B Consistent
C External
D Linear
Answer A
Q.46 The number of swappings needed to sort the numbers 8, 22, 7, 9, 31, 19, 5, 13
in ascending order, using bubble sort is
A 11
B 12
C 13
D 14
Answer D
Data Structures
Unit II
Searching and Sorting Algorithms
Q.47 A sort which iteratively passes through a list to exchange the first element with
any element less than it and then repeats with a new first element is called
A insertion sort
B bubble sort
C selection sort
D none of these
Answer C
Q.48 A sort which compares adjacent elements in a list and switches where necessary
is
A insertion sort
B bubble sort
C selection sort
D none of these
Answer B
Q.50 The worst case time required to search a given element in a sorted linked list of
length n is
A O(1)
B O(log2 n)
C O(n)
D O(n log2 n)
Answer C
Data Structures
Unit II
Searching and Sorting Algorithms
Q.51 Which of the following sorting algorithm has the running time that is least
dependant on the initial ordering of the input?
A Insertion Sort
B Quick Sort
C Merge Sort
D Selection Sort
Answer D
Q.54 Which of the following algorithm(s) can be used to sort n integers in range
[1…..n3] in O(n) time?
A Heap
B Quick
C Merge
D Radix
Answer D
Data Structures
Unit II
Searching and Sorting Algorithms
Q.55 Which of the following algorithm design technique is used in the quick sort
algorithm?
A Dynamic programming
B Backtracking
C Divide-and-conquer
D Greedy method
Answer C
Q.57 For merging two sorted lists of size m and n into sorted list of size m+n, we
require comparisons of
A O(m)
B O(n)
C O(m+n)
D O(logm + logn)
Answer C
Data Structures
Unit II
Searching and Sorting Algorithms
Q.59 In a heap with n elements with the smallest element at the root, the seventh
smallest element can be found in time
A θ (nlogn)
B θ (n)
C θ (logn)
D θ (1)
Answer A
Q.60 What would be the worst case time complexity of the insertion sort algorithm, if
the inputs are restricted to permutation of 1…..n with at most n inversion?
A θ (n2)
B θ (nlogn)
C θ (n1.5)
D θ (n)
Answer D
Q.61 In a binary max heap containing n numbers, the smallest element can be found
in time
A θ (n)
B θ (logn)
C θ (loglogn)
D θ (1)
Answer A
Q.62 The time complexity of linear search algorithm over an array of n elements is
A O (log2 n)
B O(n)
C O(n log2 n)
D 0 (n2)
Answer B
Data Structures
Unit II
Searching and Sorting Algorithms
Q.63 The time required to search an element in a linked list of length n is
A O(log2 n)
B O(n)
C O(1)
D 0 (n2)
Answer B
Q.64 The worst case time required to search a given element in a sorted linked list of
length n is
A O(1)
B O(log2 n)
C O(n)
D O(n log2 n)
Answer B
Q.65 For a linear search in an array of n elements the time complexity for best, worst
and average case are ......., ....... and ........ respectively
A O(n), O(1), and O(n/2)
B O(1), O(n) and O(n/2)
C O(1),O(n) and O(n)
D O(1), O(n) and (n-1/2)
Answer C
Q.66. The average time required to perform a successful sequential search for an
element in an array A(1 : n) is given by
A (n + 1)/2
B log2n
C n(n + 1)/2
D n2
Answer A
Data Structures
Unit II
Searching and Sorting Algorithms
Q.67 Using the standard algorithm, what is the time required to determine that a
number n is prime?
A Linear time
B Logarithmic time
C Constant time
D Quadratic time
Answer A
Q.68 The average time required to perform a successful sequential search for an
element in an array A (1 : n) is given by
A (n+1)/2
B n (n + 1)/2
C log(n/2)
D n2
Answer A
Q.70 A search begins the search with the element that is located in the middle of the
array
A Serial
B Random
C Parallel
D Binary
Data Structures
Unit II
Searching and Sorting Algorithms
Answer D
Data Structures
Unit II
Searching and Sorting Algorithms
A Search method divides given array in unequal parts
B uses division operator to divide range
C examines relatively closer elements in subsequent steps
D Has Log n time complexity.
Answer D
Q.77 The worst case occur in linear search algorithm when searching _______
A Item is somewhere in the middle of the array
B Item is not in the array at all
C Item is the last element in the array
D Item is the last element in the array or not present in the array
Answer D
Q.79 Which of the following does not exist in the algorithm complexity ?
A Best case
B Worst case
C Average case
Data Structures
Unit II
Searching and Sorting Algorithms
D Null case
Answer D
Q.82 What is the time complexity of bubble sort for n number of elements?
A O(log n)
B O(n(logn))
C O(n*n)
D O(2n)
Answer C
Q.83 What is the time complexity of insertion sort for n number of elements?
A O(n(logn))
B O(n*n)
C O(2n)
D O(log n)
Answer B
Data Structures
Unit II
Searching and Sorting Algorithms
Q.84 What is the time complexity of selection sort for n number of elements?
A O(n*n)
B O(n(logn))
C O(log n)
D O(2n)
Answer A
Q.85 The worst case time required to search a given element in a sorted linked list of
length n is
A O(1)
B O(log2 n)
C O(n)
D O(n log2 n)
Answer C
Q.87 A sort which compares adjacent elements in a list and switches where necessary
is
A insertion sort
B bubble sort
C selection sort
D none of these
Answer B
Data Structures
Unit II
Searching and Sorting Algorithms
Q.88 A sort which iteratively passes through a list to exchange the first element with
any element less than it and then repeats with a new first element is called
A insertion sort
B bubble sort
C selection sort
D none of these
Answer C
Q.89 A search begins the search with the element that is located in the middle of the
array
A Serial
B Random
C Parallel
D Binary
Answer D
Q.91 For a linear search in an array of n elements the time complexity for best, worst
and average case are ......., ....... and ........ respectively
A O(n), O(1), and O(n/2)
B O(1), O(n) and O(n/2)
C O(1),O(n) and O(n)
D O(1), O(n) and (n-1/2)
Answer C
Data Structures
Unit II
Searching and Sorting Algorithms
Q.92 The average successful search time for sequential search on 'n' items is
A n/2
B (n-1)/2
C (n+1)/2
D log (n)+1
Answer C
Q.93 A characteristic of the data that binary search uses but the linear search ignores
is the___________
A Order of the elements of the list
B Length of the list
C Maximum value in list
D Type of elements of the list
Answer A
Q.95 Suppose DATA array contains 1000000 elements. Using the binary search
algorithm, one requires only about n comparisons to find the location of an item
in the DATA array, then n is
A 60
B 45
Data Structures
Unit II
Searching and Sorting Algorithms
C 20
D None of these
Answer C
Data Structures
Unit II
Searching and Sorting Algorithms
Q.100 If the search item lies in the upper half in case of binary search which is the
correct set of statements.
A top = mid + 1;
B top = mid - 1;
C bot = mid + 1;
D bot = mid - 1;
Answer D
Q.101 What is the time taken by the binary search algorithm to search a key ‘k’ in a
sorted array of ‘n’ elements?
A O(log2 n)
B O(n)
C O(n2)
D O(2n)
Answer C
Q.102 ------------------is a search for data that uses an index to locate the item
A Binary search
B Sequential search
C Indexed search
D Jump search
Answer C
Q.103 The space factor when determining the efficiency of algorithm is measured by
A Counting the maximum memory needed by the algorithm
B Counting the maximum memory needed by the algorithm
C Counting the average memory needed by the algorithm
D Counting the kilobytes of algorithm
Answer A
Data Structures
Unit II
Searching and Sorting Algorithms
Q.103 How many number of swaps required to sort n elements using selection sort in
worst case?
A O(n)
B O(n2)
C O(nlogn)
D O(log2n)
Answer A
Q.104 How many number of shifts required to sort n elements using Insertion sort in
worst case
A O(n)
B O(n2)
C O(nlogn)
D O(log2n)
Answer B
Q.105 How many number of swaps required to sort n elements using Bubble Sort in
worst case?
A O(n)
B O(n2)
C O(nlogn)
D O(log2n)
Answer B
Q.106 ____________ passes are required to sort n data using bubble sort
A N
B n-1
C n-2
D n+2
Answer B
Data Structures
Unit II
Searching and Sorting Algorithms
Q.107 Selection sort is called as_______
A divide sort
B (log n)sort
C Iinterchanged sort
D Exchange sort
Answer C
Q.110 There are four different Algorithms A1, A2, A3, A4 to solve the given problem
with the order log(n), (nlogn), log(logn), n/logn respectively. Which is the best
algorithm?
A A1
B A2
C A3
D A4
Answer A
Q.111 The time complexity of linear search algorithm over an array of n elements is
Data Structures
Unit II
Searching and Sorting Algorithms
A O (log2 n)
B O(n)
C O(n log2 n)
D O(n2)
Answer B
Q.114 A characteristic of the data that binary search uses but the linear search ignores
is the___________
A Order of the elements of the list
B Length of the list
C Maximum value in list
D Type of elements of the list
Answer A
Data Structures
Unit II
Searching and Sorting Algorithms
C Shell sort
D Bubble sort
Answer D
Q.116 A machine took 200 sec to sort 200 names, using bubble sort. In 800 sec, it can
approximately sort
A 400 names
B 800 names
C 750 names
D 800 names
Answer A
Q.117 Given a file of size n the number of times a given file is passed through in
bubble sort is
A n2
B n–1
C n log n
D None of the above
Answer B
Q.118 In bubble sort, for a file of size n, after p iterations number of records in proper
positions is
A n–p
B n-p+1
C P
D None of the above
Answer A
Q.119 For a file of size n, during each pth pass the number of last records left out are
Data Structures
Unit II
Searching and Sorting Algorithms
A n–p
B P
C p–1
D None of the above
Answer C
Q.120 A sort which iteratively passes through a list to exchange the first element with
any element less than it and then repeats with a new first element is called
A insertion sort
B selection sort
C heap sort
D quick sor
Answer B
Q.121 Which of the following sorting methods will be the best if number of swappings
done, is the only measure of efficienty?
A Bubble sort
B Selection sort
C Insertion sort
D Quick sort
Answer B
Q.121 What is the number of swaps required to sort n elements using selection sort, in
the worst case?
A T(n)
B T(n log n)
C T(n2)
D .T(n2 log n)
Answer A
Data Structures
Unit II
Searching and Sorting Algorithms
A Interchange
B Searching
C position adjustment
D None of the above
Answer C
Q.123 Which of the following sorting algorithms does not have a worst case running
time of O(n2)?
A Insertion sort
B Merge sort
C Quick sort
D Bubble sort
Answer B
Q.125 Assume 5 buffer pages are available to sort a file of 105 pages. The cost of
sorting using m-way merge sort is
A 206
B 618
C 840
D 926
Answer C
Data Structures
Unit II
Searching and Sorting Algorithms
B Last element of the list
C Randomly chosen element of the list
D Median of the list
Answer A
Q.128 A sort which relatively passes through a list to exchange the first element with
any element less than it and then repeats with a new first element is called
A Insertion sort
B Selection sort
C Heap sort
D Quick sort
Answer D
Data Structures
Unit III
Stack & Queue
Q.3 In a stack, if a user tries to remove an element from an empty stack it is called
_________
A Underflow
B Empty collection
C Overflow
D Garbage Collection
Answer A
Q.4 Pushing an element into stack already having five elements and stack size of 5, then
stack becomes ___________
A Overflow
B Crash
C Underflow
D User flow
Answer A
Q.6 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 A
Q.7 The data structure required for Breadth First Traversal on a graph is?
A Stack
B Array
Data Structures
Unit III
Stack & Queue
C Queue
D Tree
Answer C
Q.10 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 A
Q.12 Stack is data structure in which all insertion and deletions of entries are made at
A One end
B In the middle
C Both ends
D Any position
Answer A
Q.13 A queue is data structure in which all insertion and deletions are made
respectively at
A Rear & front
B Front and rear
C Front and front
D Rear and rear
Answer A
Data Structures
Unit III
Stack & Queue
Q.14 Which data structure is required to convert the infix to prefix
notation?
A Stack
B Linked List
C Binary Tree
D Queue
Answer A
Q.15 Which one of the following node is considered the top of the stack
if the stack is implemented using the linked list?
A First node
B Second node
C Last node
D None of the above
Answer A
Q.16 A list of elements in which enqueue operation takes place from one
end, and dequeue operation takes place from one end is__
A Binary tree
B Stack
C Queue
D Linked List
Answer C
Q.17 Which one of the following is not the type of the Queue?
A Linear queue
B Circular queue
C Double ended queue
D Single ended queue
Answer D
Q.18 Which one of the following is the overflow condition if linear queue
is implemented using an array with a size MAX_SIZE?
A Rear=front
B Rear=front+1
C Rear=MAX_SIZE-1
D Rear=MAX_SIZE
Answer C
Q.21 Which of the following that determines the need for the Circular
Queue?
A Avoid wastage of memory
B Access the Queue using priority
C Follows the FIFO principle
D None of the above
Answer A
Q.22 Which one of the following is the correct way to increment the rear
end in a circular queue?
A rear =rear+1
B (rear+1) % max
C (rear % max) + 1
D None of the above
Answer B
Q.23 In the linked list implementation of queue, where will the new
element be inserted?
A At the middle position of the linked list
B At the head position of the linked list
C At the tail position of the linked list
D None of the above
Answer C
Q.26 Which data structure is the best for implementing a priority queue?
A Stack
B Linked list
Data Structures
Unit III
Stack & Queue
C Array
D Heap
Answer D
Q.28 In the Deque implementation using singly linked list, what would
be the time complexity of deleting an element from the rear end?
A O(1)
B O(n2)
C O(n)
D O(nlogn)
Answer C
Data Structures
Unit III
Stack & Queue
Q.33 What data structure is used for breadth first traversal of a graph?
A Queue
B Stack
C List
D None of the above
Answer A
Answer D
Q.36 In conversion from prefix to postfix using stack data-structure, if operators and
operands are pushed and popped exactly once, then the run-time complexity is
A Ο(1)
B Ο(n)
C Ο(log n)
D Ο(n2)
Answer B
Q.37 If queue is implemented using arrays, what would be the worst run time complexity
of queue and dequeue operations?
A Ο(n), Ο(n)
B Ο(n), Ο(1)
C Ο(1), Ο(n)
D Ο(1), Ο(1)
Answer D
Q.40 What data structure can be used to check if a syntax has balanced parenthesis ?
A queue
B tree
C list
D stack
Answer D
Data Structures
Unit IV
Linked List
Q.2 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
Answer A
Q.4 In linked list each node contains 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 C
Q.5 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 C
Q.6 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
Answer B
Data Structures
Unit IV
Linked List
Q.7 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
Answer B
Q.8 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
Answer A
Q.9 A variant of linked list in which last node of the list points to the first node of the
list is?
A Singly linked list
B Doubly linked list
C Circular linked list
D Multiply linked list
Answer C
Q.11 A variant of the linked list in which none of the node contains null pointer is?
A Singly linked list
B Doubly linked list
C Circular linked list
D None
Answer C
Q.14 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 above
Answer A
Q.16 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 C
Q.18 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 D
Q.19 A variation of linked list is circular linked list, in which the last node in the list
points to first node of the list. One problem with this type of list is?
A It wastes memory space since the pointer head already points to the first node and
thus the list node does not need to point to the first node.
B It is not possible to add a node at the end of the list.
Data Structures
Unit IV
Linked List
C It is difficult to traverse the list as the pointer of the last node is now not NULL
D All of above
Answer C
Q.20 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 these
Answer A
Q.21 The time required to delete a node x from a doubly linked list having n nodes is
A O (n)
B O (log n)
C O (1)
D O (n log n)
Answer C
Q.22 A collection of data items of similar type arranged in a sequence is termed as?
A Memory space
B Static data structure
C Data structure
D List
Answer D
Q.24 Depending on what on what can a linked list be classified into various other
types?
A The number of pointers in a node
B The purpose for which the pointers are maintained
C Both (a) and (b)
D None of the above
Answer C
Q.25 In a singly-linked list (linear linked list), how many fields does each node
consists of?
A One
B Three
C Two
D Zero
Answer C
Data Structures
Unit IV
Linked List
Q.27 A linked list contains a list pointer variable _____that stores the address of the
first node of the list.
A Start
B NULL
C Next
D Empty list
Answer A
Q.28 To maintain a linked list in memory, how many parallel arrays of equal size are
used?
A One
B Two
C Three
D Four
Answer B
Q.29 As memory is allocated dynamically to a linked list, a new node can be inserted
anytime in the list. For this, the memory manager maintains a special linked list
known as___________.
A Free pool
B Memory bank
C Free storage list
D All of the above
Answer C
Q.31 _________a list means accessing its elements one by one to process all or some
of the elements.
A Traversing
B Creating
C Linking
D None of the above
Answer A
Data Structures
Unit IV
Linked List
Q.32 Searching a value (say, item) in a linked list means finding the position of the
node, which stores ___________ as its value?
A Node
B Item
C info
D None of the above
Answer B
Q.33 A situation where the user tries to delete a node from an empty linked list is
termed as___________.
A Underflow
B Overflow
C Pointers
D None of the above
Answer A
Q.34 To delete a node from the end of a linked list, the list is traversed up to the last
______.
A Pointer
B Node
C List
D None of the above
Answer B
Q.35 Since a doubly-linked list allows traversing in both the forward and backward
directions, it is also referred to as a___________.
A Multi-way list
B One-way list
C Two-way list
D None of the above
Answer C
Q.37 To implement Sparse matrix dynamically, the following data structure is used
A Trees
B Graphs
C Priority Queues
D Linked List
Answer D
Data Structures
Unit IV
Linked List
B Postfix and prefix manipulations
C Dictionary systems, polynomial manipulations
D Fixed block storage allocation, garbage collection
Answer D
Q.39 Overflow condition in linked list may occur when attempting to .............
A Create a node when free space pool is empty
B Traverse the nodes when free space pool is empty
C Create a node when linked list is empty
D None of these
Answer A
Q.40 Linked lists are not suitable data structures for which one of the following
problems?
A Insertion sort
B Binary search
C Radix sort
D Polynomial manipulation
Answer B
Q.45 Each Node contain minimum two fields one field called data field to store data.
Another field is of type _________.
A Pointer to Class
B Pointer to an Integer
C Pointer to Character
D Pointer to Node
Answer D
Q.46 Consider the Singly linked list having n elements. What will be the time taken to
add an node at the end of linked list if Pointer is initially pointing to first node of
the list.
A O(1)
B O(n-1)
C O(n)
D O(n^2)
Answer B
Q.47 Pointer is pointing to the first element of the Node then time require to Insert
Element to second position is __________.
A O(n)
B O(1)
C O(n^2)
D O(n-1)
Answer B
Q.48 Consider a linked list of n elements. What is the time taken to insert an element
after element pointed by same pointer ?
A O(n)
B O(log n)
C O(n-1)
D O(1)
Answer D
Q.49 The concatenation of two lists is to be performed in O(1) time. Which of the
following implementations of a list could be used ?
A Array Implementation of List
B Singly Linked List
C Circular Doubly Linked List
D Doubly Linked List
Answer C
Q.50 Time require to find any element of the linked list is ______
A O(n)
B O(1)
C O(n^2)
D None of these
Data Structures
Unit IV
Linked List
Answer A
Q.52 Consider the following linked list and linked list representation. what will be the
value of following statement ?
start->next->next->next->data
struct node {
int data;
}*start = NULL;
A 12
B 30
C 15
D 25
Answer D
Q.54 A linked list in which the last node of Linked list points to the first is called a
_________.
A Doubly Linked List
B Circular Linked List
C Singly Linked List
D None
Answer B
Q.57 Consider linked list is used to implement the Stack then which of the following
node is considered as Top of the Stack ?
A Any Node
B Last Node
C First Node
D Middle Node
Answer C
Q.58 The link field in the last node of the linked list contains _________.
A Link to the first node
B Zero value
C Pointer to the next element location
D None of the above
Answer B
Q.59 When new element is added in the middle of singly linked list then ________.
A Only elements that appear after the new element need to be moved
B Only elements that appear before the new element need to be moved
C No need to move element
D Only elements that appear after the new element and before need to be moved
Answer C
Q.60 Which of the following operation is performed more efficiently in doubly linked
list ?
A Inserting a node at given position
B Deleting a node at given position
C Searching a node at given position
D None of these
Answer B
Q.61 If in a linked list address of first node is 1020 then what will be the address of
node at 5th position ?
A 1036
B 1028
C 1038
D None of these
Answer D
Data Structures
Unit IV
Linked List
Q.62 In Circular Linked List insertion of a node involves the modification of ____
links.
A 3
B 4
C 1
D 2
Answer D
Q.64 The worst case time required to search a given element in a sorted linked list of
length n is
A O(1)
B O(n)
C O (n2)
D O(log2 n)
Answer B
Data Structures
Unit V
Trees
Q.1 The number of edges from the root to the node is called __________ of the tree.
A Height
B Depth
C Length
D Width
Answer B
Explanation: The number of edges from the root to the node is called depth of the
tree.
Q.2 The number of edges from the node to the deepest leaf is called _________ of the
tree.
A Height
B Depth
C Length
D Width
Answer A
Explanation: The number of edges from the node to the deepest leaf is called
height of the tree.
Q.5 What is the average case time complexity for finding the height of the binary
tree?
A h = O(loglogn)
B h = O(nlogn)
C h = O(n)
Data Structures
Unit V
Trees
D h = O(log n)
Answer D
Explanation: The nodes are either a part of left sub tree or the right sub tree, so
we don’t have to traverse all the nodes, this means the complexity is lesser than
n, in the average case, assuming the nodes are spread evenly, the time complexity
becomes O(logn).
Q.7 In a full binary tree if number of internal nodes is I, then number of leaves L are?
A L = 2*I
B L=I+1
C L=I–1
D L = 2*I – 1
Answer B
Explanation: Number of Leaf nodes in full binary tree is equal to 1 + Number of
Internal Nodes i.e L = I + 1
Q.8 In a full binary tree if number of internal nodes is I, then number of nodes N are?
A N = 2*I
B N=I+1
C N=I–1
D N = 2*I + 1
Answer D
Explanation: Relation between number of internal nodes(I) and nodes(N) is N =
2*I+1.
Q.9 In a full binary tree if there are L leaves, then total number of nodes N are?
A N = 2*L
B N=L+1
C N=L–1
D N = 2*L – 1
Answer D
Explanation: The relation between number of nodes(N) and leaves(L) is N=2*L-
1.
Data Structures
Unit V
Trees
D Let T be a binary tree with N nodes. Then the number of levels is at least
floor(log (N + 1))
Answer D
Explanation: In a binary tree, there are atmost 2k nodes in level k and 2k-1 total
number of nodes. Number of levels is at least ceil(log(N+1)).
Q.11 Construct a binary tree by using postorder and inorder sequences given below.
Inorder: N, M, P, O, Q
Postorder: N, P, Q, O, M
Data Structures
Unit V
Trees
C
Answer D
Q.12 Construct a binary search tree by using postorder sequence given below.
Postorder: 2, 4, 3, 7, 9, 8, 5.
A
Data Structures
Unit V
Trees
B
Answer B
Q.13 Construct a binary tree using inorder and level order traversal given below.
Inorder Traversal: 3, 4, 2, 1, 5, 8, 9
Level Order Traversal: 1, 4, 5, 9, 8, 2, 3
Data Structures
Unit V
Trees
A
Answer A
Data Structures
Unit V
Trees
A 6, 2, 5, 7, 11, 2, 5, 9, 4
B 6, 5, 2, 11, 7, 4, 9, 5, 2
C 2, 7, 2, 6, 5, 11, 5, 9, 4
D 2, 7, 6, 5, 11, 2, 9, 5, 4
Answer A
Answer B
Q.16 What is the space complexity of the in-order traversal in the recursive fashion? (d
is the tree depth and n is the number of nodes)
Data Structures
Unit V
Trees
A O(1)
B O(nlogd)
C O(logd)
D O(d)
Answer D
Q.18 Which of the following graph traversals closely imitates level order traversal of a
binary tree?
A Depth First Search
B Breadth First Search
C Depth & Breadth First Search
D Binary Search
Answer B
Explanation: Both level order tree traversal and breadth first graph traversal
follow the principle that visit your neighbors first and then move on to further
nodes.
Q.19 In a binary search tree, which of the following traversals would print the numbers
in the ascending order?
A Level-order traversal
B Pre-order traversal
C Post-order traversal
D In-order traversal
Answer D
Q.20 In postorder traversal of binary tree right subtree is traversed before visiting root.
A True
B False
Answer A
Explanation: Post-order method of traversing involves – i) Traverse left subtree
in post-order, ii) Traverse right subtree in post-order, iii) visit the root.
Q.21 What is the possible number of binary trees that can be created with 3 nodes,
giving the sequence N, M, L when traversed in post-order.
A 15
B 3
C 5
D 8
Answer C
Data Structures
Unit V
Trees
traversal will be ________
A TQRSOP
B TOQRPS
C TQOPSR
D TQOSPR
Answer
Q.23 A binary search tree contains values 7, 8, 13, 26, 35, 40, 70, 75. Which one of the
following is a valid post-order sequence of the tree provided the pre-order
sequence as 35, 13, 7, 8, 26, 70, 40 and 75?
A 7, 8, 26, 13, 75, 40, 70, 35
B 26, 13, 7, 8, 70, 75, 40, 35
C 7, 8, 13, 26, 35, 40, 70, 75
D 8, 7, 26, 13, 40, 75, 70, 35
Answer D
Q.24 Which of the following pair’s traversals on a binary tree can build the tree
uniquely?
A post-order and pre-order
B post-order and in-order
C post-order and level order
D level order and preorder
Answer B
Explanation: A binary tree can uniquely be created by post-order and in-order
traversals.
Q.26 The maximum number of nodes in a tree for which post-order and pre-order
traversals may be equal is ______
A 3
B 1
C 2
D 5
Answer B
Explanation: The tree with only one node has post-order and pre-order traversals
equal.
Q.27 The steps for finding post-order traversal are traverse the right subtree, traverse
the left subtree or visit the current node.
Data Structures
Unit V
Trees
A True
B False
Answer B
Explanation: Left subtree is traversed first in post-order traversal, then the right
subtree is traversed and then the output current node.
Q.28 The pre-order and in-order are traversals of a binary tree are T M L N P O Q and
L M N T O P Q. Which of following is post-order traversal of the tree?
A LNMOQPT
B NMOPOLT
C LMNOPQT
D OPLMNQT
Answer A
Q.29 For a binary tree the first node visited in in-order and post-order traversal is
same.
A True
B False
Answer B
Q.30 Find the post-order traversal of the binary tree shown below.
A PQRSTUVWX
B WRSQPVTUX
C SWTQXUVRP
D STWUXVQRP
Answer C
Explanation: In post-order traversal the left subtree is traversed first and then the
right subtree and then the current node. So, the post-order traversal of the tree is,
S W T Q X U V R P.
Data Structures
Unit V
Trees
A 2, 7, 2, 6, 5, 11, 5, 9, 4
B 2, 7, 5, 2, 6, 9, 5, 11, 4
C 2, 5, 11, 6, 7, 4, 9, 5, 2
D 2, 7, 5, 6, 11, 2, 5, 4, 9
Answer A
Explanation: Pre order traversal follows NLR(Node-Left-Right).
A 2, 7, 2, 6, 5, 11, 5, 9, 4
B 2, 7, 5, 2, 6, 9, 5, 11, 4
C 2, 5, 11, 6, 7, 4, 9, 5, 2
D 2, 7, 5, 6, 11, 2, 5, 4, 9
Answer C
Explanation: Post order traversal follows LRN(Left-Right-Node).
Data Structures
Unit V
Trees
B
Answer A
Explanation: Pre-order traversal follows NLR(Node-Left-Right).
Data Structures
Unit V
Trees
D
Answer A
Explanation: Post order traversal follows NLR(Left-Right-Node).
Q.35 What is the time complexity of pre-order traversal in the iterative fashion?
A O(1)
B O(n)
C O(logn)
D O(nlogn)
Answer B
Explanation: Since you have to go through all the nodes, the complexity becomes
O(n).
Q.36 What is the space complexity of the post-order traversal in the recursive fashion?
(d is the tree depth and n is the number of nodes)
A O(1)
B O(nlogd)
C O(logd)
D O(d)
Answer D
Explanation: In the worst case we have d stack frames in the recursive call, hence
the complexity is O(d).
Q.38 Consider the following data. The pre order traversal of a binary tree is A, B, E, C,
D. The in order traversal of the same binary tree is B, E, A, D, C. The level order
sequence for the binary tree is _________
A A, C, D, B, E
B A, B, C, D, E
C A, B, C, E, D
D D, B, E, A, C
Answer B
Q.39 Consider the following data and specify which one is Preorder Traversal
Sequence, Inorder and Postorder sequences.
S1: N, M, P, O, Q
Data Structures
Unit V
Trees
S2: N, P, Q, O, M
S3: M, N, O, P, Q
A S1 is preorder, S2 is inorder and S3 is postorder
B S1 is inorder, S2 is preorder and S3 is postorder
C S1 is inorder, S2 is postorder and S3 is preorder
D S1 is postorder, S2 is inorder and S3 is preorder
Answer C
Q.40 What is the maximum number of children that a binary tree node can have?
A 0
B 1
C 2
D 3
Answer C
Data Structures
Unit V
Trees
traversal strategy used in a binary tree. It involves visiting all the nodes at a given
level.
Data Structures
Unit V
Trees
A O(N)
B O(√N)
C O(N2)
D O(log N)
Answer D
Explanation: The average depth of a binary tree is given as O(√N). In case of a
binary search tree, it is O(log N).
Q.50 How many orders of traversal are applicable to a binary tree (In General)?
A 1
B 4
C 2
D 3
Answer D
Explanation: The three orders of traversal that can be applied to a binary tree are
in-order, pre-order and post order traversal.
Q.51 If binary trees are represented in arrays, what formula can be used to locate a left
child, if the node has an index i?
A 2i+1
B 2i+2
C 2i
D 4i
Answer A
Explanation: If binary trees are represented in arrays, left children are located at
indices 2i+1 and right children at 2i+2.
Q.53 Which of the following properties are obeyed by all three tree – traversals?
A Left subtrees are visited before right subtrees
B ight subtrees are visited before left subtree
C Root node is visited before left subtree
D Root node is visited before right subtree
Answer A
Explanation: In preorder, inorder and postorder traversal the left subtrees are
visited before the right subtrees. In Inorder traversal, the Left subtree is visited
first then the Root node then the Right subtree. In postorder traversal, the Left
subtree is visited first, then Right subtree and then the Root node is visited.
Data Structures
Unit V
Trees
The preorder traversal of a binary tree is 1, 2, 5, 3, 4. The inorder traversal of the
same binary tree is 2, 5, 1, 4, 3.
A
Answer D
Data Structures
Unit V
Trees
A The left child is always lesser than its parent
B The right child is always greater than its parent
C The left and right sub-trees should also be binary search trees
D In order sequence gives decreasing order of elements
Answer D
Explanation: In order sequence of binary search trees will always give ascending
order of elements. Remaining all are true regarding binary search trees.
Q.56 What is the specialty about the in-order traversal of a binary search tree?
A It traverses in a non-increasing order
B It traverses in an increasing order
C It traverses in a random fashion
D It traverses based on priority of the node
Answer B
Explanation: As a binary search tree consists of elements lesser than the node to
the left and the ones greater than the node to the right, an inorder traversal will
give the elements in an increasing order.
A Preorder traversal
B Inorder traversal
C Postorder traversal
D Level order traversal
Answer C
Explanation: In a postorder traversal, first the left child is visited, then the right
child and finally the parent.
A Preorder traversal
B Inorder traversal
C Postorder traversal
D Level order traversal
Answer A
Explanation: In a preorder traversal, first the parent is visited, then the left child
and finally the right child.
Data Structures
Unit V
Trees
Q.59 What are the worst case and average case complexities of a binary search tree?
A O(n), O(n)
B O(logn), O(logn)
C O(logn), O(n)
D O(n), O(logn)
Answer D
Explanation: Worst case arises when the tree is skewed(either to the left or right)
in which case you have to process all the nodes of the tree giving O(n)
complexity, otherwise O(logn) as you process only the left half or the right half
of the tree.
Data Structures
Unit V
Trees
D
Answer C
Q.64 The no of external nodes in a full binary tree with n internal nodes is?
A n
B n+1
C 2n
D 2n + 1
Data Structures
Unit V
Trees
Answer B
Q.65 Which type of traversal of binary search tree outputs the value in sorted order?
A Pre-order
B In-order
C Post-order
D None
Answer B
Q.67 A binary tree in which all the leaves are on the same level is called as
A Complete Binary tree
B Strictly Binary Tree
C Binary Search Tree
D Full Binary Tree
Answer D
Q.71 For the binary tree shown in figure the in-order traversal sequence is
Data Structures
Unit V
Trees
A ABCDEFGHIJK
B HIDEBFJKCGA
C HDIBEAFCJGK
D ABDHIECFGJK
Answer C
Q.72 For the binary tree shown in figure the pre-order traversal sequence is
A ABCDEFGHIJK
B HIDEBFJKCGA
C HDIBEAFCJGK
D ABDHIECFGJK
Answer D
Q.73 For the binary tree shown in figure the pre-order traversal sequence is
A ABCDEFGHIJK
B HIDEBFJKCGA
Data Structures
Unit V
Trees
C HDIBEAFCJGK
D ABDHIECFGJK
Answer B
Data Structures