- Data Structures & Algorithms
- DSA - Home
- DSA - Overview
- DSA - Environment Setup

- Algorithm
- DSA - Algorithms Basics
- DSA - Asymptotic Analysis
- DSA - Greedy Algorithms
- DSA - Divide and Conquer
- DSA - Dynamic Programming

- Data Structures
- DSA - Data Structure Basics
- DSA - Array Data Structure

- Stack & Queue
- DSA - Stack
- DSA - Expression Parsing
- DSA - Queue

- Searching Techniques
- DSA - Linear Search
- DSA - Binary Search
- DSA - Interpolation Search
- DSA - Hash Table

- Sorting Techniques
- DSA - Sorting Algorithms
- DSA - Bubble Sort
- DSA - Insertion Sort
- DSA - Selection Sort
- DSA - Merge Sort
- DSA - Shell Sort
- DSA - Quick Sort

- Graph Data Structure
- DSA - Graph Data Structure
- DSA - Depth First Traversal
- DSA - Breadth First Traversal

- Tree Data Structure
- DSA - Tree Data Structure
- DSA - Tree Traversal
- DSA - Binary Search Tree
- DSA - AVL Tree
- DSA - Spanning Tree
- DSA - Heap

- DSA Useful Resources
- DSA - Questions and Answers
- DSA - Quick Guide
- DSA - Useful Resources
- DSA - Discussion

This section presents you various set of Mock Tests related to **Data Structures Algorithms**. You can download these sample mock tests at your local machine and solve offline at your convenience. Every mock test is supplied with a mock test key to let you verify the final score and grade yourself.

Q 1 - What is the worst case time complexity of linear search algorithm?

Linear search scans sequentially to find the target value. The best case is Ο(1) and average and worst case is Ο(n). Worst case is when data is not in the list, and it has to scan all n elements.

Q 2 - What is the worst case run-time complexity of binary search algorithm?

In the worst case, binary search will be left or right intended, making it compare all the n values.

Q 3 - Which of the following usees FIFO method

Queue maintains two pointers − front and rear. In queue data structure, the item inserted first will always be removed first, hence FIFO!

Q 4 - A complete graph can have

At maximum, a complete graph can have n^{n - 1} spanning trees.

Q 5 - Which one of the below is not divide and conquer approach?

Among the options, only Merge sort divides the list in sub-list, sorts and then merges them together

Q 6 - Prefix notation is alsow known as

Polish Notation

Q 7 - In order traversal of binary search tree will produce −

Binary search tree yields a sorted list when traversed in-order.

Q 8 - In a min-heap:

A - parent nodes have values greater than or equal to their childs

B - parent nodes have values less than or equal to their childs

In a min heap, parents always have lesser or equal values than that of their childs.

Q 9 - A procedure that calls itself is called

In recursion, a procedure calls itself, either directly or by calling a procedure which in turn calls it.

Q 10 - For a binary search algorithm to work, it is necessary that the array (list) must be

As binary search divides the list and selects a the sub-list to extend search based on comparison of values, it becomes necessary that the array (list) must be in sorted form.

Stack uses push() to insert an item in stack, and pop() to remove the top item from stack.

In queue, data item inserted first, will be available first and data item inserted last will be available in the last. FIFO stands for First In First Out and is a correct answer.

Q 13 - Maximum number of nodes in a binary tree with height k, where root is height 0, is

If the root node is at height 0, then a binary tree can have at max 2^{k+1} − 1 nodes.

For example: a binary tree of height 1, can have maximum 2^{1+1} − 1 = 3 nodes.

r --------- 0 / \ L R --------- 1

Q 14 - Which one of the below mentioned is linear data structure −

All mentioned data structures are linear in nature.

Q 15 - What data structure is used for depth first traversal of a graph?

Stack is used for depth first traversal whereas queue is used for breadth first traversal

Q 16 - What data structure is used for breadth first traversal of a graph?

Queue is used for breadth first traversal whereas stack is used for depth first traversal.

Q 17 - What data structure can be used to check if a syntax has balanced paranthesis ?

Stack uses LIFO method which is good for checking matching paranthesis.

Expression notations are not reverse (or so) of each other, rather operators used in the expression have different arrangements.

Q 19 - Stack is used for

Recursive procedures use stacks to execute the result of last executed procedural call.

Q 20 - A circular linked list can be used for

Both stack and queue data structure can be represented by circular linked-list.

A linked-list is dynamic structure, it can shrink and expand as required by the program.

Q 22 - Minimum number of moves required to solve a *Tower of Hanoi* puzzle is

Minimum number of moves required to solve a Tower of Hanoi puzzle is 2^{n} - 1. Where n is the number of disks. If the number of disks is 3, then minimum number of moves required are 2^{3} - 1 = 7

Q 23 - Which of the following is an example of dynamic programming approach?

All mentioned use dynamic programming approach. Before solving the in-hand sub-problem, dynamic algorithm will try to examine the results of previously solved sub-problems. The solutions of sub-problems are combined in order to achieve the best solution.

Q 24 - The following formula will produce

F_{n}= F_{n-1}+ F_{n-2}

Fibonacci Series generates subsequent number by adding two previous numbers.

Minimum number of queues required for priority queue implementation is two. One for storing actual data and one for storing priorities.

data_structures_algorithms_questions_answers.htm

Advertisements