Pseudo code of algorithms are to be read by.

Similar documents
MIDTERM EXAMINATION Fall 2011 CS502- Fundamentals of Algorithms

MUHAMMAD FAISAL MIT 4 th Semester Al-Barq Campus (VGJW01) Gujranwala


Algorithm Efficiency & Sorting. Algorithm efficiency Big-O notation Searching algorithms Sorting algorithms

Sorting. Sorting in Arrays. SelectionSort. SelectionSort. Binary search works great, but how do we create a sorted array in the first place?

The Limits of Sorting Divide-and-Conquer Comparison Sorts II

Measuring algorithm efficiency

Multiple-choice (35 pt.)

CS-301 Data Structure. Tariq Hanif

Hiroki Yasuga, Elisabeth Kolp, Andreas Lang. 25th September 2014, Scientific Programming

FINALTERM EXAMINATION Fall 2009 CS301- Data Structures Question No: 1 ( Marks: 1 ) - Please choose one The data of the problem is of 2GB and the hard

O(n): printing a list of n items to the screen, looking at each item once.

Algorithms in Systems Engineering ISE 172. Lecture 12. Dr. Ted Ralphs

CS 6402 DESIGN AND ANALYSIS OF ALGORITHMS QUESTION BANK

Analysis of Algorithms. Unit 4 - Analysis of well known Algorithms

DIVIDE & CONQUER. Problem of size n. Solution to sub problem 1

Lecture 5: Sorting Part A

Cs502 Solved MCQS MidTerm

Deliverables. Quick Sort. Randomized Quick Sort. Median Order statistics. Heap Sort. External Merge Sort

17/05/2018. Outline. Outline. Divide and Conquer. Control Abstraction for Divide &Conquer. Outline. Module 2: Divide and Conquer

CSE373: Data Structure & Algorithms Lecture 21: More Comparison Sorting. Aaron Bauer Winter 2014

Total Points: 60. Duration: 1hr

Plotting run-time graphically. Plotting run-time graphically. CS241 Algorithmics - week 1 review. Prefix Averages - Algorithm #1

PROGRAM EFFICIENCY & COMPLEXITY ANALYSIS

(Refer Slide Time: 01.26)

CSE 373 APRIL 3 RD ALGORITHM ANALYSIS

CPSC 320 Midterm 2 Thursday March 13th, 2014

Sorting. Bubble Sort. Pseudo Code for Bubble Sorting: Sorting is ordering a list of elements.

CS 171: Introduction to Computer Science II. Quicksort

Sorting. Two types of sort internal - all done in memory external - secondary storage may be used

UNIT-2. Problem of size n. Sub-problem 1 size n/2. Sub-problem 2 size n/2. Solution to the original problem

CS 360 Exam 1 Fall 2014 Name. 1. Answer the following questions about each code fragment below. [8 points]

Lecture 9: Sorting Algorithms

Analysis of Algorithm. Chapter 2

CS301 - Data Structures Glossary By

Question 7.11 Show how heapsort processes the input:

Sorting. Sorting. Stable Sorting. In-place Sort. Bubble Sort. Bubble Sort. Selection (Tournament) Heapsort (Smoothsort) Mergesort Quicksort Bogosort

Comparison Sorts. Chapter 9.4, 12.1, 12.2

We can use a max-heap to sort data.

Classic Data Structures Introduction UNIT I

having any value between and. For array element, the plot will have a dot at the intersection of and, subject to scaling constraints.

LECTURE NOTES OF ALGORITHMS: DESIGN TECHNIQUES AND ANALYSIS

CS502 Design & Analysis of Algorithms

CSE 373 MAY 24 TH ANALYSIS AND NON- COMPARISON SORTING

Basic Data Structures (Version 7) Name:

Total Points: 60. Duration: 1hr

The divide and conquer strategy has three basic parts. For a given problem of size n,

Virtual University of Pakistan

CSC Design and Analysis of Algorithms

1. Covered basics of a simple design technique (Divideand-conquer) 2. Next, more sorting algorithms.

CSC Design and Analysis of Algorithms. Lecture 6. Divide and Conquer Algorithm Design Technique. Divide-and-Conquer

Midterm solutions. n f 3 (n) = 3

DESIGN AND ANALYSIS OF ALGORITHMS

DATA STRUCTURES AND ALGORITHMS

Today s Outline. CSE 326: Data Structures Asymptotic Analysis. Analyzing Algorithms. Analyzing Algorithms: Why Bother? Hannah Takes a Break

CS583 Lecture 01. Jana Kosecka. some materials here are based on Profs. E. Demaine, D. Luebke A.Shehu, J-M. Lien and Prof. Wang s past lecture notes

Algorithms and Data Structures

Algorithm Analysis. (Algorithm Analysis ) Data Structures and Programming Spring / 48

Choice of C++ as Language

[ 11.2, 11.3, 11.4] Analysis of Algorithms. Complexity of Algorithms. 400 lecture note # Overview

Algorithm Analysis and Design

Faster Sorting Methods

Presentation for use with the textbook, Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, Merge Sort & Quick Sort

ECE 2574: Data Structures and Algorithms - Basic Sorting Algorithms. C. L. Wyatt

Unit-2 Divide and conquer 2016

CS 261 Data Structures. Big-Oh Analysis: A Review

Analysis of Algorithms - Quicksort -

COE428 Lecture Notes Week 1 (Week of January 9, 2017)

10/5/2016. Comparing Algorithms. Analyzing Code ( worst case ) Example. Analyzing Code. Binary Search. Linear Search

Cpt S 223 Course Overview. Cpt S 223, Fall 2007 Copyright: Washington State University

Introduction to Data Structure

Sankalchand Patel College of Engineering - Visnagar Department of Computer Engineering and Information Technology. Assignment

CSE 100 Advanced Data Structures

UNIT 1 ANALYSIS OF ALGORITHMS

Algorithm Analysis. Applied Algorithmics COMP526. Algorithm Analysis. Algorithm Analysis via experiments

CLASS: II YEAR / IV SEMESTER CSE CS 6402-DESIGN AND ANALYSIS OF ALGORITHM UNIT I INTRODUCTION

Divide and Conquer CISC4080, Computer Algorithms CIS, Fordham Univ. Instructor: X. Zhang

Next. 1. Covered basics of a simple design technique (Divideand-conquer) 2. Next, more sorting algorithms.

Divide and Conquer CISC4080, Computer Algorithms CIS, Fordham Univ. Acknowledgement. Outline

CS:3330 (22c:31) Algorithms

CMPSCI 187: Programming With Data Structures. Lecture #34: Efficient Sorting Algorithms David Mix Barrington 3 December 2012

Lecture #2. 1 Overview. 2 Worst-Case Analysis vs. Average Case Analysis. 3 Divide-and-Conquer Design Paradigm. 4 Quicksort. 4.

Analysis of Sorting Algorithms. Imagine you have a few thousand dollars in your safe in all different denominations. The

CS 171: Introduction to Computer Science II. Quicksort

II (Sorting and) Order Statistics

Divide-and-Conquer Algorithms

COMP 250 Fall recurrences 2 Oct. 13, 2017

CS 445: Data Structures Final Examination: Study Guide

CSE373: Data Structure & Algorithms Lecture 18: Comparison Sorting. Dan Grossman Fall 2013

CSE 146. Asymptotic Analysis Interview Question of the Day Homework 1 & Project 1 Work Session

Introduction to Computers and Programming. Today

1. [1 pt] What is the solution to the recurrence T(n) = 2T(n-1) + 1, T(1) = 1

Sorting. CPSC 259: Data Structures and Algorithms for Electrical Engineers. Hassan Khosravi

Data Structures Lecture 8

Quick Sort. CSE Data Structures May 15, 2002

CmpSci 187: Programming with Data Structures Spring 2015

Sorting Pearson Education, Inc. All rights reserved.

CS2223: Algorithms Sorting Algorithms, Heap Sort, Linear-time sort, Median and Order Statistics

Sorting is a problem for which we can prove a non-trivial lower bound.

Introduction. e.g., the item could be an entire block of information about a student, while the search key might be only the student's name

Transcription:

Cs502 Quiz No1 Complete Solved File Pseudo code of algorithms are to be read by. People RAM Computer Compiler Approach of solving geometric problems by sweeping a line across the plane is called sweep. Line Plane Cube Box For average-case time analysis of Quick sort algorithm, Pivot selection is on average basis from half of the input values all possible random values Pivot is input separately

values greater than 5 Insertion sort is an in-place sorting algorithm. True False Heap sort is a/an and _ sorting algorithm. Not in-place, not stable one In-place, stable one In-place, not stable one Not in-place, stable one Merge sort is based on. Brute-force Plan-sweep Axis-sweep Divide and Conquer

While solving Selection problem, in Sieve technique we partition input data In increasing order In decreasing order According to Pivot Randomly Quick sort is a not a partitioning-based algorithm. True False In Heap Sort algorithm, the first step is to Call Build-Heap procedure Sort the array in descending order Call Heapify procedure

Find the number of input elements In Heap Sort algorithm (using max heap), when every time maximum element is removed from top We call merge Sort algorithm It becomes Order n2 Algorithm Divide and Conquer strategy helps us We are left with a hole The running time of Quick sort algorithm Is impossible to compute Has nothing to do with pivot selection

Is Random upon each execution Greatly influenced by the selection of pivot In asymptotical analysis of n*(5 + 2) 3, as n becomes large, the dominant (fastest growing) term is some constant times n_1 n n+1 n*n The total running time for Selection algorithm is Quadratic

Linear Geometric Exponential Quick sort is a not a partitioning-based algorithm. True False The main purpose of mathematical analysis is measuring the required by the algorithm. Space Execution time

Inputs & outputs Execution time and memory Result of asymptotical analysis of n(n - 3) and 4n*n is that. n(n-1) is asymptotically Less n(n-1) is asymptotically Greater Both are asymptotically Not equivalent Both are asymptotically Equivalent Upper bound requires that there exist positive constants c2 and n0 such that f(n) c2n for all n <= n0

Less than Equal to or Less than Equal or Greater than Greater than Merge sort have running time...running time of Heap sort. Greater than Less than Equal to Different than

Algorithms having O (order) running time are considered to be slow ones. n n2 n3 log (n) Boolean operation is a operation on an idealized RAM model of computation. Starting Basic Advance

Normal The main purpose of mathematical analysis is measuring the required by the algorithm. Space Execution time Inputs & outputs Execution time and memory In average-case time analysis of Quick sort algorithm, the most balanced case for partition is when we divide the list of elements into Equal no. of pieces as of input elements

Single piece exactly Two nearly equal pieces Three nearly equal pieces Algorithm is a sequence of computational steps that...the input into output. Merge Assign Transform Integrate The Iteration method is used for Comparing sorting algorithms only

Solving Recurrence relations Merging elements in Merge sort Dividing elements in Merge sort In plane sweep approach of solving geometric problems, a is swept across the plane. Line Plane Cube Box Counting sort is suitable to sort the elements in range 1 to k: K is large

K is small K may be large or small None In we have to find rank of an element from given input. Merge sort algorithm Selection problem Brute force technique Plane Sweep algorithm Rank of an element can be defined as

One minus the number of elements that are smaller Two plus the number of elements that are greater One plus the number of elements that are smaller Two minus the number of elements that are smaller The total no of arguments passed to merge sort algorithm is 2 3 4 5

In Heap Sort algorithm, the total running time for Heapify procedure is Theta (log n) Order (log n) Omega (log n) O (1) i.e. Constant time A sorting algorithm is called as if duplicate elements remain in the same relative position after sorting. Parallel O(n) algorithm Stable

Complex Al-Khwarizmi was a/an... Artist Mathematician Astronomer Khalifah is one of the few problems, where provable lower bounds exist on how fast we can sort. Searching Sorting

Both Searching & Sorting Graphing The worst case running time of Quick sort algorithm Cannot be quadratic Is quadratic Is always Exponential Is linear In Heap Sort algorithm, Heapify procedure is in nature. Recursive

Non-Recursive While solving Selection problem, in Sieve technique we choose pivot Minimum element Maximum element Randomly Average element Which one is not passed as parameter in Quick sort algorithm? End of the array Middle of the array

Array (containing input elements) Start of the array In plane sweep approach, a vertical line is swept across the 2dplane from. Right to Left Left to Right Top to Bottom Bottom to Top If input n is odd, the median will be (n+1)/2

n/2...of reference is an important fact of current processor technology. Defining Assigning Formality Locality While Sorting, the ordered domain means for any two input elements x and y satisfies only. x < y x > y

x = y All of the above Counting sort is suitable for sorting the elements within range 1 to P, where P is large P is small P is very large P is undetermined The sieve technique works where we have to find item(s) from a large input.

Single Two Three Similar While analyzing Selection algorithm, we make a number of passes, in fact it could be as many as n(n+1) log(n) n/3 n/4 The sequence of merge sort algorithm is:

Divide-Combine-Conquer Conquer-Divide-Combine Divide-Conquer-Combine Combine-Divide-Conquer Quick sort is based on Divide and Conquer strategy. not always sometimes occasionally In Heap Sort algorithm, we call Build-heap procedure

Only once Twice Thrice As many times as we need Counting sort is suitable for sorting the elements within range 1 to P, where P is large P is small P is very large P is undetermined

f(n) and g(n) are asymptotically equivalent. This means that they have essentially the same for large n. Results Variables Size Growth rates Floor and ceiling are to calculate while analyzing algorithms. Very easy Usually considered difficult

Sorting is one of the problems in Computer Sciences. Easiest Solution-less Least popular Most popular The worst case running time of Quick sort algorithm Cannot be quadratic Is quadratic Is always Exponential

Is linear The definition of Theta-notation relies on proving asymptotic bound. One Lower Upper Both lower & upper For comparison-based sorting algorithms, it is possible to sort more efficiently than Omega nlog(n) time. Always Not

Sometimes Sometimes not The running time of Quick sort algorithm Is impossible to compute Has nothing to do with pivot selection Is Random upon each execution Greatly influenced by the selection of pivot Efficient algorithm requires less computational... Memory Running Time

Memory and Running Time Energy We can improve the performance of Quick sort if we can be able to Skip input elements somehow Select two or more pivots Skip any sub-array completely Eliminate recursive calls Floor and ceiling are to calculate while analyzing algorithms. Very easy Usually considered difficult

We do not need to mathematically prove that for comparisonbased sorting algorithms always takes Omega nlog(n) time. True False In we have to find rank of an element from given input. Merge sort algorithm Selection problem Brute force technique Plane Sweep algorithm

In Quick sort algorithm, we choose pivot Always smallest element Greater than 5 Randomly Less than 5 The brute-force algorithm for 2D-Maxima runs in order O( ) time. n n(log n) n*n n3

In Heap Sort algorithm, we build for ascending sort. Max heap Min heap provides us more accurate result when input values are not closer with each other. Average Median In addition to passing in the array itself to Merge Sort algorithm, we will pass in other arguments which are indices. Two Three

Four Five In Heap Sort algorithm, the first step is to Call Build-Heap procedure Sort the array in descending order Call Heapify procedure Find the number of input elements Algorithms having O (order) running time are considered to be slow ones. n

n2 n3 log (n) In the statement output P[i].x, P[i].y, the number of times elements of P are accessed is 1 2 3 4 Merge sort is based on.

Brute-force Plan-sweep Axis-sweep Divide and Conquer The total no of arguments passed to merge sort algorithm is 2 3 4 5 In selection problem, the rank of an element will be its position if we sort the input data.

first final Second last Last The sieve technique is a special case, where the number of subproblems is just 1 2 3 4

The O-notation is used to state only the asymptotic bounds. Two Lower Upper Both lower & upper In Selection problem, the Sieve technique works in Non-recursive manner Constant time

Phases One complete go We can improve the performance of Quick sort if we can be able to Skip input elements somehow Select two or more pivots Skip any sub-array completely Eliminate recursive calls Number of of the pseudo code are counted to measure the running time. Inputs

Outputs Steps Pages Quick sort algorithm was developed by Alfred Aho Sedgewick John Vincent Atanasoff Tony Hoare In asymptotical analysis of n*(5 + 2) 3, as n becomes large, the dominant (fastest growing) term is some constant times

n_1 n n+1 n*n Recurrence can be described in terms of a tree. Yes No We can improve the performance of Quick sort if we can be able to Skip input elements somehow Select two or more pivots Skip any sub-array completely

Eliminate recursive calls Result of asymptotical analysis of n(n - 3) and 4n*n is that. n(n-1) is asymptotically Less n(n-1) is asymptotically Greater Both are asymptotically Not equivalent Both are asymptotically Equivalent Median is not useful measure of central tendency of given input set especially when the distribution of values is highly skewed. True False In max heap (for Heap Sort algorithm), when every time maximum element is removed from top we replace it with leaf in the tree. Second last Last First Any

In Heap Sort algorithm, every time the maximum element is removed We call Build-Heap procedure Heap Sort algorithm terminates without result We call heapify procedure Nothing happens In Selection problem, the Sieve technique Adds some more input items each time Do not work recursively Do not uses Divide and Conquer approach

Eliminates undesired data items each time Bubble sort is not an in-place sorting algorithm. True False In merge sort algorithm, we split the array around the index q. Entring Mid Exiting Summing Selection algorithm takes theta

(n2) (n) log(n) nlog(n) In Sieve Technique, we know the item of interest. True False Selection sort is not an in-place sorting algorithm. True False Upper bound requires that there exist positive constants c2 and n0 such that

f(n) c2n for all n <= n0 Less than Equal to or Less than Equal or Greater than Greater than If pj dominates pi and pi dominates ph then pj also dominates ph. It means dominance relation is Transitive Non Transitive Equation

Symbolic For average-case time analysis of Quick sort algorithm, Pivot selection is on average basis from half of the input values all possible random values Pivot is input separately values greater than 5 In Quick sort algorithm, decides nature of Binary Search Tree formed by Pivots. No one Smallest element from input

Rank of the pivot Largest element from input The sieve technique works where we have to find item(s) from a large input. Single Two Three Similar For average-case time analysis of Quick sort algorithm, Pivot selection is on average basis from half of the input values all possible random values

Pivot is input separately values greater than 5 To find maximal points in brute-force algorithm, each point of the space is compared against of that space. One other point All other points Few other points Most of the other points Sorting can be in Increasing order only

Decreasing order only Both Increasing and Decreasing order Random order The worst case running time of Quick sort algorithm Cannot be quadratic Is quadratic Is always Exponential Is linear Quick sort is a recursive algorithm.

True False The time assumed for each basic operation to execute on RAM model of computation is Infinite Continuous Constant Variable In Heap Sort algorithm (using max heap), when every time maximum element is removed from top We call merge Sort algorithm

It becomes Order n2 Algorithm Divide and Conquer strategy helps us We are left with a hole In Quick sort algorithm, Pivots form Stack Queue Binary Search Tree Graph If pj dominates pi and pi dominates ph then pj also dominates ph. It means dominance relation is Transitive

Non Transitive Equation Symbolic The running time of Quick sort algorithm Is impossible to compute Has nothing to do with pivot selection Is Random upon each execution Greatly influenced by the selection of pivot For solving Selection problem, we introduced Sieve technique due to Using Decrease and Conquer strategy

Avoiding to sort all input data Eliminating Rank of an element Using Brute-force approach In Quick sort algorithm, decides nature of Binary Search Tree formed by Pivots. No one Smallest element from input Rank of the pivot Largest element from input