Narendra Kumar has Published 196 Articles

Minimum number of deletions to make a string palindrome in C++.

Narendra Kumar

Narendra Kumar

Updated on 31-Oct-2019 06:40:01

787 Views

Problem statementGiven a string of size ‘n’. The task is to delete a minimum number of characters to make string palindrome.If the given string is “abcda” then we can delete any 2 characters except first and last to make it a palindrome.If we delete character ‘b’ and ‘c’ then “ada” ... Read More

Minimum number of deletions and insertions to transform one string into another using C++.

Narendra Kumar

Narendra Kumar

Updated on 31-Oct-2019 06:33:35

252 Views

DescriptionGiven two strings str1 and str2 of size m and n respectively. The task is to delete and insert a minimum number of characters from/in str1 so as to transform it into str2.Str1 = “tutorialspoint” Str2 = “tutorials” To transform str1 to str2 we have to delete five characters i.e. ... Read More

Merge Overlapping Intervals using C++.

Narendra Kumar

Narendra Kumar

Updated on 31-Oct-2019 06:27:59

485 Views

Problem statementGiven a set of time intervals in any order, merge all overlapping intervals into one and output the result which should have only mutually exclusive intervalsGiven set of interval is {{12, 14}, {11, 13}, {20, 22}, {21, 23}} thenInterval {12, 14} and {11, 13} overlap with each other hence ... Read More

Merge Sort for Doubly Linked List using C++.

Narendra Kumar

Narendra Kumar

Updated on 31-Oct-2019 06:24:22

402 Views

Problem statementGiven a doubly linked list. Sort it using merge sort algorithmList: 10->20->8-17->5->13->4 Sorted list: 4->5->8->10->13->17->20Algorithm1. If head is NULL or list contains only one element then return list 2. Create two lists by dividing original list into 2 parts 3. Sort first and second part of list 4. Merge ... Read More

Merge Sort for Linked Lists using C++.

Narendra Kumar

Narendra Kumar

Updated on 31-Oct-2019 06:21:00

162 Views

Problem statementGiven a linked list. Sort it using merge sort algorithmList: 10->20->8-17->5->13->4 Sorted list: 4->5->8->10->13->17->20Algorithm1. If head is NULL or list contains only one element then return list 2. Create two lists by dividing original list into 2 parts 3. Sort first and second part of list 4. Merge both ... Read More

Merge two binary Max Heaps using C++.

Narendra Kumar

Narendra Kumar

Updated on 31-Oct-2019 06:18:19

163 Views

Problem statementGiven two binary max heaps as arrays, merge the into single max heap.Heap1[] = {20, 17, 15, 10} Heap2[] = {19, 13, 7} Result[] = {20, 19, 15, 13, 17, 7, 10}Algorithm1.Create an array to store result 2. Copy both given arrays one by one to result array 3. ... Read More

Merge two sorted arrays using C++.

Narendra Kumar

Narendra Kumar

Updated on 31-Oct-2019 06:14:58

2K+ Views

Problem statementGiven 2 sorted arrays list. Write a function to merge given two sorted arrays into oneArr1[] = {10, 15, 17, 20} Arr2[] = {5, 9, 13, 19} Result[] = {5, 9, 10, 13, 15, 17, 19, 20}Algorithm1. Traverse both array    1.1. If arr1[i] < arr2[j]       ... Read More

Merge two sorted linked lists using C++.

Narendra Kumar

Narendra Kumar

Updated on 31-Oct-2019 06:12:11

2K+ Views

Problem statementGiven 2 sorted singly linked list. Write a function to merge given two sorted linked listsList1: 10->15->17->20 List2: 5->9->13->19 Result: 5->9->10->13->15->17->19->20Algorithm1. Traverse both lists    1.1. If list1->data < list2->data       1.1.1 Add list1->data to new list and increment list1 pointer    1.2 If list2->data < list1->data ... Read More

Merging elements of two different arrays alternatively in third array in C++.

Narendra Kumar

Narendra Kumar

Updated on 31-Oct-2019 06:09:34

622 Views

Problem statementGiven two arrays, we need to combine two arrays in such a way that the combined array has alternate elements of the first and second array. If one of the arrays has an extra element, then these elements should be appended at the end of the combined array.arr1[] = ... Read More

Merging two unsorted arrays in sorted order in C++.

Narendra Kumar

Narendra Kumar

Updated on 31-Oct-2019 06:03:10

324 Views

Problem statementWrite a function that takes two unsorted arrays and merges them into a new array in sorted order.arr1[] = {10, 5, 7, 2} arr2[] = {4, 17, 9, 3} result[] = {2, 3, 4, 5, 7, 9, 10, 17}Algorithm1. Merge two unsorted array into new array 2. Sort newly ... Read More

Advertisements