Today's Question:  What does your personal desk look like?        GIVE A SHOUT

SEARCH KEYWORD -- Implementation



  Algorithm: Traverse binary tree

Preface There are three ways to traverse a binary tree based on the traversing order. Pre-Order: Root - Left - Right In-Order: Left - Root - Right Post-Order: Left - Right - Root Take below binary tree as example The node to be traversed in different order would be Pre-Order: A - B - C - D - E - F In-Order: C - B - D - A - E - F Post-Order: C - D - B - F - E - A Below are the implementations of different orders for traversing the binary tree. Pre-Order Traversing Recursive implementation N...

   ALGORITHM,BINARY TREE     2019-03-01 22:49:04

  Hexadecimal and long in Java

Today I encountered a hexadecimal operation problem when I was implementing a bit reverse function for integer type. Basically in the implementation, there is an operation which is to do the bit operation & between one long integer and a hexadecimal number 0x00000000FFFFFFFFF. I was expecting that the high 32 bits of the long integer will be zeroed. But unfortunately I didn't get the expected result. The basic implementation is: long num=0x00F0_0000; num = (num>>16) | (num<<16); ...

   Hexadecimal,long,Java,bitwise operation     2014-06-18 23:44:32

  Ensuring Go Interface Implementation: A Quick Guide

Introduction Go's simplicity and power shine in its interface system, offering a clean way to define contracts between types. However, when it comes to checking whether a struct satisfies an interface, Go's static typing philosophy means there isn't a direct runtime check. In this concise guide, we'll explore practical methods, including some lesser-known tricks, to verify whether a struct implements an interface. Method 1: Type Assertion and a Dummy Method package main import "fmt" type MyInt...

   INTERFACE,GOLANG,IMPLEMENTS     2023-11-25 21:36:01

  How to check whether a struct implements an interface in GoLang

Unlike other programming languages like Java, when implementing an interface in GoLang, there is no syntax like below to explicit tell the relationship: type I interface { } type A struct implements I { } When looking at the code or running the code in GoLang, it might lead to a case one doesn't know whether a struct implements interface before trying to use it as some interface. According to GoLang spec, as long as a struct implements all functions of an interface, it is considered as having i...

   GOLANG,INTERFACE,IMPLEMENTATION,CHECK     2020-05-03 00:05:54

  Java AbstractMethodError explained and demonstrated

According to Oracle Java API documentation, AbstractMethodError is a kind of runtime error where the application is having some incompatible changes which leads to a missing implementation of an abstract method. Below is the official description. Thrown when an application tries to call an abstract method. Normally, this error is caught by the compiler; this error can only occur at run time if the definition of some class has incompatibly changed since the currently executing method was last co...

   JAVA,ABSTRACTMETHODERROR     2016-07-22 22:03:20

  Implementation of Tower of Hanoi

The Tower of Hanoi is a mathematical game or puzzle. It consists of three rods, and a number of disks of different sizes which can slide onto any rod. The puzzle starts with the disks in a neat stack in ascending order of size on one rod, the smallest at the top, thus making a conical shape. The objective of the puzzle is to move the entire stack to another rod, obeying the following rules: Only one disk may be moved at a time. Each move consists of taking the upper disk fro...

   Algorithm,Tower of Hanoi     2012-08-20 02:15:55

  The 9 lines of code of Google

Are you still remembering the then hot debated news about Oracle suing Google allegedly copying a small portion of codes from Oracle's Java in 2010. At that time, Oracle experts estimated that Google owes Oracle between $1.4 billion and $6 billion in damages if liable. But the court thought Oracle was eligible only for statutory damages for that copying, which were not expected to exceed a few hundred thousand dollars. At last, Oracle agreed the zero damage result. Are you curious about whi...

   Google,Java,Open source     2014-08-15 20:29:52

  Java API vs Framework

What is the difference between a Java Library and a framework? The two concepts are essentially important for a Java developer. The most important difference between a library and a framework is Inversion of Control. It means that when you call a library you are in control. But with a framework, the control is inverted: the framework calls you. (This is called the Hollywood Principle: Don’t call Us, We’ll call You.) This is pretty much the definition of a framework. Basicall...

   Difference,API,Framework,Library,Java     2011-12-19 13:40:33

  Sort an array with only one local variable

Array sorting algorithm question is frequently asked during technical interviews. There are lots of sort algorithms including bubble sort, selection sort, insertion sort, quick sort, merge sort etc. Usually interviewees will be asked to implement sort algorithms. But have you ever been asked to sort an array which you are allowed to define ONLY ONE local variable in your algorithm?  Bubble sort can be used to do this actually. Normally a bubble sort algorithm may need three local ...

   JAVASCRIPT,ALGORITHM,SORTING,BUBBLE SORT     2016-10-07 09:46:49

  Google plans to deprecate FTP URL support in Chrome

Currently people can access FTP list and download resources hosted on FTP servers in Chrome through FTP URLs, but this may not work anymore in the near future. In a post published by Chrome engineers, there is a plan to deprecate FTP support in Chrome version 82. The major motivation for this deprecation is that Chrome doesn't have an encrypted FTP connection support(FTPs), this raises security risk of downloading resources over FTP. Since users can access FTP URLs and download resources, there...

   CHROME 82,CHROME,FTP     2019-08-16 21:35:02