Data Structure Exam 2 Multiple choice

¡Supera tus tareas y exámenes ahora con Quizwiz!

In BFS, how many times a node is visited?

equivalent to number of indegree of the node

Consider an array of elements arr[5]= {5,4,3,2,1} , what are the steps of insertions done while doing insertion sort in the array.

(A) 4 5 3 2 1 3 4 5 2 1 2 3 4 5 1 1 2 3 4 5

A person wants to visit some places. He starts from a vertex and then wants to visit every vertex till it finishes from one vertex, backtracks and then explore other vertex from same vertex. What algorithm he should use?

Depth First Search

What is the advantage of bubble sort over other sorting techniques?

Detects whether the input is already sorted

Merge sort uses

Divide-and-conquer

The given array is arr = {1,2,4,3}. Bubble sort is used to sort the array elements. How many iterations will be done to sort the array?

4

The given array is arr = {1,2,3,4,5}. (bubble sort is implemented with a flag variable). The number of iterations in selection sort and bubble sort respectively are,

4 and 1

A B-Tree used as an index for a large database table has four levels including the root node. If a new key is inserted in this index, then the maximum number of nodes that could be newly created in the process are:

5

A B-tree of order 4 is built from scratch by 10 successive insertions. What is the maximum number of node splitting operations that may take place?

5

The given array is arr = {3,4,5,2,1}. The number of iterations in bubble sort and selection sort respectively are,

5 and 4

A binary search algorithm can be best described as what?

A divide and conquer technique

What are the correct intermediate steps of the following data set when it is being sorted with the Insertion sort?15,20,10,18

A. 15,20,10,18 -- 10,15,20,18 -- 10,15,18,20 -- 10,15,18,20

Searching and sorting algorithms are best implemented with which data structure?

A. An array-based list B. A linked list

The purpose of the bubble sorting algorithm is what?

A. To speed up the search of an item in the list B. To sort the contents of the list

What is an internal sorting algorithm?

Algorithm that uses main memory during the sort

What is an external sorting algorithm?

Algorithm that uses tape or disk during the sort

Regarding implementation of Breadth First Search using queues, what is the maximum distance between two nodes present in the queue? (considering each edge length 1)

At most 1

Consider the following lists of partially sorted numbers. The double bars represent the sort marker. How many comparisons and swaps are needed to sort the next number. [1 3 4 8 9 || 5

B. 3 comparisons, 2 swaps

If one uses straight two-way merge sort algorithm to sort the following elements in ascending order: 20, 47, 15, 8, 9, 4, 40, 30, 12, 17 then the order of these elements after second pass of the algorithm is:

B. 8, 15, 20, 47, 4, 9, 30, 40, 12, 17

Which search algorithm is best for a large list?

Binary search

Given two vertices in a graph s and t, which of the two traversals (BFS and DFS) can be used to find if there is path from s to t?

Both BFS and DFS

A person wants to visit some places. He starts from a vertex and then wants to visit every place connected to this vertex and so on. What algorithm he should use?

Breadth First Search

The following best describes which algorithm? The elements are compared and swapped if the first is found to be greater than the second.

Bubble sorting algorithm

Consider the following lists of partially sorted numbers. The double bars represent the sort marker. How many comparisons and swaps are needed to sort the next number. [1 3 4 5 8 9 || 2]

C. 6 comparisons, 5 swaps

The Breadth First Search algorithm has been implemented using the queue data structure. One possible order of visiting the nodes of the following graph is

C. QMNPRO

Regarding implementation of Depth First Search using stacks, what is the maximum distance between two nodes present in the stack? (considering each edge length 1)

Can be anything

On average, a sequential search algorithm would make N/2 number of comparisons for a list of size N.

True

In Depth First Search, how many times a node is visited?

Equivalent to number of indegree of the node

A selection sort algorithm sorts the list by which method?

Finding the smallest element in the list and moving this to the beginning of the unsorted list

The heap sort algorithm begins by converting the list into a heap, then sorting.

True

The insertion sort algorithm improves on the selection sort method by reducing the number of comparisons.

True

The merge sort algorithm differs from the quick sort only in how it partitions the list, which is to create two nearly equal sub lists.

True

The quick sort algorithm divides the list into two sub lists, then sorts each sub lists, and then combines both sub lists.

True

What is the key used in a search algorithm?

Used in operations such as searching, sorting, inserting and deleting

Which of the following is not true about comparison-based sorting algorithms?

Heap Sort is not a comparison-based sorting algorithm.

Which algorithm would work best to sort data as it arrives, one piece at a time, perhaps from a network?

Insertion sort

What is the disadvantage of selection sort?

It is not scalable

What is an in-place sorting algorithm?

It needs O(1) or O(logn) memory to create auxiliary locations

What is the advantage of selection sort over other sorting techniques?

It requires no additional storage space

In the following scenarios, when will you use selection sort?

Large values need to be sorted with small keys

Breadth First Search is equivalent to which of the traversal in the Binary Trees?

Level-order Traversal

The below diagram represents what type of sorting algorithm?

Merge sort

You have to sort 1 GB of data with only 100 MB of available main memory. Which sorting technique will be most appropriate?

Merge sort

Depth First Search is equivalent to which of the traversal in the Binary Trees?

Pre-order Traversal

The Data structure used in standard implementation of Breadth First Search is?

Queue Explanation: The Breadth First Search explores every node once and put that node in queue and then it takes out nodes from the queue and explores it's neighbors.

What is the best sorting algorithm to use for the elements in array are more than 1 million in general?

Quick sort.

Consider a situation where swap operation is very costly. Which of the following sorting algorithms should be preferred so that the number of swap operations are minimized in general?

Selection Sort

The Data structure used in standard implementation of Breadth First Search is?

Stack Explanation: The Depth First Search is implemented using recursion. So, stack can be used as a data structure to implement depth first search.

What operation does the Insertion Sort use to move numbers from the unsorted section to the sorted section of the list?

Swapping

Merge sort works on the principle of divide-and-conquer

TRUE

The Breadth First Search traversal of a graph will result into?

Tree

The Depth First Search traversal of a graph will result into?

Tree

When the Breadth First Search of a graph is unique?

When the graph is a Linked List

When the Depth First Search of a graph is unique?

When the graph is a Linked List

What can be the applications of Breadth First Search?

a) Finding shortest path between two nodes b) Finding bipartiteness of a graph c) GPS navigation system

What can be the applications of Depth First Search?

a) For generating topological sort of a graph b) For generating Strongly Connected Components of a directed graph c) Detecting cycles in the graph


Conjuntos de estudio relacionados

Chapter 7: The Skeletal System: The Axial Skeleton

View Set

Chapter 23: Male Genitalia and Rectum

View Set

ap bio: chapter 32-homeostasis and endocrine signaling

View Set

Chapter 3: The Organizational Environment and Culture

View Set

Ch. 1 I An Overview of Prime Suite's Practice Management and Electronic Health Record Software

View Set

CSE3 - Personal Computers Quiz #2

View Set