Data Structures/Algorithms Mock Test Q's
The time required to merge two sorted lists of size m and n, is:
Om + n
In a min-heap:
Parent nodes have values less than or equal to their childs.
From a complete graph, by removing the maximum _________ edges, we can construct a spanning tree.
e-n+1
Name 3 dynamic programming approaches:
Fibonacci Series, Tower of Hanoi, and Dijkstras Shortest Path
The minimum number of moves required to solve a Tower of Hanoi puzzle is:
2^n-1
Which of the following has a search effeciency of O(1)? Tree, Heap, Hash Table, or Linked-List?
A Hash Table
What data structure is used for breadth first traversal of a graph?
A Queue is used for a breadth first traversal of a graph.
A circular linked list can be used for:
A Stack and a Queue
What data structure is used for depth first traversal of a graph?
A Stack is used.
Apriori analysis of an algorithm assumes that:
All other factors like CPU speed are constant and have no effect on implementation.
All possible spanning trees of graph G:
Have the same number of edges and vertices.
A balance factor in an AVL tree is used to check:
If the tree is unbalanced.
Which sorting method is not a divide and conquer approach? Insertion sort, Merge sort, Shell sort, or Heap sort?
It is Merge Sort
What is the worst case run-time complexity of a binary search algorithm?
It is O(n)
What is the maximum degree of any vertex in a simple graph of vertices n is?
It is n - 1.
Which of the following asymptotic notation is the worst among all?
2^On
In doubly LinkedLists
Two pointers are maintained to store the next and previous nodes.
What is the worst case time complexity of a linear search algorithm?
The worst case time complexity of a linear search algorithm is O(n).
Push and pop functions are found in
Stack datastructures
A quick sort algorithm is an example of...
A divide and conquer algorithm.
Which of the searching techniques do NOT require the data to be in a sorted form?
A linear search
A stable sorting algorithm:
Does not change the sequence of the appearance of elements.
Prefix notation is also known as:
Polish Notation
Visiting the root node after visiting the left and right sub-trees is called....
Post-order Traversal
The minimum number of queues required for a priority queue implementation is?
2 queues.
A binary search tree is an example of a complete binary tree with special attributes. However:
A BST does not care about complete binary tree properties.
Which algorithm does not divide the list?
A linear search.
In order traversal of a binary search tree will produce:
A sorted list.
What data structure an be used to check if a syntax has balanced parenthesis?
A stack data structure.
An algorithm is
A step by step procedure to solve a problem.
The O notation in asymptotic evaluation represents:
Base case
Which search method can find if two vertices X & Y have a path between them?
Depth First Search and Breadth First Search.
The Tower of Hanoi is a classic example of:
Divide and Conquer......along with a recursive approach.
If the array is already sorted, which algorithm will exhibit the best performance?
Insertion Sort
Shell sort uses:
Insertion Sort
The time complexity of a Depth First Traversal is:
O | V | + |E|
The complexity of Bubble Sort is:
O(n^2)
Apriori algorithm analysis does not include:
Program Complexity. Apriori algorithm definition is an algorithm that attempts to operate on database records, particularly transactional records.
A pivot element to partition unsorted list(s) is used in:
Quick Sort
Which sorting algorithm is known to be not stable?
Selection Sort.
In a min heap:
Parent nodes have less value than child nodes.
Re-balancing of an AVL tree costs:
Olog(n)
Which algorithm is known to be unstable?
Quick Sort
A stack is used for:
Recursion
An interpolation search is an improved variant of binary search. It is necessary for this search algorithm to work that:
Data collection should be in sorted form and equally distributed.
If locality is a concern, you can use _______ to traverse the graph.
Depth First Search
Recursion uses more memory space than iteration because:
Every recursive call has to be stored.
If there is no base criteria in a recursive program, the program will:
Execute infinitely.
If queue is implemented using arrays, what would be the worst run time complexity of queue and dequeue operations?
It would be O(1) and O(1).
What is the minimum number of edges required to create a cyclid graph of n vertices is
Its just n.
Which algorithm is an example of an in-place algorithm?
Merge Sort
In the conversion from prefix to postfix using the stack data-structure, if operators and operands are pushed and popped exactly once, then the run-time complexity is:
O(n)
The complexity of Selection Sort is:
O(n)
A queue data-structure can be used for:
Resource allocation. In computing, resource allocation is necessary for any application to be run on the system. When the user opens any program this will be counted as a process, and therefore requires the computer to allocate certain resources for it to be able to run.
Which two sorting algorithms maintain two sub-lists, one sorted and one to be sorted?
Selection Sort and Insertion Sort.
Which of the below given sorting techniques has the highest best-case runtime complexity? Quick Sort, Selection Sort, Insertion Sort, or Bubble Sort?
Selection Sort has the highest best-case run-time complexity.
For a binary search algorithm to work, it is necessary that the array list must be
Sorted. The arraylist must be sorted.
The program with the highest run-time complexity is:
The Tower of Hanoi
Which algorithmic approach tries to use memoization?
The dynamic programming approach. In computing, memoization or memoisation is an optimization technique used primarily to speed up computer programs by storing the results of expensive function calls and returning the cached result when the same inputs occur again.
Which algorithmic approach tries to achieve the localized optimum solution?
The greedy approach
In the deletion operation of max heap, the root is replaced by:
The last element of the last level.
In a binary heap, whenever the root is removed then the rightmost element of the last level is replaced by the root. Why?
To make sure that it is still a complete binary tree.
A graph traversal is different from a tree traversal, because:
Trees have a root.
If we choose Prim's Algorithm for uniquely weighted spanning tree instead of Kruskal's Algorith, then:
We'll get the same spanning tree.
An adaptive sorting algorithm:
Takes advantage of already sorted elements.
The complexity of Shell Sort is:
Olog(n)
The worst case complexity of a binary search matches with:
A linear search
The minimum number of a spanning tree in a connected graph is....
Is 1
A binary search tree has the best case run-time complexity of Olog(n). What could be the worst case?
O(n)
Access time of a binary search tree may go worse in terms of time complexity up to:
O(n)
If the data collection is in sorted form and equally distributed then the run time complexity of interpolation search is:
Olog(n)
The following formula of the left_subtree < the node and the node is < the right_subtree belongs to what?
A Binary Search Tree
The travelling salesman problem is an example of....
A Greedy Algorithm
A Heap is an example of:
A complete binary tree.
Project scheduling is an example of:
Dynamic programming.
Queue data structure works on:
FIFO, first in, first out.
Aposterior analysis are more accurate than apriori analysis beacuse:
It contains the real data.
What about recursion is true in comparison with iteration?
Very expensive in terms of memory, low performance, and every recursive program can be written with iteration too.
Is a LinkedList a dynamic data structure?
Yes it is.
Which one of the below is a linear data structure? A. Queue B. Stack C. Arrays D. All of the above
D. All of the above.
The LinkedList search complexity is:
O(n)
After each iteration in a bubble sort:
At least one element is at its sorted position and one less comparison is made in the next iteration.
Quick sort running time depends on the selection of:
The pivot element