Windows Shortcurts tricks

I have been always wondered how the shortcuts exactly work in Windows when you create a shortcut and then move the target file to some location or just rename it.

“Everything genius is simple”

Remember?

This feature of tracking the target file changes is implemented as the windows service called “Distributed Link Tracking Client “. Let’s consider the following cases:

1. Service is running

I created test.txt, new folder, and the shortcut to test.txt as below

Image

Next I moved test.txt to the New folder and double click the shortcut on the desktop.

ImageIt works just fine, as designed.

2. Service is stopped

Performing exactly the same actions, we got the following:

It’s obviously, right?:)

Posted in Random thoughts on IT | Leave a comment

“How Would You Move Mount Fuji?” by William Poundstone

How Would You Move Mount Fuji?

How Would You Move Mount Fuji?

A fun, revealing take on an unusual subject…. At once a study of corporate hiring, an assessment of IQ testing’s value, a history of interviewing, and a puzzle book.
Publishers Weekly

Posted in Programming tasks, puzzles and riddles | Leave a comment

.NET Data structures 101

Data structures and algorithms are basis in computing field. Everybody in the university has a course which devotes to various data structures. It is not really difficult course, but it is one of the MUST TO KNOW FOR LIFE course.

Everybody knows what are Array, Linked List, Queue, Stack, BT, etc, but in real life they ain’t used implicitly, mostly wrappers are used, but the problem is that there are a lot of various wrappers like ArrayList, List<T> or Hashtable, Dictionary<T, T> and it is important to understand the difference among them and use them in apropriate way. Using wrappers ofthen makes us forget about fundametals and more often we don’t know the difference, which leads to a low performance. We often choose not appropriate wrapper, because we don’t clearly know (or smth don’t know at all) what is inside of selected one, because some wrappers  looks really similar and we don’t care about the difference and insights. Digging thru source code is very boring and I always wanted to find an article that describes an insights of base .NET data structures and eventually I faced with this worthless article An Extensive Examination of Data Structures, that contains information about base .net data structures, divided in six articles, below:

  1. Part 1: An Introduction to Data Sturctures
  2. Part 2: The Queue, Stack, and Hashtable
  3. Part 3: Binary Trees and BSTs
  4. Part 4: Building a Better Binary Search Tree
  5. Part 5: From Trees to Graphs
  6. Part 6: Efficiently Representing Sets

Have a nice programming!

Posted in Programming tasks, puzzles and riddles | Leave a comment

Programming task: Finding Duplicate Elements in an Array

Task:

Given an array t[100] which contains numbers between 1..99. Return the duplicated value. Try both O(n) and O(n-square).

Eplanation:

This is the best article on “Finding duplicate elements in an Array”. Many thanks to an author.

Posted in Programming tasks, puzzles and riddles | Leave a comment

“A collection of technical interview questions” book by www.spellscroll.com

Hi! Just faced with a great compilation of programming tasks, riddles, puzzles, call it whatever. The book names is “A collection of technical interview questions” book by www.spellscroll.com

Posted in Programming tasks, puzzles and riddles | Leave a comment

Nested structure layout problem

Few days ago I wrote a sample C# code that performs breadth first traversal of a binary search tree, I started from the very begining and I decided to use structure instead of class to define Node of the tree in orderd to save memory:


struct Node
{
public Node Parent
{ get; set; }
public Node Left
{ get; set; }
public Node Right
{ get; set; }
public int Key
{ get; set; }
}

and eventually I got a compile error, that stated:

Struct member 'Node.Parent' of type 'Node' causes a cycle in the struct layout

, but if shift example to class, then it compiles successfully.

As I understood lately, structure is value type and once runtime initializes it, it calls default constructor and initializes its fields, but as so as there is a field that has the same type as structure has and it cannot be not null (because it is a value type), runtime would go to recursion while initializing it, but compiler prevents it, showing an error. In case we use class instead of structure all fields will automaticaly have null values, if it wasn’t initialized precisely.

Posted in Programming tasks, puzzles and riddles | 1 Comment

Programming task: Maximum sum of neighboring elements in the set

maxsofar = 0
maxendinghere = 0
for i = 0 to n-1
maxendinghere = max(maxendinghere + x[i], x[i])
maxsofar = max(maxendinghere, maxsofar)

Posted in Programming tasks, puzzles and riddles | Leave a comment