Table of contents Recursive exponential Recursive max Recursive multiplication Recursive sum Recursive average Recursive uppercase Recursive exponential Given two exponential numbers with the same base, the multiplication is another exponential number with the same base but we add the exponents. We can utilize this observation and define a recursive exponential formula. If (n) is even
Problem Implement merge sort algorithm in Python. Solution For definition and explanation, You may refer to the following post. This post is just a rewrite in Python. Before jumping directly to the code, check out the following nice YouTube clip Recursive merge sort in python Take a look at the comments for explanation… Thanks for
Introduction Today, I am going to dive into the awesome world of sorting. It reminds me with entry level computer science courses and algorithm design. The goal of this article is to summarize popular sorting algorithms and put it in one place so that it is easy to remember and refer to. My intention is
Introduction This short article is mainly for students, software engineers and those who are struggling to get a grip on the subject. In other words I will not be focusing on the theoretical side of the topic. I will first explain what Dynamic Programming means then provide several examples to demonstrate this algorithmic technique. I
Merging Two Arrays Problem Given two sorted arrays A and B of different sizes m and n. Describe an algorithm to combine the two arrays into one array. The output array must not have duplicates. The output array must maintain the original order of values in A and B Solution If you recall the well
What is Recursion: Please Bear with me This is going to be a short and technical article so please bear with my bad English and writing style. Language is also a mean of communication and sometimes it fails to convey understanding so I will brain dump the concept in plain English to the best of
Problem Write a recursive function to compute (x) to the power of (n) where (x) and (n) are positive integers. Your algorithm should run in O(logn) time complexity Solution Use divide and conquer technique. For even values of (n) calculate x^(n/2) and return the square of that as the final result because x^n = x^(n/2)
Problem Given an array of positive integers. Write an iterative version of binary search to find an element in the array Solution Binary search can be easily implemented using recursion due to the divide and conquer nature of the algorithm however we can also do it using iteration. Please refer to the code below for
Divide and conquer largest two numbers problem Given an array of integers. Find the first and second largest elements in the array. Use divide and conquer technique. Divide and conquer algorithm largest two elements Simply divide the array into two halves then find the largest two elements in each half. At the end you need
Merge sort c++ string Given a character string in small letter case. Write a C++ function to sort the string using Merge Sort Algorithm. Merge sort c++ implementation Merge sort is a popular sorting algorithm that runs in O(nlogn). It uses divide and concur technique so it keeps dividing the input array into two halves