Menu

(Solved) : 1 Many Comparisons Required Search Sorted Vector 1023 Elements Using Binary Search Algorit Q26165287 . . .

1.   At most, how many comparisons are required to search asorted vector of 1023 elements using the binary searchalgorithm?

      (a)10           (b)8                    (c) 7              (d) 9

2.   The right array in the partition algorithm of the mergesort that sorting n elements consists of __________elements.

      (a)floor of n/2 (b)ceil ofn/2     (c) floor ofn   (d) ceilof n

3.   A list implementation of a graph might use an array oflinked lists, each list containing all the ________ avertex.

pathscontaining                (b) vertices adjacent to

edges adjacent to                 (d)trees containing

4.   (T/F) The linear search has asymptotic running time oforder n.

Time complexities of three algorithmsare given. Which should execute the slowest for largevalues of N?

(a)O(N1/2)                                           (b) O(N)

(c) O(logN)                                         (d) None of these

How many multiplications do you need to compute2100 using square and multiply algorithm?

(a)99                                         (b) 100

(c)8                                         (d)None of these

(T/F) The running time of the PerfixAverage2 algorithmis linear function.

Where f is a function, O(f (n)) means_______ f (n).

   (a)Exactly;                                         (b) atmost;   

   (c) Roughlyproportional to;           (d) at least;

log2(1000) is closest to

(a) 3;                    (b) 10;           (c)50;           (d)100;    

10.        What is the sum of all natural numbers from 1 to100?

(a)3240                   (b)5050                 (c)701               (d) 248

Question 2 ( 15 Marks): Answer the followingquestions:

Name two algorithms have running timewhere is the size of theinput.                                          (2 Marks)                                                 

Write the worst case running time of the correspondingalgorithm in the table:                                       (2Marks)                                                                                  

Algorithm

Its worst case rung time

BFS

………………………………..

Selection sort

………………………………..

Quick sort

……………………………….

How to represent the following directed graph using theadjacency list.

                                                                               (2Marks)

              

  

……………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………

…………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………

Discover the trees of the DFS-forest of the followinggraph: (3 Marks)

    

……………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………

Compute the running time of the followingalgorithm:  

(3 Marks)

         

…………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………

f.     The number ofoperations executed by algorithms A and B is 8n log n and2n2, respectively. Determine n0 such that Ais better than B for n ≥n0.                              (3 Marks)

………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………

Question 3 ( 20 Marks): Answer the followingquestions:

Rewrite the linearSearch algorithm given belowto output all positions of the element in thearray L, where S is the set of all elements inL.                                 (5 Marks)

…………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………

Apply the merge sort algorithm to the sequence ofintegers A=(20,15, 30, 10, 40, 5, 50, 6, 18), and count the numberof comparisons operations.       ( 5 Marks)

……………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………

Apply the BFS algorithm to the following graph startingfrom the vertex3.                                                             ( 5 Marks)

                        

                               

…………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………

…………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………

…………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………

…………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………

Sort the following sequence of numbers

A=(20,15, 30, 10, 40, 5, 50,6, 18)

Using one of the algorithms Bubble, Selection, andInsertion that gives you less number of swaps.                                                     (5 Marks)

………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………

……………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………

………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………

…………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………

……………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………

Expert Answer


Answer to 1 Many Comparisons Required Search Sorted Vector 1023 Elements Using Binary Search Algorit Q26165287 . . .

OR