0% found this document useful (0 votes)
79 views2 pages

Quiz 3

This document contains a quiz with three questions about data structures algorithms. Question 1 has subparts asking to draw arrays after iterations of selection, insertion, and quicksort algorithms. Question 2 asks for a concise description of how quicksort could improve performance by using insertionsort on smaller sections. Question 3 asks for the best and worst case time complexities of binary search, insertion sort, heap sort, bubble sort, and selection sort.

Uploaded by

Adeena Saifullah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
79 views2 pages

Quiz 3

This document contains a quiz with three questions about data structures algorithms. Question 1 has subparts asking to draw arrays after iterations of selection, insertion, and quicksort algorithms. Question 2 asks for a concise description of how quicksort could improve performance by using insertionsort on smaller sections. Question 3 asks for the best and worst case time complexities of binary search, insertion sort, heap sort, bubble sort, and selection sort.

Uploaded by

Adeena Saifullah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

CSE 247 Data Structures (3 + 1) Fall 2020

Quiz 3
Instructor: Dr. Asma Sanam Larik ([email protected])

Student Name: _______________________ ID:__________________


Time : 30 min Date: 18th Nov 2020

Marks : 15
Q1. Here is an array of ten integers:
5 3 8 9 1 7 0 2 6 4

a) Draw this array after the FIRST iteration of the large loop in a selection sort (sorting from
smallest to largest). [2]

0 3 8 9 1 7 5 2 6 4

b) Draw this array after the FIRST iteration of the large loop in an insertion sort (sorting from
smallest to largest). [2]

3 5 8 9 1 7 0 2 6 4

c) Suppose we partition this array using quicksort's partition function and using 5 for the pivot.
Draw the resulting array after the partition finishes.
[2]

3 1 0 2 4 7 8 9 6 5

Q2. Give a concise accurate description of a good way for quicksort to improve its performance
by using insertionsort. [4]

Ans 2: We will start by using Quicksort to break the array into smaller pieces and then we will
call insertion sort to perform the insertions into smaller sections thus making it faster than
quicksort and more efficient
Q3. State the best case and the worst case of the following algorithms. You have to mention the
case and the Big-o notation: [5]
1.Binary Search of a sorted array
2.Insertion sort
3.Heap sort
4.Bubble sort
5.Selection sort

Ans 3:
1. Best case when middle value is desired value, O(1) and worst case is O(log n)
2. Best: Array is already sorted: O(n) and worst case is O(n2)
3. Both cases are O(nlogn)
4. Best: Array is already sorted: O(n) and worst case is O(n2)
5. Both best and worst cases are same. O(n2)

You might also like