CS502 Midterm Current Papers Fall 2023 (Mubashir) .
CS502 Midterm Current Papers Fall 2023 (Mubashir) .
MCQs
Few from Waqar, Moaaz & Haadi 1,2, 3 Files.
Short Questions
Which one of the following is the maximal points (According to 2-D Maxima)?
Edit-Distance between 2 Words by deleting last column.
3 steps of Divide & Conquer.
Long Questions
Suggest how Quick Sort can be improved more.
Formula of Recursion
How many times the following given loop will execute?
------------------------------------------------------------------------------------------------------------------------------------------
Question: In Algorithms, write "average" and "worst" time complexity of Quick sort.
Answer: The average time complexity of QuickSort is O(n log n), while the worst-case time complexity is
O(n^2).
https://youtu.be/CD3RCknhCQc?si=qgHD2bHq131-Mffv
https://youtu.be/DlmjtDs6xqQ?si=Me5Tpylu0Iw323RZ
In the context of algorithms, an "edit script" refers to a sequence of edit operations that transform one
object into another. Edit scripts are commonly used in the field of computational biology, text
processing, and computer science in general. The concept is often associated with the problem of
measuring the similarity or dissimilarity between two sequences and finding the minimum set of
operations (edits) needed to transform one sequence into the other.
For example, given two strings "kitten" and "sitting," an edit script to transform "kitten" into "sitting"
might look like:
The minimum edit distance between two sequences is the smallest number of edit operations needed to
transform one sequence into the other. Edit scripts are used to represent and analyze these
transformations in the context of algorithms like the Wagner-Fisher algorithm for dynamic
programming, which efficiently computes the edit distance between two sequences.
Bubble Sort is a simple sorting algorithm that repeatedly steps through the list to be sorted, compares
each pair of adjacent items, and swaps them if they are in the wrong order. The pass through the list is
repeated until the list is sorted. The algorithm gets its name because smaller elements "bubble" to the
top of the list.
1. **Compare adjacent elements:** Start at the beginning of the list and compare the first two
elements. If the first element is larger than the second one, swap them.
2. **Move to the next pair:** Move to the next pair of elements (the second and third elements) and
compare them. Again, swap them if they are in the wrong order.
3. **Continue through the list:** Continue comparing and swapping adjacent elements throughout the
entire list. After the first pass through the list, the largest element will have "bubbled up" to the end of
the list.
4. **Repeat:** Repeat steps 1-3 for the remaining unsorted elements. After the second pass, the
second-largest element will have bubbled up to its correct position.
5. **Continue until sorted:** Keep repeating the process until the entire list is sorted. In each pass, the
next largest element will move to its correct position.
Bubble Sort has a time complexity of O(n^2), where n is the number of elements in the list. It's not the
most efficient sorting algorithm, especially for large lists, but it is easy to understand and implement.
There are more efficient sorting algorithms like Merge Sort or QuickSort for larger datasets.
1#Seive technique ko selection problem and median sy related working btani thi iski
2#Can we sort array without using combination based algorithms if yess then how?
Average-case:
Worst Case:
Dynamic programing