Skip to main content

Posts

Python Insertion Sort

Here you’ll learn about Python insertion sort algorithm. In terms of performance Insertion sort is not the best sorting algorithm. But it is little bit more efficient then the Selection sort and Bubble sort. To understand the Insertion Sort algorithm easily, we’ll start with an example. Also Read:  Python Selection Sort Python Insertion Sort Example Let’s say we have an array [14,5,18,6,21]. Assume that we have two parts in this array first one is sorted and another one is unsorted. The  sorted part of array is in the left of orange line and unsorted part is in the right side. Now all we have to do is pick each element one by one from the unsorted part and add it into the sorted array at its appropriate place. 14 is the only element in our sorted part so it is already sorted. Now pick the first element from the unsorted part and add it to the sorted part. As 5 is less than 14 so 14 have to right shift by one place. Again pick first element from unsorted part an...

C++ Variables

In this section we will be studying the concepts of variables in C++ programming language. We hope you guys must have heard about variables in C or somewhere else. Though it is not a very complex topic to discuss in detail but let’s see what we have to say for this. C++ Variables We can see a variable as a ‘source of storage with some name’, which our programs can use for modification or manipulation. There is always a type associated with each variable which we need to specify at the starting of the program during variable declaration or we can also specify the type of the variable during initialization of that particular variable. The type of a variable determines the size of the variable’s memory ( i.e. how many bits can be accommodated within), layout of the memory, range of values that can be stored and the set of instructions that are permissible to be applied over the variable. Things to keep in mind when naming a variable: Digits, letters and an underscore character is ...

Introduction to Machine Learning (ML)

Here you will get introduction to machine learning. Hello there. Many of you must be aware of this term but some might be wondering what the heck is this? Another technical jargon only? Let’s make this simple for you, Machine Learning is made up of two different words Machine and Learning which literally means “making machines learn”. Again how is this possible? We would talk about this later in this very post. Stay tuned. Image Source If you eager to know some interesting points about Machine Learning (ML) we’ve got you covered. Let’s dive deeper. ML is a vast field and very often related with AI (Artificial Intelligence), whereas some people use these two terms interchangeably. But according to data scientists these two are quite distinct from each other in many aspects. In other words ML is a subset of AI. Real Life Machine Learning (ML) Examples Example 1: We all use email services of Gmail on almost regular basis, but have you ever wondered why is there a section named ‘...

Python Selection Sort

Here you’ll learn about python selection sort algorithm with program example. Selection sort is one of the easiest sorting algorithm out there. In Selection sort, to sort an unsorted array, all we have to do is find the minimum in the array and swap it with the first element in the unsorted array. After each swapping increase the starting index of the array by one. This is for sorting in ascending order. If we want to sort it into descending order find the maximum instead of minimum and replace with the first element in unsorted array. Python Selection Sort Example We have an unsorted array- [4,8,19,2,28,21] Step 1: Step 2: Step 3: Step 4: Step 5: Step 6: Algorithm If we have an array of n elements. Step 1:- set MIN = 0 Step 2:- find minimum element in array If exists then swap with element at MIN Step 3:-  increase MIN by 1 Step 4:-  go to Step 2 until  array is sorted (for n-1 times) Time Complexity Best Case = O(n) 2 Average Case = O(n)...

Lightweight bundling, minifying, and compression, for CSS and JavaScript with ASP.NET Core and Smidge

Yesterday I blogged about WebOptimizer, a minifier that Mads Kristensen wrote for ASP.NET Core. A few people mentioned that Shannon Deminick also had a great minifier for ASP.NET Core. Shannon has a number of great libraries on his GitHub https://github.com/Shazwazza including not just " Smidge " but also Examine, an indexing system , ClientDependency for managing all your client side assets , and Articulate, a blog engine built on Umbraco . Often when there's more than one way to do things, but one of the ways is made by a Microsoft employee like Mads - even if it's in his spare time - it can feel like inside baseball or an unfair advantage. The same would apply if I made a node.js library but a node.js core committer also made a similar one. Many things can affect whether an open source library "pops," and it's not always merit. Sometimes it's locale/location, niceness of docs, marketing, word of mouth, website. Both Mads and Shannon and a doze...

C++ STL Unordered Map – std::unordered_map

In this tutorial you will learn about stl unordered map container i.e. std::unordered_map and all functions applicable on it. By its name we can say that it comes under Associative containers with Unordered property. We know that any unordered container internally implemented with hash tables. So same has hashing concept in worst case any operation takes O(n) time and in average and best case it takes O(1) time. We can say it vary based on type of hash function we used. With comparison to map containers these work efficiently to find value by using key. And one main difference is that map elements are order but unordered map elements are not in order. Since it is based on key-value pair concept all keys must be unique. C++ STL Unordered Map – std::unordered_map Iterators that can be applicable on Unordered map: begin(): returns iterator to the beginning end(): returns iterator to the end of the container. cbegin(): Returns constant iterator to the beginning. cend(): Returns ...

WebOptimizer - a Bundler and Minifier for ASP.NET Core

ASP.NET Core didn't have a runtime bundler like previous versions of ASP.NET. This was a bummer as I was a fan. Fortunately Mads Kristensen created one and put it on GitHub, called WebOptimizer . WebOptimizer - ASP.NET Core middleware for bundling and minification of CSS and JavaScript files at runtime. With full server-side and client-side caching to ensure high performance. I'll try it out on a default ASP.NET Core 2.0 app. First, assuming I've installed http://dot.net I'll run C:\Users\scott\Desktop> cd squishyweb C:\Users\scott\Desktop\squishyweb> dotnet new mvc The template "ASP.NET Core Web App (Model-View-Controller)" was created successfully. This template contains technologies from parties other than Microsoft, see https://aka.ms/template-3pn for details. SNIP Restore succeeded. Then I'll add a reference to the WebOptimizer package . Be sure to check the versioning and pick the one you want, or use the latest. C:\Users\scott\Desk...