The document details the divide-and-conquer approach applied to sorting algorithms such as merge sort and quick sort, explaining how problems are recursively divided into subproblems. It outlines the steps of merging sorted lists in merge sort and the partitioning method in quick sort to efficiently sort elements without additional merging steps. Additionally, it briefly covers selection sort, emphasizing its procedure for finding and swapping minimum elements in an array.
Quicksort is a divide-and-conquer sorting algorithm that works as follows:
1. Pick a pivot element and partition the array around it so that all elements less than the pivot come before elements greater than the pivot.
2. Recursively apply quicksort to the subarrays on each side of the pivot.
The average time complexity of quicksort is O(n log n) because on average the partitioning divides the array into equal halves at each step. However, the worst case is O(n^2) if the array is already sorted. Choosing the median element as the pivot helps avoid this worst case.
This document provides an overview of the quick sort algorithm. It discusses that quick sort has average case performance of O(n log n) but worst case of O(n^2). The document outlines the main steps of quick sort as picking a pivot, partitioning the array around the pivot, and recursively sorting the subarrays. It discusses issues like how to pick the pivot and describes strategies like median-of-three. The document also analyzes quick sort's performance and compares it to other sorting algorithms like merge sort.
The document discusses the merge sort algorithm which uses a divide and conquer approach. It works by recursively dividing an array into two halves and then merging the sorted halves. The key steps are:
1) Divide - Divide the array into equal halves repeatedly until arrays can no longer be divided.
2) Conquer - Sort the individual arrays using any sorting algorithm.
3) Combine - Merge the sorted halves back into a single sorted array by comparing elements pair-wise from both halves and writing them into the correct position in the new array.
The overall time complexity of merge sort is O(n log n) as in each recursion step, the problem size halves, resulting in log n recursive calls.
The document presents an overview of various sorting algorithms, including insertion sort, selection sort, bubble sort, and merge sort. It details each algorithm's methodology, advantages, disadvantages, and complexity in terms of best and worst-case scenarios. The content also includes code examples for implementing these sorting algorithms.
Quick sort is a widely used and efficient sorting algorithm that utilizes the divide and conquer strategy, partitioning an array into smaller arrays based on a specified pivot value. The algorithm sorts elements in place by recursively sorting sub-arrays and has a best and average time complexity of O(n log n), with a worst case of O(n^2). Space complexity can range from O(n) for the basic approach to O(log n) for the modified approach.
The document outlines various searching and sorting algorithms including sequential search, binary search, selection sort, radix sort, quick sort, insertion sort, and bubble sort. Each algorithm is presented with a step-by-step explanation and examples to illustrate their function. The document serves as a comprehensive guide to understanding these fundamental computer science concepts.
Quicksort is a divide-and-conquer sorting algorithm that has average case performance of O(N log N). It works by recursively dividing the array into two partitions based on a pivot value and sorting them independently. While quicksort's average case is efficient, its worst case is O(N^2) if the pivot choices are poor, though this seldom occurs in practice with randomization techniques. Quicksort is generally faster than mergesort due to its simpler in-place partitioning avoiding extra data movement.
The document discusses 'divide and conquer' sorting algorithms, specifically mergesort and quicksort, highlighting their techniques and implementations. Mergesort involves dividing an array into halves, recursively sorting them, and merging, requiring an auxiliary array, while quicksort partitions an array around a pivot. It compares performance, noting that mergesort runs in O(n log n) time, is stable but not in-place, while quicksort shows average O(n log n) but worst-case O(n²) performance.
The document elaborates on sorting algorithms using the divide and conquer strategy, focusing on mergesort and quicksort. Mergesort recursively divides the array, sorts the halves, and merges them using an auxiliary array, while quicksort partitions the array around a pivot and recursively sorts the partitions. Both algorithms have average time complexity of O(n log n), but quicksort may degrade to O(n^2) in the worst case.
Merge sort has a runtime of O(n log n). It works by recursively dividing an array into halves and then merging the sorted halves. First it divides the array into single elements, sorts those, then merges them back together piece by piece into a fully sorted array.
sorting algorithms presentation for understandingrafaelhidalgo005
The document discusses the divide and conquer approach in sorting algorithms, focusing on mergesort and quicksort. Mergesort splits an array into halves, recursively sorts each half, and then merges them, requiring auxiliary space, while quicksort partitions an array around a pivot and sorts the partitions in place, generally using less space. The performance analysis of both algorithms indicates that mergesort has a time complexity of O(n log n) while quicksort has an average case of O(n log n) but can degrade to O(n^2) in the worst case.
The document discusses the quick sort algorithm through examples. It explains that quick sort works by picking a pivot element and partitioning the array around it such that elements less than the pivot come before and elements greater than or equal to the pivot come after. It then recursively applies this process on the subarrays until the entire array is sorted. The document provides a step-by-step example of applying quick sort to an array of numbers to demonstrate how it works.
09 QUICK SORT Design and Analysis of algorithmssyamalamaganti
The document discusses the design and analysis of the Quick Sort algorithm, a divide and conquer method that partitions an array around a chosen pivot, leading to recursive sorting of subarrays. Different pivot selection methods are outlined, including picking the first, last, random, or median values, and time complexities for best, average, and worst cases are analyzed. Example problems and comparisons with Merge Sort are also included to enhance understanding of the algorithm's efficiency and application.
The document discusses algorithms and their analysis. It begins by defining an algorithm and key aspects like correctness, input, and output. It then discusses two aspects of algorithm performance - time and space. Examples are provided to illustrate how to analyze the time complexity of different structures like if/else statements, simple loops, and nested loops. Big O notation is introduced to describe an algorithm's growth rate. Common time complexities like constant, linear, quadratic, and cubic functions are defined. Specific sorting algorithms like insertion sort, selection sort, bubble sort, merge sort, and quicksort are then covered in detail with examples of how they work and their time complexities.
The document discusses static models of continuous variables in the context of econometric analysis, specifically focusing on panel data estimation techniques. It covers model structures, data arrangement, pooled and fixed effects estimators, and the implications of individual and time constants on econometric results. The document highlights the advantages of using within-groups estimators and provides insights on practical implementation using statistical software.
The document discusses two sorting algorithms: Quicksort and Mergesort. Quicksort works by picking a pivot element and partitioning the array around that pivot, recursively sorting the subarrays. It has average time complexity of O(n log n) but worst case of O(n^2). Mergesort works by dividing the array into halves, recursively sorting the halves, and then merging the sorted halves together. It has time complexity of O(n log n) in all cases. The document also includes Java code for implementing MergeSort and discusses how it works.
This document discusses rational expressions and operations involving them. It defines rational expressions as the quotient of two polynomials where the denominator is not equal to 0. It explains how to find the domain of a rational expression by setting the denominator equal to 0 and solving. The document provides examples of multiplying, dividing, adding and subtracting rational expressions by treating them as fractions and using properties of fractions. It emphasizes writing rational expressions in lowest terms and finding the lowest common denominator when adding or subtracting.
The document provides an overview of the quick sort algorithm through diagrams and explanations. It begins by introducing quick sort and stating that it is one of the fastest sorting algorithms because it runs in O(n log n) time and uses less memory than other algorithms like merge sort. It then provides step-by-step examples to demonstrate how quick sort works by picking a pivot element, partitioning the array around the pivot, and recursively sorting the subarrays. The summary concludes by restating that quick sort is an efficient sorting algorithm due to its speed and memory usage.
The document covers the merge sort algorithm, a recursive divide-and-conquer method for sorting lists by dividing them into sub-lists, sorting each recursively, and merging them. It includes detailed examples and analysis of the merging process, as well as considerations for when to use merge sort versus insertion sort for smaller lists. The implementation of the algorithm is also discussed, providing templates and pseudocode for practical use.
Counting Sort and Radix Sort AlgorithmsSarvesh Rawat
Counting sort is an integer sorting algorithm that works by counting the number of objects that have each distinct key value and using arithmetic to determine the position of each object in the sorted output. It runs in O(n+k) time where n is the number of elements and k is the largest element. It requires an extra array to store counts of each key value. Radix sort is an extension of counting sort that sorts elements based on individual digits by performing counting sort repeatedly on each digit, from least to most significant.
Calc Techniques for Boards Exam PurposesMcdarylLleno
The document details calculator techniques across various modes used for computations, including general calculations, complex numbers, statistics, equations, matrices, vectors, and configuration settings. It provides specific examples of how to utilize different modes for calculations such as finding the volume of materials, handling force systems, and determining components of force in different contexts. It also includes notes on setting up the calculator for optimal use in engineering mechanics and problem-solving scenarios.
Analysis of Algorithm (Bubblesort and Quicksort)Flynce Miguel
Quicksort is a recursive divide-and-conquer algorithm that works by selecting a pivot element and partitioning the array into two subarrays of elements less than and greater than the pivot. It recursively sorts the subarrays. The divide step does all the work by partitioning, while the combine step does nothing. It has average case performance of O(n log n) but worst case of O(n^2). Bubble sort repeatedly swaps adjacent elements that are out of order until the array is fully sorted. It has a simple implementation but poor performance of O(n^2).
Quicksort is a divide and conquer algorithm that works by partitioning an array around a pivot value and recursively sorting the subarrays. It first selects a pivot element and partitions the array by moving all elements less than the pivot before it and greater elements after it. The subarrays are then recursively sorted through this process. When implemented efficiently with an in-place partition, quicksort is one of the fastest sorting algorithms in practice, with average case performance of O(n log n) time but worst case of O(n^2) time.
The document outlines the essential concepts and objectives for working with rational expressions, including simplification, multiplication, division, addition, and subtraction. It explains that a rational expression is the quotient of two polynomials and provides various examples for each operation. Additionally, it discusses complex fractions and methods for simplifying them.
The document provides a comprehensive overview of various types of matrices, including row, column, square, diagonal, scalar, identity, equal, negative, upper and lower triangular, symmetric, and skew symmetric matrices, along with their definitions and examples. Additionally, it covers matrix operations such as addition, subtraction, multiplication, determinants, minors, cofactors, and adjoints, as well as the method of matrix inversion for solving linear equations. Key mathematical concepts and calculations related to matrices are illustrated through numerous examples.
Structured Programming with C++ :: Kjell BackmanShabista Imam
Step into the world of high-performance programming with the Complete Guidance Book of C++ Programming—a definitive resource for mastering one of the most powerful and versatile languages in computer science.
Whether you're a beginner looking to learn the fundamentals or an intermediate developer aiming to sharpen your skills, this book walks you through C++ from the ground up. You'll start with basics like variables, control structures, and functions, then progress to object-oriented programming (OOP), memory management, file handling, templates, and the Standard Template Library (STL).
Low Power SI Class E Power Amplifier and Rf Switch for Health Careieijjournal
This research was to design a 2.4 GHz class E Power Amplifier (PA) for health care, with 0.18um Semiconductor Manufacturing International Corporation CMOS technology by using Cadence software. And also RF switch was designed at cadence software with power Jazz 180nm SOI process. The ultimate goal for such application is to reach high performance and low cost, and between high performance and low power consumption design. This paper introduces the design of a 2.4GHz class E power amplifier and RF switch design. PA consists of cascade stage with negative capacitance. This power amplifier can transmit 16dBm output power to a 50Ω load. The performance of the power amplifier and switch meet the specification requirements of the desired.
More Related Content
Similar to MERGE and Quick Sort algorithm explain ppt (20)
The document discusses 'divide and conquer' sorting algorithms, specifically mergesort and quicksort, highlighting their techniques and implementations. Mergesort involves dividing an array into halves, recursively sorting them, and merging, requiring an auxiliary array, while quicksort partitions an array around a pivot. It compares performance, noting that mergesort runs in O(n log n) time, is stable but not in-place, while quicksort shows average O(n log n) but worst-case O(n²) performance.
The document elaborates on sorting algorithms using the divide and conquer strategy, focusing on mergesort and quicksort. Mergesort recursively divides the array, sorts the halves, and merges them using an auxiliary array, while quicksort partitions the array around a pivot and recursively sorts the partitions. Both algorithms have average time complexity of O(n log n), but quicksort may degrade to O(n^2) in the worst case.
Merge sort has a runtime of O(n log n). It works by recursively dividing an array into halves and then merging the sorted halves. First it divides the array into single elements, sorts those, then merges them back together piece by piece into a fully sorted array.
sorting algorithms presentation for understandingrafaelhidalgo005
The document discusses the divide and conquer approach in sorting algorithms, focusing on mergesort and quicksort. Mergesort splits an array into halves, recursively sorts each half, and then merges them, requiring auxiliary space, while quicksort partitions an array around a pivot and sorts the partitions in place, generally using less space. The performance analysis of both algorithms indicates that mergesort has a time complexity of O(n log n) while quicksort has an average case of O(n log n) but can degrade to O(n^2) in the worst case.
The document discusses the quick sort algorithm through examples. It explains that quick sort works by picking a pivot element and partitioning the array around it such that elements less than the pivot come before and elements greater than or equal to the pivot come after. It then recursively applies this process on the subarrays until the entire array is sorted. The document provides a step-by-step example of applying quick sort to an array of numbers to demonstrate how it works.
09 QUICK SORT Design and Analysis of algorithmssyamalamaganti
The document discusses the design and analysis of the Quick Sort algorithm, a divide and conquer method that partitions an array around a chosen pivot, leading to recursive sorting of subarrays. Different pivot selection methods are outlined, including picking the first, last, random, or median values, and time complexities for best, average, and worst cases are analyzed. Example problems and comparisons with Merge Sort are also included to enhance understanding of the algorithm's efficiency and application.
The document discusses algorithms and their analysis. It begins by defining an algorithm and key aspects like correctness, input, and output. It then discusses two aspects of algorithm performance - time and space. Examples are provided to illustrate how to analyze the time complexity of different structures like if/else statements, simple loops, and nested loops. Big O notation is introduced to describe an algorithm's growth rate. Common time complexities like constant, linear, quadratic, and cubic functions are defined. Specific sorting algorithms like insertion sort, selection sort, bubble sort, merge sort, and quicksort are then covered in detail with examples of how they work and their time complexities.
The document discusses static models of continuous variables in the context of econometric analysis, specifically focusing on panel data estimation techniques. It covers model structures, data arrangement, pooled and fixed effects estimators, and the implications of individual and time constants on econometric results. The document highlights the advantages of using within-groups estimators and provides insights on practical implementation using statistical software.
The document discusses two sorting algorithms: Quicksort and Mergesort. Quicksort works by picking a pivot element and partitioning the array around that pivot, recursively sorting the subarrays. It has average time complexity of O(n log n) but worst case of O(n^2). Mergesort works by dividing the array into halves, recursively sorting the halves, and then merging the sorted halves together. It has time complexity of O(n log n) in all cases. The document also includes Java code for implementing MergeSort and discusses how it works.
This document discusses rational expressions and operations involving them. It defines rational expressions as the quotient of two polynomials where the denominator is not equal to 0. It explains how to find the domain of a rational expression by setting the denominator equal to 0 and solving. The document provides examples of multiplying, dividing, adding and subtracting rational expressions by treating them as fractions and using properties of fractions. It emphasizes writing rational expressions in lowest terms and finding the lowest common denominator when adding or subtracting.
The document provides an overview of the quick sort algorithm through diagrams and explanations. It begins by introducing quick sort and stating that it is one of the fastest sorting algorithms because it runs in O(n log n) time and uses less memory than other algorithms like merge sort. It then provides step-by-step examples to demonstrate how quick sort works by picking a pivot element, partitioning the array around the pivot, and recursively sorting the subarrays. The summary concludes by restating that quick sort is an efficient sorting algorithm due to its speed and memory usage.
The document covers the merge sort algorithm, a recursive divide-and-conquer method for sorting lists by dividing them into sub-lists, sorting each recursively, and merging them. It includes detailed examples and analysis of the merging process, as well as considerations for when to use merge sort versus insertion sort for smaller lists. The implementation of the algorithm is also discussed, providing templates and pseudocode for practical use.
Counting Sort and Radix Sort AlgorithmsSarvesh Rawat
Counting sort is an integer sorting algorithm that works by counting the number of objects that have each distinct key value and using arithmetic to determine the position of each object in the sorted output. It runs in O(n+k) time where n is the number of elements and k is the largest element. It requires an extra array to store counts of each key value. Radix sort is an extension of counting sort that sorts elements based on individual digits by performing counting sort repeatedly on each digit, from least to most significant.
Calc Techniques for Boards Exam PurposesMcdarylLleno
The document details calculator techniques across various modes used for computations, including general calculations, complex numbers, statistics, equations, matrices, vectors, and configuration settings. It provides specific examples of how to utilize different modes for calculations such as finding the volume of materials, handling force systems, and determining components of force in different contexts. It also includes notes on setting up the calculator for optimal use in engineering mechanics and problem-solving scenarios.
Analysis of Algorithm (Bubblesort and Quicksort)Flynce Miguel
Quicksort is a recursive divide-and-conquer algorithm that works by selecting a pivot element and partitioning the array into two subarrays of elements less than and greater than the pivot. It recursively sorts the subarrays. The divide step does all the work by partitioning, while the combine step does nothing. It has average case performance of O(n log n) but worst case of O(n^2). Bubble sort repeatedly swaps adjacent elements that are out of order until the array is fully sorted. It has a simple implementation but poor performance of O(n^2).
Quicksort is a divide and conquer algorithm that works by partitioning an array around a pivot value and recursively sorting the subarrays. It first selects a pivot element and partitions the array by moving all elements less than the pivot before it and greater elements after it. The subarrays are then recursively sorted through this process. When implemented efficiently with an in-place partition, quicksort is one of the fastest sorting algorithms in practice, with average case performance of O(n log n) time but worst case of O(n^2) time.
The document outlines the essential concepts and objectives for working with rational expressions, including simplification, multiplication, division, addition, and subtraction. It explains that a rational expression is the quotient of two polynomials and provides various examples for each operation. Additionally, it discusses complex fractions and methods for simplifying them.
The document provides a comprehensive overview of various types of matrices, including row, column, square, diagonal, scalar, identity, equal, negative, upper and lower triangular, symmetric, and skew symmetric matrices, along with their definitions and examples. Additionally, it covers matrix operations such as addition, subtraction, multiplication, determinants, minors, cofactors, and adjoints, as well as the method of matrix inversion for solving linear equations. Key mathematical concepts and calculations related to matrices are illustrated through numerous examples.
Structured Programming with C++ :: Kjell BackmanShabista Imam
Step into the world of high-performance programming with the Complete Guidance Book of C++ Programming—a definitive resource for mastering one of the most powerful and versatile languages in computer science.
Whether you're a beginner looking to learn the fundamentals or an intermediate developer aiming to sharpen your skills, this book walks you through C++ from the ground up. You'll start with basics like variables, control structures, and functions, then progress to object-oriented programming (OOP), memory management, file handling, templates, and the Standard Template Library (STL).
Low Power SI Class E Power Amplifier and Rf Switch for Health Careieijjournal
This research was to design a 2.4 GHz class E Power Amplifier (PA) for health care, with 0.18um Semiconductor Manufacturing International Corporation CMOS technology by using Cadence software. And also RF switch was designed at cadence software with power Jazz 180nm SOI process. The ultimate goal for such application is to reach high performance and low cost, and between high performance and low power consumption design. This paper introduces the design of a 2.4GHz class E power amplifier and RF switch design. PA consists of cascade stage with negative capacitance. This power amplifier can transmit 16dBm output power to a 50Ω load. The performance of the power amplifier and switch meet the specification requirements of the desired.
Complete guidance book of Asp.Net Web APIShabista Imam
Unlock the full potential of modern web development with the Complete Guidance Book of ASP.NET Web API—your all-in-one resource for mastering RESTful services using Microsoft’s powerful ASP.NET Core framework. This book takes you on a step-by-step journey from beginner to expert, covering everything from routing and controllers to security, performance optimization, and real-world architecture.
20CE601- DESIGN OF STEEL STRUCTURES ,INTRODUCTION AND ALLOWABLE STRESS DESIGNgowthamvicky1
• Understand concepts of limit state and working stress method of design of structural steel members and various types of connections.
• Determine net area and effective sections in tension members, tension splices, lug angles and gussets.
• Execute design of compression members as per IS codal practice.
• Analyze concepts of design of flexural members.
• Design structural systems such as roof trusses, gantry girders as per provisions of IS 800 – 2007 of practice for limit state method.
OUTCOMES:
On successful completion of this course, the students will be able to,
• Analyze different types of bolted and welded connections.
• Develop skills to design tension members, splices, lug angles and gussets.
• Elaborate IS Code design practice of various compression members.
• Design laterally supported and unsupported beams, built-up beams, plate girders and stiffeners.
• Acquire knowledge about components of industrial structures, Gantry girders and roof trusses.
TEXT BOOKS:
1. Bhavikatti S S, “Design of Steel Structures”, By Limit State Method as per IS: 800 – 2007, IK International Publishing House Pvt. Ltd., 2019.
2. Subramanian N, “Design of Steel Structures”, Oxford University Press 2011.
REFERENCE BOOKS:
1. Duggal S K, “Limit State Design of Steel Structures”, Tata, McGraw Hill Education Pvt. Ltd., New Delhi, 2017.
2. Shiyekar M R, “Limit State Design in Structural Steel”, PHI Learning Private Limited, New Delhi, 2013.
3. IS: 800 – 2007, IS: 800 – 1984, General Construction in Steel – Code of Practice, BIS, New Delhi.
Structural steel types – Mechanical Properties of structural steel- Indian structural steel products- Steps involved in the Deign Process -Steel Structural systems and their Elements- -Type of Loads on Structures and Load combinations- Code of practices, Loading standards and Specifications - Concept of Allowable Stress Method, and Limit State Design Methods for Steel structures-Relative advantages and Limitations-Strengths and Serviceability Limit states.
Allowable stresses as per IS 800 section 11 -Concepts of Allowable stress design for bending and Shear –Check for Elastic deflection-Calculation of moment carrying capacity –Design of Laterally supported Solid Hot Rolled section beams-Allowable stress deign of Angle Tension and Compression Members and estimation of axial load carrying capacity.
Type of Fasteners- Bolts Pins and welds- Types of simple bolted and welded connections Relative advantages and Limitations-Modes of failure-the concept of Shear lag-efficiency of joints- Axially loaded bolted connections for Plates and Angle Members using bearing type bolts –Prying forces and Hanger connection– Design of Slip critical connections with High strength Friction Grip bolts.- Design of joints for combined shear and Tension- Eccentrically Loaded Bolted Bracket Connections- Welds-symbols and specifications- Effective area of welds-Fillet and but Welded connections-Axially Loaded connections for Plate and angle truss members and
Learning – Types of Machine Learning – Supervised Learning – Unsupervised Learning- semi supervised learning - The Brain and the Neuron – Design a Learning System – Perspectives and Issues in Machine Learning – Concept Learning Task – Concept Learning as Search – Finding a Maximally Specific Hypothesis – Version Spaces and the Candidate Elimination Algorithm
Multi-proposer consensus protocols let multiple validators propose blocks in parallel, breaking the single-leader throughput bottleneck of classic designs. Yet the modern multi-proposer consensus implementation has grown a lot since HotStuff. THisworkshop will explore the implementation details of recent advances – DAG-based approaches like Narwhal and Sui’s Mysticeti – and reveal how implementation details translate to real-world performance gains. We focus on the nitty-gritty: how network communication patterns and data handling affect throughput and latency. New techniques such as Turbine-like block propagation (inspired by Solana’s erasure-coded broadcast) and lazy push gossip broadcasting dramatically cut communication overhead. These optimizations aren’t just theoretical – they enable modern blockchains to process over 100,000 transactions per second with finality in mere milliseconds redefining what is possible in decentralized systems.
VARICELLA VACCINATION: A POTENTIAL STRATEGY FOR PREVENTING MULTIPLE SCLEROSISijab2
Multiple sclerosis (MS) is a debilitating neurological condition affecting approximately 2.9 million people worldwide. Its cause remains unclear but environmental factors, such as post-childhood Epstein-Barr virus (EBV) infection, are thought to contribute to MS incidence.
This covers traditional machine learning algorithms for classification. It includes Support vector machines, decision trees, Naive Bayes classifier , neural networks, etc.
It also discusses about model evaluation and selection. It discusses ID3 and C4.5 algorithms. It also describes k-nearest neighbor classifer.
A Cluster-Based Trusted Secure Multipath Routing Protocol for Mobile Ad Hoc N...IJCNCJournal
Mobile Ad Hoc Network (MANET) is a self-organizing and flexible system. MANET systems manage sensitive data from many distinct applications in various domains. Its dynamic nature increases its vulnerability to numerous types of security threats. Many of the present approaches using indirect approaches provide false approximations of trust degrees. It is significantly required a good routing system that meets Quality of Service (QoS) standards and enhances network performance. In this paper purposed cluster-based trustworthy safe multipath routing (CTSMP-Routing) for mobile ad hoc networks (MANETs). Load balancing challenge is addressed by using a modified proportional topology optimization (MPTO) approach using geographical data related to network nodes. The Enhanced Seeker Search Optimization (ESSO) approach is used to compute trust degrees after the clustering phase considering numerous network constraints including node mobility, received signal strength, energy consumption, and cooperation rate. Assumed to be the service node, the node showing the highest degree of trust manages inter-cluster routing. We have developed a hybrid soft computing approach termed the multi-layer deep recurrent neural network (ML-DRNN) to enhance the optimal path-finding process. This method selects, among many routes between source and destination nodes, the best one quickly. The outcomes of this paper demonstrate that CTSMP-Routing provides effective protection against several attack paths within the MANET environment and displays better performance in regard to quality of service (QoS) requirements.
Complete University of Calculus :: 2nd editionShabista Imam
Master the language of change with the Complete Guidance Book of Calculus—your comprehensive resource for understanding the core concepts and applications of differential and integral calculus. Designed for high school, college, and self-study learners, this book takes a clear, intuitive approach to a subject often considered challenging.
Complete University of Calculus :: 2nd editionShabista Imam
Ad
MERGE and Quick Sort algorithm explain ppt
1. Merge Sort
Merge Sort
Merge sort with n input size of array
Divide:
Divide the n-element sequence to be
sorted into two subsequences of n/2
elements each
Conquer
Sort the subsequences recursively using merge sort
When the size of the sequences is 1 there is nothing more
to do
Combine
Merge the two sorted sub sequences
Dr.Tamilarasan.S (18CS42) 4/2/2025 49
2. Merge Sort
Merge Sort
The array is A[O .. n - 1]
Dividing into two halves
A[0 .. n/2 -1] and A[n/2 .. n -1]
Sorting each of them recursively
Merging the two smaller sorted arrays into a single sorted
one.
Dr.Tamilarasan.S (18CS42) 4/2/2025 50
3. Merge Sort
Merge Sort
ALGORITHM Merge-sort(A[0 .. n - 1])
//Sorts array A[O .. n - 1] by recursive merge-sort
//Input: An array A[O .. n - 1] of orderable elements
//Output: Array A[O .. n - 1] sorted in non-decreasing
order If n > 1
Copy A[0 .. (n/2) -1] to B[0 .. n/2 -1]
copy A[(n/2) .. n -1] to C[0 .. (n/2) -1]
Merge-sort(B[0 .. (n/2) - 1])
Merge-sort(C[0 .. (n/2) -1])
Merge(B, C, A)
Dr.Tamilarasan.S (18CS42) 4/2/2025 51
4. Merge Sort
Merge Sort
ALGORITHM Merge(B[0 .. p- 1], C[0 .. q -1], A[0 .. p + q -1])
//Merges two sorted arrays into one sorted array
//Input: Arrays B[O .. p -1] and C[O .. q -1] both sorted
//Output: Sorted array A[O .. p + q -1] of the elements of Band C
i ← 0; j ← 0; k ← 0
While i < p and j < q do
if B[i] ≤ S C[j]
A[k] ← B[i]; i ← i + 1
else A[k] ← C[j]; j ← j +
1 k← k+1
If i = p
copy C[j .. q -1] to A[k .. p
+ q -1]
else copy B[i .. p -1] to
A[k .. p + q -1]
Dr.Tamilarasan.S (18CS42) 4/2/2025 52
6. Merge Sort
8 3
3 8
Merge Sort
A[i] A[j]
If (A[i] ≤ A[j])
{
temp[k] ←
A[i] i ← i + 1
k ← k + 1
}
Else
{
temp[k] ← A[j]
j ← j + 1
k ← k + 1
While(i ≤ mid)
{
temp[k] ←
A[i] i ← i + 1
k ← k + 1
}
While(j ≤ high)
{
temp[k] ←
A[j]
j ← j + 1
k ← k + 1
}
Dr.Tamilarasan.S (18CS42) 4/2/2025 54
7. Merge Sort
Merge Sort
Algorithm Analysis
Merge sort
with n input
size of array
Basic
Operation:
Comparison
Two recursive
calls are made
Combine two
sub-list
Dr.Tamilarasan.S (18CS42) 4/2/2025 55
8. Merge Sort
+
Where n > 1 and T(1) = 0
Master Method
T(n) = T(n/2) + T(n/2) +
cn
T(n) = 2T(n/2) + cn
T(1) = 0
(1)
(2)
Merge Sort
Algorithm Analysis
T(n) = T(n/2)
Time taken by left sub
list to get sorted
T(n/2)
+
Time taken by right
sub list to get sorted
for combining
cn
Time taken
two sub lists
Dr.Tamilarasan.S (18CS42) 4/2/2025 56
10. QUICKSORT
Follows the divide-and-conquer paradigm.
Divide: Partition (separate) the array into two (possibly empty) sub-arrays
Conquer: Sort the two sub-arrays by recursive calls to quicksort
Combine: The sub-arrays are sorted in place – no work is needed
to combine them.
A[0] …………. A[m - 1] A[m] A[m + 1] …….. A[n – 1]
These elements are less than
A[m]
These elements are greater than
A[m]
Mid value
Dr.Tamilarasan.S (18CSL47) 4/2/2025 58
11. QUICKSORT
Pivot
i
⦿ Example:
⦿ Sort the following Random numbers
50, 30, 10, 90, 80, 20, 40, 70
◾ Let consider
a array;
p is a Pivot value
p=a[low];
i=low+1;
j=high
; Low
Dr.Tamilarasan.S (18CSL47) 4/2/2025 59
50 30 10 90 80 20 40 70
High
j
12. QUICKSORT
⦿ Step: 2
⦿ If a[i] ≤ Pivot, i will
increment
⦿ 30 ≤ 50, then increment i
Pivot
⦿ Step:3
i
Low
50 30 10 90 80 20 40 70
High
j
i
⦿ If a[i] ≤ Pivot, i will
increment
⦿ 10 ≤ 50, then increment i
Dr.Tamilarasan.S (18CSL47) 4/2/2025 60
j
13. QUICKSORT
⦿ If a[i] ≤ Pivot, i will
increment
⦿ 90 ≤ 50, then increment i will stop
⦿ Step:5
⦿ If a[j]
⦿ 70 > 50, then decrement j
⦿ Step: 4
Pivot i
Low
50 30 10 90 80 20 40 70
High
j
i
> Pivot, j will decrement
Dr.Tamilarasan.S (18CSL47) 4/2/2025 61
j
14. LAB-4 QUICKSORT
⦿ 40 > 50, then j decrement will stop
⦿ Swap a[i] and a[j] (swap 90 and 40)
⦿ Step:7
If a[i] < a[low] and a[j] > a[low] then start continue incrementing i and
decrementing j, until the false conditions are obtained 40 < 50
increment i and 90 > 50 decrement j
⦿ Step: 6
Pivot
⦿ If a[j] > Pivot, j will
decrement
i
Low
50 30 10 90 80 20 40 70
High
j
i j
Low
Dr.Tamilarasan.S (18CSL47) 4/2/2025 62
50 30 10 40 80 20 90 70
High
15. QUICKSORT
a[i] < Pivot (20 < 50) and a[j] > Pivot (80 > 50) continue increment i and
decrement j.
⦿ Step: 8
Pivot
⦿ If a[i] ≤ Pivot, i will increment
⦿ 80 > 50, then i increment will stop then a[j] > pivot decrement j, 20 > 50 so
stop decrement j
⦿ Swap a[i] and a[j] (swap 80 and 20)
⦿ Step:9
Low
50 30 10 40 80 20 90 70
High
i j
i j
Low
Dr.Tamilarasan.S (18CSL47) 4/2/2025 63
50 30 10 40 20 80 90 70
High
16. QUICKSORT
⦿ Step: 10
⦿ Step: 11
Pivot i, j
Low
50 30 10 40 20 80 90 70
High
j
i
⦿ If a[i] < a[low] and j has crossed i. that is j < i, then swap a[low] or Pivot
and a[j]. ( swap 50 and 20).
Low
50 30 10 40 20 80 90 70
High
Low
20 30 10 40 50 80 90 70
High
Left sub list Right sub list
Pivot is
Shifted at its
position
Dr.Tamilarasan.S (18CSL47) 4/2/2025 64
17. QUICKSORT
⚫ If a[i] ≤ Pivot then start increment I
⚫ 30 ≤ 20 hen stop increment I
⚫ Then if a[j] > Pivot then decrement j
⚫ 40 > 20 then start decrement j
20
Dr.Tamilarasan.S (18CSL47) 4/2/2025 65
30 10 40
⦿ Step: 12
Consider left sub list
Low High
Pivot i j
18. QUICKSORT
⚫ Then if a[j] > Pivot then decrement j
⚫ 10 > 20 then stop decrement j
⚫ Swap a[i] and a[j]
20 30 10 40
⦿ Step: 13
Consider left sub list
Low High
Pivot i j
Low High
20 10 30 40
Pivot i j
Dr.Tamilarasan.S (18CSL47) 4/2/2025 66
19. QUICKSORT
⚫ Then if a[i] ≤ Pivot then increment i
⚫ 10 ≤ 20 then increment I
⚫ a[j] > Pivot, 30 > 20 then
decrement j
20 10 30 40
⦿ Step: 14
Consider left sub list
Low High
Pivot i j
Low High
20 10 30 40
Pivot i, j
Dr.Tamilarasan.S (18CSL47) 4/2/2025 67
20. QUICKSORT
⚫ a[j] > Pivot, 30 > 20 then
decrement j
⚫ a[j] > Pivot, 10 > 20 then stop decrement j, here j crossed i , swap
a[j] and Pivot (swap 10 and 20)
⦿ Step: 15
Consider left sub list
Low High
20 10 30 40
Pivot i, j
Low High
20 10 30 40
Pivot j i
Dr.Tamilarasan.S (18CSL47) 4/2/2025 68
21. QUICKSORT
Here a[i] < Pivot (70 < 80) then increment i
⦿ Step: 17
Sorted left sub list
Low High
10 20 30 40
80
Dr.Tamilarasan.S (18CSL47) 4/2/2025 69
70 90
Apply right sub tree
Low High
Pivot i j
22. QUICKSORT
Now swap Pivot and a[j] (Swap 80 and 90)
80 70 90
⦿ Step: 18
◾ Apply right sub tree
Low
High
Pivot i, j
80 70 90
Here, a[j] > Pivot (90 > 80) so decrement j
Low High
Pivot i
j
70 80
Dr.Tamilarasan.S (18CSL47) 4/2/2025 70
90
Low High
24. QUICKSORT
Quick Sort
It is based on the divide-and conquer approach.
it rearranges elements of a given array A(0 .. n - 1] with respect to
partition (s).
All the elements before positions are less than
A[s]
All the elements after positions are greater than A[s]
A[0] ... A[s -1] A[s] A[s + 1] ... A[n -1]
all are <
A(s]
Dr.Tamilarasan.S (18CSL47) 4/2/2025 72
all are > A(s]
25. QUICKSORT
Quick Sort
It is a process of partition of problem.
To achieve Partition, we need to choose an element from the
array called Pivot.
The first element in the array is pivot point
Partition can be done by double Scan approach
Dr.Tamilarasan.S (18CSL47) 4/2/2025 73
26. QUICKSORT
Quick Sort
Algorithm
ALGORITHM Quicksort(A[l … r])
//Sorts a sub-array by quicksort
//Input: A sub-array A[L … r] of A[0 … n -1], defined by its left
//and right indices l and r
//Output: Sub-array A[l .. r] sorted in nondecreasing order
if (l < r)
s ←Partition(A[l .. r]) // s
is a split position Quicksort(A[l .. s- 1])
Quicksort(A[s + l…r])
Dr.Tamilarasan.S (18CSL47) 4/2/2025 74
27. QUICKSORT
Quick Sort
ALGORITHM Partition(A[l ... r])
//Partitions a sub array by Hoare’s algorithm, using the first element as a pivot
//Input: Sub array of array A[0..n − 1], defined by its left and right indices l and r
(l<r)
//Output: Partition of A[l…r], with the split position returned as this function’s value
p := A[l]
i ←l+1; j ←r;
repeat
repeat i ←i + 1 until A[i] ≥ p
repeat j ←j − 1 until A[j ] ≤ p
swap(A[i], A[j ])
until i ≥ j
Dr.Tamilarasan.S (18CSL47) 4/2/2025 75
//undo last swap when i ≥ j
swap(A[i],
A[j ])
swap( p, A[j ])
return j
28. QUICKSORT
Quick Sort
Three situations
Case - 1
◾ If scanning indices i and j have not crossed
◾ (i < j)
exchange A[i] and A[j] and resume the scans by incrementing
i and decrementing j, respectively
P All are ≤ P ≥ P ………… ≤ P All are ≥P
i j
Dr.Tamilarasan.S (18CSL47) 4/2/2025 76
29. QUICKSORT
Quick Sort
Three
situations
Case - 2
◾ If scanning indices i and j have crossed
◾ (i > j) then
exchange A[low] and A[j] and
resume
the scans by
incrementing i and decrementing j, respectively
P All are ≤ P ≥ P ≤ P All are ≥P
i
j
Dr.Tamilarasan.S (18CSL47) 4/2/2025 77
30. QUICKSORT
Quick Sort
Three situations
Case - 3
◾ If scanning indices i and j stop while pointing to the same
element
◾ (i = j) then
The array partitioned, with the split positions = i = j:
P All are ≤ P = P All are
≥P
j
Dr.Tamilarasan.S (18CSL47) 4/2/2025 78
i =
31. QUICKSORT
Quick Sort-Algorithm Analysis
Best case (Split in the Middle)
Recurrence relation for quick sort
C(n) = C(n / 2) +
C(n / 2) + n
C(1) = 0
Time required to
sort left sub array
Time required to
sort right sub array
Time required for
partitioning the
sub array
Dr.Tamilarasan.S (18CSL47) 4/2/2025 79
32. QUICKSORT
Quick Sort-Algorithm Analysis
Best case (Split in the Middle)
Recurrence relation for quick sort
C(n)
C(n)
= C(n / 2)
= 2C(n / 2)
+ C(n / 2) + n
+ n ---------------------(1)
C(1) = 0 (2)
Dr.Tamilarasan.S (18CSL47) 4/2/2025 80