4. SORTING
● The sorting problem is to rearrange the items of a given list in nondecreasing
(ascending) order
● Sorting can be done on numbers, characters, strings or records
● Example: To sort student records in alphabetical order of names or by student
number or by student grade-point average. Such a specially chosen piece of
information is called a key
Sorting classification:
1. stable sorting - preserve the relative order of equal elements
2. unstable sorting - Doesn’t preserve the relative order of equal elements
7. IN-PLACE AND OUT OF PLACE SORTING
In-Place Sorting :
● Algorithm directly modifies the list that is received as input instead of creating a new
list that is then modified
● In-place sorting uses small amount of extra space to manipulate the input set
● In other Words, the output is placed in the correct position while the algorithm is still
executing, which means that the input will be overwritten by the desired output on
run-time
● In-Place, Sorting Algorithm updates input only through replacement or swapping of
elements
● An algorithm which is not in-place is sometimes called not-in-Place or out of Place
8. TYPES OF SORTING
1. Bubble sort, insertion sort, and selection sort are in-place sorting algorithms Because
only swapping of the element in the input array is required
2. Bubble sort and insertion sort can be applying as stable algorithms but selection sort
cannot
3. Merge sort is a stable algorithm but not an in-place algorithm. It requires extra array
storage
4. Quicksort is not stable but is an in-place algorithm
5. Heap sort is an in-place algorithm but is not stable
12. SEARCHING
The searching problem deals with finding a given value, called a search key, in a given set.
Types :
1. Linear search
a. Finding an element within a list.
b. It sequentially checks each element of the list until a match is found or the whole list has been searched
2. Binary search
a. Finding an item from a sorted list of items
b. It works by repeatedly dividing in half the portion of the list that could contain the item
15. STRING PROCESSING
● Astring is a sequence of characters from an alphabet
● Strings comprise letters, numbers, and special characters; bit strings, which
comprise zeros and ones; and gene sequences, which can be modeled by
strings of characters from the four character alphabet {A, C, G, T}.
● It is very useful in bioinformatics
● Searching for a given word in a text is called string matching
17. GRAPH PROBLEM
Graph problems: Agraph is a collection of points called vertices, some of which are
connected by line segments called edges
Examples:
1. Graph traversal
2. Shortest path algorithm
3. Topological sort
4. Traveling salesman problem
5. Graph-coloring problem and so on
18. COMBINATORIAL PROBLEMS
• combination, or a subset that satisfies certain constraints
● Adesired combinatorial object may also be required to have some additional property
such s a maximum value or a minimum cost.
● In practical, the combinatorial problems are the most difficult problems in computing.
• Example :
1. The traveling salesman problem
2. The graph coloring problem
● Combinatorial problems :To find a combinatorial object such as a permutation, a
19. GEOMETRICAL PROBLEMS
Geometric problems:
● Geometric algorithms deal with geometric objects such as points, lines, and polygons
● Geometric algorithms are used in computer graphics, robotics, and tomography
Examples :
1. The closest-pair problem
2. The convex-hull problem