Comparison of Data structures and Python support

Comparison between different data structures  Each data structure has it’s own different way, or different algorithm for sorting, inserting, finding, …etc. This is due to the nature of the data structure. There are algorithms used with specific data structure, where some other can’t be used. The more efficient & suitable the algorithm, the more you … Continue reading Comparison of Data structures and Python support

What Is A Data Structure?

When we have a programming problem, we dive into the algorithm, while ignoring the underlying data structure. And even worse, we think that using another data structure won’t make much of a difference, although we could vastly improve the performance of our code by picking an alternative data structure. This post is gonna be long. … Continue reading What Is A Data Structure?

Google Coding Problem- #001

Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use the same element twice.Example:Given nums = [2, 7, 11, 15], target = 9,Because nums[0] + nums[1] = 2 + 7 … Continue reading Google Coding Problem- #001

Kadane’s algorithm – (Largest Sum Contiguous Sub-array)

Kadane’s algorithm is to look for all positive contiguous segments of the array (max_ending_here is used for this). And keep track of maximum sum contiguous segment among all positive segments (max_so_far is used for this). Each time we get a positive sum compare it with max_so_far and update max_so_far if it is greater than max_so_far … Continue reading Kadane’s algorithm – (Largest Sum Contiguous Sub-array)

Sorting Algorithm

A Sorting Algorithm is used to rearrange a given array or list elements according to a comparison operator on the elements. The comparison operator is used to decide the new order of element in the respective data structure. Selection Sort The selection sort algorithm sorts an array by repeatedly finding the minimum element (considering ascending … Continue reading Sorting Algorithm

Fibonacci Search

Fibonacci Search is a comparison-based technique that uses Fibonacci numbers to search an element in a sorted array. Similarities with Binary Search: Works for sorted arrays A Divide and Conquer Algorithm. Has Log n time complexity. Differences with Binary Search: Fibonacci Search divides given array in unequal partsBinary Search uses division operator to divide range. … Continue reading Fibonacci Search