## Sort a given stack – Using Temporary Stack

Objective: Given a stack of integers, write an algorithm to sort the stack using a temporary stack. Example: Given Stack: [14, 9, 67, 91, 101, 25] Sorted Stack: [9, 14, 25, 67, 91, 101]...

@tutorialhorizon

Objective: Given a stack of integers, write an algorithm to sort the stack using a temporary stack. Example: Given Stack: [14, 9, 67, 91, 101, 25] Sorted Stack: [9, 14, 25, 67, 91, 101]...

Objective: Given an array of integers that contains duplicates as well. Write a program to find the sum of all unique elements in the array. This problem is also referred to as find the...

What is Selection Sort?? Selection sort is a simple sorting algorithm that builds the sorted array one item at a time. This sorting is efficient for small data sets, not efficient for large data...

Objective: Given an array of integers A[],find no of reverse pairs means no of (i, j) pairs where i < j and A[i]>A[j]. Example: A[] = {10, 3, 4, 2, 5, 7, 9, 11}...

What is Insertion Sort?? Insertion sort is a simple sorting algorithm that builds the sorted array one item at a time. Efficient for small data sets, not efficient for large data sets. Most of...

What is Heap Sort?? Heap sort is comparison based sorting algorithm. Heap sort is considered as improved selection sort, it divides the input into sorted and unsorted region. The improvement from selection sort is...

In this article we will discuss about what is bubble sort, why it is considered as one of the simplest sorting algorithm, what its complexity, how we can improve the bubble sort algorithm. What...

Objective: Given a list of names ( first name and last name), sort the list by their last names. Example: List [] = {“Daenerys Targaryen”, “Jon Snow”, ” Tyrion Lannister”, ” Joffrey Baratheon”} Output:...

Objective: Given k sorted array, write an algorithm to merge Them into One sorted array. Example : int[][] A = new int[5][]; A[0] = new int[] { 1, 5, 8, 9 }; A[1] =...

Counting Sort is an sorting algorithm, which sorts the integers( or Objects) given in a specific range. Algorithm: Time Complexity O(n) Take two arrays, Count[] and Result[] and given array is input[]. Count[] will...

Objective: – Given three integers, sort them without using if condition. Appraoch: Say 3 integers are, a, b, c. Find the maximum of a, b, c using Max() function. multiply all integers by -1....

Objective: Given a Linked List, Sort it using merge sort. Example: ->9->3->4->2->5->1 Sorted List: ->1->2->3->4->5->9 Approach: Reference : Merge Sort in array As it Merge sort, we apply the same logic , Divide and...

Objective: Given an array of integers, write an algorithm to sort it according to the order defined by another array. Input: An Array of Integers Example: Input Array : 2 6 9 1 4...

Objective: Given an array of intergers, sort it such that the odd numbers appear first followed by the even numbers . The odd numbers in ascending order and the even numbers in descending order....

Objective: Write an algorithm to find out whether in a given array there exists or not two numbers whose sum is exactly equals to a given number. This problem has been asked in Amazon...

%d bloggers like this: