Heap sort is a comparison based sorting technique on binary heap data structure. It is similar to selection sort in which we first find the maximum element and put it at the end of the data structure. Then repeat the same process for the remaining items.
Pseudo code for Heap Sort:
function heapsor...
There are quite a number situations where one has huge amounts of data and using which he has to classify an object in to one of several known classes. Consider the following situations:
Banking: When a bank receives a request from a customer for a bankcard, the bank has to decide whether to issue...
Uses C standard format codes.
from datetime import datetime
datetime_for_string = datetime(2016,10,1,0,0)
datetime_string_format = '%b %d %Y, %H:%M:%S'
datetime.strftime(datetime_for_string,datetime_string_format)
# Oct 01 2016, 00:00:00
malloc() often calls underlying operating system functions to obtain pages of memory. But there is nothing special about the function and it can be implemented in straight C by declaring a large static array and allocating from it (there is a slight difficulty in ensuring correct alignment, in pract...
Let's say we have 8 houses. We want to setup telephone lines between these houses. The edge between the houses represent the cost of setting line between two houses.
Our task is to set up lines in such a way that all the houses are connected and the cost of setting up the whole connection is mini...
FullCalendar can be downloaded from it's website: https://fullcalendar.io/download/
from NPM:
$ npm install fullcalendar
from Bower:
$ bower install fullcalendar
or CDNJS:
//cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.0.1/fullcalendar.min.js
//cdnjs.cloudflare.com/ajax/libs/fullca...
After enabling and creating migrations there might be a need to initially fill or migrate data in your database. There are several possibilities but for simple migrations you can use the method 'Seed()' in the file Configuration created after calling enable-migrations.
The Seed() function retrieves...
class Program
{
static void Main(string[] args)
{
//Initialize a new container
WindsorContainer container = new WindsorContainer();
//Register IService with a specific implementation and supply its dependencies
container.Register(Component.For<ISer...
When run with no arguments, this program starts a TCP socket server that listens for connections to 127.0.0.1 on port 5000. The server handles each connection in a separate thread.
When run with the -c argument, this program connects to the server, reads the client list, and prints it out. The clie...
Find f(n): nth Fibonacci number. The problem is quite easy when n is relatively small. We can use simple recursion, f(n) = f(n-1) + f(n-2), or we can use dynamic programming approach to avoid the calculation of same function over and over again. But what will you do if the problem says, Given 0 <...
Sometimes we want to use a where query on a a collection of records returned which is not ActiveRecord::Relation.Hence we get the above error as Where clause is know to ActiveRecord and not to Array.
There is a precise solution for this by using Joins.
EXAMPLE:-
Suppose i need to find all user ...
Important: Be sure to set up the server-side implementation as per the instructions here, otherwise uploads will not work.
To get started, create a new HTML document. Download the script as per the "Installation" example, and include it in your head tag like so (remebering to replace the ...
Consider the following Java classes:
class Foo {
private Bar bar;
public void foo() {
bar.baz();
}
}
As can be seen, the class Foo needs to call the method baz on an instance of another class Bar for its method foo to work successfully. Bar is said to be a dependency for Foo sin...
The same examples as shown above with XML configuration can be re-written with Java configuration as follows.
Constructor injection
@Configuration
class AppConfig {
@Bean
public Bar bar() { return new Bar(); }
@Bean
public Foo foo() { return new Foo(bar()); }
}
Property in...
Dependencies can be autowired when using the component scan feature of the Spring framework. For autowiring to work, the following XML configuration must be made:
<context:annotation-config/>
<context:component-scan base-package="[base package]"/>
where, base-package is th...
Constructor injection through Java configuration can also utilize autowiring, such as:
@Configuration
class AppConfig {
@Bean
public Bar bar() { return new Bar(); }
@Bean
public Foo foo(Bar bar) { return new Foo(bar); }
}
Calls to the Metadata API are with HTTP Get:
Using Public API Key
GET https://www.googleapis.com/analytics/v3/metadata/ga/columns?key={YOUR_API_KEY}
Using Access token from either Oauth2 or Service account authentication
GET https://www.googleapis.com/analytics/v3/metadata/ga/columns?acces...